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 *
22 from ie_stats
import *
35 global PortraitsTable
, LastPortrait
37 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"G"
38 PortraitButton
.SetPicture (PortraitName
)
42 global AppearanceWindow
, PortraitButton
, PortraitsTable
, LastPortrait
45 if GUICommon
.CloseOtherWindow (OnLoad
):
47 AppearanceWindow
.Unload()
50 GemRB
.LoadWindowPack("GUICG")
51 AppearanceWindow
= GemRB
.LoadWindow (11)
54 MyChar
= GemRB
.GetVar ("Slot")
55 Gender
= GemRB
.GetPlayerStat (MyChar
, IE_SEX
)
57 #Load the Portraits Table
58 PortraitsTable
= GemRB
.LoadTable ("PICTURES")
59 PortraitsStart
= PortraitsTable
.FindValue (0, 2)
60 FemaleCount
= PortraitsTable
.GetRowCount () - PortraitsStart
+ 1
62 LastPortrait
= GemRB
.Roll (1, FemaleCount
, PortraitsStart
-1)
64 LastPortrait
= GemRB
.Roll (1, PortraitsTable
.GetRowCount()-FemaleCount
, 0)
66 PortraitButton
= AppearanceWindow
.GetControl (1)
67 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
68 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
70 LeftButton
= AppearanceWindow
.GetControl (2)
71 RightButton
= AppearanceWindow
.GetControl (3)
73 BackButton
= AppearanceWindow
.GetControl (5)
74 BackButton
.SetText (15416)
76 CustomButton
= AppearanceWindow
.GetControl (6)
77 CustomButton
.SetText (17545)
79 DoneButton
= AppearanceWindow
.GetControl (0)
80 DoneButton
.SetText (11973)
81 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
,OP_OR
)
83 RightButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RightPress
)
84 LeftButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LeftPress
)
85 BackButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CharGenCommon
.BackPress
)
86 CustomButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomPress
)
87 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, NextPress
)
91 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
94 LastPortrait
= LastPortrait
+ 1
95 if LastPortrait
>= PortraitsTable
.GetRowCount ():
102 AppearanceWindow
.ShowModal(MODAL_SHADOW_NONE
)
108 LastPortrait
= LastPortrait
+ 1
109 if LastPortrait
>= PortraitsTable
.GetRowCount ():
111 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
118 LastPortrait
= LastPortrait
- 1
120 LastPortrait
= PortraitsTable
.GetRowCount ()-1
121 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
126 global AppearanceWindow
128 Window
= CustomWindow
129 Portrait
= PortraitList1
.QueryText ()
130 GemRB
.SetToken ("LargePortrait", Portrait
)
131 Portrait
= PortraitList2
.QueryText ()
132 GemRB
.SetToken ("SmallPortrait", Portrait
)
142 CustomWindow
.Unload ()
145 def LargeCustomPortrait():
146 Window
= CustomWindow
148 Portrait
= PortraitList1
.QueryText ()
150 if GemRB
.GetVar ("Row1") == RowCount1
:
153 Label
= Window
.GetControl (0x10000007)
154 Label
.SetText (Portrait
)
156 Button
= Window
.GetControl (6)
158 Portrait
= "NOPORTLG"
159 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
161 if PortraitList2
.QueryText ()!="":
162 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
164 Button
= Window
.GetControl (0)
165 Button
.SetPicture (Portrait
, "NOPORTLG")
168 def SmallCustomPortrait():
169 Window
= CustomWindow
171 Portrait
= PortraitList2
.QueryText ()
173 if GemRB
.GetVar ("Row2") == RowCount2
:
176 Label
= Window
.GetControl (0x10000008)
177 Label
.SetText (Portrait
)
179 Button
= Window
.GetControl (6)
181 Portrait
= "NOPORTSM"
182 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
184 if PortraitList1
.QueryText ()!="":
185 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
187 Button
= Window
.GetControl (1)
188 Button
.SetPicture (Portrait
, "NOPORTSM")
192 global PortraitList1
, PortraitList2
193 global RowCount1
, RowCount2
196 CustomWindow
= Window
= GemRB
.LoadWindow (18)
197 PortraitList1
= Window
.GetControl (2)
198 RowCount1
= PortraitList1
.GetPortraits (0)
199 PortraitList1
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, LargeCustomPortrait
)
200 GemRB
.SetVar ("Row1", RowCount1
)
201 PortraitList1
.SetVarAssoc ("Row1",RowCount1
)
203 PortraitList2
= Window
.GetControl (4)
204 RowCount2
= PortraitList2
.GetPortraits (1)
205 PortraitList2
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, SmallCustomPortrait
)
206 GemRB
.SetVar ("Row2", RowCount2
)
207 PortraitList2
.SetVarAssoc ("Row2",RowCount2
)
209 Button
= Window
.GetControl (6)
210 Button
.SetText (11973)
211 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomDone
)
212 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
214 Button
= Window
.GetControl (7)
215 Button
.SetText (15416)
216 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomAbort
)
218 Button
= Window
.GetControl (0)
219 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"L"
220 Button
.SetPicture (PortraitName
, "NOPORTLG")
221 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
223 Button
= Window
.GetControl (1)
224 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"S"
225 Button
.SetPicture (PortraitName
, "NOPORTSM")
226 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
228 Window
.ShowModal (MODAL_SHADOW_GRAY
)
232 PortraitTable
= GemRB
.LoadTable ("pictures")
233 PortraitName
= PortraitTable
.GetRowName (LastPortrait
)
234 GemRB
.SetToken ("SmallPortrait", PortraitName
+"S")
235 GemRB
.SetToken ("LargePortrait", PortraitName
+"L")
237 #GemRB.SetVar("Step",1)
238 #GemRB.SetNextScript("CharGen")
239 #GemRB.SetNextScript ("CharGen2") #Before race