def load(self):
        self.displaySettings = None
        self.displaySettingsChanged = 0
        self.displaySettingsSize = (None, None)
        self.displaySettingsFullscreen = None
        self.displaySettingsApi = None
        self.displaySettingsApiChanged = 0
        self.speed_chat_scale = 0.055
        buttonbase_ycoord = 0.45
        textRowHeight = 0.145
        textStartHeight = 0.45
        self.Music_Label = OptionLabel(parent=self)
        self.SoundFX_Label = OptionLabel(parent=self,
                                         z=textStartHeight - textRowHeight)
        self.Friends_Label = OptionLabel(parent=self,
                                         z=textStartHeight - 3 * textRowHeight)
        self.Whispers_Label = OptionLabel(parent=self,
                                          z=textStartHeight -
                                          4 * textRowHeight)
        self.DisplaySettings_Label = OptionLabel(parent=self,
                                                 text_wordwrap=10,
                                                 z=textStartHeight -
                                                 5 * textRowHeight)
        self.SpeedChatStyle_Label = OptionLabel(
            parent=self,
            text=TTLocalizer.OptionsPageSpeedChatStyleLabel,
            text_wordwrap=10,
            z=textStartHeight - 6 * textRowHeight)
        self.ToonChatSounds_Label = OptionLabel(parent=self,
                                                z=textStartHeight -
                                                2 * textRowHeight + 0.025)
        self.ToonChatSounds_Label.setScale(0.9)
        self.Music_toggleButton = OptionButton(parent=self,
                                               command=self.__doToggleMusic)
        self.SoundFX_toggleButton = OptionButton(parent=self,
                                                 z=buttonbase_ycoord -
                                                 textRowHeight,
                                                 command=self.__doToggleSfx)
        self.Friends_toggleButton = OptionButton(
            parent=self,
            z=buttonbase_ycoord - textRowHeight * 3,
            command=self.__doToggleAcceptFriends)
        self.Whispers_toggleButton = OptionButton(
            parent=self,
            z=buttonbase_ycoord - textRowHeight * 4,
            command=self.__doToggleAcceptWhispers)
        self.DisplaySettingsButton = OptionButton(
            parent=self,
            image3_color=Vec4(0.5, 0.5, 0.5, 0.5),
            text=TTLocalizer.OptionsPageChange,
            z=buttonbase_ycoord - textRowHeight * 5,
            command=self.__doDisplaySettings)

        gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
        self.speedChatStyleLeftArrow = DirectButton(
            parent=self,
            relief=None,
            image=(gui.find('**/Horiz_Arrow_UP'),
                   gui.find('**/Horiz_Arrow_DN'),
                   gui.find('**/Horiz_Arrow_Rllvr'),
                   gui.find('**/Horiz_Arrow_UP')),
            image3_color=Vec4(1, 1, 1, 0.5),
            scale=(-1.0, 1.0, 1.0),
            pos=(0.25, 0, buttonbase_ycoord - textRowHeight * 6),
            command=self.__doSpeedChatStyleLeft)
        self.speedChatStyleRightArrow = DirectButton(
            parent=self,
            relief=None,
            image=(gui.find('**/Horiz_Arrow_UP'),
                   gui.find('**/Horiz_Arrow_DN'),
                   gui.find('**/Horiz_Arrow_Rllvr'),
                   gui.find('**/Horiz_Arrow_UP')),
            image3_color=Vec4(1, 1, 1, 0.5),
            pos=(0.65, 0, buttonbase_ycoord - textRowHeight * 6),
            command=self.__doSpeedChatStyleRight)
        self.ToonChatSounds_toggleButton = OptionButton(
            parent=self,
            image3_color=Vec4(0.5, 0.5, 0.5, 0.5),
            z=buttonbase_ycoord - textRowHeight * 2 + 0.025,
            command=self.__doToggleToonChatSounds)
        self.ToonChatSounds_toggleButton.setScale(0.8)
        self.speedChatStyleText = SpeedChat.SpeedChat(
            name='OptionsPageStyleText',
            structure=[2000],
            backgroundModelName='phase_3/models/gui/ChatPanel',
            guiModelName='phase_3.5/models/gui/speedChatGui')
        self.speedChatStyleText.setScale(self.speed_chat_scale)
        self.speedChatStyleText.setPos(
            0.37, 0, buttonbase_ycoord - textRowHeight * 6 + 0.03)
        self.speedChatStyleText.reparentTo(self, DGG.FOREGROUND_SORT_INDEX)
        self.exitButton = OptionButton(
            parent=self,
            image_scale=1.15,
            text=TTLocalizer.OptionsPageExitToontown,
            pos=(0.45, 0, -0.6),
            command=self.__handleExitShowWithConfirm)
        gui.removeNode()
    def __init__(self):
        self.dialog = TTDialog.TTGlobalDialog(
            dialogName="KeybindRemap",
            doneEvent="doneRemapping",
            style=TTDialog.TwoChoice,
            suppressKeys=True,
            suppressMouse=True,
        )
        scale = self.dialog.component("image0").getScale()
        scale.setX(((scale[0] * 5) / base.aspectRatio) * 1.2)
        scale.setZ(scale[2] * 2.25)
        self.dialog.component("image0").setScale(scale)
        button_x = -0.6
        button_y = 0.3
        labelPos = (0, 0, 0.1)

        self.upKey = OptionButton(
            parent=self.dialog,
            text=base.MOVE_UP,
            pos=(button_x, 0.0, button_y),
            command=self.enterWaitForKey,
            extraArgs=[self.UP],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[0],
        )

        self.leftKey = OptionButton(
            parent=self.dialog,
            text=base.MOVE_LEFT,
            pos=(button_x + 0.4, 0.0, button_y),
            command=self.enterWaitForKey,
            extraArgs=[self.LEFT],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[1],
        )

        self.downKey = OptionButton(
            parent=self.dialog,
            text=base.MOVE_DOWN,
            pos=(button_x + 0.8, 0.0, button_y),
            command=self.enterWaitForKey,
            extraArgs=[self.DOWN],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[2],
        )

        self.rightKey = OptionButton(
            parent=self.dialog,
            text=base.MOVE_RIGHT,
            pos=(button_x + 1.2, 0.0, button_y),
            command=self.enterWaitForKey,
            extraArgs=[self.RIGHT],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[3],
        )

        self.jumpKey = OptionButton(
            parent=self.dialog,
            text=base.JUMP,
            pos=(button_x, 0.0, button_y - 0.3),
            command=self.enterWaitForKey,
            extraArgs=[self.JUMP],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[4],
        )

        self.actionKey = OptionButton(
            parent=self.dialog,
            text=base.ACTION_BUTTON,
            pos=(button_x + 0.4, 0.0, button_y - 0.3),
            command=self.enterWaitForKey,
            extraArgs=[self.ACTION_BUTTON],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[5],
        )

        self.optionsKey = OptionButton(
            parent=self.dialog,
            text=OptionsPageHotkey,
            pos=(button_x + 0.8, 0.0, button_y - 0.3),
            command=self.enterWaitForKey,
            extraArgs=[self.OPTIONS_PAGE_HOTKEY],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[6],
        )

        self.chatHotkey = OptionButton(
            parent=self.dialog,
            text=base.CHAT_HOTKEY,
            pos=(button_x + 1.2, 0.0, button_y - 0.3),
            command=self.enterWaitForKey,
            extraArgs=[self.CHAT_HOTKEY],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[7],
        )

        self.screenshotKey = OptionButton(
            parent=self.dialog,
            text=base.SCREENSHOT_KEY,
            pos=(button_x, 0.0, button_y - 0.6),
            command=self.enterWaitForKey,
            extraArgs=[self.SCREENSHOT_KEY],
            wantLabel=True,
            labelOrientation="top",
            labelPos=labelPos,
            labelText=TTLocalizer.Controls[8],
        )

        self.controlsToBeSaved = {
            self.UP: base.MOVE_UP,
            self.LEFT: base.MOVE_LEFT,
            self.DOWN: base.MOVE_DOWN,
            self.RIGHT: base.MOVE_RIGHT,
            self.JUMP: base.JUMP,
            self.ACTION_BUTTON: base.ACTION_BUTTON,
            self.OPTIONS_PAGE_HOTKEY: OptionsPageHotkey,
            self.CHAT_HOTKEY: base.CHAT_HOTKEY,
            self.SCREENSHOT_KEY: base.SCREENSHOT_KEY,
        }

        self.popupDialog = None
        self.dialog.show()

        self.fsm = ClassicFSM.ClassicFSM(
            "ControlRemapDialog",
            [
                State.State("off", self.enterShow, self.exitShow, ["waitForKey"]),
                State.State(
                    "waitForKey", self.enterWaitForKey, self.exitWaitForKey, ["off"]
                ),
            ],
            "off",
            "off",
        )

        self.fsm.enterInitialState()
        self.dialog.accept("doneRemapping", self.exit)
        messenger.send("disable-hotkeys")
        try:
            base.localAvatar.chatMgr.disableBackgroundFocus()
        except:
            pass
Ejemplo n.º 3
0
    def __init__(self):
        self.dialog = TTDialog.TTGlobalDialog(dialogName='ControlRemap',
                                              doneEvent='doneRemapping',
                                              style=TTDialog.TwoChoice,
                                              text=RemapPrompt,
                                              text_wordwrap=24,
                                              text_pos=(0, 0, -0.8),
                                              suppressKeys=True,
                                              suppressMouse=True)
        scale = self.dialog.component('image0').getScale()
        scale.setX(((scale[0] * 2.5) / base.getAspectRatio()) * 1.2)
        scale.setZ(scale[2] * 2.5)
        self.dialog.component('image0').setScale(scale)
        button_x = -0.6
        button_y = 0.4
        labelPos = (0, 0, 0.1)

        self.upKey = OptionButton(parent=self.dialog,
                                  text=base.MOVE_UP,
                                  pos=(button_x, 0.0, button_y),
                                  command=self.enterWaitForKey,
                                  extraArgs=[self.UP],
                                  wantLabel=True,
                                  labelOrientation='top',
                                  labelPos=labelPos,
                                  labelText=Controls[0])

        self.leftKey = OptionButton(parent=self.dialog,
                                    text=base.MOVE_LEFT,
                                    pos=(button_x + 0.4, 0.0, button_y),
                                    command=self.enterWaitForKey,
                                    extraArgs=[self.LEFT],
                                    wantLabel=True,
                                    labelOrientation='top',
                                    labelPos=labelPos,
                                    labelText=Controls[1])

        self.downKey = OptionButton(parent=self.dialog,
                                    text=base.MOVE_DOWN,
                                    pos=(button_x + 0.8, 0.0, button_y),
                                    command=self.enterWaitForKey,
                                    extraArgs=[self.DOWN],
                                    wantLabel=True,
                                    labelOrientation='top',
                                    labelPos=labelPos,
                                    labelText=Controls[2])

        self.rightKey = OptionButton(parent=self.dialog,
                                     text=base.MOVE_RIGHT,
                                     pos=(button_x + 1.2, 0.0, button_y),
                                     command=self.enterWaitForKey,
                                     extraArgs=[self.RIGHT],
                                     wantLabel=True,
                                     labelOrientation='top',
                                     labelPos=labelPos,
                                     labelText=Controls[3])

        self.jumpKey = OptionButton(parent=self.dialog,
                                    text=base.JUMP,
                                    pos=(button_x, 0.0, button_y - 0.3),
                                    command=self.enterWaitForKey,
                                    extraArgs=[self.JUMP],
                                    wantLabel=True,
                                    labelOrientation='top',
                                    labelPos=labelPos,
                                    labelText=Controls[4])

        self.actionKey = OptionButton(parent=self.dialog,
                                      text=base.ACTION_BUTTON,
                                      pos=(button_x + 0.4, 0.0,
                                           button_y - 0.3),
                                      command=self.enterWaitForKey,
                                      extraArgs=[self.ACTION_BUTTON],
                                      wantLabel=True,
                                      labelOrientation='top',
                                      labelPos=labelPos,
                                      labelText=Controls[5])

        self.optionsKey = OptionButton(parent=self.dialog,
                                       text=OptionsPageHotkey,
                                       pos=(button_x + 0.8, 0.0,
                                            button_y - 0.3),
                                       command=self.enterWaitForKey,
                                       extraArgs=[self.OPTIONS_PAGE_HOTKEY],
                                       wantLabel=True,
                                       labelOrientation='top',
                                       labelPos=labelPos,
                                       labelText=Controls[6])
        self.chatHotkey = OptionButton(parent=self.dialog,
                                       text=base.CHAT_HOTKEY,
                                       pos=(button_x + 1.2, 0.0,
                                            button_y - 0.3),
                                       command=self.enterWaitForKey,
                                       extraArgs=[self.CHAT_HOTKEY],
                                       wantLabel=True,
                                       labelOrientation='top',
                                       labelPos=labelPos,
                                       labelText=Controls[7])

        self.controlsToBeSaved = {
            self.UP: base.MOVE_UP,
            self.LEFT: base.MOVE_LEFT,
            self.DOWN: base.MOVE_DOWN,
            self.RIGHT: base.MOVE_RIGHT,
            self.JUMP: base.JUMP,
            self.ACTION_BUTTON: base.ACTION_BUTTON,
            self.OPTIONS_PAGE_HOTKEY: OptionsPageHotkey,
            self.CHAT_HOTKEY: base.CHAT_HOTKEY
        }

        self.popupDialog = None
        self.dialog.show()

        self.fsm = ClassicFSM.ClassicFSM('ControlRemapDialog', [
            State.State('off', self.enterShow, self.exitShow, ['waitForKey']),
            State.State('waitForKey', self.enterWaitForKey,
                        self.exitWaitForKey, ['off']),
        ], 'off', 'off')
        self.fsm.enterInitialState()
        self.dialog.accept('doneRemapping', self.exit)
        messenger.send('disable-hotkeys')
        base.localAvatar.chatMgr.disableBackgroundFocus()