def __init__(self): OTPBase.OTPBase.__init__(self) self.cr = None # Get the native display info: self.nativeWidth = self.pipe.getDisplayWidth() self.nativeHeight = self.pipe.getDisplayHeight() ratio = float(self.nativeWidth) / float(self.nativeHeight) fraction = fractions.Fraction(ratio).limit_denominator() self.nativeRatio = (int(fraction.numerator), int(fraction.denominator)) # Choose the best resolution if we're either fullscreen, or we don't # have a resolution defined in our settings: fullscreen = settings.get('fullscreen', False) if fullscreen or ('res' not in settings): if fullscreen: # Fit the entire display: res = (self.nativeWidth, self.nativeHeight) else: # Choose the smallest resolution that matches that largest # ratio that contains resolutions that will fit our display in # windowed mode: resolutions = ToontownGlobals.CommonDisplayResolutions.get(self.nativeRatio, ()) if len(resolutions) < 2: ratios = ToontownGlobals.CommonDisplayResolutions.keys() ratios.sort(key=lambda value: float(value[0]) / float(value[1])) while ratios: ratio = ratios.pop() if (float(ratio[0])/float(ratio[1])) < (float(self.nativeRatio[0])/float(self.nativeRatio[1])): resolutions = ToontownGlobals.CommonDisplayResolutions[ratio] if resolutions[0][0] >= (self.nativeWidth - 125): continue if resolutions[0][1] >= (self.nativeHeight - 125): continue break else: resolutions = ToontownGlobals.CommonDisplayResolutions[(4, 3)] res = resolutions[0] # Store our result settings['res'] = res # Reload the graphics pipe: properties = WindowProperties() properties.setSize(res[0], res[1]) properties.setFullscreen(fullscreen) properties.setParentWindow(0) # Store the window sort for later: sort = self.win.getSort() if self.win: currentProperties = WindowProperties(self.win.getProperties()) gsg = self.win.getGsg() else: currentProperties = WindowProperties.getDefault() gsg = None newProperties = WindowProperties(currentProperties) newProperties.addProperties(properties) if (gsg is None) or ( currentProperties.getFullscreen() != newProperties.getFullscreen()) or ( currentProperties.getParentWindow() != newProperties.getParentWindow()): self.openMainWindow(props=properties, gsg=gsg, keepCamera=True) self.graphicsEngine.openWindows() self.disableShowbaseMouse() else: self.win.requestProperties(properties) self.graphicsEngine.renderFrame() self.win.setSort(sort) self.graphicsEngine.renderFrame() self.graphicsEngine.renderFrame() self.disableShowbaseMouse() self.addCullBins() self.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor self.baseXpMultiplier = self.config.GetFloat('base-xp-multiplier', 1.0) self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1) self.placeBeforeObjects = self.config.GetBool('place-before-objects', 1) self.endlessQuietZone = False self.wantDynamicShadows = 0 self.exitErrorCode = 0 base.camera.setPosHpr(0, 0, 0, 0, 0, 0) self.camLens.setMinFov(ToontownGlobals.DefaultCameraFov / (4. / 3.)) 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 'launcher' in __builtins__ 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) # OS X Specific Actions if platform == "darwin": self.acceptOnce(ToontownGlobals.QuitGameHotKeyOSX, self.exitOSX) self.accept(ToontownGlobals.QuitGameHotKeyRepeatOSX, self.exitOSX) self.acceptOnce(ToontownGlobals.HideGameHotKeyOSX, self.hideGame) self.accept(ToontownGlobals.HideGameHotKeyRepeatOSX, self.hideGame) self.acceptOnce(ToontownGlobals.MinimizeGameHotKeyOSX, self.minimizeGame) self.accept(ToontownGlobals.MinimizeGameHotKeyRepeatOSX, self.minimizeGame) self.accept('f3', self.toggleGui) self.accept('f4', self.toggleNameTags) 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.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) 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.minigameSafezoneId = self.config.GetInt('minigame-safezone-id', -1) self.autoPlayAgain = self.config.GetBool('auto-play-again', 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.mouseWatcherNode.setEnterPattern('mouse-enter-%r') self.mouseWatcherNode.setLeavePattern('mouse-leave-%r') self.mouseWatcherNode.setButtonDownPattern('button-down-%r') self.mouseWatcherNode.setButtonUpPattern('button-up-%r') if self.minigameDifficulty == -1.0: del self.minigameDifficulty 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) self.forceSkipTutorial = self.config.GetBool('force-skip-tutorial', 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.oldX = max(1, base.win.getXSize()) self.oldY = max(1, base.win.getYSize()) self.aspectRatio = float(self.oldX) / self.oldY self.localAvatarStyle = None self.filters = CommonFilters(self.win, self.cam) ToontownGlobals.setInterfaceFont(TTLocalizer.InterfaceFont) ToontownGlobals.setSignFont(TTLocalizer.SignFont) ToontownGlobals.setFancyFont(TTLocalizer.FancyFont) for i in xrange(len(TTLocalizer.NametagFonts)): ToontownGlobals.setNametagFont(i, TTLocalizer.NametagFonts[i]) # Free black/white Toons: self.wantYinYang = config.GetBool('want-yin-yang', False) activeHolidays = config.GetString('active-holidays', '') self.clientHolidayIdList = [] for holidayId in activeHolidays.split(','): if holidayId: self.clientHolidayIdList.append(int(holidayId.strip())) self.__tick()