factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / iwd / MessageWindow.py
bloba4d41ba96e27267c296f1783654caf200721feb8
1 # -*-python-*-
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 ###################################################
24 import GemRB
25 import GUICommon
26 import GUICommonWindows
27 import CommonWindow
28 from GUIDefines import *
29 import GUIClasses
31 MessageWindow = 0
32 PortraitWindow = 0
33 OptionsWindow = 0
34 ExpandButton = 0
35 ContractButton = 0
37 def OnLoad():
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)
51 else:
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
77 TMessageWindow = 0
78 TMessageTA = 0
79 GSFlags = GemRB.GetMessageWindowSize ()
80 Expand = GSFlags&GS_DIALOGMASK
81 Override = GSFlags&GS_DIALOG
82 GSFlags = GSFlags-Expand
84 if Override:
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)
104 else:
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)
121 if Override:
122 TMessageTA.SetStatus (IE_GUI_CONTROL_FOCUSED)
123 else:
124 GUICommon.GameControl.SetStatus(IE_GUI_CONTROL_FOCUSED)
126 if hideflag:
127 GemRB.UnhideGUI ()
128 return
130 #upgrade savegame to next version
131 def GameExpansion():
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)
135 return