do the bashing via the BashDoor action
[gemrb.git] / gemrb / GUIScripts / iwd2 / SPParty.py
bloba09fb4018b924c205d9057890ab75cc39d305532
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 #Single Player Party Select
20 import GemRB
21 from GUIDefines import *
23 PartySelectWindow = 0
24 TextArea = 0
25 PartyCount = 0
26 ScrollBar = 0
28 def OnLoad():
29 global PartySelectWindow, TextArea, PartyCount, ScrollBar
30 GemRB.LoadWindowPack("GUISP", 800, 600)
32 PartyCount = GemRB.GetINIPartyCount()
34 PartySelectWindow = GemRB.LoadWindow(10)
35 PartySelectWindow.SetFrame( )
36 TextArea = PartySelectWindow.GetControl(6)
37 ScrollBar = PartySelectWindow.GetControl(8)
38 ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, ScrollBarPress)
39 ScrollBar.SetVarAssoc("TopIndex", PartyCount)
41 ModifyButton = PartySelectWindow.GetControl(12)
42 ModifyButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ModifyPress)
43 ModifyButton.SetText(10316)
45 CancelButton = PartySelectWindow.GetControl(11)
46 CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress)
47 CancelButton.SetText(13727)
48 CancelButton.SetFlags(IE_GUI_BUTTON_CANCEL,OP_OR)
50 DoneButton = PartySelectWindow.GetControl(10)
51 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress)
52 DoneButton.SetText(11973)
53 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
55 GemRB.SetVar("PartyIdx",0)
56 GemRB.SetVar("TopIndex",0)
58 for i in range(0,PARTY_SIZE):
59 Button = PartySelectWindow.GetControl(i)
60 Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR)
61 Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, PartyButtonPress)
63 ScrollBarPress()
64 PartyButtonPress()
66 PartySelectWindow.SetVisible(WINDOW_VISIBLE)
68 return
70 def ScrollBarPress():
71 global PartySelectWindow, PartyCount
72 Pos = GemRB.GetVar("TopIndex")
73 for i in range(0,PARTY_SIZE):
74 ActPos = Pos + i
75 Button = PartySelectWindow.GetControl(i)
76 Button.SetText("")
77 Button.SetVarAssoc("PartyIdx",-1)
78 if ActPos<PartyCount:
79 Button.SetState(IE_GUI_BUTTON_ENABLED)
80 else:
81 Button.SetState(IE_GUI_BUTTON_DISABLED)
83 for i in range(0,PARTY_SIZE):
84 ActPos = Pos + i
85 Button = PartySelectWindow.GetControl(i)
86 if ActPos<PartyCount:
87 Button.SetVarAssoc("PartyIdx",ActPos)
88 Tag = "Party " + str(ActPos)
89 PartyDesc = GemRB.GetINIPartyKey(Tag, "Name", "")
90 Button.SetText(PartyDesc)
91 return
93 def ModifyPress():
94 Pos = GemRB.GetVar("PartyIdx")
95 if Pos == 0: # first entry - behaves same as pressing on done
96 if PartySelectWindow:
97 PartySelectWindow.Unload()
98 GemRB.LoadGame(None, 22)
99 GemRB.SetNextScript("SPPartyFormation")
100 #else: # here come the real modifications
102 def DonePress():
103 global PartySelectWindow
104 Pos = GemRB.GetVar("PartyIdx")
105 if Pos == 0:
106 if PartySelectWindow:
107 PartySelectWindow.Unload()
108 GemRB.LoadGame(None, 22)
109 GemRB.SetNextScript("SPPartyFormation")
110 else:
111 if PartySelectWindow:
112 PartySelectWindow.Unload()
113 GemRB.LoadGame(None, 22)
114 #here we should load the party characters
115 #but gemrb engine limitations require us to
116 #return to the main engine (loadscreen)
117 GemRB.SetNextScript("SPParty2")
118 return
120 def CancelPress():
121 global PartySelectWindow
122 if PartySelectWindow:
123 PartySelectWindow.Unload()
124 GemRB.SetNextScript("Start")
125 return
127 def PartyButtonPress():
128 global PartySelectWindow, TextArea
129 i = GemRB.GetVar("PartyIdx")
130 Tag = "Party " + str(i)
131 PartyDesc = ""
132 for j in range(1, 9):
133 Key = "Descr" + str(j)
134 NewString = GemRB.GetINIPartyKey(Tag, Key, "")
135 if NewString != "":
136 NewString = NewString + "\n\n"
137 PartyDesc = PartyDesc + NewString
139 TextArea.SetText(PartyDesc)
140 return
142 #loading characters from party.ini
143 def LoadPartyCharacters():
144 i = GemRB.GetVar("PartyIdx")
145 Tag = "Party " + str(i)
146 for j in range(1, PARTY_SIZE+1):
147 Key = "Char"+str(j)
148 CharName = GemRB.GetINIPartyKey(Tag, Key, "")
149 print Tag, Key, CharName
150 if CharName !="":
151 GemRB.CreatePlayer(CharName, j, 1)
152 return