1 # GemRB - Infinity Engine Emulator
2 # Copyright (C) 2003 The GemRB Project
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #character generation, appearance (GUICG12)
21 from GUIDefines
import *
30 global PortraitsTable
, LastPortrait
32 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"L"
33 PortraitButton
.SetPicture (PortraitName
)
37 global AppearanceWindow
, PortraitButton
, PortraitsTable
, LastPortrait
40 Gender
=GemRB
.GetVar ("Gender")
42 GemRB
.LoadWindowPack ("GUICG", 800, 600)
43 AppearanceWindow
= GemRB
.LoadWindow (11)
44 #AppearanceWindow.SetFrame ()
46 #Load the Portraits Table
47 PortraitsTable
= GemRB
.LoadTable ("PICTURES")
50 PortraitButton
= AppearanceWindow
.GetControl (1)
51 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
52 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
54 LeftButton
= AppearanceWindow
.GetControl (2)
55 RightButton
= AppearanceWindow
.GetControl (3)
57 BackButton
= AppearanceWindow
.GetControl (5)
58 BackButton
.SetText (15416)
59 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
,OP_OR
)
61 CustomButton
= AppearanceWindow
.GetControl (6)
62 CustomButton
.SetText (17545)
64 DoneButton
= AppearanceWindow
.GetControl (0)
65 DoneButton
.SetText (36789)
66 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
,OP_OR
)
68 RightButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RightPress
)
69 LeftButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LeftPress
)
70 BackButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BackPress
)
71 CustomButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomPress
)
72 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, NextPress
)
75 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
78 LastPortrait
= LastPortrait
+ 1
79 AppearanceWindow
.SetVisible (WINDOW_VISIBLE
)
85 LastPortrait
= LastPortrait
+ 1
86 if LastPortrait
>= PortraitsTable
.GetRowCount ():
88 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
95 LastPortrait
= LastPortrait
- 1
97 LastPortrait
= PortraitsTable
.GetRowCount ()-1
98 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
104 AppearanceWindow
.Unload ()
105 GemRB
.SetNextScript ("CharGen")
106 GemRB
.SetVar ("Gender",0) #scrapping the gender value
110 Window
= CustomWindow
112 Portrait
= PortraitList1
.QueryText ()
113 GemRB
.SetToken ("SmallPortrait", Portrait
)
114 Portrait
= PortraitList2
.QueryText ()
115 GemRB
.SetToken ("LargePortrait", Portrait
)
119 AppearanceWindow
.Unload ()
120 GemRB
.SetNextScript ("CharGen2")
125 CustomWindow
.Unload ()
128 def LargeCustomPortrait ():
129 Window
= CustomWindow
131 Portrait
= PortraitList1
.QueryText ()
133 if GemRB
.GetVar ("Row1") == RowCount1
:
136 Label
= Window
.GetControl (0x10000007)
137 Label
.SetText (Portrait
)
139 Button
= Window
.GetControl (6)
141 Portrait
= "NOPORTMD"
142 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
144 if PortraitList2
.QueryText ()!="":
145 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
147 Button
= Window
.GetControl (0)
148 Button
.SetPicture (Portrait
, "NOPORTMD")
151 def SmallCustomPortrait ():
152 Window
= CustomWindow
154 Portrait
= PortraitList2
.QueryText ()
156 if GemRB
.GetVar ("Row2") == RowCount2
:
159 Label
= Window
.GetControl (0x10000008)
160 Label
.SetText (Portrait
)
162 Button
= Window
.GetControl (6)
164 Portrait
= "NOPORTSM"
165 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
167 if PortraitList1
.QueryText ()!="":
168 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
170 Button
= Window
.GetControl (1)
171 Button
.SetPicture (Portrait
, "NOPORTSM")
175 global PortraitList1
, PortraitList2
176 global RowCount1
, RowCount2
179 CustomWindow
= Window
= GemRB
.LoadWindow (18)
180 PortraitList1
= Window
.GetControl (2)
181 RowCount1
= PortraitList1
.GetPortraits (0)
182 PortraitList1
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, LargeCustomPortrait
)
183 GemRB
.SetVar ("Row1", RowCount1
)
184 PortraitList1
.SetVarAssoc ("Row1",RowCount1
)
186 PortraitList2
= Window
.GetControl (4)
187 RowCount2
= PortraitList2
.GetPortraits (1)
188 PortraitList2
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, SmallCustomPortrait
)
189 GemRB
.SetVar ("Row2", RowCount2
)
190 PortraitList2
.SetVarAssoc ("Row2",RowCount2
)
192 Button
= Window
.GetControl (6)
193 Button
.SetText (11973)
194 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
,OP_OR
)
195 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomDone
)
196 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
198 Button
= Window
.GetControl (7)
199 Button
.SetText (15416)
200 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
,OP_OR
)
201 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomAbort
)
203 Button
= Window
.GetControl (0)
204 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"L"
205 Button
.SetPicture (PortraitName
, "NOPORTMD")
206 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
208 Button
= Window
.GetControl (1)
209 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"S"
210 Button
.SetPicture (PortraitName
, "NOPORTSM")
211 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
213 Window
.ShowModal (MODAL_SHADOW_NONE
)
218 AppearanceWindow
.Unload ()
219 PortraitTable
= GemRB
.LoadTable ("pictures")
220 PortraitName
= PortraitTable
.GetRowName (LastPortrait
)
221 GemRB
.SetToken ("SmallPortrait", PortraitName
+"S")
222 GemRB
.SetToken ("LargePortrait", PortraitName
+"L")
223 #GemRB.SetVar ("PortraitIndex",LastPortrait)
224 GemRB
.SetNextScript ("CharGen2") #Before race