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 ###################################################
26 import GUICommonWindows
27 from GUIDefines
import *
28 from GUICommon
import CloseOtherWindow
29 from GUICommon
import GameWindow
30 from GUICommonWindows
import *
34 WorldMapControl
= None
36 OldPortraitWindow
= None
38 OldOptionsWindow
= None
42 global OldPortraitWindow
, OldOptionsWindow
44 if CloseOtherWindow (ShowMap
):
48 OptionsWindow
.Unload ()
50 PortraitWindow
.Unload ()
53 #this window type should block the game
54 GemRB
.SetVar ("OtherWindow", -1)
55 GameWindow
.SetVisible(WINDOW_VISIBLE
)
57 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
58 OldPortraitWindow
= None
59 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
60 OldOptionsWindow
= None
62 PosX
= GemRB
.GetVar ("MapControlX")
63 PosY
= GemRB
.GetVar ("MapControlY")
65 GemRB
.RevealArea (PosX
, PosY
, 30, 1)
69 ###################################################
71 ###################################################
73 global MapWindow
, OptionsWindow
, PortraitWindow
74 global OldPortraitWindow
, OldOptionsWindow
76 if CloseOtherWindow (ShowMap
):
80 OptionsWindow
.Unload ()
82 PortraitWindow
.Unload ()
85 #this window type should block the game
86 GemRB
.SetVar ("OtherWindow", -1)
87 GameWindow
.SetVisible(WINDOW_VISIBLE
)
89 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
90 OldPortraitWindow
= None
91 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
92 OldOptionsWindow
= None
96 GameWindow
.SetVisible(WINDOW_INVISIBLE
)
98 GemRB
.LoadWindowPack ("GUIMAP", 640, 480)
99 MapWindow
= Window
= GemRB
.LoadWindowObject (2)
100 #this window type blocks the game normally, but map window doesn't
101 GemRB
.SetVar ("OtherWindow", MapWindow
.ID
)
102 #saving the original portrait window
103 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
104 OptionsWindow
= GemRB
.LoadWindowObject (0)
105 SetupMenuWindowControls (OptionsWindow
, 0, "ShowMap")
106 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
107 PortraitWindow
= OpenPortraitWindow (0)
108 OptionsWindow
.SetFrame ()
111 Button
= Window
.GetControl (1)
112 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
115 Window
.CreateMapControl (2, 0, 0, 0, 0)
116 Map
= Window
.GetControl (2)
117 Map
.SetEvent (IE_GUI_MAP_ON_PRESS
, "RevealMap")
118 Window
.SetVisible (WINDOW_VISIBLE
)
119 OptionsWindow
.SetVisible (WINDOW_GRAYED
)
120 PortraitWindow
.SetVisible (WINDOW_GRAYED
)
121 OptionsWindow
.SetVisible (WINDOW_FRONT
)
122 PortraitWindow
.SetVisible (WINDOW_FRONT
)
123 Window
.SetVisible (WINDOW_FRONT
)
124 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
125 GemRB
.GamePause (0,0)
128 ###################################################
129 def OpenMapWindow ():
130 global MapWindow
, OptionsWindow
, PortraitWindow
131 global OldPortraitWindow
, OldOptionsWindow
133 if CloseOtherWindow (OpenMapWindow
):
137 OptionsWindow
.Unload ()
139 PortraitWindow
.Unload ()
142 #this window type should block the game
143 GemRB
.SetVar ("OtherWindow", -1)
144 GameWindow
.SetVisible(WINDOW_VISIBLE
)
145 #OldOptionsWindow.SetVisible (WINDOW_VISIBLE)
146 #OldPortraitWindow.SetVisible (WINDOW_VISIBLE)
148 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
149 OldPortraitWindow
= None
150 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
151 OldOptionsWindow
= None
155 GameWindow
.SetVisible(WINDOW_INVISIBLE
)
157 GemRB
.LoadWindowPack ("GUIMAP", 640, 480)
158 MapWindow
= Window
= GemRB
.LoadWindowObject (2)
159 #this window type blocks the game normally, but map window doesn't
160 GemRB
.SetVar ("OtherWindow", MapWindow
.ID
)
161 #saving the original portrait window
162 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
163 OptionsWindow
= GemRB
.LoadWindowObject (0)
164 MarkMenuButton (OptionsWindow
)
165 SetupMenuWindowControls (OptionsWindow
, 0, "OpenMapWindow")
166 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
167 PortraitWindow
= OpenPortraitWindow (0)
168 OptionsWindow
.SetFrame ()
171 Button
= Window
.GetControl (1)
172 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "OpenWorldMapWindowInside")
175 Window
.CreateMapControl (2, 0, 0, 0, 0)
176 Map
= Window
.GetControl (2)
177 Map
.SetEvent (IE_GUI_MAP_ON_DOUBLE_PRESS
, "LeftDoublePressMap")
178 #OldOptionsWindow.SetVisible (WINDOW_INVISIBLE)
179 #OldPortraitWindow.SetVisible (WINDOW_INVISIBLE)
180 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
181 Window
.SetVisible (WINDOW_VISIBLE
)
182 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
183 Map
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
185 def LeftDoublePressMap ():
190 def OpenWorldMapWindowInside ():
193 OpenMapWindow () #closes mapwindow
195 print "MapWindow=",MapWindow
196 WorldMapWindowCommon (-1)
199 def OpenWorldMapWindow ():
200 WorldMapWindowCommon (GemRB
.GetVar ("Travel"))
203 def MoveToNewArea ():
204 global WorldMapWindow
, WorldMapControl
206 tmp
= WorldMapControl
.GetDestinationArea (1)
207 if tmp
["Distance"]==-1:
208 print "Invalid target", tmp
211 CloseWorldMapWindow ()
212 GemRB
.CreateMovement (tmp
["Destination"], tmp
["Entrance"], tmp
["Direction"])
215 def ChangeTooltip ():
216 global WorldMapWindow
, WorldMapControl
219 tmp
= WorldMapControl
.GetDestinationArea ()
221 str = "%s: %d"%(GemRB
.GetString(23084),tmp
["Distance"])
225 WorldMapControl
.SetTooltip (str)
228 def CloseWorldMapWindow ():
229 global WorldMapWindow
, WorldMapControl
231 print "CloseWorldMapWindow found Mapwindow = ",MapWindow
235 WorldMapWindow
.Unload ()
236 WorldMapWindow
= None
237 WorldMapControl
= None
242 WorldMapWindow
.Unload ()
243 WorldMapWindow
= None
244 WorldMapControl
= None
245 GameWindow
.SetVisible(WINDOW_VISIBLE
)
249 def WorldMapWindowCommon (Travel
):
250 global WorldMapWindow
, WorldMapControl
253 CloseWorldMapWindow ()
257 GameWindow
.SetVisible(WINDOW_INVISIBLE
)
259 GemRB
.LoadWindowPack ("GUIWMAP", 640, 480)
260 WorldMapWindow
= Window
= GemRB
.LoadWindowObject (0)
261 #saving the original portrait window
264 Window
.CreateWorldMapControl (4, 0, 62, 640, 418, Travel
, "toolfont")
265 WorldMapControl
= Window
.GetControl (4)
266 WorldMapControl
.SetAnimation ("WMDAG")
267 WorldMapControl
.SetEvent (IE_GUI_WORLDMAP_ON_PRESS
, "MoveToNewArea")
268 WorldMapControl
.SetEvent (IE_GUI_MOUSE_ENTER_WORLDMAP
, "ChangeTooltip")
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