PHP Code:
class QuestCurtain(ui.Window):
CURTAIN_TIME = 0.25
CURTAIN_SPEED = 200
BarHeight = 60
OnDoneEventList = []
def __init__(self,layer="TOP_MOST"):
ui.Window.__init__(self,layer)
self.TopBar = ui.Bar("TOP_MOST")
self.BottomBar = ui.Bar("TOP_MOST")
self.TopBar.Show()
self.BottomBar.Show()
self.TopBar.SetColor(0xff000000)
self.BottomBar.SetColor(0xff000000)
self.TopBar.SetPosition(0,-self.BarHeight)
self.TopBar.SetSize(wndMgr.GetScreenWidth(),self.BarHeight)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight())
self.BottomBar.SetSize(wndMgr.GetScreenWidth(),self.BarHeight)
self.CurtainMode = 0
self.lastclock = time.clock()
def Close(self):
self.CurtainMode = 0
self.TopBar.SetPosition(0, -self.BarHeight-1)
self.BottomBar.SetPosition(0, wndMgr.GetScreenHeight()+1)
for OnDoneEvent in QuestCurtain.OnDoneEventList:
apply(OnDoneEvent,(self,))
QuestCurtain.OnDoneEventList = []
def OnUpdate(self):
dt = time.clock() - self.lastclock
if self.CurtainMode>0:
self.TopBar.SetPosition(0, int(self.TopBar.GetGlobalPosition()[1]+dt*self.CURTAIN_SPEED))
self.BottomBar.SetPosition(0, int(self.BottomBar.GetGlobalPosition()[1]-dt*self.CURTAIN_SPEED))
if self.TopBar.GetGlobalPosition()[1]>0:
self.TopBar.SetPosition(0,0)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight()-self.BarHeight)
self.CurtainMode = 0
elif self.CurtainMode<0:
self.TopBar.SetPosition(0, int(self.TopBar.GetGlobalPosition()[1]-dt*self.CURTAIN_SPEED))
self.BottomBar.SetPosition(0, int(self.BottomBar.GetGlobalPosition()[1]+dt*self.CURTAIN_SPEED))
if self.TopBar.GetGlobalPosition()[1]<-self.BarHeight:
self.TopBar.SetPosition(0,-self.BarHeight-1)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight()+1)
self.Close()
self.lastclock = time.clock()