diff --git a/dev/tools/gui/EditorStart.py b/dev/tools/gui/EditorStart.py index ceb39fb0..d719a702 100644 --- a/dev/tools/gui/EditorStart.py +++ b/dev/tools/gui/EditorStart.py @@ -1,7 +1,16 @@ from direct.stdpy import threading from direct.showbase.ShowBase import ShowBase from panda3d.core import VirtualFileSystem -import __builtin__, wx, os +import __builtin__, wx, os, sys + +sys.path.append( + os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "../../../" + ) + ) +) __builtin__.__dict__.update(__import__('pandac.PandaModules', fromlist=['*']).__dict__) @@ -9,25 +18,31 @@ loadPrcFile('dependencies/config/guieditor.prc') loadPrcFile('dependencies/config/general.prc') defaultText = """from pandac.PandaModules import * +from direct.gui import DirectGuiGlobals from direct.gui.DirectGui import * +from toontown.toonbase import ToontownGlobals +DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont) +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')) """ -def inject(_): - code = textbox.GetValue() - exec(code, globals()) +exec( + "from %s import %s as imported" % \ + ( + '.'.join( + sys.argv[1].split('.')[:-1] + ), + sys.argv[1].split('.')[-1] + ) +) -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)) -textbox = wx.TextCtrl(parent=panel, id=-1, pos=(20, 22), size=(600, 340), style=wx.TE_MULTILINE) - -frame.Bind(wx.EVT_BUTTON, inject, button) -frame.Show() -app.SetTopWindow(frame) -textbox.AppendText(defaultText) -threading.Thread(target=app.MainLoop).start() +if hasattr(imported, 'GUI_EDITOR'): + defaultText += imported.GUI_EDITOR __builtin__.base = ShowBase() + +exec(defaultText) + base.run() diff --git a/dev/tools/gui/start-gui-editor.bat b/dev/tools/gui/start-gui-editor.bat index 10d0be24..5a5ac9c5 100644 --- a/dev/tools/gui/start-gui-editor.bat +++ b/dev/tools/gui/start-gui-editor.bat @@ -1,5 +1,16 @@ @echo off + cd ../../../ + title GUI Editor -"dependencies/panda/python/ppython.exe" "dev/tools/gui/EditorStart.py" -pause +set GUI= + +:main + +set /P GUI="File: %gui%" +"dependencies/panda/python/ppython.exe" "dev/tools/gui/EditorStart.py" %GUI% + +echo. +echo. + +goto main \ No newline at end of file diff --git a/toontown/coghq/BossLobbyGui.py b/toontown/coghq/BossLobbyGui.py index 223bd26a..2a7d59b5 100644 --- a/toontown/coghq/BossLobbyGui.py +++ b/toontown/coghq/BossLobbyGui.py @@ -120,18 +120,9 @@ class BossLobbyGui(DirectFrame): elif lobby == 1: self.callback(self.avatar, True) -# Use the following to run with the Gui Editor. -""" -from pandac.PandaModules import * -from direct.gui import DirectGuiGlobals -from direct.gui.DirectGui import * +# The following is made for use with the GUI editor. +GUI_EDITOR = """ from toontown.coghq.BossLobbyGui import BossLobbyGui -from toontown.toonbase import ToontownGlobals - -DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont) -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')) test = BossLobbyGui(None, None) """