comparison clients/editor/run.py @ 255:51cc05d862f2

Merged editor_rewrite branch to trunk. This contains changes that may break compatibility against existing clients. For a list of changes that may affect your client, see: http://wiki.fifengine.de/Changes_to_pychan_and_FIFE_in_editor_rewrite_branch
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 08 Jun 2009 16:00:02 +0000
parents bcc93e17f978
children 8b125ec749d7
comparison
equal deleted inserted replaced
254:10b5f7f36dd4 255:51cc05d862f2
11 for p in _paths: 11 for p in _paths:
12 if p not in sys.path: 12 if p not in sys.path:
13 sys.path.append(_jp(p)) 13 sys.path.append(_jp(p))
14 14
15 import fife 15 import fife
16 import fifelog
17 import basicapplication 16 import basicapplication
18 import pychan 17 import scripts
19 import pychan.widgets as widgets 18 from scripts.editor import Editor
20 import sys
21
22 from listener import EditorListener
23
24 from plugins.plugin import Plugin
25 from plugins.maploader import MapLoader
26 from plugins.maploader import MapSaver
27 from plugins.importer import Importer
28 from plugins.mapeditor import MapEditor
29 from plugins.mapwizard import MapWizard
30 from fifedit import Fifedit
31
32 # zero-projekt plugins
33 from plugins.objectedit import ObjectEdit
34 from plugins.layertool import LayerTool
35
36
37 # Help display
38 class Help(Plugin):
39 def __init__(self):
40 self._helpWidget = None
41 self.menu_items = { 'Help' : self.showHelp }
42
43 def showHelp(self):
44 if self._helpWidget:
45 self._helpWidget.show()
46 return
47 self._helpWidget = pychan.loadXML('gui/help.xml')
48 self._helpWidget.mapEvents({ 'closeButton' : self._helpWidget.hide })
49 self._helpWidget.distributeData({ 'helpText' : open("misc/infotext.txt").read() })
50 self._helpWidget.show()
51
52 class Editor(basicapplication.ApplicationBase):
53 def __init__(self, params):
54 super(Editor,self).__init__()
55
56 # embed Fifedit tools
57 self.fifedit = Fifedit(self.engine)
58
59 # Create this client's modules
60 self.mapedit = MapEditor(self.engine)
61 self.maploader = MapLoader(self.engine)
62 self.mapsaver = MapSaver(self.engine)
63 self.mapwizard = MapWizard(self.engine)
64 self.importer = Importer(self.engine)
65
66 # zero-projekt plugins
67 self.objectedit = ObjectEdit(self.engine, self.mapedit)
68 self.layertool = LayerTool(self.engine, self.mapedit)
69
70 # Register plugins with Fifedit.
71 self.fifedit.registerPlugin(Help())
72 self.fifedit.registerPlugin(self.maploader)
73 self.fifedit.registerPlugin(self.mapsaver)
74 self.fifedit.registerPlugin(self.mapedit)
75 self.fifedit.registerPlugin(self.mapwizard)
76 self.fifedit.registerPlugin(self.importer)
77
78 # zero-projekt plugins
79 self.fifedit.registerPlugin(self.objectedit)
80 self.fifedit.registerPlugin(self.layertool)
81
82 self.params = params
83
84 def createListener(self):
85 # override default event listener
86 return EditorListener(self)
87
88 def _pump(self):
89 self.mapedit.pump()
90 if self.maploader.newMap:
91 self.mapedit.editMap(self.maploader.newMap.getId())
92 self.importer.addDirs(self.maploader.newMap.importDirs)
93 self.maploader.newMap = None
94 if self.mapwizard.newMap:
95 self.mapedit.editMap(self.mapwizard.map.getId())
96 self.mapwizard.newMap = False
97 if self.mapsaver.saveRequested:
98 if self.mapedit._map:
99 self.mapsaver.saveMap(self.mapedit._map,self.importer.importList)
100 else:
101 print "Cannot save, map doesn't exist"
102 self.mapsaver.saveRequested = False
103 if not self.fifedit.active:
104 self.quitRequested = True
105 if self.params:
106 s = os.path.sep
107 parts = self.params.split(s)
108 self.maploader.loadFile(s.join(parts[0:-1]), parts[-1])
109 self.params = None
110
111 # zero-projekt plugins
112 if self.mapedit._instances is not None:
113 self.objectedit.input()
114
115 19
116 if __name__ == '__main__': 20 if __name__ == '__main__':
117 print sys.argv 21 print sys.argv
118 params = None 22 params = None
119 if len(sys.argv) > 1: 23 if len(sys.argv) > 1: