2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2005 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.
20 # MessageWindow.py - scripts and GUI for main (walk) window
22 ###################################################
26 import GUICommonWindows
28 from GUIDefines
import *
38 global PortraitWindow
, OptionsWindow
40 GemRB
.GameSetPartySize (PARTY_SIZE
)
41 GemRB
.GameSetProtagonistMode (2)
42 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
44 GUICommonWindows
.PortraitWindow
= None
45 GUICommonWindows
.ActionsWindow
= None
46 GUICommonWindows
.OptionsWindow
= None
48 #this is different in IWD (0) and HoW (25)
49 if GUICommon
.HasHOW():
50 OptionsWindow
= GemRB
.LoadWindow (25)
52 OptionsWindow
= GemRB
.LoadWindow (0)
53 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 1, None)
54 PortraitWindow
= GUICommonWindows
.OpenPortraitWindow (1)
56 ActionsWindow
= GemRB
.LoadWindow (3)
57 GUICommonWindows
.OpenActionsWindowControls (ActionsWindow
)
59 GemRB
.SetVar ("PortraitWindow", PortraitWindow
.ID
)
60 GemRB
.SetVar ("ActionsWindow", ActionsWindow
.ID
)
61 GemRB
.SetVar ("OptionsWindow", OptionsWindow
.ID
)
62 GemRB
.SetVar ("TopWindow", -1)
63 GemRB
.SetVar ("OtherWindow", -1)
64 GemRB
.SetVar ("FloatWindow", -1)
65 GemRB
.SetVar ("PortraitPosition", 2) #Right
66 GemRB
.SetVar ("ActionsPosition", 4) #BottomAdded
67 GemRB
.SetVar ("OptionsPosition", 0) #Left
68 GemRB
.SetVar ("MessagePosition", 4) #BottomAdded
69 GemRB
.SetVar ("OtherPosition", 5) #Inactivating
70 GemRB
.SetVar ("TopPosition", 5) #Inactivating
72 UpdateControlStatus ()
74 def UpdateControlStatus ():
75 global MessageWindow
, ExpandButton
, ContractButton
79 GSFlags
= GemRB
.GetMessageWindowSize ()
80 Expand
= GSFlags
&GS_DIALOGMASK
81 Override
= GSFlags
&GS_DIALOG
82 GSFlags
= GSFlags
-Expand
85 Expand
= GS_LARGEDIALOG
87 MessageWindow
= GemRB
.GetVar ("MessageWindow")
89 GemRB
.LoadWindowPack (GUICommon
.GetWindowPack())
91 if Expand
== GS_MEDIUMDIALOG
:
92 TMessageWindow
= GemRB
.LoadWindow (12)
93 TMessageTA
= TMessageWindow
.GetControl (1)
94 ExpandButton
= TMessageWindow
.GetControl (0)
95 ExpandButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CommonWindow
.OnIncreaseSize
)
96 ContractButton
= TMessageWindow
.GetControl (3)
97 ContractButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CommonWindow
.OnDecreaseSize
)
99 elif Expand
== GS_LARGEDIALOG
:
100 TMessageWindow
= GemRB
.LoadWindow (7)
101 TMessageTA
= TMessageWindow
.GetControl (1)
102 ContractButton
= TMessageWindow
.GetControl (0)
103 ContractButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CommonWindow
.OnDecreaseSize
)
105 TMessageWindow
= GemRB
.LoadWindow (4)
106 TMessageTA
= TMessageWindow
.GetControl (3)
107 ExpandButton
= TMessageWindow
.GetControl (2)
108 ExpandButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CommonWindow
.OnIncreaseSize
)
110 TMessageTA
.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL
)
111 TMessageTA
.SetHistory (100)
113 hideflag
= GemRB
.HideGUI ()
114 MessageTA
= GUIClasses
.GTextArea (MessageWindow
,GemRB
.GetVar ("MessageTextArea"))
115 if MessageWindow
>0 and MessageWindow
!=TMessageWindow
.ID
:
116 MessageTA
.MoveText (TMessageTA
)
117 GUIClasses
.GWindow(MessageWindow
).Unload()
119 GemRB
.SetVar ("MessageWindow", TMessageWindow
.ID
)
120 GemRB
.SetVar ("MessageTextArea", TMessageTA
.ID
)
122 TMessageTA
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
124 GUICommon
.GameControl
.SetStatus(IE_GUI_CONTROL_FOCUSED
)
130 #upgrade savegame to next version
132 #the original savegames got 0, but the engine upgrades all saves to 3
133 #this is a good place to perform one-time adjustments if needed
134 GemRB
.GameSetExpansion(3)