diff --git a/CustomKnight/Canvas/SkinSwapperPanel.cs b/CustomKnight/Canvas/SkinSwapperPanel.cs index 7be62fa..b58aa00 100644 --- a/CustomKnight/Canvas/SkinSwapperPanel.cs +++ b/CustomKnight/Canvas/SkinSwapperPanel.cs @@ -18,28 +18,32 @@ public class SkinSwapperPanel { public static CanvasPanel Panel; - private static float y; - public static void BuildMenu(GameObject canvas) { Log("Building Skin Swapper Panel"); - y = 30.0f; - int imageWidth = 300; - int panelHeight = 1080; - int imageHeight = 60; - Texture2D texture2D = new Texture2D(imageWidth, panelHeight); - for (int i = 0; i < imageWidth; i++) + float currentElementPosY = CustomKnight.Instance.Settings.PanelY; + int PanelWidth = CustomKnight.Instance.Settings.PanelWidth; + int PanelHeight = CustomKnight.Instance.Settings.PanelHeight; + + int NameLength = CustomKnight.Instance.Settings.NameLength; + int OptionSize = CustomKnight.Instance.Settings.OptionSize; + int fontSize = (int)(OptionSize * 0.6f); + int headingSize = (int)(OptionSize * 1.1f); + int headingFontSize = (int)(headingSize * 0.85f); + + Texture2D texture2D = new Texture2D(PanelWidth, PanelHeight); + for (int i = 0; i < PanelWidth; i++) { - for (int j = 0; j < panelHeight; j++) + for (int j = 0; j < PanelHeight; j++) { texture2D.SetPixel(i, j, Color.clear); } } texture2D.Apply(); - Texture2D texture2D2 = new Texture2D(imageWidth, imageHeight); - for (int k = 0; k < imageWidth; k++) + Texture2D texture2D2 = new Texture2D(PanelWidth, OptionSize); + for (int k = 0; k < PanelWidth; k++) { - for (int l = 0; l < imageHeight; l++) + for (int l = 0; l < OptionSize; l++) { texture2D2.SetPixel(k, l, Color.clear); } @@ -48,50 +52,49 @@ public static void BuildMenu(GameObject canvas) Panel = new CanvasPanel( canvas, texture2D, - new Vector2(0, y), + new Vector2(0, currentElementPosY), Vector2.zero, - new Rect(0, 0, imageWidth, 60) + new Rect(0, 0, PanelWidth, 60) ); - float textHeight = 90; Panel.AddText( "Change Skin Text", "Change Skin", - new Vector2(0, y), - new Vector2(imageWidth, textHeight), + new Vector2(0, currentElementPosY), + new Vector2(PanelWidth, headingSize), GUIController.Instance.trajanNormal, - 24, + headingFontSize, FontStyle.Bold, TextAnchor.MiddleCenter ); - y += textHeight; + currentElementPosY += headingSize; GC.Collect(); foreach (string path in Directory.GetDirectories(CustomKnight.DATA_DIR)) { string directoryName = new DirectoryInfo(path).Name; - + string buttonText = directoryName.Length <= NameLength ? directoryName : directoryName.Substring(0,NameLength - 3) + "..."; Panel.AddButton( directoryName, texture2D2, - new Vector2(0, y), + new Vector2(0, currentElementPosY), Vector2.zero, ChangeSkin, - new Rect(0, y, imageWidth, imageHeight), + new Rect(0, currentElementPosY, PanelWidth, OptionSize), GUIController.Instance.trajanNormal, - directoryName, - 24 + buttonText, + fontSize ); - y += imageHeight; + currentElementPosY += OptionSize; GC.Collect(); } Panel.SetActive(false, true); - Vector2 newPanelSize = new Vector2(imageWidth, y); + Vector2 newPanelSize = new Vector2(PanelWidth, currentElementPosY); Panel.ResizeBG(newPanelSize); On.HeroController.Pause += OnPause; @@ -102,6 +105,7 @@ public static void BuildMenu(GameObject canvas) private static void ChangeSkin(string buttonName) { CustomKnight.SKIN_FOLDER = buttonName; + CustomKnight.Instance.Settings.DefaultSkin = buttonName; GameManager.instance.StartCoroutine(ChangeSkinRoutine()); } diff --git a/CustomKnight/CustomKnight.cs b/CustomKnight/CustomKnight.cs index b6565a4..03dd2ae 100644 --- a/CustomKnight/CustomKnight.cs +++ b/CustomKnight/CustomKnight.cs @@ -17,8 +17,15 @@ namespace CustomKnight { - public class CustomKnight : Mod, ITogglableMod + public class CustomKnight : Mod, ITogglableMod { + public GlobalModSettings Settings = new GlobalModSettings(); + public override ModSettings GlobalSettings + { + get => Settings; + set => Settings = (GlobalModSettings) value; + } + public class CustomKnightTexture { public bool missing; @@ -132,9 +139,10 @@ public CustomKnightTexture(string fileName, bool missing, Texture2D defaultTex, public static CustomKnight Instance { get; private set; } + public override List<(string, string)> GetPreloadNames() { - if (GlobalSettings.Preloads) + if (Settings.Preloads) { return new List<(string, string)> { @@ -191,7 +199,7 @@ public override void Initialize(Dictionary "1.2.4"; + public override string GetVersion() => "1.2.4b"; private void ResetTextures() { diff --git a/CustomKnight/CustomKnight.csproj b/CustomKnight/CustomKnight.csproj index 1e29d26..052d4d6 100644 --- a/CustomKnight/CustomKnight.csproj +++ b/CustomKnight/CustomKnight.csproj @@ -101,9 +101,5 @@ - - - - \ No newline at end of file diff --git a/CustomKnight/Images/Panel_BG.png b/CustomKnight/Images/Panel_BG.png deleted file mode 100644 index a868ee2..0000000 Binary files a/CustomKnight/Images/Panel_BG.png and /dev/null differ diff --git a/CustomKnight/Settings.cs b/CustomKnight/Settings.cs index 195bb43..01d93bb 100644 --- a/CustomKnight/Settings.cs +++ b/CustomKnight/Settings.cs @@ -4,9 +4,16 @@ namespace CustomKnight { public class SaveSettings : ModSettings { } - public class GlobalSettings : ModSettings + public class GlobalModSettings : ModSettings { public bool Preloads { get => GetBool(true); set => SetBool(value); } public string DefaultSkin { get => GetString("Default"); set => SetString(value); } + public float PanelY { get => GetFloat(80.0f); set => SetFloat(value);} + public int PanelWidth { get => GetInt(250); set => SetInt(value); } + public int PanelHeight { get => GetInt(1080); set => SetInt(value); } + public int NameLength { get => GetInt(10); set => SetInt(value); } + public int OptionSize { get => GetInt(35); set => SetInt(value); } + } + } \ No newline at end of file