def __init__(self): DirectObject.DirectObject.__init__(self) self.event = None self.sfx = None self.text = DirectLabel(parent = render2d, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.055, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, text_font = PiratesGlobals.getPirateFont(), pos = (0, 0, -0.90000000000000002), sortOrder = 80) self.confirmButton = DialogButton(parent = base.a2dBottomRight, pos = (-0.14999999999999999, 0, 0.095000000000000001), text = PLocalizer.MakeAPirateNext, text_scale = 0.050000000000000003, text_pos = (0.040000000000000001, -0.017999999999999999), text_fg = PiratesGuiGlobals.TextFG2, textMayChange = 1, command = self.advancePageNumber, sortOrder = 90, buttonStyle = DialogButton.YES) self.EscText = DirectLabel(parent = render2d, relief = None, text = '', text_align = TextNode.ALeft, text_scale = 0.055, text_fg = PiratesGuiGlobals.TextFG9, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, text_font = PiratesGlobals.getPirateFont(), pos = (-0.92000000000000004, 0, 0.88), sortOrder = 80) base.transitions.loadLetterbox() self.text.setScale(aspect2d, 1) self.accept('aspectRatioChanged', self.text.setScale, [ aspect2d, 1]) self.text.hide() self.confirmButton.hide() self.EscText.hide() self.fader = None self.subtitleParent = render2d.attachNewNode(PGTop('subtitleParent')) self.subtitleParent.node().setMouseWatcher(base.mouseWatcherNode) self._Subtitler__chatPageNumber = None self._Subtitler__chatPages = None self._Subtitler__chatMessage = None self._Subtitler__chatPages = [] self._Subtitler__optionButtons = [] self.specialButtonImage = None self.clearTextOverride = False
def setupGui(self): self.destroyGui() if not self.guiSetup: self.button = DialogButton(parent = self, buttonStyle = DialogButton.NO, pos = (0.25, 0, 0.080000000000000002), text = PLocalizer.lClose, helpPos = (-0.40000000000000002, 0, 0.029999999999999999), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = self['extraArgs']) self.background = BorderFrame(parent = self, pos = (0.050000000000000003, 0, 0.050000000000000003), frameSize = [ 0.0, 0.40000000000000002, 0.10000000000000001, 0.59999999999999998], bgColorScale = VBase4(0, 0, 0, 0.75), bgTransparency = 1, flatten = 0) if self['ownShip']: state = DGG.NORMAL else: state = DGG.DISABLED ship = localAvatar.getShip() if ship: friendState = ship.getAllowFriendState() crewState = ship.getAllowCrewState() guildState = ship.getAllowGuildState() publicState = ship.getAllowPublicState() else: friendState = 0 crewState = 0 guildState = 0 publicState = 0 buttonOptions = { 'parent': self.background, 'state': state, 'relief': None, 'pos': (0.059999999999999998, 0, 0.53000000000000003), 'scale': 0.29999999999999999, 'text': PLocalizer.CrewBoardingAccessAllowFriends, 'value': friendState, 'text_pos': (0.16700000000000001, -0.059999999999999998, 0), 'text0_fg': PiratesGuiGlobals.TextFG1, 'text1_fg': PiratesGuiGlobals.TextFG1, 'text2_fg': PiratesGuiGlobals.TextFG1, 'text3_fg': PiratesGuiGlobals.TextFG9, 'text_font': PiratesGlobals.getInterfaceFont(), 'text_scale': 0.14999999999999999, 'text_shadow': (0, 0, 0, 1), 'text_align': TextNode.ALeft, 'command': self.allowFriends } self.friendsButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowCrew buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowCrew buttonOptions['value'] = crewState self.crewButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowGuild buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowGuild buttonOptions['value'] = guildState self.guildButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowPublic buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowPublic buttonOptions['value'] = publicState self.publicButton = CheckButton(**None) self.guiSetup = True
class ShipFrameBoard(ShipFrame): def __init__(self, parent, **kw): gui = loader.loadModel('models/gui/toplevel_gui') image = (gui.find('**/generic_button'), gui.find('**/generic_button_down'), gui.find('**/generic_button_over'), gui.find('**/generic_button_disabled')) optiondefs = (('relief', 0, None), ('frameSize', (0.0, 0.90000000000000002, 0.0, 0.41999999999999998), None), ('image', image[3], None), ('image_pos', (0.45000000000000001, 0.0, 0.20799999999999999), None), ('image_scale', (0.93999999999999995, 1, 1.1000000000000001), None), ('image_color', (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), None), ('frameColor', (1, 1, 1, 0.90000000000000002), None), ('snapShotPos', (-0.040000000000000001, 0, -0.080000000000000002), None), ('shipPos', VBase3(0.20000000000000001, 0, 0.080000000000000002), None), ('shipHpr', VBase3(-70, 6, 15), None), ('shipScale', VBase3(0.55000000000000004), None), ('time', 0, None), ('command', None, None), ('extraArgs', [], None)) self.nameLabel = None self.classLabel = None self.typeLabel = None self.stateLabel = None self.button = None self.snapShot = None self.defineoptions(kw, optiondefs) ShipFrame.__init__(self, parent) self.initialiseoptions(ShipFrameBoard) def destroy(self): self.nameLabel = None self.classLabel = None self.typeLabel = None self.stateLabel = None self.button = None self.snapShot = None ShipFrame.destroy(self) def createGui(self): ShipFrame.createGui(self) self.nameLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(self['shipName'], 2), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_pos = (0.059999999999999998, 0.014999999999999999), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, frameColor = PiratesGuiGlobals.ButtonColor1[3], frameSize = (self['frameSize'][0] + 0.040000000000000001, self['frameSize'][1] - 0.029999999999999999, -0.0, 0.050000000000000003), pos = (0, 0, self['frameSize'][3] - 0.089999999999999997)) self.classLabel = DirectLabel(parent = self.nameLabel, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(PLocalizer.ShipClassNames.get(self['shipClass']), 1), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleMed, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_pos = (self.nameLabel['frameSize'][0] + 0.02, -0.029999999999999999)) self.timer = PiratesTimer.PiratesTimer(showMinutes = True, mode = None, titleText = '', titleFg = '', infoText = '', cancelText = '', cancelCallback = None) self.timer.setFontColor(PiratesGuiGlobals.TextFG2) self.timer.reparentTo(self) self.timer.setScale(0.55000000000000004) self.timer.setPos(0.62, 0, 0.315) self.timer.unstash() self.timer.countdown(self['time']) self.mainText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = 'How will you lead your crew?', text_pos = (0.62, 0.20000000000000001), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 10, text_shadow = (0, 0, 0, 1), textMayChange = 1) gui = loader.loadModel('models/gui/toplevel_gui') geomCheck = gui.find('**/generic_check') self.yesButton = DialogButton(parent = self, buttonStyle = DialogButton.YES, pos = (0.5, 0, 0.080000000000000002), text = PLocalizer.BoardShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), geom = (geomCheck,) * 4, geom_pos = (-0.059999999999999998, 0, 0), geom_scale = 0.5, geom0_color = PiratesGuiGlobals.ButtonColor6[0], geom1_color = PiratesGuiGlobals.ButtonColor6[1], geom2_color = PiratesGuiGlobals.ButtonColor6[2], geom3_color = PiratesGuiGlobals.ButtonColor6[3], image3_color = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ True]) self.noButton = DialogButton(parent = self, buttonStyle = DialogButton.NO, pos = (0.73999999999999999, 0, 0.080000000000000002), text = PLocalizer.ParlayShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ False]) self.noButton.hide() def enableStats(self, shipName = '', shipClass = 0, mastInfo = [], hp = 0, sp = 0, cargo = 0, crew = 0, time = 0): pass
def createGui(self): ShipFrame.createGui(self) self.nameLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(self['shipName'], 2), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_pos = (0.059999999999999998, 0.014999999999999999), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, frameColor = PiratesGuiGlobals.ButtonColor1[3], frameSize = (self['frameSize'][0] + 0.040000000000000001, self['frameSize'][1] - 0.029999999999999999, -0.0, 0.050000000000000003), pos = (0, 0, self['frameSize'][3] - 0.089999999999999997)) self.classLabel = DirectLabel(parent = self.nameLabel, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(PLocalizer.ShipClassNames.get(self['shipClass']), 1), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleMed, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_pos = (self.nameLabel['frameSize'][0] + 0.02, -0.029999999999999999)) self.timer = PiratesTimer.PiratesTimer(showMinutes = True, mode = None, titleText = '', titleFg = '', infoText = '', cancelText = '', cancelCallback = None) self.timer.setFontColor(PiratesGuiGlobals.TextFG2) self.timer.reparentTo(self) self.timer.setScale(0.55000000000000004) self.timer.setPos(0.62, 0, 0.315) self.timer.unstash() self.timer.countdown(self['time']) self.mainText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = 'How will you lead your crew?', text_pos = (0.62, 0.20000000000000001), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 10, text_shadow = (0, 0, 0, 1), textMayChange = 1) gui = loader.loadModel('models/gui/toplevel_gui') geomCheck = gui.find('**/generic_check') self.yesButton = DialogButton(parent = self, buttonStyle = DialogButton.YES, pos = (0.5, 0, 0.080000000000000002), text = PLocalizer.BoardShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), geom = (geomCheck,) * 4, geom_pos = (-0.059999999999999998, 0, 0), geom_scale = 0.5, geom0_color = PiratesGuiGlobals.ButtonColor6[0], geom1_color = PiratesGuiGlobals.ButtonColor6[1], geom2_color = PiratesGuiGlobals.ButtonColor6[2], geom3_color = PiratesGuiGlobals.ButtonColor6[3], image3_color = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ True]) self.noButton = DialogButton(parent = self, buttonStyle = DialogButton.NO, pos = (0.73999999999999999, 0, 0.080000000000000002), text = PLocalizer.ParlayShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ False])
def createGui(self): ShipFrame.createGui(self) self.nameLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(self['shipName'], 2), text_align = TextNode.ALeft, text_scale = 0.050000000000000003, text_pos = (0.059999999999999998, 0.014999999999999999), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, frameColor = PiratesGuiGlobals.ButtonColor1[3], frameSize = (self['frameSize'][0] + 0.040000000000000001, self['frameSize'][1] - 0.029999999999999999, -0.0, 0.050000000000000003), pos = (0, 0, self['frameSize'][3] - 0.089999999999999997)) self.classLabel = DirectLabel(parent = self.nameLabel, relief = None, state = DGG.DISABLED, text = PLocalizer.makeHeadingString(PLocalizer.ShipClassNames.get(self['shipClass']), 1), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleMed, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_pos = (self.nameLabel['frameSize'][0] + 0.02, -0.029999999999999999)) self.timer = PiratesTimer.PiratesTimer(showMinutes = True, mode = None, titleText = '', titleFg = '', infoText = '', cancelText = '', cancelCallback = None) self.timer.setFontColor(PiratesGuiGlobals.TextFG2) self.timer.reparentTo(self) self.timer.setScale(0.55000000000000004) self.timer.setPos(0.62, 0, 0.315) self.timer.unstash() self.timer.countdown(self['time']) self.mainText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = 'How will you lead your crew?', text_pos = (0.62, 0.20000000000000001), text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 10, text_shadow = (0, 0, 0, 1), textMayChange = 1) gui = loader.loadModel('models/gui/toplevel_gui') geomCheck = gui.find('**/generic_check') self.yesButton = DialogButton(parent = self, buttonStyle = DialogButton.YES, pos = (0.5, 0, 0.080000000000000002), text = PLocalizer.BoardShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), geom = (geomCheck,) * 4, geom_pos = (-0.059999999999999998, 0, 0), geom_scale = 0.5, geom0_color = PiratesGuiGlobals.ButtonColor6[0], geom1_color = PiratesGuiGlobals.ButtonColor6[1], geom2_color = PiratesGuiGlobals.ButtonColor6[2], geom3_color = PiratesGuiGlobals.ButtonColor6[3], image3_color = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ True]) self.noButton = DialogButton(parent = self, buttonStyle = DialogButton.NO, pos = (0.73999999999999999, 0, 0.080000000000000002), text = PLocalizer.ParlayShip, text_scale = PiratesGuiGlobals.TextScaleLarge, text_font = PiratesGlobals.getInterfaceFont(), text_pos = (0.035000000000000003, -0.014), helpPos = (0, 0, -0.12), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = [ False]) self.noButton.hide()
class Subtitler(DirectObject.DirectObject): __module__ = __name__ def __init__(self): DirectObject.DirectObject.__init__(self) self.event = None self.sfx = None self.text = DirectLabel(parent=render2d, relief=None, text='', text_align=TextNode.ACenter, text_scale=0.055, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, text_font=PiratesGlobals.getPirateFont(), pos=(0, 0, -0.9), sortOrder=80) self.confirmButton = DialogButton(parent=base.a2dBottomRight, pos=(-0.15, 0, 0.095), text=PLocalizer.MakeAPirateNext, text_scale=0.05, text_pos=(0.04, -0.018), text_fg=PiratesGuiGlobals.TextFG2, textMayChange=1, command=self.advancePageNumber, sortOrder=90, buttonStyle=DialogButton.YES) self.EscText = DirectLabel(parent=render2d, relief=None, text='', text_align=TextNode.ALeft, text_scale=0.055, text_fg=PiratesGuiGlobals.TextFG9, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, text_font=PiratesGlobals.getPirateFont(), pos=(-0.92, 0, 0.88), sortOrder=80) base.transitions.loadLetterbox() self.text.setScale(aspect2d, 1) self.accept('aspectRatioChanged', self.text.setScale, [aspect2d, 1]) self.text.hide() self.confirmButton.hide() self.EscText.hide() self.fader = None self.subtitleParent = render2d.attachNewNode(PGTop('subtitleParent')) self.subtitleParent.node().setMouseWatcher(base.mouseWatcherNode) self.__chatPageNumber = None self.__chatPages = None self.__chatMessage = None self.__chatPages = [] self.__optionButtons = [] self.specialButtonImage = None self.clearTextOverride = False return def destroy(self): self.ignoreAll() if self.fader: self.fader.finish() self.fader = None if self.sfx: self.sfx.stop() self.sfx = None self.text.destroy() del self.text self.confirmButton.destroy() del self.confirmButton self.EscText.destroy() del self.EscText self.subtitleParent.removeNode() self.__destroyOptionButtons() taskMgr.remove('clearSubtitleTask') return def clearText(self, resetOverride=False): if resetOverride: self.clearTextOverride = False if self.clearTextOverride: return taskMgr.remove('clearSubtitleTask') self.event = None self.text['text'] = '' self.text['text_fg'] = PiratesGuiGlobals.TextFG2 self.text.hide() self.confirmButton.hide() if self.sfx: self.sfx.stop() self.sfx = None self.ignore('enter') self.ignore('mouse1') self.ignore('letterboxOff') self.__clearChatMessage() self.__destroyOptionButtons() self.__optionButtons = [] return def __processChatMessage(self, message): self.__chatPages = message.split('\x07') self.__chatMessage = message self.__chatSet = 0 self.__chatPageNumber = 0 def __clearChatMessage(self): self.__chatPageNumber = None self.__chatPages = None self.__chatMessage = None self.__chatPages = [] return def setPageChat(self, message, timeout=False, confirm=False, options=None, callback=None, extraArgs=[]): if options != None: self.__loadOptionButtons(options, callback, extraArgs) self.__processChatMessage(message) self.__updatePageChat(timeout, confirm) return def __loadOptionButtons(self, options, callback, extraArgs): def optionCallback(*args): self.advancePageNumber() callback(*args) for i in xrange(len(options)): optionButton = GuiButton(parent=base.a2dBottomRight, pos=(-0.15 - (len(options) - 1 - i) * 0.25, 0, 0.095), text=str(options[i]), text_pos=(0, -0.0125), text_scale=0.05, text_fg=PiratesGuiGlobals.TextFG2, textMayChange=1, command=optionCallback, extraArgs=[options[i]] + extraArgs, sortOrder=90) if self.specialButtonImage: optionButton['image'] = self.specialButtonImage optionButton['image_scale'] = (0.6, 0.6, 0.6) optionButton.hide() self.__optionButtons.append(optionButton) def __destroyOptionButtons(self): for optionButton in self.__optionButtons: optionButton.destroy() del optionButton self.__optionButtons = None return def __updatePageChat(self, timeout=False, confirm=False): if self.__chatPageNumber >= 0: message = self.__chatPages[self.__chatPageNumber] self.showText(message, timeout=timeout, confirm=confirm) def getNumChatPages(self): if self.__chatPageNumber != None: return len(self.__chatPages) return 0 def advancePageNumber(self): if self.__chatPageNumber != None: if self.__chatPageNumber >= 0: self.__chatPageNumber += 1 if self.__chatPageNumber >= len(self.__chatPages): self.__chatPageNumber = -1 self.__updatePageChat() if self.__chatPageNumber >= 0: messenger.send('nextChatPage', [self.__chatPageNumber, 0]) else: messenger.send('doneChatPage', [0]) self.confirmCallback() return def showText(self, text, color=None, sfx=None, timeout=0, confirm=False): taskMgr.remove('clearSubtitleTask') self.text['text'] = text self.text.show() self.accept('letterboxOff', self.clearText) if self.getNumChatPages() > 1 or self.__optionButtons or confirm: self.confirmButton.show() if self.__chatPageNumber == len(self.__chatPages) - 1: messenger.send('lastSubtitlePage') if self.__optionButtons: for optionButton in self.__optionButtons: optionButton.show() self.confirmButton.hide() else: self.confirmButton['text'] = PLocalizer.GenericConfirmOK else: self.confirmButton['text'] = PLocalizer.GenericConfirmNext else: self.confirmButton.hide() self.event = None if color: self.text['text_fg'] = color if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) if timeout: taskMgr.doMethodLater(timeout, self.clearText, 'clearSubtitleTask', extraArgs=[True]) return def fadeInText(self, text, color=None, sfx=None): self.text['text'] = text self.text.show() self.confirmButton.hide() self.event = None if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) if self.fader: self.fader.finish() self.fader = None if color: self.text['text_fg'] = color self.fader = LerpFunctionInterval(self.text.setAlphaScale, fromData=0, toData=1, duration=1.0) self.fader.start() return def fadeOutText(self): self.event = None self.confirmButton.hide() if self.sfx: self.sfx.stop() self.sfx = None self.ignore('enter') self.ignore('mouse1') if self.fader: self.fader.finish() self.fader = None fadeOut = LerpFunctionInterval(self.text.setAlphaScale, fromData=1, toData=0, duration=1.0) def restoreColor(): self.text['text_fg'] = PiratesGuiGlobals.TextFG2 def resetPos(): self.text.setPos(Vec3(0.0, 0.0, 0.0)) self.fader = Sequence(fadeOut, Func(self.text.hide), Func(restoreColor), Func(resetPos)) self.fader.start() return def confirmText(self, text, event, color=None, sfx=None): self.text['text'] = text if color: self.text['text_fg'] = color self.text.show() self.confirmButton.show() self.event = event if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) self.confirmButton['command'] = self.confirmCallback def confirmCallback(self): if self.event: messenger.send(self.event) self.event = None self.clearText() self.hideEscapeText() self.confirmButton['command'] = self.advancePageNumber return def showEscapeText(self, text): self.EscText['text'] = text self.EscText.show() def hideEscapeText(self): self.EscText['text'] = '' self.EscText.hide()
class BoardingPermissionPanel(GuiPanel): def __init__(self, parent, *args, **kw): self.guiSetup = False optiondefs = (('parent', parent, None), ('pos', (-0.57999999999999996, 0, -0.089999999999999997), None), ('command', None, None), ('extraArgs', [], None), ('ownShip', 0, None)) self.defineoptions(kw, optiondefs) GuiPanel.__init__(self, title = PLocalizer.BoardPermTitle, h = 0.80000000000000004, w = 0.5, titleSize = 1.5, showClose = False) self.initialiseoptions(BoardingPermissionPanel) self.titleLabel['text_align'] = TextNode.ACenter self.titleLabel.setPos(0.23000000000000001, 0, 0.71999999999999997) self.setupGui() def destroy(self): self.button = None self.background = None self.friendsButton = None self.crewButton = None self.guildButton = None self.publicButton = None GuiPanel.destroy(self) def setupGui(self): self.destroyGui() if not self.guiSetup: self.button = DialogButton(parent = self, buttonStyle = DialogButton.NO, pos = (0.25, 0, 0.080000000000000002), text = PLocalizer.lClose, helpPos = (-0.40000000000000002, 0, 0.029999999999999999), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = self['extraArgs']) self.background = BorderFrame(parent = self, pos = (0.050000000000000003, 0, 0.050000000000000003), frameSize = [ 0.0, 0.40000000000000002, 0.10000000000000001, 0.59999999999999998], bgColorScale = VBase4(0, 0, 0, 0.75), bgTransparency = 1, flatten = 0) if self['ownShip']: state = DGG.NORMAL else: state = DGG.DISABLED ship = localAvatar.getShip() if ship: friendState = ship.getAllowFriendState() crewState = ship.getAllowCrewState() guildState = ship.getAllowGuildState() publicState = ship.getAllowPublicState() else: friendState = 0 crewState = 0 guildState = 0 publicState = 0 buttonOptions = { 'parent': self.background, 'state': state, 'relief': None, 'pos': (0.059999999999999998, 0, 0.53000000000000003), 'scale': 0.29999999999999999, 'text': PLocalizer.CrewBoardingAccessAllowFriends, 'value': friendState, 'text_pos': (0.16700000000000001, -0.059999999999999998, 0), 'text0_fg': PiratesGuiGlobals.TextFG1, 'text1_fg': PiratesGuiGlobals.TextFG1, 'text2_fg': PiratesGuiGlobals.TextFG1, 'text3_fg': PiratesGuiGlobals.TextFG9, 'text_font': PiratesGlobals.getInterfaceFont(), 'text_scale': 0.14999999999999999, 'text_shadow': (0, 0, 0, 1), 'text_align': TextNode.ALeft, 'command': self.allowFriends } self.friendsButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowCrew buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowCrew buttonOptions['value'] = crewState self.crewButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowGuild buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowGuild buttonOptions['value'] = guildState self.guildButton = CheckButton(**None) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowPublic buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowPublic buttonOptions['value'] = publicState self.publicButton = CheckButton(**None) self.guiSetup = True def destroyGui(self): if self.guiSetup: self.background.destroy() self.background = None self.friendsButton.destroy() self.friendsButton = None self.crewButton.destroy() self.crewButton = None self.guildButton.destroy() self.guildButton = None self.publicButton.destroy() self.publicButton = None self.button.destroy() self.button = None self.guiSetup = False def allowFriends(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowFriendState(allow) def allowCrew(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowCrewState(allow) def allowGuild(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowGuildState(allow) def allowPublic(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowPublicState(allow) def setAllowFriends(self, allow): self.friendsButton['value'] = allow def setAllowCrew(self, allow): self.crewButton['value'] = allow def setAllowGuild(self, allow): self.guildButton['value'] = allow def setAllowPublic(self, allow): self.publicButton['value'] = allow
class BoardingPermissionPanel(GuiPanel): def __init__(self, parent, *args, **kw): self.guiSetup = False optiondefs = (('parent', parent, None), ('pos', (-0.58, 0, -0.09), None), ('command', None, None), ('extraArgs', [], None), ('ownShip', 0, None)) self.defineoptions(kw, optiondefs) GuiPanel.__init__(self, title=PLocalizer.BoardPermTitle, h=0.8, w=0.5, titleSize=1.5, showClose=False, **kw) self.initialiseoptions(BoardingPermissionPanel) self.titleLabel['text_align'] = TextNode.ACenter self.titleLabel.setPos(0.23, 0, 0.72) self.setupGui() return def destroy(self): self.button = None self.background = None self.friendsButton = None self.crewButton = None self.guildButton = None self.publicButton = None GuiPanel.destroy(self) return def setupGui(self): self.destroyGui() if not self.guiSetup: self.button = DialogButton(parent=self, buttonStyle=DialogButton.NO, pos=(0.25, 0, 0.08), text=PLocalizer.lClose, helpPos=(-0.4, 0, 0.03), helpDelay=0.3, command=self['command'], extraArgs=self['extraArgs']) self.background = BorderFrame(parent=self, pos=(0.05, 0, 0.05), frameSize=[0.0, 0.4, 0.1, 0.6], bgColorScale=VBase4(0, 0, 0, 0.75), bgTransparency=1, flatten=0) if self['ownShip']: state = DGG.NORMAL else: state = DGG.DISABLED ship = localAvatar.getShip() if ship: friendState = ship.getAllowFriendState() crewState = ship.getAllowCrewState() guildState = ship.getAllowGuildState() publicState = ship.getAllowPublicState() else: friendState = 0 crewState = 0 guildState = 0 publicState = 0 buttonOptions = { 'parent': self.background, 'state': state, 'relief': None, 'pos': (0.06, 0, 0.53), 'scale': 0.3, 'text': PLocalizer.CrewBoardingAccessAllowFriends, 'value': friendState, 'text_pos': (0.167, -0.06, 0), 'text0_fg': PiratesGuiGlobals.TextFG1, 'text1_fg': PiratesGuiGlobals.TextFG1, 'text2_fg': PiratesGuiGlobals.TextFG1, 'text3_fg': PiratesGuiGlobals.TextFG9, 'text_font': PiratesGlobals.getInterfaceFont(), 'text_scale': 0.15, 'text_shadow': (0, 0, 0, 1), 'text_align': TextNode.ALeft, 'command': self.allowFriends } self.friendsButton = CheckButton(**buttonOptions) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowCrew buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowCrew buttonOptions['value'] = crewState self.crewButton = CheckButton(**buttonOptions) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowGuild buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowGuild buttonOptions['value'] = guildState self.guildButton = CheckButton(**buttonOptions) buttonOptions['text'] = PLocalizer.CrewBoardingAccessAllowPublic buttonOptions['pos'] = (buttonOptions['pos'][0], buttonOptions['pos'][1], buttonOptions['pos'][2] - 0.12) buttonOptions['command'] = self.allowPublic buttonOptions['value'] = publicState self.publicButton = CheckButton(**buttonOptions) self.guiSetup = True return def destroyGui(self): if self.guiSetup: self.background.destroy() self.background = None self.friendsButton.destroy() self.friendsButton = None self.crewButton.destroy() self.crewButton = None self.guildButton.destroy() self.guildButton = None self.publicButton.destroy() self.publicButton = None self.button.destroy() self.button = None self.guiSetup = False return def allowFriends(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowFriendState(allow) def allowCrew(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowCrewState(allow) def allowGuild(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowGuildState(allow) def allowPublic(self, allow): if self['ownShip']: ship = localAvatar.getShip() if ship: ship.b_setAllowPublicState(allow) def setAllowFriends(self, allow): self.friendsButton['value'] = allow def setAllowCrew(self, allow): self.crewButton['value'] = allow def setAllowGuild(self, allow): self.guildButton['value'] = allow def setAllowPublic(self, allow): self.publicButton['value'] = allow
class ShipFrameBoard(ShipFrame): def __init__(self, parent, **kw): gui = loader.loadModel('models/gui/toplevel_gui') image = (gui.find('**/generic_button'), gui.find('**/generic_button_down'), gui.find('**/generic_button_over'), gui.find('**/generic_button_disabled')) optiondefs = (('relief', 0, None), ('frameSize', (0.0, 0.90000000000000002, 0.0, 0.41999999999999998), None), ('image', image[3], None), ('image_pos', (0.45000000000000001, 0.0, 0.20799999999999999), None), ('image_scale', (0.93999999999999995, 1, 1.1000000000000001), None), ('image_color', (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), None), ('frameColor', (1, 1, 1, 0.90000000000000002), None), ('snapShotPos', (-0.040000000000000001, 0, -0.080000000000000002), None), ('shipPos', VBase3(0.20000000000000001, 0, 0.080000000000000002), None), ('shipHpr', VBase3(-70, 6, 15), None), ('shipScale', VBase3(0.55000000000000004), None), ('time', 0, None), ('command', None, None), ('extraArgs', [], None)) self.nameLabel = None self.classLabel = None self.typeLabel = None self.stateLabel = None self.button = None self.snapShot = None self.defineoptions(kw, optiondefs) ShipFrame.__init__(self, parent) self.initialiseoptions(ShipFrameBoard) def destroy(self): self.nameLabel = None self.classLabel = None self.typeLabel = None self.stateLabel = None self.button = None self.snapShot = None ShipFrame.destroy(self) def createGui(self): ShipFrame.createGui(self) self.nameLabel = DirectLabel( parent=self, relief=None, state=DGG.DISABLED, text=PLocalizer.makeHeadingString(self['shipName'], 2), text_align=TextNode.ALeft, text_scale=0.050000000000000003, text_pos=(0.059999999999999998, 0.014999999999999999), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, frameColor=PiratesGuiGlobals.ButtonColor1[3], frameSize=(self['frameSize'][0] + 0.040000000000000001, self['frameSize'][1] - 0.029999999999999999, -0.0, 0.050000000000000003), pos=(0, 0, self['frameSize'][3] - 0.089999999999999997)) self.classLabel = DirectLabel( parent=self.nameLabel, relief=None, state=DGG.DISABLED, text=PLocalizer.makeHeadingString( PLocalizer.ShipClassNames.get(self['shipClass']), 1), text_font=PiratesGlobals.getInterfaceFont(), text_scale=PiratesGuiGlobals.TextScaleMed, text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=(0, 0, 0, 1), textMayChange=1, text_pos=(self.nameLabel['frameSize'][0] + 0.02, -0.029999999999999999)) self.timer = PiratesTimer.PiratesTimer(showMinutes=True, mode=None, titleText='', titleFg='', infoText='', cancelText='', cancelCallback=None) self.timer.setFontColor(PiratesGuiGlobals.TextFG2) self.timer.reparentTo(self) self.timer.setScale(0.55000000000000004) self.timer.setPos(0.62, 0, 0.315) self.timer.unstash() self.timer.countdown(self['time']) self.mainText = DirectLabel( parent=self, relief=None, state=DGG.DISABLED, text='How will you lead your crew?', text_pos=(0.62, 0.20000000000000001), text_font=PiratesGlobals.getInterfaceFont(), text_scale=PiratesGuiGlobals.TextScaleLarge, text_align=TextNode.ACenter, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=10, text_shadow=(0, 0, 0, 1), textMayChange=1) gui = loader.loadModel('models/gui/toplevel_gui') geomCheck = gui.find('**/generic_check') self.yesButton = DialogButton( parent=self, buttonStyle=DialogButton.YES, pos=(0.5, 0, 0.080000000000000002), text=PLocalizer.BoardShip, text_scale=PiratesGuiGlobals.TextScaleLarge, text_font=PiratesGlobals.getInterfaceFont(), text_pos=(0.035000000000000003, -0.014), geom=(geomCheck, ) * 4, geom_pos=(-0.059999999999999998, 0, 0), geom_scale=0.5, geom0_color=PiratesGuiGlobals.ButtonColor6[0], geom1_color=PiratesGuiGlobals.ButtonColor6[1], geom2_color=PiratesGuiGlobals.ButtonColor6[2], geom3_color=PiratesGuiGlobals.ButtonColor6[3], image3_color=(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), helpPos=(0, 0, -0.12), helpDelay=0.29999999999999999, command=self['command'], extraArgs=[True]) self.noButton = DialogButton( parent=self, buttonStyle=DialogButton.NO, pos=(0.73999999999999999, 0, 0.080000000000000002), text=PLocalizer.ParlayShip, text_scale=PiratesGuiGlobals.TextScaleLarge, text_font=PiratesGlobals.getInterfaceFont(), text_pos=(0.035000000000000003, -0.014), helpPos=(0, 0, -0.12), helpDelay=0.29999999999999999, command=self['command'], extraArgs=[False]) self.noButton.hide() def enableStats(self, shipName='', shipClass=0, mastInfo=[], hp=0, sp=0, cargo=0, crew=0, time=0): pass
class Subtitler(DirectObject.DirectObject): def __init__(self): DirectObject.DirectObject.__init__(self) self.event = None self.sfx = None self.text = DirectLabel(parent = render2d, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.055, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, text_font = PiratesGlobals.getPirateFont(), pos = (0, 0, -0.90000000000000002), sortOrder = 80) self.confirmButton = DialogButton(parent = base.a2dBottomRight, pos = (-0.14999999999999999, 0, 0.095000000000000001), text = PLocalizer.MakeAPirateNext, text_scale = 0.050000000000000003, text_pos = (0.040000000000000001, -0.017999999999999999), text_fg = PiratesGuiGlobals.TextFG2, textMayChange = 1, command = self.advancePageNumber, sortOrder = 90, buttonStyle = DialogButton.YES) self.EscText = DirectLabel(parent = render2d, relief = None, text = '', text_align = TextNode.ALeft, text_scale = 0.055, text_fg = PiratesGuiGlobals.TextFG9, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, text_font = PiratesGlobals.getPirateFont(), pos = (-0.92000000000000004, 0, 0.88), sortOrder = 80) base.transitions.loadLetterbox() self.text.setScale(aspect2d, 1) self.accept('aspectRatioChanged', self.text.setScale, [ aspect2d, 1]) self.text.hide() self.confirmButton.hide() self.EscText.hide() self.fader = None self.subtitleParent = render2d.attachNewNode(PGTop('subtitleParent')) self.subtitleParent.node().setMouseWatcher(base.mouseWatcherNode) self._Subtitler__chatPageNumber = None self._Subtitler__chatPages = None self._Subtitler__chatMessage = None self._Subtitler__chatPages = [] self._Subtitler__optionButtons = [] self.specialButtonImage = None self.clearTextOverride = False def destroy(self): self.ignoreAll() if self.fader: self.fader.finish() self.fader = None if self.sfx: self.sfx.stop() self.sfx = None self.text.destroy() del self.text self.confirmButton.destroy() del self.confirmButton self.EscText.destroy() del self.EscText self.subtitleParent.removeNode() self._Subtitler__destroyOptionButtons() taskMgr.remove('clearSubtitleTask') def clearText(self, resetOverride = False): if resetOverride: self.clearTextOverride = False if self.clearTextOverride: return None taskMgr.remove('clearSubtitleTask') self.event = None self.text['text'] = '' self.text['text_fg'] = PiratesGuiGlobals.TextFG2 self.text.hide() self.confirmButton.hide() if self.sfx: self.sfx.stop() self.sfx = None self.ignore('enter') self.ignore('mouse1') self.ignore('letterboxOff') self._Subtitler__clearChatMessage() self._Subtitler__destroyOptionButtons() self._Subtitler__optionButtons = [] def _Subtitler__processChatMessage(self, message): self._Subtitler__chatPages = [] self._Subtitler__chatMessage = message self._Subtitler__chatSet = 0 self._Subtitler__chatPageNumber = 0 def _Subtitler__clearChatMessage(self): self._Subtitler__chatPageNumber = None self._Subtitler__chatPages = None self._Subtitler__chatMessage = None self._Subtitler__chatPages = [] def setPageChat(self, message, timeout = False, confirm = False, options = None, callback = None, extraArgs = []): if options != None: self._Subtitler__loadOptionButtons(options, callback, extraArgs) self._Subtitler__processChatMessage(message) self._Subtitler__updatePageChat(timeout, confirm) def _Subtitler__loadOptionButtons(self, options, callback, extraArgs): def optionCallback(*args): self.advancePageNumber() callback(*args) for i in xrange(len(options)): optionButton = GuiButton(parent = base.a2dBottomRight, pos = (-0.14999999999999999 - (len(options) - 1 - i) * 0.25, 0, 0.095000000000000001), text = str(options[i]), text_pos = (0, -0.012500000000000001), text_scale = 0.050000000000000003, text_fg = PiratesGuiGlobals.TextFG2, textMayChange = 1, command = optionCallback, extraArgs = [ options[i]] + extraArgs, sortOrder = 90) if self.specialButtonImage: optionButton['image'] = self.specialButtonImage optionButton['image_scale'] = (0.59999999999999998, 0.59999999999999998, 0.59999999999999998) optionButton.hide() self._Subtitler__optionButtons.append(optionButton) def _Subtitler__destroyOptionButtons(self): for optionButton in self._Subtitler__optionButtons: optionButton.destroy() del optionButton self._Subtitler__optionButtons = None def _Subtitler__updatePageChat(self, timeout = False, confirm = False): if self._Subtitler__chatPageNumber >= 0: message = self._Subtitler__chatPages[self._Subtitler__chatPageNumber] self.showText(message, timeout = timeout, confirm = confirm) def getNumChatPages(self): if self._Subtitler__chatPageNumber != None: return len(self._Subtitler__chatPages) return 0 def advancePageNumber(self): if self._Subtitler__chatPageNumber != None: if self._Subtitler__chatPageNumber >= 0: self._Subtitler__chatPageNumber += 1 if self._Subtitler__chatPageNumber >= len(self._Subtitler__chatPages): self._Subtitler__chatPageNumber = -1 self._Subtitler__updatePageChat() if self._Subtitler__chatPageNumber >= 0: messenger.send('nextChatPage', [ self._Subtitler__chatPageNumber, 0]) else: messenger.send('doneChatPage', [ 0]) self.confirmCallback() def showText(self, text, color = None, sfx = None, timeout = 0, confirm = False): taskMgr.remove('clearSubtitleTask') self.text['text'] = text self.text.show() self.accept('letterboxOff', self.clearText) if self.getNumChatPages() > 1 and self._Subtitler__optionButtons or confirm: self.confirmButton.show() if self._Subtitler__chatPageNumber == len(self._Subtitler__chatPages) - 1: messenger.send('lastSubtitlePage') if self._Subtitler__optionButtons: for optionButton in self._Subtitler__optionButtons: optionButton.show() self.confirmButton.hide() else: self.confirmButton['text'] = PLocalizer.GenericConfirmOK else: self.confirmButton['text'] = PLocalizer.GenericConfirmNext else: self.confirmButton.hide() self.event = None if color: self.text['text_fg'] = color if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) if timeout: taskMgr.doMethodLater(timeout, self.clearText, 'clearSubtitleTask', extraArgs = [ True]) def fadeInText(self, text, color = None, sfx = None): self.text['text'] = text self.text.show() self.confirmButton.hide() self.event = None if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) if self.fader: self.fader.finish() self.fader = None if color: self.text['text_fg'] = color self.fader = LerpFunctionInterval(self.text.setAlphaScale, fromData = 0, toData = 1, duration = 1.0) self.fader.start() def fadeOutText(self): self.event = None self.confirmButton.hide() if self.sfx: self.sfx.stop() self.sfx = None self.ignore('enter') self.ignore('mouse1') if self.fader: self.fader.finish() self.fader = None fadeOut = LerpFunctionInterval(self.text.setAlphaScale, fromData = 1, toData = 0, duration = 1.0) def restoreColor(): self.text['text_fg'] = PiratesGuiGlobals.TextFG2 def resetPos(): self.text.setPos(Vec3(0.0, 0.0, 0.0)) self.fader = Sequence(fadeOut, Func(self.text.hide), Func(restoreColor), Func(resetPos)) self.fader.start() def confirmText(self, text, event, color = None, sfx = None): self.text['text'] = text if color: self.text['text_fg'] = color self.text.show() self.confirmButton.show() self.event = event if sfx: if self.sfx: self.sfx.stop() self.sfx = sfx base.playSfx(sfx) self.confirmButton['command'] = self.confirmCallback def confirmCallback(self): if self.event: messenger.send(self.event) self.event = None self.clearText() self.hideEscapeText() self.confirmButton['command'] = self.advancePageNumber def showEscapeText(self, text): self.EscText['text'] = text self.EscText.show() def hideEscapeText(self): self.EscText['text'] = '' self.EscText.hide()