Poodletooth-iLand/toontown/toontowngui/ToontownLoadingScreen.py

79 lines
3.8 KiB
Python
Raw Normal View History

2015-08-02 18:48:08 -05:00
from pandac.PandaModules import *
2015-03-03 16:10:12 -06:00
from direct.gui.DirectGui import *
2015-08-02 18:48:08 -05:00
from toontown.toonbase import ToontownGlobals, TTLocalizer
2015-03-03 16:10:12 -06:00
from toontown.hood import ZoneUtil
import random
LOADING_SCREEN_SORT_INDEX = 4000
class ToontownLoadingScreen:
def __init__(self):
self.__expectedCount = 0
self.__count = 0
2015-08-22 17:33:08 -05:00
self.textures = [(loader.loadTexture('phase_3.5/maps/loading/toon.jpg'), ToontownGlobals.getInterfaceFont(), (0, 0, 0.5, 1)),
2015-08-02 18:48:08 -05:00
(loader.loadTexture('phase_3.5/maps/loading/cog.jpg'), ToontownGlobals.getSuitFont(), (1.0, 1.0, 1.0, 1)),
(loader.loadTexture('phase_3.5/maps/loading/default.jpg'), ToontownGlobals.getInterfaceFont(), (0, 0, 0.5, 1))
]
2015-03-03 16:10:12 -06:00
self.gui = loader.loadModel('phase_3/models/gui/progress-background.bam')
self.title = DirectLabel(guiId='ToontownLoadingScreenTitle', parent=self.gui, relief=None, pos=(base.a2dRight/5, 0, 0.235), text='', textMayChange=1, text_scale=0.08, text_fg=(0, 0, 0.5, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getInterfaceFont())
self.tip = DirectLabel(guiId='ToontownLoadingScreenTip', parent=self.gui, relief=None, pos=(0, 0, 0.045), text='', textMayChange=1, text_scale=0.05, text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_align=TextNode.ACenter)
2015-03-03 16:10:12 -06:00
self.waitBar = DirectWaitBar(guiId='ToontownLoadingScreenWaitBar', parent=self.gui, frameSize=(base.a2dLeft+(base.a2dRight/4.95), base.a2dRight-(base.a2dRight/4.95), -0.03, 0.03), pos=(0, 0, 0.15), text='')
logoScale = 0.5625 # Scale for our locked aspect ratio (2:1).
self.logo = OnscreenImage(
image='phase_3/maps/toontown-logo.png',
scale=(logoScale * 2.0, 1, logoScale))
self.logo.reparentTo(hidden)
self.logo.setTransparency(TransparencyAttrib.MAlpha)
scale = self.logo.getScale()
self.logo.setPos(0, 0, -scale[2])
def destroy(self):
self.tip.destroy()
2015-03-03 16:10:12 -06:00
self.title.destroy()
self.gui.removeNode()
self.logo.removeNode()
def getTip(self, tipCategory):
return TTLocalizer.TipTitle + ' ' + random.choice(TTLocalizer.TipDict.get(tipCategory))
2015-03-03 16:10:12 -06:00
def begin(self, range, label, gui, tipCategory, zoneId):
2015-08-02 18:48:08 -05:00
info = self.textures[ZoneUtil.isCogHQZone(zoneId) if zoneId else 2]
2015-03-03 16:10:12 -06:00
self.waitBar['range'] = range
self.title['text'] = label
self.__count = 0
self.__expectedCount = range
if gui:
self.waitBar['frameSize'] = (base.a2dLeft+(base.a2dRight/4.95), base.a2dRight-(base.a2dRight/4.95), -0.03, 0.03)
2015-08-02 18:48:08 -05:00
self.title['text_font'] = info[1]
self.title['text_fg'] = info[2]
2015-03-03 16:10:12 -06:00
self.title.reparentTo(base.a2dpBottomLeft, LOADING_SCREEN_SORT_INDEX)
self.title.setPos(base.a2dRight/5, 0, 0.235)
self.tip['text'] = self.getTip(tipCategory)
2015-03-03 16:10:12 -06:00
self.gui.setPos(0, -0.1, 0)
self.gui.reparentTo(aspect2d, LOADING_SCREEN_SORT_INDEX)
2015-08-02 18:48:08 -05:00
self.gui.setTexture(info[0], 1)
self.logo.reparentTo(base.a2dpTopCenter, LOADING_SCREEN_SORT_INDEX)
2015-03-03 16:10:12 -06:00
else:
self.title.reparentTo(base.a2dpBottomLeft, LOADING_SCREEN_SORT_INDEX)
self.gui.reparentTo(hidden)
self.logo.reparentTo(hidden)
self.tip.reparentTo(base.a2dpBottomCenter, LOADING_SCREEN_SORT_INDEX)
2015-03-03 16:10:12 -06:00
self.waitBar.reparentTo(base.a2dpBottomCenter, LOADING_SCREEN_SORT_INDEX)
self.waitBar.update(self.__count)
def end(self):
self.waitBar.finish()
self.waitBar.reparentTo(self.gui)
self.title.reparentTo(self.gui)
self.tip.reparentTo(self.gui)
2015-03-03 16:10:12 -06:00
self.gui.reparentTo(hidden)
self.logo.reparentTo(hidden)
return (self.__expectedCount, self.__count)
def abort(self):
self.gui.reparentTo(hidden)
def tick(self):
self.__count = self.__count + 1
2015-08-02 18:48:08 -05:00
self.waitBar.update(self.__count)