GUIScript: Remove last direct uses of metaclass methods.
[gemrb.git] / gemrb / GUIScripts / iwd2 / MessageWindow.py
blobe1237d26d18807b98b6c9c4e46240d3e53b982b1
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
22 from GUICommonWindows import *
23 import GUICommonWindows
24 from GUICommon import GameControl
25 from GUIINV import *
26 from GUIJRNL import *
27 from GUIMA import *
28 from GUIOPT import *
29 from GUISPL import *
30 from GUIREC import *
31 from GUISTORE import *
32 from GUIWORLD import *
33 from TextScreen import *
34 from GUIClasses import GTextArea
35 from GUIClasses import GWindow
37 MessageWindow = 0
38 PortraitWindow = 0
39 def OnLoad():
40 global MessageWindow, PortraitWindow
42 GemRB.GameSetPartySize(PARTY_SIZE)
43 GemRB.GameSetProtagonistMode(2)
44 GemRB.SetDefaultActions(1,14,16,17)
45 GemRB.LoadWindowPack(GetWindowPack())
46 OptionsWindow = MessageWindow = GemRB.LoadWindowObject(0)
47 ActionsWindow = PortraitWindow = OpenPortraitWindow()
49 GemRB.SetVar ("MessageWindow", MessageWindow.ID)
50 GemRB.SetVar ("PortraitWindow", PortraitWindow.ID)
51 GemRB.SetVar ("TopWindow", -1)
52 GemRB.SetVar ("OtherWindow", -1)
53 GemRB.SetVar ("FloatWindow", -1)
54 GemRB.SetVar ("ActionsPosition", -1) #already handled in portraitwindow
55 GemRB.SetVar ("OptionsPosition", -1) #already handled in messagewindow
56 GemRB.SetVar ("MessagePosition", 4)
57 GemRB.SetVar ("PortraitPosition", 4)
58 GemRB.SetVar ("OtherPosition", 5) #Inactivating
59 GemRB.SetVar ("TopPosition", 5) #Inactivating
61 SetupMenuWindowControls (OptionsWindow, 1, "ReturnToGame")
63 MessageWindow.SetVisible(WINDOW_VISIBLE)
64 PortraitWindow.SetVisible(WINDOW_VISIBLE)
65 return
67 def OnIncreaseSize():
68 GemRB.GameSetScreenFlags(GS_LARGEDIALOG, OP_OR)
70 def OnDecreaseSize():
71 GemRB.GameSetScreenFlags(GS_LARGEDIALOG, OP_NAND)
73 def UpdateControlStatus():
74 global MessageWindow
76 TMessageWindow = 0
77 TMessageTA = 0
78 GSFlags = GemRB.GetMessageWindowSize()
79 Expand = GSFlags&GS_DIALOGMASK
80 Override = GSFlags&GS_DIALOG
81 GSFlags = GSFlags-Expand
83 #a dialogue is running, setting messagewindow size to maximum
84 if Override:
85 Expand = GS_LARGEDIALOG
87 MessageWindow = GemRB.GetVar ("MessageWindow")
89 GemRB.LoadWindowPack(GetWindowPack())
90 hideflag = GemRB.HideGUI()
91 if Expand == GS_LARGEDIALOG:
92 GemRB.SetVar ("PortraitWindow", -1)
93 TMessageWindow = GemRB.LoadWindowObject(7)
94 TMessageTA = TMessageWindow.GetControl (1)
95 else:
96 GemRB.SetVar ("PortraitWindow", PortraitWindow.ID)
97 TMessageWindow = GemRB.LoadWindowObject(0)
98 TMessageTA = TMessageWindow.GetControl (1)
99 SetupMenuWindowControls (TMessageWindow, 1, "ReturnToGame")
102 TMessageTA.SetFlags(IE_GUI_TEXTAREA_AUTOSCROLL)
103 TMessageTA.SetHistory(100)
105 MessageTA = GTextArea(MessageWindow, GemRB.GetVar ("MessageTextArea"))
106 if MessageWindow>0 and MessageWindow!=TMessageWindow.ID:
107 MessageTA.MoveText (TMessageTA)
108 GWindow(MessageWindow).Unload()
109 GemRB.SetVar ("MessageWindow", TMessageWindow.ID)
110 GemRB.SetVar ("MessageTextArea", TMessageTA.ID)
112 if Override:
113 TMessageTA.SetStatus (IE_GUI_CONTROL_FOCUSED)
114 #gets PC currently talking
115 pc = GemRB.GameGetSelectedPCSingle (1)
116 if pc:
117 Portrait = GemRB.GetPlayerPortrait(pc,1)
118 else:
119 Portrait = None
120 Button = TMessageWindow.GetControl(11)
121 Button.SetState (IE_GUI_BUTTON_LOCKED)
122 if not Portrait:
123 Button.SetFlags(IE_GUI_BUTTON_NO_IMAGE, OP_SET)
124 else:
125 Button.SetPicture(Portrait, "NOPORTSM")
126 else:
127 GameControl.SetStatus(IE_GUI_CONTROL_FOCUSED)
129 if hideflag:
130 GemRB.UnhideGUI()
131 return