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
4bc41eb2f1
commit
499c84e843
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7434e4d912f845754e3ac21aaefb662ff990f99358b6d7180e3adc9e22803ca6
|
||||
oid sha256:dc76280eebfaa6bfe954ea3e6aba95a91650fe5f60ba66a8ee5a9b6863e327fb
|
||||
size 55808
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5acf1dc16ad4f6adca7d9e303b46b896c6681dc665857c496c6ab1c2161cbbb8
|
||||
size 266582
|
||||
oid sha256:c3ec32bf0dd2571ed80f8e12e05b06591f35364e4d926b0dec6f543c7323d4df
|
||||
size 267232
|
||||
|
|
|
@ -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");
|
||||
ProcessImage(gameObject.GetComponent<Image>(), style.normal);
|
||||
}
|
||||
|
||||
image.sprite = style.normal.background;
|
||||
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