annotate clients/editor/scripts/editor.py @ 374:1115f7cae9a3

Editor: * The editor will now force filenames to be lowercase, as VFS does not like uppercase path names. * If a map filename does not have a .xml extension on save, it will be automatically added. * Log modules set to "all" by default. Only new users will be affected by this without having to modify or remove their configuration file. * Log level set to LOGLEVEL_WARN
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 21 Nov 2009 13:11:56 +0000
parents 20fa29f376c7
children
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")
374
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
132 loglevel = self._settings.get("FIFE", "LogLevel", "Warn");
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
133
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 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
135 if logModules:
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
136 self.log.setVisibleModules(*logModules)
374
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
137
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
138 if loglevel == "Debug":
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
139 loglevel = fife.LogManager.LEVEL_DEBUG
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
140 elif loglevel == "Log":
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
141 loglevel = fife.LogManager.LEVEL_LOG
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
142 elif loglevel == "Error":
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
143 loglevel = fife.LogManager.LEVEL_ERROR
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
144 else:
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
145 loglevel = fife.LogManager.LEVEL_WARN
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
146 self.log.lm.setLevelFilter(loglevel)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 def _initTools(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 """ Initializes tools """
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
150 self._pluginmanager = plugin.PluginManager(self.getSettings())
255
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._filemanager = FileManager()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 self._toolbar.adaptLayout()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 self._mapeditor = MapEditor()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 def _initGui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 """ Sets up the GUI """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 screen_width = self.engine.getSettings().getScreenWidth()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 screen_height = self.engine.getSettings().getScreenHeight()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 MainWindow.initGui(self, screen_width, screen_height)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 self._toolbox = ToolBar(title=u"", orientation=1)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 self._toolbox.position_technique = "explicit"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 self._toolbox.position = (150, 150)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
166 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
167 self._mapbar.setDocked(True)
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._maparea = pychan.widgets.VBox()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 self._maparea.opaque = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 self._maparea.is_focusable = True
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 # Capture mouse and key events for EventListener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 cw = self._maparea
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 cw.capture(self.__sendMouseEvent, "mouseEntered")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 cw.capture(self.__sendMouseEvent, "mouseExited")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 cw.capture(self.__sendMouseEvent, "mousePressed")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 cw.capture(self.__sendMouseEvent, "mouseReleased")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 cw.capture(self.__sendMouseEvent, "mouseClicked")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 cw.capture(self.__sendMouseEvent, "mouseMoved")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 cw.capture(self.__sendMouseEvent, "mouseWheelMovedUp")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 cw.capture(self.__sendMouseEvent, "mouseWheelMovedDown")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 cw.capture(self.__sendMouseEvent, "mouseDragged")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 cw.capture(self.__sendKeyEvent, "keyPressed")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 cw.capture(self.__sendKeyEvent, "keyReleased")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 self._centralwidget.addChild(self._mapbar)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 self._centralwidget.addChild(self._maparea)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 self._initActions()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 self._toolbox.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 def _initActions(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 """ Initializes toolbar and menubar buttons """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 exitAction = Action(u"Exit", "gui/icons/quit.png")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 exitAction.helptext = u"Exit program"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 action.activated.connect(self.quit, sender=exitAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
200 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
201 self._file_menu.addAction(exitAction)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
203 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
204 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
205 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
206 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
207 self._help_menu = Menu(name=u"Help")
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._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
210 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
211 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
212
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
213 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
214 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
215 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
216
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
217 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
218 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
219 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
220
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
221 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
222 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
223 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
224 self._view_menu.addSeparator()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
227 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
228 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
229 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
230 self._view_menu.addAction(test_action1)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 self._mapgroup = ActionGroup(exclusive=True, name="Mapgroup")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 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
234 self._window_menu.addAction(self._mapgroup)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
236 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
237 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
238 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
239 self._help_menu.addAction(help_action)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
241 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
242 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
243 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
244 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
245 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
246 self._menubar.addMenu(self._help_menu)
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 def _actionActivated(self, sender):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 self._toolbar.button_style += 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 def _showHelpDialog(self, sender):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 """ 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
253 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
254 self._help_dialog.show()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
257 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
258 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
259
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 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
261 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
262 f.close()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
264 self._help_dialog.show()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 def toggleStatusbar(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 """ Toggles status bar """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 statusbar = self.getStatusBar()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 if statusbar.max_size[1] > 0:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 statusbar.min_size=(statusbar.min_size[0], 0)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 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
272 self._action_show_statusbar.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 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
275 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
276 self._action_show_statusbar.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 statusbar.adaptLayout()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 def toggleToolbar(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 """ Toggles toolbar """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 toolbar = self.getToolBar()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 if toolbar.isVisible():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 toolbar.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 toolbar.hide()
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
285 self._action_show_toolbar.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287 tx = toolbar.x
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 ty = toolbar.y
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 toolbar.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 toolbar.x = tx
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 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
292 self._action_show_toolbar.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 def toggleToolbox(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 """ Toggles tool box """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 toolbox = self.getToolbox()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297 if toolbox.isVisible():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 toolbox.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 toolbox.hide()
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
300 self._action_show_toolbox.setChecked(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 tx = toolbox.x
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 ty = toolbox.y
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 toolbox.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 toolbox.x = tx
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 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
307 self._action_show_toolbox.setChecked(True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 toolbox.adaptLayout()
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 getToolbox(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 return self._toolbox
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 getPluginManager(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 return self._pluginmanager
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 getEngine(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 return self.engine
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 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
320 return self._mapviewlist
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322 def getActiveMapView(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 return self._mapview
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 def getSettings(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 return self._settings;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 def showMapView(self, mapview):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 """ Switches to mapview. """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 if mapview is None or mapview == self._mapview:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 return
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 events.preMapShown.send(sender=self, mapview=mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self._mapview = mapview
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 self._mapview.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 events.postMapShown.send(sender=self, mapview=mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 def createListener(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 """ 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
340 if self._eventlistener is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
341 self._eventlistener = EventListener(self.engine)
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 return self._eventlistener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 def getEventListener(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 """ Returns the event listener """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 return self._eventlistener
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
349 def newMapView(self, map):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
350 """ Creates a new map view """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
351 mapview = MapView(map)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
353 self._mapviewlist.append(mapview)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
355 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
356 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
357 self._mapgroup.addAction(map_action)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359 self.showMapView(mapview)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
361 events.preMapClosed.connect(self._preMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
362 events.postMapClosed.connect(self._postMapRemoved)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
363 events.mapAdded.send(sender=self, map=map)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
364
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365 return mapview
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
366
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
367 def _preMapRemoved(self, sender, mapview):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
368 events.preMapClosed.disconnect(self._preMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
369
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
370 # Remove from open files list
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
371 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
372 path = mapview.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
373 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
374 self._open_files.remove(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
375 except ValueError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
376 pass
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
377 except RuntimeError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
378 # Mapview is not saved
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
379 return
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
380
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
381 # Remove tab
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
382 for map_action in self._mapgroup.getActions():
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
383 if map_action.text == unicode(mapview.getMap().getId()):
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
384 self._mapgroup.removeAction(map_action)
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
385 break
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
386
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
387 def _postMapRemoved(self, mapview):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
388 events.postMapClosed.disconnect(self._postMapRemoved)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
389
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
390 # Remove from mapviewlist
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
391 index = self._mapviewlist.index(mapview)-1
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
392 self._mapviewlist.remove(mapview)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
393
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
394 # Change mapview
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
395 if index >= 0:
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
396 self.showMapView(self._mapviewlist[index])
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
397 else:
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
398 self._mapview = None
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
399 self.getEngine().getView().clearCameras()
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
400
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
401 def getMapviewByPath(self, path):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
402 mappath = ""
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
403 for mv in self._mapviewlist:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
404 try:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
405 mappath = mv.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
406 except RuntimeError:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
407 # Mapview is not saved yet
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
408 continue
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
409
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
410 if mappath == path:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
411 return mv
367
598547404022 * Initial support for closing maps:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 361
diff changeset
412
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
413 def openFile(self, path):
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
414 if path in self._open_files:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
415 # 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
416 mapview = self.getMapviewByPath(path)
374
1115f7cae9a3 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 373
diff changeset
417 YesNoDialog(u"Map is already open. Do you want to reload it?", cbwa(self.reloadMapview, mapview=mapview))
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
418 return
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
419
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420 """ Opens a file """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
421 try:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
422 map = loaders.loadMapFile(path, self.engine)
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
423 mapview = self.newMapView(map)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
424 self._open_files.append(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
425 return mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
426 except:
265
043d71a192b5 * _ListItem in HistoryManager will now return a string object in __str__
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
427 traceback.print_exc(sys.exc_info()[1])
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
428 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
429 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
430 errormsg += u"Error: "+unicode(sys.exc_info()[1])
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
431 ErrorDialog(errormsg)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
432 return None
373
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
433
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
434 def reloadMapview(self, mapview=None):
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
435 if mapview is None:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
436 mapview = self._mapview
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
437
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
438 if mapview is None:
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
439 print "Can't reload map: No maps are open."
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
440 return
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
441
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
442 path = mapview.getMap().getResourceLocation().getFilename()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
443 mapview.close()
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
444 self.openFile(path)
20fa29f376c7 Editor:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 367
diff changeset
445
255
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 def saveAll(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
448 """ 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
449 tmpview = self._mapview
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
450 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
451 self._mapview = mapview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
452 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
453 self._mapview = tmpview
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
454
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
455 def quit(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
456 """ 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
457 events.onQuit.send(sender=self)
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 self._settings.saveSettings()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460 ApplicationBase.quit(self)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 def _pump(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
463 """ Called once per frame """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
464 # 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
465 if self._inited == False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
466 self._initGui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
467 self._initTools()
361
f55ddf7fdad5 * Editor command line map arg support patch by or1andov / superfluid
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
468 if self._params: self.openFile(self._params)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
469 self._inited = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
470
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
471 events.onPump.send(sender=self)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
472
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
473 def __sendMouseEvent(self, event, **kwargs):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
474 """ 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
475 ms_event = fife.MouseEvent
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
476 type = event.getType()
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 if type == ms_event.MOVED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
479 mouseMoved.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.PRESSED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
482 mousePressed.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.RELEASED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
485 mouseReleased.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.WHEEL_MOVED_DOWN:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
488 mouseWheelMovedDown.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.WHEEL_MOVED_UP:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
491 mouseWheelMovedUp.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
492
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
493 elif type == ms_event.CLICKED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
494 mouseClicked.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
495
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
496 elif type == ms_event.ENTERED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
497 mouseEntered.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
498
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
499 elif type == ms_event.EXITED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
500 mouseExited.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
501
359
ad5818097cd6 * Some cleanups for Editor class to match new coding standards
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 355
diff changeset
502 elif type == ms_event.DRAGGED:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
503 mouseDragged.send(sender=self._maparea, event=event)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
504
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
505 def __sendKeyEvent(self, event, **kwargs):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
506 """ Function used to capture key events for EventListener """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
507 type = event.getType()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
508
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
509 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
510 keyPressed.send(sender=self._maparea, event=event)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
511
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
512 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
513 keyReleased.send(sender=self._maparea, event=event)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
514
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
515
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
516
361
f55ddf7fdad5 * Editor command line map arg support patch by or1andov / superfluid
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 359
diff changeset
517