From 499c84e8431fcb468c98ab8c98d4a0ead44e6d1f Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sun, 12 Jul 2020 22:38:37 -0700 Subject: [PATCH] Fix some gui issues --- .../Plugins/ConformalDecals.dll | 2 +- .../Resources/ui.conformaldecals | 4 +-- Source/ConformalDecals/ConformalDecals.csproj | 1 + Source/ConformalDecals/ModuleConformalText.cs | 4 +-- .../ConformalDecals/UI/TextEntryController.cs | 9 ++++++ Source/ConformalDecals/UI/UILoader.cs | 28 +++++++++++++++---- Source/ConformalDecals/UI/UITag.cs | 1 + 7 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 Source/ConformalDecals/UI/TextEntryController.cs diff --git a/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 08e5ba3..6d613d4 100644 --- a/GameData/ConformalDecals/Plugins/ConformalDecals.dll +++ b/GameData/ConformalDecals/Plugins/ConformalDecals.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7434e4d912f845754e3ac21aaefb662ff990f99358b6d7180e3adc9e22803ca6 +oid sha256:dc76280eebfaa6bfe954ea3e6aba95a91650fe5f60ba66a8ee5a9b6863e327fb size 55808 diff --git a/GameData/ConformalDecals/Resources/ui.conformaldecals b/GameData/ConformalDecals/Resources/ui.conformaldecals index 484ad32..fe86c07 100644 --- a/GameData/ConformalDecals/Resources/ui.conformaldecals +++ b/GameData/ConformalDecals/Resources/ui.conformaldecals @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5acf1dc16ad4f6adca7d9e303b46b896c6681dc665857c496c6ab1c2161cbbb8 -size 266582 +oid sha256:c3ec32bf0dd2571ed80f8e12e05b06591f35364e4d926b0dec6f543c7323d4df +size 267232 diff --git a/Source/ConformalDecals/ConformalDecals.csproj b/Source/ConformalDecals/ConformalDecals.csproj index 067412d..c66ad9a 100644 --- a/Source/ConformalDecals/ConformalDecals.csproj +++ b/Source/ConformalDecals/ConformalDecals.csproj @@ -87,6 +87,7 @@ + diff --git a/Source/ConformalDecals/ModuleConformalText.cs b/Source/ConformalDecals/ModuleConformalText.cs index e805e9a..6957e51 100644 --- a/Source/ConformalDecals/ModuleConformalText.cs +++ b/Source/ConformalDecals/ModuleConformalText.cs @@ -26,8 +26,8 @@ namespace ConformalDecals { { if (_textEntryGui == null) { _textEntryGui = Instantiate(UILoader.textEntryPrefab, MainCanvasUtil.MainCanvas.transform, true); - _textEntryGui.AddComponent(); - MenuNavigation.SpawnMenuNavigation(_textEntryGui, Navigation.Mode.Automatic, true); + //_textEntryGui.AddComponent(); + //MenuNavigation.SpawnMenuNavigation(_textEntryGui, Navigation.Mode.Automatic, true); } } } diff --git a/Source/ConformalDecals/UI/TextEntryController.cs b/Source/ConformalDecals/UI/TextEntryController.cs new file mode 100644 index 0000000..4d4c04b --- /dev/null +++ b/Source/ConformalDecals/UI/TextEntryController.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace ConformalDecals.UI { + public class TextEntryController : MonoBehaviour { + public void OnClose() { + Debug.Log("Close!"); + } + } +} \ No newline at end of file diff --git a/Source/ConformalDecals/UI/UILoader.cs b/Source/ConformalDecals/UI/UILoader.cs index e0743a3..81ef217 100644 --- a/Source/ConformalDecals/UI/UILoader.cs +++ b/Source/ConformalDecals/UI/UILoader.cs @@ -18,6 +18,8 @@ namespace ConformalDecals.UI { ProcessWindow(textEntryPrefab); Debug.Log("[ConformalDecals] UI prefabs loaded and modified"); + + var window = Instantiate(UILoader.textEntryPrefab, MainCanvasUtil.MainCanvas.transform, true); } private static void ProcessWindow(GameObject window) { @@ -37,7 +39,7 @@ namespace ConformalDecals.UI { var tags = window.GetComponentsInChildren(true); foreach (var tag in tags) { - Debug.Log($"Handling object ${tag.gameObject.name}"); + Debug.Log($"Handling object {tag.gameObject.name}"); switch (tag.type) { case UITag.UIType.Window: ProcessImage(tag.gameObject, skin.window); @@ -46,6 +48,9 @@ namespace ConformalDecals.UI { ProcessSelectable(tag.gameObject, skin.button); break; case UITag.UIType.ButtonToggle: + ProcessToggleButton(tag.gameObject, skin.button); + break; + case UITag.UIType.RadioToggle: ProcessSelectable(tag.gameObject, skin.toggle); break; case UITag.UIType.Slider: @@ -68,10 +73,12 @@ namespace ConformalDecals.UI { } private static void ProcessImage(GameObject gameObject, UIStyle style) { - var image = gameObject.GetComponent(); - if (image == null) throw new FormatException("No Image component present"); - - image.sprite = style.normal.background; + ProcessImage(gameObject.GetComponent(), style.normal); + } + + private static void ProcessImage(Image image, UIStyleState state) { + image.sprite = state.background; + image.color = Color.white; image.type = Image.Type.Sliced; } @@ -79,7 +86,7 @@ namespace ConformalDecals.UI { var selectable = gameObject.GetComponent(); if (selectable == null) throw new FormatException("No Selectable component present"); - ProcessImage(gameObject, style); + ProcessImage(selectable.image, style.normal); selectable.transition = Selectable.Transition.SpriteSwap; @@ -87,6 +94,15 @@ namespace ConformalDecals.UI { state.highlightedSprite = style.highlight.background; state.pressedSprite = style.active.background; state.disabledSprite = style.disabled.background; + + selectable.spriteState = state; + } + + private static void ProcessToggleButton(GameObject gameObject, UIStyle style) { + ProcessSelectable(gameObject, style); + + var toggle = gameObject.GetComponent(); + ProcessImage(toggle.graphic as Image, style.active); } private static void ProcessSlider(GameObject gameObject, UIStyle horizontalStyle, UIStyle horizontalThumbStyle, UIStyle verticalStyle, UIStyle verticalThumbStyle) { diff --git a/Source/ConformalDecals/UI/UITag.cs b/Source/ConformalDecals/UI/UITag.cs index ecc2397..5574ee9 100644 --- a/Source/ConformalDecals/UI/UITag.cs +++ b/Source/ConformalDecals/UI/UITag.cs @@ -8,6 +8,7 @@ namespace ConformalDecals.UI { Box, Button, ButtonToggle, + RadioToggle, Slider, Dropdown, Label,