TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / GUICG1.py
blob77217086210614fd2f67515b50314ee864cbd358
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, gender (GUICG1)
20 import GemRB
21 from ie_stats import *
22 from GUIDefines import *
24 GenderWindow = 0
25 TextAreaControl = 0
26 DoneButton = 0
27 MyChar = 0
29 def OnLoad():
30 global GenderWindow, TextAreaControl, DoneButton, MyChar
32 GemRB.LoadWindowPack("GUICG", 640, 480)
33 MyChar = GemRB.GetVar ("Slot")
34 #this hack will redraw the base CG window
35 GenderWindow = GemRB.LoadWindow(0)
36 PortraitButton = GenderWindow.GetControl(12)
37 PortraitButton.SetFlags(IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE,OP_SET)
38 ImportButton = GenderWindow.GetControl(13)
39 ImportButton.SetText(13955)
40 ImportButton.SetState(IE_GUI_BUTTON_DISABLED)
42 CancelButton = GenderWindow.GetControl(15)
43 CancelButton.SetText(13727)
44 CancelButton.SetState(IE_GUI_BUTTON_DISABLED)
46 BiographyButton = GenderWindow.GetControl(16)
47 BiographyButton.SetText(18003)
48 BiographyButton.SetState(IE_GUI_BUTTON_DISABLED)
50 GenderWindow.SetVisible(WINDOW_VISIBLE)
51 GemRB.DrawWindows()
52 if GenderWindow:
53 GenderWindow.Unload()
54 GenderWindow = GemRB.LoadWindow(1)
56 BackButton = GenderWindow.GetControl(6)
57 BackButton.SetText(15416)
58 BackButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
59 DoneButton = GenderWindow.GetControl(0)
60 DoneButton.SetText(11973)
61 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
63 TextAreaControl = GenderWindow.GetControl(5)
64 TextAreaControl.SetText(17236)
66 MaleButton = GenderWindow.GetControl(2)
67 MaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
69 FemaleButton = GenderWindow.GetControl(3)
70 FemaleButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
72 MaleButton.SetVarAssoc("Gender",1)
73 FemaleButton.SetVarAssoc("Gender",2)
74 MaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedMale)
75 FemaleButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ClickedFemale)
76 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
77 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
78 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
79 GenderWindow.SetVisible(WINDOW_VISIBLE)
80 return
82 def ClickedMale():
83 TextAreaControl.SetText(13083)
84 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
85 return
87 def ClickedFemale():
88 TextAreaControl.SetText(13084)
89 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
90 return
92 def BackPress():
93 if GenderWindow:
94 GenderWindow.Unload()
95 GemRB.SetNextScript("CharGen")
96 GemRB.SetVar("Gender",0) #scrapping the gender value
97 return
99 def NextPress():
100 if GenderWindow:
101 GenderWindow.Unload()
103 Gender = GemRB.GetVar ("Gender")
104 GemRB.SetPlayerStat (MyChar, IE_SEX, Gender)
105 GemRB.SetNextScript("GUICG12") #appearance
106 return