EE: No gui quickload
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 223
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 4
Description
The EEs added a quickload button to some start screens, just like iwd2. We need to store the name of the last save that was saved in the config/ini (something like "Last Quick Save" with the value being the filename), so we can look it up on start up. Just deriving it at the time is not good enough, since there's an action that can prevent it — `ContinueGame`. And then we need to wire the quickload itself.
As a bonus, we can add a small button to the other games, so they can use the functionality as well.
Here's an old diff from chiv for the same thing; perhaps some of it can be salvaged:
```diff
diff --git a/gemrb/GUIScripts/bg2/Start.py b/gemrb/GUIScripts/bg2/Start.py
index 6e25d01..35db7d2 100644
--- a/gemrb/GUIScripts/bg2/Start.py
+++ b/gemrb/GUIScripts/bg2/Start.py
@@ -19,6 +19,7 @@
#ToB start window, precedes the SoA window
import GemRB
import GUICommon
+import LoadScreen
try:
import os
@@ -28,13 +29,20 @@ except ImportError:
StartWindow = 0
+#which save game to load from the quick menu
+
+SoASave = 0
+ToBSave = 0
+SoAGames = ()
+ToBGames = ()
+
def EndTest():
GemRB.QuitGame()
GemRB.Quit()
print "Game test completed"
def OnLoad():
- global StartWindow, skip_videos
+ global StartWindow, skip_videos, SoAGames, ToBGames
# check if we're just running the game-entering test
if os and os.getenv('GEMRB_TEST', "0") != "0":
@@ -91,6 +99,83 @@ def OnLoad():
ExitButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ExitPress)
StartWindow.SetVisible(WINDOW_VISIBLE)
GemRB.LoadMusicPL("Cred.mus")
+ #add a quick load button
+ extra = GemRB.GetVar("GUIEnhancements")&GE_SPLASH_LOAD_SHORTCUT
+ if not extra:
+ return
+
+ GemRB.SetMasterScript("BALDUR","WORLDMAP")
+ GemRB.SetVar("oldgame",1)
+ GemRB.SetVar ("PlayMode", 0)
+ SoAGames = GemRB.GetSaveGames()
+
+ GemRB.SetMasterScript("BALDUR25","WORLDM25")
+ GemRB.SetVar("oldgame",0)
+ GemRB.SetVar ("PlayMode", 2)
+ ToBGames = GemRB.GetSaveGames()
+
+ InitializeQuickLoadInator(StartWindow)
+ return
+
+def InitializeQuickLoadInator (Window):
+ StartWindow = Window
+
+
+ SoAResumeButton = StartWindow.CreateButton(65, 30,346 , 103, 77)
+ sup = StartWindow.CreateButton(66, 270,346 , 20, 40) #up button
+ sdn = StartWindow.CreateButton(67, 270,386 , 20, 40) #down button
+
+ ToBResumeButton = StartWindow.CreateButton(85, 360,346 , 103, 77)
+ tup = StartWindow.CreateButton(86, 600,346 , 20, 40) #up button
+ tdn = StartWindow.CreateButton(87, 600,386 , 20, 40) #down button
+
+ DrawSaveGameButtons() #passer le bal
+ return
+
+def DrawSaveGameButtons ():
+ global SoAGames, SoASave, ToBGames, ToBSave
+
+ if len(SoAGames): # if no games, just do the old text
+ GemRB.SetVar("oldgame",1)
+ GemRB.SetMasterScript("BALDUR","WORLDMAP")
+ SoAResumeButton = StartWindow.GetControl(65)
+ sup = StartWindow.GetControl(66)
+ sdn = StartWindow.GetControl(67)
+ SoAResumeButton.SetSprite2D(SoAGames[SoASave].GetPreview())
+ SoAResumeButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SoAResume)
+ text = SoAGames[SoASave].GetName()
+ text += "\n"
+ text += SoAGames[SoASave].GetGameDate()
+ TextArea = StartWindow.GetControl(0)
+ TextArea.SetPos(136,346)
+ TextArea.SetSize(100,90)
+ TextArea.SetText(text)
+ #TextArea.SetPos(34,400) #cant put name on the save because even though the text area acts on top, it draws below
+ sup.SetSprites ("GUIBTBUT",0,0,1,2,3)
+ sup.SetEvent(IE_GUI_BUTTON_ON_PRESS, SoAUp)
+ sdn.SetSprites ("GUIBTBUT",0,0,1,2,3)
+ sdn.SetEvent(IE_GUI_BUTTON_ON_PRESS, SoADown)
+
+ if len(ToBGames):
+ GemRB.SetVar("oldgame",0)
+ GemRB.SetMasterScript("BALDUR25","WORLDM25")
+ ToBResumeButton = StartWindow.GetControl(85)
+ tup = StartWindow.GetControl(86)
+ tdn = StartWindow.GetControl(87)
+ ToBResumeButton.SetSprite2D(ToBGames[ToBSave].GetPreview())
+ ToBResumeButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, ToBResume)
+ text = ToBGames[ToBSave].GetName()
+ text += "\n"
+ text += ToBGames[ToBSave].GetGameDate()
+ TextArea = StartWindow.GetControl(1)
+ TextArea.SetPos(467,346)
+ TextArea.SetSize(100,90)
+ TextArea.SetText(text)
+ tup.SetSprites ("GUIBTBUT",0,0,1,2,3)
+ tup.SetEvent(IE_GUI_BUTTON_ON_PRESS, ToBUp)
+ tdn.SetSprites ("GUIBTBUT",0,0,1,2,3)
+ tdn.SetEvent(IE_GUI_BUTTON_ON_PRESS, ToBDown)
+
return
def SoAPress():
@@ -100,7 +185,37 @@ def SoAPress():
GemRB.SetVar("oldgame",1)
GemRB.SetNextScript("Start2")
return
+
+def SoAResume():
+ global SoASave, SoAGames
+
+ if StartWindow:
+ StartWindow.Unload()
+ GemRB.SetMasterScript("BALDUR","WORLDMAP")
+ GemRB.SetVar("oldgame",1)
+ GemRB.SetVar ("PlayMode", 0) #just in case, no idea what important stuff im skipping...
+
+
+ LoadScreen.StartLoadScreen()
+ GemRB.LoadGame(SoAGames[SoASave])
+ GemRB.EnterGame()
+ return
+
+def SoAUp ():
+ global SoASave,SoAGames
+ if SoASave:
+ SoASave -=1
+ DrawSaveGameButtons()
+ return
+
+def SoADown ():
+ global SoASave,SoAGames
+ if SoASave < len(SoAGames)-1: #-1 or out of range mistake
+ SoASave +=1
+ DrawSaveGameButtons()
+ return
+
def ToBPress():
GemRB.SetMasterScript("BALDUR25","WORLDM25")
GemRB.SetVar("oldgame",0)
@@ -109,6 +224,35 @@ def ToBPress():
GemRB.SetNextScript("Start2")
return
+def ToBResume():
+ global ToBSave, ToBGames
+
+ if StartWindow:
+ StartWindow.Unload()
+
+ GemRB.SetMasterScript("BALDUR25","WORLDM25")
+ GemRB.SetVar("oldgame",0)
+ GemRB.SetVar ("PlayMode", 2)
+
+ LoadScreen.StartLoadScreen()
+ GemRB.LoadGame(ToBGames[ToBSave])
+ GemRB.EnterGame()
+ return
+
+def ToBUp ():
+ global ToBSave,ToBGames
+ if ToBSave:
+ ToBSave -=1
+ DrawSaveGameButtons()
+ return
+
+def ToBDown ():
+ global ToBSave,ToBGames
+ if ToBSave < len(ToBGames)-1: #-1 or out of range mistake
+ ToBSave +=1
+ DrawSaveGameButtons()
+ return
+
def ExitPress():
GemRB.Quit()
return
```
Contributor guide
Assessment
This issue has not been assessed yet.