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 ###################################################
27 from GUIDefines
import *
35 global LoadWindow
, TextAreaControl
, Games
, ScrollBar
37 GemRB
.LoadWindowPack ("GUILOAD", 640, 480)
38 LoadWindow
= GemRB
.LoadWindow (0)
39 LoadWindow
.SetFrame ()
41 CancelButton
=LoadWindow
.GetControl (34)
42 CancelButton
.SetText (13727)
43 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CancelPress
)
44 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
46 GemRB
.SetVar ("LoadIdx",0)
48 Button
= LoadWindow
.GetControl (26+i
)
49 Button
.SetText (15590)
50 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LoadGamePress
)
51 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
52 Button
.SetVarAssoc ("LoadIdx",i
)
54 Button
= LoadWindow
.GetControl (30+i
)
55 Button
.SetText (13957)
56 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGamePress
)
57 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
58 Button
.SetVarAssoc ("LoadIdx",i
)
61 Button
= LoadWindow
.GetControl (1+i
)
62 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
63 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
66 for j
in range (PARTY_SIZE
):
67 Button
= LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
68 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
69 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
71 ScrollBar
=LoadWindow
.GetControl (25)
72 ScrollBar
.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE
, ScrollBarPress
)
73 Games
=GemRB
.GetSaveGames ()
74 TopIndex
= max (0, len(Games
) - 4)
75 GemRB
.SetVar ("TopIndex",TopIndex
)
76 ScrollBar
.SetVarAssoc ("TopIndex", TopIndex
+1)
78 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
81 def ScrollBarPress ():
82 #draw load game portraits
83 Pos
= GemRB
.GetVar ("TopIndex")
87 Button1
= LoadWindow
.GetControl (26+i
)
88 Button2
= LoadWindow
.GetControl (30+i
)
90 Button1
.SetState (IE_GUI_BUTTON_ENABLED
)
91 Button2
.SetState (IE_GUI_BUTTON_ENABLED
)
93 Button1
.SetState (IE_GUI_BUTTON_DISABLED
)
94 Button2
.SetState (IE_GUI_BUTTON_DISABLED
)
97 Slotname
= Games
[ActPos
].GetName()
100 Label
= LoadWindow
.GetControl (0x10000008+i
)
101 Label
.SetText (Slotname
)
103 if ActPos
<len(Games
):
104 Slotname
= Games
[ActPos
].GetDate()
107 Label
= LoadWindow
.GetControl (0x10000010+i
)
108 Label
.SetText (Slotname
)
110 Button
=LoadWindow
.GetControl (1+i
)
111 if ActPos
<len(Games
):
112 Button
.SetSprite2D(Games
[ActPos
].GetPreview())
114 Button
.SetPicture ("")
115 for j
in range (PARTY_SIZE
):
116 Button
=LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
117 if ActPos
<len(Games
):
118 Button
.SetSprite2D(Games
[ActPos
].GetPortrait(j
))
120 Button
.SetPicture ("")
123 def LoadGamePress ():
126 Pos
= GemRB
.GetVar ("TopIndex")+GemRB
.GetVar ("LoadIdx")
127 LoadScreen
.StartLoadScreen()
128 GemRB
.LoadGame (Games
[Pos
]) #loads and enters savegame
132 def DeleteGameConfirm():
135 TopIndex
= GemRB
.GetVar ("TopIndex")
136 Pos
= TopIndex
+GemRB
.GetVar ("LoadIdx")
137 GemRB
.DeleteSaveGame(Games
[Pos
])
139 GemRB
.SetVar ("TopIndex",TopIndex
-1)
141 ScrollBar
.SetVarAssoc ("TopIndex", len(Games
))
144 ConfirmWindow
.Unload ()
145 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
148 def DeleteGameCancel ():
150 ConfirmWindow
.Unload ()
151 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
154 def DeleteGamePress ():
157 LoadWindow
.SetVisible (WINDOW_INVISIBLE
)
158 ConfirmWindow
=GemRB
.LoadWindow (1)
159 Text
=ConfirmWindow
.GetControl (0)
161 DeleteButton
=ConfirmWindow
.GetControl (1)
162 DeleteButton
.SetText (13957)
163 DeleteButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGameConfirm
)
164 CancelButton
=ConfirmWindow
.GetControl (2)
165 CancelButton
.SetText (13727)
166 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGameCancel
)
167 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
169 ConfirmWindow
.SetVisible (WINDOW_VISIBLE
)
175 GemRB
.SetNextScript ("Start")