2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2004 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # GUIMA.py - scripts to control map windows from the GUIMA and GUIWMAP winpacks
23 ###################################################
27 import GUICommonWindows
28 from GUIDefines
import *
32 WorldMapControl
= None
34 OldPortraitWindow
= None
36 OldOptionsWindow
= None
40 global OldPortraitWindow
, OldOptionsWindow
42 if GUICommon
.CloseOtherWindow (ShowMap
):
46 OptionsWindow
.Unload ()
48 PortraitWindow
.Unload ()
51 #this window type should block the game
52 GemRB
.SetVar ("OtherWindow", -1)
53 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
55 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
56 OldPortraitWindow
= None
57 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
58 OldOptionsWindow
= None
60 PosX
= GemRB
.GetVar ("MapControlX")
61 PosY
= GemRB
.GetVar ("MapControlY")
63 GemRB
.RevealArea (PosX
, PosY
, 30, 1)
67 ###################################################
69 ###################################################
71 global MapWindow
, OptionsWindow
, PortraitWindow
72 global OldPortraitWindow
, OldOptionsWindow
74 if GUICommon
.CloseOtherWindow (ShowMap
):
78 OptionsWindow
.Unload ()
80 PortraitWindow
.Unload ()
83 #this window type should block the game
84 GemRB
.SetVar ("OtherWindow", -1)
85 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
87 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
88 OldPortraitWindow
= None
89 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
90 OldOptionsWindow
= None
94 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
96 GemRB
.LoadWindowPack ("GUIMAP", 640, 480)
97 MapWindow
= Window
= GemRB
.LoadWindow (2)
98 #this window type blocks the game normally, but map window doesn't
99 GemRB
.SetVar ("OtherWindow", MapWindow
.ID
)
100 #saving the original portrait window
101 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
102 OptionsWindow
= GemRB
.LoadWindow (0)
103 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 0, ShowMap
)
104 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
105 PortraitWindow
= GUICommonWindows
.OpenPortraitWindow (0)
106 OptionsWindow
.SetFrame ()
109 Button
= Window
.GetControl (1)
110 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
113 Window
.CreateMapControl (2, 0, 0, 0, 0)
114 Map
= Window
.GetControl (2)
115 Map
.SetEvent (IE_GUI_MAP_ON_PRESS
, RevealMap
)
116 Window
.SetVisible (WINDOW_VISIBLE
)
117 OptionsWindow
.SetVisible (WINDOW_GRAYED
)
118 PortraitWindow
.SetVisible (WINDOW_GRAYED
)
119 OptionsWindow
.SetVisible (WINDOW_FRONT
)
120 PortraitWindow
.SetVisible (WINDOW_FRONT
)
121 Window
.SetVisible (WINDOW_FRONT
)
122 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
123 GemRB
.GamePause (0,0)
126 ###################################################
127 def OpenMapWindow ():
128 global MapWindow
, OptionsWindow
, PortraitWindow
129 global OldPortraitWindow
, OldOptionsWindow
131 if GUICommon
.CloseOtherWindow (OpenMapWindow
):
135 OptionsWindow
.Unload ()
137 PortraitWindow
.Unload ()
140 #this window type should block the game
141 GemRB
.SetVar ("OtherWindow", -1)
142 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
143 #OldOptionsWindow.SetVisible (WINDOW_VISIBLE)
144 #OldPortraitWindow.SetVisible (WINDOW_VISIBLE)
146 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
147 OldPortraitWindow
= None
148 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
149 OldOptionsWindow
= None
153 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
155 GemRB
.LoadWindowPack ("GUIMAP", 640, 480)
156 MapWindow
= Window
= GemRB
.LoadWindow (2)
157 #this window type blocks the game normally, but map window doesn't
158 GemRB
.SetVar ("OtherWindow", MapWindow
.ID
)
159 #saving the original portrait window
160 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
161 OptionsWindow
= GemRB
.LoadWindow (0)
162 GUICommonWindows
.MarkMenuButton (OptionsWindow
)
163 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 0, OpenMapWindow
)
164 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
165 PortraitWindow
= GUICommonWindows
.OpenPortraitWindow (0)
166 OptionsWindow
.SetFrame ()
169 Button
= Window
.GetControl (1)
170 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenWorldMapWindowInside
)
173 Window
.CreateMapControl (2, 0, 0, 0, 0)
174 Map
= Window
.GetControl (2)
175 Map
.SetEvent (IE_GUI_MAP_ON_DOUBLE_PRESS
, LeftDoublePressMap
)
176 #OldOptionsWindow.SetVisible (WINDOW_INVISIBLE)
177 #OldPortraitWindow.SetVisible (WINDOW_INVISIBLE)
178 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
179 Window
.SetVisible (WINDOW_VISIBLE
)
180 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
181 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
183 def LeftDoublePressMap ():
187 def OpenWorldMapWindowInside ():
190 OpenMapWindow () #closes mapwindow
192 print "MapWindow=",MapWindow
193 WorldMapWindowCommon (-1)
196 def OpenWorldMapWindow ():
197 WorldMapWindowCommon (GemRB
.GetVar ("Travel"))
200 def MoveToNewArea ():
201 global WorldMapWindow
, WorldMapControl
203 tmp
= WorldMapControl
.GetDestinationArea (1)
204 if tmp
["Distance"]==-1:
205 print "Invalid target", tmp
208 CloseWorldMapWindow ()
209 GemRB
.CreateMovement (tmp
["Destination"], tmp
["Entrance"], tmp
["Direction"])
212 def ChangeTooltip ():
213 global WorldMapWindow
, WorldMapControl
216 tmp
= WorldMapControl
.GetDestinationArea ()
218 str = "%s: %d"%(GemRB
.GetString(23084),tmp
["Distance"])
222 WorldMapControl
.SetTooltip (str)
225 def CloseWorldMapWindow ():
226 global WorldMapWindow
, WorldMapControl
228 print "CloseWorldMapWindow found Mapwindow = ",MapWindow
232 WorldMapWindow
.Unload ()
233 WorldMapWindow
= None
234 WorldMapControl
= None
239 WorldMapWindow
.Unload ()
240 WorldMapWindow
= None
241 WorldMapControl
= None
242 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
246 def WorldMapWindowCommon (Travel
):
247 global WorldMapWindow
, WorldMapControl
250 CloseWorldMapWindow ()
254 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
256 GemRB
.LoadWindowPack ("GUIWMAP", 640, 480)
257 WorldMapWindow
= Window
= GemRB
.LoadWindow (0)
258 #saving the original portrait window
261 Window
.CreateWorldMapControl (4, 0, 62, 640, 418, Travel
, "toolfont")
262 WorldMapControl
= Window
.GetControl (4)
263 WorldMapControl
.SetAnimation ("WMDAG")
264 WorldMapControl
.SetEvent (IE_GUI_WORLDMAP_ON_PRESS
, MoveToNewArea
)
265 WorldMapControl
.SetEvent (IE_GUI_MOUSE_ENTER_WORLDMAP
, ChangeTooltip
)
266 #center on current area
267 WorldMapControl
.AdjustScrolling (0, 0)
270 Button
= Window
.GetControl (1)
271 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MapN
)
274 Button
= Window
.GetControl (2)
275 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MapS
)
278 Button
= Window
.GetControl (0)
279 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseWorldMapWindow
)
280 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
281 Window
.SetVisible (WINDOW_VISIBLE
)
285 WorldMapControl
.AdjustScrolling (0, -10)
289 WorldMapControl
.AdjustScrolling (0, 10)
293 ###################################################
294 # End of file GUIMA.py