mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Fix some gui issues
This commit is contained in:
parent
4a3569a7be
commit
47727ef0ce
Binary file not shown.
Binary file not shown.
@ -87,6 +87,7 @@
|
||||
<Compile Include="Text\TextRenderer.cs" />
|
||||
<Compile Include="Text\TextSettings.cs" />
|
||||
<Compile Include="Test\TestLayers.cs" />
|
||||
<Compile Include="UI\TextEntryController.cs" />
|
||||
<Compile Include="UI\UILoader.cs" />
|
||||
<Compile Include="UI\UITag.cs" />
|
||||
<Compile Include="Util\Logging.cs" />
|
||||
|
@ -26,8 +26,8 @@ namespace ConformalDecals {
|
||||
{
|
||||
if (_textEntryGui == null) {
|
||||
_textEntryGui = Instantiate(UILoader.textEntryPrefab, MainCanvasUtil.MainCanvas.transform, true);
|
||||
_textEntryGui.AddComponent<DragPanel>();
|
||||
MenuNavigation.SpawnMenuNavigation(_textEntryGui, Navigation.Mode.Automatic, true);
|
||||
//_textEntryGui.AddComponent<DragPanel>();
|
||||
//MenuNavigation.SpawnMenuNavigation(_textEntryGui, Navigation.Mode.Automatic, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
Source/ConformalDecals/UI/TextEntryController.cs
Normal file
9
Source/ConformalDecals/UI/TextEntryController.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class TextEntryController : MonoBehaviour {
|
||||
public void OnClose() {
|
||||
Debug.Log("Close!");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<UITag>(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<Image>();
|
||||
if (image == null) throw new FormatException("No Image component present");
|
||||
|
||||
image.sprite = style.normal.background;
|
||||
ProcessImage(gameObject.GetComponent<Image>(), 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<Selectable>();
|
||||
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<Toggle>();
|
||||
ProcessImage(toggle.graphic as Image, style.active);
|
||||
}
|
||||
|
||||
private static void ProcessSlider(GameObject gameObject, UIStyle horizontalStyle, UIStyle horizontalThumbStyle, UIStyle verticalStyle, UIStyle verticalThumbStyle) {
|
||||
|
@ -8,6 +8,7 @@ namespace ConformalDecals.UI {
|
||||
Box,
|
||||
Button,
|
||||
ButtonToggle,
|
||||
RadioToggle,
|
||||
Slider,
|
||||
Dropdown,
|
||||
Label,
|
||||
|
Loading…
Reference in New Issue
Block a user