Ticket #4417: 4417_autosave.2.patch
File 4417_autosave.2.patch, 3.7 KB (added by , 7 years ago) |
---|
-
binaries/data/config/default.cfg
62 62 ; Emulate right-click with Ctrl+Click on Mac mice 63 63 macmouse = false 64 64 65 autosave = "true" 66 autosave.period = "10" 67 65 68 ; System settings: 66 69 67 70 ; if false, actors won't be rendered but anything entity will be. -
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": "number", 109 "label": "Autosave Period", 110 "tooltip": "Save the game every selected period.", 111 "parameters": { "config": "autosave.period", "min": 1, "max": 1440 } 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"/> -
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 = +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 }