iwd: more gcw syncing with bg2 - actonpc and dragging
[gemrb.git] / gemrb / GUIScripts / bg2 / GUICG8.py
blob2445b7853af84538630206083bc1ddb8bc229635
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, race (GUICG2)
20 import GemRB
21 import GUICommon
22 from ie_stats import IE_RACE
23 from GUIDefines import *
25 RaceWindow = 0
26 TextAreaControl = 0
27 DoneButton = 0
28 MyChar = 0
30 def OnLoad():
31 global RaceWindow, TextAreaControl, DoneButton, MyChar
33 GemRB.LoadWindowPack("GUICG", 640, 480)
34 RaceWindow = GemRB.LoadWindow(8)
36 MyChar = GemRB.GetVar ("Slot")
37 RaceCount = GUICommon.RaceTable.GetRowCount()
39 for i in range(2,RaceCount+2):
40 #hack to stop if the race table has more entries than the gui resource
41 #this needs to be done because the race table has non-selectable entries
42 if not RaceWindow.HasControl(i):
43 RaceCount = i-2
44 break
45 Button = RaceWindow.GetControl(i)
46 Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
48 GemRB.SetVar ("Race", -1)
49 for i in range(2, RaceCount+2):
50 Button = RaceWindow.GetControl(i)
51 Button.SetText(GUICommon.RaceTable.GetValue(i-2,0) )
52 Button.SetState(IE_GUI_BUTTON_ENABLED)
53 Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, RacePress)
54 Button.SetVarAssoc("Race", i-2 )
56 BackButton = RaceWindow.GetControl(i+2) #i=8 now (when race count is 7)
57 BackButton.SetText(15416)
58 BackButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
59 DoneButton = RaceWindow.GetControl(0)
60 DoneButton.SetText(11973)
61 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
62 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
64 TextAreaControl = RaceWindow.GetControl(12)
65 TextAreaControl.SetText(17237)
67 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
68 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
69 RaceWindow.SetVisible(WINDOW_VISIBLE)
70 return
72 def RacePress():
73 Race = GemRB.GetVar("Race")
74 TextAreaControl.SetText(GUICommon.RaceTable.GetValue(Race,1) )
75 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
76 return
78 def BackPress():
79 if RaceWindow:
80 RaceWindow.Unload()
81 GemRB.SetNextScript("CharGen2")
82 GemRB.SetVar("Race",0) #scrapping the race value
83 return
85 def NextPress():
86 if RaceWindow:
87 RaceWindow.Unload()
89 Race = GemRB.GetVar ("Race")
90 GemRB.SetPlayerStat (MyChar, IE_RACE, GUICommon.RaceTable.GetValue(Race,3) )
92 GemRB.SetNextScript("CharGen3") #class
93 return