prep auto-population of property menu

This commit is contained in:
minenice55 2022-09-01 20:57:47 -04:00
parent c9b37fc8a4
commit 434e40274c
23 changed files with 552 additions and 25 deletions

View file

@ -28048,7 +28048,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 137.66667, y: -20}
m_AnchoredPosition: {x: 137.66669, y: -20}
m_SizeDelta: {x: 70, y: 40}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1107362316
@ -29701,7 +29701,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 129.89537}
m_AnchoredPosition: {x: 0, y: 189.92252}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1154875944
@ -30145,7 +30145,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
propertyHolder: {fileID: 1496522766}
propertyNames: []
IntegerP: {fileID: 797336683}
FloatP: {fileID: 797336683}
BooleanP: {fileID: 2083473857}
@ -35214,6 +35213,21 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
dialog: {fileID: 1336470761}
infoTags:
- remixtitle
infoLabels:
- Remix Title
flavourTags: []
flavourLabels: []
infoContainer: {fileID: 1177777399}
chart:
bpm: 0
musicVolume: 0
entities: []
tempoChanges: []
volumeChanges: []
beatmapSections: []
firstBeatOffset: 0
--- !u!1 &1337141464
GameObject:
m_ObjectHideFlags: 0
@ -45262,7 +45276,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -84.99002}
m_AnchoredPosition: {x: 0, y: -84.990036}
m_SizeDelta: {x: 320, y: -113.92}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1852819572

View file

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Editor.Track;
using TMPro;
namespace HeavenStudio.Editor
{
public abstract class TabsContent : MonoBehaviour
{
public abstract void OnOpenTab();
public abstract void OnCloseTab();
}
}

View file

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

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28745dfd251ff86468a98978665f553b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eccea73a04818a844bc25e6308bc1d05
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
namespace HeavenStudio.Editor
{
public class BoolChartPropertyPrefab : RemixPropertyPrefab
{
[Header("Boolean")]
[Space(10)]
public Toggle toggle;
new public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption)
{
InitProperties(diag, propertyName, caption);
// ' (bool)type ' always results in false
toggle.isOn = Convert.ToBoolean(parameterManager.chart[propertyName]);
toggle.onValueChanged.AddListener(
_ => parameterManager.chart[propertyName] = toggle.isOn
);
}
private void Update()
{
}
}
}

View file

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

View file

@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
namespace HeavenStudio.Editor
{
public class ColorChartPropertyPrefab : RemixPropertyPrefab
{
[Header("Color")]
[Space(10)]
public Button ColorBTN;
public RectTransform ColorTable;
public bool colorTableActive;
public ColorPreview colorPreview;
new public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption)
{
InitProperties(diag, propertyName, caption);
colorPreview.colorPicker.onColorChanged += _ =>
parameterManager.chart[propertyName] = colorPreview.colorPicker.color;
Color paramCol = parameterManager.chart[propertyName];
ColorBTN.onClick.AddListener(
() =>
{
ColorTable.gameObject.SetActive(true);
colorTableActive = true;
colorPreview.ChangeColor(paramCol);
}
);
colorPreview.ChangeColor(paramCol);
ColorTable.gameObject.SetActive(false);
}
private void Update()
{
if (colorTableActive)
{
if (!Editor.MouseInRectTransform(ColorTable))
{
if (Input.GetMouseButtonDown(0))
{
ColorTable.gameObject.SetActive(false);
colorTableActive = false;
}
}
}
}
}
}

View file

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

View file

@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
namespace HeavenStudio.Editor
{
public class EnumChartPropertyPrefab : RemixPropertyPrefab
{
[Header("Dropdown")]
[Space(10)]
public TMP_Dropdown dropdown;
new public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption)
{
InitProperties(diag, propertyName, caption);
var enumType = type.GetType();
var enumVals = Enum.GetValues(enumType);
var enumNames = Enum.GetNames(enumType).ToList();
// Can we assume non-holey enum?
// If we can we can simplify to dropdown.value = (int) parameterManager.chart[propertyName]
var currentlySelected = (int) parameterManager.chart[propertyName];
var selected = enumVals
.Cast<object>()
.ToList()
.FindIndex(val => (int) val == currentlySelected);
dropdown.AddOptions(enumNames);
dropdown.value = selected;
dropdown.onValueChanged.AddListener(_ =>
parameterManager.chart[propertyName] = (int) enumVals.GetValue(dropdown.value)
);
}
private void Update()
{
}
}
}

View file

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

View file

@ -0,0 +1,101 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
namespace HeavenStudio.Editor
{
public class NumberChartPropertyPrefab : RemixPropertyPrefab
{
[Header("Integer and Float")]
[Space(10)]
public Slider slider;
public TMP_InputField inputField;
new public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption)
{
InitProperties(diag, propertyName, caption);
switch (type)
{
case EntityTypes.Integer integer:
slider.minValue = integer.min;
slider.maxValue = integer.max;
slider.wholeNumbers = true;
slider.value = Convert.ToSingle(parameterManager.chart[propertyName]);
inputField.text = slider.value.ToString();
slider.onValueChanged.AddListener(
_ =>
{
inputField.text = slider.value.ToString();
parameterManager.chart[propertyName] = (int) slider.value;
}
);
inputField.onSelect.AddListener(
_ =>
Editor.instance.editingInputField = true
);
inputField.onEndEdit.AddListener(
_ =>
{
slider.value = Convert.ToSingle(inputField.text);
parameterManager.chart[propertyName] = (int) slider.value;
Editor.instance.editingInputField = false;
}
);
break;
case EntityTypes.Float fl:
slider.minValue = fl.min;
slider.maxValue = fl.max;
slider.value = Convert.ToSingle(parameterManager.chart[propertyName]);
inputField.text = slider.value.ToString("G");
slider.onValueChanged.AddListener(
_ =>
{
var newValue = (float) Math.Round(slider.value, 4);
inputField.text = newValue.ToString("G");
parameterManager.chart[propertyName] = newValue;
}
);
inputField.onSelect.AddListener(
_ =>
Editor.instance.editingInputField = true
);
inputField.onEndEdit.AddListener(
_ =>
{
slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4);
parameterManager.chart[propertyName] = slider.value;
Editor.instance.editingInputField = false;
}
);
break;
default:
throw new ArgumentOutOfRangeException(
nameof(type), type, "I don't know how to make a property of this type!"
);
}
}
private void Update()
{
}
}
}

View file

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

View file

@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
using HeavenStudio.Editor;
namespace HeavenStudio.Editor
{
public class StringChartPropertyPrefab : RemixPropertyPrefab
{
[Header("String")] //why wasn't this a thing before
[Space(10)]
public TMP_InputField inputFieldString;
new public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption)
{
InitProperties(diag, propertyName, caption);
inputFieldString.text = (string) parameterManager.chart[propertyName];
inputFieldString.onSelect.AddListener(
_ =>
Editor.instance.editingInputField = true
);
inputFieldString.onEndEdit.AddListener(
_ =>
{;
parameterManager.chart[propertyName] = inputFieldString.text;
Editor.instance.editingInputField = false;
}
);
}
private void Update()
{
}
}
}

View file

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

View file

@ -9,6 +9,18 @@ namespace HeavenStudio.Editor
{
public class RemixPropertiesDialog : Dialog
{
[Header("Editable Properties")]
[SerializeField] string[] infoTags;
[SerializeField] string[] infoLabels;
[SerializeField] string[] flavourTags;
[SerializeField] string[] flavourLabels;
[Header("Containers")]
[SerializeField] ChartInfoProperties infoContainer;
// [SerializeField] ChartFlavourProperties flavourContainer;
public DynamicBeatmap chart;
private void Start() {}
public void SwitchPropertiesDialog()
@ -17,11 +29,46 @@ namespace HeavenStudio.Editor
Editor.instance.canSelect = true;
Editor.instance.inAuthorativeMenu = false;
dialog.SetActive(false);
CleanDialog();
} else {
ResetAllDialogs();
Editor.instance.canSelect = false;
Editor.instance.inAuthorativeMenu = true;
dialog.SetActive(true);
SetupDialog();
}
}
private void SetupDialog() {
chart = GameManager.instance.Beatmap;
string[] tags = infoTags;
string[] labels = infoLabels;
int i = 0;
foreach (string property in tags) {
if (chart.properties.ContainsKey(property)) {
infoContainer.AddParam(this, property, chart.properties[property], labels[i]);
}
else
{
if (property == "divider")
{
//TODO: prefab that's just a dividing line
}
else
{
Debug.LogWarning("Property Menu generation Warning: Property " + property + " not found");
}
}
i++;
}
}
private void CleanDialog() {
foreach (Transform child in dialog.transform) {
Destroy(child.gameObject);
}
}

View file

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
using TMPro;
using Starpelly;
using HeavenStudio.Util;
namespace HeavenStudio.Editor
{
public class RemixPropertyPrefab : MonoBehaviour
{
public TMP_Text caption;
public RemixPropertiesDialog parameterManager;
public string propertyName;
public void SetProperties(RemixPropertiesDialog diag, string propertyName, object type, string caption) {}
public void InitProperties(RemixPropertiesDialog diag, string propertyName, string caption)
{
this.parameterManager = diag;
this.propertyName = propertyName;
this.caption.text = caption;
}
}
}

View file

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

View file

@ -4,14 +4,11 @@ using TMPro;
namespace HeavenStudio.Editor
{
public class ChartInfoProperties : MonoBehaviour
public class ChartInfoProperties : TabsContent
{
[Header("General References")]
[SerializeField] private GameObject propertyHolder;
[Header("Editable Properties")]
[SerializeField] private string[] propertyNames;
[Header("Property Prefabs")]
[SerializeField] private GameObject IntegerP;
[SerializeField] private GameObject FloatP;
@ -20,7 +17,7 @@ namespace HeavenStudio.Editor
[SerializeField] private GameObject ColorP;
[SerializeField] private GameObject StringP;
private void AddParam(string propertyName, object type, string caption, string tooltip = "")
public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, string tooltip = "")
{
GameObject prefab = IntegerP;
GameObject input;
@ -31,43 +28,43 @@ namespace HeavenStudio.Editor
{
prefab = IntegerP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<NumberPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
var property = input.GetComponent<NumberChartPropertyPrefab>();
property.SetProperties(diag, 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);
var property = input.GetComponent<NumberChartPropertyPrefab>();
property.SetProperties(diag, propertyName, type, caption);
}
else if (type is bool)
{
prefab = BooleanP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<BoolPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
var property = input.GetComponent<BoolChartPropertyPrefab>();
property.SetProperties(diag, propertyName, type, caption);
}
else if (objType.IsEnum)
{
prefab = DropdownP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<EnumPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
var property = input.GetComponent<EnumChartPropertyPrefab>();
property.SetProperties(diag, propertyName, type, caption);
}
else if (objType == typeof(Color))
{
prefab = ColorP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<ColorPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
var property = input.GetComponent<ColorChartPropertyPrefab>();
property.SetProperties(diag, propertyName, type, caption);
}
else if (objType == typeof(string))
{
prefab = StringP;
input = InitPrefab(prefab, tooltip);
var property = input.GetComponent<StringPropertyPrefab>();
property.SetProperties(propertyName, type, caption);
var property = input.GetComponent<StringChartPropertyPrefab>();
property.SetProperties(diag, propertyName, type, caption);
}
else
{
@ -88,5 +85,13 @@ namespace HeavenStudio.Editor
return input;
}
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
}
}

View file

@ -12,7 +12,7 @@ using static JSL;
namespace HeavenStudio.Editor
{
public class ControllerSettings : MonoBehaviour
public class ControllerSettings : TabsContent
{
[SerializeField] private TMP_Text numConnectedLabel;
[SerializeField] private TMP_Text currentControllerLabel;
@ -245,5 +245,13 @@ namespace HeavenStudio.Editor
yield return new WaitForSeconds(0.25f);
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
}
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
}
}

View file

@ -9,7 +9,7 @@ using TMPro;
namespace HeavenStudio.Editor
{
public class CreditsLegalSettings : MonoBehaviour
public class CreditsLegalSettings : TabsContent
{
private int SecretCounter = 0;
private bool SecretActive = false;
@ -50,5 +50,13 @@ namespace HeavenStudio.Editor
SecretActive = false;
secretContent.CloseDanceWindow();
}
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
}
}

View file

@ -6,7 +6,7 @@ using TMPro;
namespace HeavenStudio.Editor
{
public class DispAudioSettings : MonoBehaviour
public class DispAudioSettings : TabsContent
{
public TMP_Dropdown resolutionsDropdown;
public GameObject customSetter;
@ -71,5 +71,13 @@ namespace HeavenStudio.Editor
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text) / 100f, 2);
GlobalGameManager.ChangeMasterVolume(volSlider.value);
}
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
}
}

View file

@ -4,7 +4,7 @@ using TMPro;
namespace HeavenStudio.Editor
{
public class EditorSettings : MonoBehaviour
public class EditorSettings : TabsContent
{
public Toggle cursorCheckbox;
@ -16,5 +16,13 @@ namespace HeavenStudio.Editor
GameManager.instance.CursorCam.enabled = Editor.instance.isCursorEnabled;
}
}
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
}
}