class ReturnKartDlg(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr.ReturnKartDlg') def __init__(self, doneEvent): self.modelScale = 1 model = loader.loadModel('phase_6/models/gui/ReturnKartPanel') DirectFrame.__init__(self, relief = None, state = 'normal', geom = model, geom_scale = self.modelScale, frameSize = (-1, 1, -1, 1), pos = (0, 0, -0.01), text = TTLocalizer.KartShop_ConfirmReturnKart, text_wordwrap = 11, text_scale = KS_TEXT_SIZE_SMALL * 0.90000000000000002, text_pos = (0, -0.26000000000000001)) self.initialiseoptions(KartShopGuiMgr.ReturnKartDlg) self.cancelButton = DirectButton(parent = self, relief = None, image = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover')), geom = model.find('**/CancelIcon'), scale = self.modelScale, pressEffect = False, command = lambda : messenger.send(doneEvent, [ RK_OPTIONS.Cancel])) self.okButton = DirectButton(parent = self, relief = None, image = (model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckButtonRollover')), geom = model.find('**/CheckIcon'), scale = self.modelScale, pressEffect = False, command = lambda : messenger.send(doneEvent, [ RK_OPTIONS.ReturnKart])) oldDNA = list(base.localAvatar.getKartDNA()) for d in range(len(oldDNA)): if d == KartDNA.bodyType: continue continue oldDNA[d] = InvalidEntry self.kartView = KartViewer(oldDNA, parent = self) self.kartView.setPos(model.find('**/KartViewerFrame').getPos()) self.kartView.load(model, 'KartViewerFrame', [], [], None) self.kartView.setBounds(-0.38, 0.38, -0.040000000000000001, 0.48999999999999999) self.kartView.setBgColor(1.0, 1.0, 0.80000000000000004, 1.0) self.kartView.show() model.removeNode() self.initialize = True def destroy(self): if self.initialize: self.kartView.destroy() DirectFrame.destroy(self)
class ReturnKartDlg(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr.ReturnKartDlg') def __init__(self, doneEvent): self.modelScale = 1 model = loader.loadModel('phase_6/models/gui/ReturnKartPanel') DirectFrame.__init__( self, relief=None, state='normal', geom=model, geom_scale=self.modelScale, frameSize=(-1, 1, -1, 1), pos=(0, 0, -0.01), text=TTLocalizer.KartShop_ConfirmReturnKart, text_wordwrap=11, text_scale=KS_TEXT_SIZE_SMALL * 0.9, text_pos=(0, -0.26)) self.initialiseoptions(KartShopGuiMgr.ReturnKartDlg) self.cancelButton = DirectButton( parent=self, relief=None, image=(model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover')), geom=model.find('**/CancelIcon'), scale=self.modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [RK_OPTIONS.Cancel])) self.okButton = DirectButton( parent=self, relief=None, image=(model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckButtonRollover')), geom=model.find('**/CheckIcon'), scale=self.modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [RK_OPTIONS.ReturnKart])) oldDNA = list(base.localAvatar.getKartDNA()) for d in xrange(len(oldDNA)): if d == KartDNA.bodyType: continue else: oldDNA[d] = InvalidEntry self.kartView = KartViewer(oldDNA, parent=self) self.kartView.setPos(model.find('**/KartViewerFrame').getPos()) self.kartView.load(model, 'KartViewerFrame', [], [], None) self.kartView.setBounds(-0.38, 0.38, -.04, 0.49) self.kartView.setBgColor(1.0, 1.0, 0.8, 1.0) self.kartView.show() model.removeNode() self.initialize = True return def destroy(self): if self.initialize: self.kartView.destroy() DirectFrame.destroy(self)
class BoughtKartDlg(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr.BoughtKartDlg') def __init__(self, doneEvent, kartID): self.modelScale = 1 model = loader.loadModel('phase_6/models/gui/BoughtKartPanel') kartInfo = getKartTypeInfo(kartID) name = kartInfo[KartInfo.name] DirectFrame.__init__( self, relief=None, state='normal', geom=model, geom_scale=self.modelScale, frameSize=(-1, 1, -1, 1), pos=(0, 0, -0.01), text=TTLocalizer.KartShop_ConfirmBoughtTitle, text_wordwrap=26, text_scale=KS_TEXT_SIZE_SMALL, text_pos=(0, -0.26)) self.initialiseoptions(KartShopGuiMgr.BoughtKartDlg) self.ticketDisplay = DirectLabel( parent=self, relief=None, text=str(base.localAvatar.getTickets()), text_scale=KS_TEXT_SIZE_SMALL, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_pos=(0.43, -0.5), text_font=ToontownGlobals.getSignFont()) self.okButton = DirectButton( parent=self, relief=None, image=(model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckButtonRollover')), geom=model.find('**/CheckIcon'), scale=self.modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [BTK_OPTIONS.Ok])) self.kartView = KartViewer([kartID, -1, -1, -1, -1, -1, -1, -1, -1], parent=self) self.kartView.setPos(model.find('**/KartViewerFrame').getPos()) self.kartView.load(model, 'KartViewerFrame', [], []) self.kartView.setBounds(-0.38, 0.38, -.0425, 0.49) self.kartView.setBgColor(1.0, 1.0, 0.8, 1.0) self.kartView.show() model.removeNode() self.initialize = True return def destroy(self): if self.initialize: self.kartView.destroy() DirectFrame.destroy(self)
class BuyKartDlg(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr.BuyKartDlg') def __init__(self, doneEvent): self.modelScale = 1 model = loader.loadModel('phase_6/models/gui/BuyKartPanel') self.unownedKartList = KartDict.keys() if base.localAvatar.hasKart(): k = base.localAvatar.getKartBodyType() if k in self.unownedKartList: self.unownedKartList.remove(k) self.numKarts = len(self.unownedKartList) self.curKart = 0 DirectFrame.__init__( self, relief=None, state='normal', geom=model, geom_scale=self.modelScale, frameSize=(-1, 1, -1, 1), pos=(0, 0, -0.01), text_wordwrap=26, text_scale=KS_TEXT_SIZE_BIG, text_pos=(0, 0)) self.initialiseoptions(KartShopGuiMgr.BuyKartDlg) self.ticketDisplay = DirectLabel( parent=self, relief=None, text=str(base.localAvatar.getTickets()), text_scale=KS_TEXT_SIZE_SMALL, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_pos=(0.44, -0.55), text_font=ToontownGlobals.getSignFont()) self.buyKartButton = DirectButton( parent=self, relief=None, image=(model.find('**/BuyKartButtonUp'), model.find('**/BuyKartButtonDown'), model.find('**/BuyKartButtonRollover'), model.find('**/BuyKartButtonDisabled')), scale=self.modelScale, text=TTLocalizer.KartShop_BuyKart, text_scale=KS_TEXT_SIZE_BIG, text_pos=(0, -.534), pressEffect=False, command=lambda : messenger.send(doneEvent, [self.unownedKartList[self.curKart]])) self.cancelButton = DirectButton( parent=self, relief=None, image=(model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover')), geom=model.find('**/CancelIcon'), scale=self.modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [BK_OPTIONS.Cancel])) self.arrowLeftButton = DirectButton( parent=self, relief=None, image=(model.find('**/ArrowLeftButtonUp'), model.find('**/ArrowLeftButtonDown'), model.find('**/ArrowLeftButtonRollover'), model.find('**/ArrowLeftButtonInactive')), scale=self.modelScale, pressEffect=False, command=self.__handleKartChange, extraArgs=[-1]) self.arrowRightButton = DirectButton( parent=self, relief=None, image=(model.find('**/ArrowRightButtonUp'), model.find('**/ArrowRightButtonDown'), model.find('**/ArrowRightButtonRollover'), model.find('**/ArrowRightButtonInactive')), scale=self.modelScale, pressEffect=False, command=self.__handleKartChange, extraArgs=[1]) self.kartView = KartViewer([self.curKart, -1, -1, -1, -1, -1, -1, -1, -1], parent=self) self.kartView.setPos(model.find('**/KartViewerFrame').getPos()) self.kartView.load(model, 'KartViewerFrame', ['rotate_right_up', 'rotate_right_down', 'rotate_right_roll', 'rotate_right_down', (0.255, -.054)], ['rotate_left_up', 'rotate_left_down', 'rotate_left_roll', 'rotate_left_down', (-.24, -.054)], (0, -.055)) self.kartView.setBounds(-0.38, 0.38, 0.0035, 0.53) self.kartView.setBgColor(1.0, 1.0, 0.8, 1.0) self.showKart() self.initialize = True model.removeNode() return def showKart(self): self.buyKartButton.configure(text=TTLocalizer.KartShop_BuyKart) self.buyKartButton.configure(text_scale=KS_TEXT_SIZE_BIG) if self.numKarts > 0: info = getKartTypeInfo(self.unownedKartList[self.curKart]) description = info[KartInfo.name] cost = TTLocalizer.KartShop_Cost % info[KartInfo.cost] self.kartDescription = DirectButton( parent=self, relief=None, scale=self.modelScale, text=description, text_pos=(0, -.29), text_scale=KS_TEXT_SIZE_SMALL, pressEffect=False, textMayChange=True) self.kartCost = DirectButton( parent=self, relief=None, scale=self.modelScale, text=cost, text_pos=(0, -.365), text_scale=KS_TEXT_SIZE_SMALL, pressEffect=False, textMayChange=True) self.buyKartButton['state'] = DGG.NORMAL self.arrowRightButton['state'] = DGG.DISABLED self.arrowLeftButton['state'] = DGG.DISABLED if self.numKarts > self.curKart + 1: self.arrowRightButton['state'] = DGG.NORMAL if self.curKart > 0: self.arrowLeftButton['state'] = DGG.NORMAL if info[KartInfo.cost] > base.localAvatar.getTickets(): self.buyKartButton['state'] = DGG.DISABLED self.buyKartButton.configure(text_scale=KS_TEXT_SIZE_SMALL * 0.75) self.buyKartButton.configure(text=TTLocalizer.KartShop_NotEnoughTickets) self.kartCost.configure(text_fg=(0.95, 0, 0.0, 1.0)) self.kartView.refresh([self.unownedKartList[self.curKart], -1, -1, -1, -1, -1, -1, -1, -1]) self.kartView.show() return def __handleKartChange(self, nDir): self.curKart = (self.curKart + nDir) % self.numKarts self.kartDescription.destroy() self.kartCost.destroy() self.showKart() def destroy(self): if self.initialize: self.kartView.destroy() DirectFrame.destroy(self)
class BuyAccessoryDlg(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr.buyAccessoryDlg') def __init__(self, doneEvent): self.modelScale = 1 model = loader.loadModel('phase_6/models/gui/BuyAccessoryPanel') self.doneEvent = doneEvent DirectFrame.__init__(self, relief=None, state='normal', geom=model, geom_scale=self.modelScale, frameSize=(-1, 1, -1, 1), pos=(0, 0, -0.01), text_wordwrap=26, text_scale=0.1, text_fg=Vec4(0.36, 0.94, 0.93, 1.0), text_pos=(0, 0)) self.initialiseoptions(KartShopGuiMgr.BuyAccessoryDlg) self.ticketDisplay = DirectLabel( parent=self, relief=None, text=str(base.localAvatar.getTickets()), text_scale=KS_TEXT_SIZE_SMALL, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_pos=(0.42, -0.6), text_font=ToontownGlobals.getSignFont()) self.arrowLeftButton = DirectButton( parent=self, relief=None, image=(model.find('**/ArrowLeftButtonUp'), model.find('**/ArrowLeftButtonDown'), model.find('**/ArrowLeftButtonRollover'), model.find('**/ArrowLeftButtonInactive')), scale=self.modelScale, text_pos=(0, 0), text_scale=0.1, pressEffect=False, command=self.__handleAccessoryChange, extraArgs=[-1]) self.arrowRightButton = DirectButton( parent=self, relief=None, image=(model.find('**/ArrowRightButtonUp'), model.find('**/ArrowRightButtonDown'), model.find('**/ArrowRightButtonRollover'), model.find('**/ArrowRightButtonInactive')), scale=self.modelScale, text_pos=(0, 0), text_scale=0.1, pressEffect=False, command=self.__handleAccessoryChange, extraArgs=[1]) self.cancelButton = DirectButton( parent=self, relief=None, image=(model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover')), geom=model.find('**/CancelIcon'), scale=self.modelScale, command=lambda : messenger.send(doneEvent, [BA_OPTIONS.Cancel]), pressEffect=False) self.decalAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/DecalButtonUp'), model.find('**/DecalButtonDown'), model.find('**/DecalButtonRollover'), model.find('**/DecalButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.decalType]) self.spoilerAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/SpoilerButtonUp'), model.find('**/SpoilerButtonDown'), model.find('**/SpoilerButtonRollover'), model.find('**/SpoilerButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.spType]) self.eBlockAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/EBlockButtonUp'), model.find('**/EBlockButtonDown'), model.find('**/EBlockButtonRollover'), model.find('**/EBlockButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.ebType]) self.rearAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/RearButtonUp'), model.find('**/RearButtonDown'), model.find('**/RearButtonRollover'), model.find('**/RearButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.bwwType]) self.frontAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/FrontButtonUp'), model.find('**/FrontButtonDown'), model.find('**/FrontButtonRollover'), model.find('**/FrontButtonDown')), scale=self.modelScale, text_pos=(0, 0), text_scale=0.1, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.fwwType]) self.rimAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/RimButtonUp'), model.find('**/RimButtonDown'), model.find('**/RimButtonRollover'), model.find('**/RimButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.rimsType]) self.paintAccButton = DirectButton( parent=self, relief=None, image=(model.find('**/PaintButtonUp'), model.find('**/PaintButtonDown'), model.find('**/PaintButtonRollover'), model.find('**/PaintButtonDown')), scale=self.modelScale, pressEffect=False, command=self.__handleAccessoryTypeChange, extraArgs=[KartDNA.bodyColor]) self.accButtonsDict = { KartDNA.ebType: self.eBlockAccButton, KartDNA.spType: self.spoilerAccButton, KartDNA.fwwType: self.frontAccButton, KartDNA.bwwType: self.rearAccButton, KartDNA.rimsType: self.rimAccButton, KartDNA.decalType: self.decalAccButton, KartDNA.bodyColor: self.paintAccButton} self.buyAccessoryButton = DirectButton( parent=self, relief=None, image=(model.find('**/BuyAccessoryButtonUp'), model.find('**/BuyAccessoryButtonDown'), model.find('**/BuyAccessoryButtonRollover'), model.find('**/BuyAccessoryButtonDisabled')), scale=self.modelScale, text=TTLocalizer.KartShop_BuyAccessory, text_pos=(0, -.57), text_scale=KS_TEXT_SIZE_SMALL, pressEffect=False, command=self.__handleBuyAccessory) if not base.cr.isPaid(): def showTeaserPanel(): TeaserPanel(pageName='kartingAccessories') self.buyAccessoryButton['command'] = showTeaserPanel self.ownedAccList = base.localAvatar.getKartAccessoriesOwned() while -1 in self.ownedAccList: self.ownedAccList.remove(-1) self.unownedAccDict = getAccessoryDictFromOwned(self.ownedAccList) self.curAccType = KartDNA.ebType self.curAccIndex = {} for type in self.unownedAccDict: self.curAccIndex[type] = 0 self.kartView = KartViewer(list(base.localAvatar.getKartDNA()), parent=self) self.kartView.setPos(model.find('**/KartViewerFrame').getPos()) self.kartView.load(model, 'KartViewerFrame', ['rotate_right_up', 'rotate_right_down', 'rotate_right_roll', 'rotate_right_down', (0.255, 0)], ['rotate_left_up', 'rotate_left_down', 'rotate_left_roll', 'rotate_left_down', (-.24, 0)], (0, 0)) self.kartView.setBounds(-0.38, 0.38, 0.044, 0.58) self.kartView.setBgColor(1.0, 1.0, 0.87, 1.0) self.initialize = True self.showAccessory() model.removeNode() return def __handleBuyAccessory(self): accessoryID = self.unownedAccDict[self.curAccType][self.curAccIndex[self.curAccType]] self.ownedAccList.append(accessoryID) self.unownedAccDict = getAccessoryDictFromOwned(self.ownedAccList) self.__handleAccessoryChange(0) messenger.send(self.doneEvent, [accessoryID]) def __handleAccessoryChange(self, nDir): if len(self.unownedAccDict[self.curAccType]) < 1: self.curAccIndex[self.curAccType] = -1 else: self.curAccIndex[self.curAccType] = (self.curAccIndex[self.curAccType] + nDir) % len(self.unownedAccDict[self.curAccType]) if hasattr(self, 'accDescription'): self.accDescription.destroy() self.accCost.destroy() self.showAccessory() def __handleAccessoryTypeChange(self, type): self.curAccType = type try: self.accDescription.destroy() self.accCost.destroy() except: pass for b in self.accButtonsDict: self.accButtonsDict[b]['state'] = DGG.NORMAL self.accButtonsDict[self.curAccType]['state'] = DGG.DISABLED self.showAccessory() def showAccessory(self): self.arrowRightButton['state'] = DGG.DISABLED self.arrowLeftButton['state'] = DGG.DISABLED self.buyAccessoryButton['state'] = DGG.DISABLED self.accDescription = DirectButton( parent=self, relief=None, scale=self.modelScale, text='', text_pos=(0, -.33), text_scale=KS_TEXT_SIZE_SMALL, pressEffect=False, text_wordwrap=TTLocalizer.KSGaccDescriptionWordwrap, textMayChange=True) self.buyAccessoryButton.configure(text_fg=(0, 0, 0.0, 1.0)) self.buyAccessoryButton.configure(text=TTLocalizer.KartShop_BuyAccessory) self.buyAccessoryButton.configure(text_scale=KS_TEXT_SIZE_SMALL) self.buyAccessoryButton['state'] = DGG.NORMAL if len(self.unownedAccDict[self.curAccType]) < 1: self.kartView.setDNA(None) self.kartView.hide() self.accDescription.configure(text=TTLocalizer.KartShop_NoAvailableAcc) self.buyAccessoryButton['state'] = DGG.DISABLED else: if self.curAccIndex[self.curAccType] + 1 < len(self.unownedAccDict[self.curAccType]): self.arrowRightButton['state'] = DGG.NORMAL if self.curAccIndex[self.curAccType] > 0: self.arrowLeftButton['state'] = DGG.NORMAL curDNA = None curDNA = list(base.localAvatar.getKartDNA()) for d in xrange(len(curDNA)): if d == KartDNA.bodyType or d == KartDNA.accColor or d == KartDNA.bodyColor: continue else: curDNA[d] = -1 curAcc = self.unownedAccDict[self.curAccType][self.curAccIndex[self.curAccType]] curDNA[self.curAccType] = curAcc self.kartView.refresh(curDNA) self.accDescription.configure(text=AccessoryDict[curAcc][KartInfo.name]) cost = TTLocalizer.KartShop_Cost % AccessoryDict[curAcc][KartInfo.cost] self.accCost = DirectButton( parent=self, relief=None, scale=self.modelScale, text=cost, text_pos=(0, -.4), text_scale=KS_TEXT_SIZE_SMALL, text_fg=(0, 0, 0.0, 1.0), pressEffect=False, textMayChange=True) if AccessoryDict[curAcc][KartInfo.cost] > base.localAvatar.getTickets(): self.buyAccessoryButton['state'] = DGG.DISABLED self.buyAccessoryButton.configure(text_scale=KS_TEXT_SIZE_SMALL * 0.75) self.buyAccessoryButton.configure(text=TTLocalizer.KartShop_NotEnoughTickets) self.accCost.configure(text_fg=(0.95, 0, 0.0, 1.0)) if len(base.localAvatar.getKartAccessoriesOwned()) >= KartShopGlobals.MAX_KART_ACC: self.buyAccessoryButton['state'] = DGG.DISABLED self.buyAccessoryButton.configure(text_fg=(0.95, 0, 0.0, 1.0)) self.buyAccessoryButton.configure(text_scale=KS_TEXT_SIZE_SMALL * 0.8) self.buyAccessoryButton.configure(text=TTLocalizer.KartShop_FullTrunk) self.kartView.show() return def destroy(self): if self.initialize: try: self.accDescription.destroy() except: pass try: self.kartView.destroy() except: pass DirectFrame.destroy(self)