Adding an infinite number of quicksaves with naming pattern?
![GrimLefourbe](https://forums.beamdog.com/uploads/userpics/119/n561BZR408JN7.jpg)
in UI Modding
Is it possible?
Has someone tried? I like to have many many saves but i'm way too lazy to go make a save through the menu every time.
I'm thinking it could be done by adding a function that makes a save with a given naming pattern and then map it to q. Can I map custom functions to hotkeys?
I'm not bringing much sorry, I don't have a lot of time to spend on that and I'd rather not do something that's already been done.
Thanks.
Has someone tried? I like to have many many saves but i'm way too lazy to go make a save through the menu every time.
I'm thinking it could be done by adding a function that makes a save with a given naming pattern and then map it to q. Can I map custom functions to hotkeys?
I'm not bringing much sorry, I don't have a lot of time to spend on that and I'd rather not do something that's already been done.
Thanks.
0
Comments
You'd need to do something like this:
Decide the format for your AutoSaved filenames - let's say it is 'Auto Save - X' where X is the number of the file (increasing from 0 to infinity).
Create an invisible button (area -1 -1 -1 -1) on the game screen (presumably the leftsidebar menu for consistency).
Give it the hotkey you want (on P, for example)
Have it trigger a function
Write the function so that it cycles through all 'Auto Save - X' files and checks the value of X each time. Once it's found the highest X, remember it.
Save the game with new filename 'Auto Save - X+1'
Potential issue - if the game has to cycle through lots of files it could cause it to slowdown/stop when it is running the cycle process.
I'm pretty sure this approach would work as I have some working code that's similar - it automatically saves when you hit the rest key. It checks to see if you have 'AutoSaveRest'-ed previously, deletes that file if you have, and then saves the game with the name 'AutoSave before Rest' (to ensure you only have one file called AutoSave before Rest).
Something like this:
Decide the format for your AutoSaved filenames - let's say it is 'AutoSave - X' where X is the timestamp.
Create an invisible button (area -1 -1 -1 -1) on the game screen (presumably the leftsidebar menu for consistency).
Give it the hotkey you want (on P, for example)... so something like this:
button { area -1 -1 -1 -1 on P action " CustomAutoSave() " }
Write the function so it is something like this:
function CustomAutoSave() e:GetActiveEngine():OnLeftPanelButtonClick(7) optionsScreen:SaveGame(0) Infinity_PushMenu('SAVE_NEWSAVE'); newSaveName = "AutoSave - " .. gameSaves.currentGameInfo.chapter .. ' - ' .. gameSaves.currentGameInfo.time completeSave() end
And testing that worked...
However, it revealed a bug with 'currentGameInfo.time'
The game saves with that variable.... however the load screen uses a different variable for the timestamp - eg you may save with 'Chapter 2, Day 3 Hour 7' but the save file has timestamp 'Chapter 2, Day 17 Hour 10'. You can test this by saving the game and checking the timestamp. Then trying to load that game immediately and seeing that the timestamp is listed differently, pic:
(I think it may be saving the game with the time since the current chapter started, but the savefile has total play time)
I'll report it on Redmine.
button { area -1 -1 -1 -1 on P action " if sidebarsGreyed ~= 1 then CustomAutoSave() end " }
Then it will check for the same conditions that would let you quicksave - and this shortcut would only work at the same time that does.
The function/action are forcing a save in a specific format through the normal save function of the game. The challenge is that the UI doesn't 'know' if the standard save function should be accessible or not, and I can't think of a way to test for it in the UI.... If that doesn't work, I will keep checking.
Try this:
button { area -1 -1 -1 -1 on P action " if canClickSaveLoad() then CustomAutoSave() end " }
It doesn't work either, might be out of luck then. From the save related functions i've looked at, this seems to be managed by the engine. Clicking on "Save Game" from the options menu makes a popup but the code for the save game button doesn't include spawning this popup.
It seems like the saving process is made heavily longer by the number of saves in the saves folder. I had like 350 saves and loading/saving was taking between 5 and 10 seconds, I cleared my folder and it's much faster now.
Must be a bad optimisation in the engine right? It shouldn't have much impact on loading/saving time.