factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / MessageWindow.py
blobb997f5e75649d0f988896438419ccae8ba03571d
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 import GemRB
21 import GUICommon
22 import GUICommonWindows
23 import CommonWindow
24 import GUIClasses
25 from GUIDefines import *
27 MessageWindow = 0
28 PortraitWindow = 0
29 OptionsWindow = 0
30 ExpandButton = 0
31 ContractButton = 0
33 def OnLoad():
34 global PortraitWindow, OptionsWindow
36 GemRB.GameSetPartySize(PARTY_SIZE)
37 GemRB.GameSetProtagonistMode(1)
38 GemRB.LoadWindowPack(GUICommon.GetWindowPack())
40 GUICommonWindows.PortraitWindow = None
41 GUICommonWindows.ActionsWindow = None
42 GUICommonWindows.OptionsWindow = None
44 ActionsWindow = GemRB.LoadWindow(3)
45 OptionsWindow = GemRB.LoadWindow(0)
46 PortraitWindow = GUICommonWindows.OpenPortraitWindow(1)
48 GemRB.SetVar("PortraitWindow", PortraitWindow.ID)
49 GemRB.SetVar("ActionsWindow", ActionsWindow.ID)
50 GemRB.SetVar("OptionsWindow", OptionsWindow.ID)
51 GemRB.SetVar("TopWindow", -1)
52 GemRB.SetVar("OtherWindow", -1)
53 GemRB.SetVar("FloatWindow", -1)
54 GemRB.SetVar("PortraitPosition", 2) #Right
55 GemRB.SetVar("ActionsPosition", 4) #BottomAdded
56 GemRB.SetVar("OptionsPosition", 0) #Left
57 GemRB.SetVar("MessagePosition", 4) #BottomAdded
58 GemRB.SetVar("OtherPosition", 5) #Inactivating
59 GemRB.SetVar("TopPosition", 5) #Inactivating
61 GUICommonWindows.OpenActionsWindowControls (ActionsWindow)
62 GUICommonWindows.SetupMenuWindowControls (OptionsWindow, 1, None)
64 UpdateControlStatus()
66 def ScrollUp ():
67 TMessageWindow = GemRB.GetVar("MessageWindow")
68 TMessageTA = GUIClasses.GTextArea(TMessageWindow,GemRB.GetVar("MessageTextArea"))
69 TMessageTA.Scroll(-1)
71 def ScrollDown ():
72 TMessageWindow = GemRB.GetVar("MessageWindow")
73 TMessageTA = GUIClasses.GTextArea(TMessageWindow,GemRB.GetVar("MessageTextArea"))
74 TMessageTA.Scroll(1)
76 def UpdateControlStatus():
77 global MessageWindow, ExpandButton, ContractButton
79 TMessageWindow = 0
80 TMessageTA = 0
81 GSFlags = GemRB.GetMessageWindowSize()
82 Expand = GSFlags&GS_DIALOGMASK
83 Override = GSFlags&GS_DIALOG
84 GSFlags = GSFlags-Expand
86 #a dialogue is running, setting messagewindow size to maximum
87 if Override:
88 Expand = GS_LARGEDIALOG
90 MessageWindow = GemRB.GetVar("MessageWindow")
92 GemRB.LoadWindowPack(GUICommon.GetWindowPack())
94 if Expand == GS_MEDIUMDIALOG:
95 TMessageWindow = GemRB.LoadWindow(12)
96 TMessageTA = TMessageWindow.GetControl(1)
97 ExpandButton = TMessageWindow.GetControl(0)
98 ExpandButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CommonWindow.OnIncreaseSize)
99 ContractButton = TMessageWindow.GetControl(3)
100 ContractButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CommonWindow.OnDecreaseSize)
102 elif Expand == GS_LARGEDIALOG:
103 TMessageWindow = GemRB.LoadWindow(7)
104 TMessageTA = TMessageWindow.GetControl(1)
105 ContractButton = TMessageWindow.GetControl(0)
106 ContractButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CommonWindow.OnDecreaseSize)
108 else:
109 TMessageWindow = GemRB.LoadWindow(4)
110 TMessageTA = TMessageWindow.GetControl(3)
111 ExpandButton = TMessageWindow.GetControl(2)
112 ExpandButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CommonWindow.OnIncreaseSize)
113 #up button (instead of scrollbar)
114 Button = TMessageWindow.GetControl(0)
115 Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ScrollUp)
116 #down button (instead of scrollbar)
117 Button = TMessageWindow.GetControl(1)
118 Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, ScrollDown)
120 TMessageTA.SetFlags(IE_GUI_TEXTAREA_AUTOSCROLL)
121 TMessageTA.SetHistory(100)
123 hideflag = GemRB.HideGUI()
124 MessageTA = GUIClasses.GTextArea(MessageWindow,GemRB.GetVar("MessageTextArea"))
125 if MessageWindow>0 and MessageWindow!=TMessageWindow.ID:
126 MessageTA.MoveText(TMessageTA)
127 GUIClasses.GWindow(MessageWindow).Unload()
129 GemRB.SetVar("MessageWindow", TMessageWindow.ID)
130 GemRB.SetVar("MessageTextArea", TMessageTA.ID)
131 if Override:
132 TMessageTA.SetStatus (IE_GUI_CONTROL_FOCUSED)
133 else:
134 GUICommon.GameControl.SetStatus(IE_GUI_CONTROL_FOCUSED)
136 if GSFlags & GS_OPTIONPANE:
137 GemRB.SetVar("OptionsWindow", -1)
138 else:
139 GemRB.SetVar("OptionsWindow", OptionsWindow.ID)
141 if GSFlags & GS_PORTRAITPANE:
142 GemRB.SetVar("PortraitWindow", -1)
143 else:
144 GemRB.SetVar("PortraitWindow", PortraitWindow.ID)
146 if hideflag:
147 GemRB.UnhideGUI()