2015-03-22 22:44:12 +00:00
|
|
|
from pandac.PandaModules import *
|
2015-04-21 18:44:10 +00:00
|
|
|
from panda3d.core import NodePath, ModelNode
|
2015-03-22 22:44:12 +00:00
|
|
|
from direct.fsm import StateData
|
|
|
|
from direct.gui.DirectGui import *
|
|
|
|
from toontown.toonbase import TTLocalizer, ToontownGlobals
|
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
2015-04-21 18:44:10 +00:00
|
|
|
from toontown.toonbase import ToontownBattleGlobals
|
2015-03-22 22:44:12 +00:00
|
|
|
|
|
|
|
class TrackShop(StateData.StateData):
|
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('TrackShop')
|
|
|
|
|
|
|
|
def __init__(self, doneEvent):
|
|
|
|
StateData.StateData.__init__(self, doneEvent)
|
|
|
|
self.loaded = False
|
|
|
|
self.index = 0
|
2015-04-21 18:44:10 +00:00
|
|
|
self.buttonPath = None
|
|
|
|
self.curTrackLabel = None
|
2015-03-22 22:44:12 +00:00
|
|
|
return
|
|
|
|
|
2015-04-21 18:44:10 +00:00
|
|
|
def showButtons(self):
|
|
|
|
self.buttonPath.show()
|
|
|
|
self.curTrackLabel.show()
|
|
|
|
|
|
|
|
def hideButtons(self):
|
|
|
|
self.buttonPath.hide()
|
|
|
|
self.curTrackLabel.hide()
|
|
|
|
|
2015-03-22 22:44:12 +00:00
|
|
|
def enter(self):
|
|
|
|
base.disableMouse()
|
|
|
|
self.acceptOnce('last', self.__handleBackward)
|
|
|
|
self.acceptOnce('next', self.__handleForward)
|
|
|
|
|
|
|
|
def exit(self):
|
|
|
|
self.ignore('last')
|
|
|
|
self.ignore('next')
|
|
|
|
self.hideButtons()
|
|
|
|
|
|
|
|
def load(self):
|
|
|
|
if self.loaded:
|
|
|
|
return
|
|
|
|
self.loaded = True
|
|
|
|
|
2015-04-21 18:44:10 +00:00
|
|
|
buttonModel = ModelNode('tracks')
|
|
|
|
self.buttonPath = NodePath(buttonModel)
|
|
|
|
|
|
|
|
self.curTrackLabel = DirectLabel(aspect2d, relief=None,
|
|
|
|
text='toon-up', text_scale=0.12, text_font=ToontownGlobals.getSignFont(), text_fg=(1, 0, 0, 1),
|
|
|
|
pos=(0, 0, -0.9))
|
2015-03-22 22:44:12 +00:00
|
|
|
|
2015-04-21 18:44:10 +00:00
|
|
|
buttonImage = loader.loadModel("phase_3/models/gui/quit_button.bam")
|
2015-03-22 22:44:12 +00:00
|
|
|
|
2015-04-21 18:44:10 +00:00
|
|
|
availableTracks = [(0, 'toon-up'), (1, 'trap'), (2, 'lure'), (3, 'sound'), (4, 'drop')]
|
|
|
|
for i, track in reversed(availableTracks):
|
|
|
|
track = DirectButton(self.buttonPath, relief=None,
|
|
|
|
text=track, text_scale=0.08, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.03), text_fg=(1, 0, 0, 1),
|
|
|
|
pos=(0, 0, (i * 0.15) - 0.5),
|
|
|
|
image=(buttonImage.find('**/QuitBtn_UP'), buttonImage.find('**/QuitBtn_DN'), buttonImage.find('**/QuitBtn_RLVR')),
|
|
|
|
command=self.handleSetIndex, extraArgs=[i, track])
|
|
|
|
|
|
|
|
self.buttonPath.reparentTo(aspect2d)
|
2015-03-22 22:44:12 +00:00
|
|
|
|
|
|
|
def unload(self):
|
2015-04-21 18:44:10 +00:00
|
|
|
if self.buttonPath:
|
|
|
|
self.buttonPath.removeNode()
|
|
|
|
del self.buttonPath
|
|
|
|
if self.curTrackLabel:
|
|
|
|
self.curTrackLabel.removeNode()
|
|
|
|
del self.curTrackLabel
|
2015-03-22 22:44:12 +00:00
|
|
|
self.index = 0
|
|
|
|
self.loaded = False
|
|
|
|
|
2015-04-21 18:44:10 +00:00
|
|
|
def handleSetIndex(self, i, track):
|
|
|
|
self.index = i
|
|
|
|
self.curTrackLabel['text'] = track
|
2015-03-22 22:44:12 +00:00
|
|
|
|
|
|
|
def __handleForward(self):
|
|
|
|
self.doneStatus = 'next'
|
|
|
|
messenger.send(self.doneEvent)
|
|
|
|
|
|
|
|
def __handleBackward(self):
|
|
|
|
self.doneStatus = 'last'
|
|
|
|
messenger.send(self.doneEvent)
|