Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. import gc
  3. import os
  4.  
  5. gc.disable()
  6.  
  7. os.environ['TTS_PLAYCOOKIE'] = os.environ["TTD_PLAYCOOKIE"]
  8. os.environ['TTS_GAMESERVER'] = os.environ["TTD_GAMESERVER"]
  9.  
  10. import __builtin__
  11.  
  12. __builtin__.process = 'client'
  13.  
  14. import sys, os
  15. sys.path.append(
  16. os.path.abspath(
  17. os.path.join(
  18. os.path.dirname(__file__),
  19. "../../dependencies"
  20. )
  21. )
  22. )
  23.  
  24. # Temporary hack patch:
  25. __builtin__.__dict__.update(__import__('pandac.PandaModules', fromlist=['*']).__dict__)
  26.  
  27.  
  28. from panda3d.core import loadPrcFile
  29.  
  30. if not os.path.exists('user/'):
  31. os.mkdir('user/')
  32.  
  33.  
  34. if __debug__:
  35. try:
  36. import wx
  37. except:
  38. import wxversion
  39. wxversion.select('3.0')
  40. import wx
  41. import sys
  42. from direct.stdpy import threading
  43.  
  44. loadPrcFile('dependencies/config/general.prc')
  45. loadPrcFile('dependencies/config/release/dev.prc')
  46.  
  47. if os.path.isfile('dependencies/config/local.prc'):
  48. loadPrcFile('dependencies/config/local.prc')
  49.  
  50. from direct.directnotify.DirectNotifyGlobal import directNotify
  51.  
  52. notify = directNotify.newCategory('ToontownStart')
  53. notify.setInfo(True)
  54.  
  55. if __debug__:
  56. # The VirtualFileSystem, which has already initialized, doesn't see the mount
  57. # directives in the config(s) yet. We have to force it to load those manually:
  58. from panda3d.core import VirtualFileSystem, ConfigVariableList, Filename
  59. vfs = VirtualFileSystem.getGlobalPtr()
  60. mounts = ConfigVariableList('vfs-mount')
  61. for mount in mounts:
  62. mountfile, mountpoint = (mount.split(' ', 2) + [None, None, None])[:2]
  63. vfs.mount(Filename(mountfile), Filename(mountpoint), 0)
  64.  
  65. from otp.settings.Settings import Settings
  66. from otp.otpbase import OTPGlobals
  67.  
  68. preferencesFilename = ConfigVariableString(
  69. 'preferences-filename',
  70. 'user/preferences.json'
  71. ).getValue()
  72.  
  73. notify.info('Reading %s...' % preferencesFilename)
  74.  
  75. __builtin__.settings = Settings(preferencesFilename)
  76. if 'res' not in settings:
  77. settings['res'] = (1280, 720)
  78. if 'fullscreen' not in settings:
  79. settings['fullscreen'] = False
  80. if 'musicVol' not in settings:
  81. settings['musicVol'] = 1.0
  82. if 'sfxVol' not in settings:
  83. settings['sfxVol'] = 1.0
  84. if 'loadDisplay' not in settings:
  85. settings['loadDisplay'] = 'pandagl'
  86. if 'toonChatSounds' not in settings:
  87. settings['toonChatSounds'] = True
  88. if 'language' not in settings:
  89. settings['language'] = 'English'
  90. if 'cogInterface' not in settings:
  91. settings['cogInterface'] = True
  92. if 'speedchatPlus' not in settings:
  93. settings['speedchatPlus'] = True
  94. if 'trueFriends' not in settings:
  95. settings['trueFriends'] = True
  96. if 'tpTransition' not in settings:
  97. settings['tpTransition'] = True
  98. if 'fov' not in settings:
  99. settings['fov'] = OTPGlobals.DefaultCameraFov
  100. if 'talk2speech' not in settings:
  101. settings['talk2speech'] = False
  102. if 'fpsMeter' not in settings:
  103. settings['fpsMeter'] = False
  104.  
  105. loadPrcFileData('Settings: res', 'win-size %d %d' % tuple(settings['res']))
  106. loadPrcFileData('Settings: fullscreen', 'fullscreen %s' % settings['fullscreen'])
  107. loadPrcFileData('Settings: musicVol', 'audio-master-music-volume %s' % settings['musicVol'])
  108. loadPrcFileData('Settings: sfxVol', 'audio-master-sfx-volume %s' % settings['sfxVol'])
  109. loadPrcFileData('Settings: loadDisplay', 'load-display %s' % settings['loadDisplay'])
  110.  
  111. import time
  112. import sys
  113. import random
  114. import __builtin__
  115. from toontown.launcher.TTSLauncher import TTSLauncher
  116.  
  117. __builtin__.launcher = TTSLauncher()
  118.  
  119. notify.info('Starting the game...')
  120. tempLoader = Loader()
  121. backgroundNode = tempLoader.loadSync(Filename('phase_3/models/gui/loading-background'))
  122. from direct.gui import DirectGuiGlobals
  123. from direct.gui.DirectGui import *
  124. notify.info('Setting the default font...')
  125. import ToontownGlobals
  126. DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont)
  127. import ToonBase
  128. ToonBase.ToonBase()
  129. from panda3d.core import *
  130. if base.win is None:
  131. notify.error('Unable to open window; aborting.')
  132. ConfigVariableDouble('decompressor-step-time').setValue(0.01)
  133. ConfigVariableDouble('extractor-step-time').setValue(0.01)
  134. backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
  135. backgroundNodePath.setPos(0.0, 0.0, 0.0)
  136. backgroundNodePath.setScale(render2d, VBase3(1))
  137. backgroundNodePath.find('**/fg').hide()
  138. logo = OnscreenImage(
  139. image='phase_3/maps/toontown-logo.png',
  140. scale=(1 / (4.0/3.0), 1, 1 / (4.0/3.0)),
  141. pos=backgroundNodePath.find('**/fg').getPos())
  142. logo.setTransparency(TransparencyAttrib.MAlpha)
  143. logo.setBin('fixed', 20)
  144. logo.reparentTo(backgroundNodePath)
  145. backgroundNodePath.find('**/bg').setBin('fixed', 10)
  146. base.graphicsEngine.renderFrame()
  147. DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
  148. DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
  149. DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel('phase_3/models/gui/dialog_box_gui'))
  150. import TTLocalizer
  151. if base.musicManagerIsValid:
  152. music = base.loadMusic('phase_3/audio/bgm/tt_theme.ogg')
  153. if music:
  154. music.setLoop(1)
  155. music.play()
  156. notify.info('Loading the default GUI sounds...')
  157. DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
  158. DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
  159. else:
  160. music = None
  161. import ToontownLoader
  162. from direct.gui.DirectGui import *
  163. serverVersion = base.config.GetString('server-version', 'no_version_set')
  164. version = OnscreenText(serverVersion, pos=(-1.3, -0.975), scale=0.06, fg=Vec4(0, 0, 1, 0.6), align=TextNode.ALeft)
  165. version.setPos(0.03,0.03)
  166. version.reparentTo(base.a2dBottomLeft)
  167. from toontown.suit import Suit
  168. Suit.loadModels()
  169. loader.beginBulkLoad('init', TTLocalizer.LoaderLabel, 138, 0, TTLocalizer.TIP_NONE, 0)
  170. from ToonBaseGlobal import *
  171. from direct.showbase.MessengerGlobal import *
  172. from toontown.distributed import ToontownClientRepository
  173. cr = ToontownClientRepository.ToontownClientRepository(serverVersion)
  174. cr.music = music
  175. del music
  176. base.initNametagGlobals()
  177. base.setFrameRateMeter(settings['fpsMeter'])
  178. base.cr = cr
  179. loader.endBulkLoad('init')
  180. from otp.friends import FriendManager
  181. from otp.distributed.OtpDoGlobals import *
  182. cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager')
  183. base.startShow(cr)
  184. backgroundNodePath.reparentTo(hidden)
  185. backgroundNodePath.removeNode()
  186. del backgroundNodePath
  187. del backgroundNode
  188. del tempLoader
  189. version.cleanup()
  190. del version
  191. base.loader = base.loader
  192. __builtin__.loader = base.loader
  193. autoRun = ConfigVariableBool('toontown-auto-run', 1)
  194.  
  195. gc.enable()
  196. gc.collect()
  197.  
  198. if autoRun:
  199. try:
  200. base.run()
  201. except SystemExit:
  202. pass
  203. except:
  204. import traceback
  205. traceback.print_exc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement