factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / iwd2 / Race.py
blob5cec35a8eaaec3f7449d64a2ba558b2992cc742b
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 from GUIDefines import *
22 import CommonTables
24 RaceWindow = 0
25 TextAreaControl = 0
26 DoneButton = 0
27 SubRacesTable = 0
29 def OnLoad():
30 global RaceWindow, TextAreaControl, DoneButton
31 global SubRacesTable
33 GemRB.LoadWindowPack("GUICG", 800 ,600)
34 RaceWindow = GemRB.LoadWindow (8)
36 RaceCount = CommonTables.Races.GetRowCount ()
38 SubRacesTable = GemRB.LoadTable ("SUBRACES")
40 for i in range(2,9):
41 Button = RaceWindow.GetControl (i)
42 Button.SetFlags (IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
44 for i in range(7):
45 Button = RaceWindow.GetControl (i+2)
46 Button.SetText (CommonTables.Races.GetValue (i,0) )
47 Button.SetState (IE_GUI_BUTTON_ENABLED)
48 Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, RacePress)
49 Button.SetVarAssoc ("BaseRace", CommonTables.Races.GetValue (i, 3) )
51 BackButton = RaceWindow.GetControl (11)
52 BackButton.SetText (15416)
53 BackButton.SetFlags(IE_GUI_BUTTON_CANCEL,OP_OR)
55 DoneButton = RaceWindow.GetControl (0)
56 DoneButton.SetText (36789)
57 DoneButton.SetState (IE_GUI_BUTTON_DISABLED)
58 DoneButton.SetFlags (IE_GUI_BUTTON_DEFAULT,OP_OR)
60 TextAreaControl = RaceWindow.GetControl (9)
61 TextAreaControl.SetText (17237)
63 DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, NextPress)
64 BackButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, BackPress)
65 RaceWindow.SetVisible(WINDOW_VISIBLE)
66 return
68 def RacePress():
69 global RaceWindow, SubRacesTable
70 Race = GemRB.GetVar ("BaseRace")
71 GemRB.SetVar ("Race", Race)
72 RaceID = CommonTables.Races.GetRowName (CommonTables.Races.FindValue (3, Race) )
73 HasSubRaces = SubRacesTable.GetValue (RaceID, "PURE_RACE")
74 if HasSubRaces == 0:
75 TextAreaControl.SetText (CommonTables.Races.GetValue (RaceID,"DESC_REF") )
76 DoneButton.SetState (IE_GUI_BUTTON_ENABLED)
77 return
78 if RaceWindow:
79 RaceWindow.Unload ()
80 GemRB.SetNextScript ("SubRaces")
81 return
83 def BackPress():
84 if RaceWindow:
85 RaceWindow.Unload ()
86 GemRB.SetNextScript ("CharGen2")
87 GemRB.SetVar ("BaseRace",0) #scrapping the race value
88 return
90 def NextPress():
91 if RaceWindow:
92 RaceWindow.Unload ()
93 GemRB.SetNextScript ("CharGen3") #class
94 return