Sfoglia il codice sorgente

Made LE data can be loaded outside of LE

Gyedo Jeon 16 anni fa
parent
commit
e36c303ce7
2 ha cambiato i file con 9 aggiunte e 10 eliminazioni
  1. 8 9
      direct/src/leveleditor/FileMgr.py
  2. 1 1
      direct/src/leveleditor/testData.py

+ 8 - 9
direct/src/leveleditor/FileMgr.py

@@ -1,23 +1,22 @@
 import os
 import os
 import imp
 import imp
 
 
-from ObjectMgr import ObjectMgr
-from ObjectHandler import ObjectHandler
-from ObjectPalette import ObjectPalette
-
+import ObjectMgr
+import ObjectHandler
+import ObjectPalette
 import ObjectGlobals as OG
 import ObjectGlobals as OG
 
 
 class FileMgr:
 class FileMgr:
     """ To handle data file """
     """ To handle data file """
     
     
-    def __init__(self, editor):
+    def __init__(self, editor=None):
         self.editor = editor
         self.editor = editor
 
 
     def saveToFile(self, fileName):
     def saveToFile(self, fileName):
         try:
         try:
             f = open(fileName, 'w')
             f = open(fileName, 'w')
             f.write("from pandac.PandaModules import *\n")
             f.write("from pandac.PandaModules import *\n")
-            f.write("\nhasattr(base, 'le'):\n")
+            f.write("\nif hasattr(base, 'le'):\n")
             f.write("\tobjectMgr = base.le.objectMgr\n")
             f.write("\tobjectMgr = base.le.objectMgr\n")
             f.write('\tui = base.le.ui\n')
             f.write('\tui = base.le.ui\n')
             f.write('\tui.sceneGraphUI.reset()\n\n')
             f.write('\tui.sceneGraphUI.reset()\n\n')
@@ -46,9 +45,9 @@ class FileMgr:
         file, pathname, description = imp.find_module(moduleName, [dirname])
         file, pathname, description = imp.find_module(moduleName, [dirname])
         try:
         try:
             if self.editor is None: # when loaded outside of LE
             if self.editor is None: # when loaded outside of LE
-                base.objectPalette = ObjectPalette()
-                base.objectHandler = ObjectHandler(None)
-                base.objectMgr = ObjectMgr(None)
+                base.objectPalette = ObjectPalette.ObjectPalette()
+                base.objectHandler = ObjectHandler.ObjectHandler(None)
+                base.objectMgr = ObjectMgr.ObjectMgr(None)
 
 
             module = imp.load_module(moduleName, file, pathname, description)
             module = imp.load_module(moduleName, file, pathname, description)
         except:
         except:

+ 1 - 1
direct/src/leveleditor/testData.py

@@ -1,6 +1,6 @@
 from pandac.PandaModules import *
 from pandac.PandaModules import *
 
 
-hasattr(base, 'le'):
+if hasattr(base, 'le'):
 	objectMgr = base.le.objectMgr
 	objectMgr = base.le.objectMgr
 	ui = base.le.ui
 	ui = base.le.ui
 	ui.sceneGraphUI.reset()
 	ui.sceneGraphUI.reset()