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
.SetVar ("PlayMode",0) #iwd is always using 'mpsave'
38 GemRB
.SetVar ("SaveDir",1) #iwd is always using 'mpsave'
39 GemRB
.LoadWindowPack ("GUILOAD", 640, 480)
40 LoadWindow
= GemRB
.LoadWindow (0)
41 LoadWindow
.SetFrame ()
42 CancelButton
=LoadWindow
.GetControl (34)
43 CancelButton
.SetText (13727)
44 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CancelPress
)
45 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
47 GemRB
.SetVar ("LoadIdx",0)
49 Button
= LoadWindow
.GetControl (26+i
)
50 Button
.SetText (15590)
51 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LoadGamePress
)
52 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
53 Button
.SetVarAssoc ("LoadIdx",i
)
55 Button
= LoadWindow
.GetControl (30+i
)
56 Button
.SetText (13957)
57 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGamePress
)
58 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
59 Button
.SetVarAssoc ("LoadIdx",i
)
62 Button
= LoadWindow
.GetControl (1+i
)
63 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
64 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
67 for j
in range (PARTY_SIZE
):
68 Button
= LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
69 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
70 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE|IE_GUI_BUTTON_PICTURE
,OP_SET
)
72 ScrollBar
=LoadWindow
.GetControl (25)
73 ScrollBar
.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE
, ScrollBarPress
)
74 Games
=GemRB
.GetSaveGames ()
75 TopIndex
= max (0, len(Games
) - 4)
76 GemRB
.SetVar ("TopIndex",TopIndex
)
77 ScrollBar
.SetVarAssoc ("TopIndex", TopIndex
+1)
79 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
82 def ScrollBarPress ():
83 #draw load game portraits
84 Pos
= GemRB
.GetVar ("TopIndex")
88 Button1
= LoadWindow
.GetControl (26+i
)
89 Button2
= LoadWindow
.GetControl (30+i
)
91 Button1
.SetState (IE_GUI_BUTTON_ENABLED
)
92 Button2
.SetState (IE_GUI_BUTTON_ENABLED
)
94 Button1
.SetState (IE_GUI_BUTTON_DISABLED
)
95 Button2
.SetState (IE_GUI_BUTTON_DISABLED
)
98 Slotname
= Games
[ActPos
].GetName()
101 Label
= LoadWindow
.GetControl (0x10000008+i
)
102 Label
.SetText (Slotname
)
104 if ActPos
<len(Games
):
105 Slotname
= Games
[ActPos
].GetGameDate()
108 Label
= LoadWindow
.GetControl (0x10000010+i
)
109 Label
.SetText (Slotname
)
111 Button
=LoadWindow
.GetControl (1+i
)
112 if ActPos
<len(Games
):
113 Button
.SetSprite2D(Games
[ActPos
].GetPreview())
115 Button
.SetPicture ("")
116 for j
in range (PARTY_SIZE
):
117 Button
=LoadWindow
.GetControl (40 + i
*PARTY_SIZE
+ j
)
118 if ActPos
<len(Games
):
119 Button
.SetSprite2D(Games
[ActPos
].GetPortrait(j
))
121 Button
.SetPicture ("")
124 def LoadGamePress ():
127 Pos
= GemRB
.GetVar ("TopIndex")+GemRB
.GetVar ("LoadIdx")
128 LoadScreen
.StartLoadScreen()
129 GemRB
.LoadGame(Games
[Pos
]) #loads and enters savegame
130 GemRB
.SetNextScript ("PartyFormation")
133 def DeleteGameConfirm():
136 TopIndex
= GemRB
.GetVar ("TopIndex")
137 Pos
= TopIndex
+GemRB
.GetVar ("LoadIdx")
138 GemRB
.DeleteSaveGame(Games
[Pos
])
140 GemRB
.SetVar ("TopIndex",TopIndex
-1)
142 ScrollBar
.SetVarAssoc ("TopIndex", len(Games
))
145 ConfirmWindow
.Unload ()
146 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
149 def DeleteGameCancel ():
151 ConfirmWindow
.Unload ()
152 LoadWindow
.SetVisible (WINDOW_VISIBLE
)
155 def DeleteGamePress ():
158 LoadWindow
.SetVisible (WINDOW_INVISIBLE
)
159 ConfirmWindow
=GemRB
.LoadWindow (1)
160 Text
=ConfirmWindow
.GetControl (0)
162 DeleteButton
=ConfirmWindow
.GetControl (1)
163 DeleteButton
.SetText (13957)
164 DeleteButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGameConfirm
)
165 CancelButton
=ConfirmWindow
.GetControl (2)
166 CancelButton
.SetText (13727)
167 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DeleteGameCancel
)
168 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
170 ConfirmWindow
.SetVisible (WINDOW_VISIBLE
)
176 GemRB
.SetNextScript ("Start")