Ticket #4417: 4417_autosave.patch
File 4417_autosave.patch, 3.8 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/public/gui/options/options.json
96 96 "label": "Chat Timestamp", 97 97 "tooltip": "Show time that messages are posted in the lobby, gamesetup and ingame chat.", 98 98 "parameters": { "config": "chat.timestamp" } 99 }, 100 { 101 "type": "boolean", 102 "label": "Autosave", 103 "tooltip": "Enable autosaves in the game.", 104 "parameters": { "config": "autosave" }, 105 "dependencies": [ "autosave.period" ] 106 }, 107 { 108 "type": "dropdown", 109 "label": "Autosave Period", 110 "tooltip": "Save the game every selected period.", 111 "parameters": { "list": [ "1 minute", "5 minutes", "10 minutes", "15 minutes", "30 minutes", "60 minutes" ], "config": "autosave.period" } 99 112 } 100 113 ], 101 114 "graphicsSetting": -
binaries/data/mods/public/gui/options/options.xml
21 21 <object style="ModernLabelText" type="text" size="0 5 100% 25"> 22 22 <translatableAttribute id="caption">General</translatableAttribute> 23 23 </object> 24 <repeat count="2 3">24 <repeat count="25"> 25 25 <object name="generalSetting[n]" size="0 25 100% 50" hidden="true"> 26 26 <object name="generalSettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/> 27 27 <object name="generalSettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/> 28 28 <object name="generalSettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/> 29 <object name="generalSettingDropdown[n]" size=" 70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>29 <object name="generalSettingDropdown[n]" size="60% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/> 30 30 </object> 31 31 </repeat> 32 32 </object> -
binaries/data/mods/public/gui/session/session.js
169 169 */ 170 170 var g_HasIdleWorker = false; 171 171 172 var g_AutosavePeriod = 0; 173 172 174 function GetSimState() 173 175 { 174 176 if (!g_SimState) … … 312 314 onSimulationUpdate(); 313 315 setTimeout(displayGamestateNotifications, 1000); 314 316 317 if (!g_IsNetworked && !g_IsReplay && Engine.ConfigDB_GetValue("user", "autosave") == "true") 318 { 319 g_AutosavePeriod = +[1, 5, 10, 15, 30, 60][+Engine.ConfigDB_GetValue("user", "autosave.period")] * 60000; // the autosave period is set in minutes 320 // Prevent the autosave spamming for invalid values 321 if (g_AutosavePeriod >= 60000) 322 setTimeout(autosaveGame, g_AutosavePeriod); 323 } 324 315 325 // Report the performance after 5 seconds (when we're still near 316 326 // the initial camera view) and a minute (when the profiler will 317 327 // have settled down if framerates as very low), to give some … … 1412 1422 1413 1423 Engine.SendGameReport(reportObject); 1414 1424 } 1425 1426 function autosaveGame() 1427 { 1428 // Get the all current simulation state 1429 let savedGameData = getSavedGameData(); 1430 savedGameData = savedGameData && savedGameData.savedGameData || {}; 1431 let simulationState = Engine.GuiInterfaceCall("GetSimulationState"); 1432 savedGameData.timeElapsed = simulationState.timeElapsed; 1433 savedGameData.states = simulationState.players.map(pState => pState.state); 1434 1435 // Rewrite the autosave 1436 Engine.SaveGame("autosave", translate("Autosave"), savedGameData); 1437 1438 setTimeout(autosaveGame, g_AutosavePeriod); 1439 }