using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.binbin.quicksave")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.9.1.0")]
[assembly: AssemblyInformationalVersion("0.9.1+e1f73e7571be07c1eb9b9f7b096865c5615a6bf2")]
[assembly: AssemblyProduct("QuickSave")]
[assembly: AssemblyTitle("com.binbin.quicksave")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace QuickSave
{
[BepInPlugin("com.binbin.quicksave", "QuickSave", "0.9.1")]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
internal int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
private readonly Harmony harmony = new Harmony("com.binbin.quicksave");
internal static ManualLogSource Log;
public static string debugBase = "com.binbin.quicksave ";
public static ConfigEntry<bool> EnableMod { get; set; }
public static ConfigEntry<bool> EnableDebugging { get; set; }
public static ConfigEntry<bool> EnableCustomSaveNames { get; set; }
public static ConfigEntry<float> MidCombatHorizontalShift { get; set; }
public static ConfigEntry<string> SaveFolderName { get; set; }
public static ConfigEntry<bool> DisableControlClick { get; set; }
private void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0047: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0078: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00a9: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00de: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0113: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
//IL_0144: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"com.binbin.quicksave 0.9.1 has loaded!");
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Quick Save", "EnableMod"), true, new ConfigDescription("Enables the Mod", (AcceptableValueBase)null, Array.Empty<object>()));
EnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Quick Save", "Enable Debugging"), true, new ConfigDescription("Enables debugging logs.", (AcceptableValueBase)null, Array.Empty<object>()));
EnableCustomSaveNames = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Quick Save", "Enable Custom Save Names"), false, new ConfigDescription("Enables you to choose the name of your saves with the Save Game button.", (AcceptableValueBase)null, Array.Empty<object>()));
MidCombatHorizontalShift = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Quick Save", "Mid Combat UI Shift"), 100f, new ConfigDescription("Shifts the UI to the right in combat. More positive is more to the right, more negative is more to the left. A value of 100 will shift the UI one \"Icon\" to the right.", (AcceptableValueBase)null, Array.Empty<object>()));
SaveFolderName = ((BaseUnityPlugin)this).Config.Bind<string>(new ConfigDefinition("Quick Save", "Save Folder Name"), "", new ConfigDescription("Sets the name of your save folder. If left blank, the current seed will be used instead.", (AcceptableValueBase)null, Array.Empty<object>()));
DisableControlClick = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Quick Save", "Disable Control Key Click"), false, new ConfigDescription("If selected, disables the control keys from clicking.", (AcceptableValueBase)null, Array.Empty<object>()));
if (EnableMod.Value)
{
harmony.PatchAll();
}
}
internal static void LogDebug(string msg)
{
if (EnableDebugging.Value)
{
Log.LogDebug((object)(debugBase + msg));
}
}
internal static void LogInfo(string msg)
{
Log.LogInfo((object)(debugBase + msg));
}
internal static void LogError(string msg)
{
Log.LogError((object)(debugBase + msg));
}
}
[HarmonyPatch]
public class QuickSaveFunctions
{
public enum LoadType
{
Turn,
Game
}
[CompilerGenerated]
private sealed class <SaveGame>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public bool doCustomName;
private int <saveSlot>5__1;
private string <savePath>5__2;
private string <directory>5__3;
private string <seed>5__4;
private string <node>5__5;
private string <folderName>5__6;
private string <outputDirectory>5__7;
private string <originalPath>5__8;
private string <newFileName>5__9;
private string <newPath>5__10;
private string <nextFilePath>5__11;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SaveGame>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<savePath>5__2 = null;
<directory>5__3 = null;
<seed>5__4 = null;
<node>5__5 = null;
<folderName>5__6 = null;
<outputDirectory>5__7 = null;
<originalPath>5__8 = null;
<newFileName>5__9 = null;
<newPath>5__10 = null;
<nextFilePath>5__11 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
<saveSlot>5__1 = AtOManager.Instance.GetSaveSlot();
<savePath>5__2 = SaveManager.PathSaveGameTurn(<saveSlot>5__1);
<directory>5__3 = Path.GetDirectoryName(<savePath>5__2);
AtOManager instance = AtOManager.Instance;
<seed>5__4 = ((instance != null) ? instance.GetGameId() : null) ?? "nullseed";
<node>5__5 = AtOManager.Instance?.currentMapNode ?? "sen_0";
<folderName>5__6 = ((Plugin.SaveFolderName.Value == "") ? <seed>5__4 : Plugin.SaveFolderName.Value);
<outputDirectory>5__7 = Path.Combine(<directory>5__3, <folderName>5__6, <node>5__5);
<originalPath>5__8 = Path.Combine(<directory>5__3, $"gamedata_{<saveSlot>5__1}.ato");
Plugin.LogDebug("Original Path: " + <originalPath>5__8);
<newFileName>5__9 = $"gamedata_{<saveSlot>5__1}_{<node>5__5}.ato";
Plugin.LogDebug("Output Dir: " + <outputDirectory>5__7);
if (!Directory.Exists(<outputDirectory>5__7))
{
Directory.CreateDirectory(<outputDirectory>5__7);
}
<newPath>5__10 = Path.Combine(<outputDirectory>5__7, <newFileName>5__9);
<nextFilePath>5__11 = ((!doCustomName) ? GetUniqueFilename(<newPath>5__10) : Path.Combine(<outputDirectory>5__7, QuickSavePatches.customName));
File.Copy(<originalPath>5__8, <nextFilePath>5__11, overwrite: true);
quickLoadFilename = <nextFilePath>5__11;
quickLoadType = LoadType.Game;
QuickSavePatches.changeSaveGameText = true;
<>2__current = Globals.Instance.WaitForSeconds(5f);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
QuickSavePatches.changeSaveGameText = false;
<>2__current = Globals.Instance.WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <SaveGameTurn>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public bool doCustomName;
private int <saveSlot>5__1;
private string <savePath>5__2;
private string <directory>5__3;
private string <seed>5__4;
private string <node>5__5;
private string <folderName>5__6;
private string <outputDirectory>5__7;
private string <originalPath>5__8;
private string <originalGameData>5__9;
private string <charActive>5__10;
private int <turnNum>5__11;
private string <newFileName>5__12;
private string <newPath>5__13;
private string <nextFilePath>5__14;
private string <nameWithoutExtension>5__15;
private string <extension>5__16;
private string <newGamePathName>5__17;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SaveGameTurn>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<savePath>5__2 = null;
<directory>5__3 = null;
<seed>5__4 = null;
<node>5__5 = null;
<folderName>5__6 = null;
<outputDirectory>5__7 = null;
<originalPath>5__8 = null;
<originalGameData>5__9 = null;
<charActive>5__10 = null;
<newFileName>5__12 = null;
<newPath>5__13 = null;
<nextFilePath>5__14 = null;
<nameWithoutExtension>5__15 = null;
<extension>5__16 = null;
<newGamePathName>5__17 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
<saveSlot>5__1 = AtOManager.Instance.GetSaveSlot();
Plugin.LogDebug($"Saving turn to slot {<saveSlot>5__1}");
<savePath>5__2 = SaveManager.PathSaveGameTurn(<saveSlot>5__1);
<directory>5__3 = Path.GetDirectoryName(<savePath>5__2);
AtOManager instance = AtOManager.Instance;
<seed>5__4 = ((instance != null) ? instance.GetGameId() : null) ?? "nullseed";
<node>5__5 = AtOManager.Instance?.currentMapNode ?? "sen_0";
<folderName>5__6 = ((Plugin.SaveFolderName.Value == "") ? <seed>5__4 : Plugin.SaveFolderName.Value);
<outputDirectory>5__7 = Path.Combine(<directory>5__3, <folderName>5__6, <node>5__5);
<originalPath>5__8 = <savePath>5__2;
<originalGameData>5__9 = Path.Combine(<directory>5__3, $"gamedata_{<saveSlot>5__1}.ato");
MatchManager instance2 = MatchManager.Instance;
object obj;
if (instance2 == null)
{
obj = null;
}
else
{
Character characterActive = instance2.GetCharacterActive();
obj = ((characterActive != null) ? characterActive.SourceName : null);
}
if (obj == null)
{
obj = "nullchar";
}
<charActive>5__10 = (string)obj;
MatchManager instance3 = MatchManager.Instance;
<turnNum>5__11 = ((instance3 != null) ? instance3.GetCurrentRound() : 0);
Plugin.LogDebug("Original Path: " + <originalPath>5__8);
<newFileName>5__12 = $"gamedata_{<saveSlot>5__1}_{<node>5__5}_turn{<turnNum>5__11}_{<charActive>5__10}.ato";
Plugin.LogDebug("Output Dir: " + <outputDirectory>5__7);
if (!Directory.Exists(<outputDirectory>5__7))
{
Directory.CreateDirectory(<outputDirectory>5__7);
}
<newPath>5__13 = Path.Combine(<outputDirectory>5__7, <newFileName>5__12);
<nextFilePath>5__14 = ((!doCustomName) ? GetUniqueFilename(<newPath>5__13) : Path.Combine(<outputDirectory>5__7, QuickSavePatches.customName));
<nameWithoutExtension>5__15 = Path.GetFileNameWithoutExtension(<nextFilePath>5__14);
<extension>5__16 = Path.GetExtension(<nextFilePath>5__14);
<newGamePathName>5__17 = <nameWithoutExtension>5__15 + "_gamedata" + <extension>5__16;
Plugin.LogDebug($"nextFilePath with doCustomName = {doCustomName}: {<nextFilePath>5__14}");
Plugin.LogDebug($"newGamePathName with doCustomName = {doCustomName}: {<newGamePathName>5__17}");
File.Copy(<originalPath>5__8, <nextFilePath>5__14, overwrite: true);
File.Copy(<originalGameData>5__9, <newGamePathName>5__17, overwrite: true);
quickLoadFilename = <nextFilePath>5__14;
quickLoadFilenameGameForTurn = <newGamePathName>5__17;
quickLoadType = LoadType.Turn;
QuickSavePatches.changeSaveGameText = true;
<>2__current = Globals.Instance.WaitForSeconds(1f);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
QuickSavePatches.changeSaveGameText = false;
<>2__current = Globals.Instance.WaitForSeconds(1f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static string quickLoadFilename;
public static string quickLoadFilenameGameForTurn;
public static LoadType quickLoadType;
public static bool isHost = GameManager.Instance.IsMultiplayer() && NetworkManager.Instance.IsMaster();
public static bool isMP = GameManager.Instance.IsMultiplayer();
public static Transform CreateIcon(Transform original, string name = "", List<GameObject> buttonList = null)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(((Component)original).gameObject, Vector3.zero, Quaternion.identity, (Transform)null);
if ((Object)(object)val == (Object)null)
{
Plugin.LogDebug("Failed to instantiate game object clone");
return null;
}
Transform transform = val.transform;
if ((Object)(object)transform == (Object)null)
{
Plugin.LogDebug("Cloned object has no transform component");
return null;
}
Object.DontDestroyOnLoad((Object)(object)transform);
((Component)transform).gameObject.SetActive(false);
((Object)((Component)transform).gameObject).name = name;
buttonList?.Add(((Component)transform).gameObject);
return transform;
}
public static List<string> GetAllSaves(string rootDirectory)
{
string[] files = Directory.GetFiles(rootDirectory, "*", SearchOption.AllDirectories);
List<string> list = new List<string>();
string[] array = files;
foreach (string text in array)
{
string item = text.Substring(rootDirectory.Length + 1);
list.Add(item);
}
return list;
}
[IteratorStateMachine(typeof(<SaveGameTurn>d__8))]
public static IEnumerator SaveGameTurn(bool doCustomName = false)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SaveGameTurn>d__8(0)
{
doCustomName = doCustomName
};
}
[IteratorStateMachine(typeof(<SaveGame>d__9))]
public static IEnumerator SaveGame(bool doCustomName = false)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SaveGame>d__9(0)
{
doCustomName = doCustomName
};
}
public static void QuickLoad()
{
Plugin.LogDebug("attempting to load" + quickLoadFilename);
LoadGameFromFilename(quickLoadType, quickLoadFilename, quickLoadFilenameGameForTurn);
}
public static void LoadGameFromFilename(LoadType loadType, string filePath, string filePathToGameIfTurn = "")
{
int saveSlot = AtOManager.Instance.GetSaveSlot();
string directoryName = Path.GetDirectoryName(SaveManager.PathSaveGameTurn(saveSlot));
switch (loadType)
{
case LoadType.Turn:
{
string destFileName = Path.Combine(directoryName, $"gamedata_{saveSlot}.ato");
string destFileName2 = Path.Combine(directoryName, $"gamedata_{saveSlot}_turn.ato");
if (File.Exists(filePathToGameIfTurn))
{
File.Copy(filePathToGameIfTurn, destFileName, overwrite: true);
}
File.Copy(filePath, destFileName2, overwrite: true);
BinbinLoadGame(saveSlot);
break;
}
case LoadType.Game:
{
string destFileName = Path.Combine(directoryName, $"gamedata_{saveSlot}.ato");
File.Copy(filePath, destFileName, overwrite: true);
BinbinLoadGame(saveSlot);
break;
}
default:
BinbinLoadGame(saveSlot);
break;
}
}
public static void SetButtons(List<GameObject> gameObjects, bool active)
{
foreach (GameObject gameObject in gameObjects)
{
gameObject.SetActive(active);
}
}
public static string GetUniqueFilename(string originalFilename)
{
string directoryName = Path.GetDirectoryName(originalFilename);
string text = Path.GetFileName(originalFilename);
int num = 2;
while (File.Exists(Path.Combine(directoryName, text)))
{
Match match = Regex.Match(text, "^(gamedata_\\d+_[^_]+_)(\\d+)(\\.ato)$");
if (match.Success)
{
string value = match.Groups[1].Value;
int num2 = int.Parse(match.Groups[2].Value);
string value2 = match.Groups[3].Value;
text = $"{value}{num2}_save{num}{value2}";
}
else
{
Match match2 = Regex.Match(text, "(.+?)(\\d+)(\\.ato)$");
if (match2.Success)
{
string value3 = match2.Groups[1].Value;
int num3 = int.Parse(match2.Groups[2].Value);
string value4 = match2.Groups[3].Value;
num3++;
text = $"{value3}{num3}{value4}";
}
else
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
string extension = Path.GetExtension(text);
text = $"{fileNameWithoutExtension}_save{num}{extension}";
}
}
num++;
}
return Path.Combine(directoryName, text);
}
public static string StripGamedataPrefix(string filename)
{
if (filename == null)
{
return filename;
}
return Regex.Replace(filename, "^gamedata_\\d+_", "");
}
public static List<string> GetAllFilePaths(string directory)
{
string text = ".ato";
return (from f in Directory.GetFiles(directory, "*" + text, SearchOption.AllDirectories)
orderby File.GetLastWriteTime(f) descending
select Path.GetRelativePath(directory, f)).ToList();
}
public static void SetCustomName(bool isTurn = false)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (isTurn)
{
AlertManager.buttonClickDelegate = new OnButtonClickDelegate(SetFilenameTurn);
AlertManager.Instance.AlertInput("Input Name of Save", Texts.Instance.GetText("accept", "").ToUpper());
}
else
{
AlertManager.buttonClickDelegate = new OnButtonClickDelegate(SetFilenameGame);
AlertManager.Instance.AlertInput("Input Name of Save", Texts.Instance.GetText("accept", "").ToUpper());
}
}
public static void SetFilenameGame()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
AlertManager.buttonClickDelegate = (OnButtonClickDelegate)Delegate.Remove((Delegate?)(object)AlertManager.buttonClickDelegate, (Delegate?)new OnButtonClickDelegate(SetFilenameGame));
if (AlertManager.Instance.GetInputValue() != null)
{
string text = AlertManager.Instance.GetInputValue().ToLower();
if (text.Trim() == "")
{
((MonoBehaviour)Globals.Instance).StartCoroutine(SaveGame());
return;
}
QuickSavePatches.customName = text + ".ato";
((MonoBehaviour)Globals.Instance).StartCoroutine(SaveGame(doCustomName: true));
}
}
public static void SetFilenameTurn()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
AlertManager.buttonClickDelegate = (OnButtonClickDelegate)Delegate.Remove((Delegate?)(object)AlertManager.buttonClickDelegate, (Delegate?)new OnButtonClickDelegate(SetFilenameGame));
if (AlertManager.Instance.GetInputValue() != null)
{
string text = AlertManager.Instance.GetInputValue().ToLower();
if (text.Trim() == "")
{
((MonoBehaviour)Globals.Instance).StartCoroutine(SaveGameTurn());
return;
}
QuickSavePatches.customName = text + ".ato";
((MonoBehaviour)Globals.Instance).StartCoroutine(SaveGameTurn(doCustomName: true));
}
}
public static void LoadMP()
{
}
public static void BinbinLoadGame(int saveSlot, bool isTurn = false)
{
if (!isMP)
{
AtOManager.Instance.LoadGame(saveSlot, false);
}
else if (isHost)
{
if (isTurn)
{
}
AtOManager.Instance.DoLoadGameFromMP(false);
}
}
}
[HarmonyPatch]
public class QuickSavePatches
{
public static List<GameObject> myButtonsMap;
public static List<GameObject> myButtonsCombat;
public static List<GameObject> test;
public static Transform iconReloadTurn;
public static Transform iconSkipCorruptor;
public static Transform iconResetSeed;
public static Transform iconSaveGame;
public static Transform iconSaveTurn;
public static Transform iconLoadGame;
public static Transform iconLoadGame2;
public static Transform iconQuickLoad;
public static Transform iconQuickLoad2;
public static Transform iconShowMap;
public static TMP_Dropdown loadgameDropdown;
public static bool skipCinematic = false;
public static bool skipCorruption = false;
public static bool changeSaveGameText = false;
public static List<string> loadFiles;
public static string customName = "";
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsManager), "Awake")]
public static void AwakePostfix(OptionsManager __instance, List<GameObject> ___buttonOrder)
{
Plugin.LogDebug("AwakePostfix");
myButtonsMap = new List<GameObject>();
myButtonsCombat = new List<GameObject>();
iconQuickLoad = QuickSaveFunctions.CreateIcon(__instance.iconSettings, "quickload", myButtonsMap);
iconLoadGame = QuickSaveFunctions.CreateIcon(__instance.iconStats, "loadgame", myButtonsMap);
iconSaveGame = QuickSaveFunctions.CreateIcon(__instance.iconTome, "savegame", myButtonsMap);
iconResetSeed = QuickSaveFunctions.CreateIcon(__instance.iconRetry, "resetseed", myButtonsMap);
iconReloadTurn = QuickSaveFunctions.CreateIcon(__instance.iconRetry, "reloadturn", myButtonsCombat);
iconSaveTurn = QuickSaveFunctions.CreateIcon(__instance.iconTome, "saveturn", myButtonsCombat);
iconLoadGame2 = QuickSaveFunctions.CreateIcon(__instance.iconStats, "loadgame", myButtonsCombat);
iconQuickLoad2 = QuickSaveFunctions.CreateIcon(__instance.iconSettings, "quickload", myButtonsCombat);
iconSkipCorruptor = QuickSaveFunctions.CreateIcon(__instance.iconResign, "skipcorruptor", myButtonsCombat);
myButtonsCombat.Reverse();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SettingsManager), "Awake")]
public static void SettingsManagerAwakePostfix(SettingsManager __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
TMP_Dropdown languageDropdown = SettingsManager.Instance.languageDropdown;
GameObject val = Object.Instantiate<GameObject>(((Component)languageDropdown).gameObject, Vector3.zero, Quaternion.identity, __instance.canvas.transform);
loadgameDropdown = val.GetComponent<TMP_Dropdown>();
((Component)loadgameDropdown).gameObject.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)((Component)loadgameDropdown).transform);
((Object)loadgameDropdown).name = "loadgamedropdown";
((UnityEventBase)loadgameDropdown.onValueChanged).SetPersistentListenerState(0, (UnityEventCallState)0);
RectTransform component = ((Component)loadgameDropdown).GetComponent<RectTransform>();
component.SetSizeWithCurrentAnchors((Axis)0, 500f);
loadgameDropdown.ClearOptions();
((UnityEvent<int>)(object)loadgameDropdown.onValueChanged).AddListener((UnityAction<int>)OnDropdownValueChanged);
((Component)loadgameDropdown).transform.position = ((Component)__instance).transform.position;
((Component)loadgameDropdown).transform.localPosition = new Vector3(((Component)__instance).transform.localPosition.x - 200f, ((Component)__instance).transform.localPosition.y - 200f, ((Component)__instance).transform.localPosition.z);
Plugin.LogDebug("Created DropDownTest");
Plugin.LogDebug(string.Format("Created DropDownTest: {0} with index options {1}", ((Component)loadgameDropdown).gameObject.activeSelf, string.Join(", ", loadgameDropdown.options)));
}
public static void OnDropdownValueChanged(int index)
{
Plugin.LogDebug($"OnSubmit Test option selected {index}: {loadgameDropdown.options[index].text}");
if ((Object)(object)AtOManager.Instance == (Object)null)
{
Plugin.LogDebug("OnDropdownValueChanged - Null AtOManger");
return;
}
string directoryName = Path.GetDirectoryName(SaveManager.PathSaveGameTurn(AtOManager.Instance.GetSaveSlot()));
string gameId = AtOManager.Instance.GetGameId();
string path = ((Plugin.SaveFolderName.Value == "") ? gameId : Plugin.SaveFolderName.Value);
string text = Path.Combine(directoryName, path, loadgameDropdown.options[index].text);
long length = new FileInfo(text).Length;
Plugin.LogDebug($"Current filesize in bytes: {length}");
Plugin.LogDebug("Current filename: " + text);
QuickSaveFunctions.LoadType loadType = ((length > 10000) ? QuickSaveFunctions.LoadType.Game : QuickSaveFunctions.LoadType.Turn);
string filePathToGameIfTurn = "";
if (loadType == QuickSaveFunctions.LoadType.Turn)
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
string extension = Path.GetExtension(text);
filePathToGameIfTurn = fileNameWithoutExtension + "_gamedata" + extension;
}
QuickSaveFunctions.LoadGameFromFilename(loadType, text, filePathToGameIfTurn);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsManager), "Show")]
public static void ShowPostfix(OptionsManager __instance, List<GameObject> ___buttonOrder)
{
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
Plugin.LogDebug("ShowPostfix");
QuickSaveFunctions.SetButtons(myButtonsCombat, active: false);
QuickSaveFunctions.SetButtons(myButtonsMap, active: false);
if (Object.op_Implicit((Object)(object)MatchManager.Instance) && (QuickSaveFunctions.isHost || !QuickSaveFunctions.isMP))
{
QuickSaveFunctions.SetButtons(myButtonsCombat, active: true);
if (!AtOManager.Instance.corruptionAccepted)
{
((Component)iconSkipCorruptor).gameObject.SetActive(false);
}
}
else if (Object.op_Implicit((Object)(object)TownManager.Instance) || AtOManager.Instance.CharInTown())
{
QuickSaveFunctions.SetButtons(myButtonsMap, active: true);
if (AtOManager.Instance.currentMapNode != "sen_41")
{
((Component)iconResetSeed).gameObject.SetActive(false);
}
}
else if (Object.op_Implicit((Object)(object)MapManager.Instance))
{
QuickSaveFunctions.SetButtons(myButtonsMap, active: true);
if (!(AtOManager.Instance.currentMapNode == "sen_0") && !(AtOManager.Instance.currentMapNode == "sen_41"))
{
((Component)iconResetSeed).gameObject.SetActive(false);
}
}
float num = 0.95f;
float num2 = 0.65f;
for (int i = 0; i < myButtonsMap.Count; i++)
{
if (myButtonsMap[i].activeSelf)
{
myButtonsMap[i].transform.position = new Vector3(((Component)__instance.iconTome).transform.position.x - num, ((Component)__instance.iconTome).transform.position.y, ((Component)__instance.iconTome).transform.position.z);
myButtonsMap[i].transform.localPosition = new Vector3(num + num2 * 2f, myButtonsMap[i].transform.localPosition.y, myButtonsMap[i].transform.localPosition.z);
num -= num2;
}
}
num = 0.95f;
for (int j = 0; j < myButtonsCombat.Count; j++)
{
if (myButtonsCombat[j].activeSelf)
{
myButtonsCombat[j].transform.position = new Vector3(((Component)__instance.iconTome).transform.position.x - num, ((Component)__instance.iconTome).transform.position.y, ((Component)__instance.iconTome).transform.position.z);
myButtonsCombat[j].transform.localPosition = new Vector3(num - num2 * 5.7f + Plugin.MidCombatHorizontalShift.Value * 0.01f, myButtonsCombat[j].transform.localPosition.y, myButtonsCombat[j].transform.localPosition.z);
num -= num2;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BotonRollover), "ShowText")]
public static void BotonRolloverShowText(BotonRollover __instance)
{
if (((Object)((Component)__instance).gameObject).name == "reloadturn")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Reload Turn";
}
if (((Object)((Component)__instance).gameObject).name == "savegame")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = (changeSaveGameText ? "Game Saved!" : "Save Game");
}
if (((Object)((Component)__instance).gameObject).name == "loadgame")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Load Game";
}
if (((Object)((Component)__instance).gameObject).name == "resetseed")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Reset Seed";
}
if (((Object)((Component)__instance).gameObject).name == "saveturn")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = (changeSaveGameText ? "Game Saved!" : "Save Turn");
}
if (((Object)((Component)__instance).gameObject).name == "skipcorruptor")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Restart Combat without Corruptor";
}
if (((Object)((Component)__instance).gameObject).name == "quickload")
{
string text = "Quick Load \n(" + QuickSaveFunctions.StripGamedataPrefix(Path.GetFileNameWithoutExtension(QuickSaveFunctions.quickLoadFilename)) + ")";
string value = "\n";
int num = text.IndexOf('_');
int num2 = -1;
if (num != -1)
{
num2 = text.IndexOf('_', num + 1);
}
if (num2 != -1)
{
StringBuilder stringBuilder = new StringBuilder(text);
stringBuilder.Remove(num2, 1);
stringBuilder.Insert(num2, value);
text = stringBuilder.ToString();
}
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = text;
}
if (((Object)((Component)__instance).gameObject).name == "showmap")
{
((Component)__instance.rollOverText).GetComponent<TMP_Text>().text = "Show Map (Coming Soon)";
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BotonRollover), "OnMouseUp")]
public static void BotonRolloverOnMouseUp(BotonRollover __instance)
{
if (!Functions.ClickedThisTransform(((Component)__instance).transform) || (Object.op_Implicit((Object)(object)MatchManager.Instance) && MatchManager.Instance.CombatLoading) || AlertManager.Instance.IsActive() || GameManager.Instance.IsTutorialActive() || SettingsManager.Instance.IsActive() || DamageMeterManager.Instance.IsActive() || (Object.op_Implicit((Object)(object)MapManager.Instance) && MapManager.Instance.IsCharacterUnlock()) || (Object.op_Implicit((Object)(object)MatchManager.Instance) && MatchManager.Instance.console.IsActive()))
{
return;
}
string name = ((Object)((Component)__instance).gameObject).name;
CloseWindows(__instance, name);
int saveSlot = AtOManager.Instance.GetSaveSlot();
Plugin.LogDebug("BotonRolloverOnMouseUp " + (name ?? "null object"));
switch (name)
{
case "reloadturn":
AtOManager.Instance.LoadGame(saveSlot, false);
break;
case "resetseed":
{
skipCinematic = true;
string[] array = new string[4];
Hero[] team = AtOManager.Instance.GetTeam();
for (int i = 0; i < team.Count(); i++)
{
int num = i;
Hero obj = team[i];
array[num] = ((obj != null) ? ((Character)obj).SubclassName : null) ?? "";
}
AtOManager instance = AtOManager.Instance;
if (instance != null)
{
instance.SetTeamFromArray(array);
}
AtOManager instance2 = AtOManager.Instance;
if (instance2 != null)
{
instance2.SetGameId("");
}
AtOManager instance3 = AtOManager.Instance;
if (instance3 != null)
{
instance3.SetPlayerGold(0);
}
AtOManager instance4 = AtOManager.Instance;
if (instance4 != null)
{
instance4.SetPlayerDust(0);
}
AtOManager instance5 = AtOManager.Instance;
if (instance5 != null)
{
instance5.BeginAdventure();
}
break;
}
case "savegame":
if (Plugin.EnableCustomSaveNames.Value)
{
QuickSaveFunctions.SetCustomName();
}
else
{
((MonoBehaviour)Globals.Instance).StartCoroutine(QuickSaveFunctions.SaveGame());
}
break;
case "saveturn":
if (Plugin.EnableCustomSaveNames.Value)
{
QuickSaveFunctions.SetCustomName(isTurn: true);
}
else
{
((MonoBehaviour)Globals.Instance).StartCoroutine(QuickSaveFunctions.SaveGameTurn());
}
break;
case "loadgame":
{
string directoryName = Path.GetDirectoryName(SaveManager.PathSaveGameTurn(saveSlot));
string gameId = AtOManager.Instance.GetGameId();
string path = ((Plugin.SaveFolderName.Value == "") ? gameId : Plugin.SaveFolderName.Value);
string directory = Path.Combine(directoryName, path);
List<string> allFilePaths = QuickSaveFunctions.GetAllFilePaths(directory);
Plugin.LogDebug("initialized dropdown");
loadgameDropdown.ClearOptions();
loadgameDropdown.AddOptions(allFilePaths);
((Component)loadgameDropdown).gameObject.SetActive(true);
SettingsManager.Instance.ShowSettings(true);
break;
}
case "quickload":
QuickSaveFunctions.QuickLoad();
break;
case "skipcorruptor":
skipCorruption = true;
AtOManager.Instance.corruptionAccepted = false;
MatchManager.Instance.ALL_BreakByDesync();
break;
}
fRollOut(__instance);
}
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(BotonRollover), "fRollOut")]
public static void fRollOut(BotonRollover __instance)
{
}
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(BotonRollover), "CloseWindows")]
public static void CloseWindows(BotonRollover __instance, string botName)
{
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CinematicManager), "Awake")]
public static void CinematicManagerAwakePostfix(CinematicManager __instance)
{
if (skipCinematic)
{
Plugin.LogDebug("CinematicManagerAwakePostfix attempting to skip");
skipCinematic = false;
if (__instance != null)
{
__instance.SkipCinematic();
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AtOManager), "DoLoadGame")]
public static void DoLoadGamePrefix(AtOManager __instance, bool comingFromReloadCombat = false)
{
if (skipCorruption)
{
Plugin.LogDebug("DoLoadGame attempting to corruption");
AtOManager.Instance.corruptionAccepted = false;
skipCorruption = false;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AtOManager), "DoLoadGameFromMP")]
public static void DoLoadGameFromMPPrefix(AtOManager __instance, bool comingFromReloadCombat = false)
{
if (skipCorruption)
{
Plugin.LogDebug("DoLoadGameFromMPPrefix attempting to corruption");
AtOManager.Instance.corruptionAccepted = false;
skipCorruption = false;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(InputController), "DoKeyBinding")]
public static bool DoKeyBindingPrefix(CallbackContext _context)
{
if (Keyboard.current != null && Plugin.DisableControlClick.Value && (((CallbackContext)(ref _context)).control == Keyboard.current[(Key)55] || ((CallbackContext)(ref _context)).control == Keyboard.current[(Key)56]))
{
Plugin.LogDebug("Disabling control click");
return false;
}
return true;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.quicksave";
public const string PLUGIN_NAME = "QuickSave";
public const string PLUGIN_VERSION = "0.9.1";
}
}