iwd: more gcw syncing with bg2 - actonpc and dragging
[gemrb.git] / gemrb / GUIScripts / pst / GUIMA.py
blob4ed550cd3460bc966c7bde6aefa5638af6765f56
1 # -*-python-*-
2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003 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 GUIMA and GUIWMAP winpacks
23 ###################################################
25 import GemRB
26 import GUICommon
27 import GUICommonWindows
28 from GUIDefines import *
30 MapWindow = None
31 WorldMapWindow = None
32 PosX = 0
33 PosY = 0
35 ###################################################
36 def OpenMapWindow ():
37 global MapWindow
39 if GUICommon.CloseOtherWindow (OpenMapWindow):
40 GemRB.HideGUI ()
41 if WorldMapWindow: OpenWorldMapWindowInside ()
43 if MapWindow:
44 MapWindow.Unload ()
45 MapWindow = None
46 GemRB.SetVar ("OtherWindow", -1)
48 GemRB.UnhideGUI ()
49 return
51 GemRB.HideGUI ()
52 GemRB.LoadWindowPack ("GUIMA")
53 MapWindow = Window = GemRB.LoadWindow (3)
54 GemRB.SetVar ("OtherWindow", MapWindow.ID)
56 # World Map
57 Button = Window.GetControl (0)
58 Button.SetText (20429)
59 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindow)
61 # Add Note
62 Button = Window.GetControl (1)
63 Button.SetText (4182)
64 Button.SetVarAssoc ("x", IE_GUI_MAP_SET_NOTE)
66 # Note text
67 Text = Window.GetControl (4)
68 Text.SetText ("")
70 Edit = Window.CreateTextEdit (6, 0, 0, 200, 100, "FONTDLG", " ")
72 # Map Control
73 # ronote and usernote are the pins for the notes
74 # 4 is the Label's control ID
75 Window.CreateMapControl (3, 24, 23, 480, 360, 4, "USERNOTE","RONOTE")
76 Map = Window.GetControl (3)
77 GemRB.SetVar ("x",IE_GUI_MAP_VIEW_NOTES)
78 Map.SetVarAssoc ("x", IE_GUI_MAP_VIEW_NOTES)
80 Map.SetEvent (IE_GUI_MAP_ON_PRESS, SetMapNote)
82 MapTable = GemRB.LoadTable( "MAPNAME" )
83 MapName = MapTable.GetValue (GemRB.GetCurrentArea (), "STRING")
85 Label = Window.GetControl (0x10000005)
86 Label.SetText (MapName)
87 #Label.SetTextColor (255, 0, 0)
88 # 2 - map name?
89 # 3 - map bitmap?
90 # 4 - ???
92 # Done
93 Button = Window.GetControl (5)
94 Button.SetText (1403)
95 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenMapWindow)
96 Button.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
98 GemRB.UnhideGUI ()
100 def NoteChanged ():
101 Label = MapWindow.GetControl (6)
102 Text = Label.QueryText ()
103 GemRB.SetMapnote (PosX, PosY, 0, Text)
104 return
106 def SetMapNote ():
107 global PosX, PosY
109 Label = MapWindow.GetControl (6)
110 Label.SetEvent (IE_GUI_EDIT_ON_CHANGE, NoteChanged)
111 PosX = GemRB.GetVar("MapControlX")
112 PosY = GemRB.GetVar("MapControlY")
113 Label.SetStatus (IE_GUI_CONTROL_FOCUSED)
114 Map = MapWindow.GetControl (3)
115 GemRB.SetVar ("x",IE_GUI_MAP_VIEW_NOTES)
116 Map.SetVarAssoc ("x", IE_GUI_MAP_VIEW_NOTES)
117 return
119 def OpenWorldMapWindowInside ():
120 WorldMapWindowCommon (-1)
121 return
123 def OpenWorldMapWindow ():
124 WorldMapWindowCommon (GemRB.GetVar ("Travel"))
125 return
127 def WorldMapWindowCommon (Travel):
128 global WorldMapWindow
130 GemRB.HideGUI()
132 if WorldMapWindow:
133 if WorldMapWindow:
134 WorldMapWindow.Unload ()
135 WorldMapWindow = None
136 GemRB.SetVar ("OtherWindow", -1)
137 GUICommonWindows.EnableAnimatedWindows ()
138 GemRB.UnhideGUI ()
139 return
141 GUICommonWindows.DisableAnimatedWindows ()
142 GemRB.LoadWindowPack ("GUIWMAP")
143 WorldMapWindow = Window = GemRB.LoadWindow (0)
144 MapWindow = None
145 GemRB.SetVar ("OtherWindow", WorldMapWindow.ID)
147 Window.CreateWorldMapControl (4, 0, 62, 640, 418, Travel, "FONTDLG")
148 WMap = Window.GetControl (4)
149 WMap.SetTextColor (IE_GUI_WMAP_COLOR_NORMAL, 0x20, 0x20, 0x00, 0xff)
150 WMap.SetTextColor (IE_GUI_WMAP_COLOR_SELECTED, 0x20, 0x20, 0x00, 0xff)
151 WMap.SetTextColor (IE_GUI_WMAP_COLOR_NOTVISITED, 0x20, 0x20, 0x00, 0xa0)
152 WMap.SetAnimation ("WMPTY")
154 # Done
155 Button = Window.GetControl (0)
156 Button.SetText (1403)
157 if Travel>=0:
158 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenWorldMapWindow)
159 else:
160 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenMapWindow)
161 GemRB.UnhideGUI ()
163 ###################################################
164 # End of file GUIMA.py