Exemple #1
0
    def __init__(self, gameObject=None):
        base.loadingScreen.beginStep('GameGUI', 3, 20)
        self.gameObject = gameObject
        gui = loader.loadModel('models/gui/toplevel_gui')
        guiIcons = loader.loadModel('models/textureCards/icons')
        weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
        fishingIcons = loader.loadModel('models/textureCards/fishing_icons')
        self.tackleBoxButton = DirectButton(
            parent=base.a2dBottomRight,
            relief=None,
            pos=(-0.53000000000000003, 0.0, 0.10000000000000001),
            scale=0.5,
            text=PLocalizer.FishingGui['Lures'],
            text_pos=(0, -0.14999999999999999),
            text_scale=0.065000000000000002,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'),
                  fishingIcons.find('**/pir_t_gui_fsh_tackleBasket'),
                  fishingIcons.find('**/pir_t_gui_fsh_tackleBasket_over')),
            geom_pos=(0, 0, 0),
            geom_scale=0.25,
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.toggleLureSelectionDialog)
        self.tackleBoxInterval = Sequence(
            self.tackleBoxButton.colorScaleInterval(
                0.5, Vec4(1.0, 0.59999999999999998, 0.59999999999999998, 1.0)),
            self.tackleBoxButton.colorScaleInterval(0.5,
                                                    Vec4(1.0, 1.0, 1.0, 1.0)))
        self.exitButton = DirectButton(
            parent=base.a2dBottomRight,
            relief=None,
            pos=(-0.29999999999999999, 0.0, 0.10000000000000001),
            scale=0.5,
            text=PLocalizer.FishingGui['ExitButton'],
            text_pos=(0, -0.14999999999999999),
            text_scale=0.065000000000000002,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(fishingIcons.find('**/pir_t_gui_fsh_esc'),
                  fishingIcons.find('**/pir_t_gui_fsh_esc'),
                  fishingIcons.find('**/pir_t_gui_fsh_esc_over')),
            geom_pos=(0, 0, 0),
            geom_scale=0.25,
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.handleExitGame)
        self.OkDialog = None
        base.loadingScreen.tick()
        dialogText = PLocalizer.FishingGui['ChooseYourLure']
        self.lureSelectionPanel = GuiPanel.GuiPanel(dialogText, 0.75, 0.5,
                                                    True, 1)
        self.lureSelectionPanel.reparentTo(base.a2dBottomRight)
        self.lureSelectionPanel.setPos(-0.90000000000000002, 0.0, 0.22)
        self.lureSelectionPanel.regularLureButton = DirectButton(
            parent=self.lureSelectionPanel,
            relief=None,
            pos=(0.20000000000000001, 0, 0.25),
            scale=0.5,
            text='',
            text_pos=(0, 0),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image=fishingIcons.find('**/pir_t_gui_fsh_lureReg'),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle_over')),
            geom_pos=(0, 0, 0),
            geom_scale=1,
            geom_hpr=(0, 0, 90),
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.chooseRegularLure)
        self.lureSelectionPanel.regularLureButtonText = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text=PLocalizer.FishingGui['RegularLures'],
            text_align=TextNode.ARight,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.28000000000000003, 0.14999999999999999),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        base.loadingScreen.tick()
        inv = localAvatar.getInventory()
        regQty = inv.getStackQuantity(InventoryType.RegularLure)
        self.lureSelectionPanel.regularLureQty = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text='x' + str(regQty),
            text_align=TextNode.ACenter,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.29999999999999999, 0.20000000000000001),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        self.lureSelectionPanel.legendaryLureButton = DirectButton(
            parent=self.lureSelectionPanel,
            relief=None,
            pos=(0.55000000000000004, 0.0, 0.25),
            scale=0.5,
            text='',
            text_pos=(0, 0),
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            image=fishingIcons.find('**/pir_t_gui_fsh_lureLegend'),
            image_pos=(0, 0, 0),
            image_scale=0.17999999999999999,
            geom=(gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle'),
                  gui.find('**/pir_t_gui_but_circle_over')),
            geom_pos=(0, 0, 0),
            geom_scale=1,
            geom_hpr=(0, 0, 90),
            geom_color=(1.0, 1.0, 1.0, 1),
            sortOrder=2,
            command=self.chooseLegendaryLure)
        self.lureSelectionPanel.legendaryLureButtonText = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text=PLocalizer.FishingGui['LegendaryLures'],
            text_align=TextNode.ARight,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.65000000000000002, 0.14999999999999999),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        inv = localAvatar.getInventory()
        legQty = inv.getStackQuantity(InventoryType.LegendaryLure)
        self.lureSelectionPanel.legendaryLureQty = DirectLabel(
            parent=self.lureSelectionPanel,
            relief=None,
            text='x' + str(legQty),
            text_align=TextNode.ACenter,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_pos=(0.66000000000000003, 0.20000000000000001),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_font=PiratesGlobals.getPirateBoldOutlineFont(),
            textMayChange=1)
        self.lureSelectionPanel.hide()
        self.lureSelectionPanelShowing = False
        self.resultsScreen = FishingResults(self.gameObject)
        self.resultsScreen.hide()
        bestRod = self.gameObject.getAvatarsBestRod()
        if bestRod == -1:
            base.notify.error(
                'Somehow the avatar got into the fishing game without a rod in their inventory!'
            )

        if bestRod == ItemGlobals.FISHING_ROD_3:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarExpert')
        elif bestRod == ItemGlobals.FISHING_ROD_2:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarNovice')
        else:
            self.castPowerMeterModel = loader.loadModel(
                'models/gui/pir_m_gui_fsh_fishingBarBeginner')
        base.loadingScreen.tick()
        self.castPowerMeter = NodePath('castPowerMeter')
        self.castPowerMeter.reparentTo(base.a2dLeftCenter)
        self.castMeterBackground = self.castPowerMeterModel.find(
            '**/background')
        self.castMeterBackground.setBin('fixed', 32)
        self.castMeterBackground.reparentTo(self.castPowerMeter)
        self.castMeterBar = self.castPowerMeterModel.find('**/meter')
        self.castMeterBar.setBin('fixed', 33)
        self.castMeterBar.reparentTo(self.castPowerMeter)
        self.castMeterBar.setColorScale(0.5, 0.5, 1.0, 1.0)
        self.castMeterFrame = self.castPowerMeterModel.find('**/bar')
        self.castMeterFrame.setBin('fixed', 34)
        self.castMeterFrame.reparentTo(self.castPowerMeter)
        self.castPowerMeter.setPos(0.13700000000000001, 0, 0.22800000000000001)
        self.castPowerMeter.setScale(1)
        self.lineHealthMeter = NodePath('lineHealthMeter')
        self.lineHealthMeter.reparentTo(base.a2dLeftCenter)
        self.lineHealthMeterModel = loader.loadModel(
            'models/gui/pir_m_gui_fsh_fishingBarHealth')
        self.lineHealthMeterBackground = self.lineHealthMeterModel.find(
            '**/background')
        self.lineHealthMeterBackground.setBin('fixed', 32)
        self.lineHealthMeterBackground.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterBar = self.lineHealthMeterModel.find('**/meter')
        self.lineHealthMeterBar.setBin('fixed', 33)
        self.lineHealthMeterBar.reparentTo(self.lineHealthMeter)
        self.lineHealthMeterFrame = self.lineHealthMeterModel.find('**/bar')
        self.lineHealthMeterFrame.setBin('fixed', 34)
        self.lineHealthMeterFrame.reparentTo(self.lineHealthMeter)
        self.lineHealthMeter.setPos(0.13700000000000001, 0, 0.25)
        self.lineHealthMeter.setScale(1)
        self.lineLengthLabel = TextPrinter()
        self.lineLengthLabel.text.setScale(1.2)
        self.lineLengthLabel.text.setHpr(0.0, 0.0, 0.0)
        self.lineLengthLabel.text['sortOrder'] = 200
        self.lineLengthLabel.text.setBin('gui-fixed', 10)
        self.lineLengthLabel.text.setDepthTest(0)
        self.lineLengthLabel.text.setDepthWrite(0)
        self.lineLengthLabel.showText('0', (1, 1, 1, 1))
        base.loadingScreen.endStep('GameGUI')