annotate clients/editor/scripts/editor.py @ 373:20fa29f376c7

Editor: * If a map is already open, the user will be presented with a dialog asking if he wants to reload the map * CancelCallback argument in InputDialog is no longer mandatory * New dialog: YesNoDialog
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 20 Nov 2009 02:04:39 +0000
parents 598547404022
children 1115f7cae9a3
rev   line source
355
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
1 # -*- coding: utf-8 -*-
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
2
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
3 # ####################################################################
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
5 # http://www.fifengine.de
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
6 # This file is part of FIFE.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
7 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
8 # FIFE is free software; you can redistribute it and/or
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
10 # License as published by the Free Software Foundation; either
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
12 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
13 # This library is distributed in the hope that it will be useful,
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
16 # Lesser General Public License for more details.
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
17 #
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
19 # License along with this library; if not, write to the
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
20 # Free Software Foundation, Inc.,
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
22 # ####################################################################
8b125ec749d7 Started cleaning up the editor source code:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 324
diff changeset
23
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
24 """
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
25 Editor
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
26 ======
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
27
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
28 This class serves as
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
29 """
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
30
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
31 import sys
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
32 import traceback
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
33
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 import fife
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 import loaders
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 import events
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 import plugin
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
38
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
39 from basicapplication import ApplicationBase
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
40
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
41 import pychan
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
42 from pychan.tools import callbackWithArguments as cbwa
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
43
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 from events import *
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 from gui import ToolBar, action
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 from gui.action import Action, ActionGroup
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 from gui.filemanager import FileManager
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 from gui.mainwindow import MainWindow
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 from gui.mapeditor import MapEditor
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 from gui.menubar import Menu, MenuBar
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 from gui.error import ErrorDialog
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
52 from gui.yesnodialog import YesNoDialog
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
53 from mapview import MapView
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 from settings import Settings
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 def getEditor():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 """ Returns the Global editor instance """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 if Editor.editor is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 Editor(None)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 return Editor.editor
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 class Editor(ApplicationBase, MainWindow):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 """ 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
64 editor = None
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 def __init__(self, params, *args, **kwargs):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 Editor.editor = self
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._filemanager = None
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
70 self._open_files = []
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
72 self._params = params
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 self._eventlistener = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 self._pluginmanager = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 self._inited = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self._mapview = None
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
79 self._mapviewlist = []
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 self._mapgroup = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 self._mapbar = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self._maparea = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 self._mapeditor = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
85 self._file_menu = None
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
86 self._edit_menu = None
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
87 self._view_menu = None
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
88 self._tools_menu = None
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
89 self._help_menu = None
255
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 self._settings = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
93 self._help_dialog = None
255
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 ApplicationBase.__init__(self, *args, **kwargs)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 MainWindow.__init__(self, *args, **kwargs)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 pychan.init(self.engine, debug=False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98
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 loadSettings(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 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
103 Called in the ApplicationBase constructor.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 self._settings = Settings()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 TDS = self._settings
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 glyphDft = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\\\""
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 engineSetting = self.engine.getSettings()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 engineSetting.setDefaultFontGlyphs(TDS.get("FIFE", "FontGlyphs", glyphDft))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 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
112 engineSetting.setDefaultFontSize(12)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 engineSetting.setBitsPerPixel(TDS.get("FIFE", "BitsPerPixel", 0))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 engineSetting.setInitialVolume(TDS.get("FIFE", "InitialVolume", 5.0))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 engineSetting.setSDLRemoveFakeAlpha(TDS.get("FIFE", "SDLRemoveFakeAlpha", 1))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 engineSetting.setScreenWidth(TDS.get("FIFE", "ScreenWidth", 1024))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 engineSetting.setScreenHeight(TDS.get("FIFE", "ScreenHeight", 768))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 engineSetting.setRenderBackend(TDS.get("FIFE", "RenderBackend", "OpenGL"))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 engineSetting.setFullScreen(TDS.get("FIFE", "FullScreen", 0))
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 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
122 engineSetting.setWindowIcon(TDS.get("FIFE", "WindowIcon", ""))
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 engineSetting.setImageChunkingSize(TDS.get("FIFE", "ImageChunkSize", 256))
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 def initLogging(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 Initialize the LogManager.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 import fifelog
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
131 logModules = self._settings.get("FIFE", "LogModules")
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 self.log = fifelog.LogManager(self.engine, self._settings.get("FIFE", "LogToPrompt"), self._settings.get("FIFE", "LogToFile"))
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
133 if logModules:
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
134 self.log.setVisibleModules(*logModules)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 def _initTools(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 """ Initializes tools """
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
138 self._pluginmanager = plugin.PluginManager(self.getSettings())
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 self._filemanager = FileManager()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 self._toolbar.adaptLayout()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 self._mapeditor = MapEditor()
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 def _initGui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 """ Sets up the GUI """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 screen_width = self.engine.getSettings().getScreenWidth()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 screen_height = self.engine.getSettings().getScreenHeight()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 MainWindow.initGui(self, screen_width, screen_height)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 self._toolbox = ToolBar(title=u"", orientation=1)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 self._toolbox.position_technique = "explicit"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 self._toolbox.position = (150, 150)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
154 self._mapbar = ToolBar(name="MapBar", panel_size=20)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 self._mapbar.setDocked(True)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 self._maparea = pychan.widgets.VBox()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 self._maparea.opaque = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 self._maparea.is_focusable = True
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 # Capture mouse and key events for EventListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 cw = self._maparea
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 cw.capture(self.__sendMouseEvent, "mouseEntered")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 cw.capture(self.__sendMouseEvent, "mouseExited")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 cw.capture(self.__sendMouseEvent, "mousePressed")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 cw.capture(self.__sendMouseEvent, "mouseReleased")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 cw.capture(self.__sendMouseEvent, "mouseClicked")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 cw.capture(self.__sendMouseEvent, "mouseMoved")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 cw.capture(self.__sendMouseEvent, "mouseWheelMovedUp")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 cw.capture(self.__sendMouseEvent, "mouseWheelMovedDown")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 cw.capture(self.__sendMouseEvent, "mouseDragged")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 cw.capture(self.__sendKeyEvent, "keyPressed")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 cw.capture(self.__sendKeyEvent, "keyReleased")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 self._centralwidget.addChild(self._mapbar)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 self._centralwidget.addChild(self._maparea)
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 self._initActions()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 self._toolbox.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 def _initActions(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 """ Initializes toolbar and menubar buttons """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 exitAction = Action(u"Exit", "gui/icons/quit.png")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 exitAction.helptext = u"Exit program"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 action.activated.connect(self.quit, sender=exitAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
188 self._file_menu = Menu(name=u"File")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
189 self._file_menu.addAction(exitAction)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
191 self._edit_menu = Menu(name=u"Edit")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
192 self._view_menu = Menu(name=u"View")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
193 self._tools_menu = Menu(name=u"Tools")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
194 self._window_menu = Menu(name=u"Window")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
195 self._help_menu = Menu(name=u"Help")
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
197 self._action_show_statusbar = Action(u"Statusbar")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
198 self._action_show_statusbar.helptext = u"Toggle statusbar"
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
199 action.activated.connect(self.toggleStatusbar, sender=self._action_show_statusbar)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
201 self._action_show_toolbar = Action(u"Toolbar")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
202 self._action_show_toolbar.helptext = u"Toggle toolbar"
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
203 action.activated.connect(self.toggleToolbar, sender=self._action_show_toolbar)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
205 self._action_show_toolbox = Action(u"Tool box")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
206 self._action_show_toolbox.helptext = u"Toggle tool box"
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
207 action.activated.connect(self.toggleToolbox, sender=self._action_show_toolbox)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
209 self._view_menu.addAction(self._action_show_statusbar)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
210 self._view_menu.addAction(self._action_show_toolbar)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
211 self._view_menu.addAction(self._action_show_toolbox)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
212 self._view_menu.addSeparator()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
215 test_action1 = Action(u"Cycle buttonstyles", "gui/icons/cycle_styles.png")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
216 test_action1.helptext = u"Cycles button styles. There are currently four button styles."
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
217 action.activated.connect(self._actionActivated, sender=test_action1)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
218 self._view_menu.addAction(test_action1)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 self._mapgroup = ActionGroup(exclusive=True, name="Mapgroup")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 self._mapbar.addAction(self._mapgroup)
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
222 self._window_menu.addAction(self._mapgroup)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
224 help_action = Action(u"Help", "gui/icons/help.png")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
225 help_action.helptext = u"Displays a window with some simple instructions"
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
226 action.activated.connect(self._showHelpDialog, sender=help_action)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
227 self._help_menu.addAction(help_action)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
229 self._menubar.addMenu(self._file_menu)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
230 self._menubar.addMenu(self._edit_menu)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
231 self._menubar.addMenu(self._view_menu)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
232 self._menubar.addMenu(self._tools_menu)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
233 self._menubar.addMenu(self._window_menu)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
234 self._menubar.addMenu(self._help_menu)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 def _actionActivated(self, sender):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 self._toolbar.button_style += 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 def _showHelpDialog(self, sender):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 """ Shows the help dialog """
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
241 if self._help_dialog is not None:
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
242 self._help_dialog.show()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
245 self._help_dialog = pychan.loadXML("gui/help.xml")
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
246 self._help_dialog.findChild(name="closeButton").capture(self._help_dialog.hide)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 f = open('lang/infotext.txt', 'r')
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
249 self._help_dialog.findChild(name="helpText").text = unicode(f.read())
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 f.close()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
252 self._help_dialog.show()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 def toggleStatusbar(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 """ Toggles status bar """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 statusbar = self.getStatusBar()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 if statusbar.max_size[1] > 0:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 statusbar.min_size=(statusbar.min_size[0], 0)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 statusbar.max_size=(statusbar.max_size[0], 0)
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
260 self._action_show_statusbar.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 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
263 statusbar.max_size=(statusbar.max_size[0], statusbar.max_size[0])
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
264 self._action_show_statusbar.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 statusbar.adaptLayout()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 def toggleToolbar(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 """ Toggles toolbar """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 toolbar = self.getToolBar()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 if toolbar.isVisible():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 toolbar.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 toolbar.hide()
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
273 self._action_show_toolbar.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 tx = toolbar.x
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 ty = toolbar.y
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 toolbar.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 toolbar.x = tx
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 toolbar.y = ty
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
280 self._action_show_toolbar.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 def toggleToolbox(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 """ Toggles tool box """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 toolbox = self.getToolbox()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 if toolbox.isVisible():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 toolbox.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287 toolbox.hide()
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
288 self._action_show_toolbox.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 tx = toolbox.x
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 ty = toolbox.y
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 toolbox.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 toolbox.x = tx
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 toolbox.y = ty
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
295 self._action_show_toolbox.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 toolbox.adaptLayout()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 def getToolbox(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 return self._toolbox
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 getPluginManager(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 return self._pluginmanager
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 def getEngine(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 return self.engine
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 def getMapViews(self):
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
308 return self._mapviewlist
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 def getActiveMapView(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 return self._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 def getSettings(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 return self._settings;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 def showMapView(self, mapview):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 """ Switches to mapview. """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 if mapview is None or mapview == self._mapview:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 events.preMapShown.send(sender=self, mapview=mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322 self._mapview = mapview
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 self._mapview.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324 events.postMapShown.send(sender=self, mapview=mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 def createListener(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 """ 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
328 if self._eventlistener is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 self._eventlistener = EventListener(self.engine)
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 return self._eventlistener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 def getEventListener(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 """ Returns the event listener """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 return self._eventlistener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 def newMapView(self, map):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 """ Creates a new map view """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 mapview = MapView(map)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
341 self._mapviewlist.append(mapview)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
343 map_action = Action(unicode(map.getId()))
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
344 action.activated.connect(cbwa(self.showMapView, mapview), sender=map_action, weak=False)
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
345 self._mapgroup.addAction(map_action)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 self.showMapView(mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
349 events.preMapClosed.connect(self._preMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
350 events.postMapClosed.connect(self._postMapRemoved)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
351 events.mapAdded.send(sender=self, map=map)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353 return mapview
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
354
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
355 def _preMapRemoved(self, sender, mapview):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
356 events.preMapClosed.disconnect(self._preMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
357
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
358 # Remove from open files list
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
359 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
360 path = mapview.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
361 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
362 self._open_files.remove(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
363 except ValueError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
364 pass
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
365 except RuntimeError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
366 # Mapview is not saved
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
367 return
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
368
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
369 # Remove tab
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
370 for map_action in self._mapgroup.getActions():
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
371 if map_action.text == unicode(mapview.getMap().getId()):
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
372 self._mapgroup.removeAction(map_action)
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
373 break
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
374
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
375 def _postMapRemoved(self, mapview):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
376 events.postMapClosed.disconnect(self._postMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
377
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
378 # Remove from mapviewlist
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
379 index = self._mapviewlist.index(mapview)-1
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
380 self._mapviewlist.remove(mapview)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
381
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
382 # Change mapview
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
383 if index >= 0:
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
384 self.showMapView(self._mapviewlist[index])
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
385 else:
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
386 self._mapview = None
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
387 self.getEngine().getView().clearCameras()
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
388
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
389 def getMapviewByPath(self, path):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
390 mappath = ""
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
391 for mv in self._mapviewlist:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
392 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
393 mappath = mv.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
394 except RuntimeError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
395 # Mapview is not saved yet
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
396 continue
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
397
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
398 if mappath == path:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
399 return mv
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
400
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 def openFile(self, path):
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
402 if path in self._open_files:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
403 # Map is already open, ask user if he wants to reload the map
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
404 mapview = self.getMapviewByPath(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
405 YesNoDialog("Map is already open. Do you want to reload it?", cbwa(self.reloadMapview, mapview=mapview))
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
406 return
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
407
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
408 """ Opens a file """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
409 try:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
410 map = loaders.loadMapFile(path, self.engine)
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
411 mapview = self.newMapView(map)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
412 self._open_files.append(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
413 return mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
414 except:
265
043d71a192b5 * _ListItem in HistoryManager will now return a string object in __str__
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
415 traceback.print_exc(sys.exc_info()[1])
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
416 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
417 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
418 errormsg += u"Error: "+unicode(sys.exc_info()[1])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
419 ErrorDialog(errormsg)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420 return None
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
421
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
422 def reloadMapview(self, mapview=None):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
423 if mapview is None:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
424 mapview = self._mapview
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
425
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
426 if mapview is None:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
427 print "Can't reload map: No maps are open."
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
428 return
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
429
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
430 path = mapview.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
431 mapview.close()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
432 self.openFile(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
433
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
435 def saveAll(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
436 """ Saves all open maps """
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
437 tmpview = self._mapview
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
438 for mapview in self._mapviewlist:
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
439 self._mapview = mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
440 self._filemanager.save()
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
441 self._mapview = tmpview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
442
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
443 def quit(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
444 """ 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
445 events.onQuit.send(sender=self)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
446
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
447 self._settings.saveSettings()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
448 ApplicationBase.quit(self)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
449
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
450 def _pump(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
451 """ Called once per frame """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
452 # 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
453 if self._inited == False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
454 self._initGui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
455 self._initTools()
361
f55ddf7fdad5 * Editor command line map arg support patch by or1andov / superfluid
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
456 if self._params: self.openFile(self._params)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
457 self._inited = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
458
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
459 events.onPump.send(sender=self)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461 def __sendMouseEvent(self, event, **kwargs):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 """ Function used to capture mouse events for EventListener """
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
463 ms_event = fife.MouseEvent
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
464 type = event.getType()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
465
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
466 if type == ms_event.MOVED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
467 mouseMoved.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
468
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
469 elif type == ms_event.PRESSED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
470 mousePressed.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
471
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
472 elif type == ms_event.RELEASED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
473 mouseReleased.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
474
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
475 elif type == ms_event.WHEEL_MOVED_DOWN:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
476 mouseWheelMovedDown.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
477
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
478 elif type == ms_event.WHEEL_MOVED_UP:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
479 mouseWheelMovedUp.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
480
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
481 elif type == ms_event.CLICKED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
482 mouseClicked.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
483
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
484 elif type == ms_event.ENTERED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
485 mouseEntered.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
486
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
487 elif type == ms_event.EXITED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
488 mouseExited.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
489
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
490 elif type == ms_event.DRAGGED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
491 mouseDragged.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
492
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
493 def __sendKeyEvent(self, event, **kwargs):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
494 """ Function used to capture key events for EventListener """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
495 type = event.getType()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
496
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
497 if type == fife.KeyEvent.PRESSED:
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 318
diff changeset
498 keyPressed.send(sender=self._maparea, event=event)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
499
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
500 elif type == fife.KeyEvent.RELEASED:
324
e249fa887259 * Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 318
diff changeset
501 keyReleased.send(sender=self._maparea, event=event)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
502
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
503
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
504
361
f55ddf7fdad5 * Editor command line map arg support patch by or1andov / superfluid
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
505