mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 19:57:38 +02:00
Advanced Blocks (#720)
* play sfx and play animation blocks i also changed prescheduleFunction to preFunction, and removed the unused preFunction argument in GameAction i can revert this if need be but it just seemed vestigial * count in rework + preloading, multisound addition multisound was using an array that was converted to a list..? very silly when you consider it's a list first so sometimes it's list -> array -> list lol new Count-In and Play SFX block preloads sfx now!! epic. * prefab-ify event properties, Button EntityType * things are very nearly working! however i just hit an insane hurdle. how do i modify a dropdown while still being able to access the index/int value of that param directly. UGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH * okay it's WORKING now i just need to do some better dropdown stuff * ITS WORKING ITS WORKING ITS WORKING arbitrary animations, now accessible to those without prefab knowledge! and it's piss easy to use!! * about to make a struct + class, tooltip improvements gonna make the struct define it, then the class will actually be the dropdown this is gonna make things so so so so much easier to comprehend * finishing up, probably one more commit after this * split up Dropdown into Dropdown and DropdownObj, which basically fixed all of my problems lol * fixed a count bug * added param tooltip toggle * grah it's ALMOST DONE * it's 99.9% finished. just some touch ups, i don't think i even know of any bugs * alright, looks like that's all the bugs gone * EVERYTHING IS FINISHED!!
This commit is contained in:
@ -134,7 +134,14 @@ namespace HeavenStudio.Editor.Commands
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
dupEntityData.Add(entity.DeepCopy());
|
||||
var newEntity = entity.DeepCopy();
|
||||
// there's gotta be a better way to do this. i just don't know how... -AJ
|
||||
foreach ((var key, var value) in new Dictionary<string, dynamic>(newEntity.dynamicData)) {
|
||||
if (value is EntityTypes.DropdownObj dd) {
|
||||
newEntity[key] = new EntityTypes.DropdownObj(dd.value, dd.Values);
|
||||
}
|
||||
}
|
||||
dupEntityData.Add(newEntity);
|
||||
}
|
||||
|
||||
for (var i = 0; i < original.Count; i++)
|
||||
|
@ -2,10 +2,11 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Editor.Track;
|
||||
using Jukebox;
|
||||
using Jukebox.Legacy;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using static HeavenStudio.EntityTypes;
|
||||
using HeavenStudio.Common;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
@ -18,10 +19,12 @@ namespace HeavenStudio.Editor
|
||||
[Header("Property Prefabs")]
|
||||
[SerializeField] private GameObject IntegerP;
|
||||
[SerializeField] private GameObject FloatP;
|
||||
[SerializeField] private GameObject ButtonP;
|
||||
[SerializeField] private GameObject BooleanP;
|
||||
[SerializeField] private GameObject DropdownP;
|
||||
[SerializeField] private GameObject ColorP;
|
||||
[SerializeField] private GameObject StringP;
|
||||
private static Dictionary<Type, GameObject> PropertyPrefabs;
|
||||
|
||||
public RiqEntity entity;
|
||||
|
||||
@ -36,6 +39,18 @@ namespace HeavenStudio.Editor
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
if (PropertyPrefabs == null) {
|
||||
PropertyPrefabs = new() {
|
||||
{ typeof(Integer), IntegerP },
|
||||
{ typeof(Float), FloatP },
|
||||
{ typeof(Dropdown), DropdownP },
|
||||
{ typeof(Button), ButtonP },
|
||||
{ typeof(Color), ColorP },
|
||||
{ typeof(bool), BooleanP },
|
||||
{ typeof(string), StringP },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@ -70,15 +85,6 @@ namespace HeavenStudio.Editor
|
||||
AddParams(entity);
|
||||
}
|
||||
|
||||
static string TrackToThemeColour(int track) => track switch
|
||||
{
|
||||
1 => EditorTheme.theme.properties.Layer2Col,
|
||||
2 => EditorTheme.theme.properties.Layer3Col,
|
||||
3 => EditorTheme.theme.properties.Layer4Col,
|
||||
4 => EditorTheme.theme.properties.Layer5Col,
|
||||
_ => EditorTheme.theme.properties.Layer1Col
|
||||
};
|
||||
|
||||
private void AddParams(RiqEntity entity)
|
||||
{
|
||||
string[] split = entity.datamodel.Split('/');
|
||||
@ -91,7 +97,14 @@ namespace HeavenStudio.Editor
|
||||
eventSelector.SetActive(false);
|
||||
this.entity = entity;
|
||||
|
||||
string col = TrackToThemeColour((int)entity["track"]);
|
||||
string col = (int)entity["track"] switch
|
||||
{
|
||||
1 => EditorTheme.theme.properties.Layer2Col,
|
||||
2 => EditorTheme.theme.properties.Layer3Col,
|
||||
3 => EditorTheme.theme.properties.Layer4Col,
|
||||
4 => EditorTheme.theme.properties.Layer5Col,
|
||||
_ => EditorTheme.theme.properties.Layer1Col
|
||||
};
|
||||
Editor.instance.SetGameEventTitle($"Properties for <color=#{col}>{action.displayName}</color> on Beat {entity.beat.ToString("F2")} on <color=#{col}>Track {(int)entity["track"] + 1}</color>");
|
||||
|
||||
DestroyParams();
|
||||
@ -100,11 +113,8 @@ namespace HeavenStudio.Editor
|
||||
|
||||
for (int i = 0; i < action.parameters.Count; i++)
|
||||
{
|
||||
object param = action.parameters[i].parameter;
|
||||
string caption = action.parameters[i].propertyCaption;
|
||||
string propertyName = action.parameters[i].propertyName;
|
||||
string tooltip = action.parameters[i].tooltip;
|
||||
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
|
||||
var p = action.parameters[i];
|
||||
ePrefabs.Add(p.propertyName, AddParam(p.propertyName, p.parameter, p.caption, p.tooltip));
|
||||
}
|
||||
|
||||
foreach (var p in action.parameters)
|
||||
@ -129,70 +139,27 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private GameObject AddParam(string propertyName, object type, string caption, string tooltip = "")
|
||||
{
|
||||
GameObject prefab = IntegerP;
|
||||
GameObject input;
|
||||
|
||||
var objType = type.GetType();
|
||||
|
||||
if (objType == typeof(EntityTypes.Integer))
|
||||
{
|
||||
prefab = IntegerP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<NumberPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else if (objType == typeof(EntityTypes.Float))
|
||||
{
|
||||
prefab = FloatP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<NumberPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else if(type is bool)
|
||||
{
|
||||
prefab = BooleanP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<BoolPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else if (objType.IsEnum)
|
||||
{
|
||||
prefab = DropdownP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<EnumPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else if (objType == typeof(Color))
|
||||
{
|
||||
prefab = ColorP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<ColorPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else if(objType == typeof(string))
|
||||
{
|
||||
prefab = StringP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<StringPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Can't make property interface of type: " + type.GetType());
|
||||
Type typeType = type.GetType();
|
||||
GameObject propertyPrefab = DropdownP; // enum check is hardcoded because enums are awesome (lying)
|
||||
if (!typeType.IsEnum && !PropertyPrefabs.TryGetValue(typeType, out propertyPrefab)) {
|
||||
Debug.LogError("Can't make property interface of type: " + typeType);
|
||||
return null;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
private GameObject InitPrefab(GameObject prefab, string tooltip = "")
|
||||
{
|
||||
GameObject input = Instantiate(prefab);
|
||||
input.transform.SetParent(this.gameObject.transform);
|
||||
GameObject input = Instantiate(propertyPrefab, transform);
|
||||
input.SetActive(true);
|
||||
input.transform.localScale = Vector3.one;
|
||||
|
||||
if(tooltip != string.Empty)
|
||||
Tooltip.AddTooltip(input, "", tooltip);
|
||||
if (tooltip != string.Empty) {
|
||||
if (PersistentDataManager.gameSettings.showParamTooltips) {
|
||||
Tooltip.AddTooltip(input, tooltip);
|
||||
} else {
|
||||
Tooltip.AddTooltip(input, "", tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
EventPropertyPrefab property = input.GetComponent<EventPropertyPrefab>();
|
||||
property.SetProperties(propertyName, type, caption);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
@ -17,29 +15,30 @@ namespace HeavenStudio.Editor
|
||||
public TMP_Text caption;
|
||||
protected string _captionText;
|
||||
public EventParameterManager parameterManager;
|
||||
public RiqEntity entity;
|
||||
public string propertyName;
|
||||
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
|
||||
|
||||
public void SetProperties(string propertyName, object type, string caption) {}
|
||||
public virtual void SetCollapses(object type) { }
|
||||
|
||||
public void InitProperties(string propertyName, string caption)
|
||||
public virtual void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
this.parameterManager = EventParameterManager.instance;
|
||||
|
||||
entity = parameterManager.entity;
|
||||
this.propertyName = propertyName;
|
||||
|
||||
_captionText = caption;
|
||||
|
||||
this.caption.text = _captionText;
|
||||
this.caption.text = _captionText = caption;
|
||||
}
|
||||
public virtual void SetCollapses(object type) { }
|
||||
|
||||
public void UpdateCollapse(object type)
|
||||
{
|
||||
foreach (var p in propertyCollapses)
|
||||
{
|
||||
foreach (var c in p.collapseables)
|
||||
{
|
||||
if (c != null) c.SetActive(p.collapseOn(type, p.entity) && gameObject.activeSelf);
|
||||
if (p.collapseables.Count > 0) { // there could be a better way to do it, but for now this works
|
||||
foreach (var c in p.collapseables) {
|
||||
if (c != null) c.SetActive(p.collapseOn(type, p.entity) && gameObject.activeSelf);
|
||||
}
|
||||
} else {
|
||||
_ = p.collapseOn(type, p.entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,6 @@ using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class BoolPropertyPrefab : EventPropertyPrefab
|
||||
@ -20,27 +16,18 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private bool _defaultValue;
|
||||
|
||||
new public void SetProperties(string propertyName, object type, string caption)
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
InitProperties(propertyName, caption);
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
_defaultValue = (bool)type;
|
||||
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
|
||||
toggle.isOn = Convert.ToBoolean(entity[propertyName]);
|
||||
|
||||
toggle.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
parameterManager.entity[propertyName] = toggle.isOn;
|
||||
if (toggle.isOn != _defaultValue)
|
||||
{
|
||||
this.caption.text = _captionText + "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.caption.text = _captionText;
|
||||
}
|
||||
}
|
||||
);
|
||||
toggle.onValueChanged.AddListener(_ =>
|
||||
{
|
||||
entity[propertyName] = toggle.isOn;
|
||||
this.caption.text = (toggle.isOn != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||
});
|
||||
}
|
||||
|
||||
public void ResetValue()
|
||||
@ -50,9 +37,7 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
toggle.onValueChanged.AddListener(
|
||||
_ => UpdateCollapse(toggle.isOn)
|
||||
);
|
||||
toggle.onValueChanged.AddListener(newVal => UpdateCollapse(newVal));
|
||||
UpdateCollapse(toggle.isOn);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class ButtonPropertyPrefab : EventPropertyPrefab
|
||||
{
|
||||
[Header("Boolean")]
|
||||
[Space(10)]
|
||||
public float minButtonSize;
|
||||
public RectTransform buttonTextRect;
|
||||
public RectTransform buttonRect;
|
||||
public TMP_Text buttonText;
|
||||
public EntityTypes.Button button;
|
||||
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
if (type is EntityTypes.Button button) {
|
||||
this.button = button;
|
||||
buttonText.text = entity[propertyName];
|
||||
} else {
|
||||
Debug.LogError("ButtonPropertyPrefab was unable to use " + type.GetType() + " as a Button.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
string text = button.onClick.Invoke(entity);
|
||||
if (text != null) {
|
||||
buttonText.text = entity[propertyName] = text;
|
||||
}
|
||||
UpdateCollapse(entity[propertyName]);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// OnClick() already handles this.
|
||||
// if somebody wants to uncomment this for their thing feel free but it's unused for now -AJ
|
||||
// if (entity[propertyName] != buttonText.text) {
|
||||
// buttonText.text = entity[propertyName];
|
||||
// }
|
||||
|
||||
buttonRect.sizeDelta = new(Mathf.Max(buttonTextRect.sizeDelta.x, minButtonSize), buttonRect.sizeDelta.y);
|
||||
}
|
||||
|
||||
public void ResetValue()
|
||||
{
|
||||
buttonText.text = entity[propertyName] = button.defaultLabel;
|
||||
}
|
||||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
UpdateCollapse(entity[propertyName]);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ada001011e54c74b87c04d7186d5f3c
|
||||
guid: 7891bc13f0b17734e9a197bf22818300
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -6,10 +6,6 @@ using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class ColorPropertyPrefab : EventPropertyPrefab
|
||||
@ -24,9 +20,9 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private Color _defaultColor;
|
||||
|
||||
new public void SetProperties(string propertyName, object type, string caption)
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
InitProperties(propertyName, caption);
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
hex.onSelect.AddListener(
|
||||
_ =>
|
||||
|
@ -0,0 +1,100 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
using HeavenStudio.Common;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class DropdownPropertyPrefab : EventPropertyPrefab
|
||||
{
|
||||
[Header("Dropdown")]
|
||||
[Space(10)]
|
||||
public LeftClickTMP_Dropdown dropdown;
|
||||
public Scrollbar scrollbar;
|
||||
|
||||
private int _defaultValue;
|
||||
|
||||
private bool openedDropdown = false;
|
||||
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
int selected = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EntityTypes.Dropdown dropdownEntity:
|
||||
// entity[propertyName].ChangeValues(dropdownEntity.Values);
|
||||
_defaultValue = dropdownEntity.defaultValue;
|
||||
EntityTypes.DropdownObj dropdownObj = entity[propertyName];
|
||||
selected = dropdownObj.value;
|
||||
dropdown.AddOptions(dropdownObj.Values);
|
||||
dropdown.onValueChanged.AddListener(newVal => dropdownObj.value = newVal);
|
||||
dropdownObj.onValueChanged = new Action<List<string>>(newValues =>
|
||||
{
|
||||
if (dropdown == null) return;
|
||||
dropdown.ClearOptions();
|
||||
dropdown.AddOptions(newValues);
|
||||
dropdown.enabled = newValues.Count > 0;
|
||||
dropdownObj.value = _defaultValue;
|
||||
});
|
||||
break;
|
||||
case Enum enumEntity:
|
||||
Type enumType = enumEntity.GetType();
|
||||
_defaultValue = (int)type;
|
||||
int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray();
|
||||
selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]);
|
||||
|
||||
dropdown.AddOptions(Enum.GetNames(enumType).ToList());
|
||||
dropdown.onValueChanged.AddListener(val => entity[propertyName] = keys[val]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dropdown.value = selected;
|
||||
dropdown.enabled = dropdown.options.Count > 0;
|
||||
|
||||
dropdown.onValueChanged.AddListener(newValue => {
|
||||
this.caption.text = (newValue != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||
});
|
||||
}
|
||||
|
||||
public void ResetValue()
|
||||
{
|
||||
dropdown.value = _defaultValue;
|
||||
}
|
||||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse(type));
|
||||
UpdateCollapse(type);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (scrollbar != null)
|
||||
{
|
||||
if (openedDropdown == false)
|
||||
{
|
||||
openedDropdown = true;
|
||||
|
||||
var valuePos = (float)dropdown.value / (dropdown.options.Count - 1);
|
||||
var scrollVal = scrollbar.direction == Scrollbar.Direction.TopToBottom ? valuePos : 1.0f - valuePos;
|
||||
scrollbar.value = Mathf.Max(0.001f, scrollVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
openedDropdown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dbe69d785c445e41a3096329bda742d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,95 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
using HeavenStudio.Common;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class EnumPropertyPrefab : EventPropertyPrefab
|
||||
{
|
||||
[Header("Dropdown")]
|
||||
[Space(10)]
|
||||
public LeftClickTMP_Dropdown dropdown;
|
||||
private Array enumVals;
|
||||
|
||||
private int _defaultValue;
|
||||
|
||||
private bool openedDropdown = false;
|
||||
|
||||
new public void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
InitProperties(propertyName, caption);
|
||||
|
||||
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]
|
||||
var currentlySelected = (int) parameterManager.entity[propertyName];
|
||||
var selected = enumVals
|
||||
.Cast<object>()
|
||||
.ToList()
|
||||
.FindIndex(val => (int) val == currentlySelected);
|
||||
|
||||
dropdown.AddOptions(enumNames);
|
||||
dropdown.value = selected;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void ResetValue()
|
||||
{
|
||||
dropdown.value = _defaultValue;
|
||||
}
|
||||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
dropdown.onValueChanged.AddListener(_ => UpdateCollapse((int)enumVals.GetValue(dropdown.value)));
|
||||
UpdateCollapse((int)enumVals.GetValue(dropdown.value));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var scrollbar = GetComponentInChildren<ScrollRect>()?.verticalScrollbar;
|
||||
|
||||
// This is bad but we'll fix it later.
|
||||
if (scrollbar != null)
|
||||
{
|
||||
if (openedDropdown == false)
|
||||
{
|
||||
openedDropdown = true;
|
||||
|
||||
var valuePos = (float)dropdown.value / (dropdown.options.Count - 1);
|
||||
var scrollVal = scrollbar.direction == Scrollbar.Direction.TopToBottom ? valuePos : 1.0f - valuePos;
|
||||
scrollbar.value = Mathf.Max(0.001f, scrollVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
openedDropdown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,6 @@ using System;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
|
||||
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Editor;
|
||||
using static HeavenStudio.EntityTypes;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class NumberPropertyPrefab : EventPropertyPrefab
|
||||
@ -22,9 +17,9 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private float _defaultValue;
|
||||
|
||||
new public void SetProperties(string propertyName, object type, string caption)
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
InitProperties(propertyName, caption);
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -141,42 +136,18 @@ namespace HeavenStudio.Editor
|
||||
switch (type)
|
||||
{
|
||||
case EntityTypes.Integer integer:
|
||||
slider.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse((int)slider.value);
|
||||
}
|
||||
);
|
||||
|
||||
inputField.onEndEdit.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse((int)slider.value);
|
||||
}
|
||||
);
|
||||
slider.onValueChanged.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||
inputField.onEndEdit.AddListener(_ => UpdateCollapse((int)slider.value));
|
||||
|
||||
UpdateCollapse((int)slider.value);
|
||||
|
||||
break;
|
||||
|
||||
case EntityTypes.Float fl:
|
||||
slider.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
var newValue = (float)Math.Round(slider.value, 4);
|
||||
UpdateCollapse(newValue);
|
||||
}
|
||||
);
|
||||
slider.onValueChanged.AddListener(newVal => UpdateCollapse((float)Math.Round(newVal, 4)));
|
||||
inputField.onEndEdit.AddListener(_ => UpdateCollapse(slider.value));
|
||||
|
||||
var newValue = (float)Math.Round(slider.value, 4);
|
||||
UpdateCollapse(newValue);
|
||||
|
||||
inputField.onEndEdit.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse(slider.value);
|
||||
}
|
||||
);
|
||||
UpdateCollapse((float)Math.Round(slider.value, 4));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -21,13 +21,13 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private string _defaultValue;
|
||||
|
||||
new public void SetProperties(string propertyName, object type, string caption)
|
||||
public override void SetProperties(string propertyName, object type, string caption)
|
||||
{
|
||||
InitProperties(propertyName, caption);
|
||||
base.SetProperties(propertyName, type, caption);
|
||||
|
||||
_defaultValue = (string)type;
|
||||
|
||||
inputFieldString.text = (string) parameterManager.entity[propertyName];
|
||||
inputFieldString.text = (string)entity[propertyName];
|
||||
|
||||
inputFieldString.onSelect.AddListener(
|
||||
_ =>
|
||||
@ -36,21 +36,14 @@ namespace HeavenStudio.Editor
|
||||
inputFieldString.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
parameterManager.entity[propertyName] = inputFieldString.text;
|
||||
if (inputFieldString.text != _defaultValue)
|
||||
{
|
||||
this.caption.text = _captionText + "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.caption.text = _captionText;
|
||||
}
|
||||
entity[propertyName] = inputFieldString.text;
|
||||
this.caption.text = (inputFieldString.text != _defaultValue) ? (_captionText + "*") : _captionText;
|
||||
}
|
||||
);
|
||||
|
||||
inputFieldString.onEndEdit.AddListener(
|
||||
_ =>
|
||||
{;
|
||||
{
|
||||
Editor.instance.editingInputField = false;
|
||||
}
|
||||
);
|
||||
@ -63,16 +56,15 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public override void SetCollapses(object type)
|
||||
{
|
||||
inputFieldString.onValueChanged.AddListener(
|
||||
_ =>
|
||||
{
|
||||
UpdateCollapse(inputFieldString.text);
|
||||
});
|
||||
inputFieldString.onValueChanged.AddListener(newVal => UpdateCollapse(newVal));
|
||||
UpdateCollapse(inputFieldString.text);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (entity[propertyName] != inputFieldString.text) {
|
||||
inputFieldString.text =entity[propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -888,23 +888,18 @@ namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
for (int i = 0; i < ep.Count; i++)
|
||||
{
|
||||
object returnVal = ep[i].parameter;
|
||||
object returnVal = ep[i].parameter switch {
|
||||
EntityTypes.Integer intVal => intVal.val,
|
||||
EntityTypes.Float floatVal => floatVal.val,
|
||||
EntityTypes.Button buttonVal => buttonVal.defaultLabel,
|
||||
EntityTypes.Dropdown ddVal => new EntityTypes.DropdownObj(ddVal),
|
||||
_ => ep[i].parameter,
|
||||
};
|
||||
|
||||
var propertyType = returnVal.GetType();
|
||||
if (propertyType == typeof(EntityTypes.Integer))
|
||||
{
|
||||
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
||||
}
|
||||
else if (propertyType == typeof(EntityTypes.Float))
|
||||
{
|
||||
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
||||
}
|
||||
else if (propertyType.IsEnum)
|
||||
{
|
||||
if (returnVal.GetType().IsEnum) {
|
||||
returnVal = (int)ep[i].parameter;
|
||||
}
|
||||
|
||||
//tempEntity[ep[i].propertyName] = returnVal;
|
||||
tempEntity.CreateProperty(ep[i].propertyName, returnVal);
|
||||
}
|
||||
}
|
||||
@ -956,7 +951,14 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
foreach (RiqEntity entity in original)
|
||||
{
|
||||
CopiedEntities.Add(entity.DeepCopy());
|
||||
var newEntity = entity.DeepCopy();
|
||||
// there's gotta be a better way to do this. i just don't know how... -AJ
|
||||
foreach ((var key, var value) in new Dictionary<string, dynamic>(newEntity.dynamicData)) {
|
||||
if (value is EntityTypes.DropdownObj dd) {
|
||||
newEntity[key] = new EntityTypes.DropdownObj(dd.value, dd.Values);
|
||||
}
|
||||
}
|
||||
CopiedEntities.Add(newEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,20 +388,19 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
else if (Input.GetMouseButton(2))
|
||||
{
|
||||
// var mgs = EventCaller.instance.minigames;
|
||||
string[] datamodels = entity.datamodel.Split('/');
|
||||
Debug.Log("Selected entity's datamodel : " + entity.datamodel);
|
||||
|
||||
bool isSwitchGame = datamodels[1] == "switchGame";
|
||||
// int gameIndex = mgs.FindIndex(c => c.name == datamodels[isSwitchGame ? 2 : 0]);
|
||||
int block = isSwitchGame ? 0 : EventCaller.instance.minigames[datamodels[isSwitchGame ? 2 : 0]].actions.FindIndex(c => c.actionName == datamodels[1]) + 1;
|
||||
var game = EventCaller.instance.minigames[datamodels[isSwitchGame ? 2 : 0]];
|
||||
int block = isSwitchGame ? 0 : game.actions.FindIndex(c => c.actionName == datamodels[1]) + 1;
|
||||
|
||||
if (!isSwitchGame)
|
||||
{
|
||||
// hardcoded stuff
|
||||
// needs to happen because hidden blocks technically change the event index
|
||||
if (datamodels[0] == "gameManager") block -= 2;
|
||||
else if (datamodels[0] is "countIn" or "vfx") block -= 1;
|
||||
if (game.fxOnly) block--;
|
||||
if (datamodels[0] == "gameManager") block --;
|
||||
}
|
||||
|
||||
GridGameSelector.instance.SelectGame(datamodels[isSwitchGame ? 2 : 0], block);
|
||||
|
@ -71,8 +71,15 @@ namespace HeavenStudio.Editor
|
||||
private void OnEnterPrivate(string tooltipText, string altTooltipText)
|
||||
{
|
||||
group.alpha = 1;
|
||||
SetText(tooltipText);
|
||||
Editor.instance.tooltipText.text = altTooltipText.Replace("\n","");
|
||||
|
||||
text.text = tooltipText;
|
||||
text.ForceMeshUpdate();
|
||||
|
||||
Vector2 textSize = text.GetRenderedValues(false);
|
||||
Vector2 paddingSize = new Vector2(8, 8);
|
||||
|
||||
background.sizeDelta = textSize + paddingSize;
|
||||
Editor.instance.tooltipText.text = altTooltipText.Replace("\n", "");
|
||||
Editor.instance.tooltipText.ForceMeshUpdate();
|
||||
}
|
||||
|
||||
@ -92,10 +99,9 @@ namespace HeavenStudio.Editor
|
||||
background.sizeDelta = textSize + paddingSize;
|
||||
}
|
||||
|
||||
public static void AddTooltip(GameObject g, string tooltipText, string altTooltipText = "")
|
||||
public static void AddTooltip(GameObject g, string tooltipText, string altTooltipText = null)
|
||||
{
|
||||
if (altTooltipText == "")
|
||||
altTooltipText = tooltipText;
|
||||
altTooltipText ??= tooltipText;
|
||||
|
||||
EventTrigger et = g.AddComponent<EventTrigger>();
|
||||
|
||||
|
Reference in New Issue
Block a user