class ObjectivesPanel(DirectFrame): __module__ = __name__ def __init__(self, name, holder=None, mouseFade=False): DirectFrame.__init__(self, relief=None, frameSize=(0.0, PiratesGuiGlobals.ObjectivesPanelWidth, 0.0, PiratesGuiGlobals.ObjectivesPanelHeight)) self.initialiseoptions(ObjectivesPanel) self.childFrame = GuiPanel(name, PiratesGuiGlobals.ObjectivesPanelWidth, PiratesGuiGlobals.ObjectivesPanelHeight) self.childFrame.initialiseoptions(GuiPanel) self.childFrame.reparentTo(self) self.list = ListFrame(PiratesGuiGlobals.ObjectivesPageWidth, PiratesGuiGlobals.ObjectivesPageHeight, name, holder, hideAll=False) self.list.setup() self.list.reparentTo(self.childFrame) self.childFrame.closeButton.hide() if mouseFade: self.childFrame.setMouseFade(True) else: self.childFrame.hide() return def destroy(self): DirectFrame.destroy(self) self.list.destroy() def cleanup(self): self.list.cleanup()
class Scoreboard(DirectFrame): def __init__(self, name, width, height, results, titleHeight=1.0): DirectFrame.__init__(self, relief=None, state=DGG.NORMAL, frameColor=PiratesGuiGlobals.FrameColor, borderWidth=PiratesGuiGlobals.BorderWidth, pos=(0, 0, -0.029999999999999999)) self.initialiseoptions(Scoreboard) self.width = width self.height = height self.titleHeight = titleHeight self.results = results self.listHeight = self.height width = self.width - 0.02 height = self.height - self.titleHeight - 0.17000000000000001 self.list = ListFrame(width - 0.02, 0, name, self, delayedReveal=1) self.list.setup() self.list.reparentTo(self) self.setPos(0.01, 0, 0.01) self.fixHeight() def destroy(self): self.list.destroy() DirectFrame.destroy(self) def getItemList(self): return self.results def getItemChangeMsg(self): return self.taskName('tmRewardChanged') def addNewResult(self, result): self.results.append(result) def fixHeight(self): height = self.height - self.titleHeight - 0.17000000000000001 items = self.list.items itemHeight = 0.0 for item in items: itemHeight += item.getHeight() newZ = height - itemHeight self.list.setZ(newZ) def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): width = self.width - 0.02 height = self.listHeight / (len(self.getItemList()) + 1) if height > 0.10000000000000001: height = 0.10000000000000001 if item.get('Type') == 'Space': height = height / 3 return ScoreboardItemGui(item, width, height, parent)
class ObjectivesPanel(DirectFrame): def __init__(self, name, holder = None, mouseFade = False): DirectFrame.__init__(self, relief = None, frameSize = (0.0, PiratesGuiGlobals.ObjectivesPanelWidth, 0.0, PiratesGuiGlobals.ObjectivesPanelHeight)) self.initialiseoptions(ObjectivesPanel) self.childFrame = GuiPanel(name, PiratesGuiGlobals.ObjectivesPanelWidth, PiratesGuiGlobals.ObjectivesPanelHeight) self.childFrame.initialiseoptions(GuiPanel) self.childFrame.reparentTo(self) self.list = ListFrame(PiratesGuiGlobals.ObjectivesPageWidth, PiratesGuiGlobals.ObjectivesPageHeight, name, holder, hideAll = False) self.list.setup() self.list.reparentTo(self.childFrame) self.childFrame.closeButton.hide() if mouseFade: self.childFrame.setMouseFade(True) else: self.childFrame.hide() def destroy(self): DirectFrame.destroy(self) self.list.destroy() def cleanup(self): self.list.cleanup()
class Scoreboard(DirectFrame): def __init__(self, name, width, height, results, titleHeight=1.0): DirectFrame.__init__( self, relief=None, state=DGG.NORMAL, frameColor=PiratesGuiGlobals.FrameColor, borderWidth=PiratesGuiGlobals.BorderWidth, pos=(0, 0, -0.029999999999999999), ) self.initialiseoptions(Scoreboard) self.width = width self.height = height self.titleHeight = titleHeight self.results = results self.listHeight = self.height width = self.width - 0.02 height = self.height - self.titleHeight - 0.17000000000000001 self.list = ListFrame(width - 0.02, 0, name, self, delayedReveal=1) self.list.setup() self.list.reparentTo(self) self.setPos(0.01, 0, 0.01) self.fixHeight() def destroy(self): self.list.destroy() DirectFrame.destroy(self) def getItemList(self): return self.results def getItemChangeMsg(self): return self.taskName("tmRewardChanged") def addNewResult(self, result): self.results.append(result) def fixHeight(self): height = self.height - self.titleHeight - 0.17000000000000001 items = self.list.items itemHeight = 0.0 for item in items: itemHeight += item.getHeight() newZ = height - itemHeight self.list.setZ(newZ) def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): width = self.width - 0.02 height = self.listHeight / (len(self.getItemList()) + 1) if height > 0.10000000000000001: height = 0.10000000000000001 if item.get("Type") == "Space": height = height / 3 return ScoreboardItemGui(item, width, height, parent)
class TreasureMapCompletePanel(DirectFrame): __module__ = __name__ def __init__(self, name, tm, results): self.width = PiratesGuiGlobals.TMCompletePanelWidth self.height = PiratesGuiGlobals.TMCompletePanelHeight DirectFrame.__init__(self, relief=DGG.RIDGE, state=DGG.NORMAL, frameColor=PiratesGuiGlobals.FrameColor, borderWidth=PiratesGuiGlobals.BorderWidth, frameSize=(0, self.width, 0, self.height)) self.initialiseoptions(TreasureMapCompletePanel) self.results = results self.continueButton = DirectButton(parent=self, relief=DGG.FLAT, text='Continue Treasure Map', text_align=TextNode.ALeft, text_scale=PiratesGuiGlobals.TextScaleLarge, text_pos=(0.05, 0.045), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=0, frameColor=PiratesGuiGlobals.ButtonColor1, frameSize=(0, 0.5, 0, 0.1), pos=(1.5, 0, -0.12)) self.continueButton['state'] = DGG.DISABLED self.endButton = DirectButton(parent=self, relief=DGG.FLAT, text='Exit Treasure Map', text_align=TextNode.ALeft, text_scale=PiratesGuiGlobals.TextScaleLarge, text_pos=(0.09, 0.045), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=0, frameColor=PiratesGuiGlobals.ButtonColor1, frameSize=(0, 0.5, 0, 0.1), command=tm.requestTreasureMapLeave, pos=(0.42, 0, -0.12)) self.title = DirectLabel(parent=self, relief=None, text=name, text_align=TextNode.ACenter, text_scale=0.09, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, pos=(1.2, 0, 1.55)) self.list = ListFrame(PiratesGuiGlobals.TMCompletePageWidth, PiratesGuiGlobals.TMCompletePageHeight, name, self) self.list.setup() self.list.reparentTo(self) return def destroy(self): self.list.destroy() del self.list DirectFrame.destroy(self) def getItemList(self): return self.getResults() def getItemChangeMsg(self): return self.taskName('tmRewardChanged') def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): return RewardItemGui(item, parent) def getResults(self): return self.results
class TreasureMapCompletePanel(DirectFrame): def __init__(self, name, tm, results): self.width = PiratesGuiGlobals.TMCompletePanelWidth self.height = PiratesGuiGlobals.TMCompletePanelHeight DirectFrame.__init__(self, relief = DGG.RIDGE, state = DGG.NORMAL, frameColor = PiratesGuiGlobals.FrameColor, borderWidth = PiratesGuiGlobals.BorderWidth, frameSize = (0, self.width, 0, self.height)) self.initialiseoptions(TreasureMapCompletePanel) self.results = results self.continueButton = DirectButton(parent = self, relief = DGG.FLAT, text = 'Continue Treasure Map', text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.050000000000000003, 0.044999999999999998), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, frameColor = PiratesGuiGlobals.ButtonColor1, frameSize = (0, 0.5, 0, 0.10000000000000001), pos = (1.5, 0, -0.12)) self.continueButton['state'] = DGG.DISABLED self.endButton = DirectButton(parent = self, relief = DGG.FLAT, text = 'Exit Treasure Map', text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.089999999999999997, 0.044999999999999998), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, frameColor = PiratesGuiGlobals.ButtonColor1, frameSize = (0, 0.5, 0, 0.10000000000000001), command = tm.requestTreasureMapLeave, pos = (0.41999999999999998, 0, -0.12)) self.title = DirectLabel(parent = self, relief = None, text = name, text_align = TextNode.ACenter, text_scale = 0.089999999999999997, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (1.2, 0, 1.55)) self.list = ListFrame(PiratesGuiGlobals.TMCompletePageWidth, PiratesGuiGlobals.TMCompletePageHeight, name, self) self.list.setup() self.list.reparentTo(self) def destroy(self): self.list.destroy() del self.list DirectFrame.destroy(self) def getItemList(self): return self.getResults() def getItemChangeMsg(self): return self.taskName('tmRewardChanged') def createNewItem(self, item, parent, itemType = None, columnWidths = [], color = None): return RewardItemGui(item, parent) def getResults(self): return self.results
class LookoutRequestLVL3(DirectFrame): def __init__(self, name, titleTextScale=None, itemList=None, optionsFor=None): self.width = PiratesGuiGlobals.LookoutRequestLVL3Width self.height = PiratesGuiGlobals.LookoutRequestLVL3Height DirectFrame.__init__(self, relief=DGG.RIDGE, state=DGG.NORMAL, frameColor=(0, 0, 0, 0), borderWidth=PiratesGuiGlobals.BorderWidth, frameSize=(0, self.width, 0, self.height)) self.initialiseoptions(LookoutRequestLVL3) base.localAvatar.guiMgr.lookoutPage.title = name self.optionsFor = optionsFor self.name = name if itemList: self.itemList = itemList else: self.itemList = None self.activityListItems = ListFrame(0.8, None, 'blah', self, frameColor=(0, 0, 0, 0)) self.activityListItems.itemBuffer = 0.04 self.activityListItems.setup() self.activityList = DirectScrolledFrame( parent=self, frameSize=(0, 0.9, 0, 0.77), relief=DGG.GROOVE, state=DGG.NORMAL, frameColor=(0, 0, 0, 0), borderWidth=PiratesGuiGlobals.BorderWidth, canvasSize=(0, 0.7, 0, self.activityListItems['frameSize'][3]), verticalScroll_frameColor=PiratesGuiGlobals.ScrollbarColor, verticalScroll_borderWidth=(0.0075, 0.0075), verticalScroll_frameSize=(0, PiratesGuiGlobals.ScrollbarSize, 0, self.height), verticalScroll_thumb_frameColor=PiratesGuiGlobals.ButtonColor2, verticalScroll_incButton_frameColor=PiratesGuiGlobals.ButtonColor2, verticalScroll_decButton_frameColor=PiratesGuiGlobals.ButtonColor2, sortOrder=5, pos=(0.115, 0, 0.2)) self.activityListItems.reparentTo(self.activityList.getCanvas()) self.selectedItem = None self.optionsPanel = None self.parentPanel = None self.acceptButton = None return def createDoneButton(self): lookoutUI = loader.loadModel('models/gui/lookout_gui') self.acceptButton, self.acceptButtonText = self.parentPanel.parentPanel.createButtonAndText( imageInfo={ 'textureCard': lookoutUI, 'imageName': 'lookout_accept', 'buttonPos': (0.54, 0, 0.15), 'buttonScale': 0.3, 'clickCommand': self.confirmOptions }, textInfo=PLocalizer.LookoutConfirm) def confirmOptions(self): if self.optionsFor != None: currGameType = self.optionsFor options = [] for currOption in self.activityListItems.items: optionPair = currOption.getOptionValuePair() options.append(optionPair) self.parentPanel.storedOptions[currGameType] = options self.parentPanel.optionsClose() return def getGameOptions(self, gameType, clear=False): options = self.parentPanel.storedOptions.get(gameType, []) if clear and len(options) > 0: del self.parentPanel.storedOptions[gameType] return options def setParentPanel(self, parentPanel): self.parentPanel = parentPanel if parentPanel: self.createDoneButton() self.activityList.wrtReparentTo(parentPanel.parentPanel) DirectFrame.hide(self) def destroy(self): self.selectedItem = None self.parentPanel = None if self.activityList: self.activityList.destroy() self.activityList = None if self.activityListItems: self.activityListItems.destroy() self.activityListItems = None if self.acceptButton: self.acceptButton.destroy() self.acceptButton = None DirectFrame.destroy(self) return def getItemChangeMsg(self): return self.taskName('gameTypeChanged') def getItemList(self): return self.itemList def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): newItem = OptionItemGui(item, parent, frameColor=(0, 0, 0, 0), titleWrapLen=4) newItem.setup() return newItem def hide(self): self.activityList.hide() self.acceptButton.hide() def show(self, gameType, selectedItem): itemList = self.parentPanel.determineLvl3ItemList(selectedItem) if self.itemList != itemList: self.itemList = itemList self.activityListItems._handleItemChange() self.activityList['canvasSize'] = ( 0, 0.7, 0, self.activityListItems['frameSize'][3]) self.activityList.show() self.acceptButton.show() self.title = self.name
class LookoutRequestLVL3(DirectFrame): def __init__(self, name, titleTextScale = None, itemList = None, optionsFor = None): self.width = PiratesGuiGlobals.LookoutRequestLVL3Width self.height = PiratesGuiGlobals.LookoutRequestLVL3Height DirectFrame.__init__(self, relief = DGG.RIDGE, state = DGG.NORMAL, frameColor = (0, 0, 0, 0), borderWidth = PiratesGuiGlobals.BorderWidth, frameSize = (0, self.width, 0, self.height)) self.initialiseoptions(LookoutRequestLVL3) base.localAvatar.guiMgr.lookoutPage.title = name self.optionsFor = optionsFor self.name = name if itemList: self.itemList = itemList else: self.itemList = None self.activityListItems = ListFrame(0.80000000000000004, None, 'blah', self, frameColor = (0, 0, 0, 0)) self.activityListItems.itemBuffer = 0.040000000000000001 self.activityListItems.setup() self.activityList = DirectScrolledFrame(parent = self, frameSize = (0, 0.90000000000000002, 0, 0.77000000000000002), relief = DGG.GROOVE, state = DGG.NORMAL, frameColor = (0, 0, 0, 0), borderWidth = PiratesGuiGlobals.BorderWidth, canvasSize = (0, 0.69999999999999996, 0, self.activityListItems['frameSize'][3]), verticalScroll_frameColor = PiratesGuiGlobals.ScrollbarColor, verticalScroll_borderWidth = (0.0074999999999999997, 0.0074999999999999997), verticalScroll_frameSize = (0, PiratesGuiGlobals.ScrollbarSize, 0, self.height), verticalScroll_thumb_frameColor = PiratesGuiGlobals.ButtonColor2, verticalScroll_incButton_frameColor = PiratesGuiGlobals.ButtonColor2, verticalScroll_decButton_frameColor = PiratesGuiGlobals.ButtonColor2, sortOrder = 5, pos = (0.115, 0, 0.20000000000000001)) self.activityListItems.reparentTo(self.activityList.getCanvas()) self.selectedItem = None self.optionsPanel = None self.parentPanel = None self.acceptButton = None def createDoneButton(self): lookoutUI = loader.loadModel('models/gui/lookout_gui') (self.acceptButton, self.acceptButtonText) = self.parentPanel.parentPanel.createButtonAndText(imageInfo = { 'textureCard': lookoutUI, 'imageName': 'lookout_accept', 'buttonPos': (0.54000000000000004, 0, 0.14999999999999999), 'buttonScale': 0.29999999999999999, 'clickCommand': self.confirmOptions }, textInfo = PLocalizer.LookoutConfirm) def confirmOptions(self): if self.optionsFor != None: currGameType = self.optionsFor options = [] for currOption in self.activityListItems.items: optionPair = currOption.getOptionValuePair() options.append(optionPair) self.parentPanel.storedOptions[currGameType] = options self.parentPanel.optionsClose() def getGameOptions(self, gameType, clear = False): options = self.parentPanel.storedOptions.get(gameType, []) if clear and len(options) > 0: del self.parentPanel.storedOptions[gameType] return options def setParentPanel(self, parentPanel): self.parentPanel = parentPanel if parentPanel: self.createDoneButton() self.activityList.wrtReparentTo(parentPanel.parentPanel) DirectFrame.hide(self) def destroy(self): self.selectedItem = None self.parentPanel = None if self.activityList: self.activityList.destroy() self.activityList = None if self.activityListItems: self.activityListItems.destroy() self.activityListItems = None if self.acceptButton: self.acceptButton.destroy() self.acceptButton = None DirectFrame.destroy(self) def getItemChangeMsg(self): return self.taskName('gameTypeChanged') def getItemList(self): return self.itemList def createNewItem(self, item, parent, itemType = None, columnWidths = [], color = None): newItem = OptionItemGui(item, parent, frameColor = (0, 0, 0, 0), titleWrapLen = 4) newItem.setup() return newItem def hide(self): self.activityList.hide() self.acceptButton.hide() def show(self, gameType, selectedItem): itemList = self.parentPanel.determineLvl3ItemList(selectedItem) if self.itemList != itemList: self.itemList = itemList self.activityListItems._handleItemChange() self.activityList['canvasSize'] = (0, 0.69999999999999996, 0, self.activityListItems['frameSize'][3]) self.activityList.show() self.acceptButton.show() self.title = self.name
class OptionItemGui(DirectFrame): Width = PiratesGuiGlobals.OptionItemWidth Height = PiratesGuiGlobals.OptionItemHeight TOPLEVEL_GUI_FILE = 'models/gui/toplevel_gui' CHAR_GUI_FILE = 'models/gui/char_gui' def __init__(self, item, parent=None, textScale=None, itemHeight=None, frameColor=(0.1, 0.1, 1, 0.08), titleWrapLen=None, **kw): if itemHeight == None: itemHeight = OptionItemGui.Height optiondefs = (('state', DGG.NORMAL, None), ('frameColor', frameColor, None), ('borderWidth', PiratesGuiGlobals.BorderWidth, None), ('frameSize', (0.0, OptionItemGui.Width, 0.0, itemHeight), None)) self.defineoptions(kw, optiondefs) DirectFrame.__init__(self, parent) self.initialiseoptions(OptionItemGui) self.textScale = 0.04 if textScale: self.textScale = textScale self.item = item self.value = '' self.optionUI = None self.selectedItem = None self.borderFrame = None self.optionType = None self.titleWrapLen = titleWrapLen return def setup(self): self.optionType = self.item['ValueType'] self._createIface() def destroy(self): self._destroyIface() DirectFrame.destroy(self) self.ignoreAll() def _createIface(self): self._createLabel() self._createOptionEntry() def _createLabel(self): if self.optionType == PiratesGuiGlobals.UIItemType_Choice: self.titleWrapLen = None textFg = PiratesGuiGlobals.TextFG1 self.descText = DirectLabel(parent=self, relief=None, text=self.item['Text'] + ':', text_align=TextNode.ALeft, text_scale=self.textScale, text_fg=textFg, text_shadow=PiratesGuiGlobals.TextShadow, text_wordwrap=self.titleWrapLen, textMayChange=1, pos=(0, 0, self.getHeight() / 2)) return def _createOptionEntry(self): if self.optionType == PiratesGuiGlobals.UIItemType_Label: self.optionUI = DirectLabel( parent=self, relief=None, text=str(self.item['Value']), text_align=TextNode.ALeft, text_scale=self.textScale, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, pos=(0.3, 0, self.getHeight() / 2)) elif self.optionType == PiratesGuiGlobals.UIItemType_Choice: lookoutUI = loader.loadModel('models/gui/lookout_gui') check_on = lookoutUI.find('**/lookout_submit') check_off = lookoutUI.find('**/lookout_submit_disabled') if self.value == '': self.value = 0 self.optionItems = DirectCheckButton(parent=self, scale=0.05, indicatorValue=self.value, boxImageScale=4, command=self.itemChecked, pos=(0.78, 0, self.getHeight() / 2)) elif self.optionType == PiratesGuiGlobals.UIItemType_ListItem: lookoutUI = loader.loadModel('models/gui/lookout_gui') charUI = loader.loadModel(self.CHAR_GUI_FILE) charGui_slider = charUI.find('**/chargui_slider_large') charGui_slider_thumb = charUI.find('**/chargui_slider_node') self.optionItems = ListFrame(0.4, None, 'blah', self, frameColor=(0, 0, 0, 0)) self.optionItems.itemBuffer = 0.008 self.optionItems.setup() self.optionUI = DirectScrolledFrame( parent=self, frameSize=(0, 0.45, 0, 0.3), relief=DGG.GROOVE, state=DGG.NORMAL, frameColor=(0, 0, 0, 0), borderWidth=PiratesGuiGlobals.BorderWidth, canvasSize=(0, 0.38, 0, self.optionItems['frameSize'][3]), verticalScroll_frameColor=(0, 0, 0, 0), verticalScroll_thumb_frameColor=(0, 0, 0, 0), verticalScroll_incButton_frameColor=(0, 0, 0, 0), verticalScroll_decButton_frameColor=(0, 0, 0, 0), verticalScroll_image=charGui_slider, verticalScroll_image_scale=(0.12, 1, 0.28), verticalScroll_image_pos=(0.4195, 0, 0.15), verticalScroll_image_hpr=(0, 0, 90), verticalScroll_frameSize=(0, PiratesGuiGlobals.ScrollbarSize, 0, OptionItemGui.Height * 3), verticalScroll_thumb_image=charGui_slider_thumb, verticalScroll_thumb_image_scale=(0.35, 0.35, 0.35), sortOrder=5, pos=(0.3, 0, self.getHeight() / 2 - 0.15)) self.optionUI.guiItem.getVerticalSlider().clearLeftButton() self.optionUI.guiItem.getVerticalSlider().clearRightButton() self.optionUI.guiItem.getVerticalSlider().setRange(-1, 1) self.optionUI.guiItem.getHorizontalSlider().clearLeftButton() self.optionUI.guiItem.getHorizontalSlider().clearRightButton() self.optionUI.guiItem.getHorizontalSlider().setRange(-1, 1) self.createFrame() self.optionItems.reparentTo(self.optionUI.getCanvas()) return def getItemChangeMsg(self): return self.taskName('gameTypeChanged') def getItemList(self): itemList = [] for currValue in self.item['Values']: itemList.append({ 'Type': 'Literal', 'Text': str(currValue), 'Value': currValue }) return itemList def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): newItem = ButtonListItem(item, 0.08, 0.38, parent, parentList=self, txtColor=color, pressEffect=False, image=GuiButton.GuiButton.genericButton, frameColor=(0, 0, 0, 0), textScale=0.05) newItem.setup() return newItem def _destroyIface(self): self.removeFrame() self.descText.destroy() del self.descText if self.optionUI: self.optionUI.destroy() del self.optionUI def _handleItemChange(self): self._destroyIface() self._createIface() def itemSelect(self, item): for currItem in self.optionItems.items: currItem.setSelected(False) item.setSelected(True) self.selectedItem = item def itemChecked(self, status): self.value = status def getOptionValuePair(self): option = self.item['Option'] value = self.value if self.selectedItem: value = self.selectedItem.value return [str(option), str(value)] def createFrame(self): self.removeFrame() self.borderFrame = BorderFrame(parent=self, pos=(0.5, 0, 0.15), scale=(0.57, 1, 0.33)) self.borderFrame.setBackgroundVisible(False) def removeFrame(self): if self.borderFrame: self.borderFrame.removeNode() self.borderFrame = None return
class PVPPanel(BorderFrame.BorderFrame): def __init__(self, name, holder = None): w = PiratesGuiGlobals.PVPPanelWidth h = PiratesGuiGlobals.PVPPanelHeight BorderFrame.BorderFrame.__init__(self, relief = None, frameSize = (0.0, w, 0.0, h), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75)) self.secondLayer = BorderFrame.BorderFrame(parent = self, relief = None, frameSize = (0.0, w, 0.0, h), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75)) self.initialiseoptions(PVPPanel) if holder: self['frameSize'] = (0.0, w, 0.0 - len(holder.getItemList()) * 0.050000000000000003, h) self.secondLayer['frameSize'] = (0.0, w, 0.0 - len(holder.getItemList()) * 0.050000000000000003, h) self.list = ListFrame(PiratesGuiGlobals.PVPPageWidth, None, name, holder, frameColor = (0, 0, 0, 0)) self.list.setup() self.list.reparentTo(self) self.list.setPos(0.0050000000000000001, 0.20000000000000001, 0.0 - len(holder.getItemList()) * 0.050000000000000003) self.renownDisplay = None if base.config.GetBool('want-land-infamy', 0) and not (self.renownDisplay): self.renownDisplay = PVPRankGui.PVPRankGui(parent = base.a2dBottomRight, displayType = PVPRankGui.LAND_RENOWN_DISPLAY) self.renownDisplay.setPos(0.0, 0.0, 0.0) self.pvpTeamGraphic = None def destroy(self): if self.list: self.list.destroy() self.list = None if self.renownDisplay: self.renownDisplay.destroy() self.renownDisplay = None if self.secondLayer: self.secondLayer.destroy() self.secondLayer = None if self.pvpTeamGraphic: self.pvpTeamGraphic.removeNode() self.pvpTeamGraphic = None BorderFrame.BorderFrame.destroy(self) def cleanup(self): self.list.cleanup() def show(self, team): DirectFrame.show(self) self.setTeamGraphic(team) if self.renownDisplay: self.renownDisplay.show() def hide(self): DirectFrame.hide(self) if self.renownDisplay: self.renownDisplay.hide() def setTeamGraphic(self, team): if self.pvpTeamGraphic: self.pvpTeamGraphic.removeNode() self.pvpTeamGraphic = None if team > 0: self.pvpTeamGraphic = Beacon.getBeaconModel() self.pvpTeamGraphic.reparentTo(self) self.pvpTeamGraphic.setColor(PVPGlobals.getTeamColor(team)) self.pvpTeamGraphic.setScale(0.23000000000000001) self.pvpTeamGraphic.setPos(0.13, 0, 0.13)
class LookoutRequestLVL2(DirectFrame, InventoryRequestGameType): def __init__(self, name, titleTextScale=None, itemList=None, parentPanel=None): self.width = PiratesGuiGlobals.LookoutRequestLVL2Width self.height = PiratesGuiGlobals.LookoutRequestLVL2Height DirectFrame.__init__( self, relief=None, state=DGG.DISABLED, frameColor=PiratesGuiGlobals.FrameColor, borderWidth=PiratesGuiGlobals.BorderWidth, frameSize=(0, self.width, 0, self.height), ) self.initialiseoptions(LookoutRequestLVL2) InventoryRequestGameType.__init__(self) self.parentPanel = parentPanel self.name = name if itemList: self.itemList = itemList else: self.notify.warning("no itemList provied, displaying default parlor game types") self.itemList = [ { "Text": GameTypeGlobals.getGameTypeString(PiratesGlobals.GAME_STYLE_BLACKJACK, "style"), "Value": PiratesGlobals.GAME_STYLE_BLACKJACK, }, { "Text": GameTypeGlobals.getGameTypeString(PiratesGlobals.GAME_STYLE_POKER, "style"), "Value": PiratesGlobals.GAME_STYLE_POKER, }, ] self.activityListItems = ListFrame(0.80000000000000004, None, "blah", self, frameColor=(0, 0, 0, 0)) self.activityListItems.setup() if self.parentPanel.UI_VERSION == 0: size = (0, 0.81999999999999995, 0, 0.45000000000000001) pos = (0.14999999999999999, 0, 0.55000000000000004) else: size = (0, 0.81999999999999995, 0, 0.75) pos = (0.14999999999999999, 0, 0.20000000000000001) self.activityList = DirectScrolledFrame( parent=self, frameSize=size, relief=DGG.GROOVE, state=DGG.NORMAL, frameColor=(0, 0, 0, 0), borderWidth=PiratesGuiGlobals.BorderWidth, canvasSize=(0, 0.69999999999999996, 0, self.activityListItems["frameSize"][3]), verticalScroll_frameColor=PiratesGuiGlobals.ScrollbarColor, verticalScroll_borderWidth=(0.0074999999999999997, 0.0074999999999999997), verticalScroll_frameSize=(0, PiratesGuiGlobals.ScrollbarSize, 0, self.height), verticalScroll_thumb_frameColor=PiratesGuiGlobals.ButtonColor2, verticalScroll_incButton_frameColor=PiratesGuiGlobals.ButtonColor2, verticalScroll_decButton_frameColor=PiratesGuiGlobals.ButtonColor2, sortOrder=5, pos=pos, ) if self.parentPanel.UI_VERSION == 0: self.createListFrame(self.activityList) self.activityListItems.reparentTo(self.activityList.getCanvas()) self.selectedItem = None self.optionsPanel = None self.optionsButton = None self.rankingDisplay = DirectLabel( parent=self.getParent(), relief=None, text="Ranking", text_align=TextNode.ALeft, text_scale=0.050000000000000003, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, pos=(0.28999999999999998, 0, -0.55000000000000004), ) self.rankingDisplay.hide() self.setParentPanel(parentPanel) self.storedOptions = {} self.customOptions = {} def createListFrame(self, list, lookoutUI=None): self.activityListBorderFrame = BorderFrame( parent=list, pos=(0.40000000000000002, 0, 0.25), scale=(0.80000000000000004, 1, 0.45000000000000001) ) self.activityListBorderFrame.setBackgroundVisible(False) def createOptionsButton(self, lookoutUI=None, parentInfo=None): if lookoutUI == None: lookoutUI = loader.loadModel("models/gui/lookout_gui") if parentInfo == None: parent = self.parentPanel buttonPos = (0.42999999999999999, 0, 0.14999999999999999) buttonScale = 0.29999999999999999 else: parent = parentInfo.get("parent") buttonPos = parentInfo.get("pos", (0.42999999999999999, 0, 0.14999999999999999)) buttonScale = parentInfo.get("scale", 0.29999999999999999) (optionsButton, optionsButtonText) = self.parentPanel.createButtonAndText( imageInfo={ "parent": parent, "textureCard": lookoutUI, "imageName": "lookout_option", "buttonPos": buttonPos, "buttonScale": buttonScale, "clickCommand": lambda param=parent: self.optionsClick(param), }, textInfo=PLocalizer.Options, ) if parentInfo == None: buttonParent = self else: buttonParent = parent buttonParent.optionsButton = optionsButton buttonParent.optionsButtonText = optionsButtonText if self.parentPanel.submitButton: self.parentPanel.submitButton["state"] = DGG.DISABLED def setParentPanel(self, parentPanel): self.parentPanel = parentPanel def hide(self): self.activityList.hide() if self.optionsButton: self.optionsButton.hide() if self.rankingDisplay: self.rankingDisplay.hide() def show(self): self.activityList.show() def gotOptions(itemList): if itemList and len(itemList) > 0 and self.optionsButton: self.optionsButton.hide() itemList = self.determineLvl3ItemList(self.selectedItem, gotOptions) def destroy(self): self.selectedItem = None self.parentPanel = None if self.activityList: self.activityList.destroy() self.activityList = None if self.activityListItems: self.activityListItems.destroy() self.activityListItems = None if self.optionsButton: self.optionsButton.destroy() self.optionsButton = None if self.optionsPanel: self.optionsPanel.destroy() self.optionsPanel = None if self.rankingDisplay: self.rankingDisplay.destroy() DirectFrame.destroy(self) self.cancelAllInventoryRequests() def getItemChangeMsg(self): return self.taskName("gameTypeChanged") def getItemList(self): return self.itemList def createNewItem(self, item, parent, itemType=None, columnWidths=[], color=None): if self.parentPanel.UI_VERSION == 0: newItem = ButtonListItem( item, 0.080000000000000002, 0.75, parent, parentList=self, txtColor=color, pressEffect=False, frameColor=(0, 0, 0, 0), ) else: newItem = LookoutListItem( item, self.parentPanel.TOPLEVEL_GUI_FILE, 0.16, 0.75, parent, parentList=self, txtColor=color, pressEffect=False, frameColor=(0, 0, 0, 0), wantFrame=True, ) if self.parentPanel.invited == None: def gotOptions(itemList): if itemList and len(itemList) > 0: parentInfo = { "parent": newItem, "pos": (0.67500000000000004, 0, 0.105), "scale": 0.17999999999999999, } self.createOptionsButton(parentInfo=parentInfo) self.determineLvl3ItemList(newItem, gotOptions) newItem.setup() if item["Value"] == PiratesGlobals.CREW_STYLE_FIND_A_CREW: if ( localAvatar.guiMgr.crewHUD.crew and localAvatar.guiMgr.crewHUD.startACrewState or localAvatar.guiMgr.crewHUD.joinACrewStatusPVP ): newItem["state"] = DGG.DISABLED newItem.title["text_fg"] = PiratesGuiGlobals.TextFG9 newItem.desc["text_fg"] = PiratesGuiGlobals.TextFG9 if item["Value"] == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS: if ( not (localAvatar.guiMgr.crewHUD.crew) or DistributedBandMember.DistributedBandMember.IsLocalAvatarHeadOfBand() == 0 ): newItem["state"] = DGG.DISABLED newItem.title["text_fg"] = PiratesGuiGlobals.TextFG9 newItem.desc["text_fg"] = PiratesGuiGlobals.TextFG9 if localAvatar.guiMgr.crewHUD.startACrewState: newItem["state"] = DGG.NORMAL newItem.title["text_fg"] = PiratesGuiGlobals.TextFG1 newItem.desc["text_fg"] = PiratesGuiGlobals.TextFG1 if item["Value"] == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW: if ( localAvatar.guiMgr.crewHUD.crew and localAvatar.guiMgr.crewHUD.startACrewState or localAvatar.guiMgr.crewHUD.joinACrewStatus ): newItem["state"] = DGG.DISABLED newItem.title["text_fg"] = PiratesGuiGlobals.TextFG9 newItem.desc["text_fg"] = PiratesGuiGlobals.TextFG9 if item["Value"] == PiratesGlobals.GAME_STYLE_TM_BLACK_PEARL: newItem.title["text_scale"] = PiratesGuiGlobals.TextScaleTitleSmall return newItem def determineLvl3ItemList(self, item, callback=None): availItems = [] if item == None: return availItems gameType = self.parentPanel.getSelectedValue() def optionsReceived(options): if options: optionKeys = options.keys() for currOption in optionKeys: if options[currOption][0] == PiratesGuiGlobals.UIItemType_Hidden or options.get("execute"): continue availItems.append( { "Text": GameTypeGlobals.getGameTypeString(currOption, "option"), "Option": currOption, "Values": options[currOption][1], "Value": options[currOption][1][0], "ValueType": options[currOption][0], } ) if callback: callback(availItems) self.getGameOptions(gameType, item.value, optionsReceived) return availItems def itemSelect(self, item): if ( item.value == PiratesGlobals.CREW_STYLE_FIND_A_CREW and item.value == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS or item.value == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW ): self.toggleAICrewLookout(item.value) return None for currItem in self.activityListItems.items: currItem.setSelected(False) item.setSelected(True) self.selectedItem = item categoryName = GameTypeGlobals.getGameTypeString(self.selectedItem.value, "style") invCat = GameTypeGlobals.getGameTypeRanking(self.selectedItem.value) inv = base.localAvatar.getInventory() if inv: playerRank = inv.getStackQuantity(invCat) self.rankingDisplay["text"] = "%s : %d" % (categoryName, playerRank) self.rankingDisplay.show() if self.parentPanel.submitButton == None: self.parentPanel.submitRequest() def optionsClick(self, selectedItem): if self.optionsPanel: self.optionsPanel.destroy() self.optionsPanel = None def gotOptions(itemList): if itemList and len(itemList) > 0: self.optionsPanel = LookoutRequestLVL3( PLocalizer.LookoutOptionsTitle, titleTextScale=0.050000000000000003, itemList=itemList, optionsFor=selectedItem.value, ) self.optionsPanel.reparentTo(self.parentPanel) self.optionsPanel.setPos(0, 0, 0) self.optionsPanel.setParentPanel(self) gameTypeStr = GameTypeGlobals.getGameTypeString(selectedItem.value, "style") self.optionsPanel.show(gameTypeStr, selectedItem) if self.optionsButton: self.optionsButton.hide() self.parentPanel.updateMode(PiratesGuiGlobals.REQUEST_OPT_MODE) self.determineLvl3ItemList(selectedItem, gotOptions) def optionsClose(self): self.parentPanel.updateMode(PiratesGuiGlobals.REQUEST_TYPE_MODE) if self.parentPanel.deleteWhenClosed: self.optionsPanel.destroy() self.optionsPanel.removeNode() self.optionsPanel = None else: self.optionsPanel.hide() self.rankingDisplay.hide() if self.optionsButton: self.optionsButton.show() def itemSelectByValue(self, itemValue=None): itemToSelect = None if itemValue == None: if len(self.activityListItems.items) > 0: itemToSelect = self.activityListItems.items[0] else: for currItem in self.activityListItems.items: print "checking item with value %s" % currItem.value if currItem.value == itemValue: itemToSelect = currItem break continue if itemToSelect: self.itemSelect(itemToSelect) def addCustomOptions(self, gameType, optionPairs): currOptions = self.customOptions.get(gameType) if currOptions == None: self.customOptions[gameType] = optionPairs return None for currOptionPair in optionPairs: for currOption in currOptions: if currOption[0] == currOptionPair[0]: currOption[1] = currOptionPair[1] continue continue currOptions.append(currOptionPair) def getCustomOptions(self, gameType, clear=False): options = self.customOptions.get(gameType, []) if clear and len(options) > 0: del self.customOptions[gameType] return options def getAllGameOptions(self, gameType, clear=False): if self.optionsPanel: options = self.optionsPanel.getGameOptions(gameType, clear) else: options = [] customOptions = self.getCustomOptions(gameType, clear) return options + customOptions def toggleAICrewLookout(self, itemType): if itemType == PiratesGlobals.CREW_STYLE_FIND_A_CREW: localAvatar.guiMgr.crewHUD.toggleAvatarLookout() if itemType == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS: localAvatar.guiMgr.crewHUD.toggleCrewLookout() if itemType == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW: localAvatar.guiMgr.crewHUD.toggleAvatarLookoutPVP() localAvatar.guiMgr.lookoutPage.close()
class PVPPanel(BorderFrame.BorderFrame): def __init__(self, name, holder=None): w = PiratesGuiGlobals.PVPPanelWidth h = PiratesGuiGlobals.PVPPanelHeight BorderFrame.BorderFrame.__init__(self, relief=None, frameSize=(0.0, w, 0.0, h), modelName='pir_m_gui_frm_subframe', imageColorScale=VBase4( 0.75, 0.75, 0.90000000000000002, 0.75)) self.secondLayer = BorderFrame.BorderFrame( parent=self, relief=None, frameSize=(0.0, w, 0.0, h), modelName='pir_m_gui_frm_subframe', imageColorScale=VBase4(0.75, 0.75, 0.90000000000000002, 0.75)) self.initialiseoptions(PVPPanel) if holder: self['frameSize'] = ( 0.0, w, 0.0 - len(holder.getItemList()) * 0.050000000000000003, h) self.secondLayer['frameSize'] = ( 0.0, w, 0.0 - len(holder.getItemList()) * 0.050000000000000003, h) self.list = ListFrame(PiratesGuiGlobals.PVPPageWidth, None, name, holder, frameColor=(0, 0, 0, 0)) self.list.setup() self.list.reparentTo(self) self.list.setPos( 0.0050000000000000001, 0.20000000000000001, 0.0 - len(holder.getItemList()) * 0.050000000000000003) self.renownDisplay = None if base.config.GetBool('want-land-infamy', 0) and not (self.renownDisplay): self.renownDisplay = PVPRankGui.PVPRankGui( parent=base.a2dBottomRight, displayType=PVPRankGui.LAND_RENOWN_DISPLAY) self.renownDisplay.setPos(0.0, 0.0, 0.0) self.pvpTeamGraphic = None def destroy(self): if self.list: self.list.destroy() self.list = None if self.renownDisplay: self.renownDisplay.destroy() self.renownDisplay = None if self.secondLayer: self.secondLayer.destroy() self.secondLayer = None if self.pvpTeamGraphic: self.pvpTeamGraphic.removeNode() self.pvpTeamGraphic = None BorderFrame.BorderFrame.destroy(self) def cleanup(self): self.list.cleanup() def show(self, team): DirectFrame.show(self) self.setTeamGraphic(team) if self.renownDisplay: self.renownDisplay.show() def hide(self): DirectFrame.hide(self) if self.renownDisplay: self.renownDisplay.hide() def setTeamGraphic(self, team): if self.pvpTeamGraphic: self.pvpTeamGraphic.removeNode() self.pvpTeamGraphic = None if team > 0: self.pvpTeamGraphic = Beacon.getBeaconModel() self.pvpTeamGraphic.reparentTo(self) self.pvpTeamGraphic.setColor(PVPGlobals.getTeamColor(team)) self.pvpTeamGraphic.setScale(0.23000000000000001) self.pvpTeamGraphic.setPos(0.13, 0, 0.13)
class OptionItemGui(DirectFrame): Width = PiratesGuiGlobals.OptionItemWidth Height = PiratesGuiGlobals.OptionItemHeight TOPLEVEL_GUI_FILE = 'models/gui/toplevel_gui' CHAR_GUI_FILE = 'models/gui/char_gui' def __init__(self, item, parent = None, textScale = None, itemHeight = None, frameColor = (0.10000000000000001, 0.10000000000000001, 1, 0.080000000000000002), titleWrapLen = None, **kw): if itemHeight == None: itemHeight = OptionItemGui.Height optiondefs = (('state', DGG.NORMAL, None), ('frameColor', frameColor, None), ('borderWidth', PiratesGuiGlobals.BorderWidth, None), ('frameSize', (0.0, OptionItemGui.Width, 0.0, itemHeight), None)) self.defineoptions(kw, optiondefs) DirectFrame.__init__(self, parent) self.initialiseoptions(OptionItemGui) self.textScale = 0.040000000000000001 if textScale: self.textScale = textScale self.item = item self.value = '' self.optionUI = None self.selectedItem = None self.borderFrame = None self.optionType = None self.titleWrapLen = titleWrapLen def setup(self): self.optionType = self.item['ValueType'] self._createIface() def destroy(self): self._destroyIface() DirectFrame.destroy(self) self.ignoreAll() def _createIface(self): self._createLabel() self._createOptionEntry() def _createLabel(self): if self.optionType == PiratesGuiGlobals.UIItemType_Choice: self.titleWrapLen = None textFg = PiratesGuiGlobals.TextFG1 self.descText = DirectLabel(parent = self, relief = None, text = self.item['Text'] + ':', text_align = TextNode.ALeft, text_scale = self.textScale, text_fg = textFg, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = self.titleWrapLen, textMayChange = 1, pos = (0, 0, self.getHeight() / 2)) def _createOptionEntry(self): if self.optionType == PiratesGuiGlobals.UIItemType_Label: self.optionUI = DirectLabel(parent = self, relief = None, text = str(self.item['Value']), text_align = TextNode.ALeft, text_scale = self.textScale, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.29999999999999999, 0, self.getHeight() / 2)) elif self.optionType == PiratesGuiGlobals.UIItemType_Choice: lookoutUI = loader.loadModel('models/gui/lookout_gui') check_on = lookoutUI.find('**/lookout_submit') check_off = lookoutUI.find('**/lookout_submit_disabled') if self.value == '': self.value = 0 self.optionItems = DirectCheckButton(parent = self, scale = 0.050000000000000003, indicatorValue = self.value, boxImageScale = 4, command = self.itemChecked, pos = (0.78000000000000003, 0, self.getHeight() / 2)) elif self.optionType == PiratesGuiGlobals.UIItemType_ListItem: lookoutUI = loader.loadModel('models/gui/lookout_gui') charUI = loader.loadModel(self.CHAR_GUI_FILE) charGui_slider = charUI.find('**/chargui_slider_large') charGui_slider_thumb = charUI.find('**/chargui_slider_node') self.optionItems = ListFrame(0.40000000000000002, None, 'blah', self, frameColor = (0, 0, 0, 0)) self.optionItems.itemBuffer = 0.0080000000000000002 self.optionItems.setup() self.optionUI = DirectScrolledFrame(parent = self, frameSize = (0, 0.45000000000000001, 0, 0.29999999999999999), relief = DGG.GROOVE, state = DGG.NORMAL, frameColor = (0, 0, 0, 0), borderWidth = PiratesGuiGlobals.BorderWidth, canvasSize = (0, 0.38, 0, self.optionItems['frameSize'][3]), verticalScroll_frameColor = (0, 0, 0, 0), verticalScroll_thumb_frameColor = (0, 0, 0, 0), verticalScroll_incButton_frameColor = (0, 0, 0, 0), verticalScroll_decButton_frameColor = (0, 0, 0, 0), verticalScroll_image = charGui_slider, verticalScroll_image_scale = (0.12, 1, 0.28000000000000003), verticalScroll_image_pos = (0.41949999999999998, 0, 0.14999999999999999), verticalScroll_image_hpr = (0, 0, 90), verticalScroll_frameSize = (0, PiratesGuiGlobals.ScrollbarSize, 0, OptionItemGui.Height * 3), verticalScroll_thumb_image = charGui_slider_thumb, verticalScroll_thumb_image_scale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998), sortOrder = 5, pos = (0.29999999999999999, 0, self.getHeight() / 2 - 0.14999999999999999)) self.optionUI.guiItem.getVerticalSlider().clearLeftButton() self.optionUI.guiItem.getVerticalSlider().clearRightButton() self.optionUI.guiItem.getVerticalSlider().setRange(-1, 1) self.optionUI.guiItem.getHorizontalSlider().clearLeftButton() self.optionUI.guiItem.getHorizontalSlider().clearRightButton() self.optionUI.guiItem.getHorizontalSlider().setRange(-1, 1) self.createFrame() self.optionItems.reparentTo(self.optionUI.getCanvas()) def getItemChangeMsg(self): return self.taskName('gameTypeChanged') def getItemList(self): itemList = [] for currValue in self.item['Values']: itemList.append({ 'Type': 'Literal', 'Text': str(currValue), 'Value': currValue }) return itemList def createNewItem(self, item, parent, itemType = None, columnWidths = [], color = None): newItem = ButtonListItem(item, 0.080000000000000002, 0.38, parent, parentList = self, txtColor = color, pressEffect = False, image = GuiButton.GuiButton.genericButton, frameColor = (0, 0, 0, 0), textScale = 0.050000000000000003) newItem.setup() return newItem def _destroyIface(self): self.removeFrame() self.descText.destroy() del self.descText if self.optionUI: self.optionUI.destroy() del self.optionUI def _handleItemChange(self): self._destroyIface() self._createIface() def itemSelect(self, item): for currItem in self.optionItems.items: currItem.setSelected(False) item.setSelected(True) self.selectedItem = item def itemChecked(self, status): self.value = status def getOptionValuePair(self): option = self.item['Option'] value = self.value if self.selectedItem: value = self.selectedItem.value return [ str(option), str(value)] def createFrame(self): self.removeFrame() self.borderFrame = BorderFrame(parent = self, pos = (0.5, 0, 0.14999999999999999), scale = (0.56999999999999995, 1, 0.33000000000000002)) self.borderFrame.setBackgroundVisible(False) def removeFrame(self): if self.borderFrame: self.borderFrame.removeNode() self.borderFrame = None
class LookoutRequestLVL2(DirectFrame, InventoryRequestGameType): def __init__(self, name, titleTextScale = None, itemList = None, parentPanel = None): self.width = PiratesGuiGlobals.LookoutRequestLVL2Width self.height = PiratesGuiGlobals.LookoutRequestLVL2Height DirectFrame.__init__(self, relief = None, state = DGG.DISABLED, frameColor = PiratesGuiGlobals.FrameColor, borderWidth = PiratesGuiGlobals.BorderWidth, frameSize = (0, self.width, 0, self.height)) self.initialiseoptions(LookoutRequestLVL2) InventoryRequestGameType.__init__(self) self.parentPanel = parentPanel self.name = name if itemList: self.itemList = itemList else: self.notify.warning('no itemList provied, displaying default parlor game types') self.itemList = [ { 'Text': GameTypeGlobals.getGameTypeString(PiratesGlobals.GAME_STYLE_BLACKJACK, 'style'), 'Value': PiratesGlobals.GAME_STYLE_BLACKJACK }, { 'Text': GameTypeGlobals.getGameTypeString(PiratesGlobals.GAME_STYLE_POKER, 'style'), 'Value': PiratesGlobals.GAME_STYLE_POKER }] self.activityListItems = ListFrame(0.80000000000000004, None, 'blah', self, frameColor = (0, 0, 0, 0)) self.activityListItems.setup() if self.parentPanel.UI_VERSION == 0: size = (0, 0.81999999999999995, 0, 0.45000000000000001) pos = (0.14999999999999999, 0, 0.55000000000000004) else: size = (0, 0.81999999999999995, 0, 0.75) pos = (0.14999999999999999, 0, 0.20000000000000001) self.activityList = DirectScrolledFrame(parent = self, frameSize = size, relief = DGG.GROOVE, state = DGG.NORMAL, frameColor = (0, 0, 0, 0), borderWidth = PiratesGuiGlobals.BorderWidth, canvasSize = (0, 0.69999999999999996, 0, self.activityListItems['frameSize'][3]), verticalScroll_frameColor = PiratesGuiGlobals.ScrollbarColor, verticalScroll_borderWidth = (0.0074999999999999997, 0.0074999999999999997), verticalScroll_frameSize = (0, PiratesGuiGlobals.ScrollbarSize, 0, self.height), verticalScroll_thumb_frameColor = PiratesGuiGlobals.ButtonColor2, verticalScroll_incButton_frameColor = PiratesGuiGlobals.ButtonColor2, verticalScroll_decButton_frameColor = PiratesGuiGlobals.ButtonColor2, sortOrder = 5, pos = pos) if self.parentPanel.UI_VERSION == 0: self.createListFrame(self.activityList) self.activityListItems.reparentTo(self.activityList.getCanvas()) self.selectedItem = None self.optionsPanel = None self.optionsButton = None self.rankingDisplay = DirectLabel(parent = self.getParent(), relief = None, text = 'Ranking', text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0.28999999999999998, 0, -0.55000000000000004)) self.rankingDisplay.hide() self.setParentPanel(parentPanel) self.storedOptions = { } self.customOptions = { } def createListFrame(self, list, lookoutUI = None): self.activityListBorderFrame = BorderFrame(parent = list, pos = (0.40000000000000002, 0, 0.25), scale = (0.80000000000000004, 1, 0.45000000000000001)) self.activityListBorderFrame.setBackgroundVisible(False) def createOptionsButton(self, lookoutUI = None, parentInfo = None): if lookoutUI == None: lookoutUI = loader.loadModel('models/gui/lookout_gui') if parentInfo == None: parent = self.parentPanel buttonPos = (0.42999999999999999, 0, 0.14999999999999999) buttonScale = 0.29999999999999999 else: parent = parentInfo.get('parent') buttonPos = parentInfo.get('pos', (0.42999999999999999, 0, 0.14999999999999999)) buttonScale = parentInfo.get('scale', 0.29999999999999999) (optionsButton, optionsButtonText) = self.parentPanel.createButtonAndText(imageInfo = { 'parent': parent, 'textureCard': lookoutUI, 'imageName': 'lookout_option', 'buttonPos': buttonPos, 'buttonScale': buttonScale, 'clickCommand': lambda param = parent: self.optionsClick(param) }, textInfo = PLocalizer.Options) if parentInfo == None: buttonParent = self else: buttonParent = parent buttonParent.optionsButton = optionsButton buttonParent.optionsButtonText = optionsButtonText if self.parentPanel.submitButton: self.parentPanel.submitButton['state'] = DGG.DISABLED def setParentPanel(self, parentPanel): self.parentPanel = parentPanel def hide(self): self.activityList.hide() if self.optionsButton: self.optionsButton.hide() if self.rankingDisplay: self.rankingDisplay.hide() def show(self): self.activityList.show() def gotOptions(itemList): if itemList and len(itemList) > 0 and self.optionsButton: self.optionsButton.hide() itemList = self.determineLvl3ItemList(self.selectedItem, gotOptions) def destroy(self): self.selectedItem = None self.parentPanel = None if self.activityList: self.activityList.destroy() self.activityList = None if self.activityListItems: self.activityListItems.destroy() self.activityListItems = None if self.optionsButton: self.optionsButton.destroy() self.optionsButton = None if self.optionsPanel: self.optionsPanel.destroy() self.optionsPanel = None if self.rankingDisplay: self.rankingDisplay.destroy() DirectFrame.destroy(self) self.cancelAllInventoryRequests() def getItemChangeMsg(self): return self.taskName('gameTypeChanged') def getItemList(self): return self.itemList def createNewItem(self, item, parent, itemType = None, columnWidths = [], color = None): if self.parentPanel.UI_VERSION == 0: newItem = ButtonListItem(item, 0.080000000000000002, 0.75, parent, parentList = self, txtColor = color, pressEffect = False, frameColor = (0, 0, 0, 0)) else: newItem = LookoutListItem(item, self.parentPanel.TOPLEVEL_GUI_FILE, 0.16, 0.75, parent, parentList = self, txtColor = color, pressEffect = False, frameColor = (0, 0, 0, 0), wantFrame = True) if self.parentPanel.invited == None: def gotOptions(itemList): if itemList and len(itemList) > 0: parentInfo = { 'parent': newItem, 'pos': (0.67500000000000004, 0, 0.105), 'scale': 0.17999999999999999 } self.createOptionsButton(parentInfo = parentInfo) self.determineLvl3ItemList(newItem, gotOptions) newItem.setup() if item['Value'] == PiratesGlobals.CREW_STYLE_FIND_A_CREW: if localAvatar.guiMgr.crewHUD.crew and localAvatar.guiMgr.crewHUD.startACrewState or localAvatar.guiMgr.crewHUD.joinACrewStatusPVP: newItem['state'] = DGG.DISABLED newItem.title['text_fg'] = PiratesGuiGlobals.TextFG9 newItem.desc['text_fg'] = PiratesGuiGlobals.TextFG9 if item['Value'] == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS: if not (localAvatar.guiMgr.crewHUD.crew) or DistributedBandMember.DistributedBandMember.IsLocalAvatarHeadOfBand() == 0: newItem['state'] = DGG.DISABLED newItem.title['text_fg'] = PiratesGuiGlobals.TextFG9 newItem.desc['text_fg'] = PiratesGuiGlobals.TextFG9 if localAvatar.guiMgr.crewHUD.startACrewState: newItem['state'] = DGG.NORMAL newItem.title['text_fg'] = PiratesGuiGlobals.TextFG1 newItem.desc['text_fg'] = PiratesGuiGlobals.TextFG1 if item['Value'] == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW: if localAvatar.guiMgr.crewHUD.crew and localAvatar.guiMgr.crewHUD.startACrewState or localAvatar.guiMgr.crewHUD.joinACrewStatus: newItem['state'] = DGG.DISABLED newItem.title['text_fg'] = PiratesGuiGlobals.TextFG9 newItem.desc['text_fg'] = PiratesGuiGlobals.TextFG9 if item['Value'] == PiratesGlobals.GAME_STYLE_TM_BLACK_PEARL: newItem.title['text_scale'] = PiratesGuiGlobals.TextScaleTitleSmall return newItem def determineLvl3ItemList(self, item, callback = None): availItems = [] if item == None: return availItems gameType = self.parentPanel.getSelectedValue() def optionsReceived(options): if options: optionKeys = options.keys() for currOption in optionKeys: if options[currOption][0] == PiratesGuiGlobals.UIItemType_Hidden or options.get('execute'): continue availItems.append({ 'Text': GameTypeGlobals.getGameTypeString(currOption, 'option'), 'Option': currOption, 'Values': options[currOption][1], 'Value': options[currOption][1][0], 'ValueType': options[currOption][0] }) if callback: callback(availItems) self.getGameOptions(gameType, item.value, optionsReceived) return availItems def itemSelect(self, item): if item.value == PiratesGlobals.CREW_STYLE_FIND_A_CREW and item.value == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS or item.value == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW: self.toggleAICrewLookout(item.value) return None for currItem in self.activityListItems.items: currItem.setSelected(False) item.setSelected(True) self.selectedItem = item categoryName = GameTypeGlobals.getGameTypeString(self.selectedItem.value, 'style') invCat = GameTypeGlobals.getGameTypeRanking(self.selectedItem.value) inv = base.localAvatar.getInventory() if inv: playerRank = inv.getStackQuantity(invCat) self.rankingDisplay['text'] = '%s : %d' % (categoryName, playerRank) self.rankingDisplay.show() if self.parentPanel.submitButton == None: self.parentPanel.submitRequest() def optionsClick(self, selectedItem): if self.optionsPanel: self.optionsPanel.destroy() self.optionsPanel = None def gotOptions(itemList): if itemList and len(itemList) > 0: self.optionsPanel = LookoutRequestLVL3(PLocalizer.LookoutOptionsTitle, titleTextScale = 0.050000000000000003, itemList = itemList, optionsFor = selectedItem.value) self.optionsPanel.reparentTo(self.parentPanel) self.optionsPanel.setPos(0, 0, 0) self.optionsPanel.setParentPanel(self) gameTypeStr = GameTypeGlobals.getGameTypeString(selectedItem.value, 'style') self.optionsPanel.show(gameTypeStr, selectedItem) if self.optionsButton: self.optionsButton.hide() self.parentPanel.updateMode(PiratesGuiGlobals.REQUEST_OPT_MODE) self.determineLvl3ItemList(selectedItem, gotOptions) def optionsClose(self): self.parentPanel.updateMode(PiratesGuiGlobals.REQUEST_TYPE_MODE) if self.parentPanel.deleteWhenClosed: self.optionsPanel.destroy() self.optionsPanel.removeNode() self.optionsPanel = None else: self.optionsPanel.hide() self.rankingDisplay.hide() if self.optionsButton: self.optionsButton.show() def itemSelectByValue(self, itemValue = None): itemToSelect = None if itemValue == None: if len(self.activityListItems.items) > 0: itemToSelect = self.activityListItems.items[0] else: for currItem in self.activityListItems.items: print 'checking item with value %s' % currItem.value if currItem.value == itemValue: itemToSelect = currItem break continue if itemToSelect: self.itemSelect(itemToSelect) def addCustomOptions(self, gameType, optionPairs): currOptions = self.customOptions.get(gameType) if currOptions == None: self.customOptions[gameType] = optionPairs return None for currOptionPair in optionPairs: for currOption in currOptions: if currOption[0] == currOptionPair[0]: currOption[1] = currOptionPair[1] continue continue currOptions.append(currOptionPair) def getCustomOptions(self, gameType, clear = False): options = self.customOptions.get(gameType, []) if clear and len(options) > 0: del self.customOptions[gameType] return options def getAllGameOptions(self, gameType, clear = False): if self.optionsPanel: options = self.optionsPanel.getGameOptions(gameType, clear) else: options = [] customOptions = self.getCustomOptions(gameType, clear) return options + customOptions def toggleAICrewLookout(self, itemType): if itemType == PiratesGlobals.CREW_STYLE_FIND_A_CREW: localAvatar.guiMgr.crewHUD.toggleAvatarLookout() if itemType == PiratesGlobals.CREW_STYLE_RECRUIT_MEMBERS: localAvatar.guiMgr.crewHUD.toggleCrewLookout() if itemType == PiratesGlobals.CREW_STYLE_FIND_A_PVP_CREW: localAvatar.guiMgr.crewHUD.toggleAvatarLookoutPVP() localAvatar.guiMgr.lookoutPage.close()