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
21 from GUIDefines
import *
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
)
66 PartySelectWindow
.SetVisible(WINDOW_VISIBLE
)
71 global PartySelectWindow
, PartyCount
72 Pos
= GemRB
.GetVar("TopIndex")
73 for i
in range(0,PARTY_SIZE
):
75 Button
= PartySelectWindow
.GetControl(i
)
77 Button
.SetVarAssoc("PartyIdx",-1)
79 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
81 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
83 for i
in range(0,PARTY_SIZE
):
85 Button
= PartySelectWindow
.GetControl(i
)
87 Button
.SetVarAssoc("PartyIdx",ActPos
)
88 Tag
= "Party " + str(ActPos
)
89 PartyDesc
= GemRB
.GetINIPartyKey(Tag
, "Name", "")
90 Button
.SetText(PartyDesc
)
94 Pos
= GemRB
.GetVar("PartyIdx")
95 if Pos
== 0: # first entry - behaves same as pressing on done
97 PartySelectWindow
.Unload()
98 GemRB
.LoadGame(None, 22)
99 GemRB
.SetNextScript("SPPartyFormation")
100 #else: # here come the real modifications
103 global PartySelectWindow
104 Pos
= GemRB
.GetVar("PartyIdx")
106 if PartySelectWindow
:
107 PartySelectWindow
.Unload()
108 GemRB
.LoadGame(None, 22)
109 GemRB
.SetNextScript("SPPartyFormation")
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")
121 global PartySelectWindow
122 if PartySelectWindow
:
123 PartySelectWindow
.Unload()
124 GemRB
.SetNextScript("Start")
127 def PartyButtonPress():
128 global PartySelectWindow
, TextArea
129 i
= GemRB
.GetVar("PartyIdx")
130 Tag
= "Party " + str(i
)
132 for j
in range(1, 9):
133 Key
= "Descr" + str(j
)
134 NewString
= GemRB
.GetINIPartyKey(Tag
, Key
, "")
136 NewString
= NewString
+ "\n\n"
137 PartyDesc
= PartyDesc
+ NewString
139 TextArea
.SetText(PartyDesc
)
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):
148 CharName
= GemRB
.GetINIPartyKey(Tag
, Key
, "")
149 print Tag
, Key
, CharName
151 GemRB
.CreatePlayer(CharName
, j
, 1)