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, color (GUICG13)
22 from GUIDefines
import *
23 from ie_stats
import *
46 table
= GemRB
.LoadTable("avprefr")
47 Race
= GemRB
.GetPlayerStat (MyChar
, IE_RACE
)
48 AnimID
= AnimID
+table
.GetValue(Race
, 0)
49 table
= GemRB
.LoadTable("avprefc")
50 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
51 AnimID
= AnimID
+table
.GetValue(Class
, 0)
52 table
= GemRB
.LoadTable("avprefg")
53 Gender
= GemRB
.GetPlayerStat (MyChar
, IE_SEX
)
54 AnimID
= AnimID
+table
.GetValue(Gender
,0)
55 ResRef
= CommonTables
.Pdolls
.GetValue(hex(AnimID
), "LEVEL1")
57 PDollButton
.SetPLT(ResRef
, 0, MinorColor
, MajorColor
, SkinColor
, 0, 0, HairColor
, 0)
61 global ColorWindow
, DoneButton
, PDollButton
, ColorTable
62 global HairButton
, SkinButton
, MajorButton
, MinorButton
63 global HairColor
, SkinColor
, MajorColor
, MinorColor
66 GemRB
.LoadWindowPack("GUICG", 640, 480)
67 ColorWindow
=GemRB
.LoadWindow(13)
69 MyChar
= GemRB
.GetVar ("Slot")
70 ColorTable
= GemRB
.LoadTable("clowncol")
71 #set these colors to some default
72 PortraitTable
= GemRB
.LoadTable("pictures")
73 PortraitName
= GemRB
.GetToken("LargePortrait")
74 PortraitName
= PortraitName
[0:len(PortraitName
)-1]
75 PortraitIndex
= PortraitTable
.GetRowIndex(PortraitName
)
77 HairColor
=PortraitTable
.GetValue(0,1)
78 SkinColor
=PortraitTable
.GetValue(0,2)
79 MinorColor
=PortraitTable
.GetValue(0,3)
80 MajorColor
=PortraitTable
.GetValue(0,4)
82 HairColor
=PortraitTable
.GetValue(PortraitIndex
,1)
83 SkinColor
=PortraitTable
.GetValue(PortraitIndex
,2)
84 MinorColor
=PortraitTable
.GetValue(PortraitIndex
,3)
85 MajorColor
=PortraitTable
.GetValue(PortraitIndex
,4)
87 PDollButton
= ColorWindow
.GetControl(1)
88 PDollButton
.SetState (IE_GUI_BUTTON_LOCKED
)
89 PDollButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
91 HairButton
= ColorWindow
.GetControl(2)
92 HairButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
93 HairButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, HairPress
)
94 HairButton
.SetBAM("COLGRAD", 1, 0, HairColor
)
96 SkinButton
= ColorWindow
.GetControl(3)
97 SkinButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
98 SkinButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, SkinPress
)
99 SkinButton
.SetBAM("COLGRAD", 1, 0, SkinColor
)
101 MajorButton
= ColorWindow
.GetControl(5)
102 MajorButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
103 MajorButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, MajorPress
)
104 MajorButton
.SetBAM("COLGRAD", 1, 0, MinorColor
)
106 MinorButton
= ColorWindow
.GetControl(4)
107 MinorButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
108 MinorButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, MinorPress
)
109 MinorButton
.SetBAM("COLGRAD", 1, 0, MajorColor
)
111 BackButton
= ColorWindow
.GetControl(13)
112 BackButton
.SetText(15416)
113 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
114 DoneButton
= ColorWindow
.GetControl(0)
115 DoneButton
.SetText(11973)
116 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
118 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
119 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
121 ColorWindow
.SetVisible(WINDOW_VISIBLE
)
125 global HairColor
, SkinColor
, MajorColor
, MinorColor
129 ColorWindow
.SetVisible(WINDOW_VISIBLE
)
130 PickedColor
=ColorTable
.GetValue(ColorIndex
, GemRB
.GetVar("Selected"))
132 HairColor
=PickedColor
133 HairButton
.SetBAM("COLGRAD", 1, 0, HairColor
)
137 SkinColor
=PickedColor
138 SkinButton
.SetBAM("COLGRAD", 1, 0, SkinColor
)
142 MinorColor
=PickedColor
143 MajorButton
.SetBAM("COLGRAD", 1, 0, MinorColor
)
147 MajorColor
=PickedColor
148 MinorButton
.SetBAM("COLGRAD", 1, 0, MajorColor
)
155 ColorPicker
=GemRB
.LoadWindow(14)
156 GemRB
.SetVar("Selected",-1)
158 Button
= ColorPicker
.GetControl(i
)
159 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
160 Button
.SetFlags(IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_RADIOBUTTON
,OP_OR
)
164 MyColor
= ColorTable
.GetValue(ColorIndex
, i
)
167 Button
= ColorPicker
.GetControl(i
)
168 Button
.SetBAM("COLGRAD", 2, 0, MyColor
)
169 if PickedColor
== MyColor
:
170 GemRB
.SetVar("Selected",i
)
172 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
173 Button
.SetVarAssoc("Selected",i
)
174 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, DonePress
)
176 ColorPicker
.SetVisible(WINDOW_VISIBLE
)
180 global ColorIndex
, PickedColor
182 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
184 PickedColor
= HairColor
189 global ColorIndex
, PickedColor
191 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
193 PickedColor
= SkinColor
198 global ColorIndex
, PickedColor
200 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
202 PickedColor
= MinorColor
207 global ColorIndex
, PickedColor
209 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
211 PickedColor
= MajorColor
218 GemRB
.SetNextScript("CharGen7")
224 GemRB
.SetVar("HairColor",HairColor
)
225 GemRB
.SetVar("SkinColor",SkinColor
)
226 GemRB
.SetVar("MinorColor",MinorColor
)
227 GemRB
.SetVar("MajorColor",MajorColor
)
228 GemRB
.SetNextScript("GUICG19") #sounds