Poodletooth-iLand/toontown/toonbase/ClientStart.py

201 lines
6.8 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
#!/usr/bin/env python2
import __builtin__
__builtin__.process = 'client'
2015-05-29 05:03:48 -05:00
import sys, os
sys.path.append(
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"../../dependencies"
)
)
)
2015-03-03 16:10:12 -06:00
# Temporary hack patch:
__builtin__.__dict__.update(__import__('pandac.PandaModules', fromlist=['*']).__dict__)
from direct.extensions_native import HTTPChannel_extensions
from direct.extensions_native import Mat3_extensions
from direct.extensions_native import VBase3_extensions
from direct.extensions_native import VBase4_extensions
from direct.extensions_native import NodePath_extensions
2015-03-03 16:10:12 -06:00
from panda3d.core import loadPrcFile
2015-03-03 16:10:12 -06:00
if __debug__:
2015-03-15 10:24:57 -05:00
import wx, sys
from direct.stdpy import threading
2015-05-29 05:03:48 -05:00
loadPrcFile('dependencies/config/general.prc')
loadPrcFile('dependencies/config/release/dev.prc')
2015-06-05 00:05:01 -05:00
2015-05-31 15:08:46 -05:00
if os.path.isfile('dependencies/config/local.prc'):
loadPrcFile('dependencies/config/local.prc')
2015-03-03 16:10:12 -06:00
defaultText = ""
2015-03-06 06:08:02 -06:00
def __inject_wx(_):
code = textbox.GetValue()
exec(code, globals())
def openInjector_wx():
app = wx.App(redirect=False)
frame = wx.Frame(None, title="Injector", size=(640, 400), style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX)
panel = wx.Panel(frame)
button = wx.Button(parent=panel, id=-1, label="Inject", size=(50, 20), pos=(295, 0))
global textbox
textbox = wx.TextCtrl(parent=panel, id=-1, pos=(20, 22), size=(600, 340), style=wx.TE_MULTILINE)
frame.Bind(wx.EVT_BUTTON, __inject_wx, button)
frame.Show()
app.SetTopWindow(frame)
textbox.AppendText(defaultText)
threading.Thread(target=app.MainLoop).start()
openInjector_wx()
2015-03-03 16:10:12 -06:00
from direct.directnotify.DirectNotifyGlobal import directNotify
notify = directNotify.newCategory('ClientStart')
notify.setInfo(True)
from otp.settings.Settings import Settings
preferencesFilename = ConfigVariableString(
2015-05-29 05:03:48 -05:00
'preferences-filename',
'user/preferences.json'
).getValue()
2015-03-03 16:10:12 -06:00
notify.info('Reading %s...' % preferencesFilename)
2015-05-29 05:03:48 -05:00
2015-03-03 16:10:12 -06:00
__builtin__.settings = Settings(preferencesFilename)
2015-05-29 05:03:48 -05:00
if 'res' not in settings:
settings['res'] = (1280, 720)
2015-03-03 16:10:12 -06:00
if 'fullscreen' not in settings:
settings['fullscreen'] = False
if 'music' not in settings:
settings['music'] = True
if 'sfx' not in settings:
settings['sfx'] = True
if 'musicVol' not in settings:
settings['musicVol'] = 1.0
if 'sfxVol' not in settings:
settings['sfxVol'] = 1.0
if 'loadDisplay' not in settings:
settings['loadDisplay'] = 'pandagl'
if 'toonChatSounds' not in settings:
settings['toonChatSounds'] = True
2015-03-13 10:02:14 -05:00
if 'language' not in settings:
settings['language'] = 'English'
if 'cogInterface' not in settings:
settings['cogInterface'] = True
2015-04-06 07:48:06 -05:00
if 'speedchatPlus' not in settings:
settings['speedchatPlus'] = True
if 'trueFriends' not in settings:
settings['trueFriends'] = True
2015-05-29 05:03:48 -05:00
loadPrcFileData('Settings: res', 'win-size %d %d' % tuple(settings['res']))
2015-03-03 16:10:12 -06:00
loadPrcFileData('Settings: fullscreen', 'fullscreen %s' % settings['fullscreen'])
loadPrcFileData('Settings: music', 'audio-music-active %s' % settings['music'])
loadPrcFileData('Settings: sfx', 'audio-sfx-active %s' % settings['sfx'])
loadPrcFileData('Settings: musicVol', 'audio-master-music-volume %s' % settings['musicVol'])
loadPrcFileData('Settings: sfxVol', 'audio-master-sfx-volume %s' % settings['sfxVol'])
loadPrcFileData('Settings: loadDisplay', 'load-display %s' % settings['loadDisplay'])
import time
import sys
import random
import __builtin__
2015-05-16 20:04:41 -05:00
from toontown.launcher.TTSLauncher import TTSLauncher
2015-03-03 16:10:12 -06:00
2015-05-16 20:04:41 -05:00
__builtin__.launcher = TTSLauncher()
2015-03-03 16:10:12 -06:00
notify.info('Starting the game...')
tempLoader = Loader()
backgroundNode = tempLoader.loadSync(Filename('phase_3/models/gui/loading-background'))
from direct.gui import DirectGuiGlobals
from direct.gui.DirectGui import *
notify.info('Setting the default font...')
import ToontownGlobals
DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont)
import ToonBase
ToonBase.ToonBase()
from pandac.PandaModules import *
if base.win is None:
notify.error('Unable to open window; aborting.')
ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/fg').hide()
logo = OnscreenImage(
image='phase_3/maps/toontown-logo.png',
scale=(1 / (4.0/3.0), 1, 1 / (4.0/3.0)),
pos=backgroundNodePath.find('**/fg').getPos())
logo.setTransparency(TransparencyAttrib.MAlpha)
logo.setBin('fixed', 20)
logo.reparentTo(backgroundNodePath)
backgroundNodePath.find('**/bg').setBin('fixed', 10)
base.graphicsEngine.renderFrame()
DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel('phase_3/models/gui/dialog_box_gui'))
import TTLocalizer
from otp.otpbase import OTPGlobals
if base.musicManagerIsValid:
music = base.loadMusic('phase_3/audio/bgm/tt_theme.ogg')
if music:
music.setLoop(1)
music.play()
notify.info('Loading the default GUI sounds...')
DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
else:
music = None
import ToontownLoader
from direct.gui.DirectGui import *
serverVersion = base.config.GetString('server-version', 'no_version_set')
2015-05-07 19:39:04 -05:00
version = OnscreenText(serverVersion, pos=(-1.3, -0.975), scale=0.06, fg=Vec4(0, 0, 1, 0.6), align=TextNode.ALeft)
2015-03-03 16:10:12 -06:00
version.setPos(0.03,0.03)
version.reparentTo(base.a2dBottomLeft)
from toontown.suit import Suit
Suit.loadModels()
loader.beginBulkLoad('init', TTLocalizer.LoaderLabel, 138, 0, TTLocalizer.TIP_NONE, 0)
from ToonBaseGlobal import *
from direct.showbase.MessengerGlobal import *
from toontown.distributed import ToontownClientRepository
cr = ToontownClientRepository.ToontownClientRepository(serverVersion)
2015-03-03 16:10:12 -06:00
cr.music = music
del music
base.initNametagGlobals()
base.cr = cr
loader.endBulkLoad('init')
from otp.friends import FriendManager
from otp.distributed.OtpDoGlobals import *
cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager')
base.startShow(cr)
2015-03-03 16:10:12 -06:00
backgroundNodePath.reparentTo(hidden)
backgroundNodePath.removeNode()
del backgroundNodePath
del backgroundNode
del tempLoader
version.cleanup()
del version
base.loader = base.loader
__builtin__.loader = base.loader
autoRun = ConfigVariableBool('toontown-auto-run', 1)
if autoRun:
try:
base.run()
2015-03-03 16:10:12 -06:00
except SystemExit:
raise
except:
from toontown.toonbase import PythonUtil
2015-03-03 16:10:12 -06:00
print PythonUtil.describeException()
raise