From: Tom <rtp...@us...> - 2010-05-23 09:25:47
|
gemrb: Infinity Engine emulator The branch master has been updated via d049abc744c49d028944034f2823c031ddf55e17 (commit) via ba796199e9c345f15daab50149830b8a1428c245 (commit) via 097be69e6f071b48f0f387233cb3b5eddac58893 (commit) via b069b734aa1e6a12fb732de0e5f8fdf581bf31f5 (commit) via 2d3af4c797906e65fab112a5bbb651f4b137f697 (commit) via 771c39af3cb09e52bc32533828d7ba90416956e3 (commit) via ff8f1f310225f9aa559377d23c3dbdbb06e9723b (commit) via be98078f6e848f982bcd1ece0079284861ef33ff (commit) via c35b237bc3fea0e35f856124b8fa3b05dd6c1462 (commit) via 66b3920caaf9981135d4ceb092c21d26bb305830 (commit) via 89d9e8feeb7c50615108f91911e963094f34c049 (commit) via e9116960a011013b59a5f5ab381220e52e692a91 (commit) via 74c9e57af4abbbc354d8ee1476fa3c09d2ce94fa (commit) via 5c05a3ca231bd8fe6d997dbdfe4ed6262dfe9296 (commit) via 0131306e46ef92c1750cc030975e206aa89f3aed (commit) via f8b97f1f762daf8a1c4f5922a804b570bc5fe773 (commit) Summary of changes: gemrb/GUIScripts/GUIClasses.py | 20 ++- gemrb/GUIScripts/bg1/GUILOAD.py | 39 ++-- gemrb/GUIScripts/bg1/GUISAVE.py | 60 +++--- gemrb/GUIScripts/bg1/Start.py | 4 +- gemrb/GUIScripts/bg2/GUILOAD.py | 39 ++-- gemrb/GUIScripts/bg2/GUISAVE.py | 60 +++--- gemrb/GUIScripts/bg2/Start2.py | 6 +- gemrb/GUIScripts/iwd/GUILOAD.py | 39 ++-- gemrb/GUIScripts/iwd/GUISAVE.py | 60 +++--- gemrb/GUIScripts/iwd/Start.py | 2 +- gemrb/GUIScripts/iwd2/GUILOAD.py | 45 ++--- gemrb/GUIScripts/iwd2/GUISAVE.py | 57 +++--- gemrb/GUIScripts/iwd2/SPParty.py | 6 +- gemrb/GUIScripts/iwd2/Start.py | 12 +- gemrb/GUIScripts/pst/GUILOAD.py | 38 ++-- gemrb/GUIScripts/pst/GUISAVE.py | 50 +++--- gemrb/GUIScripts/pst/NewLife.py | 2 +- gemrb/core/Actions.cpp | 31 +-- gemrb/core/GameControl.cpp | 14 +- gemrb/core/Holder.h | 89 ++++++++ gemrb/core/Interface.cpp | 13 +- gemrb/core/Interface.h | 8 +- gemrb/core/SaveGameIterator.cpp | 258 ++++++++++++++---------- gemrb/core/SaveGameIterator.h | 34 ++-- gemrb/core/Sprite2D.cpp | 2 + gemrb/core/Sprite2D.h | 3 + gemrb/docs/en/GemRB_INI.txt | 4 + gemrb/includes/globals.h | 5 +- gemrb/override/bg1/savegame.2da | 2 +- gemrb/override/bg2/savegame.2da | 2 +- gemrb/override/how/savegame.2da | 2 +- gemrb/override/iwd/savegame.2da | 2 +- gemrb/override/iwd2/gemrb.ini | 1 + gemrb/override/iwd2/savegame.2da | 2 +- gemrb/override/pst/savegame.2da | 2 +- gemrb/plugins/GUIScript/GUIScript.cpp | 345 ++++++++++++++----------------- gemrb/plugins/GUIScript/PythonHelpers.h | 105 ++++++++++ 37 files changed, 831 insertions(+), 632 deletions(-) create mode 100644 gemrb/core/Holder.h create mode 100644 gemrb/plugins/GUIScript/PythonHelpers.h from 09eb31183bda6d8618015337888d714f6dae5b05 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=d049abc744c49d028944034f2823c031ddf55e17 commit d049abc744c49d028944034f2823c031ddf55e17 Merge: 09eb311 ba79619 Author: Tom Prince <tom...@ua...> Date: Sun May 23 05:22:52 2010 -0400 Merge branch 'savegame' http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=ba796199e9c345f15daab50149830b8a1428c245 commit ba796199e9c345f15daab50149830b8a1428c245 Author: Tom Prince <tom...@ua...> Date: Fri May 21 16:23:33 2010 -0400 GUIScript: Expose SaveGame object to python. diff --git a/gemrb/GUIScripts/GUIClasses.py b/gemrb/GUIScripts/GUIClasses.py index ab32cac..a53b029 100644 --- a/gemrb/GUIScripts/GUIClasses.py +++ b/gemrb/GUIScripts/GUIClasses.py @@ -178,6 +178,17 @@ class GWorldMap(GControl): 'SetTextColor': _GemRB.WorldMap_SetTextColor } +class GSaveGame: + __metaclass__ = metaIDWrapper + methods = { + 'GetDate': _GemRB.SaveGame_GetDate, + 'GetGameDate': _GemRB.SaveGame_GetGameDate, + 'GetName': _GemRB.SaveGame_GetName, + 'GetPortrait': _GemRB.SaveGame_GetPortrait, + 'GetPreview': _GemRB.SaveGame_GetPreview, + 'GetSaveID': _GemRB.SaveGame_GetSaveID, + } + class GSprite2D: __metaclass__ = metaIDWrapper methods = {} diff --git a/gemrb/GUIScripts/bg1/GUILOAD.py b/gemrb/GUIScripts/bg1/GUILOAD.py index 3ae3f86..23d929d 100644 --- a/gemrb/GUIScripts/bg1/GUILOAD.py +++ b/gemrb/GUIScripts/bg1/GUILOAD.py @@ -27,11 +27,11 @@ from LoadScreen import * LoadWindow = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OnLoad (): - global LoadWindow, TextAreaControl, GameCount, ScrollBar + global LoadWindow, TextAreaControl, Games, ScrollBar GemRB.LoadWindowPack ("GUILOAD", 640, 480) LoadWindow = GemRB.LoadWindowObject (0) @@ -69,11 +69,8 @@ def OnLoad (): ScrollBar=LoadWindow.GetControl (25) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 4) GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBarPress () @@ -88,36 +85,36 @@ def ScrollBarPress (): Button1 = LoadWindow.GetControl (26+i) Button2 = LoadWindow.GetControl (30+i) - if ActPos<GameCount: + if ActPos<len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) Button2.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) Button2.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() else: Slotname = "" Label = LoadWindow.GetControl (0x10000008+i) Label.SetText (Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetDate() else: Slotname = "" Label = LoadWindow.GetControl (0x10000010+i) Label.SetText (Slotname) Button=LoadWindow.GetControl (1+i) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture ("") for j in range (PARTY_SIZE): Button=LoadWindow.GetControl (40 + i*PARTY_SIZE + j) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture ("") return @@ -127,20 +124,20 @@ def LoadGamePress (): LoadWindow.Unload () Pos = GemRB.GetVar ("TopIndex")+GemRB.GetVar ("LoadIdx") StartLoadScreen() - GemRB.LoadGame (Pos) #loads and enters savegame + GemRB.LoadGame (Games[Pos]) #loads and enters savegame GemRB.EnterGame () return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame (Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[Pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/bg1/GUISAVE.py b/gemrb/GUIScripts/bg1/GUISAVE.py index 31fab2b..e06fa35 100644 --- a/gemrb/GUIScripts/bg1/GUISAVE.py +++ b/gemrb/GUIScripts/bg1/GUISAVE.py @@ -32,11 +32,11 @@ ConfirmWindow = 0 NameField = 0 SaveButton = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OpenSaveWindow (): - global SaveWindow, TextAreaControl, GameCount, ScrollBar + global SaveWindow, TextAreaControl, Games, ScrollBar if CloseOtherWindow (OpenSaveWindow): CloseSaveWindow () @@ -80,11 +80,8 @@ def OpenSaveWindow (): ScrollBar=Window.GetControl (25) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount ()+1 #one more for the 'new game' - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 4 + 1) #one more for the 'new game' GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBar.SetDefaultScrollBar () @@ -102,15 +99,15 @@ def ScrollBarPress(): Button1 = Window.GetControl (26+i) Button2 = Window.GetControl (30+i) - if ActPos<GameCount: + if ActPos<=len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() Button2.SetState (IE_GUI_BUTTON_ENABLED) - elif ActPos == GameCount-1: + elif ActPos == len(Games): Slotname = 15304 Button2.SetState (IE_GUI_BUTTON_DISABLED) else: @@ -120,22 +117,22 @@ def ScrollBarPress(): Label = Window.GetControl (0x10000008+i) Label.SetText (Slotname) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = Window.GetControl (0x10000010+i) Label.SetText (Slotname) Button=Window.GetControl (1+i) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") for j in range(PARTY_SIZE): Button=Window.GetControl (40+i*PARTY_SIZE+j) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") return @@ -153,7 +150,10 @@ def ConfirmedSaveGame(): Label = ConfirmWindow.GetControl (3) Slotname = Label.QueryText () StartLoadScreen() - GemRB.SaveGame(Pos, Slotname) + if Pos<len(Games): + GemRB.SaveGame(Games[Pos], Slotname) + else: + GemRB.SaveGame(None, Slotname) if ConfirmWindow: ConfirmWindow.Unload () OpenSaveWindow() # close window @@ -166,8 +166,8 @@ def SavePress(): ConfirmWindow = GemRB.LoadWindowObject (1) #slot name - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameName(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetName() else: Slotname = "" NameField = ConfirmWindow.GetControl (3) @@ -175,8 +175,8 @@ def SavePress(): NameField.SetEvent (IE_GUI_EDIT_ON_CHANGE,"EditChange") #game hours (should be generated from game) - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetGameDate() else: Slotname = "" Label = ConfirmWindow.GetControl (0x10000004) @@ -184,16 +184,16 @@ def SavePress(): #areapreview Button=ConfirmWindow.GetControl (0) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if Pos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") #portraits for j in range(PARTY_SIZE): Button=ConfirmWindow.GetControl (40+j) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if Pos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") @@ -225,15 +225,15 @@ def EditChange(): return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/bg1/Start.py b/gemrb/GUIScripts/bg1/Start.py index 21a7a6c..5ac970b 100644 --- a/gemrb/GUIScripts/bg1/Start.py +++ b/gemrb/GUIScripts/bg1/Start.py @@ -109,7 +109,7 @@ def PregenPress(): QuitWindow.Unload() GemRB.SetVar("PlayMode",0) #loadgame needs this hack GemRB.GameSetExpansion(0) - GemRB.LoadGame(-1) + GemRB.LoadGame(None) GemRB.SetVar("PlayMode",-1) GemRB.SetNextScript("GUIMP") return @@ -142,7 +142,7 @@ def NewSingle(): GemRB.SetVar("PlayMode",0) GemRB.GameSetExpansion(0) GemRB.SetVar("Slot",1) - GemRB.LoadGame(-1) + GemRB.LoadGame(None) GemRB.SetNextScript("CharGen") #temporarily return diff --git a/gemrb/GUIScripts/bg2/GUILOAD.py b/gemrb/GUIScripts/bg2/GUILOAD.py index ea0774b..bd77c2e 100644 --- a/gemrb/GUIScripts/bg2/GUILOAD.py +++ b/gemrb/GUIScripts/bg2/GUILOAD.py @@ -22,11 +22,11 @@ from LoadScreen import * LoadWindow = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OnLoad(): - global LoadWindow, TextAreaControl, GameCount, ScrollBar + global LoadWindow, TextAreaControl, Games, ScrollBar GemRB.LoadWindowPack("GUILOAD", 640, 480) LoadWindow = GemRB.LoadWindowObject(0) @@ -63,11 +63,8 @@ def OnLoad(): ScrollBar=LoadWindow.GetControl(25) ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount() #count of games in save folder? - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames() + TopIndex = max (0, len(Games) - 4) GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBarPress () @@ -82,36 +79,36 @@ def ScrollBarPress(): Button1 = LoadWindow.GetControl(26+i) Button2 = LoadWindow.GetControl(30+i) - if ActPos<GameCount: + if ActPos<len(Games): Button1.SetState(IE_GUI_BUTTON_ENABLED) Button2.SetState(IE_GUI_BUTTON_ENABLED) else: Button1.SetState(IE_GUI_BUTTON_DISABLED) Button2.SetState(IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() else: Slotname = "" Label = LoadWindow.GetControl(0x10000008+i) Label.SetText(Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = LoadWindow.GetControl(0x10000010+i) Label.SetText(Slotname) Button=LoadWindow.GetControl(1+i) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") for j in range(PARTY_SIZE): Button=LoadWindow.GetControl(40+i*PARTY_SIZE+j) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") return @@ -121,20 +118,20 @@ def LoadGamePress(): LoadWindow.Unload() Pos = GemRB.GetVar("TopIndex")+GemRB.GetVar("LoadIdx") StartLoadScreen() - GemRB.LoadGame(Pos) #loads and enters savegame + GemRB.LoadGame(Games[Pos]) #loads and enters savegame GemRB.EnterGame() #it will close windows, including the loadscreen return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar("TopIndex") Pos = TopIndex +GemRB.GetVar("LoadIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount() #count of games in save folder? - ScrollBar.SetVarAssoc("TopIndex", GameCount) + del Games[Pos] + ScrollBar.SetVarAssoc("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload() diff --git a/gemrb/GUIScripts/bg2/GUISAVE.py b/gemrb/GUIScripts/bg2/GUISAVE.py index 31fab2b..3110c94 100644 --- a/gemrb/GUIScripts/bg2/GUISAVE.py +++ b/gemrb/GUIScripts/bg2/GUISAVE.py @@ -32,11 +32,11 @@ ConfirmWindow = 0 NameField = 0 SaveButton = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OpenSaveWindow (): - global SaveWindow, TextAreaControl, GameCount, ScrollBar + global SaveWindow, TextAreaControl, Games, ScrollBar if CloseOtherWindow (OpenSaveWindow): CloseSaveWindow () @@ -80,11 +80,8 @@ def OpenSaveWindow (): ScrollBar=Window.GetControl (25) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount ()+1 #one more for the 'new game' - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 4 + 1) #one more for the 'new game' GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBar.SetDefaultScrollBar () @@ -102,15 +99,15 @@ def ScrollBarPress(): Button1 = Window.GetControl (26+i) Button2 = Window.GetControl (30+i) - if ActPos<GameCount: + if ActPos<=len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() Button2.SetState (IE_GUI_BUTTON_ENABLED) - elif ActPos == GameCount-1: + elif ActPos == len(Games): Slotname = 15304 Button2.SetState (IE_GUI_BUTTON_DISABLED) else: @@ -120,22 +117,22 @@ def ScrollBarPress(): Label = Window.GetControl (0x10000008+i) Label.SetText (Slotname) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = Window.GetControl (0x10000010+i) Label.SetText (Slotname) Button=Window.GetControl (1+i) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") for j in range(PARTY_SIZE): Button=Window.GetControl (40+i*PARTY_SIZE+j) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") return @@ -153,7 +150,10 @@ def ConfirmedSaveGame(): Label = ConfirmWindow.GetControl (3) Slotname = Label.QueryText () StartLoadScreen() - GemRB.SaveGame(Pos, Slotname) + if Pos < len(Games): + GemRB.SaveGame(Games[Pos], Slotname) + else: + GemRB.SaveGame(None, Slotname) if ConfirmWindow: ConfirmWindow.Unload () OpenSaveWindow() # close window @@ -166,8 +166,8 @@ def SavePress(): ConfirmWindow = GemRB.LoadWindowObject (1) #slot name - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameName(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetName(); else: Slotname = "" NameField = ConfirmWindow.GetControl (3) @@ -175,8 +175,8 @@ def SavePress(): NameField.SetEvent (IE_GUI_EDIT_ON_CHANGE,"EditChange") #game hours (should be generated from game) - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetGameDate() else: Slotname = "" Label = ConfirmWindow.GetControl (0x10000004) @@ -184,16 +184,16 @@ def SavePress(): #areapreview Button=ConfirmWindow.GetControl (0) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if Pos<len(Games): + Button.SetSprite2D(Games[Pos].GetPreview()) else: Button.SetPicture("") #portraits for j in range(PARTY_SIZE): Button=ConfirmWindow.GetControl (40+j) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if Pos<len(Games): + Button.SetSprite2D(Games[Pos].GetPortrait(j)) else: Button.SetPicture("") @@ -225,15 +225,15 @@ def EditChange(): return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) + del Games[Pos] if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/bg2/Start2.py b/gemrb/GUIScripts/bg2/Start2.py index 664dadf..f208d7a 100644 --- a/gemrb/GUIScripts/bg2/Start2.py +++ b/gemrb/GUIScripts/bg2/Start2.py @@ -160,7 +160,7 @@ def PregenPress(): #do not start game after chargen GemRB.SetVar("PlayMode",-1) #will allow export GemRB.SetVar("Slot",0) - GemRB.LoadGame(-1) + GemRB.LoadGame(None) GemRB.SetNextScript ("CharGen") return @@ -199,7 +199,7 @@ def NewSingle(): GemRB.SetVar ("PlayMode", 0) GemRB.SetVar ("SaveDir", 0) GemRB.SetVar("Slot",1) - GemRB.LoadGame(-1) + GemRB.LoadGame(None) GemRB.SetNextScript ("CharGen") return @@ -219,7 +219,7 @@ def PlayPress(): GemRB.SetVar("SaveDir",0) GemRB.GameSetExpansion(0) GemRB.SetVar("Slot",1) - GemRB.LoadGame(-1) + GemRB.LoadGame(None) GemRB.SetNextScript ("CharGen") return diff --git a/gemrb/GUIScripts/iwd/GUILOAD.py b/gemrb/GUIScripts/iwd/GUILOAD.py index d2370f9..6b773d3 100644 --- a/gemrb/GUIScripts/iwd/GUILOAD.py +++ b/gemrb/GUIScripts/iwd/GUILOAD.py @@ -27,11 +27,11 @@ from LoadScreen import * LoadWindow = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OnLoad (): - global LoadWindow, TextAreaControl, GameCount, ScrollBar + global LoadWindow, TextAreaControl, Games, ScrollBar GemRB.SetVar ("PlayMode",0) #iwd is always using 'mpsave' GemRB.SetVar ("SaveDir",1) #iwd is always using 'mpsave' @@ -70,11 +70,8 @@ def OnLoad (): ScrollBar=LoadWindow.GetControl (25) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - if GameCount>3: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 4) GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBarPress () @@ -89,36 +86,36 @@ def ScrollBarPress (): Button1 = LoadWindow.GetControl (26+i) Button2 = LoadWindow.GetControl (30+i) - if ActPos<GameCount: + if ActPos<len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) Button2.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) Button2.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() else: Slotname = "" Label = LoadWindow.GetControl (0x10000008+i) Label.SetText (Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = LoadWindow.GetControl (0x10000010+i) Label.SetText (Slotname) Button=LoadWindow.GetControl (1+i) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture ("") for j in range (PARTY_SIZE): Button=LoadWindow.GetControl (40 + i*PARTY_SIZE + j) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture ("") return @@ -128,20 +125,20 @@ def LoadGamePress (): LoadWindow.Unload () Pos = GemRB.GetVar ("TopIndex")+GemRB.GetVar ("LoadIdx") StartLoadScreen() - GemRB.LoadGame (Pos) #loads and enters savegame + GemRB.LoadGame(Games[Pos]) #loads and enters savegame GemRB.EnterGame () return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame (Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[Pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/iwd/GUISAVE.py b/gemrb/GUIScripts/iwd/GUISAVE.py index 3c40f78..e39d6e7 100644 --- a/gemrb/GUIScripts/iwd/GUISAVE.py +++ b/gemrb/GUIScripts/iwd/GUISAVE.py @@ -32,11 +32,11 @@ ConfirmWindow = 0 NameField = 0 SaveButton = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OpenSaveWindow (): - global SaveWindow, TextAreaControl, GameCount, ScrollBar + global SaveWindow, TextAreaControl, Games, ScrollBar if CloseOtherWindow (OpenSaveWindow): CloseSaveWindow () @@ -80,11 +80,8 @@ def OpenSaveWindow (): ScrollBar=Window.GetControl (25) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount ()+1 #one more for the 'new game' - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 4 + 1) #one more for the 'new game' GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBar.SetDefaultScrollBar () @@ -102,15 +99,15 @@ def ScrollBarPress(): Button1 = Window.GetControl (26+i) Button2 = Window.GetControl (30+i) - if ActPos<GameCount: + if ActPos<=len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() Button2.SetState (IE_GUI_BUTTON_ENABLED) - elif ActPos == GameCount-1: + elif ActPos == len(Games): Slotname = 15304 Button2.SetState (IE_GUI_BUTTON_DISABLED) else: @@ -120,22 +117,22 @@ def ScrollBarPress(): Label = Window.GetControl (0x10000008+i) Label.SetText (Slotname) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = Window.GetControl (0x10000010+i) Label.SetText (Slotname) Button=Window.GetControl (1+i) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") for j in range(PARTY_SIZE): Button=Window.GetControl (40+i*PARTY_SIZE+j) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") return @@ -153,7 +150,10 @@ def ConfirmedSaveGame(): Label = ConfirmWindow.GetControl (3) Slotname = Label.QueryText () StartLoadScreen() - GemRB.SaveGame(Pos, Slotname) + if Pos < len(Games): + GemRB.SaveGame(Games[Pos], Slotname) + else: + GemRB.SaveGame(None, Slotname) if ConfirmWindow: ConfirmWindow.Unload () SaveWindow.SetVisible (WINDOW_VISIBLE) @@ -166,8 +166,8 @@ def SavePress(): ConfirmWindow = GemRB.LoadWindowObject (1) #slot name - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameName(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetName() else: Slotname = "" NameField = ConfirmWindow.GetControl (3) @@ -175,8 +175,8 @@ def SavePress(): NameField.SetEvent (IE_GUI_EDIT_ON_CHANGE,"EditChange") #game hours (should be generated from game) - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetGameDate() else: Slotname = "" Label = ConfirmWindow.GetControl (0x10000004) @@ -184,16 +184,16 @@ def SavePress(): #areapreview Button=ConfirmWindow.GetControl (0) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if Pos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") #portraits for j in range(PARTY_SIZE): Button=ConfirmWindow.GetControl (40+j) - if Pos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if Pos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") @@ -225,15 +225,15 @@ def EditChange(): return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/iwd/Start.py b/gemrb/GUIScripts/iwd/Start.py index 872b1ff..b6936f6 100644 --- a/gemrb/GUIScripts/iwd/Start.py +++ b/gemrb/GUIScripts/iwd/Start.py @@ -255,7 +255,7 @@ def GameTypeReallyDonePress(): StartWindow.Unload () StartWindow = None - GemRB.LoadGame (-1) + GemRB.LoadGame(None) GemRB.SetNextScript ("PartyFormation") def QuitGameTypePress (): diff --git a/gemrb/GUIScripts/iwd2/GUILOAD.py b/gemrb/GUIScripts/iwd2/GUILOAD.py index 43a315e..5923212 100644 --- a/gemrb/GUIScripts/iwd2/GUILOAD.py +++ b/gemrb/GUIScripts/iwd2/GUILOAD.py @@ -27,11 +27,11 @@ from LoadScreen import * LoadWindow = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OnLoad (): - global LoadWindow, TextAreaControl, GameCount, ScrollBar + global LoadWindow, TextAreaControl, Games, ScrollBar GemRB.SetVar ("SaveDir",1) #iwd2 is always using 'mpsave' GemRB.LoadWindowPack ("GUILOAD", 800 ,600) @@ -71,13 +71,10 @@ def OnLoad (): ScrollBar=LoadWindow.GetControl (23) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - if GameCount>4: - TopIndex = GameCount-5 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames() + TopIndex = max (0, len(Games) - 5) - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () LoadWindow.SetVisible (WINDOW_VISIBLE) return @@ -90,43 +87,43 @@ def ScrollBarPress (): Button1 = LoadWindow.GetControl (55+i) Button2 = LoadWindow.GetControl (60+i) - if ActPos<GameCount: + if ActPos<len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) Button2.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) Button2.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() else: Slotname = "" Label = LoadWindow.GetControl (0x10000005+i) Label.SetText (Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = LoadWindow.GetControl (0x1000000a+i) Label.SetText (Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetDate() else: Slotname = "" Label = LoadWindow.GetControl (0x1000000f+i) Label.SetText (Slotname) Button=LoadWindow.GetControl (1+i) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture ("") for j in range (PARTY_SIZE): Button=LoadWindow.GetControl (25 + i*PARTY_SIZE + j) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture ("") return @@ -136,20 +133,20 @@ def LoadGamePress (): LoadWindow.Unload () Pos = GemRB.GetVar ("TopIndex")+GemRB.GetVar ("LoadIdx") StartLoadScreen() - GemRB.LoadGame (Pos) #loads and enters savegame + GemRB.LoadGame(Games[Pos]) #loads and enters savegame GemRB.EnterGame () return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame (Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[Pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/iwd2/GUISAVE.py b/gemrb/GUIScripts/iwd2/GUISAVE.py index a4a7327..9524c6c 100644 --- a/gemrb/GUIScripts/iwd2/GUISAVE.py +++ b/gemrb/GUIScripts/iwd2/GUISAVE.py @@ -32,11 +32,11 @@ ConfirmWindow = 0 NameField = 0 SaveButton = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OpenSaveWindow (): - global SaveWindow, TextAreaControl, GameCount, ScrollBar + global SaveWindow, TextAreaControl, Games, ScrollBar if CloseOtherWindow (OpenSaveWindow): CloseSaveWindow () @@ -80,11 +80,8 @@ def OpenSaveWindow (): ScrollBar=Window.GetControl (23) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount ()+1 #one more for the 'new game' - if GameCount>4: - TopIndex = GameCount-4 - else: - TopIndex = 0 + Games=GemRB.GetSaveGames () + TopIndex = max (0, len(Games) - 5 + 1) #one more for the 'new game' GemRB.SetVar ("TopIndex",TopIndex) ScrollBar.SetVarAssoc ("TopIndex", TopIndex+1) ScrollBar.SetDefaultScrollBar () @@ -102,15 +99,15 @@ def ScrollBarPress(): Button1 = Window.GetControl (55+i) Button2 = Window.GetControl (60+i) - if ActPos<GameCount: + if ActPos<=len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() Button2.SetState (IE_GUI_BUTTON_ENABLED) - elif ActPos == GameCount-1: + elif ActPos == len(Games): Slotname = 15304 Button2.SetState (IE_GUI_BUTTON_DISABLED) else: @@ -120,22 +117,22 @@ def ScrollBarPress(): Label = Window.GetControl (0x10000005+i) Label.SetText (Slotname) - if ActPos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetGameDate() else: Slotname = "" Label = Window.GetControl (0x1000000a+i) Label.SetText (Slotname) Button=Window.GetControl (1+i) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture("") for j in range(PARTY_SIZE): Button=Window.GetControl (25+i*PARTY_SIZE+j) - if ActPos<GameCount-1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture("") return @@ -153,7 +150,7 @@ def ConfirmedSaveGame(): Label = ConfirmWindow.GetControl (3) Slotname = Label.QueryText () StartLoadScreen() - GemRB.SaveGame(Pos, Slotname, 22) #saves a game with version 2.2 + GemRB.SaveGame(Games[Pos], Slotname, 22) #saves a game with version 2.2 if ConfirmWindow: ConfirmWindow.Unload () SaveWindow.SetVisible (WINDOW_VISIBLE) @@ -166,8 +163,8 @@ def SavePress(): ConfirmWindow = GemRB.LoadWindowObject (1) #slot name - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameName(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetName() else: Slotname = "" NameField = ConfirmWindow.GetControl (3) @@ -175,8 +172,8 @@ def SavePress(): NameField.SetEvent (IE_GUI_EDIT_ON_CHANGE,"EditChange") #game hours (should be generated from game) - if Pos<GameCount-1: - Slotname = GemRB.GetSaveGameGameDate(Pos) + if Pos<len(Games): + Slotname = Games[Pos].GetGameDate() else: Slotname = "" Label = ConfirmWindow.GetControl (0x10000004) @@ -184,16 +181,16 @@ def SavePress(): #areapreview #Button=ConfirmWindow.GetControl (0) - #if Pos<GameCount-1: - # Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + #if Pos<len(Games): + # Button.SetSprite2D(Games[ActPos].GetPreview()) #else: # Button.SetPicture("") #portraits #for j in range(PARTY_SIZE): # Button=ConfirmWindow.GetControl (25+j) - # if Pos<GameCount-1: - # Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + # if Pos<len(Games): + # Button.SetSprite2D(Games[ActPos].GetPortrait(j)) # else: # Button.SetPicture("") @@ -225,15 +222,15 @@ def EditChange(): return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + del Games[pos] + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/iwd2/SPParty.py b/gemrb/GUIScripts/iwd2/SPParty.py index 1cf8cef..ec3a50c 100644 --- a/gemrb/GUIScripts/iwd2/SPParty.py +++ b/gemrb/GUIScripts/iwd2/SPParty.py @@ -94,7 +94,7 @@ def ModifyPress(): if Pos == 0: # first entry - behaves same as pressing on done if PartySelectWindow: PartySelectWindow.Unload() - GemRB.LoadGame(-1, 22) + GemRB.LoadGame(None, 22) GemRB.SetNextScript("SPPartyFormation") #else: # here come the real modifications @@ -104,12 +104,12 @@ def DonePress(): if Pos == 0: if PartySelectWindow: PartySelectWindow.Unload() - GemRB.LoadGame(-1, 22) + GemRB.LoadGame(None, 22) GemRB.SetNextScript("SPPartyFormation") else: if PartySelectWindow: PartySelectWindow.Unload() - GemRB.LoadGame(-1, 22) + GemRB.LoadGame(None, 22) #here we should load the party characters #but gemrb engine limitations require us to #return to the main engine (loadscreen) diff --git a/gemrb/GUIScripts/iwd2/Start.py b/gemrb/GUIScripts/iwd2/Start.py index aa1b68b..0ae7cfd 100644 --- a/gemrb/GUIScripts/iwd2/Start.py +++ b/gemrb/GUIScripts/iwd2/Start.py @@ -53,16 +53,16 @@ def OnLoad(): LoadGameButton.SetStatus(IE_GUI_BUTTON_ENABLED) GemRB.SetVar("SaveDir",1) - GameCount=GemRB.GetSaveGameCount() + Games=GemRB.GetSaveGames() #looking for the quicksave EnableQuickLoad = IE_GUI_BUTTON_DISABLED - for ActPos in range(GameCount): - Slotname = GemRB.GetSaveGameSaveID(ActPos) - # quick save is 2 - if Slotname == 2: + for Game in Games: + Slotname = Game.GetSaveID() + # quick save is 1 + if Slotname == 1: EnableQuickLoad = IE_GUI_BUTTON_ENABLED - QuickLoadSlot = ActPos + QuickLoadSlot = Game break QuickLoadButton.SetStatus(EnableQuickLoad) diff --git a/gemrb/GUIScripts/pst/GUILOAD.py b/gemrb/GUIScripts/pst/GUILOAD.py index 558dea9..02ca885 100644 --- a/gemrb/GUIScripts/pst/GUILOAD.py +++ b/gemrb/GUIScripts/pst/GUILOAD.py @@ -27,11 +27,11 @@ from GUICommonWindows import OpenWaitForDiscWindow LoadWindow = 0 TextAreaControl = 0 -GameCount = 0 +Games = () ScrollBar = 0 def OnLoad (): - global LoadWindow, TextAreaControl, GameCount, ScrollBar + global LoadWindow, TextAreaControl, Games, ScrollBar GemRB.LoadWindowPack ("GUILOAD") LoadWindow = GemRB.LoadWindowObject (0) @@ -68,9 +68,9 @@ def OnLoad (): ScrollBar=LoadWindow.GetControl (13) ScrollBar.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount=GemRB.GetSaveGameCount () #count of games in save folder? - if GameCount>3: - TopIndex = GameCount-4 + Games=GemRB.GetSaveGames () #count of games in save folder? + if len(Games)>3: + TopIndex = len(Games)-4 else: TopIndex = 0 GemRB.SetVar ("TopIndex",TopIndex) @@ -87,36 +87,36 @@ def ScrollBarPress (): Button1 = LoadWindow.GetControl (14+i) Button2 = LoadWindow.GetControl (18+i) - if ActPos<GameCount: + if ActPos<len(Games): Button1.SetState (IE_GUI_BUTTON_ENABLED) Button2.SetState (IE_GUI_BUTTON_ENABLED) else: Button1.SetState (IE_GUI_BUTTON_DISABLED) Button2.SetState (IE_GUI_BUTTON_DISABLED) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameName(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetName() else: Slotname = "" Label = LoadWindow.GetControl (0x10000004+i) Label.SetText (Slotname) - if ActPos<GameCount: - Slotname = GemRB.GetSaveGameDate(ActPos) + if ActPos<len(Games): + Slotname = Games[ActPos].GetDate() else: Slotname = "" Label = LoadWindow.GetControl (0x10000008+i) Label.SetText (Slotname) Button=LoadWindow.GetControl (1+i) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture ("") for j in range (PARTY_SIZE): Button=LoadWindow.GetControl (22+i*PARTY_SIZE+j) - if ActPos<GameCount: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos<len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture ("") return @@ -126,20 +126,20 @@ def LoadGamePress (): LoadWindow.Unload () Pos = GemRB.GetVar ("TopIndex")+GemRB.GetVar ("LoadIdx") StartLoadScreen () - GemRB.LoadGame (Pos) # load & start game + GemRB.LoadGame(Games[Pos]) # load & start game GemRB.EnterGame () return def DeleteGameConfirm (): - global GameCount + global Games TopIndex = GemRB.GetVar ("TopIndex") Pos = TopIndex +GemRB.GetVar ("LoadIdx") - GemRB.DeleteSaveGame (Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar ("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount () - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + Games=GemRB.GetSaveGames () + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () if ConfirmWindow: ConfirmWindow.Unload () diff --git a/gemrb/GUIScripts/pst/GUISAVE.py b/gemrb/GUIScripts/pst/GUISAVE.py index 40a5d0e..367c077 100644 --- a/gemrb/GUIScripts/pst/GUISAVE.py +++ b/gemrb/GUIScripts/pst/GUISAVE.py @@ -30,12 +30,12 @@ from GUIClasses import GWindow SaveWindow = None SaveDetailWindow = None OptionsWindow = None -GameCount = 0 +Games = () ScrollBar = 0 def OpenSaveWindow (): - global SaveWindow, OptionsWindow, GameCount, ScrollBar + global SaveWindow, OptionsWindow, Games, ScrollBar if SaveWindow: GemRB.HideGUI () @@ -88,11 +88,11 @@ def OpenSaveWindow (): ScrollBar = Window.GetControl(13) ScrollBar.SetEvent(IE_GUI_SCROLLBAR_ON_CHANGE, "ScrollBarPress") - GameCount = GemRB.GetSaveGameCount () + 1 #one more for the 'new game' - TopIndex = max (0, GameCount - 4) + Games = GemRB.GetSaveGames() + TopIndex = max (0, len(Games) - 4 + 1) #one more for the 'new game' GemRB.SetVar ("TopIndex",TopIndex) - ScrollBar.SetVarAssoc ("TopIndex", GameCount) + ScrollBar.SetVarAssoc ("TopIndex", len(Games)) ScrollBarPress () GemRB.UnhideGUI () @@ -107,16 +107,16 @@ def ScrollBarPress(): Button1 = Window.GetControl (14 + i) Button2 = Window.GetControl (18 + i) - if ActPos < GameCount: + if ActPos <= len(Games): Button1.SetState(IE_GUI_BUTTON_ENABLED) else: Button1.SetState(IE_GUI_BUTTON_DISABLED) - if ActPos < GameCount - 1: - Slotname = GemRB.GetSaveGameName(ActPos) - Slottime = GemRB.GetSaveGameDate(ActPos) + if ActPos < len(Games): + Slotname = Games[ActPos].GetName() + Slottime = Games[ActPos].GetDate() Button2.SetState(IE_GUI_BUTTON_ENABLED) - elif ActPos == GameCount-1: + elif ActPos == len(Games): Slotname = 28647 # "Empty" Slottime = "" Button2.SetState(IE_GUI_BUTTON_DISABLED) @@ -132,15 +132,15 @@ def ScrollBarPress(): Label.SetText (Slottime) Button = Window.GetControl (1 + i) - if ActPos < GameCount - 1: - Button.SetSprite2D(GemRB.GetSaveGamePreview(ActPos)) + if ActPos < len(Games): + Button.SetSprite2D(Games[ActPos].GetPreview()) else: Button.SetPicture ("") for j in range (6): Button = Window.GetControl (22 + i*6 + j) - if ActPos < GameCount - 1: - Button.SetSprite2D(GemRB.GetSaveGamePortrait(ActPos, j)) + if ActPos < len(Games): + Button.SetSprite2D(Games[ActPos].GetPortrait(j)) else: Button.SetPicture ("") @@ -150,15 +150,15 @@ def SaveGamePress (): return def DeleteGameConfirm(): - global GameCount + global Games TopIndex = GemRB.GetVar("TopIndex") Pos = TopIndex +GemRB.GetVar("SaveIdx") - GemRB.DeleteSaveGame(Pos) + GemRB.DeleteSaveGame(Games[Pos]) if TopIndex>0: GemRB.SetVar("TopIndex",TopIndex-1) - GameCount=GemRB.GetSaveGameCount() #count of games in save folder? - ScrollBar.SetVarAssoc("TopIndex", GameCount) + del Games[pos] + ScrollBar.SetVarAssoc("TopIndex", len(Games)) ScrollBarPress() if ConfirmWindow: ConfirmWindow.Unload() @@ -220,7 +220,7 @@ def OpenSaveDetailWindow (): # Save/Overwrite Button = Window.GetControl (4) - if Pos < GameCount - 1: + if Pos < len(Games): Button.SetText (28644) # Overwrite else: Button.SetText (28645) # Save @@ -234,9 +234,9 @@ def OpenSaveDetailWindow (): Button.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR) # Slot name and time - if Pos < GameCount - 1: - Slotname = GemRB.GetSaveGameName(Pos) - Slottime = GemRB.GetSaveGameGameDate(Pos) + if Pos < len(Games): + Slotname = Games[Pos].GetName() + Slottime = Games[Pos].GetGameDate() else: Slotname = "" Slottime = "" @@ -297,7 +297,7 @@ def ConfirmedSaveGame (): # We have to close floating window first OpenSaveDetailWindow () StartLoadScreen (LS_TYPE_SAVING) - GemRB.SaveGame (Pos, Slotname) + GemRB.SaveGame(Games[Pos], Slotname) CloseSaveWindow () diff --git a/gemrb/GUIScripts/pst/NewLife.py b/gemrb/GUIScripts/pst/NewLife.py index 2b9e8d9..a929cb9 100644 --- a/gemrb/GUIScripts/pst/NewLife.py +++ b/gemrb/GUIScripts/pst/NewLife.py @@ -61,7 +61,7 @@ def OnLoad(): global TextArea GemRB.SetRepeatClickFlags(GEM_RK_DOUBLESPEED, OP_SET) - GemRB.LoadGame(-1) #loading the base game + GemRB.LoadGame(None) #loading the base game StatTable = GemRB.LoadTableObject("abcomm") GemRB.LoadWindowPack("GUICG") #setting up confirmation window diff --git a/gemrb/core/Actions.cpp b/gemrb/core/Actions.cpp index cd72f4f..32058bd 100644 --- a/gemrb/core/Actions.cpp +++ b/gemrb/core/Actions.cpp @@ -5468,22 +5468,19 @@ void GameScript::PolymorphCopyBase(Scriptable* Sender, Action* parameters) void GameScript::SaveGame(Scriptable* /*Sender*/, Action* parameters) { - AutoTable tab("savegame"); - if (!tab) { - core->GetSaveGameIterator()->CreateSaveGame(-1, "Unknown Autosave"); - return; - } - if (core->HasFeature(GF_STRREF_SAVEGAME)) { + const char *basename = "Auto-Save"; + AutoTable tab("savegame"); + if (tab) { + basename = tab->QueryField(-1); + } char * str = core->GetString( parameters->int0Parameter, IE_STR_STRREFOFF); char FolderName[_MAX_PATH]; - snprintf (FolderName, sizeof(FolderName), "%s - %s", tab->QueryField(-1), str); + snprintf (FolderName, sizeof(FolderName), "%s - %s", basename, str); core->FreeString( str ); - core->GetSaveGameIterator()->CreateSaveGame(-1, FolderName); + core->GetSaveGameIterator()->CreateSaveGame(Holder< ::SaveGame>(), FolderName); } else { - const char *folder = ""; - folder = tab->QueryField(parameters->int0Parameter); - core->GetSaveGameIterator()->CreateSaveGame(parameters->int0Parameter, folder); + core->GetSaveGameIterator()->CreateSaveGame(parameters->int0Parameter); } } diff --git a/gemrb/core/GameControl.cpp b/gemrb/core/GameControl.cpp index 5872dea..8e00922 100644 --- a/gemrb/core/GameControl.cpp +++ b/gemrb/core/GameControl.cpp @@ -270,24 +270,14 @@ GameControl::~GameControl(void) //Autosave was triggered by the GUI void GameControl::AutoSave() { - const char *folder; - AutoTable tab("savegame"); - if (tab) { - folder = tab->QueryField(0); - core->GetSaveGameIterator()->CreateSaveGame(0, folder, 0); - } + core->GetSaveGameIterator()->CreateSaveGame(0, false); } //QuickSave was triggered by the GUI //mqs is the 'multiple quick saves' flag void GameControl::QuickSave() { - const char *folder; - AutoTable tab("savegame"); - if (tab) { - folder = tab->QueryField(1); - core->GetSaveGameIterator()->CreateSaveGame(1, folder, mqs == 1); - } + core->GetSaveGameIterator()->CreateSaveGame(1, mqs == 1); } // ArrowSprite cycles diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp index 05e30b7..c2618cc 100644 --- a/gemrb/core/Interface.cpp +++ b/gemrb/core/Interface.cpp @@ -3681,14 +3681,14 @@ void Interface::QuitGame(int BackToMain) GSUpdate(true); } -void Interface::SetupLoadGame(int index, int ver_override) +void Interface::SetupLoadGame(SaveGame *sg, int ver_override) { - LoadGameIndex = index; + LoadGameIndex = sg; VersionOverride = ver_override; QuitFlag |= QF_LOADGAME; } -void Interface::LoadGame(int index, int ver_override) +void Interface::LoadGame(SaveGame *sg, int ver_override) { // This function has rather painful error handling, // as it should swap all the objects or none at all @@ -3716,15 +3716,12 @@ void Interface::LoadGame(int index, int ver_override) if (!KeepCache) DelTree((const char *) CachePath, true); LoadProgress(20); - if (index == -1) { + if (sg == NULL) { //Load the Default Game gam_str = gamedata->GetResource( GameNameResRef, IE_GAM_CLASS_ID ); sav_str = NULL; wmp_str = gamedata->GetResource( WorldMapName, IE_WMP_CLASS_ID ); } else { - Holder<SaveGame> sg = sgiterator->GetSaveGame( index ); - if (!sg) - return; gam_str = sg->GetGame(); sav_str = sg->GetSave(); wmp_str = sg->GetWmap(); diff --git a/gemrb/core/Interface.h b/gemrb/core/Interface.h index e81409f..d77bf66 100644 --- a/gemrb/core/Interface.h +++ b/gemrb/core/Interface.h @@ -78,6 +78,7 @@ class ProjectileServer; class Calendar; class Plugin; class Image; +class SaveGame; struct Symbol { SymbolMgr * sm; @@ -313,7 +314,8 @@ public: int SaveAsOriginal; //if true, saves files in compatible mode int QuitFlag; int EventFlag; - int LoadGameIndex, VersionOverride; + SaveGame *LoadGameIndex; + int VersionOverride; unsigned int SlotTypes; //this is the same as the inventory size ieResRef GlobalScript; ieResRef WorldMapName; @@ -514,10 +516,10 @@ public: /** if backtomain is not null then goes back to main screen */ void QuitGame(int backtomain); /** sets up load game */ - void SetupLoadGame(int index, int ver_override); + void SetupLoadGame(SaveGame *save, int ver_override); /** load saved game by index (-1 is default), ver_override is an optional parameter to override the saved game's version */ - void LoadGame(int index, int ver_override); + void LoadGame(SaveGame *save, int ver_override); /** fix changes in global script/worldmap*/ void UpdateMasterScript(); /*reads the filenames of the portraits folder into a list */ diff --git a/gemrb/core/SaveGameIterator.cpp b/gemrb/core/SaveGameIterator.cpp index aeef774..0789679 100644 --- a/gemrb/core/SaveGameIterator.cpp +++ b/gemrb/core/SaveGameIterator.cpp @@ -293,24 +293,15 @@ bool SaveGameIterator::RescanSaveGames() } while (( de = readdir( dir ) ) != NULL); closedir( dir ); //No other files in the directory, close it - std::transform(slots.begin(), slots.end(), back_inserter(save_slots), (Holder<SaveGame>(*)(const char*))GetSaveGame); + std::transform(slots.begin(), slots.end(), back_inserter(save_slots), GetSaveGame); return true; } -int SaveGameIterator::GetSaveGameCount() +const std::vector<Holder<SaveGame> >& SaveGameIterator::GetSaveGames() { - if (! RescanSaveGames()) - return -1; - - return (int) save_slots.size(); -} - -Holder<SaveGame> SaveGameIterator::GetSaveGame(int index) -{ - if (index < 0 || index >= GetSaveGameCount()) - return NULL; + RescanSaveGames(); - return save_slots[index]; + return save_slots; } Holder<SaveGame> SaveGameIterator::GetSaveGame(const char *slotname) @@ -493,12 +484,12 @@ static void CreateSavePath(char *Path, int index, const char *slotname) chmod(Path,S_IWRITE|S_IREAD|S_IEXEC); } -int SaveGameIterator::CreateSaveGame(int index, const char *slotname, bool mqs) +int SaveGameIterator::CreateSaveGame(int index, bool mqs) { - { - int ret = CanSave(); - if (ret) - return ret; + AutoTable tab("savegame"); + const char *slotname = NULL; + if (tab) { + slotname = tab->QueryField(index); } if (mqs) { @@ -507,34 +498,15 @@ int SaveGameIterator::CreateSaveGame(int index, const char *slotname, bool mqs) } //if index is not an existing savegame, we create a unique slotname - if (index < 0 || (size_t) index >= save_slots.size()) { - //leave space for autosaves - //probably the hardcoded slot names should be read by this object - //in that case 7 == size of hardcoded slot names array (savegame.2da) - index = 7; - for (size_t i = 0; i < save_slots.size(); ++i) { - Holder<SaveGame> save = save_slots[i]; - if (save->GetSaveID() >= index) { - index = save->GetSaveID() + 1; - } - } - } else { - // the existing filename has the original index of the previous save - // this is usually bad since the gui sends the current one - Holder<SaveGame> save = save_slots[index]; - if (!save) return -1; - if (save->GetSaveID() != index) { - // stop gemrb from deleting all our save games - printf("gemrb's buggy save code is trying to delete slot %d\n", save->GetSaveID()); - printf("that is not the slot %d we were trying to save to, erroring out!\n", index); - return -1; + for (size_t i = 0; i < save_slots.size(); ++i) { + Holder<SaveGame> save = save_slots[i]; + if (save->GetSaveID() == index) { + DeleteSaveGame(save); + break; } - DeleteSaveGame(index); } - char Path[_MAX_PATH]; CreateSavePath(Path, index, slotname); - save_slots.insert( save_slots.end(), GetSaveGame( Path ) ); if (!DoSaveGame(Path)) { return -1; @@ -555,17 +527,55 @@ int SaveGameIterator::CreateSaveGame(int index, const char *slotname, bool mqs) return 0; } -void SaveGameIterator::DeleteSaveGame(int index) +int SaveGameIterator::CreateSaveGame(Holder<SaveGame> save, const char *slotname) { - const char* slotname = save_slots[index]->GetSlotName(); if (!slotname) { - return; + return -1; + } + + if (int cansave = CanSave()) + return cansave; + + int index; + if (save) { + index = save->GetSaveID(); + + DeleteSaveGame(save); + save->release(); + } else { + //leave space for autosaves + //probably the hardcoded slot names should be read by this object + //in that case 7 == size of hardcoded slot names array (savegame.2da) + index = 7; + for (size_t i = 0; i < save_slots.size(); ++i) { + Holder<SaveGame> save = save_slots[i]; + if (save->GetSaveID() >= index) { + index = save->GetSaveID() + 1; + } + } } char Path[_MAX_PATH]; - snprintf( Path, _MAX_PATH, "%s%s%s%s", core->SavePath, SaveDir(), SPathDelimiter, slotname ); - core->DelTree( Path, false ); //remove all files from folder - rmdir( Path ); + CreateSavePath(Path, index, slotname); + + if (!DoSaveGame(Path)) { + return -1; + } + + // Save succesful + core->DisplayConstantString(STR_SAVESUCCEED, 0xbcefbc); + if (core->GetGameControl()) { + core->GetGameControl()->SetDisplayText(STR_SAVESUCCEED, 30); + } + return 0; +} + +void SaveGameIterator::DeleteSaveGame(Holder<SaveGame> game) +{ + if (!game) { + return; + } - save_slots.erase(save_slots.begin()+index); + core->DelTree( game->GetPath(), false ); //remove all files from folder + rmdir( game->GetPath() ); } diff --git a/gemrb/core/SaveGameIterator.h b/gemrb/core/SaveGameIterator.h index e2e1f82..bc53afa 100644 --- a/gemrb/core/SaveGameIterator.h +++ b/gemrb/core/SaveGameIterator.h @@ -94,14 +94,13 @@ private: public: SaveGameIterator(void); ~SaveGameIterator(void); - int GetSaveGameCount(); - Holder<SaveGame> GetSaveGame(int index); - void DeleteSaveGame(int index); - int CreateSaveGame(int index, const char *slotname, bool mqs = false); + const charlist& GetSaveGames(); + void DeleteSaveGame(Holder<SaveGame>); + int CreateSaveGame(Holder<SaveGame>, const char *slotname); + int CreateSaveGame(int index, bool mqs = false); private: bool RescanSaveGames(); static Holder<SaveGame> GetSaveGame(const char *slotname); - char *GetSaveName(int index); void PruneQuickSave(const char *folder); }; diff --git a/gemrb/plugins/GUIScript/GUIScript.cpp b/gemrb/plugins/GUIScript/GUIScript.cpp index bb4da50..e2173a2 100644 --- a/gemrb/plugins/GUIScript/GUIScript.cpp +++ b/gemrb/plugins/GUIScript/GUIScript.cpp @@ -383,12 +383,14 @@ PyDoc_STRVAR( GemRB_LoadGame__doc, static PyObject* GemRB_LoadGame(PyObject*, PyObject* args) { - int GameIndex, VersionOverride = 0; + PyObject *obj; + int VersionOverride = 0; - if (!PyArg_ParseTuple( args, "i|i", &GameIndex, &VersionOverride )) { + if (!PyArg_ParseTuple( args, "O|i", &obj, &VersionOverride )) { return AttributeError( GemRB_LoadGame__doc ); } - core->SetupLoadGame(GameIndex, VersionOverride); + CObject<SaveGame> save(obj); + core->SetupLoadGame(save.get(), VersionOverride); Py_INCREF( Py_None ); return Py_None; } @@ -3762,14 +3764,16 @@ PyDoc_STRVAR( GemRB_SaveGame__doc, static PyObject* GemRB_SaveGame(PyObject * /*self*/, PyObject * args) { - int SlotCount; + PyObject *obj; int Version = -1; const char *folder; - if (!PyArg_ParseTuple( args, "is|i", &SlotCount, &folder, &Version )) { + if (!PyArg_ParseTuple( args, "Os|i", &obj, &folder, &Version )) { return AttributeError( GemRB_SaveGame__doc ); } + CObject<SaveGame> save(obj); + Game *game = core->GetGame(); if (!game) { return RuntimeError( "No game loaded!" ); @@ -3783,164 +3787,131 @@ static PyObject* GemRB_SaveGame(PyObject * /*self*/, PyObject * args) if (Version>0) { game->version = Version; } - return PyInt_FromLong(sgi->CreateSaveGame(SlotCount, folder) ); + return PyInt_FromLong(sgi->CreateSaveGame(save.get(), folder) ); } -PyDoc_STRVAR( GemRB_GetSaveGameCount__doc, +PyDoc_STRVAR( GemRB_GetSaveGames__doc, "GetSaveGameCount() => int\n\n" -"Returns the number of saved games." ); +"Returns the list of saved games." ); -static PyObject* GemRB_GetSaveGameCount(PyObject * /*self*/, - PyObject * /*args*/) +static PyObject* GemRB_GetSaveGames(PyObject * /*self*/, PyObject * /*args*/) { - return PyInt_FromLong( - core->GetSaveGameIterator()->GetSaveGameCount() ); + return MakePyList<SaveGame>(core->GetSaveGameIterator()->GetSaveGames()); } PyDoc_STRVAR( GemRB_DeleteSaveGame__doc, -"DeleteSaveGame(SlotCount)\n\n" +"DeleteSaveGame(Slot)\n\n" "Deletes a saved game folder completely." ); static PyObject* GemRB_DeleteSaveGame(PyObject * /*self*/, PyObject* args) { - int SlotCount; + PyObject *Slot; - if (!PyArg_ParseTuple( args, "i", &SlotCount )) { + if (!PyArg_ParseTuple( args, "O", &Slot )) { return AttributeError( GemRB_DeleteSaveGame__doc ); } - core->GetSaveGameIterator()->DeleteSaveGame( SlotCount ); + + CObject<SaveGame> game(Slot); + core->GetSaveGameIterator()->DeleteSaveGame( game.get() ); Py_INCREF( Py_None ); return Py_None; } -PyDoc_STRVAR( GemRB_GetSaveGameName__doc, -"GetSaveGameName(SaveSlotCount)\n\n" -"Returns savegame date." ); +PyDoc_STRVAR( GemRB_SaveGame_GetName__doc, +"SaveGame.GetName() => string/int\n\n" +"Returns name of the saved game." ); -static PyObject* GemRB_GetSaveGameName(PyObject * /*self*/, PyObject* args) +static PyObject* GemRB_SaveGame_GetName(Py... [truncated message content] |