Page 1 of 1

level bar behaviour at loading saved game

Posted: Fri Jun 06, 2014 4:35 pm
by cieply
when loading saved game level bar behaves quite strangely - it starts to update its position from zero or from max position

Image

it looks horrible
and is unprofessional... L)

in my attempt to sort it I wanted to change it just before SaveGame loading finishes so I could change it to for example 0.01 [s] (default==1.5[s]) and then after let's say 2 seconds back to normal

I implemented delay factor in widget responsible for this but now I don't know when exactly SavGame loading is finished it would be obvious workaround, I know but I don't have better idea

maybe it's possible to do it better

@ Lib/Widgets/ScorerWidgets.py

### original Lib/Widgets/ScorerWidgets.py

Code: Select all

  def SetPosition(self,pos,smooth=1):
    currpos=self.GetPosition()
    if currpos==pos:
      return

    if smooth:
      if self.Updating==1:
        if self.CurrentTarget!=pos:
          #Si ya estß actualizando y recibe una nueva petici¾n para otra posici¾n
          # Trata de atenderla mßs tarde
          Bladex.AddScheduledFunc(Bladex.GetTime()+1.5,self.SetPosition,(pos,1))
          print "Posponed SetPosition",pos,smooth
          return
      else:
        self.Updating=1
        self.CurrentTarget=pos
        now=Bladex.GetTime()
        #print "Updating level bar: now:",now,"pos:",pos,"currpos:",currpos
        m_interp=BarIncClass(currpos,pos,self)
        self.interpolator.AddAction(now,now+1.5,m_interp)
    else:
      BUIx.B_BarWidget.SetPosition(self,pos)
### new

Code: Select all

  def SetPosition(self,pos,smooth=1):
    currpos=self.GetPosition()
    if currpos==pos:
      return
    ## delay factor:
    delay = Reference.SMOOTHBARWIDGET_DELAY

    if smooth:
      if self.Updating==1:
        if self.CurrentTarget!=pos:
          #Si ya estß actualizando y recibe una nueva petici¾n para otra posici¾n
          # Trata de atenderla mßs tarde
          Bladex.AddScheduledFunc(Bladex.GetTime()+delay, self.SetPosition, (pos,1))
          print "Posponed SetPosition",pos,smooth
          return
      else:
        self.Updating=1
        self.CurrentTarget=pos
        now=Bladex.GetTime()
        print "Updating level bar: now:",now,"pos:",pos,"currpos:",currpos
        m_interp=BarIncClass(currpos,pos,self)
        self.interpolator.AddAction(now, now+delay, m_interp)
    else:
      BUIx.B_BarWidget.SetPosition(self,pos)

and in Lib/Reference.py

Code: Select all

# @ Lib/Widgets/ScorerWidgets::B_SmoothBarWidget
SMOOTHBARWIDGET_DELAY=1.5
someone has idea how to sort it

why it doesn't work?

Posted: Sun Jun 08, 2014 2:15 pm
by cieply
there is a function to change delay

Code: Select all

# @ Lib/Widgets/ScorerWidgets::B_SmoothBarWidget
SMOOTHBARWIDGET_DELAY=1.5
##
def SmoothBarWidget_delay(delay=None):
	global SMOOTHBARWIDGET_DELAY
	if (delay==None):
		return SMOOTHBARWIDGET_DELAY
	SMOOTHBARWIDGET_DELAY = delay
##
and in theory it should work like that:

Code: Select all

Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, Reference.SmoothBarWidget_delay, (1.5))
but it doesn't
what's wrong?

Re: level bar behaviour at loading saved game

Posted: Mon Jun 09, 2014 7:03 am
by cieply
your wild guess is right but I know that, question is how to improve it

actually I solved it but without scheduling change of parameter it's useless at the moment
so question is why this:
Bladex.AddScheduledFunc(Bladex.GetTime()+5.0, Reference.SmoothBarWidget_delay, (1.5))
doesn't work?