TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / GUICG9.py
blob3d7c7ff7dd6f88a51b4fff0c1c9398d6abd7237a
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, proficiencies (GUICG9)
20 import GemRB
21 from GUIDefines import *
22 from ie_stats import *
23 import LUProfsSelection
25 SkillWindow = 0
26 DoneButton = 0
27 MyChar = 0
29 def RedrawSkills():
30 ProfsPointsLeft = GemRB.GetVar ("ProfsPointsLeft")
31 if not ProfsPointsLeft:
32 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
33 else:
34 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
35 return
37 def OnLoad():
38 global SkillWindow, DoneButton, MyChar
40 GemRB.LoadWindowPack("GUICG", 640, 480)
41 SkillWindow = GemRB.LoadWindow(9)
42 MyChar = GemRB.GetVar ("Slot")
43 Levels = [GemRB.GetPlayerStat (MyChar, IE_LEVEL), GemRB.GetPlayerStat (MyChar, IE_LEVEL2), \
44 GemRB.GetPlayerStat (MyChar, IE_LEVEL3)]
45 LUProfsSelection.SetupProfsWindow (MyChar, \
46 LUProfsSelection.LUPROFS_TYPE_CHARGEN, SkillWindow, RedrawSkills, [0,0,0], Levels)
48 BackButton = SkillWindow.GetControl(77)
49 BackButton.SetText(15416)
50 BackButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
51 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
53 DoneButton = SkillWindow.GetControl(0)
54 DoneButton.SetText(11973)
55 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
56 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
57 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
59 SkillWindow.SetVisible(WINDOW_VISIBLE)
60 return
62 def BackPress():
63 if SkillWindow:
64 SkillWindow.Unload()
65 GemRB.SetNextScript("CharGen6")
66 #scrap skills
67 return
69 def NextPress():
70 if SkillWindow:
71 SkillWindow.Unload()
73 LUProfsSelection.ProfsSave (MyChar, LUProfsSelection.LUPROFS_TYPE_CHARGEN)
75 GemRB.SetNextScript("CharGen7") #appearance
76 return