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)
21 from GUIDefines
import *
22 from ie_stats
import *
47 MyChar
= GemRB
.GetVar ("Slot")
49 table
= GemRB
.LoadTable("avprefr")
50 AnimID
= AnimID
+table
.GetValue(GemRB
.GetPlayerStat (MyChar
, IE_RACE
),0)
51 charclass
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
52 charclass
= CommonTables
.Classes
.FindValue(5,charclass
)
53 charclass
= CommonTables
.Classes
.GetRowName(charclass
)
54 table
= GemRB
.LoadTable("avprefc")
55 AnimID
= AnimID
+table
.GetValue(table
.GetRowIndex(charclass
),0)
56 table
= GemRB
.LoadTable("avprefg")
57 AnimID
= AnimID
+table
.GetValue(GemRB
.GetPlayerStat (MyChar
, IE_SEX
),0)
58 ResRef
= CommonTables
.Pdolls
.GetValue(hex(AnimID
), "LEVEL1")
59 PDollButton
.SetPLT(ResRef
, 0, MinorColor
, MajorColor
, SkinColor
, 0, 0, HairColor
, 0)
64 global ColorWindow
, DoneButton
, PDollButton
, ColorTable
65 global HairButton
, SkinButton
, MajorButton
, MinorButton
66 global HairColor
, SkinColor
, MinorColor
, MajorColor
68 GemRB
.LoadWindowPack("GUICG")
69 ColorWindow
=GemRB
.LoadWindow(13)
70 GUICommon
.CloseOtherWindow (ColorWindow
.Unload
)
72 ColorTable
= GemRB
.LoadTable("clowncol")
73 #set these colors to some default
74 PortraitTable
= GemRB
.LoadTable("pictures")
75 PortraitName
= GemRB
.GetToken("LargePortrait")
76 PortraitName
= PortraitName
[0:len(PortraitName
)-1]
77 PortraitIndex
= PortraitTable
.GetRowIndex(PortraitName
)
79 HairColor
=PortraitTable
.GetValue(0,1)
80 SkinColor
=PortraitTable
.GetValue(0,2)
81 MinorColor
=PortraitTable
.GetValue(0,3)
82 MajorColor
=PortraitTable
.GetValue(0,4)
84 HairColor
=PortraitTable
.GetValue(PortraitIndex
,1)
85 SkinColor
=PortraitTable
.GetValue(PortraitIndex
,2)
86 MinorColor
=PortraitTable
.GetValue(PortraitIndex
,3)
87 MajorColor
=PortraitTable
.GetValue(PortraitIndex
,4)
89 PDollButton
= ColorWindow
.GetControl(1)
90 PDollButton
.SetState (IE_GUI_BUTTON_LOCKED
)
91 PDollButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
93 HairButton
= ColorWindow
.GetControl(2)
94 HairButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
95 HairButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, HairPress
)
96 HairButton
.SetBAM("COLGRAD", 0, 0, HairColor
)
98 SkinButton
= ColorWindow
.GetControl(3)
99 SkinButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
100 SkinButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, SkinPress
)
101 SkinButton
.SetBAM("COLGRAD", 0, 0, SkinColor
)
103 MajorButton
= ColorWindow
.GetControl(5)
104 MajorButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
105 MajorButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, MajorPress
)
106 MajorButton
.SetBAM("COLGRAD", 0, 0, MinorColor
)
108 MinorButton
= ColorWindow
.GetControl(4)
109 MinorButton
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
110 MinorButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, MinorPress
)
111 MinorButton
.SetBAM("COLGRAD", 0, 0, MajorColor
)
113 BackButton
= ColorWindow
.GetControl(13)
114 BackButton
.SetText(15416)
115 DoneButton
= ColorWindow
.GetControl(0)
116 DoneButton
.SetText(11973)
117 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
119 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
120 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, CharGenCommon
.BackPress
)
122 ColorWindow
.ShowModal(MODAL_SHADOW_NONE
)
126 global HairColor
, SkinColor
, MinorColor
, MajorColor
131 ColorWindow
.ShowModal(MODAL_SHADOW_NONE
)
132 PickedColor
=ColorTable
.GetValue(ColorIndex
, GemRB
.GetVar("Selected"))
134 HairColor
=PickedColor
135 HairButton
.SetBAM("COLGRAD", 0, 0, HairColor
)
139 SkinColor
=PickedColor
140 SkinButton
.SetBAM("COLGRAD", 0, 0, SkinColor
)
144 MinorColor
=PickedColor
145 MajorButton
.SetBAM("COLGRAD", 0, 0, MinorColor
)
149 MajorColor
=PickedColor
150 MinorButton
.SetBAM("COLGRAD", 0, 0, MajorColor
)
157 ColorPicker
=GemRB
.LoadWindow(14)
158 GemRB
.SetVar("Selected",-1)
160 Button
= ColorPicker
.GetControl(i
)
161 Button
.SetState(IE_GUI_BUTTON_LOCKED
)
162 Button
.SetFlags(IE_GUI_BUTTON_PICTURE
,OP_OR
)
163 #Button.SetFlags(IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
167 MyColor
= ColorTable
.GetValue(ColorIndex
, i
)
170 Button
= ColorPicker
.GetControl(i
)
171 Button
.SetBAM("COLGRAD", 0, 0, MyColor
)
172 if PickedColor
== MyColor
:
173 GemRB
.SetVar("Selected",i
)
175 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
176 Button
.SetVarAssoc("Selected",i
)
177 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, DonePress
)
179 ColorPicker
.ShowModal(MODAL_SHADOW_NONE
)
183 global ColorIndex
, PickedColor
185 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
187 PickedColor
= HairColor
192 global ColorIndex
, PickedColor
194 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
196 PickedColor
= SkinColor
201 global ColorIndex
, PickedColor
203 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
205 PickedColor
= MinorColor
210 global ColorIndex
, PickedColor
212 ColorWindow
.SetVisible(WINDOW_INVISIBLE
)
214 PickedColor
= MajorColor
220 MyChar
= GemRB
.GetVar ("Slot")
221 GUICommon
.SetColorStat (MyChar
, IE_HAIR_COLOR
, HairColor
)
222 GUICommon
.SetColorStat (MyChar
, IE_SKIN_COLOR
, SkinColor
)
223 GUICommon
.SetColorStat (MyChar
, IE_MAJOR_COLOR
, MajorColor
)
224 GUICommon
.SetColorStat (MyChar
, IE_MINOR_COLOR
, MinorColor
)