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.
29 global LoadWindow
, TextAreaControl
, Games
, ScrollBar
31 GemRB
.LoadWindowPack("GUILOAD", 640, 480)
32 LoadWindow
= GemRB
.LoadWindow(0)
33 LoadWindow
.SetFrame ()
34 CancelButton
=LoadWindow
.GetControl(34)
35 CancelButton
.SetText(13727)
36 CancelButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, CancelPress
)
37 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
38 GemRB
.SetVar("LoadIdx",0)
41 Button
= LoadWindow
.GetControl(26+i
)
43 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, LoadGamePress
)
44 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
45 Button
.SetVarAssoc("LoadIdx",i
)
47 Button
= LoadWindow
.GetControl(30+i
)
49 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, DeleteGamePress
)
50 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
51 Button
.SetVarAssoc("LoadIdx",i
)
54 Button
= LoadWindow
.GetControl(1+i
)
55 Button
.SetState(IE_GUI_BUTTON_LOCKED
)
56 Button
.SetFlags(IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
59 for j
in range(PARTY_SIZE
):
60 Button
= LoadWindow
.GetControl(40+i
*PARTY_SIZE
+j
)
61 Button
.SetState(IE_GUI_BUTTON_LOCKED
)
62 Button
.SetFlags(IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
64 ScrollBar
=LoadWindow
.GetControl(25)
65 ScrollBar
.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE
, ScrollBarPress
)
66 Games
=GemRB
.GetSaveGames()
67 TopIndex
= max (0, len(Games
) - 4)
68 GemRB
.SetVar ("TopIndex",TopIndex
)
69 ScrollBar
.SetVarAssoc ("TopIndex", TopIndex
+1)
71 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
75 #draw load game portraits
76 Pos
= GemRB
.GetVar("TopIndex")
80 Button1
= LoadWindow
.GetControl(26+i
)
81 Button2
= LoadWindow
.GetControl(30+i
)
83 Button1
.SetState(IE_GUI_BUTTON_ENABLED
)
84 Button2
.SetState(IE_GUI_BUTTON_ENABLED
)
86 Button1
.SetState(IE_GUI_BUTTON_DISABLED
)
87 Button2
.SetState(IE_GUI_BUTTON_DISABLED
)
90 Slotname
= Games
[ActPos
].GetName()
93 Label
= LoadWindow
.GetControl(0x10000008+i
)
94 Label
.SetText(Slotname
)
97 Slotname
= Games
[ActPos
].GetGameDate()
100 Label
= LoadWindow
.GetControl(0x10000010+i
)
101 Label
.SetText(Slotname
)
103 Button
=LoadWindow
.GetControl(1+i
)
104 if ActPos
<len(Games
):
105 Button
.SetSprite2D(Games
[ActPos
].GetPreview())
107 Button
.SetPicture("")
108 for j
in range(PARTY_SIZE
):
109 Button
=LoadWindow
.GetControl(40+i
*PARTY_SIZE
+j
)
110 if ActPos
<len(Games
):
111 Button
.SetSprite2D(Games
[ActPos
].GetPortrait(j
))
113 Button
.SetPicture("")
119 Pos
= GemRB
.GetVar("TopIndex")+GemRB
.GetVar("LoadIdx")
120 LoadScreen
.StartLoadScreen()
122 GemRB
.LoadGame(Games
[Pos
])
123 #performs conversion to ToB
124 if (GemRB
.GetVar("oldgame")==0) and GemRB
.GetVar("expansion")==1:
125 GemRB
.GameSetExpansion()
128 GemRB
.EnterGame() #it will close windows, including the loadscreen
131 def DeleteGameConfirm():
134 TopIndex
= GemRB
.GetVar("TopIndex")
135 Pos
= TopIndex
+GemRB
.GetVar("LoadIdx")
136 GemRB
.DeleteSaveGame(Games
[Pos
])
138 GemRB
.SetVar("TopIndex",TopIndex
-1)
140 ScrollBar
.SetVarAssoc("TopIndex", len(Games
))
143 ConfirmWindow
.Unload()
144 LoadWindow
.SetVisible(WINDOW_VISIBLE
)
147 def DeleteGameCancel():
149 ConfirmWindow
.Unload()
150 LoadWindow
.SetVisible(WINDOW_VISIBLE
)
153 def DeleteGamePress():
156 LoadWindow
.SetVisible(WINDOW_INVISIBLE
)
157 ConfirmWindow
=GemRB
.LoadWindow(1)
158 Text
=ConfirmWindow
.GetControl(0)
160 DeleteButton
=ConfirmWindow
.GetControl(1)
161 DeleteButton
.SetText(13957)
162 DeleteButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, DeleteGameConfirm
)
163 CancelButton
=ConfirmWindow
.GetControl(2)
164 CancelButton
.SetText(13727)
165 CancelButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, DeleteGameCancel
)
166 ConfirmWindow
.SetVisible(WINDOW_VISIBLE
)
172 GemRB
.SetNextScript("Start")