def __init__(self):
        base.useDrive()
        base.disableMouse()
        camera.setPosHpr(0, 0, 0, 0, 0, 0)
        base.camLens.setFov(ToontownGlobals.DefaultCameraFov)
        base.camLens.setNearFar(ToontownGlobals.DefaultCameraNear,
                                ToontownGlobals.DefaultCameraFar)
        base.musicManager.setVolume(0.65000000000000002)
        base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor)
        base.transitions.IrisModelName = 'phase_3/models/misc/iris'
        base.transitions.FadeModelName = 'phase_3/models/misc/fade'
        base.exitFunc = self.userExit
        if launcher:
            launcher.setPandaErrorCode(11)

        globalClock.setMaxDt(1.0)
        if base.config.GetBool('want-particles', 1) == 1:
            self.notify.debug('Enabling particles')
            base.enableParticles()

        self.base = base
        self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot)
        self.loader = ToontownLoader.ToontownLoader(base)
        self.accept('PandaPaused', base.disableAllAudio)
        self.accept('PandaRestarted', base.enableAllAudio)
        self.randomMinigameAbort = base.config.GetBool('random-minigame-abort',
                                                       0)
        self.randomMinigameDisconnect = base.config.GetBool(
            'random-minigame-disconnect', 0)
        self.randomMinigameNetworkPlugPull = base.config.GetBool(
            'random-minigame-netplugpull', 0)
        self.autoPlayAgain = base.config.GetBool('auto-play-again', 0)
        self.skipMinigameReward = base.config.GetBool('skip-minigame-reward',
                                                      0)
        self.wantMinigameDifficulty = base.config.GetBool(
            'want-minigame-difficulty', 0)
        self.minigameDifficulty = base.config.GetFloat('minigame-difficulty',
                                                       -1.0)
        if self.minigameDifficulty == -1.0:
            del self.minigameDifficulty

        self.minigameSafezoneId = base.config.GetInt('minigame-safezone-id',
                                                     -1)
        if self.minigameSafezoneId == -1:
            del self.minigameSafezoneId

        self.creditCardUpFront = base.config.GetInt('credit-card-up-front', -1)
        if self.creditCardUpFront == -1:
            del self.creditCardUpFront
        else:
            self.creditCardUpFront = self.creditCardUpFront != 0
        self.emotionsEnabled = base.config.GetBool('want-emotions', 0)
        self.emotionsMenuEnabled = base.config.GetBool('want-emotions-menu', 0)
        self.customMenuEnabled = base.config.GetBool('want-custom-menu', 0)
        self.housingEnabled = base.config.GetBool('want-housing', 1)
예제 #2
0
    def __init__(self):
        OTPBase.OTPBase.__init__(self)
        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
        camera.setPosHpr(0, 0, 0, 0, 0, 0)
        self.camLens.setMinFov(settings['fov']/(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
        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.oobe)
        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.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.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')
        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.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.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)
        tpMgr.setProperties('WLDisplay', WLDisplay)
        WLRed = tpMgr.getProperties('red')
        WLRed.setTextColor(1.0, 0.0, 0.0, 1)
        tpMgr.setProperties('WLRed', WLRed)
        del tpMgr
        self.lastScreenShotTime = globalClock.getRealTime()
        self.accept('InputState-forward', self.__walking)
        self.accept('shift', self.setSprinting)
        self.accept('shift-up', self.exitSprinting)
        self.canScreenShot = 1
        self.glitchCount = 0
        self.walking = 0
        self.isSprinting = 1
        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)
        self.wantCogInterface = settings.get('cogInterface', True)
        self.aspect2d.setAntialias(AntialiasAttrib.MMultisample)
예제 #3
0
    def __init__(self):
        if not config.GetInt('ignore-user-options', 0):
            self.settings = ToontownSettings.ToontownSettings()
            self.loadFromSettings()
        else:
            self.settings = None
        OTPBase.OTPBase.__init__(self)
        if not self.isMainWindowOpen():
            try:
                launcher.setPandaErrorCode(7)
            except:
                pass

            sys.exit(1)
        self.disableShowbaseMouse()
        self.addCullBins()
        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.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)
        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.oldX = max(1, base.win.getXSize())
        self.oldY = max(1, base.win.getYSize())
        self.aspectRatio = float(self.oldX) / self.oldY
        return
예제 #4
0
    def __init__(self):
        OTPBase.OTPBase.__init__(self)

        # First, build a list of all possible resolutions:
        self.resList = []
        displayInfo = self.pipe.getDisplayInformation()
        for i in xrange(displayInfo.getTotalDisplayModes()):
            width = displayInfo.getDisplayModeWidth(i)
            height = displayInfo.getDisplayModeHeight(i)
            if (width, height) not in self.resList:
                self.resList.append((width, height))

        # Next, separate the resolutions by their ratio:
        self.resDict = {}
        for res in self.resList:
            width = float(res[0])
            height = float(res[1])
            ratio = round(width / height, 2)
            self.resDict.setdefault(ratio, []).append(res)

        # Get the native width, height and ratio:
        if sys.platform == 'win32':  # Use displayInfo.
            self.nativeWidth = displayInfo.getMaximumWindowWidth()
            self.nativeHeight = displayInfo.getMaximumWindowHeight()
        else:  # Use PyGTK.
            import gtk
            self.nativeWidth = gtk.gdk.screen_width()
            self.nativeHeight = gtk.gdk.screen_height()
        self.nativeRatio = round(
            float(self.nativeWidth) / float(self.nativeHeight), 2)

        # Finally, choose the best resolution if we're either fullscreen, or
        # don't have one defined in our preferences:
        fullscreen = settings.get('fullscreen', False)
        if ('res' not in settings) or fullscreen:
            if fullscreen:
                # If we're fullscreen, we want to fit the entire screen:
                res = (self.nativeWidth, self.nativeHeight)
            elif len(self.resDict[self.nativeRatio]) > 1:
                # We have resolutions that match our native ratio and fit it!
                # Let's use one:
                res = sorted(self.resDict[self.nativeRatio])[0]
            else:
                # Okay, we don't have any resolutions that match our native
                # ratio and fit it (besides the native resolution itself, of
                # course). Let's just use one of the second largest ratio's
                # resolutions:
                ratios = sorted(self.resDict.keys(), reverse=False)
                nativeIndex = ratios.index(self.nativeRatio)
                res = sorted(self.resDict[ratios[nativeIndex - 1]])[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
        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('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.wantAchievements = self.config.GetBool('want-achievements', 1)
        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')
        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)
        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)

        # Free black/white Toons:
        self.wantYinYang = config.GetBool('want-yin-yang', False)
예제 #5
0
 def __init__(self):
     self.display = DisplayOptions()
     OTPBase.OTPBase.__init__(self)
     base.enableMusic(self.display.settings.getBool('game', 'music', True))
     base.enableSoundEffects(
         self.display.settings.getBool('game', 'sfx', True))
     self.disableShowbaseMouse()
     self.addCullBins()
     base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor
     self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1)
     self.textToSpeech = self.display.settings.getBool(
         'game', 'textToSpeech', False)
     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.setMinFov(ToontownGlobals.DefaultCameraFov / (4.0 / 3.0))
     self.camLens.setNearFar(ToontownGlobals.DefaultCameraNear,
                             ToontownGlobals.DefaultCameraFar)
     self.cam2d.node().setCameraMask(BitMask32.bit(1))
     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.snapshotSfx = base.loader.loadSfx(
         'phase_4/audio/sfx/Photo_shutter.ogg')
     self.flashTrack = None
     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)
     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('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.mouseWatcherNode.setEnterPattern('mouse-enter-%r')
     self.mouseWatcherNode.setLeavePattern('mouse-leave-%r')
     self.mouseWatcherNode.setButtonDownPattern('button-down-%r')
     self.mouseWatcherNode.setButtonUpPattern('button-up-%r')
     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.oldX = max(1, base.win.getXSize())
     self.oldY = max(1, base.win.getYSize())
     self.aspectRatio = float(self.oldX) / self.oldY
     self.localAvatarStyle = None
     self.shaderMgr = ShaderManager.ShaderManager()
     self.sosCheck = False
     return
예제 #6
0
    def __init__(self):
        """__init__(self)
        ToonBase constructor: create a toon and launch it into the world
        """
        if not config.GetInt('ignore-user-options', 0):
            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)]  #copied from Resolution in settingsFile.h
            res = resList[Settings.getResolution()]

            if mode == None:
                mode = 1
            if res == None:
                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)))

        OTPBase.OTPBase.__init__(self)

        if not self.isMainWindowOpen():
            try:
                # For toontown, it is possible that window open failed
                # because of a graphics card issue. In that case, take
                # user to the appropriate page.
                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

        # Toontown doesn't care about dynamic shadows for now.
        self.wantDynamicShadows = 0
        # this is temporary until we pull in the new launcher code in production
        self.exitErrorCode = 0

        camera.setPosHpr(0, 0, 0, 0, 0, 0)
        self.camLens.setFov(ToontownGlobals.DefaultCameraFov)
        self.camLens.setNearFar(ToontownGlobals.DefaultCameraNear,
                                ToontownGlobals.DefaultCameraFar)

        # Music should be a bit quieter in toontown
        self.musicManager.setVolume(0.65)

        # Set the default background color.
        self.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor)

        # Set up the default colors of the IME candidate strings.
        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)

        # set the showbase iris and fade models to point to
        # models in the ttmodels tree
        self.transitions.IrisModelName = "phase_3/models/misc/iris"
        self.transitions.FadeModelName = "phase_3/models/misc/fade"

        # When the user closes the main window, we want to get a
        # chance to shut down cleanly.
        self.exitFunc = self.userExit

        # Now that we've got the exit hook set, we can set error code
        # 11, indicating an abnormal termination.  If the user exits
        # via alt-F4, that will reset the error code to 0 before
        # exiting; if we get a Python exception, that will reset the
        # error code to 12.  But if we terminate for any other reason
        # without giving Python a chance to catch the error, it will
        # remain exit code 11: sudden death without Python cleanup.
        if __builtins__.has_key("launcher") and launcher:
            launcher.setPandaErrorCode(11)

        # Set our max dt so avatars with a low frame rate will
        # not pop through collision walls

        # Actually, we don't need such a low value these days, now
        # that collisions are better behaved; and setting this number
        # too low is frustrating for users with a poor frame rate.
        # 1.0 seems to be large enough to ease that frustration, while
        # small enough to prevent us from careening through space
        # during a particularly big chug.

        # On second thought, Dave Schuyler argues that we should have
        # a lower value now to prevent the various physics integrators
        # from blowing up.  And besides, there are still some
        # collision holes in the world.  So we compromise with 0.2 for
        # now.
        globalClock.setMaxDt(0.2)

        # Enable particles if desired
        if (self.config.GetBool('want-particles', 1) == 1):
            self.notify.debug('Enabling particles')
            self.enableParticles()

        # Turn off screen clear (enable this when there are not any
        # cracks left in the world)
        # self.win.getGsg().enableFrameClear(0, 1)

        # Accept the screenshot key
        self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot)

        # If panda throws a panic event, we know we're not rendering
        # properly; send the user to the appropriate web page.
        self.accept('panda3d-render-error', self.panda3dRenderError)

        # make a ToontownLoader. Overwrite the ShowBase one.
        oldLoader = self.loader
        self.loader = ToontownLoader.ToontownLoader(self)
        __builtins__["loader"] = self.loader
        oldLoader.destroy()

        # Handle Alt-tab notification from gsg
        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)

        # tell panda to ignore repeated key presses
        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)

        # minigame debug flags
        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.)
        if self.minigameDifficulty == -1.:
            del self.minigameDifficulty
        self.minigameSafezoneId = self.config.GetInt('minigame-safezone-id',
                                                     -1)
        if self.minigameSafezoneId == -1:
            del self.minigameSafezoneId

        ToontownBattleGlobals.SkipMovie = self.config.GetBool(
            'skip-battle-movies', 0)

        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)

        # this must be retrieved as an int (and not a bool) so
        # that we can detect the absence of this config var; if
        # we get it as a bool, our default value of -1 is
        # converted to a 1.
        self.creditCardUpFront = self.config.GetInt('credit-card-up-front', -1)
        if self.creditCardUpFront == -1:
            del self.creditCardUpFront
        else:
            # convert to a bool
            self.creditCardUpFront = (self.creditCardUpFront != 0)

        # housing
        self.housingEnabled = self.config.GetBool('want-housing', 1)

        # cannons
        self.cannonsEnabled = self.config.GetBool('estate-cannons', 0)

        # firework cannons
        self.fireworksEnabled = self.config.GetBool('estate-fireworks', 0)

        # day/night in estates
        self.dayNightEnabled = self.config.GetBool('estate-day-night', 0)

        # cloud platforms in estates
        self.cloudPlatformsEnabled = self.config.GetBool('estate-clouds', 0)

        # greySpacing Allowed?
        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)

        #whitelist text styles
        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
예제 #7
0
     loader.loadModelOnce('phase_3/models/gui/dialog_box_gui'))
 if base.musicManagerIsValid:
     music = base.musicManager.getSound('phase_3/audio/bgm/tt_theme.mid')
     if music:
         music.setLoop(1)
         music.setVolume(0.9)
         music.play()
     print 'ToontownStart: Loading default gui sounds'
     DirectGuiGlobals.setDefaultRolloverSound(
         base.loadSfx('phase_3/audio/sfx/GUI_rollover.mp3'))
     DirectGuiGlobals.setDefaultClickSound(
         base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.mp3'))
 else:
     music = None
 import ToontownLoader
 tempLoaderOther = ToontownLoader.ToontownLoader(base)
 base.loader = tempLoaderOther
 __builtin__.loader = tempLoaderOther
 from DirectGui import *
 serverVersion = base.config.GetString('server-version', 'no_version_set')
 print 'ToontownStart: serverVersion: ', serverVersion
 version = OnscreenText(serverVersion,
                        pos=(-1.3, -0.975),
                        scale=0.06,
                        fg=Vec4(0, 0, 1, 0.6),
                        align=TextNode.ALeft)
 import Localizer
 loader.beginBulkLoad('init', Localizer.LoaderLabel, 138, gui=0)
 from ToonBaseGlobal import *
 from MessengerGlobal import *
 import ToontownClientRepository
 def __init__(self):
     OTPBase.OTPBase.__init__(self)
     if self.isMainWindowOpen():
         try:
             launcher.setPandaErrorCode(7)
         except:
             pass
         else:
             sys.exit(1)
     self.disableShowbaseMouse()
     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'):
         if 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
         self.creditCardUpFront = self.config.GetInt('credit-card-up-front', -1)
         del self.creditCardUpFront == -1 and 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.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.lastScreenShotTime = globalClock.getRealTime()
     self.accept('InputState-forward', self.__walking)
     self.canScreenShot = 1
     self.glitchCount = 0
     self.walking = 0
예제 #9
0
    def __init__(self):
        OTPBase.OTPBase.__init__(self)

        # 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
        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.oobe)
        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.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.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')
        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.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.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)
        tpMgr.setProperties('WLDisplay', WLDisplay)
        WLRed = tpMgr.getProperties('red')
        WLRed.setTextColor(1.0, 0.0, 0.0, 1)
        tpMgr.setProperties('WLRed', WLRed)
        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)
        self.wantCogInterface = settings.get('cogInterface', True)

        self.wantWASD = settings.get('want-WASD', False)

        self.Move_Up = 'arrow_up'
        self.Move_Left = 'arrow_left'
        self.Move_Down = 'arrow_down'
        self.Move_Right = 'arrow_right'
        self.JUMP = 'control'

        if self.wantWASD:
            self.Move_Up = 'w'
            self.Move_Left = 'a'
            self.Move_Down = 's'
            self.Move_Right = 'd'
            self.JUMP = 'shift'

        def openMainWindow(self, *args, **kw):
            result = OTPBase.OTPBase.openMainWindow(self, *args, **kw)

        self.setCursorAndIcon()
        return
예제 #10
0
    def __init__(self):
        if not config.GetInt('ignore-user-options', 0):
            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()]
            if mode == None:
                mode = 1

            if res == None:
                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)

        OTPBase.OTPBase.__init__(self)
        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.65000000000000002)
        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.29999999999999999,
                                       0.29999999999999999,
                                       0.69999999999999996, 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.20000000000000001)
        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.29999999999999999)
        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._ToonBase__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
    def __init__(self):
        OTPBase.OTPBase.__init__(self)
        self.disableShowbaseMouse()
        self.addCullBins()
        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.setMinFov(settings['fieldofview'] / (4. / 3.))
        self.camLens.setNearFar(ToontownGlobals.DefaultCameraNear,
                                ToontownGlobals.DefaultCameraFar)
        self.cam2d.node().setCameraMask(BitMask32.bit(1))
        self.musicManager.setVolume(settings.get("musicVol"))

        for sfm in self.sfxManagerList:
            sfm.setVolume(settings.get("sfxVol"))
        self.sfxActive = settings.get("sfxVol") > 0.0
        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.snapshotSfx = base.loadSfx('phase_4/audio/sfx/Photo_shutter.ogg')
        self.flashTrack = None
        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()

        # 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('panda3d-render-error', self.panda3dRenderError)
        oldLoader = self.loader
        self.loader = ToontownLoader.ToontownLoader(self)
        __builtins__['loader'] = self.loader

        self.asyncLoader = ToontownAsyncLoader.ToontownAsyncLoader(self)
        __builtins__['asyncloader'] = self.asyncLoader

        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.mouseWatcherNode.setEnterPattern('mouse-enter-%r')
        self.mouseWatcherNode.setLeavePattern('mouse-leave-%r')
        self.mouseWatcherNode.setButtonDownPattern('button-down-%r')
        self.mouseWatcherNode.setButtonUpPattern('button-up-%r')
        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)
        textShadow = TextProperties()
        textShadow.setShadow(.01)
        textShadow.setTextColor(0.8, 0.4, 0.0, 1)
        tpMgr.setProperties('textShadow', textShadow)
        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.wantCustomControls = settings.get('want-Custom-Controls', False)

        self.MOVE_UP = 'arrow_up'
        self.MOVE_DOWN = 'arrow_down'
        self.MOVE_LEFT = 'arrow_left'
        self.MOVE_RIGHT = 'arrow_right'
        self.JUMP = 'control'
        self.ACTION_BUTTON = 'delete'
        self.SCREENSHOT_KEY = 'f9'
        keymap = settings.get('keymap', {})
        if self.wantCustomControls:
            self.MOVE_UP = keymap.get('MOVE_UP', self.MOVE_UP)
            self.MOVE_DOWN = keymap.get('MOVE_DOWN', self.MOVE_DOWN)
            self.MOVE_LEFT = keymap.get('MOVE_LEFT', self.MOVE_LEFT)
            self.MOVE_RIGHT = keymap.get('MOVE_RIGHT', self.MOVE_RIGHT)
            self.JUMP = keymap.get('JUMP', self.JUMP)
            self.ACTION_BUTTON = keymap.get('ACTION_BUTTON',
                                            self.ACTION_BUTTON)
            self.SCREENSHOT_KEY = keymap.get('SCREENSHOT_KEY',
                                             self.SCREENSHOT_KEY)
            ToontownGlobals.OptionsPageHotkey = keymap.get(
                'OPTIONS-PAGE', ToontownGlobals.OptionsPageHotkey)

        self.CHAT_HOTKEY = keymap.get('CHAT_HOTKEY', 'r')

        self.accept(
            self.SCREENSHOT_KEY, self.takeScreenShot
        )  # TODO: Make the game ignore this and then re-accept it on a new key if it is rebinded

        self.Widescreen = settings.get('Widescreen', 0)

        self.currentScale = settings.get('texture-scale', 1.0)
        self.setTextureScale()
        self.setRatio()

        self.showDisclaimer = settings.get(
            'show-disclaimer', True
        )  # Show this the first time the user starts the game, it is set in the settings to False once they pick a toon

        self.lodMaxRange = 750
        self.lodMinRange = 5
        self.lodDelayFactor = 0.4

        # enable this feature, if you have render pipeline installed
        if config.GetBool('want-pipeline-renderer', False):
            from rpcore import RenderPipeline, SpotLight
            self.loadPipeline()
예제 #12
0
    def __init__(self):
        if not config.GetInt('ignore-user-options', 0):
            self.settings = ToontownSettings.ToontownSettings()
            self.loadFromSettings()
        else:
            self.settings = None
        OTPBase.OTPBase.__init__(self)
        if self.config.GetBool('software-mode', 0):
            self.makeAllPipes()
            for pipe in self.pipeList:
                if pipe.getInterfaceName() == 'TinyPanda':
                    if base.pipe == pipe:
                        return
                    base.pipe = pipe
                    self.openMainWindow()
                    break

        if not self.isMainWindowOpen():
            try:
                launcher.setPandaErrorCode(7)
            except:
                pass

            sys.exit(1)
        self.disableShowbaseMouse()
        self.addCullBins()
        base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor
        self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1)
        self.textToSpeech = self.config.GetBool('text-to-speech', 0)
        if sys.platform == 'win32':
            if platform.machine().endswith('64'):
                programFiles = os.environ['PROGRAMFILES(x86)']
            else:
                programFiles = os.environ['PROGRAMFILES']
            self.defaultTextToSpeechPath = programFiles + '\\eSpeak\\command_line\\espeak'
        elif sys.platform == 'linux2':
            self.defaultTextToSpeechPath = '/usr/bin/espeak'
        else:
            self.defaultTextToSpeechPath = ''
        self.textToSpeechPath = self.defaultTextToSpeechPath
        self.globalChatWhispers = self.config.GetBool('global-chat-whispers',
                                                      1)
        self.chatLogOpen = self.config.GetBool('chat-log-open', False)
        self.placeBeforeObjects = self.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.setMinFov(ToontownGlobals.DefaultCameraFov / (4.0 / 3.0))
        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.screenshotSfx = base.loader.loadSfx(
            'phase_4/audio/sfx/Photo_shutter.ogg')
        self.screenshotSeq = Sequence()
        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)
        self.accept('panda3d-render-error', self.panda3dRenderError)
        self.gamemode = self.settings.getInt('game', 'gamemode', 0)
        if self.gamemode > 2 or self.gamemode < 0:
            self.gamemode = 0
        self.classicVisuals = self.settings.getInt('game', 'classic-visuals',
                                                   0)
        if self.classicVisuals == 0 or self.classicVisuals > 3 or self.classicVisuals < 0:
            self.classicVisuals = self.gamemode
        else:
            self.classicVisuals -= 1
        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.oldX = max(1, base.win.getXSize())
        self.oldY = max(1, base.win.getYSize())
        self.aspectRatio = float(self.oldX) / self.oldY
        self.nametagsHidden = False
        self.accept('f2', self.toggleNametags)
        self.accept('f3', self.toggleAspect2D)
        self.accept('f4', self.toggleOobe)
        return