2015-05-27 08:07:12 -05:00
|
|
|
from pandac.PandaModules import *
|
|
|
|
from direct.gui.DirectGui import *
|
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
from toontown.toonbase import TTLocalizer
|
|
|
|
|
|
|
|
class BossLobbyGui(DirectFrame):
|
|
|
|
|
|
|
|
class InitialFrame(DirectFrame):
|
|
|
|
|
|
|
|
frame = 0
|
|
|
|
|
|
|
|
class LobbySelection(DirectButton):
|
|
|
|
|
|
|
|
def __init__(self, parent, **kw):
|
|
|
|
optiondefs = (
|
|
|
|
('relief', None, None),
|
|
|
|
('image_scale', 0.55, None),
|
|
|
|
('text_pos', (0.3, -0.0225), None),
|
|
|
|
('text_scale', 0.075, None),
|
|
|
|
)
|
|
|
|
self.defineoptions(kw, optiondefs)
|
|
|
|
DirectButton.__init__(self, relief=None)
|
|
|
|
self.initialiseoptions(BossLobbyGui.InitialFrame.LobbySelection)
|
|
|
|
|
|
|
|
def __init__(self, parent, callback, **kw):
|
|
|
|
optiondefs = (
|
|
|
|
('relief', None, None),
|
|
|
|
('state', DGG.NORMAL, None),
|
|
|
|
('image', DGG.getDefaultDialogGeom(), None),
|
|
|
|
('image_scale', (1.0, 1.0, 0.75), None),
|
|
|
|
('image_color', ToontownGlobals.GlobalDialogColor, None),
|
|
|
|
('pos', (0, 0, 0), None),
|
|
|
|
)
|
|
|
|
self.defineoptions(kw, optiondefs)
|
|
|
|
DirectFrame.__init__(self, relief=None)
|
|
|
|
self.initialiseoptions(BossLobbyGui.InitialFrame)
|
|
|
|
self.callback = callback
|
|
|
|
self.selection = -1
|
2015-05-27 14:47:33 -05:00
|
|
|
self.load()
|
2015-05-27 08:07:12 -05:00
|
|
|
|
|
|
|
def destroy(self):
|
2015-05-27 14:47:33 -05:00
|
|
|
if hasattr(self, 'title') and self.title:
|
|
|
|
self.title.destroy()
|
|
|
|
del self.title
|
|
|
|
if hasattr(self, 'buttons') and len(self.buttons):
|
|
|
|
for button in self.buttons:
|
|
|
|
button.destroy()
|
|
|
|
del self.buttons
|
|
|
|
if hasattr(self, 'okButton') and self.okButton:
|
|
|
|
self.okButton.destroy()
|
|
|
|
del self.okButton
|
|
|
|
if hasattr(self, 'cancelButton') and self.cancelButton:
|
|
|
|
self.cancelButton.destroy()
|
|
|
|
del self.cancelButton
|
2015-05-27 08:07:12 -05:00
|
|
|
DirectFrame.destroy(self)
|
|
|
|
|
|
|
|
def load(self):
|
|
|
|
empty = loader.loadModel("phase_3.5/models/gui/matching_game_gui.bam")
|
|
|
|
buttons = loader.loadModel("phase_3/models/gui/dialog_box_buttons_gui")
|
|
|
|
self.emptyList = (empty.find("**/minnieCircle"), empty.find("**/minnieCircle"), empty.find("**/minnieCircle"))
|
|
|
|
okImageList = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr'))
|
|
|
|
cancelImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr'))
|
|
|
|
empty.removeNode()
|
|
|
|
buttons.removeNode()
|
|
|
|
self.title = DirectLabel(parent=self, relief=None, text="Select a Lobby", textMayChange=1, text_scale=0.1, pos=(0, 0, 0.25))
|
|
|
|
self.okButton = DirectButton(parent=self, relief=None, image=okImageList, pos=(-0.1, 0, -0.275), command=self.nextFrame, extraArgs=[True])
|
|
|
|
self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, pos=(0.1, 0, -0.275), command=self.nextFrame, extraArgs=[False])
|
|
|
|
self.buttons = []
|
|
|
|
public = BossLobbyGui.InitialFrame.LobbySelection(self, image=self.emptyList, pos=(-0.35, 0, 0.075), text="Public", command=self.setSelection, extraArgs=[0])
|
|
|
|
private = BossLobbyGui.InitialFrame.LobbySelection(self, image=self.emptyList, pos=(-0.3475, 0, -0.075), text="Private", command=self.setSelection, extraArgs=[1])
|
|
|
|
self.buttons.extend([
|
|
|
|
public,
|
|
|
|
private
|
|
|
|
])
|
|
|
|
|
|
|
|
def setSelection(self, buttonId):
|
|
|
|
newSelection = self.buttons[buttonId]
|
|
|
|
if newSelection:
|
|
|
|
for button in self.buttons:
|
|
|
|
button.setColor(1, 1, 1, 1)
|
|
|
|
newSelection.setColor(0, 1, 0, 1)
|
|
|
|
self.selection = buttonId
|
|
|
|
|
|
|
|
def getSelection(self):
|
|
|
|
return self.selection
|
|
|
|
|
|
|
|
def nextFrame(self, status):
|
|
|
|
if status and self.getSelection() >= 0:
|
|
|
|
options = {
|
|
|
|
'lobbyType': self.getSelection()
|
|
|
|
}
|
|
|
|
self.callback(self.frame + 1, options)
|
|
|
|
else:
|
|
|
|
self.callback(-1)
|
|
|
|
|
|
|
|
def __init__(self, callback, av):
|
|
|
|
DirectFrame.__init__(self)
|
|
|
|
self.callback = callback
|
|
|
|
self.avatar = av
|
|
|
|
self.frame = None
|
|
|
|
self.loadFrame(0)
|
|
|
|
|
|
|
|
def destroy(self):
|
|
|
|
if hasattr(self, 'frame') and self.frame:
|
|
|
|
self.frame.destroy()
|
2015-05-27 14:47:33 -05:00
|
|
|
del self.frame
|
2015-05-27 08:07:12 -05:00
|
|
|
DirectFrame.destroy(self)
|
|
|
|
|
|
|
|
def loadFrame(self, frameNum, args={}):
|
|
|
|
if hasattr(self, 'frame') and self.frame:
|
|
|
|
self.frame.destroy()
|
|
|
|
if frameNum == -1:
|
|
|
|
self.callback(self.avatar, False)
|
|
|
|
elif frameNum == 0:
|
|
|
|
self.frame = BossLobbyGui.InitialFrame(self, self.loadFrame)
|
|
|
|
elif frameNum == 1 and args.get('lobbyType') is not None:
|
|
|
|
lobby = args.get('lobbyType')
|
|
|
|
if lobby == 0:
|
|
|
|
self.callback(self.avatar, True)
|
|
|
|
elif lobby == 1:
|
|
|
|
self.callback(self.avatar, True)
|
|
|
|
|
2015-05-29 21:49:55 -05:00
|
|
|
# The following is made for use with the GUI editor.
|
|
|
|
GUI_EDITOR = """
|
2015-05-27 08:07:12 -05:00
|
|
|
from toontown.coghq.BossLobbyGui import BossLobbyGui
|
|
|
|
|
|
|
|
test = BossLobbyGui(None, None)
|
|
|
|
"""
|