settings: Initial commit
This commit is contained in:
parent
cfa209216c
commit
db25aaf10d
7 changed files with 43 additions and 112 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
|
|
27
otp/settings/Settings.py
Normal file
27
otp/settings/Settings.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
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 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
|
||||||
|
|
|
@ -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', 1)
|
||||||
music = Settings.getMusic()
|
music = base.settings.getSetting('music', 1)
|
||||||
sfx = Settings.getSfx()
|
sfx = base.settings.getSetting('sfx', 1)
|
||||||
toonChatSounds = Settings.getToonChatSounds()
|
toonChatSounds = base.settings.getSetting('toon-chat-sounds', 1)
|
||||||
resList = [(640, 480),
|
res = base.settings.getSetting('resolution', (800, 600))
|
||||||
(800, 600),
|
embed = base.settings.getSetting('embedded-mode', 0)
|
||||||
(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', 1)
|
||||||
music = Settings.getMusic()
|
music = self.settings.getSetting('music', 1)
|
||||||
sfx = Settings.getSfx()
|
sfx = self.settings.getSetting('sfx', 1)
|
||||||
toonChatSounds = Settings.getToonChatSounds()
|
toonChatSounds = self.settings.getSetting('toon-chat-sounds', 1)
|
||||||
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