def createGui(self):
     ShipFrame.createGui(self)
     if self['shipName']:
         self.nameLabel = DirectLabel(
             parent=self,
             relief=DGG.FLAT,
             state=DGG.DISABLED,
             text=self['shipName'],
             text_font=PiratesGlobals.getInterfaceFont(),
             text_align=TextNode.ALeft,
             text_scale=PiratesGuiGlobals.TextScaleMed,
             text_pos=(0.04, 0.015),
             text_fg=PiratesGuiGlobals.TextFG1,
             text_shadow=PiratesGuiGlobals.TextShadow,
             textMayChange=1,
             frameColor=PiratesGuiGlobals.ButtonColor1[3],
             frameSize=(self['frameSize'][0] + 0.02,
                        self['frameSize'][1] - 0.02, 0, 0.05),
             pos=(0, 0, self['frameSize'][3] - 0.06))
     if self['shipClass']:
         self.classLabel = DirectLabel(
             parent=self.nameLabel,
             relief=None,
             state=DGG.DISABLED,
             text=PLocalizer.ShipClassNames.get(self['shipClass']),
             text_scale=PiratesGuiGlobals.TextScaleMed,
             text_align=TextNode.ARight,
             text_fg=PiratesGuiGlobals.TextFG2,
             text_shadow=(0, 0, 0, 1),
             text_wordwrap=15,
             textMayChange=0,
             text_pos=(self.nameLabel['frameSize'][1] - 0.02, 0.015),
             text_font=PiratesGlobals.getInterfaceFont())
     return
Esempio n. 2
0
 def loadGui(self):
     self.dummyFrame = DirectFrame(parent=self,
                                   relief=None,
                                   pos=(-0.42999999999999999, 0,
                                        1.3799999999999999),
                                   sortOrder=-1000)
     self.skillRingFrame = SkillRing(color=Vec4(1, 1, 0, 1))
     self.skillRingFrame.reparentTo(self.dummyFrame)
     self.skillRingFrame.setPos(-0.089999999999999997, 0,
                                -0.029999999999999999)
     self.skillIconFrame = DirectFrame(parent=self.skillRingFrame,
                                       pos=(0, 0, 0),
                                       relief=None,
                                       image=self.skillIcon,
                                       image_scale=(0.14000000000000001, 1,
                                                    0.14000000000000001))
     self.buffTitle = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(-0.16, 0, 0.080000000000000002),
         text=PLocalizer.CrewBuffCaptainOrder,
         text_align=TextNode.ALeft,
         text_scale=0.050000000000000003,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG13,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
     self.buffNameFrame = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(0.0, 0, 0.0),
         text=self.buffName,
         text_align=TextNode.ALeft,
         text_scale=0.047,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG1,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
     self.buffDescFrame = DirectFrame(
         parent=self.dummyFrame,
         relief=None,
         pos=(0.0, 0, -0.044999999999999998),
         text=self.buffDesc,
         text_align=TextNode.ALeft,
         text_scale=0.036999999999999998,
         text_pos=(0, 0),
         text_fg=PiratesGuiGlobals.TextFG2,
         text_wordwrap=15,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0,
         text_font=PiratesGlobals.getInterfaceFont())
 def startWave(self, countdown, currWave, maxWave):
     self.currWave = currWave
     self.maxWave = maxWave
     self.resetWavesUI()
     if not self.flagshipUIBaseNode:
         self.flagshipUIBaseNode = base.a2dTopLeft.attachNewNode('FlagshipUIBaseNode')
         self.flagshipUIBaseNode.setPos(1.1499999999999999, 0, -0.41999999999999998)
         self.flagshipUIBaseNode.setScale(0.75)
         globalGui = loader.loadModel('models/gui/toplevel_gui')
         if localAvatar.ship:
             self.baseFrame = DirectFrame(parent = localAvatar.ship.flagshipUIBaseNode, relief = None, state = DGG.DISABLED, image = globalGui.find('**/generic_box'), image_scale = 0.12, image_pos = (0, 0, 0), pos = (0, 0, 0))
             self.baseFrame.reparentTo(self.flagshipUIBaseNode)
             self.baseFrame.setScale(16, 1, 8)
             self.baseFrame.setPos(0.29999999999999999, 0, 0.074999999999999997)
         
     
     if self.waveCount:
         pass
     1
     self.waveCount = TextNode('BreakRemainingText')
     self.waveCount.setFont(PiratesGlobals.getInterfaceFont())
     self.waveCount.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveCount.setAlign(TextNode.ACenter)
     self.waveCount.setText(PLocalizer.FlagshipWaveCount % (str(currWave - 1), str(self.maxWave)))
     self.waveCountNode = self.flagshipUIBaseNode.attachNewNode(self.waveCount)
     self.waveCountNode.setPos(0.29999999999999999, 0, 0.10000000000000001)
     self.waveCountNode.setScale(0.074999999999999997)
     if currWave <= 1:
         self.flagshipUIBaseNode.hide()
     
     if self.counter:
         pass
     1
     self.counter = TextNode('BreakRemainingText')
     self.counter.setFont(PiratesGlobals.getInterfaceFont())
     self.counter.setTextColor(PiratesGuiGlobals.TextFG1)
     self.counter.setAlign(TextNode.ACenter)
     self.counter.setText(str(countdown))
     self.counterNode = self.flagshipUIBaseNode.attachNewNode(self.counter)
     self.counterNode.setPos(0.45000000000000001, 0, 0)
     self.counterNode.setScale(0.10000000000000001)
     self.counterLabel = TextNode('BreakRemainingTextLabel')
     self.counterLabel.setFont(PiratesGlobals.getInterfaceFont())
     self.counterLabel.setTextColor(PiratesGuiGlobals.TextFG1)
     self.counterLabel.setAlign(TextNode.ACenter)
     self.counterLabel.setText(PLocalizer.FlagshipWaveCountdown)
     self.counterLabelNode = self.flagshipUIBaseNode.attachNewNode(self.counterLabel)
     self.counterLabelNode.setPos(0.25, 0, 0)
     self.counterLabelNode.setScale(0.050000000000000003)
     self.counterEndTime = globalClock.getRealTime() + countdown
     if self.updateCounterTask:
         taskMgr.remove(self.updateCounterTask)
     
     self.updateCounterTask = taskMgr.add(self.updateCounter, 'updateCounterTask')
 def __init__(self, tabBar, name, **kw):
     optiondefs = (
         ("modelName", "general_frame_c", None),
         ("frameSize", (0, 0.20499999999999999, 0.0, 0.10000000000000001), None),
         ("borderScale", 0.13500000000000001, None),
         ("bgBuffer", 0.14000000000000001, None),
         ("showBackground", True, None),
         ("bgColorScale", VBase4(0, 0, 0, 1), None),
         ("flatten", 0, None),
         ("label", "", None),
         ("textMayChange", 0, None),
         ("textpos", (0.10000000000000001, 0.025000000000000001, 0), None),
     )
     self.defineoptions(kw, optiondefs)
     TopTab.__init__(self, tabBar, name)
     self.initialiseoptions(ShipTab)
     self.guiComponents["background"].setTransparency(0, 1)
     self.label = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         text=name,
         text_pos=self["textpos"],
         text_scale=0.050000000000000003,
         text_align=TextNode.ACenter,
         text_fg=PiratesGuiGlobals.TextFG1,
         text_shadow=PiratesGuiGlobals.TextShadow,
         text_font=PiratesGlobals.getInterfaceFont(),
         textMayChange=1,
     )
Esempio n. 5
0
    def __init__(self, tabBar, name, text_xyz=None, **kw):
        optiondefs = (('modelName', 'general_frame_c', None),
                      ('frameSize', (0, 0.22, 0.0, 0.10000000000000001),
                       None), ('borderScale', 0.13500000000000001,
                               None), ('bgBuffer', 0.14000000000000001, None),
                      ('label', '', None), ('textMayChange', 1, None))
        self.defineoptions(kw, optiondefs)
        TopTab.__init__(self, tabBar, name)
        self.initialiseoptions(ChatTab)
        text_pos = (0.11700000000000001, 0.040000000000000001, 0)
        if text_xyz:
            text_pos = text_xyz

        self.myTextScale = PiratesGuiGlobals.TextScaleLarge * 1.1000000000000001
        self.myLabel = DirectLabel(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   text=self['label'],
                                   text_scale=self.myTextScale,
                                   text_align=TextNode.ACenter,
                                   text_fg=PiratesGuiGlobals.TextFG1,
                                   text_shadow=PiratesGuiGlobals.TextShadow,
                                   text_pos=text_pos,
                                   text_font=PiratesGlobals.getInterfaceFont(),
                                   textMayChange=1)
Esempio n. 6
0
 def __init__(self,
              parent=None,
              hotkeys=(),
              hotkeyLabel=None,
              hotkeyLabelX=0.091999999999999998,
              hotkeyArgs=True,
              helpText='',
              helpPos=(0, 0, 0),
              helpDelay=PiratesGuiGlobals.HelpPopupTime,
              helpColorOff=False,
              helpLeftAlign=False,
              helpCenterAlign=False,
              **kw):
     self.loadGui()
     self.helpBox = None
     self.helpWatcher = None
     self.canRepositon = False
     optiondefs = (('relief', None, None), ('pos', (0, 0, 0), None),
                   ('image', GuiButton.genericButton, None),
                   ('image_scale', (0.23999999999999999, 0.22, 0.22),
                    None), ('image_pos', (0, 0, 0), None),
                   ('pressEffect', 0, None), ('text', '', None),
                   ('text_font', PiratesGlobals.getInterfaceFont(),
                    None), ('text_scale', PiratesGuiGlobals.TextScaleLarge,
                            None), ('text0_fg', PiratesGuiGlobals.TextFG2,
                                    None),
                   ('text1_fg', PiratesGuiGlobals.TextFG2,
                    None), ('text2_fg', PiratesGuiGlobals.TextFG2, None),
                   ('text3_fg', PiratesGuiGlobals.TextFG3,
                    None), ('text_shadow', PiratesGuiGlobals.TextShadow,
                            None), ('text_pos', (0, -0.01),
                                    None), ('text_wordwrap', 8, None),
                   ('text_align', TextNode.ACenter,
                    None), ('textMayChange', 1,
                            None), ('helpText', helpText,
                                    self.helpTextUpdated),
                   ('helpPos', helpPos, self.setHelpPos), ('helpDelay',
                                                           helpDelay, None),
                   ('helpColorOff', helpColorOff,
                    None), ('helpLeftAlign', helpLeftAlign,
                            None), ('helpCenterAlign', helpCenterAlign,
                                    None), ('helpBin', 'gui-popup',
                                            None), ('helpBinSort', 0, None),
                   ('helpOpaque', 0, None), ('canReposition', False,
                                             None), ('sortOrder', 100,
                                                     None), ('baseImage',
                                                             None, None),
                   ('selected', False,
                    None), ('selectedImage', GuiButton.genericButton,
                            None), ('state', DGG.NORMAL, self.setState))
     self.defineoptions(kw, optiondefs)
     DirectButton.__init__(self, parent=NodePath(), **None)
     self.initialiseoptions(GuiButton)
     self.hotkeys = ()
     self.setupHotkeys(hotkeys, hotkeyLabel, self['command'],
                       self['extraArgs'], hotkeyLabelX, hotkeyArgs)
     if not parent:
         pass
     self.reparentTo(aspect2d)
     self.helpTaskName = None
Esempio n. 7
0
 def __init__(self, tabBar, name, **kw):
     optiondefs = (('modelName', 'general_frame_c',
                    None), ('frameSize', (0, 0.205, 0.0, 0.1),
                            None), ('borderScale', 0.135, None),
                   ('bgBuffer', 0.14, None), ('showBackground', True, None),
                   ('bgColorScale', VBase4(0, 0, 0,
                                           1), None), ('flatten', 0, None),
                   ('label', '', None), ('textMayChange', 0, None),
                   ('textpos', (0.1, 0.025, 0), None))
     self.defineoptions(kw, optiondefs)
     TopTab.__init__(self, tabBar, name, **kw)
     self.initialiseoptions(ShipTab)
     self.guiComponents['background'].setTransparency(0, 1)
     self.label = DirectLabel(parent=self,
                              relief=None,
                              state=DGG.DISABLED,
                              text=name,
                              text_pos=self['textpos'],
                              text_scale=0.05,
                              text_align=TextNode.ACenter,
                              text_fg=PiratesGuiGlobals.TextFG1,
                              text_shadow=PiratesGuiGlobals.TextShadow,
                              text_font=PiratesGlobals.getInterfaceFont(),
                              textMayChange=1)
     return
Esempio n. 8
0
 def setTime(self, value):
     if value < 0:
         return
     number = TextNode('Number')
     number.setFont(PiratesGlobals.getInterfaceFont())
     number.setTextColor(PiratesGuiGlobals.TextFG1)
     number.setAlign(TextNode.ACenter)
     number.setShadow(0.05, 0.05)
     number.setShadowColor(0, 0, 0, 1)
     if value > 0:
         number.setText(str(value))
     else:
         number.setText(PLocalizer.CannonDefenseHelp['BeginGame'])
     numberNode = self.attachNewNode(number)
     numberNode.setTransparency(1)
     numberNode.setDepthTest(False)
     numberNode.setDepthWrite(False)
     seq = Sequence(
         Parallel(
             numberNode.scaleInterval(1, Vec3(0, 0, 0), Vec3(0.3, 0.3,
                                                             0.3)),
             numberNode.colorScaleInterval(1, Vec4(1, 1, 1, 0),
                                           Vec4(1, 1, 1, 1))),
         Func(numberNode.removeNode))
     seq.start()
Esempio n. 9
0
 def addTextMessage(self, text, seconds = 7, priority = 0, color = (0, 0, 0, 1), icon = (), modelName = 'general_frame_b', name = None, avId = None, playerName = None):
     if name and playerName:
         t2 = text % (playerName, name)
     elif name:
         t2 = text % name
     elif playerName:
         t2 = text % playerName
     else:
         t2 = text
     if self.lastMessage == t2:
         return None
     
     msg = StackMessage(parent = self, text = t2, text_wordwrap = 15.5, text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_fg = color, text_pos = (0.17000000000000001, -0.071999999999999995, 0), textMayChange = 1, time = seconds, priority = priority, icon = icon, modelName = modelName)
     if name and playerName:
         buttonText = text % playerName
     else:
         buttonText = text
     if name or playerName:
         msg['text_fg'] = (0, 0, 0, 0)
         if name:
             nameArray = ('\x1CPOrangeHEAD\x1' + name + '\x2', '\x1CPOrangeHEAD\x1' + name + '\x2', '\x1CPOrangeOVER\x1' + name + '\x2', '\x1CPOrangeHEAD\x1' + name + '\x2')
         else:
             nameArray = ('\x1CPOrangeHEAD\x1' + playerName + '\x2', '\x1CPOrangeHEAD\x1' + playerName + '\x2', '\x1CPOrangeOVER\x1' + playerName + '\x2', '\x1CPOrangeHEAD\x1' + playerName + '\x2')
         if name:
             nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarTextPress, extraArgs = [
                 avId,
                 name])
         else:
             nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handlePlayerTextPress, extraArgs = [
                 avId,
                 playerName])
         (left, right, bottom, top) = nameButton.getBounds()
         nameGFX = TextGraphic(nameButton, left, right, 0, 1)
         if name:
             buttonName = '\x5' + name + '\x5'
         else:
             buttonName = '\x5' + playerName + '\x5'
         buttonText = buttonText % buttonName
         tpMgr = TextPropertiesManager.getGlobalPtr()
         if name:
             tpMgr.setGraphic(name, nameGFX)
         else:
             tpMgr.setGraphic(playerName, nameGFX)
         del tpMgr
         textRender = TextNode('textRender')
         textRender.setFont(PiratesGlobals.getInterfaceFont())
         textRender.setTextColor(PiratesGuiGlobals.TextFG14)
         textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
         textRender.setWordwrap(15.5)
         textRender.setTabWidth(1.0)
         textRender.setShadow(0.080000000000000002, 0.080000000000000002)
         textRender.setText(buttonText)
         x = msg.attachNewNode(textRender.generate())
         x.setScale(0.035000000000000003)
         x.setPos(0.16700000000000001, 0, -0.072999999999999995)
     
     self.addMessage(msg)
     self.lastMessage = t2
     return msg
Esempio n. 10
0
 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 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
Esempio n. 12
0
 def addTextMessage(self, text, seconds = 7, priority = 0, color = (0, 0, 0, 1), icon = (), modelName = 'general_frame_b', name = None, avId = None, playerName = None):
     if name and playerName:
         t2 = text % (playerName, name)
     elif name:
         t2 = text % name
     elif playerName:
         t2 = text % playerName
     else:
         t2 = text
     if self.lastMessage == t2:
         return None
     
     msg = StackMessage(parent = self, text = t2, text_wordwrap = 15.5, text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_fg = color, text_pos = (0.17000000000000001, -0.071999999999999995, 0), textMayChange = 1, time = seconds, priority = priority, icon = icon, modelName = modelName)
     if name and playerName:
         buttonText = text % playerName
     else:
         buttonText = text
     if name or playerName:
         msg['text_fg'] = (0, 0, 0, 0)
         if name:
             nameArray = ('\x01CPOrangeHEAD\x01' + name + '\x02', '\x01CPOrangeHEAD\x01' + name + '\x02', '\x01CPOrangeOVER\x01' + name + '\x02', '\x01CPOrangeHEAD\x01' + name + '\x02')
         else:
             nameArray = ('\x01CPOrangeHEAD\x01' + playerName + '\x02', '\x01CPOrangeHEAD\x01' + playerName + '\x02', '\x01CPOrangeOVER\x01' + playerName + '\x02', '\x01CPOrangeHEAD\x01' + playerName + '\x02')
         if name:
             nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarTextPress, extraArgs = [
                 avId,
                 name])
         else:
             nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handlePlayerTextPress, extraArgs = [
                 avId,
                 playerName])
         (left, right, bottom, top) = nameButton.getBounds()
         nameGFX = TextGraphic(nameButton, left, right, 0, 1)
         if name:
             buttonName = '\x05' + name + '\x05'
         else:
             buttonName = '\x05' + playerName + '\x05'
         buttonText = buttonText % buttonName
         tpMgr = TextPropertiesManager.getGlobalPtr()
         if name:
             tpMgr.setGraphic(name, nameGFX)
         else:
             tpMgr.setGraphic(playerName, nameGFX)
         del tpMgr
         textRender = TextNode('textRender')
         textRender.setFont(PiratesGlobals.getInterfaceFont())
         textRender.setTextColor(PiratesGuiGlobals.TextFG14)
         textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
         textRender.setWordwrap(15.5)
         textRender.setTabWidth(1.0)
         textRender.setShadow(0.080000000000000002, 0.080000000000000002)
         textRender.setText(buttonText)
         x = msg.attachNewNode(textRender.generate())
         x.setScale(0.035000000000000003)
         x.setPos(0.16700000000000001, 0, -0.072999999999999995)
     
     self.addMessage(msg)
     self.lastMessage = t2
     return msg
Esempio n. 13
0
    def createGui(self):
        (item, quantity) = self.data
        name = PLocalizer.InventoryTypeNames[item]
        self.price = EconomyGlobals.getItemCost(item)
        repId = InventoryType.SailingRep
        itemTypeName = PLocalizer.InventoryTypeNames.get(repId)
        self.itemType = itemTypeName
        if self.sell:
            self.price /= 2

        card = loader.loadModel("models/textureCards/shipCatalog")
        renderName = self.shipImageDict.get(item, "Catalog_War_Brig")
        myTexCard = card.find("**/%s*" % renderName)
        myTex = myTexCard.findAllTextures()[0]
        card.removeNode()
        del card
        self.minLvl = EconomyGlobals.getItemMinLevel(item)
        self.miscText = None
        self.picture = DirectFrame(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            image=myTex,
            image_scale=(0.070000000000000007, 1.0, 0.059999999999999998),
        )
        self.picture.setPos(0.10000000000000001, 0, 0.080000000000000002)
        self.picture.setTransparency(1)
        self.nameTag = DirectLabel(
            parent=self,
            state=DGG.DISABLED,
            relief=None,
            text=name,
            text_scale=PiratesGuiGlobals.TextScaleMed * PLocalizer.getHeadingScale(2),
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            textMayChange=0,
        )
        self.nameTag.setPos(0.20000000000000001, 0, 0.10000000000000001)
        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=self.coinImage,
            geom_scale=0.12,
            geom_pos=Vec3(-0.01, 0, 0.01),
            text=str(self.price),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            text_pos=(-0.029999999999999999, 0, 0),
            text_font=PiratesGlobals.getInterfaceFont(),
        )
        self.costText.setPos(0.47999999999999998, 0, 0.040000000000000001)
Esempio n. 14
0
 def _CannonDefenseHelpPanel__createHeaderText(self, parent, text):
     header = TextNode('Header')
     header.setFont(PiratesGlobals.getInterfaceFont())
     header.setTextColor(PiratesGuiGlobals.TextFG1)
     header.setAlign(TextNode.ALeft)
     header.setText(text)
     headerNode = parent.attachNewNode(header)
     headerNode.setScale(0.065000000000000002)
     headerNode.setZ(0.0)
     headerNode.setDepthTest(False)
Esempio n. 15
0
 def __createHeaderText(self, parent, text):
     header = TextNode('Header')
     header.setFont(PiratesGlobals.getInterfaceFont())
     header.setTextColor(PiratesGuiGlobals.TextFG1)
     header.setAlign(TextNode.ALeft)
     header.setText(text)
     headerNode = parent.attachNewNode(header)
     headerNode.setScale(0.065)
     headerNode.setZ(0.0)
     headerNode.setDepthTest(False)
Esempio n. 16
0
 def __createBodyText(self, parent, text, wordWrap):
     body = TextNode('Body')
     body.setFont(PiratesGlobals.getInterfaceFont())
     body.setTextColor(PiratesGuiGlobals.TextFG2)
     body.setAlign(TextNode.ALeft)
     body.setWordwrap(wordWrap)
     body.setText(text)
     bodyNode = parent.attachNewNode(body)
     bodyNode.setScale(0.05)
     bodyNode.setZ(-0.07)
     bodyNode.setDepthTest(False)
 def __createWaveText(self, parent):
     self.waveNumberTxt = TextNode('WaveNumber')
     self.waveNumberTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.waveNumberTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveNumberTxt.setShadow(0.05, 0.05)
     self.waveNumberTxt.setAlign(TextNode.ACenter)
     waveTxtNode = parent.attachNewNode(self.waveNumberTxt)
     waveTxtNode.setScale(0.12)
     waveTxtNode.setPos(0, -0.2, -0.08)
     waveTxtNode.setDepthTest(False)
     waveTxtNode.setDepthWrite(False)
Esempio n. 18
0
 def _CannonDefenseHelpPanel__createBodyText(self, parent, text, wordWrap):
     body = TextNode('Body')
     body.setFont(PiratesGlobals.getInterfaceFont())
     body.setTextColor(PiratesGuiGlobals.TextFG2)
     body.setAlign(TextNode.ALeft)
     body.setWordwrap(wordWrap)
     body.setText(text)
     bodyNode = parent.attachNewNode(body)
     bodyNode.setScale(0.050000000000000003)
     bodyNode.setZ(-0.070000000000000007)
     bodyNode.setDepthTest(False)
 def _CannonDefenseTimeRemainingUI__createWaveText(self, parent):
     self.waveNumberTxt = TextNode('WaveNumber')
     self.waveNumberTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.waveNumberTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveNumberTxt.setShadow(0.050000000000000003, 0.050000000000000003)
     self.waveNumberTxt.setAlign(TextNode.ACenter)
     waveTxtNode = parent.attachNewNode(self.waveNumberTxt)
     waveTxtNode.setScale(0.12)
     waveTxtNode.setPos(0, -0.20000000000000001, -0.080000000000000002)
     waveTxtNode.setDepthTest(False)
     waveTxtNode.setDepthWrite(False)
Esempio n. 20
0
 def __createTextLabel(self, parent):
     goldLabelTxt = TextNode('TreasureRemaining')
     goldLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
     goldLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     goldLabelTxt.setAlign(TextNode.ACenter)
     goldLabelTxt.setText(PLocalizer.CannonDefense['TreasureRemaining'])
     goldTxtNode = parent.attachNewNode(goldLabelTxt)
     goldTxtNode.setScale(0.03)
     goldTxtNode.setX(0.035)
     goldTxtNode.setZ(0.005)
     goldTxtNode.setDepthTest(False)
     goldTxtNode.setDepthWrite(False)
 def _CannonDefenseGoldRemaingUI__createTextLabel(self, parent):
     goldLabelTxt = TextNode("TreasureRemaining")
     goldLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
     goldLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     goldLabelTxt.setAlign(TextNode.ACenter)
     goldLabelTxt.setText(PLocalizer.CannonDefense["TreasureRemaining"])
     goldTxtNode = parent.attachNewNode(goldLabelTxt)
     goldTxtNode.setScale(0.029999999999999999)
     goldTxtNode.setX(0.035000000000000003)
     goldTxtNode.setZ(0.0050000000000000001)
     goldTxtNode.setDepthTest(False)
     goldTxtNode.setDepthWrite(False)
 def __createWaveLabel(self, parent):
     self.waveLabelTxt = TextNode('WaveLabel')
     self.waveLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.waveLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveLabelTxt.setShadow(0.05, 0.05)
     self.waveLabelTxt.setAlign(TextNode.ACenter)
     self.waveLabelTxt.setText(PLocalizer.CannonDefense['WaveLabel'])
     waveLblNode = parent.attachNewNode(self.waveLabelTxt)
     waveLblNode.setScale(0.06)
     waveLblNode.setPos(0, -0.2, 0.015)
     waveLblNode.setDepthTest(False)
     waveLblNode.setDepthWrite(False)
 def _CannonDefenseTimeRemainingUI__createWaveLabel(self, parent):
     self.waveLabelTxt = TextNode('WaveLabel')
     self.waveLabelTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.waveLabelTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveLabelTxt.setShadow(0.050000000000000003, 0.050000000000000003)
     self.waveLabelTxt.setAlign(TextNode.ACenter)
     self.waveLabelTxt.setText(PLocalizer.CannonDefense['WaveLabel'])
     waveLblNode = parent.attachNewNode(self.waveLabelTxt)
     waveLblNode.setScale(0.059999999999999998)
     waveLblNode.setPos(0, -0.20000000000000001, 0.014999999999999999)
     waveLblNode.setDepthTest(False)
     waveLblNode.setDepthWrite(False)
Esempio n. 24
0
    def createGui(self):
        (item, quantity) = self.data
        name = PLocalizer.InventoryTypeNames[item]
        self.price = EconomyGlobals.getItemCost(item)
        repId = InventoryType.SailingRep
        itemTypeName = PLocalizer.InventoryTypeNames.get(repId)
        self.itemType = itemTypeName
        if self.sell:
            self.price /= 2

        card = loader.loadModel('models/textureCards/shipCatalog')
        renderName = self.shipImageDict.get(item, 'Catalog_War_Brig')
        myTexCard = card.find('**/%s*' % renderName)
        myTex = myTexCard.findAllTextures()[0]
        card.removeNode()
        del card
        self.minLvl = EconomyGlobals.getItemMinLevel(item)
        self.miscText = None
        self.picture = DirectFrame(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   image=myTex,
                                   image_scale=(0.070000000000000007, 1.0,
                                                0.059999999999999998))
        self.picture.setPos(0.10000000000000001, 0, 0.080000000000000002)
        self.picture.setTransparency(1)
        self.nameTag = DirectLabel(parent=self,
                                   state=DGG.DISABLED,
                                   relief=None,
                                   text=name,
                                   text_scale=PiratesGuiGlobals.TextScaleMed *
                                   PLocalizer.getHeadingScale(2),
                                   text_align=TextNode.ALeft,
                                   text_fg=PiratesGuiGlobals.TextFG1,
                                   text_shadow=PiratesGuiGlobals.TextShadow,
                                   textMayChange=0)
        self.nameTag.setPos(0.20000000000000001, 0, 0.10000000000000001)
        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=self.coinImage,
            geom_scale=0.12,
            geom_pos=Vec3(-0.01, 0, 0.01),
            text=str(self.price),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ARight,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=11,
            text_pos=(-0.029999999999999999, 0, 0),
            text_font=PiratesGlobals.getInterfaceFont())
        self.costText.setPos(0.47999999999999998, 0, 0.040000000000000001)
 def _CannonDefenseTimeRemainingUI__createWaveText(self, parent):
     self.waveNumberTxt = TextNode('WaveNumber')
     self.waveNumberTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.waveNumberTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.waveNumberTxt.setShadow(0.050000000000000003,
                                  0.050000000000000003)
     self.waveNumberTxt.setAlign(TextNode.ACenter)
     waveTxtNode = parent.attachNewNode(self.waveNumberTxt)
     waveTxtNode.setScale(0.12)
     waveTxtNode.setPos(0, -0.20000000000000001, -0.080000000000000002)
     waveTxtNode.setDepthTest(False)
     waveTxtNode.setDepthWrite(False)
Esempio n. 26
0
 def makeCheckbox(self, pos, text, command, initialState, extraArgs,
                  levelText):
     charGui = loader.loadModel('models/gui/toplevel_gui')
     buttonImage = (charGui.find('**/generic_button'),
                    charGui.find('**/generic_button'),
                    charGui.find('**/generic_button'),
                    charGui.find('**/generic_button'))
     geomCheck = [
         charGui.find('**/generic_check'),
         charGui.find('**/generic_check'),
         charGui.find('**/generic_check'), None
     ]
     c = DirectCheckButton(
         parent=self,
         relief=None,
         scale=0.064000000000000001,
         boxBorder=0.080000000000000002,
         boxRelief=None,
         boxImage=geomCheck,
         boxImageScale=6,
         boxImageColor=VBase4(0, 1, 0, 1),
         pos=pos,
         text=text,
         text_fg=PiratesGuiGlobals.TextFG1,
         text_scale=0.5,
         text_pos=(-2.3999999999999999, 0, -2.7999999999999998),
         text_align=TextNode.ALeft,
         text_font=PiratesGlobals.getInterfaceOutlineFont(),
         indicator_pos=(2.2000000000000002, 0, 0.14999999999999999),
         command=command,
         indicatorValue=initialState,
         extraArgs=extraArgs,
         text0_fg=PiratesGuiGlobals.TextFG1,
         text1_fg=PiratesGuiGlobals.TextFG1,
         text2_fg=PiratesGuiGlobals.TextFG1,
         text3_fg=PiratesGuiGlobals.TextFG1,
         text_shadow=PiratesGuiGlobals.TextShadow,
         image=buttonImage,
         image_pos=(0, 0, 0.14999999999999999),
         image_scale=(6, 1, 2.4500000000000002),
         state=DGG.DISABLED)
     l = DirectLabel(parent=c,
                     text=levelText,
                     text_font=PiratesGlobals.getInterfaceFont(),
                     text_scale=0.5,
                     text_align=TextNode.ALeft,
                     frameColor=(0.80000000000000004, 0.69999999999999996,
                                 0.5, 1),
                     pos=(-0.29999999999999999, 0, 0))
     c.setIndicatorValue()
     del charGui
     return c
Esempio n. 27
0
    def createTabExtended(self, name, iconClosed, iconOpen, command,
                          extraArgList):
        newTab = self.tabBar.addTab('My Tab %s' % self.tabCount,
                                    frameSize=(-0.12, 0.12, -0.11, 0.11),
                                    focusSize=(-0.12, 0.12, -0.12, 0.12),
                                    heightFactor=0.59999999999999998,
                                    command=command,
                                    extraArgs=extraArgList)
        self.tabCount += 1
        image = iconClosed
        newTab.imageTag = DirectLabel(parent=newTab,
                                      relief=None,
                                      state=DGG.DISABLED,
                                      image=image,
                                      image_scale=image.getScale(),
                                      image_color=Vec4(0.80000000000000004,
                                                       0.80000000000000004,
                                                       0.80000000000000004, 1),
                                      pos=(0, 0, 0))
        newTab.nameTag = DirectLabel(
            parent=newTab,
            relief=None,
            state=DGG.DISABLED,
            text=name,
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0, 0, 0))
        newTab.nameTag.setBin('gui-fixed', 1)
        newTab.nameTag.hide()

        def mouseOver(tab=newTab):
            tab.imageTag.setScale(1.1000000000000001)
            tab.imageTag['image_color'] = Vec4(1, 1, 1, 1)
            base.playSfx(PiratesGuiGlobals.getDefaultRolloverSound())
            newTab.nameTag.show()

        def mouseOff(tab=newTab):
            if not tab['selected']:
                tab.imageTag.setScale(1.0)
                tab.imageTag['image_color'] = Vec4(0.80000000000000004,
                                                   0.80000000000000004,
                                                   0.80000000000000004, 1)
            else:
                mouseOver(tab)
            newTab.nameTag.hide()

        newTab['mouseEntered'] = mouseOver
        newTab['mouseLeft'] = mouseOff
        return newTab
Esempio n. 28
0
 def _createBankNoteText(self):
     textPlaceHolder = self.panel.find('**/text')
     self.bankNoteTxt = TextNode('BankNoteText')
     self.bankNoteTxt.setFont(PiratesGlobals.getInterfaceFont())
     self.bankNoteTxt.setTextColor(PiratesGuiGlobals.TextFG1)
     self.bankNoteTxt.setShadow(0.050000000000000003, 0.050000000000000003)
     self.bankNoteTxt.setAlign(TextNode.ALeft)
     bankNoteTxtNode = textPlaceHolder.attachNewNode(self.bankNoteTxt)
     bankNoteTxtNode.setScale(0.014999999999999999)
     bankNoteTxtNode.setDepthTest(False)
     bankNoteTxtNode.setDepthWrite(False)
     bankNoteTxtNode.setPos(-0.02, 0, 0)
     self.updateBankNoteText()
 def makeCheckbox(self, pos, text, command, initialState, extraArgs, levelText):
     charGui = loader.loadModel('models/gui/toplevel_gui')
     buttonImage = (charGui.find('**/generic_button'), charGui.find('**/generic_button'), charGui.find('**/generic_button'), charGui.find('**/generic_button'))
     geomCheck = [
         charGui.find('**/generic_check'),
         charGui.find('**/generic_check'),
         charGui.find('**/generic_check'),
         None]
     c = DirectCheckButton(parent = self, relief = None, scale = 0.064000000000000001, boxBorder = 0.080000000000000002, boxRelief = None, boxImage = geomCheck, boxImageScale = 6, boxImageColor = VBase4(0, 1, 0, 1), pos = pos, text = text, text_fg = PiratesGuiGlobals.TextFG1, text_scale = 0.5, text_pos = (-2.3999999999999999, 0, -2.7999999999999998), text_align = TextNode.ALeft, text_font = PiratesGlobals.getInterfaceOutlineFont(), indicator_pos = (2.2000000000000002, 0, 0.14999999999999999), command = command, indicatorValue = initialState, extraArgs = extraArgs, text0_fg = PiratesGuiGlobals.TextFG1, text1_fg = PiratesGuiGlobals.TextFG1, text2_fg = PiratesGuiGlobals.TextFG1, text3_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, image = buttonImage, image_pos = (0, 0, 0.14999999999999999), image_scale = (6, 1, 2.4500000000000002), state = DGG.DISABLED)
     l = DirectLabel(parent = c, text = levelText, text_font = PiratesGlobals.getInterfaceFont(), text_scale = 0.5, text_align = TextNode.ALeft, frameColor = (0.80000000000000004, 0.69999999999999996, 0.5, 1), pos = (-0.29999999999999999, 0, 0))
     c.setIndicatorValue()
     del charGui
     return c
Esempio n. 30
0
 def invArrived(inv):
     if inv:
         limit = localAvatar.getInventory().getStackLimit(self.itemTuple[1])
         if self.amount <= 1:
             self['text'] = ' '
             self['geom_color'] = (0.0, 0.0, 0.0, 0.0)
             self['image_scale'] = 1.0
             self.setPos(0.0, 0.0, 0.0)
         elif self.showMax:
             self['text'] = '%s/%s' % (self.amount, limit)
         else:
             self['text'] = 'x%s' % self.amount
             self.configure(text_fg = PiratesGuiGlobals.TextFG0, text_font = PiratesGlobals.getInterfaceFont(), text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0.050000000000000003, 0.042999999999999997))
             self['image_scale'] = 1.5
             self['geom_color'] = (1.0, 1.0, 1.0, 1.0)
    def __init__(self, other = None):
        Biped.Biped.__init__(self, other, HumanAnimationMixer)
        self.model = None
        self.useFaceTex = True
        self.joints = { }
        self.jointTrans = { }
        self.jointTrans2 = { }
        self.zombie = False
        self.crazyColorSkin = False
        self.crazyColorSkinIndex = 0
        self.flattenPending = None
        self.optimizeLOD = base.config.GetBool('optimize-avatar-lod', 1)
        self.master = 0
        self.loaded = 0
        self.playingRate = None
        self.shadowFileName = 'models/misc/drop_shadow'
        self.setFont(PiratesGlobals.getInterfaceFont())
        self._MasterHuman__blinkName = 'blink-' + str(self.this)
        self.eyeLids = None
        self.eyeBalls = None
        self.eyeIris = None
        self.reducedAnimList = None
        self.rootScale = 1.0
        self.headNode = None
        self.extraNode = None
        self.scaleNode = None
        self.rootNode = None
        self.floorOffsetZ = 0.0
        self.headFudgeHpr = Vec3(0, 0, 0)
        self.frozeSomething = True
        self.randGen = random.Random()
        self.randGen.seed(random.random())
        self.eyeFSM = ClassicFSM('eyeFSM', [
            State('off', self.enterEyeFSMOff, self.exitEyeFSMOff, [
                'open',
                'closed']),
            State('open', self.enterEyeFSMOpen, self.exitEyeFSMOpen, [
                'closed',
                'off']),
            State('closed', self.enterEyeFSMClosed, self.exitEyeFSMClosed, [
                'open',
                'off'])], 'off', 'off')
        self.eyeFSM.enterInitialState()
        if other != None:
            self.copyHuman(other)

        self.isPaid = False
Esempio n. 32
0
 def __init__(self, other=None):
     Biped.Biped.__init__(self, other, HumanAnimationMixer)
     self.model = None
     self.useFaceTex = True
     self.joints = {}
     self.jointTrans = {}
     self.jointTrans2 = {}
     self.zombie = False
     self.crazyColorSkin = False
     self.crazyColorSkinIndex = 0
     self.flattenPending = None
     self.optimizeLOD = base.config.GetBool('optimize-avatar-lod', 1)
     self.master = 0
     self.loaded = 0
     self.playingRate = None
     self.shadowFileName = 'models/misc/drop_shadow'
     self.setFont(PiratesGlobals.getInterfaceFont())
     self.__blinkName = 'blink-' + str(self.this)
     self.eyeLids = None
     self.eyeBalls = None
     self.eyeIris = None
     self.reducedAnimList = None
     self.rootScale = 1.0
     self.headNode = None
     self.extraNode = None
     self.scaleNode = None
     self.rootNode = None
     self.floorOffsetZ = 0.0
     self.headFudgeHpr = Vec3(0, 0, 0)
     self.frozeSomething = True
     self.randGen = random.Random()
     self.randGen.seed(random.random())
     self.eyeFSM = ClassicFSM('eyeFSM', [
      State('off', self.enterEyeFSMOff, self.exitEyeFSMOff, [
       'open', 'closed']),
      State('open', self.enterEyeFSMOpen, self.exitEyeFSMOpen, [
       'closed', 'off']),
      State('closed', self.enterEyeFSMClosed, self.exitEyeFSMClosed, [
       'open', 'off'])], 'off', 'off')
     self.eyeFSM.enterInitialState()
     if other != None:
         self.copyHuman(other)
     self.isPaid = False
     return
Esempio n. 33
0
 def __init__(self, avId, avName, location, initialRequest = False, crewType = 1):
     guiMain = loader.loadModel('models/gui/gui_main')
     DirectFrame.__init__(self, relief = None, pos = (-0.59999999999999998, 0, 0.46999999999999997), image = guiMain.find('**/general_frame_e'), image_pos = (0.25, 0, 0.27500000000000002), image_scale = 0.25)
     self.initialiseoptions(CrewMatchInvitee)
     self.avId = avId
     self.avName = avName
     self.initialRequest = initialRequest
     self.location = location
     self.crewType = crewType
     self.title = DirectLabel(parent = self, relief = None, text = PLocalizer.CrewMatchCrewLookout, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateOutlineFont(), pos = (0.25, 0, 0.41999999999999998), image = None, image_scale = 0.25)
     nameArray = ('\x01CPOrangeHEAD\x01' + self.avName + '\x02', '\x01CPOrangeHEAD\x01' + self.avName + '\x02', '\x01CPOrangeOVER\x01' + self.avName + '\x02', '\x01CPOrangeHEAD\x01' + self.avName + '\x02')
     nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarPress, extraArgs = [
         avId,
         avName])
     (left, right, bottom, top) = nameButton.getBounds()
     nameGFX = TextGraphic(nameButton, left, right, 0, 1)
     buttonName = '\x05' + self.avName + '\x05'
     if location != '':
         buttonText = PLocalizer.CrewMatchInviteeInvitation % (buttonName, self.location)
     else:
         buttonText = PLocalizer.CrewMatchInviteeInvitationNoLocation % buttonName
     tpMgr = TextPropertiesManager.getGlobalPtr()
     tpMgr.setGraphic(self.avName, nameGFX)
     del tpMgr
     textRender = TextNode('textRender')
     textRender.setFont(PiratesGlobals.getInterfaceFont())
     textRender.setTextColor(PiratesGuiGlobals.TextFG2)
     textRender.setAlign(TextNode.ACenter)
     textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
     textRender.setWordwrap(11)
     textRender.setTabWidth(1.0)
     textRender.setShadow(0.080000000000000002, 0.080000000000000002)
     textRender.setText(buttonText)
     textNode = self.attachNewNode(textRender.generate())
     textNode.setScale(PiratesGuiGlobals.TextScaleLarge)
     textNode.setPos(0.25, 0, 0.32500000000000001)
     self.bOk = CrewMatchInviteeButton(text = PLocalizer.CrewInviteeOK, command = self._CrewMatchInvitee__handleOk)
     self.bOk.reparentTo(self)
     self.bOk.setPos(0.10000000000000001, 0, 0.050000000000000003)
     self.bNo = CrewMatchInviteeButton(text = PLocalizer.CrewInviteeNo, command = self._CrewMatchInvitee__handleNo)
     self.bNo.reparentTo(self)
     self.bNo.setPos(0.29999999999999999, 0, 0.050000000000000003)
     self.accept('clientLogout', self.destroy)
     self.accept('destroyCrewMatchInvite', self.destroy)
 def __init__(self, avId, avName, location, initialRequest = False, crewType = 1):
     guiMain = loader.loadModel('models/gui/gui_main')
     DirectFrame.__init__(self, relief = None, pos = (-0.59999999999999998, 0, 0.46999999999999997), image = guiMain.find('**/general_frame_e'), image_pos = (0.25, 0, 0.27500000000000002), image_scale = 0.25)
     self.initialiseoptions(CrewMatchInvitee)
     self.avId = avId
     self.avName = avName
     self.initialRequest = initialRequest
     self.location = location
     self.crewType = crewType
     self.title = DirectLabel(parent = self, relief = None, text = PLocalizer.CrewMatchCrewLookout, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateOutlineFont(), pos = (0.25, 0, 0.41999999999999998), image = None, image_scale = 0.25)
     nameArray = ('CPOrangeHEAD' + self.avName + '', 'CPOrangeHEAD' + self.avName + '', 'CPOrangeOVER' + self.avName + '', 'CPOrangeHEAD' + self.avName + '')
     nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarPress, extraArgs = [
         avId,
         avName])
     (left, right, bottom, top) = nameButton.getBounds()
     nameGFX = TextGraphic(nameButton, left, right, 0, 1)
     buttonName = '' + self.avName + ''
     if location != '':
         buttonText = PLocalizer.CrewMatchInviteeInvitation % (buttonName, self.location)
     else:
         buttonText = PLocalizer.CrewMatchInviteeInvitationNoLocation % buttonName
     tpMgr = TextPropertiesManager.getGlobalPtr()
     tpMgr.setGraphic(self.avName, nameGFX)
     del tpMgr
     textRender = TextNode('textRender')
     textRender.setFont(PiratesGlobals.getInterfaceFont())
     textRender.setTextColor(PiratesGuiGlobals.TextFG2)
     textRender.setAlign(TextNode.ACenter)
     textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
     textRender.setWordwrap(11)
     textRender.setTabWidth(1.0)
     textRender.setShadow(0.080000000000000002, 0.080000000000000002)
     textRender.setText(buttonText)
     textNode = self.attachNewNode(textRender.generate())
     textNode.setScale(PiratesGuiGlobals.TextScaleLarge)
     textNode.setPos(0.25, 0, 0.32500000000000001)
     self.bOk = CrewMatchInviteeButton(text = PLocalizer.CrewInviteeOK, command = self._CrewMatchInvitee__handleOk)
     self.bOk.reparentTo(self)
     self.bOk.setPos(0.10000000000000001, 0, 0.050000000000000003)
     self.bNo = CrewMatchInviteeButton(text = PLocalizer.CrewInviteeNo, command = self._CrewMatchInvitee__handleNo)
     self.bNo.reparentTo(self)
     self.bNo.setPos(0.29999999999999999, 0, 0.050000000000000003)
     self.accept('clientLogout', self.destroy)
     self.accept('destroyCrewMatchInvite', self.destroy)
 def __init__(self, avId, avName, crewType, openCrew):
     guiMain = loader.loadModel('models/gui/gui_main')
     DirectFrame.__init__(self, relief=None, pos=(-0.6, 0, 0.47), image=guiMain.find('**/general_frame_e'), image_pos=(0.25,
                                                                                                                       0,
                                                                                                                       0.275), image_scale=0.25)
     self.initialiseoptions(CrewMatchNewMemberRequest)
     self.avId = avId
     self.avName = avName
     self.crewType = crewType
     self.openCrew = openCrew
     self.title = DirectLabel(parent=self, relief=None, text=PLocalizer.CrewMatchNewMemberRequestTitle, text_scale=PiratesGuiGlobals.TextScaleExtraLarge, text_align=TextNode.ACenter, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_font=PiratesGlobals.getPirateOutlineFont(), pos=(0.25,
                                                                                                                                                                                                                                                                                                                          0,
                                                                                                                                                                                                                                                                                                                          0.42))
     nameArray = (
      '\x01CPOrangeHEAD\x01' + self.avName + '\x02', '\x01CPOrangeHEAD\x01' + self.avName + '\x02', '\x01CPOrangeOVER\x01' + self.avName + '\x02', '\x01CPOrangeHEAD\x01' + self.avName + '\x02')
     nameButton = DirectButton(parent=NodePath(), relief=None, text=nameArray, text_align=TextNode.ALeft, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=0, command=self.handleAvatarPress, extraArgs=[avId, avName])
     left, right, bottom, top = nameButton.getBounds()
     nameGFX = TextGraphic(nameButton, left, right, 0, 1)
     buttonName = '\x05' + self.avName + '\x05'
     buttonText = PLocalizer.CrewMatchNewMemberRequestMessage % buttonName
     tpMgr = TextPropertiesManager.getGlobalPtr()
     tpMgr.setGraphic(self.avName, nameGFX)
     del tpMgr
     textRender = TextNode('textRender')
     textRender.setFont(PiratesGlobals.getInterfaceFont())
     textRender.setTextColor(PiratesGuiGlobals.TextFG2)
     textRender.setAlign(TextNode.ACenter)
     textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
     textRender.setWordwrap(11)
     textRender.setTabWidth(1.0)
     textRender.setShadow(0.08, 0.08)
     textRender.setText(buttonText)
     textNode = self.attachNewNode(textRender.generate())
     textNode.setScale(PiratesGuiGlobals.TextScaleLarge)
     textNode.setPos(0.25, 0, 0.325)
     self.bOk = CrewMatchNewMemberRequestButton(text=PLocalizer.CrewMatchNewMemberRequestYes, command=self.__handleOk)
     self.bOk.reparentTo(self)
     self.bOk.setPos(0.1, 0, 0.05)
     self.bNo = CrewMatchNewMemberRequestButton(text=PLocalizer.CrewMatchNewMemberRequestNo, command=self.__handleNo)
     self.bNo.reparentTo(self)
     self.bNo.setPos(0.3, 0, 0.05)
     self.accept('clientLogout', self.destroy)
     self.accept('destroyCrewMatchInvite', self.destroy)
     return
Esempio n. 36
0
 def invArrived(inv):
     if inv:
         limit = localAvatar.getInventory().getStackLimit(
             self.itemTuple[1])
         if self.amount <= 1:
             self['text'] = ' '
             self['geom_color'] = (0.0, 0.0, 0.0, 0.0)
             self['image_scale'] = 1.0
             self.setPos(0.0, 0.0, 0.0)
         elif self.showMax:
             self['text'] = '%s/%s' % (self.amount, limit)
         else:
             self['text'] = 'x%s' % self.amount
             self.configure(text_fg=PiratesGuiGlobals.TextFG0,
                            text_font=PiratesGlobals.getInterfaceFont(),
                            text_scale=PiratesGuiGlobals.TextScaleLarge,
                            text_pos=(0.05, 0.043))
             self['image_scale'] = 1.5
             self['geom_color'] = (1.0, 1.0, 1.0, 1.0)
Esempio n. 37
0
 def __init__(self, avId, avName):
     guiMain = loader.loadModel('models/gui/gui_main')
     DirectFrame.__init__(self, relief = None, pos = (-0.59999999999999998, 0, 0.46999999999999997), image = guiMain.find('**/general_frame_e'), image_pos = (0.25, 0, 0.27500000000000002), image_scale = 0.25)
     guiMain.removeNode()
     self.initialiseoptions(CrewInvitee)
     self.avId = avId
     self.avName = avName
     if base.cr.avatarFriendsManager.checkIgnored(self.avId):
         self._CrewInvitee__handleNo()
         return None
     
     self.title = DirectLabel(parent = self, relief = None, text = PLocalizer.CrewInviteeTitle, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getPirateOutlineFont(), pos = (0.25, 0, 0.41999999999999998), image = None, image_scale = 0.25)
     nameArray = ('\x001CPOrangeHEAD\x001' + self.avName + '\x002', '\x001CPOrangeHEAD\x001' + self.avName + '\x002', '\x001CPOrangeOVER\x001' + self.avName + '\x002', '\x001CPOrangeHEAD\x001' + self.avName + '\x002')
     nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarPress, extraArgs = [
         avId,
         avName])
     (left, right, bottom, top) = nameButton.getBounds()
     nameGFX = TextGraphic(nameButton, left, right, 0, 1)
     buttonName = '\x005' + self.avName + '\x005'
     buttonText = PLocalizer.CrewInviteeInvitation % buttonName
     tpMgr = TextPropertiesManager.getGlobalPtr()
     tpMgr.setGraphic(self.avName, nameGFX)
     del tpMgr
     textRender = TextNode('textRender')
     textRender.setFont(PiratesGlobals.getInterfaceFont())
     textRender.setTextColor(PiratesGuiGlobals.TextFG2)
     textRender.setAlign(TextNode.ACenter)
     textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
     textRender.setWordwrap(11)
     textRender.setTabWidth(1.0)
     textRender.setShadow(0.080000000000000002, 0.080000000000000002)
     textRender.setText(buttonText)
     textNode = self.attachNewNode(textRender.generate())
     textNode.setScale(PiratesGuiGlobals.TextScaleLarge)
     textNode.setPos(0.25, 0, 0.32500000000000001)
     self.bOk = CrewInviteeButton(text = PLocalizer.CrewInviteeOK, command = self._CrewInvitee__handleOk)
     self.bOk.reparentTo(self)
     self.bOk.setPos(0.10000000000000001, 0, 0.050000000000000003)
     self.bNo = CrewInviteeButton(text = PLocalizer.CrewInviteeNo, command = self._CrewInvitee__handleNo)
     self.bNo.reparentTo(self)
     self.bNo.setPos(0.29999999999999999, 0, 0.050000000000000003)
     self.accept('BandRequestCancel-%s' % (self.avId,), self._CrewInvitee__handleCancelFromAbove)
 def setTime(self, value):
     if value < 0:
         return None
     
     number = TextNode('Number')
     number.setFont(PiratesGlobals.getInterfaceFont())
     number.setTextColor(PiratesGuiGlobals.TextFG1)
     number.setAlign(TextNode.ACenter)
     number.setShadow(0.050000000000000003, 0.050000000000000003)
     number.setShadowColor(0, 0, 0, 1)
     if value > 0:
         number.setText(str(value))
     else:
         number.setText(PLocalizer.CannonDefenseHelp['BeginGame'])
     numberNode = self.attachNewNode(number)
     numberNode.setTransparency(1)
     numberNode.setDepthTest(False)
     numberNode.setDepthWrite(False)
     seq = Sequence(Parallel(numberNode.scaleInterval(1, Vec3(0, 0, 0), Vec3(0.29999999999999999, 0.29999999999999999, 0.29999999999999999)), numberNode.colorScaleInterval(1, Vec4(1, 1, 1, 0), Vec4(1, 1, 1, 1))), Func(numberNode.removeNode))
     seq.start()
Esempio n. 39
0
 def enterWhisper(self, avatarName='John Sharkbait', whisperId=0):
     self.whisperName = avatarName
     self.whisperId = whisperId
     self.chatTabs.stash()
     self.whisperTabs.unstash()
     if self.whisperNameLabel:
         self.whisperNameLabel.destroy()
     self.whisperNameLabel = DirectLabel(
         parent=self.whisperTabs.getTab('Name'),
         relief=None,
         state=DGG.DISABLED,
         text=avatarName,
         text_scale=(self.myTextScale * self.iPercentage, self.myTextScale,
                     self.myTextScale),
         text_align=TextNode.ALeft,
         text_fg=PiratesGuiGlobals.TextFG2,
         text_shadow=PiratesGuiGlobals.TextShadow,
         text_pos=(0.21 * self.iPercentage, 0.04, 0),
         text_font=PiratesGlobals.getInterfaceFont())
     return
 def __init__(self, other=None):
     Biped.Biped.__init__(self, other, HumanAnimationMixer)
     self.zombie = False
     self.crazyColorSkin = False
     self.crazyColorSkinIndex = 0
     self.flattenPending = None
     self.flattenSuperLowName = None
     self.optimizeLOD = base.config.GetBool("optimize-avatar-lod", 1)
     self.loaded = 0
     self.playingRate = None
     self.shadowFileName = "models/misc/drop_shadow"
     self.setFont(PiratesGlobals.getInterfaceFont())
     self._Human__blinkName = "blink-" + str(self.this)
     self.eyeLids = None
     self.eyeBalls = None
     self.eyeIris = None
     self.reducedAnimList = None
     self.headNode = None
     self.headEffects = NodePath("headEffects")
     self.extraNode = None
     self.scaleNode = None
     self.rootNode = None
     self.floorOffsetZ = 0.0
     self.isGhost = 0
     self.headFudgeHpr = Vec3(0, 0, 0)
     self.randGen = random.Random()
     self.randGen.seed(random.random())
     self.eyeFSM = ClassicFSM(
         "eyeFSM",
         [
             State("off", self.enterEyeFSMOff, self.exitEyeFSMOff, ["open", "closed"]),
             State("open", self.enterEyeFSMOpen, self.exitEyeFSMOpen, ["closed", "off"]),
             State("closed", self.enterEyeFSMClosed, self.exitEyeFSMClosed, ["open", "off"]),
         ],
         "off",
         "off",
     )
     self.eyeFSM.enterInitialState()
     if other != None:
         self.copyHuman(other)
Esempio n. 41
0
 def addModalTextMessage(self, text, buttonStyle = OTPDialog.CancelOnly, noCallback = None, yesCallback = None, cancelCallback = None, seconds = 120, priority = 0, color = (1, 1, 1, 1), icon = (), modelName = 'general_frame_f', name = None, avId = None):
     if name:
         t2 = text % name
     else:
         t2 = text
     if self.lastMessage == text:
         return None
     
     msg = ModalStackMessage(parent = self, buttonStyle = buttonStyle, noCallback = noCallback, yesCallback = yesCallback, cancelCallback = cancelCallback, text = text, text_wordwrap = 15.5, text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_fg = color, text_pos = (0.17000000000000001, -0.071999999999999995, 0), textMayChange = 1, time = seconds, priority = priority, icon = icon, modelName = modelName)
     if name:
         msg['text_fg'] = (0, 0, 0, 0)
         nameArray = ('\x1CPOrangeHEAD\x1' + name + '\x2', '\x1CPOrangeHEAD\x1' + name + '\x2', '\x1CPOrangeOVER\x1' + name + '\x2', '\x1CPOrangeHEAD\x1' + name + '\x2')
         nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarModalPress, extraArgs = [
             avId,
             name])
         (left, right, bottom, top) = nameButton.getBounds()
         nameGFX = TextGraphic(nameButton, left, right, 0, 1)
         buttonName = '\x5' + name + '\x5'
         buttonText = text % buttonName
         tpMgr = TextPropertiesManager.getGlobalPtr()
         tpMgr.setGraphic(name, nameGFX)
         del tpMgr
         textRender = TextNode('textRender')
         textRender.setFont(PiratesGlobals.getInterfaceFont())
         textRender.setTextColor(PiratesGuiGlobals.TextFG14)
         textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
         textRender.setWordwrap(15.5)
         textRender.setTabWidth(1.0)
         textRender.setShadow(0.080000000000000002, 0.080000000000000002)
         textRender.setText(buttonText)
         x = msg.attachNewNode(textRender.generate())
         x.setScale(0.034500000000000003, 1.0, 0.035000000000000003)
         x.setPos(0.16700000000000001, 0, -0.072999999999999995)
     
     self.addMessage(msg)
     self.lastMessage = text
     if icon and icon[0] == 'ship':
         self.shipMessage = msg
     
     return msg
Esempio n. 42
0
 def addModalTextMessage(self, text, buttonStyle = OTPDialog.CancelOnly, noCallback = None, yesCallback = None, cancelCallback = None, seconds = 120, priority = 0, color = (1, 1, 1, 1), icon = (), modelName = 'general_frame_f', name = None, avId = None):
     if name:
         t2 = text % name
     else:
         t2 = text
     if self.lastMessage == text:
         return None
     
     msg = ModalStackMessage(parent = self, buttonStyle = buttonStyle, noCallback = noCallback, yesCallback = yesCallback, cancelCallback = cancelCallback, text = text, text_wordwrap = 15.5, text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_fg = color, text_pos = (0.17000000000000001, -0.071999999999999995, 0), textMayChange = 1, time = seconds, priority = priority, icon = icon, modelName = modelName)
     if name:
         msg['text_fg'] = (0, 0, 0, 0)
         nameArray = ('\x01CPOrangeHEAD\x01' + name + '\x02', '\x01CPOrangeHEAD\x01' + name + '\x02', '\x01CPOrangeOVER\x01' + name + '\x02', '\x01CPOrangeHEAD\x01' + name + '\x02')
         nameButton = DirectButton(parent = NodePath(), relief = None, text = nameArray, text_align = TextNode.ALeft, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, command = self.handleAvatarModalPress, extraArgs = [
             avId,
             name])
         (left, right, bottom, top) = nameButton.getBounds()
         nameGFX = TextGraphic(nameButton, left, right, 0, 1)
         buttonName = '\x05' + name + '\x05'
         buttonText = text % buttonName
         tpMgr = TextPropertiesManager.getGlobalPtr()
         tpMgr.setGraphic(name, nameGFX)
         del tpMgr
         textRender = TextNode('textRender')
         textRender.setFont(PiratesGlobals.getInterfaceFont())
         textRender.setTextColor(PiratesGuiGlobals.TextFG14)
         textRender.setShadowColor(PiratesGuiGlobals.TextShadow)
         textRender.setWordwrap(15.5)
         textRender.setTabWidth(1.0)
         textRender.setShadow(0.080000000000000002, 0.080000000000000002)
         textRender.setText(buttonText)
         x = msg.attachNewNode(textRender.generate())
         x.setScale(0.034500000000000003, 1.0, 0.035000000000000003)
         x.setPos(0.16700000000000001, 0, -0.072999999999999995)
     
     self.addMessage(msg)
     self.lastMessage = text
     if icon and icon[0] == 'ship':
         self.shipMessage = msg
     
     return msg
Esempio n. 43
0
 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.typeLabel = DirectLabel(
         parent=self.nameLabel,
         relief=None,
         state=DGG.DISABLED,
         text='',
         text_pos=(0.59999999999999998, -0.029999999999999999),
         text_font=PiratesGlobals.getInterfaceFont(),
         text_scale=0.032000000000000001,
         text_align=TextNode.ARight,
         text_fg=PiratesGuiGlobals.TextFG2,
         text_shadow=(0, 0, 0, 1),
         textMayChange=0)
     self.stateLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         text='',
         text_font=PiratesGlobals.getInterfaceFont(),
         text_align=TextNode.ALeft,
         text_fg=PiratesGuiGlobals.TextFG2,
         text_shadow=(0, 0, 0, 1),
         text_pos=(0.19, 0.070000000000000007),
         text_scale=PiratesGuiGlobals.TextScaleLarge,
         textMayChange=0)
     gui = loader.loadModel('models/gui/toplevel_gui')
     geomCheck = gui.find('**/generic_check')
     self.button = GuiButton(
         parent=self,
         pos=(0.73999999999999999, 0, 0.080000000000000002),
         text=PLocalizer.SelectShip,
         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.40000000000000002, 0, 0.029999999999999999),
         helpDelay=0.29999999999999999,
         command=self['command'],
         extraArgs=self['extraArgs'])
 def __init__(self, parent = None, hotkeys = (), hotkeyLabel = None, hotkeyLabelX = 0.091999999999999998, hotkeyArgs = True, helpText = '', helpPos = (0, 0, 0), helpDelay = PiratesGuiGlobals.HelpPopupTime, helpColorOff = False, helpLeftAlign = False, helpCenterAlign = False, **kw):
     self.loadGui()
     self.helpBox = None
     self.helpWatcher = None
     self.canRepositon = False
     optiondefs = (('relief', None, None), ('pos', (0, 0, 0), None), ('image', GuiButton.genericButton, None), ('image_scale', (0.23999999999999999, 0.22, 0.22), None), ('image_pos', (0, 0, 0), None), ('pressEffect', 0, None), ('text', '', None), ('text_font', PiratesGlobals.getInterfaceFont(), None), ('text_scale', PiratesGuiGlobals.TextScaleLarge, None), ('text0_fg', PiratesGuiGlobals.TextFG2, None), ('text1_fg', PiratesGuiGlobals.TextFG2, None), ('text2_fg', PiratesGuiGlobals.TextFG2, None), ('text3_fg', PiratesGuiGlobals.TextFG3, None), ('text_shadow', PiratesGuiGlobals.TextShadow, None), ('text_pos', (0, -0.01), None), ('text_wordwrap', 8, None), ('text_align', TextNode.ACenter, None), ('textMayChange', 1, None), ('helpText', helpText, self.helpTextUpdated), ('helpPos', helpPos, self.setHelpPos), ('helpDelay', helpDelay, None), ('helpColorOff', helpColorOff, None), ('helpLeftAlign', helpLeftAlign, None), ('helpCenterAlign', helpCenterAlign, None), ('helpBin', 'gui-popup', None), ('helpBinSort', 0, None), ('helpOpaque', 0, None), ('canReposition', False, None), ('sortOrder', 100, None), ('baseImage', None, None), ('selected', False, None), ('selectedImage', GuiButton.genericButton, None), ('state', DGG.NORMAL, self.setState))
     self.defineoptions(kw, optiondefs)
     DirectButton.__init__(self, parent = NodePath())
     self.initialiseoptions(GuiButton)
     self.hotkeys = ()
     self.setupHotkeys(hotkeys, hotkeyLabel, self['command'], self['extraArgs'], hotkeyLabelX, hotkeyArgs)
     if not parent:
         pass
     self.reparentTo(aspect2d)
     self.helpTaskName = None
    def loadTypeAName(self):
        self.nameEntry = DirectEntry(
            parent=self.parent,
            relief=DGG.FLAT,
            scale=0.16,
            width=MAX_NAME_WIDTH,
            numLines=2,
            focus=0,
            cursorKeys=1,
            autoCapitalize=1,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            text=PL.NameGUI_EmptyNameText,
            text_fg=(1.0, 1.0, 0.5, 1.0),
            pos=(-0.65000000000000002, 0.0, -0.050000000000000003),
            suppressKeys=1,
            suppressMouse=1,
            image=self.charGui.find('**/chargui_frame02'),
            image_scale=(15, 0.0, 8.5),
            image_pos=(4.3899999999999997, 0.0, -0.20000000000000001))
        self.nameEntryGuidelines = DirectLabel(
            parent=self.parent,
            relief=None,
            text=PL.NameGUI_Guidelines,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG3,
            text_pos=(0, 0.25),
            text_wordwrap=18,
            scale=0.10000000000000001,
            pos=(-0.69999999999999996, 0, -0.5))
        if self.cr:
            self.nameEntryGuidelinesURL = DirectButton(
                parent=self.parent,
                relief=None,
                pos=(0, 0, -0.55000000000000004),
                command=base.popupBrowser,
                extraArgs=[launcher.getValue('GAME_INGAME_NAMING')],
                text=PL.NameGUI_URLText,
                text0_fg=PiratesGuiGlobals.TextFG2,
                text1_fg=PiratesGuiGlobals.TextFG2,
                text2_fg=PiratesGuiGlobals.TextFG1,
                text_font=PiratesGlobals.getInterfaceFont(),
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_scale=0.089999999999999997,
                text_pos=(0, -0.63500000000000001))

        func = lambda param=self: param.fsm.request('PickAName')
        self.pickANameButton = self._makeButton(
            text=PL.NameGUI_PickANameButtonText,
            command=func,
            pos=(0, 0, -1.7))
        if not self.independent:
            if not self.main.isNPCEditor:
                self.submitButton = self._makeButton(
                    text=PL.NameGUI_SubmitButtonText,
                    command=self._typedAName,
                    pos=(0, 0, 1.7))
                self.submitButton.hide()

        else:
            self.cancelButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.MakeAPirateCancel,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.cancel,
                pos=(-0.68000000000000005, 0, -2.4300000000000002))
            self.randomButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.RandomButton,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.makeRandomName,
                pos=(0.050000000000000003, 0, -2.4300000000000002))
            self.randomButton.hide()
            self.submitButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.NameGUI_SubmitButtonText,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.complete,
                pos=(0.78000000000000003, 0, -2.4300000000000002))
        self.typeANameGui.append(self.pickANameButton)
        self.typeANameGui.append(self.nameEntry)
        self.typeANameGui.append(self.nameEntryGuidelines)
        if self.cr:
            self.typeANameGui.append(self.nameEntryGuidelinesURL)

        self.hide()
class NameGUI(DirectFrame, StateData.StateData):
    NICKNAME = 'Nickname'
    FIRST = 'First'
    PREFIX = 'Prefix'
    SUFFIX = 'Suffix'
    _NameGUI__MODE_INIT = 0
    _NameGUI__MODE_TYPEANAME = 1
    _NameGUI__MODE_PICKANAME = 2
    POSSIBLE_NAME_COMBOS = {'first-last': [0, 1, 1]}
    text = TextNode('text')
    text.setFont(PiratesGlobals.getInterfaceFont())

    def __init__(self, main=None, independent=False):
        DirectFrame.__init__(self)
        DirectFrame.initialiseoptions(self, NameGUI)
        self.charGui = loader.loadModel('models/gui/char_gui')
        self.triangleGui = loader.loadModel('models/gui/triangle')
        if hasattr(base, 'cr') and not hasattr(base.cr, 'isFake'):
            self.cr = base.cr
        else:
            self.cr = None
        self.main = main
        self.independent = independent
        if self.independent:
            np = NodePath(PlaneNode('p', Plane(Vec4(1, 0, 0, 0))))
            self.mainFrame = DirectFrame(parent=base.a2dBottomRight,
                                         relief=None)
            self.bookModel = DirectFrame(
                parent=self.mainFrame,
                image=self.charGui.find('**/chargui_base'),
                image_pos=(-0.13, 0, 0),
                relief=None)
            self.bookModel.setClipPlane(np)
            np.setX(-1.1299999999999999)
            np.reparentTo(self.bookModel)
            self.mainFrame.setScale(0.41999999999999998)
            self.mainFrame.setX(-0.76000000000000001)
            self.mainFrame.setZ(1.2)
            self.parent = self.bookModel
            self.avatar = main
        else:
            self.parent = main.bookModel
            self.avatar = main.avatar
        self.mode = self._NameGUI__MODE_INIT
        self.wantTypeAName = True
        self.names = ['', '', '', '']
        self.savedGender = None
        self.savedMaleName = None
        self.savedMaleActiveStates = None
        self.savedFemaleName = None
        self.savedFemaleActiveStates = None
        self.customName = False
        self.nicknameIndex = 2
        self.firstIndex = 2
        self.prefixIndex = 2
        self.suffixIndex = 2
        self.listsCreated = 0
        self.nicknameActive = 0
        self.firstActive = 1
        self.lastActive = 1
        self.nameEntry = None
        self.pickANameGui = []
        self.typeANameGui = []
        self.fsm = ClassicFSM.ClassicFSM('NameShop', [
            State.State('Init', self.enterInit, self.exitInit, ['Pay']),
            State.State('Pay', self.enterPay, self.exitPay,
                        ['PickAName', 'TypeAName']),
            State.State('PickAName', self.enterPickAName, self.exitPickAName,
                        ['TypeAName', 'Done']),
            State.State(
                'TypeAName', self.enterTypeAName, self.exitTypeAName,
                ['PickAName', 'Approved', 'Accepted', 'Rejected', 'Done']),
            State.State('Approved', self.enterApproved, self.exitApproved,
                        ['PickAName', 'Done']),
            State.State('Accepted', self.enterAccepted, self.exitAccepted,
                        ['Done']),
            State.State('Rejected', self.enterRejected, self.exitRejected,
                        ['TypeAName']),
            State.State('Done', self.enterDone, self.exitDone, ['Init', 'Pay'])
        ], 'Init', 'Done')
        self.fsm.enterInitialState()
        self.initNameLists()
        if self.independent or not (self.main.wantNPCViewer):
            self.makeRandomName()

    def initNameLists(self):
        buf = ['        ', '        ']
        self.nicknamesMale = PL.PirateNames_NickNamesGeneric + PL.PirateNames_NickNamesMale
        self.nicknamesFemale = PL.PirateNames_NickNamesGeneric + PL.PirateNames_NickNamesFemale
        self.firstNamesMale = PL.PirateNames_FirstNamesGeneric + PL.PirateNames_FirstNamesMale
        self.firstNamesFemale = PL.PirateNames_FirstNamesGeneric + PL.PirateNames_FirstNamesFemale
        self.lastPrefixesMale = PL.PirateNames_LastNamePrefixesGeneric + PL.PirateNames_LastNamePrefixesCapped + PL.PirateNames_LastNamePrefixesMale
        self.lastPrefixesFemale = PL.PirateNames_LastNamePrefixesGeneric + PL.PirateNames_LastNamePrefixesCapped + PL.PirateNames_LastNamePrefixesFemale
        self.lastSuffixesMale = PL.PirateNames_LastNameSuffixesGeneric + PL.PirateNames_LastNameSuffixesMale
        self.lastSuffixesFemale = PL.PirateNames_LastNameSuffixesGeneric + PL.PirateNames_LastNameSuffixesFemale
        self.nicknamesMale.sort()
        self.nicknamesFemale.sort()
        self.firstNamesMale.sort()
        self.firstNamesFemale.sort()
        self.lastPrefixesMale.sort()
        self.lastPrefixesFemale.sort()
        self.lastSuffixesMale.sort()
        self.lastSuffixesFemale.sort()
        self.nicknamesMale = buf + self.nicknamesMale + buf
        self.nicknamesFemale = buf + self.nicknamesFemale + buf
        self.firstNamesMale = buf + self.firstNamesMale + buf
        self.firstNamesFemale = buf + self.firstNamesFemale + buf
        self.lastPrefixesMale = buf + self.lastPrefixesMale + buf
        self.lastPrefixesFemale = buf + self.lastPrefixesFemale + buf
        self.lastSuffixesMale = buf + self.lastSuffixesMale + buf
        self.lastSuffixesFemale = buf + self.lastSuffixesFemale + buf
        self.makeRandomName()

    def enter(self):
        if self.mode == self._NameGUI__MODE_INIT:
            self.loadPickAName()
            self.loadTypeAName()
            self.listsCreated = 1
            name = self.getDNA().getDNAName()
            if name:
                if not (self.independent) and self.main.isNPCEditor:
                    self._NameGUI__assignNameToTyped(name)
                    return None

                self.decipherName(name)
                if self.mode == self._NameGUI__MODE_TYPEANAME:
                    return None

            else:
                self.makeRandomName()
        elif self.mode == self._NameGUI__MODE_PICKANAME:
            self.enterPickAName()
        elif self.mode == self._NameGUI__MODE_TYPEANAME:
            self.enterTypeAName()

        if self.savedGender:
            if self.savedGender != self.getDNA().gender:
                self.listsCreated = 0
                self.reset()
                if self.getDNA().getGender() == 'f':
                    self.nicknameList['items'] = self.nicknamesFemale[:]
                    self.firstList['items'] = self.firstNamesFemale[:]
                    self.prefixList['items'] = self.lastPrefixesFemale[:]
                    self.suffixList['items'] = self.lastSuffixesFemale[:]
                else:
                    self.nicknameList['items'] = self.nicknamesMale[:]
                    self.firstList['items'] = self.firstNamesMale[:]
                    self.prefixList['items'] = self.lastPrefixesMale[:]
                    self.suffixList['items'] = self.lastSuffixesMale[:]
                self.listsCreated = 1
                if self.getDNA().gender == 'm' and self.savedMaleName:
                    (self.nicknameIndex, self.firstIndex, self.prefixIndex,
                     self.suffixIndex) = self.savedMaleName
                    (self.nicknameActive, self.firstActive,
                     self.lastActive) = self.savedMaleActiveStates
                elif self.getDNA().gender == 'f' and self.savedFemaleName:
                    (self.nicknameIndex, self.firstIndex, self.prefixIndex,
                     self.suffixIndex) = self.savedFemaleName
                    (self.nicknameActive, self.firstActive,
                     self.lastActive) = self.savedFemaleActiveStates
                else:
                    self.makeRandomName()
                self._updateLists()
                self._updateCheckBoxes()

        self.fsm.request('Pay')

    def exit(self):
        self.hide()
        if self.cr:
            self.ignore(self.cr.getWishNameResultMsg())

        if hasattr(self, 'self._nameCheckCallback'):
            del self._nameCheckCallback

        if self.independent:
            pass
        1
        self.main.enableRandom()
        self.fsm.request('Done')

    def assignAvatar(self, avatar):
        self.avatar = avatar

    def _checkNpcNames(self, name):
        def match(npcName, name=name):
            name = TextEncoder().encodeWtext(name)
            name = string.strip(name)
            return TextEncoder.upper(npcName) == TextEncoder.upper(name)

        for npcId in NPCList.NPC_LIST.keys():
            data = NPCList.NPC_LIST[npcId]
            if type(data
                    ) is types.DictType and HumanDNA.HumanDNA.setName in data:
                npcName = data[HumanDNA.HumanDNA.setName]
                if (self.independent
                        or not (self.main.isNPCEditor)) and match(npcName):
                    self.notify.info('name matches NPC name "%s"' % npcName)
                    return OL.NCGeneric

            match(npcName)

    def getTypeANameProblem(self, callback):
        if not self.customName:
            callback(None)
        else:
            problem = None
            name = self.nameEntry.get()
            name = TextEncoder().decodeText(name)
            name = name.strip()
            name = TextEncoder().encodeWtext(name)
            self.nameEntry.enterText(name)
            problem = NameCheck.checkName(self.nameEntry.get(),
                                          [self._checkNpcNames],
                                          font=self.nameEntry.getFont())
            if problem:
                callback(problem)
            elif self.cr:
                self.ignore(self.cr.getWishNameResultMsg())
                self.acceptOnce(self.cr.getWishNameResultMsg(),
                                self._handleSetWishnameResult)
                self._nameCheckCallback = callback
                self._sendSetWishname(justCheck=True)
                return None

    def _checkTypeANameAsPickAName(self):
        if self.customName:
            pnp = PCPickANamePattern(self.nameEntry.get(),
                                     self.getDNA().gender)
            if pnp.hasNamePattern():
                self.fsm.request('PickAName')
                pattern = pnp.getNamePattern()
                actives = [
                    0,
                    choice(pattern[1] != -1, 1, 0),
                    choice(pattern[2] != -1, 1, 0)
                ]
                indices = pattern
                self._updateGuiToPickAName(actives, indices)

    def _sendSetWishname(self, justCheck=False):
        name = self.nameEntry.get()
        if justCheck:
            self.cr.sendWishNameAnonymous(name)
        else:
            self.cr.sendWishName(self.main.id, name)

    def _handleSetWishnameResult(self, result, avId, name):
        callback = self._nameCheckCallback
        del self._nameCheckCallback
        problem = OL.NCGeneric
        if result in (self.cr.WishNameResult.PendingApproval,
                      self.cr.WishNameResult.Approved):
            problem = None

        callback(problem)

    def save(self):
        if self.independent:
            if self.customName:
                self._sendSetWishname()
            else:
                name = self.getNumericName()
                self.cr.avatarManager.sendRequestPatternName(
                    self.main.id, name[0], name[1], name[2], name[3])
        else:
            self.avatar.dna.setName(self._getName())

    def loadPickAName(self):
        self.nameFrameTitle = DirectFrame(parent=self.parent,
                                          relief=None,
                                          frameColor=(0.5, 0.5, 0.5,
                                                      0.29999999999999999),
                                          text=PL.NameFrameTitle,
                                          text_fg=(1, 1, 1, 1),
                                          text_scale=0.17999999999999999,
                                          text_pos=(0, 0),
                                          pos=(0, 0, 0.29999999999999999),
                                          scale=0.69999999999999996)
        self.pirateName = DirectLabel(
            parent=self.parent,
            relief=None,
            image=self.charGui.find('**/chargui_frame02'),
            image_scale=(15, 10, 10),
            text=PL.NameGUI_EmptyNameText,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 0.5, 1),
            text_pos=(0, 0.25),
            text_wordwrap=MAX_NAME_WIDTH,
            scale=0.14999999999999999,
            pos=(0, 0, -1.1000000000000001))
        if self.getDNA().getGender() == 'f':
            lists = (self.nicknamesFemale, self.firstNamesFemale,
                     self.lastPrefixesFemale, self.lastSuffixesFemale)
        else:
            lists = (self.nicknamesMale, self.firstNamesMale,
                     self.lastPrefixesMale, self.lastSuffixesMale)
        self.nicknameList = self._makeScrolledList(
            items=lists[0],
            pos=(-0.81000000000000005, 0, -0.20000000000000001),
            makeExtraArgs=[self.NICKNAME],
            extraArgs=[0])
        self.nicknameList.stash()
        self.firstList = self._makeScrolledList(items=lists[1],
                                                pos=(-0.65000000000000002, 0,
                                                     -0.20000000000000001),
                                                makeExtraArgs=[self.FIRST],
                                                extraArgs=[1])
        self.prefixList = self._makeScrolledList(items=lists[2],
                                                 pos=(-0.10000000000000001, 0,
                                                      -0.20000000000000001),
                                                 makeExtraArgs=[self.PREFIX],
                                                 extraArgs=[2])
        self.suffixList = self._makeScrolledList(items=lists[3],
                                                 pos=(0.45000000000000001, 0,
                                                      -0.20000000000000001),
                                                 makeExtraArgs=[self.SUFFIX],
                                                 extraArgs=[3])
        self.nicknameCheck = self._makeCheckbox(
            text=PL.NameGUI_CheckboxText[0],
            command=self.nicknameToggle,
            pos=(-0.81000000000000005, 0, 0.10000000000000001))
        self.nicknameCheck.stash()
        self.firstCheck = self._makeCheckbox(text=PL.NameGUI_CheckboxText[0],
                                             command=self.firstToggle,
                                             pos=(-0.65000000000000002, 0,
                                                  0.10000000000000001))
        self.lastCheck = self._makeCheckbox(text=PL.NameGUI_CheckboxText[0],
                                            command=self.lastToggle,
                                            pos=(-0.10000000000000001, 0,
                                                 0.10000000000000001))
        self.nicknameHigh = self._makeHighlight(
            (-0.81000000000000005, 0, -0.20000000000000001))
        self.nicknameHigh.hide()
        self.firstHigh = self._makeHighlight(
            (-0.65000000000000002, 0, -0.20000000000000001))
        self.prefixHigh = self._makeHighlight(
            (-0.10000000000000001, 0, -0.20000000000000001))
        self.suffixHigh = self._makeHighlight(
            (0.45000000000000001, 0, -0.20000000000000001))
        self.randomNameButton = self._makeButton(
            text=PL.NameGUI_RandomButtonText,
            command=self.makeRandomName,
            pos=(-0.5, 0, -1.3999999999999999))
        self.randomNameButton.hide()

        func = lambda param=self: param.fsm.request('TypeAName')
        self.typeANameButton = self._makeButton(
            text=PL.NameGUI_TypeANameButtonText,
            command=func,
            pos=(0, 0, -1.7))
        self.typeANameButton.hide()
        self.pickANameGui.append(self.nicknameHigh)
        self.pickANameGui.append(self.firstHigh)
        self.pickANameGui.append(self.prefixHigh)
        self.pickANameGui.append(self.suffixHigh)
        self.pickANameGui.append(self.nicknameList)
        self.pickANameGui.append(self.firstList)
        self.pickANameGui.append(self.prefixList)
        self.pickANameGui.append(self.suffixList)
        self.pickANameGui.append(self.pirateName)
        self.pickANameGui.append(self.typeANameButton)
        self.pickANameGui.append(self.nicknameCheck)
        self.pickANameGui.append(self.firstCheck)
        self.pickANameGui.append(self.lastCheck)
        self.hide()

    def loadTypeAName(self):
        self.nameEntry = DirectEntry(
            parent=self.parent,
            relief=DGG.FLAT,
            scale=0.16,
            width=MAX_NAME_WIDTH,
            numLines=2,
            focus=0,
            cursorKeys=1,
            autoCapitalize=1,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            text=PL.NameGUI_EmptyNameText,
            text_fg=(1.0, 1.0, 0.5, 1.0),
            pos=(-0.65000000000000002, 0.0, -0.050000000000000003),
            suppressKeys=1,
            suppressMouse=1,
            image=self.charGui.find('**/chargui_frame02'),
            image_scale=(15, 0.0, 8.5),
            image_pos=(4.3899999999999997, 0.0, -0.20000000000000001))
        self.nameEntryGuidelines = DirectLabel(
            parent=self.parent,
            relief=None,
            text=PL.NameGUI_Guidelines,
            text_align=TextNode.ALeft,
            text_fg=PiratesGuiGlobals.TextFG3,
            text_pos=(0, 0.25),
            text_wordwrap=18,
            scale=0.10000000000000001,
            pos=(-0.69999999999999996, 0, -0.5))
        if self.cr:
            self.nameEntryGuidelinesURL = DirectButton(
                parent=self.parent,
                relief=None,
                pos=(0, 0, -0.55000000000000004),
                command=base.popupBrowser,
                extraArgs=[launcher.getValue('GAME_INGAME_NAMING')],
                text=PL.NameGUI_URLText,
                text0_fg=PiratesGuiGlobals.TextFG2,
                text1_fg=PiratesGuiGlobals.TextFG2,
                text2_fg=PiratesGuiGlobals.TextFG1,
                text_font=PiratesGlobals.getInterfaceFont(),
                text_shadow=PiratesGuiGlobals.TextShadow,
                text_scale=0.089999999999999997,
                text_pos=(0, -0.63500000000000001))

        func = lambda param=self: param.fsm.request('PickAName')
        self.pickANameButton = self._makeButton(
            text=PL.NameGUI_PickANameButtonText,
            command=func,
            pos=(0, 0, -1.7))
        if not self.independent:
            if not self.main.isNPCEditor:
                self.submitButton = self._makeButton(
                    text=PL.NameGUI_SubmitButtonText,
                    command=self._typedAName,
                    pos=(0, 0, 1.7))
                self.submitButton.hide()

        else:
            self.cancelButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.MakeAPirateCancel,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.cancel,
                pos=(-0.68000000000000005, 0, -2.4300000000000002))
            self.randomButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.RandomButton,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.makeRandomName,
                pos=(0.050000000000000003, 0, -2.4300000000000002))
            self.randomButton.hide()
            self.submitButton = GuiButton.GuiButton(
                parent=self.bookModel,
                text=PL.NameGUI_SubmitButtonText,
                text_fg=(1, 1, 1, 1),
                text_scale=0.080000000000000002,
                text_pos=(0, -0.25 * 0.10000000000000001, 0),
                scale=1.8,
                image_scale=0.40000000000000002,
                command=self.complete,
                pos=(0.78000000000000003, 0, -2.4300000000000002))
        self.typeANameGui.append(self.pickANameButton)
        self.typeANameGui.append(self.nameEntry)
        self.typeANameGui.append(self.nameEntryGuidelines)
        if self.cr:
            self.typeANameGui.append(self.nameEntryGuidelinesURL)

        self.hide()

    def _makeScrolledList(self, items, pos, makeExtraArgs, extraArgs):
        lst = items[:]
        dsl = DirectScrolledList(
            parent=self.parent,
            relief=None,
            items=lst,
            itemMakeFunction=self._makeItemLabel,
            itemMakeExtraArgs=makeExtraArgs,
            extraArgs=extraArgs,
            command=self._listsChanged,
            pos=pos,
            scale=0.080000000000000002,
            incButton_pos=(1.5, 0, -6),
            incButton_relief=None,
            incButton_image=(self.triangleGui.find('**/triangle'),
                             self.triangleGui.find('**/triangle_down'),
                             self.triangleGui.find('**/triangle_over')),
            incButton_image_scale=1.8,
            incButton_image_hpr=(0, 0, 90),
            incButton_image_pos=(0, 0, -0.5),
            decButton_pos=(1.5, 0, 2),
            decButton_relief=None,
            decButton_image=(self.triangleGui.find('**/triangle'),
                             self.triangleGui.find('**/triangle_down'),
                             self.triangleGui.find('**/triangle_over')),
            decButton_image_scale=1.8,
            decButton_image_hpr=(0, 0, 270),
            decButton_image_pos=(0, 0, 0.5),
            itemFrame_relief=None,
            itemFrame_pos=(-0.75, 0, 0),
            itemFrame_scale=1.0,
            itemFrame_image=self.charGui.find('**/chargui_frame04'),
            itemFrame_image_scale=(14, 10, 10),
            itemFrame_image_pos=(2.3999999999999999, 0, -2),
            itemFrame_text_fg=(1, 1, 1, 1),
            forceHeight=1.1000000000000001,
            numItemsVisible=5)
        return dsl

    def _makeHighlight(self, pos):
        return DirectFrame(parent=self.parent,
                           relief=DGG.FLAT,
                           frameColor=(1, 1, 1, 0.40000000000000002),
                           frameSize=(-1.1000000000000001, 4,
                                      -2.2000000000000002,
                                      -1.1000000000000001),
                           borderWidth=(1, 0.5),
                           pos=pos,
                           scale=0.089999999999999997)

    def _makeItemLabel(self, text, index, args=[]):
        f = DirectFrame(state='normal',
                        relief=None,
                        text=text,
                        text_scale=1.0,
                        text_pos=(-0.29999999999999999, 0.14000000000000001,
                                  0),
                        text_align=TextNode.ALeft,
                        text_fg=(1, 1, 1, 1),
                        textMayChange=0)
        if len(args) > 0:
            listType = args[0]
            f.bind(DGG.B1PRESS,
                   lambda x, f=f: self._nameClickedOn(listType, index))

        return f

    def _makeButton(self, text, command, pos):
        b = DirectButton(parent=self.parent,
                         relief=None,
                         image=(self.charGui.find('**/chargui_frame02'),
                                self.charGui.find('**/chargui_frame02_down'),
                                self.charGui.find('**/chargui_frame02_over')),
                         text=text,
                         text_fg=(1, 1, 1, 1),
                         text_align=TextNode.ACenter,
                         text_scale=0.10000000000000001,
                         command=command,
                         pos=pos)
        return b

    def _makeCheckbox(self, text, command, pos):
        c = DirectCheckButton(parent=self.parent,
                              relief=None,
                              scale=0.10000000000000001,
                              boxBorder=0.080000000000000002,
                              boxRelief=None,
                              pos=pos,
                              text=text,
                              text_fg=(1, 1, 1, 1),
                              text_scale=0.80000000000000004,
                              text_pos=(0.40000000000000002, 0),
                              indicator_pos=(0, 0, 0),
                              indicator_text_fg=(1, 1, 1, 1),
                              command=command,
                              text_align=TextNode.ALeft)
        return c

    def _nameClickedOn(self, listType, index):
        if listType == self.NICKNAME:
            self.nicknameIndex = index
        elif listType == self.FIRST:
            self.firstIndex = index
        elif listType == self.PREFIX:
            self.prefixIndex = index
        else:
            self.suffixIndex = index
        self._updateLists()

    def _listsChanged(self, extraArgs):
        if self.listsCreated:
            if extraArgs == 0:
                if self.nicknameActive:
                    self.enableList(self.nicknameList)
                    self.names[0] = self.nicknameList['items'][
                        self.nicknameList.index + 2]['text']
                    self.nicknameHigh.show()
                else:
                    self.disableList(self.nicknameList)
                    self.names[0] = ''
                    self.nicknameHigh.hide()
                self.nicknameIndex = self.nicknameList.index + 2
            elif extraArgs == 1:
                if self.firstActive:
                    self.enableList(self.firstList)
                    self.names[1] = self.firstList['items'][
                        self.firstList.index + 2]['text']
                    self.firstHigh.show()
                else:
                    self.disableList(self.firstList)
                    self.names[1] = ''
                    self.firstHigh.hide()
                self.firstIndex = self.firstList.index + 2
            elif extraArgs == 2:
                if self.lastActive:
                    self.enableList(self.prefixList)
                    self.names[2] = self.prefixList['items'][
                        self.prefixList.index + 2]['text']
                    self.prefixHigh.show()
                else:
                    self.disableList(self.prefixList)
                    self.names[2] = ''
                    self.prefixHigh.hide()
                self.prefixIndex = self.prefixList.index + 2
            elif extraArgs == 3:
                if self.lastActive:
                    self.enableList(self.suffixList)
                    self.names[3] = self.suffixList['items'][
                        self.suffixList.index + 2]['text']
                    self.suffixHigh.show()
                else:
                    self.disableList(self.suffixList)
                    self.names[3] = ''
                    self.suffixHigh.hide()
                self.suffixIndex = self.suffixList.index + 2

            if len(self.names[0] + self.names[1] + self.names[2] +
                   self.names[3]) > 0:
                self.updateName()

    def _updateLists(self):
        oldIndices = [
            self.nicknameIndex, self.firstIndex, self.prefixIndex,
            self.suffixIndex
        ]
        self.firstList.scrollTo(self.firstIndex - 2)
        self._restoreIndices(oldIndices)
        self.prefixList.scrollTo(self.prefixIndex - 2)
        self._restoreIndices(oldIndices)
        self.suffixList.scrollTo(self.suffixIndex - 2)
        self._restoreIndices(oldIndices)

    def _getName(self):
        newName = ''
        if self.mode == self._NameGUI__MODE_TYPEANAME:
            newName = self.nameEntry.get()
            newName = TextEncoder().decodeText(newName)
            newName = newName.strip()
            newName = TextEncoder().encodeWtext(newName)
        else:
            newName += self.names[0]
            if len(newName) > 0 and len(self.names[1]) > 0:
                newName += ' '

            newName += self.names[1]
            if len(newName) > 0 and len(self.names[2]) > 0:
                newName += ' '

            newName += self.names[2]
            if self.names[2] in PL.PirateNames_LastNamePrefixesCapped:
                newName += self.names[3].capitalize()
            else:
                newName += self.names[3]
        return newName

    def updateName(self):
        self.pirateName['text'] = self._getName()

    def _restoreIndices(self, indices):
        self.nicknameIndex = indices[0]
        self.firstIndex = indices[1]
        self.prefixIndex = indices[2]
        self.suffixIndex = indices[3]

    def enableList(self, listToEnable):
        listToEnable.show()
        listToEnable.decButton['state'] = 'normal'
        listToEnable.incButton['state'] = 'normal'

    def disableList(self, listToDisable):
        listToDisable.decButton['state'] = 'disabled'
        listToDisable.incButton['state'] = 'disabled'
        for item in listToDisable['items']:
            if item.__class__.__name__ != 'str':
                item.hide()
                continue

    def unload(self):
        self.nicknameCheck.destroy()
        self.nicknameList.destroy()
        if self.independent:
            self.mainFrame.destroy()
        elif self.nameEntry:
            self.nameEntry.destroy()
            self.nameEntryGuidelines.destroy()
            if self.cr:
                self.nameEntryGuidelinesURL.destroy()

        del self.main
        del self.parent
        del self.avatar
        del self.fsm

    def reset(self):
        for item in self.nicknameList['items'] + self.firstList[
                'items'] + self.prefixList['items'] + self.suffixList['items']:
            if item.__class__.__name__ != 'str':
                item.destroy()
                continue

        self.nicknameIndex = 2
        self.firstIndex = 2
        self.prefixIndex = 2
        self.suffixIndex = 2
        self.nicknameList.index = 0
        self.firstList.index = 0
        self.prefixList.index = 0
        self.suffixList.index = 0

    def showPickAName(self):
        self.nameFrameTitle.show()
        for elt in self.pickANameGui:
            if elt != self.nicknameHigh and elt != self.firstHigh and elt != self.prefixHigh and elt != self.suffixHigh:
                elt.show()
                continue

    def hasCustomName(self):
        return self.customName

    def showTypeAName(self):
        self.customName = True
        self.nameFrameTitle.show()
        for elt in self.typeANameGui:
            elt.show()

    def hide(self):
        self.nameFrameTitle.hide()
        for elt in self.pickANameGui:
            elt.hide()

        for elt in self.typeANameGui:
            elt.hide()

    def makeRandomName(self):
        if self.customName and not (self.independent):
            return None

        if self.getDNA().getGender() == 'f':
            self.nicknameIndex = ''
            self.firstIndex = random.choice(
                range(len(self.firstNamesFemale) - 4)) + 2
            self.prefixIndex = random.choice(
                range(len(self.lastPrefixesFemale) - 4)) + 2
            self.suffixIndex = random.choice(
                range(len(self.lastSuffixesFemale) - 4)) + 2
        else:
            self.nicknameIndex = ''
            self.firstIndex = random.choice(
                range(len(self.firstNamesMale) - 4)) + 2
            self.prefixIndex = random.choice(
                range(len(self.lastPrefixesMale) - 4)) + 2
            self.suffixIndex = random.choice(
                range(len(self.lastSuffixesMale) - 4)) + 2
        nameCombo = random.choice(self.POSSIBLE_NAME_COMBOS.keys())
        (self.nicknameActive, self.firstActive,
         self.lastActive) = self.POSSIBLE_NAME_COMBOS[nameCombo]
        self._updateGuiToPickAName(
            [self.nicknameActive, self.firstActive, self.lastActive],
            [0, self.firstIndex, self.prefixIndex, self.suffixIndex])

    def _updateGuiToPickAName(self, actives, indices):
        (self.nicknameActive, self.firstActive, self.lastActive) = actives
        (nickname, self.firstIndex, self.prefixIndex,
         self.suffixIndex) = indices
        if self.listsCreated:
            self._updateLists()
            self._updateCheckBoxes()
        elif self.getDNA().getGender() == 'f':
            self.names[0] = ''
            self.names[1] = self.firstNamesFemale[self.firstIndex]
            self.names[2] = self.lastPrefixesFemale[self.prefixIndex]
            self.names[3] = self.lastSuffixesFemale[self.suffixIndex]
        else:
            self.names[0] = ''
            self.names[1] = self.firstNamesMale[self.firstIndex]
            self.names[2] = self.lastPrefixesMale[self.prefixIndex]
            self.names[3] = self.lastSuffixesMale[self.suffixIndex]
        self.notify.debug('random name blindly generated:%s' % self._getName())

    def decipherName(self, name):
        nameParts = name.split()
        if len(nameParts) == 1:
            self.nicknameEnabled = 0
            nameInFirst = self._NameGUI__checkForNameInFirstList(nameParts[0])
            nameInLast = self._NameGUI__checkForNameInLastList(nameParts[0])
            if not nameInFirst or nameInLast:
                self._NameGUI__assignNameToTyped(name)
                return None

        elif len(nameParts) == 2:
            if self._NameGUI__checkForNameInNicknameList(nameParts[0]):
                nameInFirst = self._NameGUI__checkForNameInFirstList(
                    nameParts[1])
                nameInLast = self._NameGUI__checkForNameInLastList(
                    nameParts[1])
                if not nameInFirst or nameInLast:
                    self._NameGUI__assignNameToTyped(name)
                    return None

            else:
                nameInFirst = self._NameGUI__checkForNameInFirstList(
                    nameParts[0])
                nameInLast = self._NameGUI__checkForNameInLastList(
                    nameParts[1])
                if not nameInFirst and nameInLast:
                    self._NameGUI__assignNameToTyped(name)
                    return None

        elif len(nameParts) == 3:
            nameInNick = self._NameGUI__checkForNameInNicknameList(
                nameParts[0])
            nameInFirst = self._NameGUI__checkForNameInFirstList(nameParts[1])
            nameInLast = self._NameGUI__checkForNameInLastList(nameParts[2])
            if not nameInNick and nameInFirst and nameInLast:
                self._NameGUI__assignNameToTyped(name)
                return None

        else:
            self._NameGUI__assignNameToTyped(name)
            return None
        self.mode = self._NameGUI__MODE_PICKANAME
        self._updateLists()
        self._updateCheckBoxes()

    def _NameGUI__checkForNameInNicknameList(self, name):
        if self.getDNA().getGender() == 'f':
            nicknameTextList = self.nicknamesFemale
        else:
            nicknameTextList = self.nicknamesMale
        if nicknameTextList.__contains__(name):
            self.nicknameEnabled = 1
            self.nicknameIndex = nicknameTextList.index(name)
            return True
        else:
            self.nicknameEnabled = 0
            return False

    def _NameGUI__checkForNameInFirstList(self, name):
        if self.getDNA().getGender() == 'f':
            firstTextList = self.firstNamesFemale
        else:
            firstTextList = self.firstNamesMale
        if firstTextList.__contains__(name):
            self.firstEnabled = 1
            self.firstIndex = firstTextList.index(name)
            return True
        else:
            self.firstEnabled = 0
            return False

    def _NameGUI__checkForNameInLastList(self, name):
        if self.getDNA().getGender() == 'f':
            prefixTextList = self.lastPrefixesFemale
            suffixTextList = self.lastSuffixesFemale
        else:
            prefixTextList = self.lastPrefixesMale
            suffixTextList = self.lastSuffixesMale
        for prefix in prefixTextList:
            if prefix.strip() != '' and name.startswith(
                    prefix) and suffixTextList.__contains__(
                        name[len(prefix):]):
                self.lastEnabled = 1
                self.prefixIndex = prefixTextList.index(prefix)
                self.suffixIndex = suffixTextList.index(name[len(prefix):])
                return True
                continue

        self.lastEnabled = 0
        return False

    def _NameGUI__assignNameToTyped(self, name):
        self.nameEntry.enterText(name)
        self.mode = self._NameGUI__MODE_TYPEANAME
        self.fsm.request('Pay')

    def nicknameToggle(self, value):
        self.nicknameActive = self.nicknameCheck['indicatorValue']
        self._listsChanged(0)
        if self.nicknameActive:
            self.nicknameList.refresh()

        self._updateCheckBoxes()

    def firstToggle(self, value):
        self.firstActive = self.firstCheck['indicatorValue']
        if not self.firstActive or self.lastActive:
            self.firstActive = 1
            self.notify.debug(random.choice(PL.NameGUI_NoNameWarnings))

        self._listsChanged(1)
        if self.firstActive:
            self.firstList.refresh()

        self._updateCheckBoxes()

    def lastToggle(self, value):
        self.lastActive = self.lastCheck['indicatorValue']
        if not self.firstActive or self.lastActive:
            self.lastActive = 1
            self.notify.debug(random.choice(PL.NameGUI_NoNameWarnings))

        self._listsChanged(2)
        self._listsChanged(3)
        if self.lastActive:
            self.prefixList.refresh()
            self.suffixList.refresh()

        self._updateCheckBoxes()

    def _updateCheckBoxes(self):
        self.nicknameCheck['indicatorValue'] = self.nicknameActive
        self.nicknameCheck['text'] = PL.NameGUI_CheckboxText[int(
            self.nicknameActive)]
        self.nicknameCheck.setIndicatorValue()
        self.firstCheck['indicatorValue'] = self.firstActive
        self.firstCheck['text'] = PL.NameGUI_CheckboxText[int(
            self.firstActive)]
        self.firstCheck.setIndicatorValue()
        self.lastCheck['indicatorValue'] = self.lastActive
        self.lastCheck['text'] = PL.NameGUI_CheckboxText[int(self.lastActive)]
        self.lastCheck.setIndicatorValue()

    def enterInit(self):
        pass

    def exitInit(self):
        pass

    def enterPay(self):
        if self.mode == self._NameGUI__MODE_TYPEANAME:
            self.fsm.request('TypeAName')
        else:
            self.fsm.request('PickAName')

    def exitPay(self):
        pass

    def enterPickAName(self):
        if self.independent:
            self.randomButton.show()
        else:
            self.main.enableRandom()
        self.mode = self._NameGUI__MODE_PICKANAME
        self.customName = False
        self.showPickAName()
        self._updateLists()
        self._updateCheckBoxes()

    def exitPickAName(self):
        if self.independent:
            self.randomButton.hide()

        self.hide()

    def enterTypeAName(self):
        self.mode = self._NameGUI__MODE_TYPEANAME
        if not self.independent:
            self.main.disableRandom()

        self.typeANameButton.hide()
        self.showTypeAName()
        self.nameEntry['focus'] = 1

    def _typedAName(self, *args):
        self.nameEntry['focus'] = 0
        name = self.nameEntry.get()
        name = TextEncoder().decodeText(name)
        name = name.strip()
        name = TextEncoder().encodeWtext(name)
        self.nameEntry.enterText(name)
        self.notify.debug('Chosen name: %s' % self.nameEntry.get())
        problem = NameCheck.checkName(name, [self._checkNpcNames],
                                      font=self.nameEntry.getFont())
        if problem:
            print problem
            self.nameEntry.enterText('')
        else:
            self.fsm.request('Approved')

    def exitTypeAName(self):
        self.typeANameButton.show()
        self.hide()

    def enterApproved(self):
        self.fsm.request('Accepted')

    def exitApproved(self):
        pass

    def enterRejected(self):
        pass

    def exitRejected(self):
        pass

    def enterAccepted(self):
        pass

    def exitAccepted(self):
        pass

    def enterDone(self):
        self.notify.debug('Entering done state')
        if self.independent:
            self.save()
            messenger.send('NameGUIFinished', [1])
            return None

        if self.getDNA().gender == 'm':
            self.savedMaleActiveStates = (self.nicknameActive,
                                          self.firstActive, self.lastActive)
            self.savedMaleName = [
                self.nicknameIndex, self.firstIndex, self.prefixIndex,
                self.suffixIndex
            ]
            self.savedGender = 'm'
        elif self.getDNA().gender == 'f':
            self.savedFemaleName = [
                self.nicknameIndex, self.firstIndex, self.prefixIndex,
                self.suffixIndex
            ]
            self.savedFemaleActiveStates = (self.nicknameActive,
                                            self.firstActive, self.lastActive)
            self.savedGender = 'f'

    def exitDone(self):
        pass

    def complete(self):
        self.nameEntry['focus'] = 0
        name = self.nameEntry.get()
        name = TextEncoder().decodeText(name)
        name = name.strip()
        name = TextEncoder().encodeWtext(name)
        self.nameEntry.enterText(name)
        self.notify.debug('Chosen name: %s' % name)
        if self.customName:
            problem = NameCheck.checkName(name, [self._checkNpcNames],
                                          font=self.nameEntry.getFont())
            if problem:
                print problem
                self.nameEntry.enterText('')
            else:
                self.fsm.request('Done')
        else:
            self.fsm.request('Done')

    def cancel(self):
        messenger.send('NameGUIFinished', [0])

    def getNumericName(self):
        nick = 0
        first = 0
        pre = 0
        suff = 0
        if self.firstActive:
            first = self.firstIndex

        if self.lastActive:
            pre = self.prefixIndex
            suff = self.suffixIndex

        return (nick, first, pre, suff)

    def findWidestInList(self, nameList):
        maxWidth = 0
        maxName = ''
        for name in nameList:
            width = self.text.calcWidth(name)
            if width > maxWidth:
                maxWidth = self.text.calcWidth(name)
                maxName = name
                continue

        print maxName + ' ' + str(maxWidth)
        return maxName

    def findWidestName(self):
        longestBoyTitle = self.findWidestInList(self.nicknamesMale[:])
        longestGirlTitle = self.findWidestInList(self.nicknamesFemale[:])
        longestBoyFirst = self.findWidestInList(self.firstNamesMale[:])
        longestGirlFirst = self.findWidestInList(self.firstNamesFemale[:])
        longestLastPrefix = self.findWidestInList(self.lastPrefixesFemale[:] +
                                                  self.lastPrefixesMale[:])
        longestLastSuffix = self.findWidestInList(self.lastSuffixesFemale[:] +
                                                  self.lastSuffixesMale[:])
        longestBoyName = longestBoyTitle + ' ' + longestBoyFirst + ' ' + longestLastPrefix + longestLastSuffix
        longestGirlName = longestGirlTitle + ' ' + longestGirlFirst + ' ' + longestLastPrefix + longestLastSuffix
        longestName = self.findWidestInList([longestBoyName, longestGirlName])
        return longestName

    def getDNA(self):
        if self.independent:
            return self.main.dna
        else:
            return self.main.pirate.style
Esempio n. 47
0
    def createTabExtended(self, name, iconClosed, iconOpen, command, extraArgList):
        newTab = self.tabBar.addTab('My Tab %s' % self.tabCount, frameSize = (-0.12, 0.12, -0.11, 0.11), focusSize = (-0.12, 0.12, -0.12, 0.12), heightFactor = 0.59999999999999998, command = command, extraArgs = extraArgList)
        self.tabCount += 1
        image = iconClosed
        newTab.imageTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, image = image, image_scale = image.getScale(), image_color = Vec4(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), pos = (0, 0, 0))
        newTab.nameTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, text = name, text_scale = PiratesGuiGlobals.TextScaleLarge, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_font = PiratesGlobals.getInterfaceFont(), pos = (0, 0, 0))
        newTab.nameTag.setBin('gui-fixed', 1)
        newTab.nameTag.hide()
        
        def mouseOver(tab = newTab):
            tab.imageTag.setScale(1.1000000000000001)
            tab.imageTag['image_color'] = Vec4(1, 1, 1, 1)
            base.playSfx(PiratesGuiGlobals.getDefaultRolloverSound())
            newTab.nameTag.show()

        
        def mouseOff(tab = newTab):
            if not tab['selected']:
                tab.imageTag.setScale(1.0)
                tab.imageTag['image_color'] = Vec4(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1)
            else:
                mouseOver(tab)
            newTab.nameTag.hide()

        newTab['mouseEntered'] = mouseOver
        newTab['mouseLeft'] = mouseOff
        return newTab
Esempio n. 48
0
 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.typeLabel = DirectLabel(parent = self.nameLabel, relief = None, state = DGG.DISABLED, text = '', text_pos = (0.59999999999999998, -0.029999999999999999), text_font = PiratesGlobals.getInterfaceFont(), text_scale = 0.032000000000000001, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), textMayChange = 0)
     self.stateLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = '', text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), text_pos = (0.19, 0.070000000000000007), text_scale = PiratesGuiGlobals.TextScaleLarge, textMayChange = 0)
     gui = loader.loadModel('models/gui/toplevel_gui')
     geomCheck = gui.find('**/generic_check')
     self.button = GuiButton(parent = self, pos = (0.73999999999999999, 0, 0.080000000000000002), text = PLocalizer.SelectShip, 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.40000000000000002, 0, 0.029999999999999999), helpDelay = 0.29999999999999999, command = self['command'], extraArgs = self['extraArgs'])
 def __init__(self, parent, titleId, position, panelIndex, titlesPage, defaultOnLand = 0, defaultOnSea = 0):
     DirectFrame.__init__(self, parent, pos = position)
     self.iconModel = loader.loadModel(TitleGlobals.getModelPath(titleId))
     tempModel = loader.loadModel('models/textureCards/skillIcons')
     self.titleId = titleId
     self.rank = 1
     self.maxRank = 1
     self.expPoints = 241
     self.expBase = 150
     self.expTarget = 400
     self.landActive = defaultOnLand
     self.seaActive = defaultOnSea
     self.panelIndex = panelIndex
     self.titlesPage = titlesPage
     self.booleanTitle = TitleGlobals.isBooleanTitle(self.titleId)
     topgui = loader.loadModel('models/gui/toplevel_gui')
     self.titleNameFrame = BorderFrame.BorderFrame(parent = self, relief = None, pos = (0.12, 0, 0.01), frameSize = (-0.14999999999999999, 0.5, -0.14999999999999999, 0.029999999999999999), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75), text = TitleGlobals.getTitleRankName(self.titleId, self.expPoints), text_align = TextNode.ALeft, text_scale = 0.035000000000000003, text_pos = (0, -0.02), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont())
     self.titleDescFrame = DirectFrame(parent = self, relief = None, pos = (0.125, 0, -0.095000000000000001), text = TitleGlobals.getTitleDesc(self.titleId), text_align = TextNode.ALeft, text_scale = 0.029999999999999999, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
     shipcard = loader.loadModel('models/gui/ship_battle')
     tex = shipcard.find('**/ship_battle_speed_bar*')
     self.expFrame = DirectFrame(parent = self, pos = (0.35999999999999999, 0, -0.050000000000000003), relief = None, image = tex, image_scale = (0.23000000000000001, 1, 0.5), scale = (1.48, 1, 1.2))
     self.expMeter = DirectWaitBar(parent = self.expFrame, relief = DGG.RAISED, borderWidth = (0.0040000000000000001, 0.0040000000000000001), range = 100, value = 50, frameColor = (0, 0, 0, 0), barColor = (223 / 255.0, 137 / 255.0, 28 / 255.0, 1), frameSize = (-0.222, 0.084000000000000005, -0.012, 0.012), pos = (0.069000000000000006, 0, 0.0))
     self.expMeterText = DirectFrame(parent = self, relief = None, pos = (0.59999999999999998, 0, 0.0), text = '%s / %s' % (self.expBase, self.expTarget), text_align = TextNode.ARight, text_scale = 0.029999999999999999, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont())
     if self.booleanTitle:
         self.expFrame.hide()
         self.expMeterText.hide()
     
     imgScale = TitleGlobals.getScale(self.titleId)
     self.iconFrame = GuiButton.GuiButton(parent = self, pos = (0.040000000000000001, 0, -0.050000000000000003), helpText = TitleGlobals.getTitleName(self.titleId), helpPos = (-0.26000000000000001, 0, 0.080000000000000002), relief = None, image = self.iconModel.find('**/' + TitleGlobals.getIconName(self.titleId, 1)), image_scale = (0.14999999999999999 * imgScale, 1, 0.14999999999999999 * imgScale))
     self.landButton = DirectButton.DirectButton(parent = self, pos = (0.70999999999999996, 0, -0.050000000000000003), relief = None, scale = 0.22, image_color = VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image = (topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command = self.selectLandBadge, extraArgs = [
         self.panelIndex])
     self.titlesPage.landButtons.append(self.landButton)
     self.seaButton = DirectButton.DirectButton(parent = self, pos = (0.87, 0, -0.050000000000000003), relief = None, scale = 0.22, image_color = VBase4(0.75, 0.84999999999999998, 1.0, 1.0), image = (topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle'), topgui.find('**/pir_t_gui_frm_base_circle_over'), topgui.find('**/pir_t_gui_frm_base_circle')), command = self.selectSeaBadge, extraArgs = [
         self.panelIndex])
     self.titlesPage.seaButtons.append(self.seaButton)
Esempio n. 50
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent=self,
                                relief=None,
                                state=DGG.DISABLED,
                                pos=(0.035, 0, 0.025))
     self.quantityLabel = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         text=str(self.quantity),
         text_fg=PiratesGuiGlobals.TextFG2,
         text_scale=PiratesGuiGlobals.TextScaleSmall *
         PLocalizer.getHeadingScale(2),
         text_align=TextNode.ARight,
         text_wordwrap=11,
         pos=(0.1225, 0, 0.015))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(
             2)
     else:
         if len(self.name) >= 35:
             textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(
                 2)
         else:
             textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(
                 2)
     self.nameTag = DirectLabel(parent=self,
                                relief=None,
                                state=DGG.DISABLED,
                                text=self.name,
                                text_fg=PiratesGuiGlobals.TextFG2,
                                text_scale=textScale,
                                text_align=TextNode.ALeft,
                                pos=(0.13, 0, 0.015))
     self.costText = DirectLabel(
         parent=self,
         relief=None,
         state=DGG.DISABLED,
         image=InventoryListItem.coinImage,
         image_scale=0.12,
         image_pos=Vec3(-0.005, 0, 0.0125),
         text=str(self.price),
         text_fg=PiratesGuiGlobals.TextFG2,
         text_scale=PiratesGuiGlobals.TextScaleSmall,
         text_align=TextNode.ARight,
         text_wordwrap=11,
         text_pos=(-0.03, 0, 0),
         pos=(self.width - 0.035, 0, 0.015),
         text_font=PiratesGlobals.getInterfaceFont())
     itemClass = EconomyGlobals.getItemCategory(itemId)
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = PurchaseListItem.fishingIcons.find(
                 '**/%s*' % asset)
             self.picture['geom_scale'] = 0.04
             self.picture['geom_pos'] = (0, 0, 0)
     else:
         if itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 self.picture['geom'] = InventoryListItem.weaponIcons.find(
                     '**/%s*' % asset)
                 self.picture['geom_scale'] = 0.04
                 self.picture['geom_pos'] = (0, 0, 0)
         else:
             if itemClass == ItemType.CONSUMABLE:
                 asset = EconomyGlobals.getItemIcons(itemId)
                 if asset:
                     self.picture[
                         'geom'] = InventoryListItem.skillIcons.find(
                             '**/%s*' % asset)
                     self.picture['geom_scale'] = 0.04
                     self.picture['geom_pos'] = (0, 0, 0)
     if InventoryType.begin_WeaponCannonAmmo <= itemId and itemId <= InventoryType.end_WeaponCannonAmmo or InventoryType.begin_WeaponPistolAmmo <= itemId and itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId and itemId <= InventoryType.end_WeaponDaggerAmmo:
         skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
         if skillId:
             asset = WeaponGlobals.getSkillIcon(skillId)
             if asset:
                 self.picture['geom'] = InventoryListItem.skillIcons.find(
                     '**/%s' % asset)
                 self.picture['geom_scale'] = 0.06
                 self.picture['geom_pos'] = (0, 0, 0)
     else:
         if InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find(
                 '**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.1
             self.picture['geom_pos'] = (0, 0, 0)
     self.flattenStrong()
     return
 def showLoot(self, plunder = [], gold = 0, collect = 0, card = 0, cloth = 0, color = 0, jewel = None, tattoo = None, weapon = None, bounty = 0):
     for loot in self.loot:
         loot.destroy()
         del loot
     
     self.loot = []
     gender = localAvatar.style.getGender()
     self.show()
     self.setAlphaScale(1.0)
     treasure = []
     for itemId in self.icons.iterkeys():
         count = 0
         for item in plunder:
             if item == itemId:
                 count += 1
                 continue
         
         if count > 0:
             treasure.append([
                 itemId,
                 count])
             continue
     
     plunder = treasure
     if gold:
         plunder.append([
             ItemId.GOLD,
             gold])
         LootPopupPanel.lootSfx.play()
     
     if bounty:
         plunder.append([
             ItemId.BOUNTY,
             bounty])
         LootPopupPanel.lootSfx.play()
     
     if collect:
         plunder.append([
             ItemId.COLLECT,
             collect])
         LootPopupPanel.lootSfx.play()
     
     if card:
         plunder.append([
             ItemId.CARD,
             card])
         LootPopupPanel.lootSfx.play()
     
     if cloth:
         plunder.append([
             ItemId.CLOTHING,
             (cloth, color)])
         LootPopupPanel.lootSfx.play()
     
     if jewel is not None:
         plunder.append([
             ItemId.QUEST_DROP_JEWEL,
             jewel])
         LootPopupPanel.lootSfx.play()
     
     if tattoo is not None:
         plunder.append([
             ItemId.QUEST_DROP_TATTOO,
             tattoo])
         LootPopupPanel.lootSfx.play()
     
     if weapon is not None:
         plunder.append([
             ItemId.QUEST_DROP_WEAPON,
             weapon])
         LootPopupPanel.lootSfx.play()
     
     for item in plunder:
         (itemType, quantity) = item
         if itemType == ItemId.COLLECT:
             itemId = quantity
             howRare = CollectionMap.Collection_Rarity.get(itemId, 0)
             rarityText = PLocalizer.CollectionRarities.get(howRare)
             value = CollectionValues.get(howRare, 0)
             itemName = PLocalizer.Collections[itemId]
             howManyDoIHave = localAvatar.getInventory().getStackQuantity(itemId)
             howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1)
             if howManyDoIHave < howManyINeed:
                 textInfo = PLocalizer.CollectionPopupNewText % (itemName, rarityText, value)
             else:
                 textInfo = PLocalizer.CollectionPopupDuplicateText % (itemName, rarityText, value)
             pic_name = CollectionMap.Assets[itemId]
             lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name)
             iconScale = 0.34999999999999998
         elif itemType == ItemId.CLOTHING:
             (clothingId, colorId) = quantity
             if clothingId in ClothingGlobals.quest_items:
                 textInfo = PLocalizer.getItemName(clothingId)
             else:
                 textInfo = PLocalizer.TailorColorStrings.get(colorId)
                 textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(ItemGlobals.getType(clothingId))
             clothingType = ItemGlobals.getType(clothingId)
             iconScale = 0.13
             if clothingType == 0:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_hat')
             elif clothingType == 1:
                 lootIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth')
                 iconScale = 0.29999999999999999
             elif clothingType == 2:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_vest')
             elif clothingType == 3:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_coat')
             elif clothingType == 4:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_pants')
             elif clothingType == 5:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_belt')
             elif clothingType == 6:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_sock')
             else:
                 lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_booths')
         elif itemType == ItemId.CARD:
             textInfo = PLocalizer.InventoryTypeNames.get(quantity)
             pic_name = ''
             lootIcon = PlayingCardGlobals.getImage('standard', PlayingCardGlobals.getSuit(quantity), PlayingCardGlobals.getRank(quantity))
             iconScale = 0.20000000000000001
         elif itemType == ItemId.GOLD:
             textInfo = PLocalizer.LootGold % str(quantity)
             potionPercent = PotionGlobals.getGoldBoostEffectPercent(localAvatar)
             potionGold = 0
             textInfo = PLocalizer.LootGold % str(quantity)
             if base.cr.newsManager:
                 if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(base.localAvatar.getDoId()) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY):
                     textInfo = PLocalizer.LootGold % str(quantity / 2) + '\n + ' + PLocalizer.LootGoldDouble % str(quantity / 2)
                 
             if potionGold > 0:
                 textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(potionGold)
             
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.BOUNTY:
             textInfo = PLocalizer.LootBounty % str(quantity)
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.27000000000000002
         elif itemType == ItemId.CARGO_CRATE:
             if quantity == 1:
                 textInfo = PLocalizer.CargoCrate % quantity
             else:
                 textInfo = PLocalizer.CargoCrateP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_CHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoChest % quantity
             else:
                 textInfo = PLocalizer.CargoChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_SKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.CargoSkChest % quantity
             else:
                 textInfo = PLocalizer.CargoSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSAC:
             if quantity == 1:
                 textInfo = PLocalizer.LootSac % quantity
             else:
                 textInfo = PLocalizer.LootSacP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootChest % quantity
             else:
                 textInfo = PLocalizer.LootChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.CARGO_LOOTSKCHEST:
             if quantity == 1:
                 textInfo = PLocalizer.LootSkChest % quantity
             else:
                 textInfo = PLocalizer.LootSkChestP % quantity
             lootIcon = self.icons.get(itemType)[0]
             iconScale = 0.089999999999999997
         elif itemType == ItemId.QUEST_DROP_JEWEL:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.BROW:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_brow')
                 iconScale = (-0.14000000000000001, 0.14000000000000001, 0.14000000000000001)
             elif type == ItemGlobals.EAR:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_ears')
                 iconScale = (-0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.NOSE:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_nose')
                 iconScale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998)
             elif type == ItemGlobals.MOUTH:
                 lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_mouth')
                 iconScale = (0.32500000000000001, 0.32500000000000001, 0.32500000000000001)
             elif type == ItemGlobals.LHAND:
                 lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_hand')
                 iconScale = (0.125, 0.125, 0.125)
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_TATTOO:
             textInfo = None
             type = None
             lootIcon = None
             iconScale = 1.0
             type = ItemGlobals.getType(quantity)
             textInfo = PLocalizer.getItemName(quantity)
             if type == ItemGlobals.CHEST:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_chest_male')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.ARM:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_arm')
                 iconScale = 0.10000000000000001
             elif type == ItemGlobals.FACE:
                 lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_face_male')
                 iconScale = 0.10000000000000001
             else:
                 lootIcon = None
         elif itemType == ItemId.QUEST_DROP_WEAPON:
             weaponId = quantity
             iconScale = 0.10000000000000001
             textInfo = None
             lootIcon = None
             iconName = getItemIcons(weaponId)
             if iconName is not None:
                 lootIcon = LootPopupPanel.WeaponIcons.find('**/' + iconName)
                 textInfo = PLocalizer.InventoryTypeNames.get(weaponId)
             
         
         entry = DirectFrame(parent = self, relief = None, geom = lootIcon, geom_scale = iconScale, text = textInfo, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG0, text_pos = (0.070000000000000007, 0.01), text_font = PiratesGlobals.getInterfaceFont())
         entry.setTransparency(1)
         self.loot.append(entry)
     
     self.repackPanels()
 def loadGUI(self):
     shipcard = loader.loadModel('models/gui/ship_battle')
     self.nameBox = DirectFrame(parent = self, relief = None, pos = (0.058000000000000003, 0, -0.0064999999999999997), text = 'Ship Name', text_align = TextNode.ALeft, text_scale = 0.044999999999999998, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont())
     tex = shipcard.find('**/ship_battle_speed_bar*')
     self.hpFrame = DirectFrame(parent = self, pos = (0.46500000000000002, 0, 0.14000000000000001), relief = None, image = tex, image_scale = (0.29999999999999999, 1, 0.59999999999999998))
     self.hpMeter = DirectWaitBar(parent = self.hpFrame, relief = DGG.RAISED, range = 100, value = 100, borderWidth = (0.002, 0.002), frameColor = (0, 0, 0, 1), barColor = (0.10000000000000001, 0.69999999999999996, 0.10000000000000001, 1), frameSize = (-0.27000000000000002, 0.13100000000000001, -0.01, 0.01), pos = (0.069000000000000006, 0, 0.0), text = PLocalizer.Hull, text_scale = PiratesGuiGlobals.TextScaleLarge * 0.75, text_align = TextNode.ALeft, text_pos = (0.16, -0.012), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = (0, 0, 0, 1), text_font = PiratesGlobals.getInterfaceFont())
     self.hpMeterChange = DirectFrame(parent = self.hpFrame, relief = DGG.FLAT, borderWidth = (0.0040000000000000001, 0.0040000000000000001), frameColor = (1.0, 0.0, 0.0, 1.0), sortOrder = 0)
     self.hpMeterChange.setBin('gui-fixed', 0)
     self.hpMeterChange.hide()
     self.hpMeterDownIval = Sequence(Func(self.hpMeterChange.show), Wait(0.10000000000000001), LerpColorInterval(self.hpMeterChange, 0.5, color = VBase4(0.69999999999999996, 0.10000000000000001, 0.10000000000000001, 1.0), blendType = 'easeOut'), LerpColorInterval(self.hpMeterChange, 0.25, color = VBase4(0.0, 0.0, 0.0, 1.0), blendType = 'easeOut'), Func(self.hpMeterChange.hide))
     self.hpMeterUpGreenIval = Sequence(Func(self.hpMeterChange.show), Wait(0.10000000000000001), LerpColorInterval(self.hpMeterChange, 0.75, color = VBase4(0.10000000000000001, 0.69999999999999996, 0.10000000000000001, 1.0)), Func(self.hpMeterChange.hide))
     self.hpMeterUpRedIval = Sequence(Func(self.hpMeterChange.show), Wait(0.10000000000000001), LerpColorInterval(self.hpMeterChange, 0.75, color = VBase4(1.0, 0.0, 0.0, 1.0)), Func(self.hpMeterChange.hide))
     self.hpMeterUpYellowIval = Sequence(Func(self.hpMeterChange.show), Wait(0.10000000000000001), LerpColorInterval(self.hpMeterChange, 0.75, color = VBase4(1.0, 1.0, 0.10000000000000001, 1.0)), Func(self.hpMeterChange.hide))
     self.spFrame = DirectFrame(parent = self, pos = (0.45500000000000002, 0, 0.115), relief = None, image = tex, image_scale = (0.29999999999999999, 1, 0.52000000000000002))
     speedArrow = loader.loadModel('models/gui/toplevel_gui').find('**/generic_arrow')
     self.speedMeter = DirectWaitBar(parent = self.spFrame, relief = DGG.RAISED, range = 100, value = 100, borderWidth = (0.002, 0.002), frameColor = (0, 0, 0, 1), barColor = (0.69999999999999996, 0.69999999999999996, 0.10000000000000001, 1), frameSize = (-0.27000000000000002, 0.13200000000000001, -0.0080000000000000002, 0.0080000000000000002), pos = (0.069000000000000006, 0, 0.0), text = PLocalizer.Speed, text_scale = PiratesGuiGlobals.TextScaleLarge * 0.75, text_align = TextNode.ALeft, text_pos = (0.16, -0.0080000000000000002), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = (0, 0, 0, 1), text_font = PiratesGlobals.getInterfaceFont(), geom = speedArrow, geom_pos = (-0.25, 0, -0.01), geom_hpr = (0, 0, 90), geom_scale = (0.40000000000000002, 0.40000000000000002, 0.25))
     self.knotSpeed = DirectFrame(parent = self.spFrame, relief = None, state = DGG.DISABLED, pos = (-0.095000000000000001, 0, -0.055), text = PLocalizer.Knots % 0, text_align = TextNode.ACenter, text_scale = 0.040000000000000001, text_pos = (0.10000000000000001, -0.01), text_fg = PiratesGuiGlobals.TextFG1, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont())
     circlecard = loader.loadModel('models/textureCards/skillIcons')
     base1 = circlecard.find('**/base')
     base2 = circlecard.find('**/base_over')
     base3 = circlecard.find('**/base_down')
     self.cargoMeter = GuiButton.GuiButton(parent = self, frameSize = (-0.045312499999999999, 0.045312499999999999, -0.045312499999999999, 0.045312499999999999), pos = (0.33000000000000002, 0, 0.20999999999999999), helpText = PLocalizer.CargoIconHelp, helpPos = (0.053999999999999999, 0, -0.10000000000000001), helpOpaque = 1, command = self.toggleCargo, image = (base1, base3, base2), image_scale = 0.10000000000000001, scale = 0.90000000000000002, relief = None)
     tex = loader.loadModel('models/gui/toplevel_gui').find('**/icon_crate')
     self.cargoLabel = DirectLabel(parent = self.cargoMeter, relief = None, state = DGG.DISABLED, image = tex, image_scale = 0.050000000000000003, image_color = (1, 1, 1, 0.80000000000000004), text = '0/0', text_scale = 0.044999999999999998, text_align = TextNode.ACenter, text_pos = (0.0044999999999999997, -0.025000000000000001), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = (0, 0, 0, 1), text_font = PiratesGlobals.getInterfaceFont())
     self.crewMeter = GuiButton.GuiButton(parent = self, relief = None, frameSize = (-0.045312499999999999, 0.045312499999999999, -0.045312499999999999, 0.045312499999999999), pos = (0.46000000000000002, 0, 0.20999999999999999), helpText = PLocalizer.CrewIconHelp, helpPos = (-0.050000000000000003, 0, -0.10000000000000001), helpOpaque = 1, image = base1, image_scale = 0.10000000000000001, scale = 0.90000000000000002)
     icons = loader.loadModel('models/textureCards/icons')
     tex = icons.find('**/icon_stickman')
     self.crewLabel = DirectLabel(parent = self.crewMeter, relief = None, state = DGG.DISABLED, image = tex, image_scale = 0.080000000000000002, image_color = (1, 1, 1, 0.80000000000000004), text = '0/0', text_scale = 0.044999999999999998, text_align = TextNode.ACenter, text_pos = (0.0044999999999999997, -0.025000000000000001), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = (0, 0, 0, 1), text_font = PiratesGlobals.getInterfaceFont())
     self.crewLabel.setTransparency(1, 1)
     gui = loader.loadModel('models/gui/avatar_chooser_rope')
     self.openPortLabel = DirectLabel(parent = base.a2dTopRight, relief = None, image = gui.find('**/avatar_c_A_middle'), image_scale = 0.29999999999999999, pos = (-0.23000000000000001, 0, -0.5), state = DGG.DISABLED, text = '', text_scale = 0.040000000000000001, text_align = TextNode.ACenter, text_pos = (0.0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), text_font = PiratesGlobals.getPirateBoldOutlineFont())
     self.openPortLabel.hide()
     self.setupPermissionUI()
     self.statusEffectsPanel = StatusEffectsPanel.StatusEffectsPanel(parent = self, pos = (0.29999999999999999, 0, 0.29999999999999999))
     self.statusEffectsPanel.iconScale = 0.65000000000000002
     self.armorGui = ShipArmorGui(self, pos = (0.14999999999999999, 0.14999999999999999, 0.14999999999999999))
     self.threatFrame = DirectFrame(parent = self, pos = (0.14999999999999999, 0, 0.155), relief = None, image = None, image_scale = 0.13500000000000001)
     self.accept('LocalAvatar_Ship_ThreatLevel_Update', self.setThreatLevel)
     self.accept('LocalAvatar_Ship_OpenPort_Update', self.setOpenPort)
     self.accept('settingLocalShip', self.handleLocalShipSet)
     self.accept('settingLocalShipId', self.handleLocalShipSet)
     self.handleLocalShipSet(quiet = 1)
Esempio n. 53
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.035000000000000003, 0, 0.025000000000000001))
     self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ARight, text_wordwrap = 11, pos = (0.1225, 0, 0.014999999999999999))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     elif len(self.name) >= 35:
         textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
     else:
         textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_fg = PiratesGuiGlobals.TextFG2, text_scale = textScale, text_align = TextNode.ALeft, pos = (0.13, 0, 0.014999999999999999))
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.0050000000000000001, 0, 0.012500000000000001), text = str(self.price), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.014999999999999999), text_font = PiratesGlobals.getInterfaceFont())
     itemClass = EconomyGlobals.getItemCategory(itemId)
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.059999999999999998
                     self.picture['geom_pos'] = (0, 0, 0)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     self.flattenStrong()
Esempio n. 54
0
 def __init__(self, w = 9.0, h = 6.0, trial = False, lock = True):
     self.width = w
     self.height = h
     self.imageFocus = 0
     self.hasEmbedded = hasEmbedded
     self.trial = trial
     if not self.trial:
         self.questIdReporting = 'None_Provided'
     
     self._TrialNonPayerPanel__fader = None
     DirectFrame.__init__(self, relief = DGG.RIDGE, state = DGG.NORMAL, frameColor = Vec4(0.0, 0.0, 0.0, 0.69999999999999996), borderWidth = PiratesGuiGlobals.BorderWidth, frameSize = (0, self.width, 0, self.height), pos = (-4.5, 0, -3.0), sortOrder = 999)
     self.initialiseoptions(TrialNonPayerPanel)
     if not self.trial:
         gui2 = loader.loadModel('models/gui/gui_main').find('**/velvetrope_top')
         geom = gui2.find('**/background')
         self.imageOne = DirectFrame(parent = self, relief = None, image = geom, image_scale = (1, 1, 0.94999999999999996), scale = 0.40000000000000002, pos = (4.4500000000000002, 0, 3.1000000000000001))
         geom = gui2.find('**/frame')
         geom.getChild(0).stash()
         self.imageTwo = DirectFrame(parent = self.imageOne, relief = None, image = geom, scale = 1.0, pos = (0, 0, 0))
         self.titleText = DirectLabel(parent = self.imageOne, relief = None, text = PLocalizer.VR_FeaturePopTitle, text_align = TextNode.ACenter, text_scale = 0.20000000000000001, text_fg = PiratesGuiGlobals.TextFG16, text_font = PiratesGlobals.getPirateFont(), text_shadow = PiratesGuiGlobals.TextShadow, pos = (0, 0, 0.20000000000000001))
         self.fullText = DirectLabel(parent = self.imageOne, relief = None, text = PLocalizer.VR_FeaturePopLongText, text_align = TextNode.ACenter, text_scale = 0.10000000000000001, text_fg = PiratesGuiGlobals.TextFG16, text_font = PiratesGlobals.getInterfaceFont(), pos = (0, 0, -0.10000000000000001))
         upgrade_button = gui2.find('**/upgrade_button')
         norm_geom = upgrade_button.find('**/normal')
         over_geom = upgrade_button.find('**/over')
         down_geom = upgrade_button.find('**/down')
         self.upgradeButton = DirectButton(parent = self.imageOne, relief = None, geom = (norm_geom, down_geom, over_geom), pos = (0, 0, 0.050000000000000003), scale = 1, command = self.upgradeNow, text = PLocalizer.VR_FirstAddUpgrade, text_fg = PiratesGuiGlobals.TextFG1, text_font = PiratesGlobals.getInterfaceFont(), text_shadow = PiratesGuiGlobals.TextShadow, text_scale = 0.089999999999999997, text_pos = (0, -0.64000000000000001))
         norm_geom.getChild(0).stash()
         over_geom.getChild(0).stash()
         down_geom.getChild(0).stash()
         self.passButton = DirectButton(parent = self.imageOne, relief = None, geom = (norm_geom, down_geom, over_geom), scale = (0.80000000000000004, 1, 0.10000000000000001), text = PLocalizer.VR_FirstAddBasic, text_fg = PiratesGuiGlobals.TextFG15, text_font = PiratesGlobals.getInterfaceFont(), text_scale = (0.125, 0.80000000000000004), text_pos = (0, -0.45000000000000001), pos = (0, 0, -0.75), command = self.dismissNow)
         basegeom = gui2.find('**/close_button')
         norm_geom = basegeom.find('**/normal')
         over_geom = basegeom.find('**/over')
         down_geom = basegeom.find('**/down')
         self.dismissButton = DirectButton(parent = self, relief = None, geom = (norm_geom, down_geom, over_geom), scale = 0.40000000000000002, pos = (4.4500000000000002, 0, 3.1000000000000001), command = self.dismissNow)
     else:
         gui2 = loader.loadModel('models/textureCards/basic_unlimited')
         self.imageOne = DirectFrame(parent = self, relief = None, image = gui2.find('**/but_message_panel_border'), image_scale = (1, 1, 0.94999999999999996), scale = 0.80000000000000004, pos = (4.5, 0, 3.0))
         self.imageTwo = DirectFrame(parent = self.imageOne, relief = None, image = gui2.find('**/but_compass'), scale = 1.0, pos = (-0.48999999999999999, 0, 0.22))
         self.titleText = DirectLabel(parent = self.imageOne, relief = None, text = PLocalizer.FirstAddTitle, text_align = TextNode.ALeft, text_scale = 0.10000000000000001, text_wordwrap = 10, text_fg = PiratesGuiGlobals.TextFG1, text_font = PiratesGlobals.getPirateFont(), text_shadow = PiratesGuiGlobals.TextShadow, text_pos = (0, -0.050000000000000003), pos = (-0.26000000000000001, 0, 0.28999999999999998))
         self.fullText = DirectLabel(parent = self.imageOne, relief = None, text = PLocalizer.FirstAddDisplay, text_align = TextNode.ALeft, text_scale = 0.059999999999999998, text_wordwrap = 21, text_fg = PiratesGuiGlobals.TextFG1, text_font = PiratesGlobals.getInterfaceFont(), pos = (-0.65000000000000002, 0, -0.059999999999999998))
         norm_geom = gui2.find('**/but_nav')
         over_geom = gui2.find('**/but_nav_over')
         down_geom = gui2.find('**/but_nav_down')
         dsbl_geom = gui2.find('**/but_nav_disabled')
         self.upgradeButton = DirectButton(parent = self.imageOne, relief = None, geom = (norm_geom, down_geom, over_geom), pos = (0.28000000000000003, 0, -0.37), scale = 0.80000000000000004, command = self.upgradeNow, text = PLocalizer.FirstAddUpgrade, text_fg = PiratesGuiGlobals.TextFG1, text_font = PiratesGlobals.getInterfaceFont(), text_shadow = PiratesGuiGlobals.TextShadow, text_scale = 0.050000000000000003, text_wordwrap = 9, text_pos = (0, -0.01))
         self.dismissButton = DirectButton(parent = self.imageOne, relief = None, geom = (norm_geom, down_geom, over_geom), scale = 0.80000000000000004, text = PLocalizer.FirstAddBasic, text_fg = PiratesGuiGlobals.TextFG1, text_font = PiratesGlobals.getInterfaceFont(), text_shadow = PiratesGuiGlobals.TextShadow, text_scale = 0.050000000000000003, text_pos = (0, -0.01), pos = (-0.28000000000000003, 0, -0.37), text_wordwrap = 9, command = self.dismissNow)
     self.setBin('gui-popup', 0)
Esempio n. 55
0
 def __init__(self, chatManager, whiteListEntry):
     optiondefs = (('relief', None, None), ('state', DGG.NORMAL,
                                            self.setState),
                   ('frameSize', (0, 0.9, 0, 0.6),
                    None), ('frameColor', (1, 0, 1, 0.2), None))
     self.defineoptions({}, optiondefs)
     DirectFrame.__init__(self, parent=NodePath())
     self.initialiseoptions(ChatPanel)
     FSM.__init__(self, 'ChatPanel')
     base.chatPanel = self
     self.chatManager = chatManager
     self.index = 0
     self.runningLineCount = 0
     self.runningLineCountLastId = -1
     self.lineCountList = [0]
     self.wrappedText = []
     self.chatFont = PiratesGlobals.getInterfaceFont()
     self.nameFont = PiratesGlobals.getInterfaceFont()
     self.shadowOffset = (0.09, 0.09)
     self.shadowColor = (0.0, 0.0, 0.0, 1.0)
     self.fontColorStyle = 1
     if base.config.GetBool('want-random-chatStyle', 0):
         self.chatFont = random.choice([
             PiratesGlobals.getInterfaceFont(),
             PiratesGlobals.getInterfaceOutlineFont()
         ])
         self.nameFont = random.choice([
             PiratesGlobals.getInterfaceFont(),
             PiratesGlobals.getInterfaceOutlineFont()
         ])
         self.shadowOffset = random.choice([(0.09, 0.09), (0.0, 0.0)])
         self.fontColorStyle = random.choice([0, 1, 2])
     self.lineDict = {}
     self.renderedLineDict = {}
     self.renderedLines = []
     self.wordWrapper = TextNode('wrapper')
     self.wordWrapper.setFont(self.chatFont)
     self.wordWrapper.setWordwrap(self.WrapWidth)
     self.wordWrapper.setTabWidth(1.0)
     self.fadeIval = None
     self.fadeTextIval = None
     self.preferredMode = 'Short'
     self.linesShown = True
     self.holdLinesShown = None
     self.wantSmallFont = 0
     self.currentFontSize = self.TextScale
     self.currentWordWrap = self.WrapWidth
     self.resizeDelayTaskName = 'ChatPanel_Resize'
     self.sCloseButton = None
     self.tCloseButton = None
     self.minButton = None
     self.maxButton = None
     self.setupGui()
     self.chatBar = ChatBar(parent=self,
                            chatMgr=chatManager,
                            whiteListEntry=whiteListEntry)
     self.setBoxWidth(base.options.chatbox_scale)
     self.checkEmotes()
     self.needSlider = 0
     self.reparentTo(base.a2dBottomLeft)
     self.accept('NewOpenMessage', self.__handleOpenMessage)
     self.accept('SetChatBoxWidth', self.setBoxWidth)
     self.accept('SetChatBoxStyle', self.setChatStyle)
     self.accept('GUIHidden', self.__handleGlobalGuiHide)
     self.accept('GUIShown', self.__handleGlobalGuiShow)
     return
Esempio n. 56
0
 def createGui(self):
     ShipFrame.createGui(self)
     if self['shipName']:
         self.nameLabel = DirectLabel(parent = self, relief = DGG.FLAT, state = DGG.DISABLED, text = self['shipName'], text_font = PiratesGlobals.getInterfaceFont(), text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleMed, text_pos = (0.040000000000000001, 0.014999999999999999), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, frameColor = PiratesGuiGlobals.ButtonColor1[3], frameSize = (self['frameSize'][0] + 0.02, self['frameSize'][1] - 0.02, 0, 0.050000000000000003), pos = (0, 0, self['frameSize'][3] - 0.059999999999999998))
     
     if self['shipClass']:
         self.classLabel = DirectLabel(parent = self.nameLabel, relief = None, state = DGG.DISABLED, text = PLocalizer.ShipClassNames.get(self['shipClass']), text_scale = PiratesGuiGlobals.TextScaleMed, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = (0, 0, 0, 1), text_wordwrap = 15, textMayChange = 0, text_pos = (self.nameLabel['frameSize'][1] - 0.02, 0.014999999999999999), text_font = PiratesGlobals.getInterfaceFont())
 def __init__(self):
     InventoryPage.InventoryPage.__init__(self)
     self.initialiseoptions(TitlesPage)
     self.titles = []
     self.selectedLandIndex = -1
     self.selectedSeaIndex = -1
     self.landButtons = []
     self.seaButtons = []
     self.forceInitLand = -1
     self.forceInitSea = -1
     self.loaded = 0
     self.opened = 0
     gui = loader.loadModel('models/gui/gui_main')
     scale = 0.33500000000000002
     self.background = self.attachNewNode('background')
     self.background.setScale(scale)
     self.background.setPos(0.53000000000000003, 0, 0.73999999999999999)
     gui.find('**/gui_inv_red_general1').copyTo(self.background)
     PiratesGlobals.flattenOrdered(self.background)
     self.displayTitleFrame = DirectFrame(parent = self, relief = None, pos = (0.55000000000000004, 0, 1.175), text = PLocalizer.DisplayTitle, text_align = TextNode.ALeft, text_scale = 0.044999999999999998, text_pos = (-0.45000000000000001, 0.050000000000000003), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 20, text_shadow = (0, 0, 0, 1), textMayChange = 1, text_font = PiratesGlobals.getInterfaceFont())
     self.displayTitleLandFrame = BorderFrame.BorderFrame(parent = self, relief = None, pos = (0.81000000000000005, 0, 1.02), frameSize = (-0.050000000000000003, 0.050000000000000003, -0.26000000000000001, -0.080000000000000002), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75), text = PLocalizer.DisplayTitleLand, text_align = TextNode.ACenter, text_scale = 0.032000000000000001, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
     self.displayTitleSeaFrame = BorderFrame.BorderFrame(parent = self, relief = None, pos = (0.96999999999999997, 0, 1.02), frameSize = (-0.050000000000000003, 0.050000000000000003, -0.26000000000000001, -0.080000000000000002), modelName = 'pir_m_gui_frm_subframe', imageColorScale = VBase4(0.75, 0.75, 0.90000000000000002, 0.75), text = PLocalizer.DisplayTitleSea, text_align = TextNode.ACenter, text_scale = 0.032000000000000001, text_pos = (0, -0.01), text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 0, text_font = PiratesGlobals.getInterfaceFont())
     self.dummyFrame = DirectFrame(parent = self, relief = None, pos = (0.10000000000000001, 0, 0.89000000000000001))
     self.accept('LocalAvatarInfamyUpdated', self.refresh)
     self.accept('landBadgeSet', self.updateLandBadge)
     self.accept('seaBadgeSet', self.updateSeaBadge)
Esempio n. 58
0
    def __init__(self, shipPage, shipId, **kwargs):
        self.shipPage = shipPage
        self.emptyBottle = True
        self.setShipId(shipId)
        self.timer = None
        self.lBroadsideLimit = 0
        self.rBroadsideLimit = 0
        kwargs.setdefault("relief", None)
        kwargs.setdefault("frameSize", (0, self.Width, 0, self.Height))
        DirectFrame.__init__(self, **None)
        self.initialiseoptions(ShipPanel)
        gui = loader.loadModel("models/gui/toplevel_gui")
        inventoryGui = loader.loadModel("models/gui/gui_icons_inventory")
        chestIcon = inventoryGui.find("**/pir_t_ico_trs_chest_01*")
        cannonIcon = gui.find("**/topgui_icon_ship_cannon_single")
        skillIcons = loader.loadModel("models/textureCards/skillIcons")
        broadsideId = InventoryType.CannonRoundShot
        ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
        broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
        crewIcon = (gui.find("**/pir_t_gui_gen_friends_pirates"),)
        self.bottleFrame = ShipFrameBottle(
            parent=self,
            shipId=shipId,
            relief=None,
            state=DGG.DISABLED,
            pos=(0.074999999999999997, 0, 0.75),
            scale=0.83499999999999996,
        )
        gui = loader.loadModel("models/gui/gui_ship_window")
        bottleImage = gui.find("**/ship_bottle")
        self.shipBottle = DirectLabel(
            parent=self.bottleFrame,
            relief=None,
            state=DGG.DISABLED,
            geom=bottleImage,
            geom_scale=0.29999999999999999,
            geom_pos=(0, 0, 0),
            pos=(0.5, 0, -0.0),
        )
        self.nameLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottle, 2),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_scale=PiratesGuiGlobals.TextScaleTitleSmall,
            text_align=TextNode.ACenter,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getPirateFont(),
            pos=(0.55000000000000004, 0, 1.22),
        )
        self.classLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottleDesc, 1),
            text_scale=PiratesGuiGlobals.TextScaleMed,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.55000000000000004, 0, 1.1799999999999999),
        )
        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.setPos(0.45000000000000001, 0, 0.93999999999999995)
        self.timer.setScale(0.59999999999999998)
        self.timer.stash()
        self.hpMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.10000000000000001, 0.69999999999999996, 0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text="",
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.45000000000000001),
            scale=1.2,
        )
        hpLabel = DirectLabel(
            parent=self.hpMeter,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.HP,
            text_scale=0.029999999999999999,
            text_align=TextNode.ALeft,
            text_pos=(0.014999999999999999, 0.029999999999999999),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.speedMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.69999999999999996, 0.69999999999999996, 0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text="",
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.34999999999999998),
            scale=1.2,
        )
        speedLabel = DirectLabel(
            parent=self.speedMeter,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Sails,
            text_scale=0.029999999999999999,
            text_align=TextNode.ALeft,
            text_pos=(0.014999999999999999, 0.029999999999999999),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.customHullLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.34999999999999998, 0, 0.68000000000000005),
        )
        self.customHullLabel.hide()
        self.customRiggingLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.75, 0, 0.68000000000000005),
        )
        self.customRiggingLabel.hide()
        textPos = (0.0, -0.16)
        self.plunderLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.10000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.20000000000000001, 0, 0.20000000000000001),
        )
        plunderLabel = DirectLabel(
            parent=self.plunderLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Cargo,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0, 0.040000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.cannonLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=cannonIcon,
            geom_scale=0.45000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.37, 0, 0.20000000000000001),
        )
        cannonLabel = DirectLabel(
            parent=self.cannonLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Cannon,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0, 0.040000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.cannonLabel = cannonLabel
        self.broadsideLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=broadsideIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, -0.050000000000000003),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.81000000000000005, 0, 0.20000000000000001),
        )
        broadsideLabel = DirectLabel(
            parent=self.broadsideLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Broadsides,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.0, 0.040000000000000001),
        )
        self.broadsideLabel = broadsideLabel
        self.crewLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=crewIcon,
            geom_scale=0.40000000000000002,
            geom_pos=(0, 0, 0.10000000000000001),
            text="",
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.56000000000000005, 0, 0.040000000000000001),
        )
        crewLabel = DirectLabel(
            parent=self.crewLimit,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.Crew,
            text_scale=0.035999999999999997,
            text_align=TextNode.ACenter,
            text_pos=(0.0, 0.20000000000000001),
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
        )
        self.crewLabel = crewLabel
        shipOV = base.cr.getOwnerView(self.shipId)
        if shipOV:
            self.setShipName(shipOV.name)
            self.setShipClass(shipOV.shipClass)
            self.setShipHp(shipOV.Hp, shipOV.maxHp)
            self.setShipSp(shipOV.Sp, shipOV.maxSp)
            self.setShipCrew(shipOV.crew, shipOV.maxCrew)
            self.setShipCargo([], shipOV.maxCargo)
            if hasattr(shipOV, "cannonConfig"):
                self.setShipMaxCannons(shipOV.cannonConfig)
                self.setShipMaxBroadside(shipOV.lBroadsideConfig, shipOV.rBroadsideConfig)

            self.updateIcons()

        if self.emptyBottle:
            self.hpMeter.hide()
            self.speedMeter.hide()
            self.plunderLimit.hide()
            self.cannonLimit.hide()
            self.broadsideLimit.hide()
            self.crewLimit.hide()

        self.accept("setName-%s" % self.shipId, self.setShipName)
        self.accept("setShipClass-%s" % self.shipId, self.setShipClass)
        self.accept("setShipHp-%s" % self.shipId, self.setShipHp)
        self.accept("setShipSp-%s" % self.shipId, self.setShipSp)
        self.accept("setShipCargo-%s" % self.shipId, self.setShipCargo)
        self.accept("setShipCrew-%s" % self.shipId, self.setShipCrew)
        self.accept("setShipTimer-%s" % self.shipId, self.setShipTimer)
        self.accept("setHullCannonConfig-%s" % self.shipId, self.setShipMaxCannons)
        self.accept("setHullLeftBroadsideConfig-%s" % self.shipId, self.setShipMaxLeftBroadside)
        self.accept("setHullRightBroadsideConfig-%s" % self.shipId, self.setShipMaxRightBroadside)
        self.accept("ShipChanged-%s" % self.shipId, self.handleShipChanged)
        if base.config.GetBool("want-deploy-button", 0):
            pass
        1