Browse Source

[QuickStack] [2.0.2.0] use of build in options

Zariteis 4 years ago
parent
commit
43cc44d16b

BIN
QuickStack/Assets/menuTile.png


+ 0 - 27
QuickStack/CoroutineManager.cs

@@ -1,27 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.Util;
-using HarmonyLib;
-using System;
-using System.Collections;
-using System.Threading;
-using System.Windows.Threading;
-using UnityEngine;
-
-namespace QuickStack
-{
-  public class CoroutineManager : MonoBehaviour
-  {
-    Action action;
-
-    public void SetAction(Action action)
-    {
-      this.action = action;
-    }
-
-    void OnEnable()
-    {
-      if (action != null)
-        action.Invoke();
-    }
-  }
-}

+ 0 - 76
QuickStack/CustomMenu.cs

@@ -1,76 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.API.ConfigMenu;
-using QuickStack.ConfigEnums;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace QuickStack
-{
-  public class CustomMenu : BasicGadgetConfigMenu
-  {
-    public CustomMenu(Gadget g)
-    {
-      {
-        var param = new string[] { "Only Main Inventory", "Only Toolbar", "Both" };
-        AddComponent(new GadgetConfigLabelComponent(this, "Take From Title", "Were should items be taken from?"));
-        AddComponent(new GadgetConfigDropdownComponent(this, "Take From", param[(int)Core.settingStackSource], param, new Action<string>((s) =>
-        {
-          for (int i = 0; i < param.Length; i++)
-          {
-            if (param[i] == s)
-              Core.settingStackSource = (StackSourceInventoryEnum)i;
-          }
-          g.Config.WriteEnum("TakeFromAll", Core.settingStackSource);
-          g.Config.Save();
-        })));
-      }
-      AddComponent(new GadgetConfigSeparatorComponent(this, "Space"));
-      {
-        var param = new string[] { "Only Main Inventory", "Only Toolbar", "Both", "None" };
-        AddComponent(new GadgetConfigLabelComponent(this, "Take Potions", "Were should potions be taken from?"));
-        AddComponent(new GadgetConfigDropdownComponent(this, "Take From", param[(int)Core.settingStackPotionsSource], param, new Action<string>((s) =>
-        {
-          for (int i = 0; i < param.Length; i++)
-          {
-            if (param[i] == s)
-              Core.settingStackPotionsSource = (StackSourceInventoryPotionsEnum)i;
-          }
-          g.Config.WriteEnum("TakeFromPotions", Core.settingStackPotionsSource);
-          g.Config.Save();
-        })));
-      }
-      AddComponent(new GadgetConfigSeparatorComponent(this, "Space"));
-      {
-        var param = new string[] { "Stacking Only", "Fill Page Containing", "Fill Page All" };
-        AddComponent(new GadgetConfigLabelComponent(this, "Insert Title", "How should items be inserted?"));
-        AddComponent(new GadgetConfigDropdownComponent(this, "Insert", param[(int)Core.settingStackMode], param, new Action<string>((s) =>
-        {
-          for (int i = 0; i < param.Length; i++)
-          {
-            if (param[i] == s)
-              Core.settingStackMode = (StackModeEnum)i;
-          }
-          g.Config.WriteEnum("StackMode", Core.settingStackMode);
-          g.Config.Save();
-        })));
-      }
-      AddComponent(new GadgetConfigSeparatorComponent(this, "Space"));
-      {
-        var param = new string[] { "All Pages", "Open Page"};
-        AddComponent(new GadgetConfigLabelComponent(this, "Insert Title", "Were should items be inserted?"));
-        AddComponent(new GadgetConfigDropdownComponent(this, "Insert", param[(int)Core.settingStackRange], param, new Action<string>((s) =>
-        {
-          for (int i = 0; i < param.Length; i++)
-          {
-            if (param[i] == s)
-              Core.settingStackRange = (StackRangeEnum)i;
-          }
-          g.Config.WriteEnum("StackRange", Core.settingStackRange);
-          g.Config.Save();
-        })));
-      }
-    }
-  }
-}

+ 0 - 138
QuickStack/GadgetConfigDropdownComponent.cs

@@ -1,138 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.API.ConfigMenu;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using UnityEngine;
-using UnityEngine.UI;
-
-namespace QuickStack
-{
-  public class GadgetConfigDropdownComponent : GadgetConfigComponent
-  {
-    public string Value { get; protected set; }
-    public string[] Values { get; protected set; }
-    public readonly string DefaultValue;
-
-    private readonly Action<string> ValueSetter;
-    private RectTransform[] Entries;
-
-    public GadgetConfigDropdownComponent(BasicGadgetConfigMenu configMenu, string name, string value, string[] values, Action<string> valueSetter, float height = 0.1f) : base(configMenu, name, height)
-    {
-      Value = value;
-      Values = values;
-      ValueSetter = valueSetter;
-    }
-
-    private T GetFromStatic<T>(string classString, string paramString)
-    {
-      var type = Type.GetType("GadgetCore" + "." + classString + ", GadgetCore");
-      var property = type.GetProperty(paramString, BindingFlags.Public | BindingFlags.Static);
-      MethodInfo strGetter = property.GetGetMethod();
-      return (T)strGetter.Invoke(null, null);
-    }
-
-    public override void Build(RectTransform parent)
-    {
-      var ModConfigMenuText = GetFromStatic<GameObject>("SceneInjector", "ModConfigMenuText");
-      var BoxSprite = GetFromStatic<Sprite>("SceneInjector", "BoxSprite");
-      var textureMenuTile = GadgetCoreAPI.LoadTexture2D("menuTile.png");
-      var MenuTile = Sprite.Create(textureMenuTile, BoxSprite.rect, BoxSprite.pivot, BoxSprite.pixelsPerUnit, default, default, BoxSprite.border);
-      if (!string.IsNullOrEmpty(Name))
-      {
-        StringBuilder nameString = new StringBuilder();
-        int spacesAdded = 0;
-        foreach (char c in Name)
-        {
-          if (nameString.Length > 0 && char.IsUpper(c) && !char.IsUpper(Name[nameString.Length - spacesAdded - 1]) && (Name.Length == 1 || !char.IsUpper(Name[nameString.Length - spacesAdded - 2]) || (Name.Length > 2 && !char.IsUpper(Name[nameString.Length - spacesAdded - 3]))))
-          {
-            spacesAdded++;
-            nameString.Append(' ');
-          }
-          nameString.Append(nameString.Length > 0 ? c : char.ToUpper(c));
-        }
-        Text label = new GameObject("Label", typeof(RectTransform), typeof(CanvasRenderer), typeof(Text)).GetComponent<Text>();
-        label.rectTransform.SetParent(parent);
-        label.rectTransform.anchorMin = new Vector2(0f, 0f);
-        label.rectTransform.anchorMax = new Vector2(0.25f, 1f);
-        label.rectTransform.offsetMin = new Vector2(0, 0);
-        label.rectTransform.offsetMax = new Vector2(-10, 0);
-        label.text = nameString + ":";
-        label.font = ModConfigMenuText.GetComponent<TextMesh>().font;
-        label.fontSize = 12;
-        label.horizontalOverflow = HorizontalWrapMode.Wrap;
-        label.alignment = TextAnchor.MiddleLeft;
-      }
-      RectTransform button = new GameObject("Button", typeof(RectTransform), typeof(Button), typeof(CanvasRenderer), typeof(Image)).GetComponent<RectTransform>();
-      button.SetParent(parent);
-      button.anchorMin = new Vector2(0.25f, 0f);
-      button.anchorMax = new Vector2(0.75f, 1f);
-      button.offsetMin = new Vector2(10, 0);
-      button.offsetMax = new Vector2(-10, 0);
-      button.GetComponent<Image>().sprite = BoxSprite;
-      button.GetComponent<Image>().type = Image.Type.Sliced;
-      button.GetComponent<Image>().fillCenter = true;
-      button.GetComponent<Button>().onClick.AddListener(() =>
-      {
-        bool set = Entries[0] != null && !Entries[0].gameObject.active;
-        for (int i = 0; i < Entries.Length; i++)
-        {
-          Entries[i].gameObject.SetActive(set);
-        }
-        parent.SetAsLastSibling();
-      });
-      Text buttonLabel = new GameObject("Label", typeof(RectTransform), typeof(CanvasRenderer), typeof(Text)).GetComponent<Text>();
-      buttonLabel.rectTransform.SetParent(button);
-      buttonLabel.rectTransform.anchorMin = new Vector2(0f, 0f);
-      buttonLabel.rectTransform.anchorMax = new Vector2(1f, 1f);
-      buttonLabel.rectTransform.offsetMin = new Vector2(2.5f, 2.5f);
-      buttonLabel.rectTransform.offsetMax = new Vector2(-2.5f, -2.5f);
-      buttonLabel.font = ModConfigMenuText.GetComponent<TextMesh>().font;
-      buttonLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
-      buttonLabel.verticalOverflow = VerticalWrapMode.Truncate;
-      buttonLabel.alignment = TextAnchor.MiddleCenter;
-      buttonLabel.text = Value;
-      Entries = new RectTransform[Values.Length];
-      for (int i = 0; i < Values.Length; i++)
-      {
-        int ic = i;
-        RectTransform dropButton = new GameObject("Button", typeof(RectTransform), typeof(Button), typeof(CanvasRenderer), typeof(Image)).GetComponent<RectTransform>();
-        dropButton.SetParent(button);
-        dropButton.anchorMin = new Vector2(0.25f, 0f);
-        dropButton.anchorMax = new Vector2(0.75f, 1f);
-        dropButton.offsetMin = new Vector2(-42, -24 * i - 24);
-        dropButton.offsetMax = new Vector2(42, -24 * i - 24);
-        dropButton.GetComponent<Image>().sprite = MenuTile;
-        dropButton.GetComponent<Image>().type = Image.Type.Sliced;
-        dropButton.GetComponent<Image>().fillCenter = true;
-        dropButton.GetComponent<Button>().onClick.AddListener(() =>
-        {
-          buttonLabel.text = Values[ic];
-          Value = Values[ic];
-          ValueSetter.Invoke(Values[ic]);
-          for (int j = 0; j < Entries.Length; j++)
-          {
-            Entries[j].gameObject.SetActive(false);
-            Entries[j].gameObject.GetComponent<RectTransform>().SetAsLastSibling();
-          }
-        });
-
-        Text dropButtonLabel = new GameObject("Label", typeof(RectTransform), typeof(CanvasRenderer), typeof(Text)).GetComponent<Text>();
-        dropButtonLabel.rectTransform.SetParent(dropButton);
-        dropButtonLabel.rectTransform.anchorMin = new Vector2(0f, 0f);
-        dropButtonLabel.rectTransform.anchorMax = new Vector2(1f, 1f);
-        dropButtonLabel.rectTransform.offsetMin = new Vector2(2.5f, 2.5f);
-        dropButtonLabel.rectTransform.offsetMax = new Vector2(-2.5f, -2.5f);
-        dropButtonLabel.font = ModConfigMenuText.GetComponent<TextMesh>().font;
-        dropButtonLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
-        dropButtonLabel.verticalOverflow = VerticalWrapMode.Truncate;
-        dropButtonLabel.alignment = TextAnchor.MiddleCenter;
-        dropButtonLabel.text = Values[i];
-        Entries[i] = dropButton;
-        dropButton.gameObject.SetActive(false);
-      }
-    }
-  }
-}

+ 0 - 9
QuickStack/ItemUtil.cs

@@ -1,9 +0,0 @@
-using UnityEngine;
-using GadgetCore.API;
-
-namespace QuickStack
-{
-  public static class ItemUtil
-  {
-  }
-}

+ 0 - 55
QuickStack/NonSolidWallScript.cs

@@ -1,55 +0,0 @@
-
-using UnityEngine;
-
-namespace QuickStack
-{
-  public class NonSolidWallScript : MonoBehaviour
-	{
-		public void InitVars(Texture2D textureSolid, Texture2D textureNonSolid, Renderer renderer)
-    {
-			this.textureNonSolid = textureNonSolid;
-			this.textureSolid = textureSolid;
-			this.renderer = renderer;
-
-			renderer.material = new Material(renderer.material)
-			{
-				mainTexture = textureSolid
-			};
-		}
-
-		private int inside = 0;
-		private Texture2D textureSolid;
-		private Texture2D textureNonSolid;
-		private Renderer renderer;
-
-		private void OnTriggerEnter(Collider c)
-		{
-			if (c.gameObject.layer == 8 && c.GetComponent<NetworkView>().isMine)
-			{
-				if(inside == 0)
-        {
-					renderer.material = new Material(renderer.material)
-					{
-						mainTexture = textureNonSolid
-					};
-				}
-				inside++;
-			}
-		}
-
-		private void OnTriggerExit(Collider c)
-		{
-			if (c.gameObject.layer == 8 && c.GetComponent<NetworkView>().isMine)
-			{
-				inside--;
-				if (inside == 0)
-				{
-					renderer.material = new Material(renderer.material)
-					{
-						mainTexture = textureSolid
-					};
-				}
-			}
-		}
-	}
-}

+ 0 - 3
QuickStack/QuickStack.csproj

@@ -162,9 +162,6 @@
     <None Update="Assets\iYellowLamp.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Assets\menuTile.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
     <None Update="Assets\midCoverChunk0.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>