* in name when changing value

This commit is contained in:
Rapandrasmus 2023-10-10 19:41:51 +02:00
parent 260f292947
commit 3919dfbedf
7 changed files with 103 additions and 15 deletions

View file

@ -105,11 +105,8 @@ namespace HeavenStudio.Editor
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
}
Debug.Log(action.parameters);
foreach (var p in action.parameters)
{
Debug.Log(p.collapseParams);
if (p.collapseParams == null || p.collapseParams.Count == 0) continue;
EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent<EventPropertyPrefab>();
foreach (var c in p.collapseParams)

View file

@ -14,6 +14,7 @@ namespace HeavenStudio.Editor
public class EventPropertyPrefab : MonoBehaviour
{
public TMP_Text caption;
protected string _captionText;
public EventParameterManager parameterManager;
public string propertyName;
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
@ -25,7 +26,10 @@ namespace HeavenStudio.Editor
{
this.parameterManager = EventParameterManager.instance;
this.propertyName = propertyName;
this.caption.text = caption;
_captionText = caption;
this.caption.text = _captionText;
}
public void UpdateCollapse(object type)
@ -34,7 +38,7 @@ namespace HeavenStudio.Editor
{
foreach (var c in p.collapseables)
{
c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
if (c != null) c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
}
}
}

View file

@ -18,15 +18,28 @@ namespace HeavenStudio.Editor
[Space(10)]
public Toggle toggle;
private bool _defaultValue;
new public void SetProperties(string propertyName, object type, string caption)
{
InitProperties(propertyName, caption);
// ' (bool)type ' always results in false
_defaultValue = (bool)type;
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
toggle.onValueChanged.AddListener(
_ => parameterManager.entity[propertyName] = toggle.isOn
_ =>
{
parameterManager.entity[propertyName] = toggle.isOn;
if (toggle.isOn != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
);
}
@ -37,9 +50,5 @@ namespace HeavenStudio.Editor
);
UpdateCollapse(toggle.isOn);
}
private void Update()
{
}
}
}

View file

@ -21,12 +21,26 @@ namespace HeavenStudio.Editor
public bool colorTableActive;
public ColorPreview colorPreview;
private Color _defaultColor;
new public void SetProperties(string propertyName, object type, string caption)
{
InitProperties(propertyName, caption);
colorPreview.colorPicker.onColorChanged += _ =>
colorPreview.colorPicker.onColorChanged += _ =>
{
parameterManager.entity[propertyName] = colorPreview.colorPicker.color;
if (colorPreview.colorPicker.color != _defaultColor)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
};
_defaultColor = (Color)type;
Color paramCol = parameterManager.entity[propertyName];

View file

@ -19,6 +19,8 @@ namespace HeavenStudio.Editor
public TMP_Dropdown dropdown;
private Array enumVals;
private int _defaultValue;
private bool openedDropdown = false;
new public void SetProperties(string propertyName, object type, string caption)
@ -28,6 +30,7 @@ namespace HeavenStudio.Editor
var enumType = type.GetType();
enumVals = Enum.GetValues(enumType);
var enumNames = Enum.GetNames(enumType).ToList();
_defaultValue = (int)type;
// Can we assume non-holey enum?
// If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName]
@ -40,8 +43,18 @@ namespace HeavenStudio.Editor
dropdown.AddOptions(enumNames);
dropdown.value = selected;
dropdown.onValueChanged.AddListener(_ =>
parameterManager.entity[propertyName] = (int) enumVals.GetValue(dropdown.value)
dropdown.onValueChanged.AddListener(_ =>
{
parameterManager.entity[propertyName] = (int)enumVals.GetValue(dropdown.value);
if ((int)enumVals.GetValue(dropdown.value) != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
);
}

View file

@ -9,6 +9,7 @@ using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
using static HeavenStudio.EntityTypes;
namespace HeavenStudio.Editor
{
@ -19,6 +20,8 @@ namespace HeavenStudio.Editor
public Slider slider;
public TMP_InputField inputField;
private float _defaultValue;
new public void SetProperties(string propertyName, object type, string caption)
{
InitProperties(propertyName, caption);
@ -28,6 +31,7 @@ namespace HeavenStudio.Editor
case EntityTypes.Integer integer:
slider.minValue = integer.min;
slider.maxValue = integer.max;
_defaultValue = integer.val;
slider.wholeNumbers = true;
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
@ -38,6 +42,14 @@ namespace HeavenStudio.Editor
{
inputField.text = slider.value.ToString();
parameterManager.entity[propertyName] = (int) slider.value;
if (slider.value != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
);
@ -52,6 +64,14 @@ namespace HeavenStudio.Editor
slider.value = Convert.ToSingle(inputField.text);
parameterManager.entity[propertyName] = (int) slider.value;
Editor.instance.editingInputField = false;
if (slider.value != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
);
break;
@ -59,6 +79,7 @@ namespace HeavenStudio.Editor
case EntityTypes.Float fl:
slider.minValue = fl.min;
slider.maxValue = fl.max;
_defaultValue = fl.val;
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
inputField.text = slider.value.ToString("G");
@ -69,6 +90,14 @@ namespace HeavenStudio.Editor
var newValue = (float) Math.Round(slider.value, 4);
inputField.text = newValue.ToString("G");
parameterManager.entity[propertyName] = newValue;
if (newValue != _defaultValue)
{
this.caption.text = "*" + _captionText;
}
else
{
this.caption.text = _captionText;
}
}
);
@ -83,6 +112,14 @@ namespace HeavenStudio.Editor
slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4);
parameterManager.entity[propertyName] = slider.value;
Editor.instance.editingInputField = false;
if (slider.value != _defaultValue)
{
this.caption.text = "*" + _captionText;
}
else
{
this.caption.text = _captionText;
}
}
);
break;

View file

@ -9,6 +9,7 @@ using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
using UnityEngine.UIElements;
namespace HeavenStudio.Editor
{
@ -18,10 +19,14 @@ namespace HeavenStudio.Editor
[Space(10)]
public TMP_InputField inputFieldString;
private string _defaultValue;
new public void SetProperties(string propertyName, object type, string caption)
{
InitProperties(propertyName, caption);
_defaultValue = (string)type;
inputFieldString.text = (string) parameterManager.entity[propertyName];
inputFieldString.onSelect.AddListener(
@ -30,10 +35,19 @@ namespace HeavenStudio.Editor
);
inputFieldString.onValueChanged.AddListener(
_ =>
{;
{
parameterManager.entity[propertyName] = inputFieldString.text;
if (inputFieldString.text != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
);
inputFieldString.onEndEdit.AddListener(
_ =>
{;