Merge branch 'develop' of github.com:open-toontown/open-toontown into develop
This commit is contained in:
commit
e193383493
8 changed files with 67 additions and 130 deletions
|
@ -1,2 +1 @@
|
||||||
from panda3d.otp import *
|
from panda3d.otp import *
|
||||||
from .settings.Settings import Settings
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
class Settings:
|
|
||||||
GL = 0
|
|
||||||
DX7 = 1
|
|
||||||
DX8 = 5
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def readSettings():
|
|
||||||
pass # todo
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def writeSettings():
|
|
||||||
pass # lol not yet
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setWindowedMode(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getWindowedMode():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setMusic(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getMusic():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setSfx(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getSfx():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setToonChatSounds(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getToonChatSounds():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setResolutionDimensions(_, __):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getResolution():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setEmbeddedMode(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getEmbeddedMode():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def doSavedSettingsExist():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setAcceptingNewFriends(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getAcceptingNewFriends():
|
|
||||||
return 1
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setAcceptingNonFriendWhispers(_):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def getAcceptingNonFriendWhispers():
|
|
||||||
return 1
|
|
34
otp/settings/Settings.py
Normal file
34
otp/settings/Settings.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class Settings:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.__settings = {}
|
||||||
|
self.__filename = 'useropt.json'
|
||||||
|
|
||||||
|
def doSavedSettingsExist(self):
|
||||||
|
return os.path.exists(self.__filename)
|
||||||
|
|
||||||
|
def readSettings(self):
|
||||||
|
if not self.doSavedSettingsExist():
|
||||||
|
self.__settings = {}
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(self.__filename, 'r') as f:
|
||||||
|
self.__settings = json.load(f)
|
||||||
|
except:
|
||||||
|
self.__settings = {}
|
||||||
|
|
||||||
|
def writeSettings(self):
|
||||||
|
with open(self.__filename, 'w+') as f:
|
||||||
|
json.dump(self.__settings, f, indent=4)
|
||||||
|
|
||||||
|
def updateSetting(self, setting, value):
|
||||||
|
self.__settings[setting] = value
|
||||||
|
|
||||||
|
def getSetting(self, setting, default=None):
|
||||||
|
result = self.__settings.get(setting, default)
|
||||||
|
return result
|
|
@ -1,9 +1,7 @@
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from libotp import *
|
|
||||||
from . import ShtikerPage
|
from . import ShtikerPage
|
||||||
from toontown.toontowngui import TTDialog
|
from toontown.toontowngui import TTDialog
|
||||||
from direct.gui.DirectGui import *
|
from direct.gui.DirectGui import *
|
||||||
from pandac.PandaModules import *
|
|
||||||
from toontown.toonbase import TTLocalizer
|
from toontown.toonbase import TTLocalizer
|
||||||
from . import DisplaySettingsDialog
|
from . import DisplaySettingsDialog
|
||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
|
@ -12,7 +10,6 @@ from otp.speedchat import SCColorScheme
|
||||||
from otp.speedchat import SCStaticTextTerminal
|
from otp.speedchat import SCStaticTextTerminal
|
||||||
from direct.showbase import PythonUtil
|
from direct.showbase import PythonUtil
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from toontown.toonbase import ToontownGlobals
|
|
||||||
speedChatStyles = ((2000,
|
speedChatStyles = ((2000,
|
||||||
(200 / 255.0, 60 / 255.0, 229 / 255.0),
|
(200 / 255.0, 60 / 255.0, 229 / 255.0),
|
||||||
(200 / 255.0, 135 / 255.0, 255 / 255.0),
|
(200 / 255.0, 135 / 255.0, 255 / 255.0),
|
||||||
|
@ -123,9 +120,6 @@ class OptionsTabPage(DirectFrame):
|
||||||
DisplaySettingsDelay = 60
|
DisplaySettingsDelay = 60
|
||||||
ChangeDisplaySettings = base.config.GetBool('change-display-settings', 1)
|
ChangeDisplaySettings = base.config.GetBool('change-display-settings', 1)
|
||||||
ChangeDisplayAPI = base.config.GetBool('change-display-api', 0)
|
ChangeDisplayAPI = base.config.GetBool('change-display-api', 0)
|
||||||
DisplaySettingsApiMap = {'OpenGL': Settings.GL,
|
|
||||||
'DirectX7': Settings.DX7,
|
|
||||||
'DirectX8': Settings.DX8}
|
|
||||||
|
|
||||||
def __init__(self, parent = aspect2d):
|
def __init__(self, parent = aspect2d):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
@ -217,7 +211,7 @@ class OptionsTabPage(DirectFrame):
|
||||||
self.ignore('confirmDone')
|
self.ignore('confirmDone')
|
||||||
self.hide()
|
self.hide()
|
||||||
if self.settingsChanged != 0:
|
if self.settingsChanged != 0:
|
||||||
Settings.writeSettings()
|
base.settings.writeSettings()
|
||||||
self.speedChatStyleText.exit()
|
self.speedChatStyleText.exit()
|
||||||
if self.displaySettingsChanged:
|
if self.displaySettingsChanged:
|
||||||
taskMgr.doMethodLater(self.DisplaySettingsDelay, self.writeDisplaySettings, self.DisplaySettingsTaskName)
|
taskMgr.doMethodLater(self.DisplaySettingsDelay, self.writeDisplaySettings, self.DisplaySettingsTaskName)
|
||||||
|
@ -259,10 +253,10 @@ class OptionsTabPage(DirectFrame):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
if base.musicActive:
|
if base.musicActive:
|
||||||
base.enableMusic(0)
|
base.enableMusic(0)
|
||||||
Settings.setMusic(0)
|
base.settings.updateSetting('music', False)
|
||||||
else:
|
else:
|
||||||
base.enableMusic(1)
|
base.enableMusic(1)
|
||||||
Settings.setMusic(1)
|
base.settings.updateSetting('music', True)
|
||||||
self.settingsChanged = 1
|
self.settingsChanged = 1
|
||||||
self.__setMusicButton()
|
self.__setMusicButton()
|
||||||
|
|
||||||
|
@ -278,10 +272,10 @@ class OptionsTabPage(DirectFrame):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
if base.sfxActive:
|
if base.sfxActive:
|
||||||
base.enableSoundEffects(0)
|
base.enableSoundEffects(0)
|
||||||
Settings.setSfx(0)
|
base.settings.updateSetting('sfx', False)
|
||||||
else:
|
else:
|
||||||
base.enableSoundEffects(1)
|
base.enableSoundEffects(1)
|
||||||
Settings.setSfx(1)
|
base.settings.updateSetting('sfx', True)
|
||||||
self.settingsChanged = 1
|
self.settingsChanged = 1
|
||||||
self.__setSoundFXButton()
|
self.__setSoundFXButton()
|
||||||
|
|
||||||
|
@ -289,10 +283,10 @@ class OptionsTabPage(DirectFrame):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
if base.toonChatSounds:
|
if base.toonChatSounds:
|
||||||
base.toonChatSounds = 0
|
base.toonChatSounds = 0
|
||||||
Settings.setToonChatSounds(0)
|
base.settings.updateSetting('toon-chat-sounds', False)
|
||||||
else:
|
else:
|
||||||
base.toonChatSounds = 1
|
base.toonChatSounds = 1
|
||||||
Settings.setToonChatSounds(1)
|
base.settings.updateSetting('toon-chat-sounds', True)
|
||||||
self.settingsChanged = 1
|
self.settingsChanged = 1
|
||||||
self.__setToonChatSoundsButton()
|
self.__setToonChatSoundsButton()
|
||||||
|
|
||||||
|
@ -323,10 +317,10 @@ class OptionsTabPage(DirectFrame):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
if base.localAvatar.acceptingNewFriends:
|
if base.localAvatar.acceptingNewFriends:
|
||||||
base.localAvatar.acceptingNewFriends = 0
|
base.localAvatar.acceptingNewFriends = 0
|
||||||
Settings.setAcceptingNewFriends(0)
|
base.settings.updateSetting('accepting-new-friends', False)
|
||||||
else:
|
else:
|
||||||
base.localAvatar.acceptingNewFriends = 1
|
base.localAvatar.acceptingNewFriends = 1
|
||||||
Settings.setAcceptingNewFriends(1)
|
base.settings.updateSetting('accepting-new-friends', True)
|
||||||
self.settingsChanged = 1
|
self.settingsChanged = 1
|
||||||
self.__setAcceptFriendsButton()
|
self.__setAcceptFriendsButton()
|
||||||
|
|
||||||
|
@ -334,10 +328,10 @@ class OptionsTabPage(DirectFrame):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
if base.localAvatar.acceptingNonFriendWhispers:
|
if base.localAvatar.acceptingNonFriendWhispers:
|
||||||
base.localAvatar.acceptingNonFriendWhispers = 0
|
base.localAvatar.acceptingNonFriendWhispers = 0
|
||||||
Settings.setAcceptingNonFriendWhispers(0)
|
base.settings.updateSetting('accepting-non-friend-whispers', False)
|
||||||
else:
|
else:
|
||||||
base.localAvatar.acceptingNonFriendWhispers = 1
|
base.localAvatar.acceptingNonFriendWhispers = 1
|
||||||
Settings.setAcceptingNonFriendWhispers(1)
|
base.settings.updateSetting('accepting-non-friend-whispers', True)
|
||||||
self.settingsChanged = 1
|
self.settingsChanged = 1
|
||||||
self.__setAcceptWhispersButton()
|
self.__setAcceptWhispersButton()
|
||||||
|
|
||||||
|
@ -439,16 +433,16 @@ class OptionsTabPage(DirectFrame):
|
||||||
self.displaySettingsFullscreen,
|
self.displaySettingsFullscreen,
|
||||||
self.displaySettingsEmbedded,
|
self.displaySettingsEmbedded,
|
||||||
self.displaySettingsApi))
|
self.displaySettingsApi))
|
||||||
Settings.setResolutionDimensions(self.displaySettingsSize[0], self.displaySettingsSize[1])
|
base.settings.updateSetting('resolution', (self.displaySettingsSize[0], self.displaySettingsSize[1]))
|
||||||
Settings.setWindowedMode(not self.displaySettingsFullscreen)
|
base.settings.updateSetting('windowed-mode', not self.displaySettingsFullscreen)
|
||||||
Settings.setEmbeddedMode(self.displaySettingsEmbedded)
|
#base.settings.updateSetting('embedded-mode', self.displaySettingsEmbedded)
|
||||||
if self.displaySettingsApiChanged:
|
if self.displaySettingsApiChanged:
|
||||||
api = self.DisplaySettingsApiMap.get(self.displaySettingsApi)
|
api = self.DisplaySettingsApiMap.get(self.displaySettingsApi)
|
||||||
if api == None:
|
if api == None:
|
||||||
self.notify.warning('Cannot save unknown display API: %s' % self.displaySettingsApi)
|
self.notify.warning('Cannot save unknown display API: %s' % self.displaySettingsApi)
|
||||||
else:
|
else:
|
||||||
Settings.setDisplayDriver(api)
|
Settings.setDisplayDriver(api)
|
||||||
Settings.writeSettings()
|
base.settings.writeSettings()
|
||||||
self.displaySettingsChanged = 0
|
self.displaySettingsChanged = 0
|
||||||
return Task.done
|
return Task.done
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ from direct.showbase import PythonUtil
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.gui import DirectGuiGlobals
|
from direct.gui import DirectGuiGlobals
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from libotp import *
|
|
||||||
from otp.avatar import LocalAvatar
|
from otp.avatar import LocalAvatar
|
||||||
from otp.login import LeaveToPayDialog
|
from otp.login import LeaveToPayDialog
|
||||||
from otp.avatar import PositionExaminer
|
from otp.avatar import PositionExaminer
|
||||||
|
@ -163,8 +162,8 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
|
||||||
if not hasattr(base.cr, 'lastLoggedIn'):
|
if not hasattr(base.cr, 'lastLoggedIn'):
|
||||||
base.cr.lastLoggedIn = self.cr.toontownTimeManager.convertStrToToontownTime('')
|
base.cr.lastLoggedIn = self.cr.toontownTimeManager.convertStrToToontownTime('')
|
||||||
self.setLastTimeReadNews(base.cr.lastLoggedIn)
|
self.setLastTimeReadNews(base.cr.lastLoggedIn)
|
||||||
self.acceptingNewFriends = Settings.getAcceptingNewFriends() and base.config.GetBool('accepting-new-friends-default', True)
|
self.acceptingNewFriends = base.settings.getSetting('accepting-new-friends', True) and base.config.GetBool('accepting-new-friends-default', True)
|
||||||
self.acceptingNonFriendWhispers = Settings.getAcceptingNonFriendWhispers() and base.config.GetBool('accepting-non-friend-whispers-default', True)
|
self.acceptingNonFriendWhispers = base.settings.getSetting('accepting-non-friend-whispers', True) and base.config.GetBool('accepting-non-friend-whispers-default', True)
|
||||||
self.physControls.event.addAgainPattern('again%in')
|
self.physControls.event.addAgainPattern('again%in')
|
||||||
self.oldPos = None
|
self.oldPos = None
|
||||||
self.questMap = None
|
self.questMap = None
|
||||||
|
|
|
@ -4,7 +4,6 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
from pandac.PandaModules import loadPrcFileData, WindowProperties
|
from pandac.PandaModules import loadPrcFileData, WindowProperties
|
||||||
from libotp import Settings
|
|
||||||
from otp.otpgui import OTPDialog
|
from otp.otpgui import OTPDialog
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals
|
||||||
from otp.otpbase import OTPRender
|
from otp.otpbase import OTPRender
|
||||||
|
@ -22,25 +21,20 @@ class DisplayOptions:
|
||||||
self.loadFromSettings()
|
self.loadFromSettings()
|
||||||
|
|
||||||
def loadFromSettings(self):
|
def loadFromSettings(self):
|
||||||
Settings.readSettings()
|
base.settings.readSettings()
|
||||||
mode = not Settings.getWindowedMode()
|
mode = not base.settings.getSetting('windowed-mode', True)
|
||||||
music = Settings.getMusic()
|
music = base.settings.getSetting('music', True)
|
||||||
sfx = Settings.getSfx()
|
sfx = base.settings.getSetting('sfx', True)
|
||||||
toonChatSounds = Settings.getToonChatSounds()
|
toonChatSounds = base.settings.getSetting('toon-chat-sounds', True)
|
||||||
resList = [(640, 480),
|
res = base.settings.getSetting('resolution', (800, 600))
|
||||||
(800, 600),
|
embed = False # base.settings.getSetting('embedded-mode', False)
|
||||||
(1024, 768),
|
|
||||||
(1280, 1024),
|
|
||||||
(1600, 1200)]
|
|
||||||
res = resList[Settings.getResolution()]
|
|
||||||
embed = Settings.getEmbeddedMode()
|
|
||||||
self.notify.debug('before prc settings embedded mode=%s' % str(embed))
|
self.notify.debug('before prc settings embedded mode=%s' % str(embed))
|
||||||
self.notify.debug('before prc settings full screen mode=%s' % str(mode))
|
self.notify.debug('before prc settings full screen mode=%s' % str(mode))
|
||||||
if mode == None:
|
if mode == None:
|
||||||
mode = 1
|
mode = 1
|
||||||
if res == None:
|
if res == None:
|
||||||
res = (800, 600)
|
res = (800, 600)
|
||||||
if not Settings.doSavedSettingsExist():
|
if not base.settings.doSavedSettingsExist():
|
||||||
self.notify.info('loadFromSettings: No settings; isDefaultEmbedded=%s' % self.isDefaultEmbedded())
|
self.notify.info('loadFromSettings: No settings; isDefaultEmbedded=%s' % self.isDefaultEmbedded())
|
||||||
embed = self.isDefaultEmbedded()
|
embed = self.isDefaultEmbedded()
|
||||||
if embed and not self.isEmbeddedPossible():
|
if embed and not self.isEmbeddedPossible():
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from otp.otpbase import OTPBase
|
from otp.otpbase import OTPBase
|
||||||
from otp.otpbase import OTPLauncherGlobals
|
from otp.otpbase import OTPLauncherGlobals
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals
|
||||||
|
from otp.settings.Settings import Settings
|
||||||
from direct.showbase.PythonUtil import *
|
from direct.showbase.PythonUtil import *
|
||||||
from . import ToontownGlobals
|
from . import ToontownGlobals
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
|
@ -21,18 +22,14 @@ class ToonBase(OTPBase.OTPBase):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('ToonBase')
|
notify = DirectNotifyGlobal.directNotify.newCategory('ToonBase')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.settings = Settings()
|
||||||
if not config.GetInt('ignore-user-options', 0):
|
if not config.GetInt('ignore-user-options', 0):
|
||||||
Settings.readSettings()
|
self.settings.readSettings()
|
||||||
mode = not Settings.getWindowedMode()
|
mode = not self.settings.getSetting('windowed-mode', True)
|
||||||
music = Settings.getMusic()
|
music = self.settings.getSetting('music', True)
|
||||||
sfx = Settings.getSfx()
|
sfx = self.settings.getSetting('sfx', True)
|
||||||
toonChatSounds = Settings.getToonChatSounds()
|
toonChatSounds = self.settings.getSetting('toon-chat-sounds', True)
|
||||||
resList = [(640, 480),
|
res = self.settings.getSetting('resolution', (800, 600))
|
||||||
(800, 600),
|
|
||||||
(1024, 768),
|
|
||||||
(1280, 1024),
|
|
||||||
(1600, 1200)]
|
|
||||||
res = resList[Settings.getResolution()]
|
|
||||||
if mode == None:
|
if mode == None:
|
||||||
mode = 1
|
mode = 1
|
||||||
if res == None:
|
if res == None:
|
||||||
|
|
Loading…
Reference in a new issue