Mercurial > fife-parpg
annotate clients/editor/scripts/editor.py @ 265:043d71a192b5
* _ListItem in HistoryManager will now return a string object in __str__
* Editor will now print full exception when an exception occurs when opening a file
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 13 Jun 2009 15:08:42 +0000 |
parents | 51cc05d862f2 |
children | e2ac8bb1a22c |
rev | line source |
---|---|
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 from basicapplication import ApplicationBase |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 import pychan |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 import fife |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 import loaders |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 import events |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 import plugin |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 from mapview import MapView |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 from events import EventListener |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 from events import * |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 from gui import ToolBar, action |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 from gui.action import Action, ActionGroup |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 from gui.filemanager import FileManager |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 from gui.mainwindow import MainWindow |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 from gui.mapeditor import MapEditor |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 from gui.menubar import Menu, MenuBar |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 from gui.error import ErrorDialog |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 from settings import Settings |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 from pychan.tools import callbackWithArguments as cbwa |
265
043d71a192b5
* _ListItem in HistoryManager will now return a string object in __str__
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
19 import sys, traceback |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 def getEditor(): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 """ Returns the Global editor instance """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 if Editor.editor is None: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 Editor(None) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 return Editor.editor |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 class Editor(ApplicationBase, MainWindow): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 """ Editor sets up all subsystems and provides access to them """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 editor = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 def __init__(self, params, *args, **kwargs): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 Editor.editor = self |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 self._filemanager = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 self.params = params |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 self._eventlistener = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 self._pluginmanager = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 self._inited = False |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 self._mapview = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 self._mapviewList = [] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 self._mapgroup = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 self._mapbar = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self._maparea = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self._mapeditor = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 self._fileMenu = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 self._editMenu = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._viewMenu = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self._toolsMenu = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self._helpMenu = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 self._settings = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 self._helpDialog = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 ApplicationBase.__init__(self, *args, **kwargs) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 MainWindow.__init__(self, *args, **kwargs) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 pychan.init(self.engine, debug=False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 def loadSettings(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 Load the settings from a python file and load them into the engine. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 Called in the ApplicationBase constructor. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 self._settings = Settings() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 TDS = self._settings |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 glyphDft = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\\\"" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 engineSetting = self.engine.getSettings() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 engineSetting.setDefaultFontGlyphs(TDS.get("FIFE", "FontGlyphs", glyphDft)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 engineSetting.setDefaultFontPath(TDS.get("FIFE", "Font", "fonts/FreeSans.ttf")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 engineSetting.setDefaultFontSize(12) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 engineSetting.setBitsPerPixel(TDS.get("FIFE", "BitsPerPixel", 0)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 engineSetting.setInitialVolume(TDS.get("FIFE", "InitialVolume", 5.0)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 engineSetting.setSDLRemoveFakeAlpha(TDS.get("FIFE", "SDLRemoveFakeAlpha", 1)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 engineSetting.setScreenWidth(TDS.get("FIFE", "ScreenWidth", 1024)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 engineSetting.setScreenHeight(TDS.get("FIFE", "ScreenHeight", 768)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 engineSetting.setRenderBackend(TDS.get("FIFE", "RenderBackend", "OpenGL")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 engineSetting.setFullScreen(TDS.get("FIFE", "FullScreen", 0)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 engineSetting.setWindowTitle(TDS.get("FIFE", "WindowTitle", "No window title set")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 engineSetting.setWindowIcon(TDS.get("FIFE", "WindowIcon", "")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 engineSetting.setImageChunkingSize(TDS.get("FIFE", "ImageChunkSize", 256)) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 def initLogging(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 Initialize the LogManager. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 import fifelog |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 LogModules = self._settings.get("FIFE", "LogModules") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 self.log = fifelog.LogManager(self.engine, self._settings.get("FIFE", "LogToPrompt"), self._settings.get("FIFE", "LogToFile")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 if LogModules: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 self.log.setVisibleModules(*LogModules) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 def _initTools(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 """ Initializes tools """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 self._pluginmanager = plugin.PluginManager() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 self._filemanager = FileManager() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 self._toolbar.adaptLayout() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 self._mapeditor = MapEditor() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 def _initGui(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 """ Sets up the GUI """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 screen_width = self.engine.getSettings().getScreenWidth() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 screen_height = self.engine.getSettings().getScreenHeight() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 MainWindow.initGui(self, screen_width, screen_height) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 self._toolbox = ToolBar(title=u"", orientation=1) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 self._toolbox.position_technique = "explicit" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 self._toolbox.position = (150, 150) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 self._mapbar = ToolBar(panel_size=20) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self._mapbar.setDocked(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 self._maparea = pychan.widgets.VBox() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 self._maparea.opaque = False |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 self._maparea.is_focusable = True |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 # Capture mouse and key events for EventListener |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 cw = self._maparea |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 cw.capture(self.__sendMouseEvent, "mouseEntered") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 cw.capture(self.__sendMouseEvent, "mouseExited") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 cw.capture(self.__sendMouseEvent, "mousePressed") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 cw.capture(self.__sendMouseEvent, "mouseReleased") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 cw.capture(self.__sendMouseEvent, "mouseClicked") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 cw.capture(self.__sendMouseEvent, "mouseMoved") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 cw.capture(self.__sendMouseEvent, "mouseWheelMovedUp") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 cw.capture(self.__sendMouseEvent, "mouseWheelMovedDown") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 cw.capture(self.__sendMouseEvent, "mouseDragged") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 cw.capture(self.__sendKeyEvent, "keyPressed") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 cw.capture(self.__sendKeyEvent, "keyReleased") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
138 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
139 self._centralwidget.addChild(self._mapbar) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 self._centralwidget.addChild(self._maparea) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
142 self._initActions() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
143 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
144 self._toolbox.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
146 def _initActions(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 """ Initializes toolbar and menubar buttons """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 exitAction = Action(u"Exit", "gui/icons/quit.png") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 exitAction.helptext = u"Exit program" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 action.activated.connect(self.quit, sender=exitAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
152 self._fileMenu = Menu(name=u"File") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 self._fileMenu.addAction(exitAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 self._editMenu = Menu(name=u"Edit") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 self._viewMenu = Menu(name=u"View") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 self._toolsMenu = Menu(name=u"Tools") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 self._windowMenu = Menu(name=u"Window") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
159 self._helpMenu = Menu(name=u"Help") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 self._actionShowStatusbar = Action(u"Statusbar") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 self._actionShowStatusbar.helptext = u"Toggle statusbar" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
163 action.activated.connect(self.toggleStatusbar, sender=self._actionShowStatusbar) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
164 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
165 self._actionShowToolbar = Action(u"Toolbar") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
166 self._actionShowToolbar.helptext = u"Toggle toolbar" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 action.activated.connect(self.toggleToolbar, sender=self._actionShowToolbar) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 self._actionShowToolbox = Action(u"Tool box") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 self._actionShowToolbox.helptext = u"Toggle tool box" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 action.activated.connect(self.toggleToolbox, sender=self._actionShowToolbox) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 self._viewMenu.addAction(self._actionShowStatusbar) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 self._viewMenu.addAction(self._actionShowToolbar) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 self._viewMenu.addAction(self._actionShowToolbox) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 self._viewMenu.addSeparator() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 testAction1 = Action(u"Cycle buttonstyles", "gui/icons/cycle_styles.png") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 testAction1.helptext = u"Cycles button styles. There are currently four button styles." |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 action.activated.connect(self._actionActivated, sender=testAction1) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 self._viewMenu.addAction(testAction1) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 self._mapgroup = ActionGroup(exclusive=True, name="Mapgroup") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 self._mapbar.addAction(self._mapgroup) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 self._mapbar.addAction(ActionGroup(exclusive=True, name="Mapgroup2")) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 self._windowMenu.addAction(self._mapgroup) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
189 helpAction = Action(u"Help", "gui/icons/help.png") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 action.activated.connect(self._showHelpDialog, sender=helpAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
191 self._helpMenu.addAction(helpAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
193 self._menubar.addMenu(self._fileMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
194 self._menubar.addMenu(self._editMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 self._menubar.addMenu(self._viewMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 self._menubar.addMenu(self._toolsMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
197 self._menubar.addMenu(self._windowMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 self._menubar.addMenu(self._helpMenu) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
199 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 def _actionActivated(self, sender): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
201 self._toolbar.button_style += 1 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 def _showHelpDialog(self, sender): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
204 """ Shows the help dialog """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
205 if self._helpDialog is not None: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 self._helpDialog.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 return |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
209 self._helpDialog = pychan.loadXML("gui/help.xml") |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
210 self._helpDialog.findChild(name="closeButton").capture(self._helpDialog.hide) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
212 f = open('lang/infotext.txt', 'r') |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 self._helpDialog.findChild(name="helpText").text = unicode(f.read()) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 f.close() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
215 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 self._helpDialog.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 def toggleStatusbar(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
219 """ Toggles status bar """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 statusbar = self.getStatusBar() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 if statusbar.max_size[1] > 0: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 statusbar.min_size=(statusbar.min_size[0], 0) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 statusbar.max_size=(statusbar.max_size[0], 0) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
224 self._actionShowStatusbar.setChecked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
225 else: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
226 statusbar.min_size=(statusbar.min_size[0], statusbar.min_size[0]) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
227 statusbar.max_size=(statusbar.max_size[0], statusbar.max_size[0]) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
228 self._actionShowStatusbar.setChecked(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 statusbar.adaptLayout() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
230 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
231 def toggleToolbar(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 """ Toggles toolbar """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
233 toolbar = self.getToolBar() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 if toolbar.isVisible(): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 toolbar.setDocked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
236 toolbar.hide() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
237 self._actionShowToolbar.setChecked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 else: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 tx = toolbar.x |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 ty = toolbar.y |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 toolbar.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 toolbar.x = tx |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 toolbar.y = ty |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 self._actionShowToolbar.setChecked(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 def toggleToolbox(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 """ Toggles tool box """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 toolbox = self.getToolbox() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 if toolbox.isVisible(): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 toolbox.setDocked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 toolbox.hide() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 self._actionShowToolbox.setChecked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 else: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 tx = toolbox.x |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 ty = toolbox.y |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 toolbox.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 toolbox.x = tx |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 toolbox.y = ty |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 self._actionShowToolbox.setChecked(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 toolbox.adaptLayout() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 def getToolbox(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 return self._toolbox |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 def getPluginManager(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 return self._pluginmanager |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 def getEngine(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 return self.engine |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
270 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 def getMapViews(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 return self._mapviewList |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
274 def getActiveMapView(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 return self._mapview |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
276 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
277 def getSettings(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
278 return self._settings; |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
279 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 def showMapView(self, mapview): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
281 """ Switches to mapview. """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
282 if mapview is None or mapview == self._mapview: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
283 return |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
284 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
285 events.preMapShown.send(sender=self, mapview=mapview) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
286 self._mapview = mapview |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 self._mapview.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 events.postMapShown.send(sender=self, mapview=mapview) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
289 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 def createListener(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
291 """ Creates the event listener. This is called by ApplicationBase """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
292 if self._eventlistener is None: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
293 self._eventlistener = EventListener(self.engine) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
294 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
295 return self._eventlistener |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
296 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
297 def getEventListener(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
298 """ Returns the event listener """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 return self._eventlistener |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
300 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
301 def newMapView(self, map): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
302 """ Creates a new map view """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
303 mapview = MapView(map) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
304 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
305 self._mapviewList.append(mapview) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
306 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
307 mapAction = Action(unicode(map.getId())) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
308 action.activated.connect(cbwa(self.showMapView, mapview), sender=mapAction, weak=False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
309 self._mapgroup.addAction(mapAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
310 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
311 self.showMapView(mapview) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
312 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
313 events.mapAdded.send(sender=self, map=map) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
314 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
315 return mapview |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
316 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
317 def openFile(self, path): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
318 """ Opens a file """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
319 try: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
320 map = loaders.loadMapFile(path, self.engine) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
321 return self.newMapView(map) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
322 except: |
265
043d71a192b5
* _ListItem in HistoryManager will now return a string object in __str__
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
323 traceback.print_exc(sys.exc_info()[1]) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
324 errormsg = u"Opening map failed:\n" |
265
043d71a192b5
* _ListItem in HistoryManager will now return a string object in __str__
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
325 errormsg += u"File: "+unicode(path, sys.getfilesystemencoding())+u"\n" |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
326 errormsg += u"Error: "+unicode(sys.exc_info()[1]) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
327 ErrorDialog(errormsg) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
328 return None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
329 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
330 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
331 def saveAll(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
332 """ Saves all open maps """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
333 tmpView = self._mapview |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
334 for mapView in self._mapviewList: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
335 self._mapview = mapView |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
336 self._filemanager.save() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
337 self._mapview = tmpView |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
338 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
339 def quit(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
340 """ Quits the editor. An onQuit signal is sent before the application closes """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
341 events.onQuit.send(sender=self) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
342 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
343 self._settings.saveSettings() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
344 ApplicationBase.quit(self) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
345 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
346 def _pump(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
347 """ Called once per frame """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
348 # ApplicationBase and Engine should be done initializing at this point |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
349 if self._inited == False: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
350 self._initGui() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
351 self._initTools() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
352 self._inited = True |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
353 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
354 events.onPump.send(sender=self) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
355 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
356 def __sendMouseEvent(self, event, **kwargs): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
357 """ Function used to capture mouse events for EventListener """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
358 msEvent = fife.MouseEvent |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
359 type = event.getType() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
360 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
361 if type == msEvent.MOVED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
362 mouseMoved.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
363 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
364 elif type == msEvent.PRESSED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
365 mousePressed.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
366 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
367 elif type == msEvent.RELEASED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
368 mouseReleased.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
369 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
370 elif type == msEvent.WHEEL_MOVED_DOWN: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
371 mouseWheelMovedDown.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
372 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
373 elif type == msEvent.WHEEL_MOVED_UP: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
374 mouseWheelMovedUp.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
375 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
376 elif type == msEvent.CLICKED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
377 mouseClicked.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
378 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
379 elif type == msEvent.ENTERED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
380 mouseEntered.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
381 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
382 elif type == msEvent.EXITED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
383 mouseExited.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
384 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
385 elif type == msEvent.DRAGGED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
386 mouseDragged.send(sender=self._maparea, event=event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
387 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
388 def __sendKeyEvent(self, event, **kwargs): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
389 """ Function used to capture key events for EventListener """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
390 type = event.getType() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
391 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
392 if type == fife.KeyEvent.PRESSED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
393 self._eventlistener.keyPressed(event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
394 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
395 elif type == fife.KeyEvent.RELEASED: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
396 self._eventlistener.keyReleased(event) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
397 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
398 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
399 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
400 |