2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # GUILOAD.py - Load window
23 ###################################################
26 from LoadScreen
import *
34 global LoadWindow
, TextAreaControl
, GameCount
, ScrollBar
36 GemRB
.LoadWindowPack ("GUILOAD", 640, 480)
37 LoadWindow
= GemRB
.LoadWindowObject (0)
38 LoadWindow
.SetFrame ()
40 CancelButton
=LoadWindow
.GetControl (34)
41 CancelButton
.SetText (13727)
42 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "CancelPress")
43 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
45 GemRB
.SetVar ("LoadIdx",0)
47 Button
= LoadWindow
.GetControl (26+i
)
48 Button
.SetText (15590)
49 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "LoadGamePress")
50 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
51 Button
.SetVarAssoc ("LoadIdx",i
)
53 Button
= LoadWindow
.GetControl (30+i
)
54 Button
.SetText (13957)
55 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "DeleteGamePress")
56 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
57 Button
.SetVarAssoc ("LoadIdx",i
)
60 Button
= LoadWindow
.GetControl (1+i
)
61 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
62 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
65 for j
in range (PARTY_SIZE
):
66 Button
= LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
67 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
68 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
70 ScrollBar
=LoadWindow
.GetControl (25)
71 ScrollBar
.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE
, "ScrollBarPress")
72 GameCount
=GemRB
.GetSaveGameCount () #count of games in save folder?
74 TopIndex
= GameCount
-4
77 GemRB
.SetVar ("TopIndex",TopIndex
)
78 ScrollBar
.SetVarAssoc ("TopIndex", TopIndex
+1)
80 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
83 def ScrollBarPress ():
84 #draw load game portraits
85 Pos
= GemRB
.GetVar ("TopIndex")
89 Button1
= LoadWindow
.GetControl (26+i
)
90 Button2
= LoadWindow
.GetControl (30+i
)
92 Button1
.SetState (IE_GUI_BUTTON_ENABLED
)
93 Button2
.SetState (IE_GUI_BUTTON_ENABLED
)
95 Button1
.SetState (IE_GUI_BUTTON_DISABLED
)
96 Button2
.SetState (IE_GUI_BUTTON_DISABLED
)
99 Slotname
= GemRB
.GetSaveGameName(ActPos
)
102 Label
= LoadWindow
.GetControl (0x10000008+i
)
103 Label
.SetText (Slotname
)
106 Slotname
= GemRB
.GetSaveGameDate(ActPos
)
109 Label
= LoadWindow
.GetControl (0x10000010+i
)
110 Label
.SetText (Slotname
)
112 Button
=LoadWindow
.GetControl (1+i
)
114 Button
.SetSprite2D(GemRB
.GetSaveGamePreview(ActPos
))
116 Button
.SetPicture ("")
117 for j
in range (PARTY_SIZE
):
118 Button
=LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
120 Button
.SetSprite2D(GemRB
.GetSaveGamePortrait(ActPos
, j
))
122 Button
.SetPicture ("")
125 def LoadGamePress ():
128 Pos
= GemRB
.GetVar ("TopIndex")+GemRB
.GetVar ("LoadIdx")
130 GemRB
.LoadGame (Pos
) #loads and enters savegame
134 def DeleteGameConfirm():
137 TopIndex
= GemRB
.GetVar ("TopIndex")
138 Pos
= TopIndex
+GemRB
.GetVar ("LoadIdx")
139 GemRB
.DeleteSaveGame (Pos
)
141 GemRB
.SetVar ("TopIndex",TopIndex
-1)
142 GameCount
=GemRB
.GetSaveGameCount () #count of games in save folder?
143 ScrollBar
.SetVarAssoc ("TopIndex", GameCount
)
146 ConfirmWindow
.Unload ()
147 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
150 def DeleteGameCancel ():
152 ConfirmWindow
.Unload ()
153 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
156 def DeleteGamePress ():
159 LoadWindow
.SetVisible (WINDOW_INVISIBLE
)
160 ConfirmWindow
=GemRB
.LoadWindowObject (1)
161 Text
=ConfirmWindow
.GetControl (0)
163 DeleteButton
=ConfirmWindow
.GetControl (1)
164 DeleteButton
.SetText (13957)
165 DeleteButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "DeleteGameConfirm")
166 CancelButton
=ConfirmWindow
.GetControl (2)
167 CancelButton
.SetText (13727)
168 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, "DeleteGameCancel")
169 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
171 ConfirmWindow
.SetVisible (WINDOW_VISIBLE
)
177 GemRB
.SetNextScript ("Start")