/// <summary> /// Loads the quicksave if it exists /// </summary> public static void DoQuickLoad() { try { if (!CoreParams.AllowSaveLoad) { return; } //quicksave format will be q_<hash> //since we aren't supporting campaign-unique autosaves yet, hash will just be 0 string campaignId = "0"; string saveFileName = $"q_{campaignId}.json"; string saveFilePath = Path.Combine(CoreParams.SavePath, saveFileName); if (File.Exists(saveFilePath)) { SharedUtils.LoadGame(saveFileName, false); } else { Debug.Log("Quickload failed (doesn't exist)"); ShowSaveIndicator(SaveStatus.LoadMissing); } } catch (Exception e) { Debug.LogError($"Quickload failed! ({e.GetType().Name})"); Debug.LogException(e); ShowSaveIndicator(SaveStatus.LoadError); } }
public void OnClickContinue() { string savePath = CoreParams.SavePath; DirectoryInfo saveDInfo = new DirectoryInfo(savePath); FileInfo saveFInfo = saveDInfo.GetFiles().OrderBy(f => f.CreationTime).Last(); SharedUtils.LoadGame(saveFInfo.Name); }
public void OnClickLoad() { if (SelectedSaveIndex < 0) { return; } SharedUtils.LoadGame(Saves[SelectedSaveIndex].FileName); }
public void OnClickLoad() { if (SelectedSave == null) { return; } SharedUtils.LoadGame(SelectedSave.FileName); }
public void OnClickContinue() { var save = SaveUtils.GetLastSave(); if (save != null) { SharedUtils.LoadGame(save, false); } else { Modal.PushMessageModal(Sub.Replace("ContinueNoSaveMessage", "IGUI_SAVE"), Sub.Replace("ContinueNoSaveHeading", "IGUI_SAVE"), null, null); } }
public void HandleReloadButtonClicked() { string saveName = SaveUtils.GetLastSave(); if (string.IsNullOrEmpty(saveName)) { Modal.PushConfirmModal("There is no previous save to load", "Save Not Found", "Main Menu", "Close", null, (status, tag, result) => { if (result) { SharedUtils.EndGame(); } }); } else { SharedUtils.LoadGame(saveName, false); } }
/// <summary> /// Loads the quicksave if it exists /// </summary> /// <remarks>Note that this does not display the indicator and can throw exceptions</remarks> public static void DoQuickLoadEx() { if (!CoreParams.AllowSaveLoad) { throw new NotSupportedException(); } //quicksave format will be q_<hash> //since we aren't supporting campaign-unique autosaves yet, hash will just be 0 string campaignId = "0"; string saveFileName = $"q_{campaignId}.json"; string saveFilePath = Path.Combine(CoreParams.SavePath, saveFileName); if (File.Exists(saveFilePath)) { SharedUtils.LoadGame(saveFileName, false); } else { throw new FileNotFoundException("Quickload file could not be found"); } }
public void HandleCommandLineArgs() { try { int scriptexecIndex = CoreParams.CommandLineArgs.IndexOf("-scriptexec", StringComparison.OrdinalIgnoreCase); if (scriptexecIndex >= 0) { string scriptName = CoreParams.CommandLineArgs[scriptexecIndex + 1]; Debug.Log($"Running script specified from command line \"{scriptName}\""); int argIndex = scriptexecIndex + 2; List <string> arguments = new List <string>(); while (argIndex < CoreParams.CommandLineArgs.Count) { string possibleArg = CoreParams.CommandLineArgs[argIndex]; if (possibleArg.StartsWith("-", StringComparison.OrdinalIgnoreCase)) { break; } arguments.Add(possibleArg); argIndex++; } ScriptingModule.Call(scriptName, new ScriptExecutionContext() { Caller = this }, arguments.ToArray()); } } catch (Exception e) { Debug.LogError($"Failed to run script specified in command line ({e.GetType().Name}:{e.Message})"); if (ConfigState.Instance.UseVerboseLogging) { Debug.LogException(e); } } try { int loadsaveIndex = CoreParams.CommandLineArgs.IndexOf("-loadsave", StringComparison.OrdinalIgnoreCase); if (loadsaveIndex >= 0) { string saveToLoad = CoreParams.CommandLineArgs[loadsaveIndex + 1]; if (!CoreParams.AllowSaveLoad) { Debug.LogWarning($"Loading {saveToLoad} (warning: save/load is not actually enabled for this game!)"); } else { Debug.Log($"Loading {saveToLoad}"); } SharedUtils.LoadGame(saveToLoad, true); } } catch (Exception e) { Debug.LogError($"Failed to load save specified in command line ({e.GetType().Name}:{e.Message})"); if (ConfigState.Instance.UseVerboseLogging) { Debug.LogException(e); } } }
static void Load(string name) { SharedUtils.LoadGame(name, true); }
public void OnClickContinue() { SharedUtils.LoadGame(SaveUtils.GetLastSave(), false); }