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
35 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
)
112 # Hide or Show mapnotes
113 Button
= Window
.GetControl (3)
114 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
116 Label
= Window
.GetControl (0x10000003)
120 Window
.CreateMapControl (2, 0, 0, 0, 0)
121 Map
= Window
.GetControl (2)
122 GemRB
.SetVar ("ShowMapNotes",IE_GUI_MAP_REVEAL_MAP
)
123 Map
.SetVarAssoc ("ShowMapNotes", IE_GUI_MAP_REVEAL_MAP
)
124 Map
.SetEvent (IE_GUI_MAP_ON_PRESS
, RevealMap
)
125 Window
.SetVisible (WINDOW_VISIBLE
)
126 OptionsWindow
.SetVisible (WINDOW_GRAYED
)
127 PortraitWindow
.SetVisible (WINDOW_GRAYED
)
128 OptionsWindow
.SetVisible (WINDOW_FRONT
)
129 PortraitWindow
.SetVisible (WINDOW_FRONT
)
130 Window
.SetVisible (WINDOW_FRONT
)
131 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
132 GemRB
.GamePause (0,0)
135 ###################################################
136 def OpenMapWindow ():
137 global MapWindow
, OptionsWindow
, PortraitWindow
138 global OldPortraitWindow
, OldOptionsWindow
140 if GUICommon
.CloseOtherWindow (OpenMapWindow
):
144 OptionsWindow
.Unload ()
146 PortraitWindow
.Unload ()
149 #this window type should block the game
150 GemRB
.SetVar ("OtherWindow", -1)
151 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
153 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
154 OldPortraitWindow
= None
155 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
156 OldOptionsWindow
= None
160 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
162 GemRB
.LoadWindowPack ("GUIMAP", 640, 480)
163 MapWindow
= Window
= GemRB
.LoadWindow (2)
164 #this window type blocks the game normally, but map window doesn't
165 GemRB
.SetVar ("OtherWindow", MapWindow
.ID
)
166 #saving the original portrait window
167 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
168 OptionsWindow
= GemRB
.LoadWindow (0)
169 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 0, OpenMapWindow
)
170 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
171 PortraitWindow
= GUICommonWindows
.OpenPortraitWindow (0)
172 OptionsWindow
.SetFrame ()
175 Button
= Window
.GetControl (1)
176 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenWorldMapWindowInside
)
179 Window
.CreateMapControl (2, 0, 0, 0, 0)
180 Map
= Window
.GetControl (2)
181 Map
.SetEvent (IE_GUI_MAP_ON_DOUBLE_PRESS
, LeftDoublePressMap
)
183 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
184 Window
.SetVisible (WINDOW_VISIBLE
)
185 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
186 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
188 def LeftDoublePressMap ():
192 def OpenWorldMapWindowInside ():
195 OpenMapWindow () #closes mapwindow
197 print "MapWindow=",MapWindow
198 WorldMapWindowCommon (-1)
201 def OpenWorldMapWindow ():
202 WorldMapWindowCommon (GemRB
.GetVar ("Travel"))
205 def MoveToNewArea ():
206 global WorldMapWindow
, WorldMapControl
208 tmp
= WorldMapControl
.GetDestinationArea (1)
209 CloseWorldMapWindow ()
210 GemRB
.CreateMovement (tmp
["Destination"], tmp
["Entrance"], tmp
["Direction"])
213 def ChangeTooltip ():
214 global WorldMapWindow
, WorldMapControl
217 tmp
= WorldMapControl
.GetDestinationArea ()
219 str = "%s: %d"%(GemRB
.GetString(23084),tmp
["Distance"])
223 WorldMapControl
.SetTooltip (str)
226 def CloseWorldMapWindow ():
227 global WorldMapWindow
, WorldMapControl
229 print "CloseWorldMapWindow found Mapwindow = ",MapWindow
233 WorldMapWindow
.Unload ()
234 WorldMapWindow
= None
235 WorldMapControl
= None
240 WorldMapWindow
.Unload ()
241 WorldMapWindow
= None
242 WorldMapControl
= None
243 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
247 def WorldMapWindowCommon (Travel
):
248 global WorldMapWindow
, WorldMapControl
251 CloseWorldMapWindow ()
255 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
257 GemRB
.LoadWindowPack ("GUIWMAP", 640, 480)
258 WorldMapWindow
= Window
= GemRB
.LoadWindow (0)
259 #saving the original portrait window
262 Window
.CreateWorldMapControl (4, 0, 62, 640, 418, Travel
, "infofont")
263 WorldMapControl
= Window
.GetControl (4)
264 WorldMapControl
.SetAnimation ("WMDAG")
265 WorldMapControl
.SetEvent (IE_GUI_WORLDMAP_ON_PRESS
, MoveToNewArea
)
266 WorldMapControl
.SetEvent (IE_GUI_MOUSE_ENTER_WORLDMAP
, ChangeTooltip
)
267 #center on current area
268 WorldMapControl
.AdjustScrolling (0,0)
271 Button
= Window
.GetControl (1)
272 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MapN
)
275 Button
= Window
.GetControl (2)
276 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MapS
)
279 Button
= Window
.GetControl (0)
280 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseWorldMapWindow
)
281 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
282 Window
.SetVisible (WINDOW_VISIBLE
)
286 WorldMapControl
.AdjustScrolling (0, -10)
290 WorldMapControl
.AdjustScrolling (0, 10)
294 ###################################################
295 # End of file GUIMA.py