mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 14:57:39 +02:00
Persistent Settings (#234)
* modularize tabs-style menus * make remix properties use modular design * add persistent settings
This commit is contained in:
@ -16,7 +16,24 @@ namespace HeavenStudio.Editor
|
||||
[Header("Containers")]
|
||||
[SerializeField] ChartInfoProperties[] containers;
|
||||
|
||||
public DynamicBeatmap chart;
|
||||
[Header("Tabs")]
|
||||
[SerializeField] private TabsManager.TabsEntry[] tabs;
|
||||
|
||||
[Header("Property Prefabs")]
|
||||
[SerializeField] public GameObject IntegerP;
|
||||
[SerializeField] public GameObject FloatP;
|
||||
[SerializeField] public GameObject BooleanP;
|
||||
[SerializeField] public GameObject DropdownP;
|
||||
[SerializeField] public GameObject ColorP;
|
||||
[SerializeField] public GameObject StringP;
|
||||
|
||||
[Header("Layout Prefabs")]
|
||||
[SerializeField] public GameObject DividerP;
|
||||
[SerializeField] public GameObject HeaderP;
|
||||
[SerializeField] public GameObject SubHeaderP;
|
||||
|
||||
[NonSerialized] public DynamicBeatmap chart;
|
||||
List<GameObject> tabContents;
|
||||
|
||||
private void Start() { }
|
||||
|
||||
@ -24,27 +41,28 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
if (dialog.activeSelf)
|
||||
{
|
||||
tabsManager.CloseContent();
|
||||
Editor.instance.canSelect = true;
|
||||
Editor.instance.inAuthorativeMenu = false;
|
||||
dialog.SetActive(false);
|
||||
|
||||
tabsManager.CleanTabs();
|
||||
tabContents = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetAllDialogs();
|
||||
|
||||
foreach (var container in containers)
|
||||
{
|
||||
container.Init(this);
|
||||
}
|
||||
|
||||
tabsManager.OpenContent();
|
||||
Editor.instance.canSelect = false;
|
||||
Editor.instance.inAuthorativeMenu = true;
|
||||
dialog.SetActive(true);
|
||||
|
||||
chart = GameManager.instance.Beatmap;
|
||||
chart["propertiesmodified"] = true;
|
||||
|
||||
tabContents = tabsManager.GenerateTabs(tabs);
|
||||
foreach (var tab in tabContents)
|
||||
{
|
||||
tab.GetComponent<ChartInfoProperties>().Init(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,56 +26,60 @@ namespace HeavenStudio.Editor
|
||||
[Header("Editable Properties")]
|
||||
[SerializeField] RemixPropertiesDialog.PropertyTag[] tags;
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
public void Init(RemixPropertiesDialog diag)
|
||||
{
|
||||
dialog = diag;
|
||||
dialog.SetupDialog(tags, this);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, bool isReadOnly = false, string tooltip = "")
|
||||
{
|
||||
GameObject prefab = IntegerP;
|
||||
GameObject prefab = diag.IntegerP;
|
||||
GameObject input;
|
||||
|
||||
var objType = type.GetType();
|
||||
|
||||
if (objType == typeof(EntityTypes.Integer))
|
||||
{
|
||||
prefab = IntegerP;
|
||||
prefab = diag.IntegerP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<NumberChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
}
|
||||
else if (objType == typeof(EntityTypes.Float))
|
||||
{
|
||||
prefab = FloatP;
|
||||
prefab = diag.FloatP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<NumberChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
}
|
||||
else if (type is bool)
|
||||
{
|
||||
prefab = BooleanP;
|
||||
prefab = diag.BooleanP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<BoolChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
}
|
||||
else if (objType.IsEnum)
|
||||
{
|
||||
prefab = DropdownP;
|
||||
prefab = diag.DropdownP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<EnumChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
}
|
||||
else if (objType == typeof(Color))
|
||||
{
|
||||
prefab = ColorP;
|
||||
prefab = diag.ColorP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<ColorChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
}
|
||||
else if (objType == typeof(string))
|
||||
{
|
||||
prefab = StringP;
|
||||
prefab = diag.StringP;
|
||||
input = InitPrefab(prefab, tooltip);
|
||||
var property = input.GetComponent<StringChartPropertyPrefab>();
|
||||
property.SetProperties(diag, propertyName, type, caption);
|
||||
@ -89,18 +93,18 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public void AddDivider(RemixPropertiesDialog diag)
|
||||
{
|
||||
InitPrefab(DividerP);
|
||||
InitPrefab(diag.DividerP);
|
||||
}
|
||||
|
||||
public void AddHeader(RemixPropertiesDialog diag, string text)
|
||||
{
|
||||
var input = InitPrefab(HeaderP);
|
||||
var input = InitPrefab(diag.HeaderP);
|
||||
input.GetComponent<RemixPropertyPrefab>().InitProperties(diag, "", text);
|
||||
}
|
||||
|
||||
public void AddSubHeader(RemixPropertiesDialog diag, string text)
|
||||
{
|
||||
var input = InitPrefab(SubHeaderP);
|
||||
var input = InitPrefab(diag.SubHeaderP);
|
||||
input.GetComponent<RemixPropertyPrefab>().InitProperties(diag, "", text);
|
||||
}
|
||||
|
||||
@ -119,11 +123,16 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public override void OnOpenTab()
|
||||
{
|
||||
dialog.SetupDialog(tags, this);
|
||||
if (dialog != null && !initialized)
|
||||
{
|
||||
initialized = true;
|
||||
dialog.SetupDialog(tags, this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCloseTab()
|
||||
{
|
||||
initialized = false;
|
||||
foreach (Transform child in propertyHolder.transform) {
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
Reference in New Issue
Block a user