Browse Source

[StorageExpansion] [2.0.3.6] init

Zariteis 4 years ago
parent
commit
00e83a8d90
36 changed files with 882 additions and 0 deletions
  1. BIN
      StorageExpansion/Assets/bStorageLockedSmall.png
  2. BIN
      StorageExpansion/Assets/menuStorage2x1x2.png
  3. BIN
      StorageExpansion/Assets/menuStorage3x3x3.png
  4. BIN
      StorageExpansion/Assets/menuStorage6x5x27.png
  5. BIN
      StorageExpansion/Assets/menuStorage6x7x14vert.png
  6. BIN
      StorageExpansion/Assets/menuStorage6x8x14vert.png
  7. BIN
      StorageExpansion/Assets/menuStorage6x8x28.png
  8. BIN
      StorageExpansion/Assets/menuStorage6x8x70.png
  9. BIN
      StorageExpansion/Assets/menuStorageButtonBig.png
  10. BIN
      StorageExpansion/Assets/menuStorageButtonBig2.png
  11. BIN
      StorageExpansion/Assets/menustorage6x5x27
  12. BIN
      StorageExpansion/Assets/menustorage6x7x14
  13. BIN
      StorageExpansion/Assets/menustorage6x8x14
  14. BIN
      StorageExpansion/Assets/menustorage6x8x28
  15. BIN
      StorageExpansion/Assets/menustorage6x8x70
  16. BIN
      StorageExpansion/Assets/storageSelectSmall.png
  17. 21 0
      StorageExpansion/Core.cs
  18. 3 0
      StorageExpansion/Manifest.ini
  19. 1 0
      StorageExpansion/ModInfo.txt
  20. 172 0
      StorageExpansion/Patches/Patch_GameScript_InitializeStorage.cs
  21. 31 0
      StorageExpansion/Patches/Patch_GameScript_LoadGame.cs
  22. 61 0
      StorageExpansion/Patches/Patch_GameScript_MultiPachSlots.cs
  23. 51 0
      StorageExpansion/Patches/Patch_GameScript_RefreshSlotStorage.cs
  24. 31 0
      StorageExpansion/Patches/Patch_GameScript_SaveGame.cs
  25. 18 0
      StorageExpansion/Patches/Patch_GameScript_SelectPage.cs
  26. 43 0
      StorageExpansion/Patches/Patch_GameScript_Storage.cs
  27. 41 0
      StorageExpansion/Patches/Patch_GameScript_Update.cs
  28. 57 0
      StorageExpansion/Patches/Patch_GameScript_UpgradeStorage.cs
  29. 41 0
      StorageExpansion/Patches/RePatch_GameScript_RefreshStoragePage.cs
  30. 57 0
      StorageExpansion/Patches/RePatch_GameScript_Update.cs
  31. 10 0
      StorageExpansion/Properties/AssemblyInfo.cs
  32. 8 0
      StorageExpansion/Properties/launchSettings.json
  33. 15 0
      StorageExpansion/README.txt
  34. 49 0
      StorageExpansion/StorageExpansion.cs
  35. 164 0
      StorageExpansion/StorageExpansion.csproj
  36. 8 0
      StorageExpansion/StorageSizeEnum.cs

BIN
StorageExpansion/Assets/bStorageLockedSmall.png


BIN
StorageExpansion/Assets/menuStorage2x1x2.png


BIN
StorageExpansion/Assets/menuStorage3x3x3.png


BIN
StorageExpansion/Assets/menuStorage6x5x27.png


BIN
StorageExpansion/Assets/menuStorage6x7x14vert.png


BIN
StorageExpansion/Assets/menuStorage6x8x14vert.png


BIN
StorageExpansion/Assets/menuStorage6x8x28.png


BIN
StorageExpansion/Assets/menuStorage6x8x70.png


BIN
StorageExpansion/Assets/menuStorageButtonBig.png


BIN
StorageExpansion/Assets/menuStorageButtonBig2.png


BIN
StorageExpansion/Assets/menustorage6x5x27


BIN
StorageExpansion/Assets/menustorage6x7x14


BIN
StorageExpansion/Assets/menustorage6x8x14


BIN
StorageExpansion/Assets/menustorage6x8x28


BIN
StorageExpansion/Assets/menustorage6x8x70


BIN
StorageExpansion/Assets/storageSelectSmall.png


+ 21 - 0
StorageExpansion/Core.cs

@@ -0,0 +1,21 @@
+using GadgetCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace StorageExpansion
+{
+  internal static class Core
+  {
+    public static GadgetLogger logger;
+
+    public static int settingAmountPages = 14;
+    public static int settingAmountSlots = 8 * 6;
+
+    public static string firstPrefabPath = null;
+
+    public static StorageSizeEnum settingSizeEnum = StorageSizeEnum.Large;
+  }
+}

+ 3 - 0
StorageExpansion/Manifest.ini

@@ -0,0 +1,3 @@
+[Metadata]
+Name=Storage Expansion
+Assembly=StorageExpansion.dll

+ 1 - 0
StorageExpansion/ModInfo.txt

@@ -0,0 +1 @@
+Increases the available storage space.

+ 172 - 0
StorageExpansion/Patches/Patch_GameScript_InitializeStorage.cs

@@ -0,0 +1,172 @@
+using GadgetCore.API;
+using HarmonyLib;
+using System;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("InitializeStorage")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_InitializeStorage
+  {
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, ref Item[] ___storage, ref GameObject ___storageSelect, ref GameObject[] ___storageButton,
+      ref GameObject ___menuStorage, ref GameObject[] ___storageIcon, ref GameObject[] ___storageIconBack, ref TextMesh[] ___txtQStorage, ref TextMesh[] ___txtStorageCost)
+    {
+      if (Core.firstPrefabPath == null)
+      {
+        Core.firstPrefabPath = GetPrefabname();
+        SetSizes();
+      }
+      var path = Core.firstPrefabPath;
+      try
+      {
+        var asset = GadgetCoreAPI.LoadAssetBundle(path);
+
+        var storageMenuOld = GameObject.Find("Main Camera").transform.Find("menuStorage").gameObject;
+        GameObject.DestroyImmediate(storageMenuOld);
+
+        var storageMenuNew = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/menustorage.prefab"));
+        storageMenuNew.SetActive(false);
+        storageMenuNew.name = "menuStorage";
+        storageMenuNew.transform.SetParent(GameObject.Find("Main Camera").transform);
+        storageMenuNew.transform.localPosition = new Vector3(8, 1.5f, 2);
+        storageMenuNew.transform.localScale = new Vector3(16, 16, 1);
+      }
+      catch (System.Exception e) { Core.logger.Log(e.Message); }
+
+      ___storage = new Item[Core.settingAmountPages * Core.settingAmountSlots];
+      for (int i = 0; i < (Core.settingAmountPages * Core.settingAmountSlots); i++)
+      {
+        ___storage[i] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
+      }
+
+      ___storageButton = new GameObject[Core.settingAmountPages];
+
+      ___storageIcon = new GameObject[Core.settingAmountSlots];
+      ___storageIconBack = new GameObject[Core.settingAmountSlots];
+      ___txtQStorage = new TextMesh[Core.settingAmountSlots];
+
+      var storageMenu = GameObject.Find("Main Camera").transform.Find("menuStorage").gameObject;
+      ___menuStorage = storageMenu;
+      ___storageSelect = storageMenu.transform.FindChild("-").gameObject;
+
+      ___txtStorageCost[0] = storageMenu.transform.FindChild("bStorageU").GetChild(0).GetComponent<TextMesh>();
+      ___txtStorageCost[1] = storageMenu.transform.FindChild("bStorageU").GetChild(0).GetChild(0).GetComponent<TextMesh>();
+
+      for (int i = 0; i < Core.settingAmountSlots; i++)
+      {
+        ___storageIcon[i] = storageMenu.transform.FindChild("" + i).gameObject;
+        ___txtQStorage[i] = storageMenu.transform.FindChild("" + i).GetChild(0).GetComponent<TextMesh>();
+        ___txtQStorage[i].text = "";
+        ___storageIconBack[i] = storageMenu.transform.FindChild("" + i).GetChild(1).gameObject;
+      }
+      for (int i = 0; i < Core.settingAmountPages; i++)
+      {
+        ___storageButton[i] = storageMenu.transform.FindChild("page" + i).gameObject;
+      }
+      postBuildQuickStackButton();
+      return false;
+    }
+
+    private static void SetSizes()
+    {
+      switch (Core.settingSizeEnum)
+      {
+        //case StorageSizeEnum.UltraSmall:
+        //  Core.settingAmountPages = 2;
+        //  Core.settingAmountSlots = 2;
+        //  break;
+        //case StorageSizeEnum.Smaller:
+        //  Core.settingAmountPages = 3;
+        //  Core.settingAmountSlots = 3 * 3;
+        //  break;
+        case StorageSizeEnum.Large:
+          Core.settingAmountPages = 14;
+          Core.settingAmountSlots = 7 * 6;
+          break;
+        case StorageSizeEnum.Larger:
+          Core.settingAmountPages = 14;
+          Core.settingAmountSlots = 8 * 6;
+          break;
+        case StorageSizeEnum.MegaLarge:
+          Core.settingAmountPages = 28;
+          Core.settingAmountSlots = 8 * 6;
+          break;
+        case StorageSizeEnum.UltraLarge:
+          Core.settingAmountPages = 70;
+          Core.settingAmountSlots = 8 * 6;
+          break;
+        case StorageSizeEnum.PagesOnly:
+          Core.settingAmountPages = 27;
+          Core.settingAmountSlots = 5 * 6;
+          break;
+        default:
+          Core.settingAmountPages = 14;
+          Core.settingAmountSlots = 7 * 6;
+          break;
+      }
+    }
+
+    private static string GetPrefabname()
+    {
+      switch (Core.settingSizeEnum)
+      {
+        //case StorageSizeEnum.UltraSmall:
+        //  return "menustorage2x1x2";
+        //case StorageSizeEnum.Smaller:
+        //  return "menustorage3x3x3";
+        case StorageSizeEnum.Large:
+          return "menustorage6x7x14";
+        case StorageSizeEnum.Larger:
+          return "menustorage6x8x14";
+        case StorageSizeEnum.MegaLarge:
+          return "menustorage6x8x28";
+        case StorageSizeEnum.UltraLarge:
+          return "menustorage6x8x70";
+        case StorageSizeEnum.PagesOnly:
+          return "menustorage6x5x27";
+        default:
+          return "menustorage6x7x14";
+      }
+    }
+
+    private static void postBuildQuickStackButton()
+    {
+      Type t = null;
+      foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
+      {
+        if (a.FullName.StartsWith("QuickStack,"))
+        {
+          t = a.GetType("QuickStack.StackButtonScript");
+          break;
+        }
+      }
+      bool isEnabled = false;
+      foreach (var gadget in GadgetCore.API.Gadgets.ListAllEnabledGadgets())
+        if (gadget.Info?.ModName == "QuickStack")
+        {
+          isEnabled = true;
+          break;
+        }
+      if (t != null && isEnabled)
+      {
+        var storageMenu = GameObject.Find("Main Camera").transform.Find("menuStorage").gameObject;
+        var pagge0 = storageMenu.transform.Find("page0");
+        var btn = UnityEngine.Object.Instantiate(pagge0, pagge0.transform.parent).gameObject;
+        btn.name = "button_quick_stack";
+
+        Component.Destroy(btn.GetComponentInChildren<ButtonMenu>());
+        btn.AddComponent(t);
+
+        btn.GetComponentInChildren<BoxCollider>().size = new Vector3(2, 2, 2);
+
+        btn.transform.SetParent(storageMenu.transform);
+        btn.transform.localPosition = new Vector3(-0.5075f, 0.3595f, 0);
+        btn.transform.localScale = new Vector3(1f / 16f, 1f / 16f, 1);
+      }
+    }
+  }
+}

+ 31 - 0
StorageExpansion/Patches/Patch_GameScript_LoadGame.cs

@@ -0,0 +1,31 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("LoadGame")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_LoadGame
+  {
+    [HarmonyPrefix]
+    public static void Prefix(GameScript __instance, Item[] ___storage)
+		{
+			for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
+			{
+				___storage[i].id = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "id");
+				___storage[i].q = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "q");
+				___storage[i].exp = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "exp");
+				___storage[i].tier = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "tier");
+				___storage[i].corrupted = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "corrupted");
+				___storage[i].aspect[0] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a0");
+				___storage[i].aspect[1] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a1");
+				___storage[i].aspect[2] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "a2");
+				___storage[i].aspectLvl[0] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL0");
+				___storage[i].aspectLvl[1] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL1");
+				___storage[i].aspectLvl[2] = PreviewLabs.PlayerPrefs.GetInt("storage" + i + "aL2");
+			}
+		}
+  }
+}

+ 61 - 0
StorageExpansion/Patches/Patch_GameScript_MultiPachSlots.cs

@@ -0,0 +1,61 @@
+using GadgetCore.API;
+using GadgetCore.Util;
+using HarmonyLib;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Reflection.Emit;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+  internal class SlotsPerPageGetter
+  {
+    public static int SlotsPerPage { get => Core.settingAmountSlots; }
+  }
+
+  [HarmonyPatch()]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_MultiPachSlots
+  {
+    [HarmonyTargetMethods]
+    static IEnumerable<MethodBase> TargetMethods()
+    {
+      yield return AccessTools.Method(typeof(GameScript), "Update");
+      yield return AccessTools.Method(typeof(GameScript), "PlaceItemStorage");
+      yield return AccessTools.Method(typeof(GameScript), "PlaceOneItemStorage");
+      yield return AccessTools.Method(typeof(GameScript), "SelectItemStorage");
+      //yield return AccessTools.Method(typeof(GameScript), "ShiftClickStorage");
+      //yield return AccessTools.Method(typeof(GameScript), "ShiftClick");
+      yield return AccessTools.Method(typeof(GameScript), "SplitItemStorage");
+      yield return AccessTools.Method(typeof(GameScript), "CombineItemStorage");
+      yield return AccessTools.Method(typeof(GameScript), "SwapItemStorage");
+      //yield return AccessTools.Method(typeof(GameScript), "RefreshSlotStorage");
+      yield return AccessTools.Method(typeof(GameScript), "HoverItemStorage");
+    
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_RefreshSlotStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_RefreshSlotStorage"), "Postfix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_ShiftClick"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_HoverItemStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_CombineItemStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_PlaceOneItemStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_SplitItemStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_ShiftClickStorage"), "Prefix");
+      yield return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_RefreshStoragePage"), "Prefix");
+      //yield return AccessTools.Method("GadgetCore.Patches.Patch_GameScript_RefreshStoragePage:Prefix"); 
+    }
+
+
+    [HarmonyTranspiler]
+    public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator gen)
+    {
+      var p = TranspilerHelper.CreateProcessor(instructions, gen);
+      var ilRefs = p.FindAllRefsByInsn(new CodeInstruction(OpCodes.Ldc_I4_S, 30));
+      MethodInfo getValue = typeof(SlotsPerPageGetter).GetProperty("SlotsPerPage").GetGetMethod();
+      foreach (var ilRef in ilRefs)
+      {
+        p.InjectInsn(ilRef, new CodeInstruction(OpCodes.Call, getValue), false);
+      }
+      return p.Insns;
+    }
+  }
+}

+ 51 - 0
StorageExpansion/Patches/Patch_GameScript_RefreshSlotStorage.cs

@@ -0,0 +1,51 @@
+using GadgetCore.API;
+using HarmonyLib;
+using System.Collections;
+using System.Reflection;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("RefreshSlotStorage")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_RefreshSlotStorage
+	{
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, int i, Item[] ___storage, GameObject[] ___storageIconBack, GameObject[] ___storageIcon,
+			int ___curStoragePage, TextMesh[] ___txtQStorage)
+		{ 
+			int num = i + ___curStoragePage * Core.settingAmountSlots;
+			___storageIcon[i].GetComponent<Renderer>().material = (Material)Resources.Load("i/i" + ___storage[num].id);
+			AnimIcon animIcon = (AnimIcon)___storageIconBack[i].GetComponent("AnimIcon");
+			if (___storage[num].id < 300 || ___storage[num].id >= 2000)
+			{
+				___storageIconBack[i].SetActive(false);
+				animIcon.anim = 0;
+			}
+			else
+			{
+				___storageIconBack[i].GetComponent<Renderer>().material = (Material)Resources.Load("iBack" + ___storage[num].tier);
+				if (___storage[num].tier == 3)
+				{
+					animIcon.anim = 1;
+				}
+				else
+				{
+					animIcon.anim = 0;
+				}
+				___storageIconBack[i].SetActive(true);
+			}
+			if (___storage[num].q > 1)
+			{
+				___txtQStorage[i].text = string.Empty + ___storage[num].q;
+			}
+			else
+			{
+				___txtQStorage[i].text = string.Empty;
+			}
+      return false;
+    }
+  }
+}

+ 31 - 0
StorageExpansion/Patches/Patch_GameScript_SaveGame.cs

@@ -0,0 +1,31 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("SaveGame")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_SaveGame
+  {
+    [HarmonyPostfix]
+    public static void Postfix(GameScript __instance, int dood, Item[] ___storage)
+		{
+			for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
+			{
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "id", ___storage[i].id);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "q", ___storage[i].q);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "exp", ___storage[i].exp);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "tier", ___storage[i].tier);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "corrupted", ___storage[i].corrupted);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a0", ___storage[i].aspect[0]);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a1", ___storage[i].aspect[1]);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "a2", ___storage[i].aspect[2]);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL0", ___storage[i].aspectLvl[0]);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL1", ___storage[i].aspectLvl[1]);
+				PreviewLabs.PlayerPrefs.SetInt("storage" + i + "aL2", ___storage[i].aspectLvl[2]);
+			}
+		}
+  }
+}

+ 18 - 0
StorageExpansion/Patches/Patch_GameScript_SelectPage.cs

@@ -0,0 +1,18 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("SelectPage")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_SelectPage
+  {
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, int a, int ___storageLevel, ref int ___curStoragePage)
+    {
+      return true;
+    }
+  }
+}

+ 43 - 0
StorageExpansion/Patches/Patch_GameScript_Storage.cs

@@ -0,0 +1,43 @@
+using GadgetCore.API;
+using HarmonyLib;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("Storage")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_Storage
+  {
+    [HarmonyPostfix]
+    public static void Postfix(GameScript __instance, int ___storageLevel, bool ___enteringCombatMode)
+    {
+      if (!___enteringCombatMode)
+      {
+        for (int i = 0; i < __instance.storageButton.Length; i++)
+        {
+          if (i <= ___storageLevel)
+          {
+            __instance.storageButton[i].GetComponent<Renderer>().enabled = false;
+          }
+          else
+          {
+            __instance.storageButton[i].GetComponent<Renderer>().enabled = true;
+          }
+        }
+        int storageUpgradeCost = __instance.GetStorageUpgradeCost(___storageLevel);
+        if (___storageLevel == __instance.storageButton.Length - 1)
+        {
+          __instance.txtStorageCost[0].text = "Max Lvl";
+          __instance.txtStorageCost[1].text = "Max Lvl";
+        }
+        else
+        {
+          __instance.txtStorageCost[0].text = string.Empty + storageUpgradeCost;
+          __instance.txtStorageCost[1].text = string.Empty + storageUpgradeCost;
+        }
+      }
+    }
+  }
+}

+ 41 - 0
StorageExpansion/Patches/Patch_GameScript_Update.cs

@@ -0,0 +1,41 @@
+using GadgetCore.API;
+using HarmonyLib;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("Update")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_Update
+  {
+    [HarmonyPrefix]
+    public static void Prefix(GameScript __instance, ref int ___storageLevel)
+    {
+      if (MenuScript.player)
+      {
+        if (!GameScript.pausing)
+        {
+          if (Input.GetMouseButtonDown(0) && GameScript.inventoryOpen)
+          {
+            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
+            RaycastHit hit;
+            if (Physics.Raycast(ray, out hit, 7f))
+            {
+              if (hit.transform.gameObject.layer != 16 && hit.transform.gameObject.layer != 17)
+              {
+                string name = hit.transform.gameObject.name;
+                if (name.StartsWith("page"))
+                {
+                  var slot = int.Parse(hit.transform.gameObject.name.Substring("page".Length));
+                  __instance.SelectPage(slot);
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}

+ 57 - 0
StorageExpansion/Patches/Patch_GameScript_UpgradeStorage.cs

@@ -0,0 +1,57 @@
+using GadgetCore.API;
+using HarmonyLib;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("UpgradeStorage")]
+  [HarmonyGadget("StorageExpansion")]
+  public static class Patch_GameScript_UpgradeStorage
+  {
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, ref int ___storageLevel)
+    {
+			if (___storageLevel < __instance.storageButton.Length)
+			{
+				int storageUpgradeCost = __instance.GetStorageUpgradeCost(___storageLevel);
+				if (__instance.GetCredits() >= storageUpgradeCost)
+				{
+					__instance.RemoveCredits(storageUpgradeCost);
+          ___storageLevel++;
+					PreviewLabs.PlayerPrefs.SetInt("storageLevel", ___storageLevel);
+					__instance.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/chesthit2"), Menuu.soundLevel / 10f);
+					Camera.main.GetComponent<Animation>().Play("craft");
+          for (int i = 0; i < __instance.storageButton.Length; i++)
+          {
+            if (i <= ___storageLevel)
+            {
+              __instance.storageButton[i].GetComponent<Renderer>().enabled = false;
+            }
+            else
+            {
+              __instance.storageButton[i].GetComponent<Renderer>().enabled = true;
+            }
+          }
+          int newStorageUpgradeCost = __instance.GetStorageUpgradeCost(___storageLevel);
+          if (___storageLevel == __instance.storageButton.Length - 1)
+          {
+            __instance.txtStorageCost[0].text = "Max Lvl";
+            __instance.txtStorageCost[1].text = "Max Lvl";
+          }
+          else
+          {
+            __instance.txtStorageCost[0].text = string.Empty + newStorageUpgradeCost;
+            __instance.txtStorageCost[1].text = string.Empty + newStorageUpgradeCost;
+          }
+        }
+				else
+				{
+					__instance.Error(3);
+				}
+			}
+			return false;
+    }
+  }
+}

+ 41 - 0
StorageExpansion/Patches/RePatch_GameScript_RefreshStoragePage.cs

@@ -0,0 +1,41 @@
+using GadgetCore.API;
+using HarmonyLib;
+using System.Collections;
+using System.Reflection;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch]
+  [HarmonyGadget("StorageExpansion")]
+  public static class RePatch_GameScript_RefreshStoragePage
+  {
+    [HarmonyTargetMethod]
+    static MethodBase TargetMethod()
+    {
+      return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.Patches.Patch_GameScript_RefreshStoragePage"), "RefreshStoragePage");
+    }
+
+    public static readonly FieldInfo curStoragePage = typeof(GameScript).GetField("curStoragePage", BindingFlags.NonPublic | BindingFlags.Instance);
+
+    [HarmonyPrefix]
+    public static bool Prefix(GameScript __instance, int p, ref IEnumerator __result)
+    {
+      __result = RefreshStoragePage(__instance, p);
+      return false;
+    }
+
+    private static IEnumerator RefreshStoragePage(GameScript instance, int p)
+    {
+      var __instance = InstanceTracker.GameScript;
+      curStoragePage.SetValue(__instance, p);
+      __instance.storageSelect.transform.position = new Vector3(__instance.storageButton[p].transform.position.x, __instance.storageButton[p].transform.position.y, __instance.storageSelect.transform.position.z);
+      for (int i = 0; i < Core.settingAmountSlots; i++)
+      {
+        __instance.RefreshSlotStorage(i);
+      }
+      yield break;
+    }
+  }
+}

+ 57 - 0
StorageExpansion/Patches/RePatch_GameScript_Update.cs

@@ -0,0 +1,57 @@
+using GadgetCore.API;
+using GadgetCore.Util;
+using HarmonyLib;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Reflection.Emit;
+using UnityEngine;
+
+namespace StorageExpansion.Patches
+{
+
+  [HarmonyPatch()]
+  [HarmonyGadget("StorageExpansion")]
+  public static class RePatch_GameScript_Update
+  {
+
+    [HarmonyPrepare]
+    static bool Prepare()
+    {
+      foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
+      {
+        if (a.FullName.StartsWith("QuickStack,"))
+        {
+          return true;
+        }
+      }
+      return false;
+    }
+
+    [HarmonyTargetMethods]
+    static IEnumerable<MethodBase> TargetMethods()
+    {
+      foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
+      {
+        if (a.FullName.StartsWith("QuickStack,"))
+        {
+          yield return AccessTools.Method(a.GetType("QuickStack.Patches.Patch_GameScript_Update"), "Prefix");
+        }
+      }
+      yield break;
+    }
+
+    [HarmonyTranspiler]
+    public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator gen)
+    {
+      var p = TranspilerHelper.CreateProcessor(instructions, gen);
+      var ilRefs = p.FindAllRefsByInsn(new CodeInstruction(OpCodes.Ldc_I4_S, 30));
+      MethodInfo getValue = typeof(SlotsPerPageGetter).GetProperty("SlotsPerPage").GetGetMethod();
+      foreach (var ilRef in ilRefs)
+      {
+        p.InjectInsn(ilRef, new CodeInstruction(OpCodes.Call, getValue), false);
+      }
+      return p.Insns;
+    }
+  }
+}

+ 10 - 0
StorageExpansion/Properties/AssemblyInfo.cs

@@ -0,0 +1,10 @@
+using System.Reflection;
+using static StorageExpansion.StorageExpansion;
+
+[assembly: AssemblyProduct("StorageExpansion")] //Set this to the full name of the mod including spaces.
+[assembly: AssemblyTitle("StorageExpansion")] //This is only used when mousing over a dll file in Windows explorer.
+[assembly: AssemblyDescription("Increases the available storage space.")] //This is a short description for your mod's assembly.
+[assembly: AssemblyCompany("")] //Set this to your name/nickname and/or website
+[assembly: AssemblyCopyright("© 2021 Zariteis. All rights reserved.")] //Set this to your copyright name.
+[assembly: AssemblyVersion(MOD_VERSION)]
+[assembly: AssemblyFileVersion(MOD_VERSION)]

+ 8 - 0
StorageExpansion/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "StorageExpansion": {
+      "commandName": "Executable",
+      "executablePath": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Roguelands\\Roguelands.exe"
+    }
+  }
+}

+ 15 - 0
StorageExpansion/README.txt

@@ -0,0 +1,15 @@
+In addition to changing all references to "Template" this and that to a more appropriate name,
+you need to add a file called "GamePaths.xml" to the folder ABOVE where you put this template, with the following content:
+
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+  <PropertyGroup>
+    <!-- Set this full path to your game folder. Must contain a slash at the end. -->
+    <GamePath>C:\Program Files (x86)\Steam\steamapps\common\Roguelands\</GamePath>
+
+    <!-- Set this partial path to the game's Managed folder. Must contain a slash at the end. -->
+    <ManagedFolder>Roguelands_Data\Managed\</ManagedFolder>
+  </PropertyGroup>
+</Project>
+
+Note that `GamePath` may need to be changed, depending on the nature of your installation.

+ 49 - 0
StorageExpansion/StorageExpansion.cs

@@ -0,0 +1,49 @@
+using UnityEngine;
+using GadgetCore.API;
+using GadgetCore.API.ConfigMenu;
+using UnityEngine.SceneManagement;
+
+namespace StorageExpansion
+{
+  [Gadget("StorageExpansion", LoadBefore: new string[] { "QuickStack" })]
+  public class StorageExpansion : Gadget<StorageExpansion>
+  {
+    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
+    public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
+
+    protected override void LoadConfig()
+    {
+      Config.Load();
+      string fileVersion = Config.ReadString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
+      if (fileVersion != CONFIG_VERSION)
+      {
+        Config.Reset();
+        Config.WriteString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
+      }
+
+      Core.settingSizeEnum = Config.ReadEnum("StorageSize", StorageSizeEnum.Large, requiresRestart: true, comments: new string[] { "How large should your storage be?", "!! Restart required !!" });
+
+      Config.Save();
+    }
+
+    public override string GetModDescription()
+    {
+      return "Increases the available storage space.";
+    }
+
+    protected override void Initialize()
+    {
+      Logger.Log("Storage Expansion v" + Info.Mod.Version);
+      Core.logger = Logger;
+
+      SceneManager.sceneLoaded += OnSceneLoaded;
+    }
+
+    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+    {
+      if (scene.buildIndex == 1)
+      {
+      }
+    }
+  }
+}

+ 164 - 0
StorageExpansion/StorageExpansion.csproj

@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+  <ImportGroup>
+    <Import Project="../GamePaths.xml" />
+  </ImportGroup>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProjectGuid>{91AB81DE-EAEE-47D1-93DD-541179208219}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>StorageExpansion</RootNamespace>
+    <AssemblyName>StorageExpansion</AssemblyName>
+    <TargetFrameworks>net35</TargetFrameworks>
+    <FileAlignment>512</FileAlignment>
+    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+    <Configurations>Release</Configurations>
+    <Authors>Zariteis</Authors>
+    <ApplicationIcon />
+    <StartupObject />
+    <Platforms>x86</Platforms>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net35|x86'">
+    <NoWarn>1701;1702</NoWarn>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="0Harmony">
+      <HintPath>$(GamePath)$(ManagedFolder)0Harmony.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="Assembly-CSharp">
+      <HintPath>$(GamePath)$(ManagedFolder)Assembly-CSharp.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="GadgetCore">
+      <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="UnityEngine">
+      <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="ModInfo.txt">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <UsingTask TaskName="GetFileVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+    <ParameterGroup>
+      <AssemblyPath ParameterType="System.String" Required="true" />
+      <Version ParameterType="System.String" Output="true" />
+      <TrimmedVersion ParameterType="System.String" Output="true" />
+    </ParameterGroup>
+    <Task>
+      <Using Namespace="System.Diagnostics" />
+      <Using Namespace="System.Text" />
+      <Using Namespace="System.Linq" />
+      <Code Type="Fragment" Language="cs">
+        <![CDATA[
+      this.Version = FileVersionInfo.GetVersionInfo(this.AssemblyPath).FileVersion;  
+      this.TrimmedVersion = this.Version.Split('.').TakeWhile(x => !x.Equals("0")).Aggregate(new StringBuilder(), (a, b) => { if (a.Length > 0) a.Append("."); a.Append(b); return a; }).ToString();
+      if (this.TrimmedVersion.IndexOf('.') == -1) this.TrimmedVersion += ".0";
+    ]]>
+      </Code>
+    </Task>
+  </UsingTask>
+  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+    <GetFileVersion AssemblyPath="$(TargetPath)">
+      <Output TaskParameter="Version" PropertyName="ModFullVersion" />
+      <Output TaskParameter="TrimmedVersion" PropertyName="AssemblyFileVersion" />
+    </GetFileVersion>
+    <ItemGroup>
+      <OldZip Include="$(TargetDir)$(AssemblyName)_v*.zip" />
+      <OldZip Include="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v*.zip" />
+    </ItemGroup>
+    <Delete Files="@(OldZip)" />
+    <MakeDir Directories="$(TargetDir)..\BuildCache\" />
+    <ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Copy SourceFiles="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <RemoveDir Directories="$(TargetDir)..\BuildCache\" />
+    <MakeDir Directories="$(GamePath)GadgetCore\Mods\" />
+    <Copy SourceFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Message Importance="High" Text="Mod Exported to $(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+  </Target>
+  <ItemGroup>
+    <None Update="Assets\menustorage">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\menustorage6x5x27">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\menustorage6x7x14">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\menustorage6x8x14">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\menustorage6x8x28">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\menustorage6x8x70">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Manifest.ini">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System">
+      <Private>false</Private>
+      <SpecificVersion>true</SpecificVersion>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Data">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Drawing">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.IO.Compression.FileSystem">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Numerics">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Runtime.Serialization">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml.Linq">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Assets\" />
+  </ItemGroup>
+</Project>

+ 8 - 0
StorageExpansion/StorageSizeEnum.cs

@@ -0,0 +1,8 @@
+namespace StorageExpansion
+{
+  public enum StorageSizeEnum
+  {
+    //UltraSmall, Smaller, 
+    Large, Larger, MegaLarge, UltraLarge, PagesOnly
+  }
+}