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
    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()
class OptionsTabPage(DirectFrame):
    notify = directNotify.newCategory('OptionsTabPage')
    DisplaySettingsTaskName = 'save-display-settings'
    DisplaySettingsDelay = 60
    ChangeDisplaySettings = base.config.GetBool('change-display-settings', 1)
    ChangeDisplayAPI = base.config.GetBool('change-display-api', 0)

    def __init__(self, parent=aspect2d):
        self.parent = parent
        self.currentSizeIndex = None

        DirectFrame.__init__(self,
                             parent=self.parent,
                             relief=None,
                             pos=(0.0, 0.0, 0.0),
                             scale=(1.0, 1.0, 1.0))

        self.load()

    def destroy(self):
        self.parent = None

        DirectFrame.destroy(self)

    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 enter(self):
        self.show()
        taskMgr.remove(self.DisplaySettingsTaskName)
        self.settingsChanged = 0
        self.__setMusicButton()
        self.__setSoundFXButton()
        self.__setAcceptFriendsButton()
        self.__setAcceptWhispersButton()
        self.__setDisplaySettings()
        self.__setToonChatSoundsButton()
        self.speedChatStyleText.enter()
        self.speedChatStyleIndex = base.localAvatar.getSpeedChatStyleIndex()
        self.updateSpeedChatStyle()
        if self.parent.book.safeMode:
            self.exitButton.hide()
        else:
            self.exitButton.show()

    def exit(self):
        self.ignore('confirmDone')
        self.hide()
        self.speedChatStyleText.exit()
        if self.displaySettingsChanged:
            taskMgr.doMethodLater(self.DisplaySettingsDelay,
                                  self.writeDisplaySettings,
                                  self.DisplaySettingsTaskName)

    def unload(self):
        self.writeDisplaySettings()
        taskMgr.remove(self.DisplaySettingsTaskName)
        if self.displaySettings is not None:
            self.ignore(self.displaySettings.doneEvent)
            self.displaySettings.unload()
        self.displaySettings = None
        self.exitButton.destroy()
        self.Music_toggleButton.destroy()
        self.SoundFX_toggleButton.destroy()
        self.Friends_toggleButton.destroy()
        self.Whispers_toggleButton.destroy()
        self.DisplaySettingsButton.destroy()
        self.speedChatStyleLeftArrow.destroy()
        self.speedChatStyleRightArrow.destroy()
        del self.exitButton
        del self.SoundFX_Label
        del self.Music_Label
        del self.Friends_Label
        del self.Whispers_Label
        del self.SpeedChatStyle_Label
        del self.SoundFX_toggleButton
        del self.Music_toggleButton
        del self.Friends_toggleButton
        del self.Whispers_toggleButton
        del self.speedChatStyleLeftArrow
        del self.speedChatStyleRightArrow
        self.speedChatStyleText.exit()
        self.speedChatStyleText.destroy()
        del self.speedChatStyleText
        self.currentSizeIndex = None

    def __doToggleMusic(self):
        messenger.send('wakeup')
        if base.musicActive:
            base.enableMusic(0)
            settings['music'] = False
        else:
            base.enableMusic(1)
            settings['music'] = True
        self.settingsChanged = 1
        self.__setMusicButton()

    def __setMusicButton(self):
        if base.musicActive:
            self.Music_Label['text'] = TTLocalizer.OptionsPageMusicOnLabel
            self.Music_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Music_Label['text'] = TTLocalizer.OptionsPageMusicOffLabel
            self.Music_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn

    def __doToggleSfx(self):
        messenger.send('wakeup')
        if base.sfxActive:
            base.enableSoundEffects(0)
            settings['sfx'] = False
        else:
            base.enableSoundEffects(1)
            settings['sfx'] = True
        self.settingsChanged = 1
        self.__setSoundFXButton()

    def __doToggleToonChatSounds(self):
        messenger.send('wakeup')
        if base.toonChatSounds:
            base.toonChatSounds = 0
            settings['toonChatSounds'] = False
        else:
            base.toonChatSounds = 1
            settings['toonChatSounds'] = True
        self.settingsChanged = 1
        self.__setToonChatSoundsButton()

    def __setSoundFXButton(self):
        if base.sfxActive:
            self.SoundFX_Label['text'] = TTLocalizer.OptionsPageSFXOnLabel
            self.SoundFX_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.SoundFX_Label['text'] = TTLocalizer.OptionsPageSFXOffLabel
            self.SoundFX_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn
        self.__setToonChatSoundsButton()

    def __setToonChatSoundsButton(self):
        if base.toonChatSounds:
            self.ToonChatSounds_Label[
                'text'] = TTLocalizer.OptionsPageToonChatSoundsOnLabel
            self.ToonChatSounds_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.ToonChatSounds_Label[
                'text'] = TTLocalizer.OptionsPageToonChatSoundsOffLabel
            self.ToonChatSounds_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOn
        if base.sfxActive:
            self.ToonChatSounds_Label.setColorScale(1.0, 1.0, 1.0, 1.0)
            self.ToonChatSounds_toggleButton['state'] = DGG.NORMAL
        else:
            self.ToonChatSounds_Label.setColorScale(0.5, 0.5, 0.5, 0.5)
            self.ToonChatSounds_toggleButton['state'] = DGG.DISABLED

    def __doToggleAcceptFriends(self):
        messenger.send('wakeup')
        acceptingNewFriends = settings.get('acceptingNewFriends', {})
        if base.localAvatar.acceptingNewFriends:
            base.localAvatar.acceptingNewFriends = 0
            acceptingNewFriends[str(base.localAvatar.doId)] = False
        else:
            base.localAvatar.acceptingNewFriends = 1
            acceptingNewFriends[str(base.localAvatar.doId)] = True
        settings['acceptingNewFriends'] = acceptingNewFriends
        self.settingsChanged = 1
        self.__setAcceptFriendsButton()

    def __doToggleAcceptWhispers(self):
        messenger.send('wakeup')
        acceptingNonFriendWhispers = settings.get('acceptingNonFriendWhispers',
                                                  {})
        if base.localAvatar.acceptingNonFriendWhispers:
            base.localAvatar.acceptingNonFriendWhispers = 0
            acceptingNonFriendWhispers[str(base.localAvatar.doId)] = False
        else:
            base.localAvatar.acceptingNonFriendWhispers = 1
            acceptingNonFriendWhispers[str(base.localAvatar.doId)] = True
        settings['acceptingNonFriendWhispers'] = acceptingNonFriendWhispers
        self.settingsChanged = 1
        self.__setAcceptWhispersButton()

    def __setAcceptFriendsButton(self):
        if base.localAvatar.acceptingNewFriends:
            self.Friends_Label[
                'text'] = TTLocalizer.OptionsPageFriendsEnabledLabel
            self.Friends_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Friends_Label[
                'text'] = TTLocalizer.OptionsPageFriendsDisabledLabel
            self.Friends_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn

    def __setAcceptWhispersButton(self):
        if base.localAvatar.acceptingNonFriendWhispers:
            self.Whispers_Label[
                'text'] = TTLocalizer.OptionsPageWhisperEnabledLabel
            self.Whispers_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Whispers_Label[
                'text'] = TTLocalizer.OptionsPageWhisperDisabledLabel
            self.Whispers_toggleButton[
                'text'] = TTLocalizer.OptionsPageToggleOn

    def __doDisplaySettings(self):
        if self.displaySettings is None:
            self.displaySettings = DisplaySettingsDialog.DisplaySettingsDialog(
            )
            self.displaySettings.load()
            self.accept(self.displaySettings.doneEvent,
                        self.__doneDisplaySettings)
        self.displaySettings.enter(self.ChangeDisplaySettings,
                                   self.ChangeDisplayAPI)

    def __doneDisplaySettings(self, anyChanged, apiChanged):
        if anyChanged:
            self.__setDisplaySettings()
            properties = base.win.getProperties()
            self.displaySettingsChanged = 1
            self.displaySettingsSize = (properties.getXSize(),
                                        properties.getYSize())
            self.displaySettingsFullscreen = properties.getFullscreen()
            self.displaySettingsApi = base.pipe.getInterfaceName()
            self.displaySettingsApiChanged = apiChanged

    def __setDisplaySettings(self):
        properties = base.win.getProperties()
        if properties.getFullscreen():
            screensize = '%s x %s' % (properties.getXSize(),
                                      properties.getYSize())
        else:
            screensize = TTLocalizer.OptionsPageDisplayWindowed
        api = base.pipe.getInterfaceName()
        settings = {'screensize': screensize, 'api': api}
        if self.ChangeDisplayAPI:
            OptionsPage.notify.debug('change display settings...')
            text = TTLocalizer.OptionsPageDisplaySettings % settings
        else:
            OptionsPage.notify.debug('no change display settings...')
            text = TTLocalizer.OptionsPageDisplaySettingsNoApi % settings
        self.DisplaySettings_Label['text'] = text

    def __doSpeedChatStyleLeft(self):
        if self.speedChatStyleIndex > 0:
            self.speedChatStyleIndex = self.speedChatStyleIndex - 1
            self.updateSpeedChatStyle()

    def __doSpeedChatStyleRight(self):
        if self.speedChatStyleIndex < len(speedChatStyles) - 1:
            self.speedChatStyleIndex = self.speedChatStyleIndex + 1
            self.updateSpeedChatStyle()

    def updateSpeedChatStyle(self):
        nameKey, arrowColor, rolloverColor, frameColor = speedChatStyles[
            self.speedChatStyleIndex]
        newSCColorScheme = SCColorScheme.SCColorScheme(
            arrowColor=arrowColor,
            rolloverColor=rolloverColor,
            frameColor=frameColor)
        self.speedChatStyleText.setColorScheme(newSCColorScheme)
        self.speedChatStyleText.clearMenu()
        colorName = SCStaticTextTerminal.SCStaticTextTerminal(nameKey)
        self.speedChatStyleText.append(colorName)
        self.speedChatStyleText.finalize()
        self.speedChatStyleText.setPos(
            0.445 -
            self.speedChatStyleText.getWidth() * self.speed_chat_scale / 2, 0,
            self.speedChatStyleText.getPos()[2])
        if self.speedChatStyleIndex > 0:
            self.speedChatStyleLeftArrow['state'] = DGG.NORMAL
        else:
            self.speedChatStyleLeftArrow['state'] = DGG.DISABLED
        if self.speedChatStyleIndex < len(speedChatStyles) - 1:
            self.speedChatStyleRightArrow['state'] = DGG.NORMAL
        else:
            self.speedChatStyleRightArrow['state'] = DGG.DISABLED
        base.localAvatar.b_setSpeedChatStyleIndex(self.speedChatStyleIndex)

    def writeDisplaySettings(self, task=None):
        if not self.displaySettingsChanged:
            return
        taskMgr.remove(self.DisplaySettingsTaskName)
        settings['res'] = (self.displaySettingsSize[0],
                           self.displaySettingsSize[1])
        settings['fullscreen'] = self.displaySettingsFullscreen
        return Task.done

    def __handleExitShowWithConfirm(self):
        self.confirm = TTDialog.TTGlobalDialog(
            doneEvent='confirmDone',
            message=TTLocalizer.OptionsPageExitConfirm,
            style=TTDialog.TwoChoice)
        self.confirm.show()
        self.parent.doneStatus = {'mode': 'exit', 'exitTo': 'closeShard'}
        self.accept('confirmDone', self.__handleConfirm)

    def __handleConfirm(self):
        status = self.confirm.doneStatus
        self.ignore('confirmDone')
        self.confirm.cleanup()
        del self.confirm
        if status == 'ok':
            base.cr._userLoggingOut = True
            messenger.send(self.parent.doneEvent)
示例#4
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()
    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()
class OptionsTabPage(DirectFrame):
    notify = directNotify.newCategory('OptionsTabPage')
    DisplaySettingsTaskName = 'save-display-settings'
    DisplaySettingsDelay = 60
    ChangeDisplaySettings = base.config.GetBool('change-display-settings', 1)
    ChangeDisplayAPI = base.config.GetBool('change-display-api', 0)

    def __init__(self, parent=aspect2d):
        self.parent = parent
        self.currentSizeIndex = None

        DirectFrame.__init__(
            self, parent=self.parent, relief=None, pos=(
                0.0, 0.0, 0.0), scale=(
                1.0, 1.0, 1.0))

        self.load()

    def destroy(self):
        self.parent = None

        DirectFrame.destroy(self)

    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 enter(self):
        self.show()
        taskMgr.remove(self.DisplaySettingsTaskName)
        self.settingsChanged = 0
        self.__setMusicButton()
        self.__setSoundFXButton()
        self.__setAcceptFriendsButton()
        self.__setAcceptWhispersButton()
        self.__setDisplaySettings()
        self.__setToonChatSoundsButton()
        self.speedChatStyleText.enter()
        self.speedChatStyleIndex = base.localAvatar.getSpeedChatStyleIndex()
        self.updateSpeedChatStyle()
        if self.parent.book.safeMode:
            self.exitButton.hide()
        else:
            self.exitButton.show()

    def exit(self):
        self.ignore('confirmDone')
        self.hide()
        self.speedChatStyleText.exit()
        if self.displaySettingsChanged:
            taskMgr.doMethodLater(
                self.DisplaySettingsDelay,
                self.writeDisplaySettings,
                self.DisplaySettingsTaskName)

    def unload(self):
        self.writeDisplaySettings()
        taskMgr.remove(self.DisplaySettingsTaskName)
        if self.displaySettings is not None:
            self.ignore(self.displaySettings.doneEvent)
            self.displaySettings.unload()
        self.displaySettings = None
        self.exitButton.destroy()
        self.Music_toggleButton.destroy()
        self.SoundFX_toggleButton.destroy()
        self.Friends_toggleButton.destroy()
        self.Whispers_toggleButton.destroy()
        self.DisplaySettingsButton.destroy()
        self.speedChatStyleLeftArrow.destroy()
        self.speedChatStyleRightArrow.destroy()
        del self.exitButton
        del self.SoundFX_Label
        del self.Music_Label
        del self.Friends_Label
        del self.Whispers_Label
        del self.SpeedChatStyle_Label
        del self.SoundFX_toggleButton
        del self.Music_toggleButton
        del self.Friends_toggleButton
        del self.Whispers_toggleButton
        del self.speedChatStyleLeftArrow
        del self.speedChatStyleRightArrow
        self.speedChatStyleText.exit()
        self.speedChatStyleText.destroy()
        del self.speedChatStyleText
        self.currentSizeIndex = None

    def __doToggleMusic(self):
        messenger.send('wakeup')
        if base.musicActive:
            base.enableMusic(0)
            settings['music'] = False
        else:
            base.enableMusic(1)
            settings['music'] = True
        self.settingsChanged = 1
        self.__setMusicButton()

    def __setMusicButton(self):
        if base.musicActive:
            self.Music_Label['text'] = TTLocalizer.OptionsPageMusicOnLabel
            self.Music_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Music_Label['text'] = TTLocalizer.OptionsPageMusicOffLabel
            self.Music_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn

    def __doToggleSfx(self):
        messenger.send('wakeup')
        if base.sfxActive:
            base.enableSoundEffects(0)
            settings['sfx'] = False
        else:
            base.enableSoundEffects(1)
            settings['sfx'] = True
        self.settingsChanged = 1
        self.__setSoundFXButton()

    def __doToggleToonChatSounds(self):
        messenger.send('wakeup')
        if base.toonChatSounds:
            base.toonChatSounds = 0
            settings['toonChatSounds'] = False
        else:
            base.toonChatSounds = 1
            settings['toonChatSounds'] = True
        self.settingsChanged = 1
        self.__setToonChatSoundsButton()

    def __setSoundFXButton(self):
        if base.sfxActive:
            self.SoundFX_Label['text'] = TTLocalizer.OptionsPageSFXOnLabel
            self.SoundFX_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.SoundFX_Label['text'] = TTLocalizer.OptionsPageSFXOffLabel
            self.SoundFX_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn
        self.__setToonChatSoundsButton()

    def __setToonChatSoundsButton(self):
        if base.toonChatSounds:
            self.ToonChatSounds_Label['text'] = TTLocalizer.OptionsPageToonChatSoundsOnLabel
            self.ToonChatSounds_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.ToonChatSounds_Label['text'] = TTLocalizer.OptionsPageToonChatSoundsOffLabel
            self.ToonChatSounds_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn
        if base.sfxActive:
            self.ToonChatSounds_Label.setColorScale(1.0, 1.0, 1.0, 1.0)
            self.ToonChatSounds_toggleButton['state'] = DGG.NORMAL
        else:
            self.ToonChatSounds_Label.setColorScale(0.5, 0.5, 0.5, 0.5)
            self.ToonChatSounds_toggleButton['state'] = DGG.DISABLED

    def __doToggleAcceptFriends(self):
        messenger.send('wakeup')
        acceptingNewFriends = settings.get('acceptingNewFriends', {})
        if base.localAvatar.acceptingNewFriends:
            base.localAvatar.acceptingNewFriends = 0
            acceptingNewFriends[str(base.localAvatar.doId)] = False
        else:
            base.localAvatar.acceptingNewFriends = 1
            acceptingNewFriends[str(base.localAvatar.doId)] = True
        settings['acceptingNewFriends'] = acceptingNewFriends
        self.settingsChanged = 1
        self.__setAcceptFriendsButton()

    def __doToggleAcceptWhispers(self):
        messenger.send('wakeup')
        acceptingNonFriendWhispers = settings.get('acceptingNonFriendWhispers', {})
        if base.localAvatar.acceptingNonFriendWhispers:
            base.localAvatar.acceptingNonFriendWhispers = 0
            acceptingNonFriendWhispers[str(base.localAvatar.doId)] = False
        else:
            base.localAvatar.acceptingNonFriendWhispers = 1
            acceptingNonFriendWhispers[str(base.localAvatar.doId)] = True
        settings['acceptingNonFriendWhispers'] = acceptingNonFriendWhispers
        self.settingsChanged = 1
        self.__setAcceptWhispersButton()

    def __setAcceptFriendsButton(self):
        if base.localAvatar.acceptingNewFriends:
            self.Friends_Label['text'] = TTLocalizer.OptionsPageFriendsEnabledLabel
            self.Friends_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Friends_Label['text'] = TTLocalizer.OptionsPageFriendsDisabledLabel
            self.Friends_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn

    def __setAcceptWhispersButton(self):
        if base.localAvatar.acceptingNonFriendWhispers:
            self.Whispers_Label['text'] = TTLocalizer.OptionsPageWhisperEnabledLabel
            self.Whispers_toggleButton['text'] = TTLocalizer.OptionsPageToggleOff
        else:
            self.Whispers_Label['text'] = TTLocalizer.OptionsPageWhisperDisabledLabel
            self.Whispers_toggleButton['text'] = TTLocalizer.OptionsPageToggleOn

    def __doDisplaySettings(self):
        if self.displaySettings is None:
            self.displaySettings = DisplaySettingsDialog.DisplaySettingsDialog()
            self.displaySettings.load()
            self.accept(self.displaySettings.doneEvent, self.__doneDisplaySettings)
        self.displaySettings.enter(self.ChangeDisplaySettings, self.ChangeDisplayAPI)

    def __doneDisplaySettings(self, anyChanged, apiChanged):
        if anyChanged:
            self.__setDisplaySettings()
            properties = base.win.getProperties()
            self.displaySettingsChanged = 1
            self.displaySettingsSize = (properties.getXSize(), properties.getYSize())
            self.displaySettingsFullscreen = properties.getFullscreen()
            self.displaySettingsApi = base.pipe.getInterfaceName()
            self.displaySettingsApiChanged = apiChanged

    def __setDisplaySettings(self):
        properties = base.win.getProperties()
        if properties.getFullscreen():
            screensize = '%s x %s' % (properties.getXSize(), properties.getYSize())
        else:
            screensize = TTLocalizer.OptionsPageDisplayWindowed
        api = base.pipe.getInterfaceName()
        settings = {'screensize': screensize,
                    'api': api}
        if self.ChangeDisplayAPI:
            OptionsPage.notify.debug('change display settings...')
            text = TTLocalizer.OptionsPageDisplaySettings % settings
        else:
            OptionsPage.notify.debug('no change display settings...')
            text = TTLocalizer.OptionsPageDisplaySettingsNoApi % settings
        self.DisplaySettings_Label['text'] = text

    def __doSpeedChatStyleLeft(self):
        if self.speedChatStyleIndex > 0:
            self.speedChatStyleIndex = self.speedChatStyleIndex - 1
            self.updateSpeedChatStyle()

    def __doSpeedChatStyleRight(self):
        if self.speedChatStyleIndex < len(speedChatStyles) - 1:
            self.speedChatStyleIndex = self.speedChatStyleIndex + 1
            self.updateSpeedChatStyle()

    def updateSpeedChatStyle(self):
        nameKey, arrowColor, rolloverColor, frameColor = speedChatStyles[self.speedChatStyleIndex]
        newSCColorScheme = SCColorScheme.SCColorScheme(
            arrowColor=arrowColor,
            rolloverColor=rolloverColor,
            frameColor=frameColor)
        self.speedChatStyleText.setColorScheme(newSCColorScheme)
        self.speedChatStyleText.clearMenu()
        colorName = SCStaticTextTerminal.SCStaticTextTerminal(nameKey)
        self.speedChatStyleText.append(colorName)
        self.speedChatStyleText.finalize()
        self.speedChatStyleText.setPos(
            0.445 -
            self.speedChatStyleText.getWidth() *
            self.speed_chat_scale /
            2,
            0,
            self.speedChatStyleText.getPos()[2])
        if self.speedChatStyleIndex > 0:
            self.speedChatStyleLeftArrow['state'] = DGG.NORMAL
        else:
            self.speedChatStyleLeftArrow['state'] = DGG.DISABLED
        if self.speedChatStyleIndex < len(speedChatStyles) - 1:
            self.speedChatStyleRightArrow['state'] = DGG.NORMAL
        else:
            self.speedChatStyleRightArrow['state'] = DGG.DISABLED
        base.localAvatar.b_setSpeedChatStyleIndex(self.speedChatStyleIndex)

    def writeDisplaySettings(self, task=None):
        if not self.displaySettingsChanged:
            return
        taskMgr.remove(self.DisplaySettingsTaskName)
        settings['res'] = (self.displaySettingsSize[0], self.displaySettingsSize[1])
        settings['fullscreen'] = self.displaySettingsFullscreen
        return Task.done

    def __handleExitShowWithConfirm(self):
        self.confirm = TTDialog.TTGlobalDialog(
            doneEvent='confirmDone',
            message=TTLocalizer.OptionsPageExitConfirm,
            style=TTDialog.TwoChoice)
        self.confirm.show()
        self.parent.doneStatus = {'mode': 'exit',
                                  'exitTo': 'closeShard'}
        self.accept('confirmDone', self.__handleConfirm)

    def __handleConfirm(self):
        status = self.confirm.doneStatus
        self.ignore('confirmDone')
        self.confirm.cleanup()
        del self.confirm
        if status == 'ok':
            base.cr._userLoggingOut = True
            messenger.send(self.parent.doneEvent)