def exit(self): self.ignore('confirmDone') self.hide() if self.settingsChanged != 0: Settings.writeSettings() self.speedChatStyleText.exit() if self.displaySettingsChanged: taskMgr.doMethodLater(self.DisplaySettingsDelay, self.writeDisplaySettings, self.DisplaySettingsTaskName)
def __doToggleAcceptWhispers(self): messenger.send('wakeup') if base.localAvatar.acceptingNonFriendWhispers: base.localAvatar.acceptingNonFriendWhispers = 0 Settings.setAcceptingNonFriendWhispers(0) else: base.localAvatar.acceptingNonFriendWhispers = 1 Settings.setAcceptingNonFriendWhispers(1) self.settingsChanged = 1 self.__setAcceptWhispersButton()
def __doToggleToonChatSounds(self): messenger.send('wakeup') if base.toonChatSounds: base.toonChatSounds = 0 Settings.setToonChatSounds(0) else: base.toonChatSounds = 1 Settings.setToonChatSounds(1) self.settingsChanged = 1 self.__setToonChatSoundsButton()
def __doToggleSfx(self): messenger.send('wakeup') if base.sfxActive: base.enableSoundEffects(0) Settings.setSfx(0) else: base.enableSoundEffects(1) Settings.setSfx(1) self.settingsChanged = 1 self.__setSoundFXButton()
def __doToggleMusic(self): messenger.send('wakeup') if base.musicActive: base.enableMusic(0) Settings.setMusic(0) else: base.enableMusic(1) Settings.setMusic(1) self.settingsChanged = 1 self.__setMusicButton()
def writeDisplaySettings(self, task = None): if not self.displaySettingsChanged: return taskMgr.remove(self.DisplaySettingsTaskName) self.notify.info('writing new display settings %s, fullscreen %s, embedded %s, %s to SettingsFile.' % (self.displaySettingsSize, self.displaySettingsFullscreen, self.displaySettingsEmbedded, self.displaySettingsApi)) Settings.setResolutionDimensions(self.displaySettingsSize[0], self.displaySettingsSize[1]) Settings.setWindowedMode(not self.displaySettingsFullscreen) Settings.setEmbeddedMode(self.displaySettingsEmbedded) if self.displaySettingsApiChanged: api = self.DisplaySettingsApiMap.get(self.displaySettingsApi) if api == None: self.notify.warning('Cannot save unknown display API: %s' % self.displaySettingsApi) else: Settings.setDisplayDriver(api) Settings.writeSettings() self.displaySettingsChanged = 0 return Task.done
def __init__(self): OTPBase.OTPBase.__init__(self) if not config.GetInt('ignore-user-options', 0): settings = Settings() settings.readSettings() mode = not settings.getWindowedMode() print(mode) music = settings.getMusic() sfx = settings.getSfx() toonChatSounds = settings.getToonChatSounds() musicVol = settings.getMusicVolume() sfxVol = settings.getSfxVolume() # Get Display Information # This also sets our getResolution() function settings.getDisplayInformation() res = settings.getResolution() if mode == True: mode = 1 if res == None: # shouldn't happen. res = (800, 600) loadPrcFileData('toonBase Settings Window Res', 'win-size %s %s' % (res[0], res[1])) loadPrcFileData('toonBase Settings Window FullScreen', 'fullscreen %s' % mode) loadPrcFileData('toonBase Settings Music Active', 'audio-music-active %s' % music) loadPrcFileData('toonBase Settings Sound Active', 'audio-sfx-active %s' % sfx) loadPrcFileData('toonBase Settings Music Volume', 'audio-master-music-volume %s' % musicVol) loadPrcFileData('toonBase Settings Sfx Volume', 'audio-master-sfx-volume %s' % sfxVol) loadPrcFileData('toonBase Settings Toon Chat Sounds', 'toon-chat-sounds %s' % toonChatSounds) # if not self.isMainWindowOpen(): # try: # launcher.setPandaErrorCode(7) # except: # pass # # sys.exit(1) self.disableShowbaseMouse() base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1) self.placeBeforeObjects = config.GetBool('place-before-objects', 1) self.endlessQuietZone = False self.wantDynamicShadows = 0 self.exitErrorCode = 0 camera.setPosHpr(0, 0, 0, 0, 0, 0) self.camLens.setFov(ToontownGlobals.DefaultCameraFov) self.camLens.setNearFar(ToontownGlobals.DefaultCameraNear, ToontownGlobals.DefaultCameraFar) self.musicManager.setVolume(0.65) self.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor) tpm = TextPropertiesManager.getGlobalPtr() candidateActive = TextProperties() candidateActive.setTextColor(0, 0, 1, 1) tpm.setProperties('candidate_active', candidateActive) candidateInactive = TextProperties() candidateInactive.setTextColor(0.3, 0.3, 0.7, 1) tpm.setProperties('candidate_inactive', candidateInactive) self.transitions.IrisModelName = 'phase_3/models/misc/iris' self.transitions.FadeModelName = 'phase_3/models/misc/fade' self.exitFunc = self.userExit if __builtins__.has_key('launcher') and launcher: launcher.setPandaErrorCode(11) globalClock.setMaxDt(0.2) if self.config.GetBool('want-particles', 1) == 1: self.notify.debug('Enabling particles') self.enableParticles() self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot) self.accept('panda3d-render-error', self.panda3dRenderError) oldLoader = self.loader self.loader = ToontownLoader.ToontownLoader(self) __builtins__['loader'] = self.loader oldLoader.destroy() self.accept('PandaPaused', self.disableAllAudio) self.accept('PandaRestarted', self.enableAllAudio) self.friendMode = self.config.GetBool('switchboard-friends', 0) self.wantPets = self.config.GetBool('want-pets', 1) self.wantBingo = self.config.GetBool('want-fish-bingo', 1) self.wantKarts = self.config.GetBool('want-karts', 1) self.wantNewSpecies = self.config.GetBool('want-new-species', 0) self.inactivityTimeout = self.config.GetFloat('inactivity-timeout', ToontownGlobals.KeyboardTimeout) if self.inactivityTimeout: self.notify.debug('Enabling Panda timeout: %s' % self.inactivityTimeout) self.mouseWatcherNode.setInactivityTimeout(self.inactivityTimeout) self.randomMinigameAbort = self.config.GetBool('random-minigame-abort', 0) self.randomMinigameDisconnect = self.config.GetBool('random-minigame-disconnect', 0) self.randomMinigameNetworkPlugPull = self.config.GetBool('random-minigame-netplugpull', 0) self.autoPlayAgain = self.config.GetBool('auto-play-again', 0) self.skipMinigameReward = self.config.GetBool('skip-minigame-reward', 0) self.wantMinigameDifficulty = self.config.GetBool('want-minigame-difficulty', 0) self.minigameDifficulty = self.config.GetFloat('minigame-difficulty', -1.0) if self.minigameDifficulty == -1.0: del self.minigameDifficulty self.minigameSafezoneId = self.config.GetInt('minigame-safezone-id', -1) if self.minigameSafezoneId == -1: del self.minigameSafezoneId cogdoGameSafezoneId = self.config.GetInt('cogdo-game-safezone-id', -1) cogdoGameDifficulty = self.config.GetFloat('cogdo-game-difficulty', -1) if cogdoGameDifficulty != -1: self.cogdoGameDifficulty = cogdoGameDifficulty if cogdoGameSafezoneId != -1: self.cogdoGameSafezoneId = cogdoGameSafezoneId ToontownBattleGlobals.SkipMovie = self.config.GetBool('skip-battle-movies', 0) self.creditCardUpFront = self.config.GetInt('credit-card-up-front', -1) if self.creditCardUpFront == -1: del self.creditCardUpFront else: self.creditCardUpFront = self.creditCardUpFront != 0 self.housingEnabled = self.config.GetBool('want-housing', 1) self.cannonsEnabled = self.config.GetBool('estate-cannons', 0) self.fireworksEnabled = self.config.GetBool('estate-fireworks', 0) self.dayNightEnabled = self.config.GetBool('estate-day-night', 0) self.cloudPlatformsEnabled = self.config.GetBool('estate-clouds', 0) self.greySpacing = self.config.GetBool('allow-greyspacing', 0) self.goonsEnabled = self.config.GetBool('estate-goon', 0) self.restrictTrialers = self.config.GetBool('restrict-trialers', 1) self.roamingTrialers = self.config.GetBool('roaming-trialers', 1) self.slowQuietZone = self.config.GetBool('slow-quiet-zone', 0) self.slowQuietZoneDelay = self.config.GetFloat('slow-quiet-zone-delay', 5) self.killInterestResponse = self.config.GetBool('kill-interest-response', 0) tpMgr = TextPropertiesManager.getGlobalPtr() WLDisplay = TextProperties() WLDisplay.setSlant(0.3) WLEnter = TextProperties() WLEnter.setTextColor(1.0, 0.0, 0.0, 1) tpMgr.setProperties('WLDisplay', WLDisplay) tpMgr.setProperties('WLEnter', WLEnter) del tpMgr self.lastScreenShotTime = globalClock.getRealTime() self.accept('InputState-forward', self.__walking) self.canScreenShot = 1 self.glitchCount = 0 self.walking = 0 self.resetMusic = self.loadMusic('phase_3/audio/bgm/MIDI_Events_16channels.mid') self.oldX = max(1, base.win.getXSize()) self.oldY = max(1, base.win.getYSize()) self.aspectRatio = float(self.oldX) / self.oldY return
def loadFromSettings(self): Settings.readSettings() mode = not Settings.getWindowedMode() music = Settings.getMusic() sfx = Settings.getSfx() toonChatSounds = Settings.getToonChatSounds() musicVol = Settings.getMusicVolume() sfxVol = Settings.getSfxVolume() resList = [(640, 480), (800, 600), (1024, 768), (1280, 1024), (1600, 1200)] res = resList[Settings.getResolution()] embed = Settings.getEmbeddedMode() self.notify.debug('before prc settings embedded mode=%s' % str(embed)) self.notify.debug('before prc settings full screen mode=%s' % str(mode)) if mode == None: mode = 1 if res == None: res = (800, 600) if not Settings.doSavedSettingsExist(): self.notify.info( 'loadFromSettings: No settings; isDefaultEmbedded=%s' % self.isDefaultEmbedded()) embed = self.isDefaultEmbedded() if embed and not self.isEmbeddedPossible(): self.notify.warning('Embedded mode is not possible.') embed = False if not mode and not self.isWindowedPossible(): self.notify.warning('Windowed mode is not possible.') mode = True loadPrcFileData('toonBase Settings Window Res', 'win-size %s %s' % (res[0], res[1])) self.notify.debug('settings resolution = %s' % str(res)) loadPrcFileData('toonBase Settings Window FullScreen', 'fullscreen %s' % mode) self.notify.debug('settings full screen mode=%s' % str(mode)) loadPrcFileData('toonBase Settings Music Active', 'audio-music-active %s' % music) loadPrcFileData('toonBase Settings Sound Active', 'audio-sfx-active %s' % sfx) loadPrcFileData('toonBase Settings Music Volume', 'audio-master-music-volume %s' % musicVol) loadPrcFileData('toonBase Settings Sfx Volume', 'audio-master-sfx-volume %s' % sfxVol) loadPrcFileData('toonBase Settings Toon Chat Sounds', 'toon-chat-sounds %s' % toonChatSounds) self.settingsFullScreen = mode self.settingsWidth = res[0] self.settingsHeight = res[1] self.settingsEmbedded = embed self.notify.debug('settings embedded mode=%s' % str(self.settingsEmbedded)) self.notify.info( 'settingsFullScreen = %s, embedded = %s width=%d height=%d' % (self.settingsFullScreen, self.settingsEmbedded, self.settingsWidth, self.settingsHeight)) return