more changes
the json is ready for any field you throw at it! the property dialog...not so much.
This commit is contained in:
parent
825b49db14
commit
1f19ac34b7
|
@ -375,7 +375,7 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
public void GetProperties(string json = "")
|
public void GetProperties(string json = "")
|
||||||
{
|
{
|
||||||
PropController.instance.LoadProperties(json);
|
Properties.PropController.instance.LoadProperties(json);
|
||||||
Debug.Log("properties sent");
|
Debug.Log("properties sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ namespace HeavenStudio.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetPropertiesJson() =>
|
public string GetPropertiesJson() =>
|
||||||
JsonConvert.SerializeObject(PropController.instance.properties);
|
JsonConvert.SerializeObject(Properties.PropController.instance.properties);
|
||||||
|
|
||||||
public void SetGameEventTitle(string txt)
|
public void SetGameEventTitle(string txt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -8,13 +9,49 @@ using Starpelly;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using HeavenStudio.Games;
|
using HeavenStudio.Games;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Properties
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public class EventParameterManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Property Prefabs")]
|
||||||
|
[SerializeField] private GameObject IntegerP;
|
||||||
|
[SerializeField] private GameObject FloatP;
|
||||||
|
[SerializeField] private GameObject BooleanP;
|
||||||
|
[SerializeField] private GameObject DropdownP;
|
||||||
|
[SerializeField] private GameObject ColorP;
|
||||||
|
[SerializeField] private GameObject StringP;
|
||||||
|
|
||||||
|
public Beatmap.Entity entity;
|
||||||
|
|
||||||
|
public bool active;
|
||||||
|
|
||||||
|
private int childCountAtStart;
|
||||||
|
|
||||||
|
public bool canDisable = true;
|
||||||
|
|
||||||
|
public static EventParameterManager instance { get; set; }
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
childCountAtStart = transform.childCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
public class Properties
|
public class Properties
|
||||||
{
|
{
|
||||||
string levelName = "";
|
//this is just copied from the beatmap lol
|
||||||
string levelCreator = "";
|
public string levelName = "test";
|
||||||
|
public string levelCreator = "testCreator";
|
||||||
|
public int Number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PropController
|
public class PropController
|
||||||
|
@ -28,7 +65,8 @@ namespace HeavenStudio.Editor
|
||||||
if (json != "")
|
if (json != "")
|
||||||
{
|
{
|
||||||
properties = JsonConvert.DeserializeObject<Properties>(json);
|
properties = JsonConvert.DeserializeObject<Properties>(json);
|
||||||
//Debug.Log("property 1 =" + (string)(levelName));
|
Debug.Log("levelName = " + (properties.levelName));
|
||||||
|
Debug.Log("levelCreator = " + (properties.levelCreator));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,10 +9,11 @@ using Starpelly;
|
||||||
|
|
||||||
using HeavenStudio.Util;
|
using HeavenStudio.Util;
|
||||||
|
|
||||||
namespace HeavenStudio.Editor
|
namespace HeavenStudio.Properties
|
||||||
{
|
{
|
||||||
public class RemixPropertyPrefab : MonoBehaviour
|
public class RemixPropertyPrefab : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
public TMP_Text caption;
|
public TMP_Text caption;
|
||||||
[SerializeField] private EventParameterManager parameterManager;
|
[SerializeField] private EventParameterManager parameterManager;
|
||||||
|
|
||||||
|
@ -29,13 +30,6 @@ namespace HeavenStudio.Editor
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public TMP_Dropdown dropdown;
|
public TMP_Dropdown dropdown;
|
||||||
|
|
||||||
[Header("Color")]
|
|
||||||
[Space(10)]
|
|
||||||
public Button ColorBTN;
|
|
||||||
public RectTransform ColorTable;
|
|
||||||
public bool colorTableActive;
|
|
||||||
public ColorPreview colorPreview;
|
|
||||||
|
|
||||||
[Header("String")] //why wasn't this a thing before
|
[Header("String")] //why wasn't this a thing before
|
||||||
[Space(10)]
|
[Space(10)]
|
||||||
public TMP_InputField inputFieldString;
|
public TMP_InputField inputFieldString;
|
||||||
|
@ -56,13 +50,13 @@ namespace HeavenStudio.Editor
|
||||||
slider.minValue = integer.min;
|
slider.minValue = integer.min;
|
||||||
slider.maxValue = integer.max;
|
slider.maxValue = integer.max;
|
||||||
|
|
||||||
slider.value = Mathf.RoundToInt(System.Convert.ToSingle(parameterManager.entity[propertyName]));
|
slider.value = Mathf.RoundToInt(System.Convert.ToSingle(PropController.Properties["levelName"]));
|
||||||
inputField.text = slider.value.ToString();
|
inputField.text = slider.value.ToString();
|
||||||
|
|
||||||
slider.onValueChanged.AddListener(delegate
|
slider.onValueChanged.AddListener(delegate
|
||||||
{
|
{
|
||||||
inputField.text = slider.value.ToString();
|
inputField.text = slider.value.ToString();
|
||||||
parameterManager.entity[propertyName] = (int)slider.value;
|
PropController.Properties["Number"] = (int)slider.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
inputField.onSelect.AddListener(delegate
|
inputField.onSelect.AddListener(delegate
|
||||||
|
@ -73,46 +67,17 @@ namespace HeavenStudio.Editor
|
||||||
inputField.onEndEdit.AddListener(delegate
|
inputField.onEndEdit.AddListener(delegate
|
||||||
{
|
{
|
||||||
slider.value = Mathf.RoundToInt(System.Convert.ToSingle(System.Convert.ToSingle(inputField.text)));
|
slider.value = Mathf.RoundToInt(System.Convert.ToSingle(System.Convert.ToSingle(inputField.text)));
|
||||||
parameterManager.entity[propertyName] = (int)slider.value;
|
PropController.Properties["levelName"] = (int)slider.value;
|
||||||
Editor.instance.editingInputField = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (objType == typeof(EntityTypes.Float))
|
|
||||||
{
|
|
||||||
var fl = ((EntityTypes.Float)type);
|
|
||||||
|
|
||||||
slider.minValue = fl.min;
|
|
||||||
slider.maxValue = fl.max;
|
|
||||||
|
|
||||||
slider.value = System.Convert.ToSingle(parameterManager.entity[propertyName]);
|
|
||||||
inputField.text = slider.value.ToString("G");
|
|
||||||
|
|
||||||
slider.onValueChanged.AddListener(delegate
|
|
||||||
{
|
|
||||||
var newValue = (float)System.Math.Round(slider.value, 4);
|
|
||||||
inputField.text = newValue.ToString("G");
|
|
||||||
parameterManager.entity[propertyName] = newValue;
|
|
||||||
});
|
|
||||||
|
|
||||||
inputField.onSelect.AddListener(delegate
|
|
||||||
{
|
|
||||||
Editor.instance.editingInputField = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
inputField.onEndEdit.AddListener(delegate
|
|
||||||
{
|
|
||||||
slider.value = (float)System.Math.Round(System.Convert.ToSingle(inputField.text), 4);
|
|
||||||
parameterManager.entity[propertyName] = slider.value;
|
|
||||||
Editor.instance.editingInputField = false;
|
Editor.instance.editingInputField = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (type is bool)
|
else if (type is bool)
|
||||||
{
|
{
|
||||||
toggle.isOn = System.Convert.ToBoolean(parameterManager.entity[propertyName]); // ' (bool)type ' always results in false
|
toggle.isOn = System.Convert.ToBoolean(PropController.Properties["levelName"]); // ' (bool)type ' always results in false
|
||||||
|
|
||||||
toggle.onValueChanged.AddListener(delegate
|
toggle.onValueChanged.AddListener(delegate
|
||||||
{
|
{
|
||||||
parameterManager.entity[propertyName] = toggle.isOn;
|
PropController.Properties["levelName"] = toggle.isOn;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (objType.IsEnum)
|
else if (objType.IsEnum)
|
||||||
|
@ -129,7 +94,7 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
dropDownData.Add(optionData);
|
dropDownData.Add(optionData);
|
||||||
|
|
||||||
if ((int)vals.GetValue(i) == (int)parameterManager.entity[propertyName])
|
if ((int)vals.GetValue(i) == (int)PropController.Properties["levelName"])
|
||||||
selected = i;
|
selected = i;
|
||||||
}
|
}
|
||||||
dropdown.AddOptions(dropDownData);
|
dropdown.AddOptions(dropDownData);
|
||||||
|
@ -137,33 +102,14 @@ namespace HeavenStudio.Editor
|
||||||
|
|
||||||
dropdown.onValueChanged.AddListener(delegate
|
dropdown.onValueChanged.AddListener(delegate
|
||||||
{
|
{
|
||||||
parameterManager.entity[propertyName] = (int)Enum.GetValues(objType).GetValue(dropdown.value);
|
PropController.Properties["levelName"] = (int)Enum.GetValues(objType).GetValue(dropdown.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (objType == typeof(Color))
|
|
||||||
{
|
|
||||||
colorPreview.colorPicker.onColorChanged += delegate
|
|
||||||
{
|
|
||||||
parameterManager.entity[propertyName] = (Color)colorPreview.colorPicker.color;
|
|
||||||
};
|
|
||||||
|
|
||||||
Color paramCol = (Color)parameterManager.entity[propertyName];
|
|
||||||
|
|
||||||
ColorBTN.onClick.AddListener(delegate
|
|
||||||
{
|
|
||||||
ColorTable.gameObject.SetActive(true);
|
|
||||||
colorTableActive = true;
|
|
||||||
colorPreview.ChangeColor(paramCol);
|
|
||||||
});
|
|
||||||
|
|
||||||
colorPreview.ChangeColor(paramCol);
|
|
||||||
ColorTable.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
//why the FUCK wasn't this a thing before lmao
|
//why the FUCK wasn't this a thing before lmao
|
||||||
else if (objType == typeof(string))
|
else if (objType == typeof(string))
|
||||||
{
|
{
|
||||||
// Debug.Log("entity " + propertyName + " is: " + (string)(parameterManager.entity[propertyName]));
|
// Debug.Log("entity " + propertyName + " is: " + (string)(PropController.Properties["levelName"]));
|
||||||
inputFieldString.text = (string)(parameterManager.entity[propertyName]);
|
inputFieldString.text = (string)(PropController.Properties["levelName"]);
|
||||||
|
|
||||||
inputFieldString.onSelect.AddListener(delegate
|
inputFieldString.onSelect.AddListener(delegate
|
||||||
{
|
{
|
||||||
|
@ -173,25 +119,10 @@ namespace HeavenStudio.Editor
|
||||||
inputFieldString.onEndEdit.AddListener(delegate
|
inputFieldString.onEndEdit.AddListener(delegate
|
||||||
{
|
{
|
||||||
// Debug.Log("setting " + propertyName + " to: " + inputFieldString.text);
|
// Debug.Log("setting " + propertyName + " to: " + inputFieldString.text);
|
||||||
parameterManager.entity[propertyName] = inputFieldString.text;
|
PropController.Properties["levelName"] = inputFieldString.text;
|
||||||
Editor.instance.editingInputField = false;
|
Editor.instance.editingInputField = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
if (colorTableActive)
|
|
||||||
{
|
|
||||||
if (!Editor.MouseInRectTransform(ColorTable))
|
|
||||||
{
|
|
||||||
if (Input.GetMouseButtonDown(0))
|
|
||||||
{
|
|
||||||
ColorTable.gameObject.SetActive(false);
|
|
||||||
colorTableActive = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue