internal void SaveToFile() { if (this.Data != null) { ModCustomDataFileHelpers.SaveAsJson <InboxMessageData>(ModHelpersMod.Instance, "Inbox", true, this.Data); } }
//////////////// public void Load() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { LogHelpers.Warn("Clients cannot load config from file"); return; } var data = ModCustomDataFileHelpers.LoadJson <ResetModeSessionData>(mymod, SessionLogic.DataFileNameOnly); if (data != null) { // Very specific failsafe: if (data.IsRunning && !data.AwaitingNextWorld && data.CurrentSessionedWorldId == "" && data.AllPlayedWorlds.Count == 0) { data.IsRunning = false; } this.DataOnLoad = data.Clone(); this.Data = data; } if (mymod.Config.DebugModeInfo) { LogHelpers.Alert("Success? " + (data != null) + ": " + this.Data.ToString()); } }
private void UnloadModData() { if (this.Data != null) { ModCustomDataFileHelpers.SaveAsJson <ModHelpersData>(this, "data", true, this.Data); } this.Data = new ModHelpersData(); }
public void Save() { var mymod = ResetModeMod.Instance; if (Main.netMode == 1) { LogHelpers.Warn("Clients cannot save config to file"); return; } ModCustomDataFileHelpers.SaveAsJson(mymod, SessionLogic.DataFileNameOnly, true, this.Data); }
//////////////// private bool LoadModData() { var data = ModCustomDataFileHelpers.LoadJson <ModHelpersData>(this, "data"); if (data != null) { this.Data = data; return(true); } return(false); }
public void Save(string baseFileName) { var mymod = RewardsMod.Instance; try { if (mymod.SettingsConfig.DebugModeSaveKillsAsJson) { ModCustomDataFileHelpers.SaveAsJson(mymod, baseFileName, true, this); // false? } else { ModCustomDataFileHelpers.SaveAsBinaryJson(mymod, baseFileName, true, this); // false? } } catch (IOException e) { throw new ModHelpersException("Failed to save file: " + baseFileName, e); } }
//////////////// internal bool LoadFromFile() { var data = ModCustomDataFileHelpers.LoadJson <InboxMessageData>(ModHelpersMod.Instance, "Inbox"); if (data == null) { return(false); } this.Data = data; foreach (string msgName in this.Data.Messages.Keys) { this.Data.MessageActions[msgName] = null; } return(true); }
//////////////// public bool Load(string baseFileName, Player forPlayer = null) { var mymod = RewardsMod.Instance; KillData data; bool success = false; try { if (mymod.SettingsConfig.DebugModeSaveKillsAsJson) { data = ModCustomDataFileHelpers.LoadJson <KillData>(mymod, baseFileName); } else { data = ModCustomDataFileHelpers.LoadBinaryJson <KillData>(mymod, baseFileName); success = data != null; } } catch (IOException e) { throw new ModHelpersException("Failed to load file: " + baseFileName, e); } if (success) { this.KilledNpcs = data.KilledNpcs; this.GoblinsConquered = data.GoblinsConquered; this.FrostLegionConquered = data.FrostLegionConquered; this.PiratesConquered = data.PiratesConquered; this.MartiansConquered = data.MartiansConquered; this.PumpkinMoonWavesConquered = data.PumpkinMoonWavesConquered; this.FrostMoonWavesConquered = data.FrostMoonWavesConquered; this.ProgressPoints = data.ProgressPoints; if (mymod.SettingsConfig.DebugModePPInfo) { LogHelpers.Alert("PP set: " + this.ProgressPoints + " (for " + (forPlayer?.name ?? "world") + ")"); } } else { LogHelpers.Alert("Could not load player's NPC kill (and PP) data. New player?"); } return(success); }