Mali61

python Loading Gauge Improvement

12 posts in this topic

First one, thanks for release and good idea, here are some advices for the next time, how you should use zip method and lambda instead of __mem__func__ and others empty functions.

  • Since the loadStepList is declared with ascending numbers from 0 to 100 (by default), we don't have to use min and max method for get the values for range, just the first value and the last value from list.
  • __mem_func__ and the function 'bos' are useless in that case, we can replace it with a null lambda, will do the same job too.
  • Using an list comprehension with conditions inside, isn't so readable.

Good idea for zip method to get all the progresses values, but we don't need to initialize like that, you can acces the first reference by using index [0] from iterator.

Spoiler

# checkin, _ = zip(*self.loadStepList)

lst = [[1, None], [2, None]]
first, second = zip(*lst)
print (first, second)
>>> (1, 3) (None, None)

lst = [[1, None], [2, None]]
first = tuple(zip(*lst))[0]
print (first)
>>> (1, 3)

# I would use a bitwise and set method to get the missing values without doing a check for progress value.
print (list(set([0, 2]) ^ set([0, 1, 2, 3, 4, 5])))
>>> [1, 3, 4, 5]

 

 

On 5/25/2019 at 12:03 AM, Mali61 said:

def bos(self):
	pass

checkin, _ = zip(*self.loadStepList)
self.loadStepList = sorted(self.loadStepList+[(i, ui.__mem_func__(self.bos)) for i in range(min(checkin), max(checkin)+1) if i not in checkin])

Should look like this:

tmpLoadStepList = tuple(zip(*self.loadStepList))[0]
for progress in range(tmpLoadStepList[0], tmpLoadStepList[-1] + 1):
	if progress not in tmpLoadStepList:
		self.loadStepList.append((progress, lambda: None))
	
self.loadStepList.sort()
  • Like 6
  • Thanks 1
  • Sad 1

Share this post


Link to post
Share on other sites

Thanks for your support :) I'm not a python developer like you. I will edit topic in a short time.

Edit:Updated

  • Like 2

Share this post


Link to post
Share on other sites

Thanks a lot! cool stuff but i have expanded loading bar which is barely larger it loads just to 70% of gauge then it enters the game. Since im new to python i do not know how to solve it. 

Could you guys help me please?

Share this post


Link to post
Share on other sites
18 minutes ago, flexivk123 said:

Thanks a lot! cool stuff but i have expanded loading bar which is barely larger it loads just to 70% of gauge then it enters the game. Since im new to python i do not know how to solve it. 

Could you guys help me please?

I think you are looking for:

Quote

self.loadingGage.SetPercentage(p, 160)

Change 160 for your gauge

  • Thanks 1

Share this post


Link to post
Share on other sites

 @VegaS™ I got  some error with this improvement:

Spoiler

1001 20:48:17180 :: Traceback (most recent call last):

1001 20:48:17180 ::   File "introLoading.py", line 287, in OnUpdate

1001 20:48:17181 ::   File "introLoading.py", line 196, in __SetProgress

1001 20:48:17181 :: KeyError
1001 20:48:17181 :: : 
0929 11:34:15143 :: 1 (load progress number so in sysser it's showing key errors from 1 to 99)
0929 11:34:15143 :: 

 

 

Share this post


Link to post
Share on other sites

@ReFresh  You used a small extension which i did for you 3 years ago.

Spoiler

If somebody still have this problem, you need to check the key of the dictionary like:

def __SetProgress(self, progress):
	if self.loadingGage:
		self.loadingGage.SetPercentage(progress, 160)
		  
		# START_OF_SHOWING_PROGRESS_TEXT
		if progress in self.txtLoadingProgressDict:
			self.loadingInfo.SetText("Loading: %s" % self.txtLoadingProgressDict[progress])
		# END_OF_SHOWING_PROGRESS_TEXT

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/24/2019 at 11:49 PM, VegaS™ said:

tmpLoadStepList = tuple(zip(*self.loadStepList))[0]
for progress in range(tmpLoadStepList[0], tmpLoadStepList[-1] + 1):
	if progress not in tmpLoadStepList:
		self.loadStepList.append((progress, lambda: None))
	
self.loadStepList.sort()

 

There's a better version instead of what i did some time ago, which find the differences directly, without check each progress index.

tmpLoadStepList = tuple(zip(*self.loadStepList))[0]
for progress in set(range(tmpLoadStepList[0], tmpLoadStepList[-1] + 1)).difference(tmpLoadStepList):
	self.loadStepList.append((progress, lambda: None))

self.loadStepList.sort()

 

  • Like 7

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.