GUI rearrangement

This commit is contained in:
AbstractConcept 2022-10-20 00:32:13 -05:00
parent 04f8c6a2e4
commit 2e50221118
90 changed files with 435 additions and 1440 deletions

View file

@ -8,7 +8,7 @@ namespace RimWorldAnimationStudio
{
public class ActorCard : MonoBehaviour
{
public Dropdown genderDropdown;
//public Dropdown genderDropdown;
public Dropdown bodyTypeDropdown;
public InputField bodyOffsetXField;
public InputField bodyOffsetZField;
@ -58,12 +58,12 @@ namespace RimWorldAnimationStudio
actor.initiator = initiatorToggle.isOn;
switch (genderDropdown.value)
{
case 0: actor.requiredGender = new List<string>() { "Female" }; break;
case 2: actor.requiredGender = new List<string>() { "Male" }; break;
default: actor.requiredGender = null; break;
}
//switch (genderDropdown.value)
//{
// case 0: actor.requiredGender = new List<string>() { "Female" }; break;
// case 2: actor.requiredGender = new List<string>() { "Male" }; break;
// default: actor.requiredGender = null; break;
//}
float.TryParse(raceOffsetXField.text, out x);
float.TryParse(raceOffsetZField.text, out z);
@ -116,14 +116,14 @@ namespace RimWorldAnimationStudio
initiatorToggle.isOn = actor.initiator;
if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Female"))
{ genderDropdown.SetValueWithoutNotify(0); }
//if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Female"))
//{ genderDropdown.SetValueWithoutNotify(0); }
else if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Male"))
{ genderDropdown.SetValueWithoutNotify(2); }
//else if (actor.requiredGender.NotNullOrEmpty() && actor.requiredGender.Contains("Male"))
//{ genderDropdown.SetValueWithoutNotify(2); }
else
{ genderDropdown.SetValueWithoutNotify(1); }
//else
//{ genderDropdown.SetValueWithoutNotify(1); }
for (int i = 0; i < selectActorLayerDropdown.options.Count; i++)
{

View file

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class ActorManipulator : MonoBehaviour
{
public ActorManipulationMode actorManipulationMode;
private Image button;
public void Start()
{
button = GetComponent<Image>();
}
public void Update()
{
if (Workspace.actorManipulationMode == actorManipulationMode)
{ button.color = Constants.ColorGoldYellow; }
else
{ button.color = Constants.ColorWhite; }
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f627be313335bf748b33eea98541581d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace RimWorldAnimationStudio
{
public class DropdownMenu : MonoBehaviour, IDeselectHandler
{
public Transform dropdownMenu;
public void OpenMenu()
{
dropdownMenu.gameObject.SetActive(true);
EventSystem.current.SetSelectedGameObject(this.gameObject);
}
public void CloseMenu()
{
if (EventSystem.current.currentSelectedGameObject != null)
{
Transform child = transform.FindDeepChild(EventSystem.current.currentSelectedGameObject.name);
if (child != null)
{
EventSystem.current.SetSelectedGameObject(this.gameObject);
return;
}
}
dropdownMenu.gameObject.SetActive(false);
}
public void OnDeselect(BaseEventData eventData)
{
Invoke("CloseMenu", 0.15f);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7367efff96a6a9043ac1c6b3a25dcc39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class RequiresAnimationDef : MonoBehaviour
{
private Button button;
private List<Text> buttonText;
private List<Color> buttonTextColor = new List<Color>();
public void Start()
{
button = GetComponent<Button>();
buttonText = GetComponentsInChildren<Text>()?.ToList();
if (buttonText != null)
{
for (int i = 0; i < buttonText.Count; i++)
{ buttonTextColor.Add(buttonText[i].color); }
}
}
public void Update()
{
button.interactable = Workspace.animationDef != null;
for (int i = 0; i < buttonText.Count; i++)
{ buttonText[i].color = button.interactable ? buttonTextColor[i] : Constants.ColorMidGrey; }
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7903694afa5d7ba429917c147e222781
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace RimWorldAnimationStudio
{
public class SnapToKeyframe : MonoBehaviour, IDragHandler
{
private Slider slider;
public void Start()
{
slider = GetComponent<Slider>();
}
public void OnDrag(PointerEventData eventData)
{
int targetTick = Workspace.FindClosestKeyFrameAtTick((int)slider.value, Mathf.CeilToInt(Workspace.StageWindowSize * 0.01f));
if (Input.GetKey(KeyCode.LeftShift))
{ slider.value = (float)targetTick; }
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b19816966eab6a4eba748f04532fb61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace RimWorldAnimationStudio
{
public class Tooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public string message = "Undefined";
public string executedCommand;
public float delay = 0f;
public Vector2 offset = new Vector2(5f, -15f);
public bool flipX = false;
private GameObject tooltip;
private Text tooltipText;
private bool isActive;
private bool isDisplayed;
private float activeTime = -1f;
public void Start()
{
tooltip = Workspace.Instance.transform.Find("TooltipMessage")?.gameObject;
tooltipText = tooltip?.GetComponentInChildren<Text>();
}
public void Update()
{
if (tooltip == null || isActive == false || (activeTime + delay) > Time.unscaledTime) return;
if (isDisplayed == false)
{
tooltip.GetComponent<RectTransform>().pivot = flipX ? new Vector2(1, 1) : new Vector2(0, 1);
tooltipText.text = message;
if (executedCommand != null && executedCommand != "")
{ tooltipText.text += " (" + KeybindConfig.GetKeybindLabel(executedCommand) + ")"; }
tooltip.transform.position = (Vector2)transform.position + offset;
tooltip.gameObject.SetActive(true);
LayoutRebuilder.ForceRebuildLayoutImmediate(tooltip.GetComponent<RectTransform>());
isDisplayed = true;
}
}
public void OnDisable()
{
if (isActive)
{ OnPointerExit(new PointerEventData(EventSystem.current)); }
}
public void OnPointerEnter(PointerEventData pointerEventData)
{
isActive = true;
activeTime = Time.unscaledTime;
}
public void OnPointerExit(PointerEventData pointerEventData)
{
isActive = false;
isDisplayed = false;
tooltip.gameObject.SetActive(false);
}
public void CalculateLayoutInputHorizontal()
{
throw new NotImplementedException();
}
public void CalculateLayoutInputVertical()
{
throw new NotImplementedException();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c05e9ac2a2f311549b12f094d2785a20
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: