From 7b1269d155f69efab76c38eaac4b6b26fccf053a Mon Sep 17 00:00:00 2001
From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com>
Date: Wed, 16 Aug 2023 13:00:27 +0200
Subject: [PATCH] Collapseable Properties Functionality (#534)
* all done
* oop
* two quick tweaks
---
.../Scripts/Games/SpaceSoccer/SpaceSoccer.cs | 29 +++++++----
.../EventSelector/EventParameterManager.cs | 24 +++++++--
.../EventSelector/EventPropertyPrefab.cs | 25 ++++++++++
.../PropertyPrefabs/BoolPropertyPrefab.cs | 8 +++
.../PropertyPrefabs/ColorPropertyPrefab.cs | 6 +++
.../PropertyPrefabs/EnumPropertyPrefab.cs | 9 +++-
.../PropertyPrefabs/NumberPropertyPrefab.cs | 50 +++++++++++++++++++
.../PropertyPrefabs/StringPropertyPrefab.cs | 10 ++++
Assets/Scripts/Minigames.cs | 20 +++++++-
9 files changed, 166 insertions(+), 15 deletions(-)
diff --git a/Assets/Scripts/Games/SpaceSoccer/SpaceSoccer.cs b/Assets/Scripts/Games/SpaceSoccer/SpaceSoccer.cs
index 9617cf94..f9a0ea19 100644
--- a/Assets/Scripts/Games/SpaceSoccer/SpaceSoccer.cs
+++ b/Assets/Scripts/Games/SpaceSoccer/SpaceSoccer.cs
@@ -20,7 +20,7 @@ namespace HeavenStudio.Games.Loaders
new Param("toggle", false, "Disable Sound", "Disables the dispense sound"),
new Param("down", false, "Down Sound", "Will the Down sound be played?")
},
- inactiveFunction = delegate
+ inactiveFunction = delegate
{
if (!eventCaller.currentEntity["toggle"]) { SpaceSoccer.DispenseSound(eventCaller.currentEntity.beat, eventCaller.currentEntity["down"]);}
}
@@ -39,13 +39,19 @@ namespace HeavenStudio.Games.Loaders
defaultLength = 4f,
parameters = new List()
{
- new Param("preset", SpaceSoccer.EnterExitPresets.FiveKickers, "Preset", "Which preset should be used?"),
- new Param("choice", SpaceSoccer.AnimationToPlay.Enter, "Enter Or Exit", "Whether the kickers should exit or enter."),
- new Param("ease", EasingFunction.Ease.Linear, "Ease", "The Ease of the entering or exiting."),
+ new Param("preset", SpaceSoccer.EnterExitPresets.FiveKickers, "Preset", "Which preset should be used?", new List()
+ {
+ new Param.CollapseParam(x => (int)x == (int)SpaceSoccer.EnterExitPresets.Custom, new string[] { "amount", "x", "y", "z" })
+ }),
+
+
new Param("amount", new EntityTypes.Integer(2, 30, 5), "Amount", "Amount of Space Kickers."),
new Param("x", new EntityTypes.Float(-30, 30, 2f), "X Distance", "How much distance should there be between the space kickers on the x axis?"),
new Param("y", new EntityTypes.Float(-30, 30, -0.5f), "Y Distance", "How much distance should there be between the space kickers on the y axis?"),
new Param("z", new EntityTypes.Float(-30, 30, 1.25f), "Z Distance", "How much distance should there be between the space kickers on the z axis?"),
+
+ new Param("choice", SpaceSoccer.AnimationToPlay.Enter, "Enter Or Exit", "Whether the kickers should exit or enter."),
+ new Param("ease", EasingFunction.Ease.Linear, "Ease", "The Ease of the entering or exiting."),
new Param("override", true, "Override Easing", "Should this block override the easing of the space kickers' positions?")
},
resizable = true
@@ -70,7 +76,10 @@ namespace HeavenStudio.Games.Loaders
resizable = true,
parameters = new List()
{
- new Param("preset", SpaceSoccer.PlayerPresets.LaunchStart, "Preset", "Which preset should be used?"),
+ new Param("preset", SpaceSoccer.PlayerPresets.LaunchStart, "Preset", "Which preset should be used?", new List()
+ {
+ new Param.CollapseParam(x => (int)x == (int)SpaceSoccer.PlayerPresets.Custom, new string[] { "x", "y", "z", "ease", "sound" })
+ }),
new Param("x", new EntityTypes.Float(-30, 30, 0f), "X Pos", "Which position should the player move to on the x axis?"),
new Param("y", new EntityTypes.Float(-30, 30, 0f), "Y Pos", "Which position should the player move to on the y axis?"),
new Param("z", new EntityTypes.Float(-30, 30, 0f), "Z Pos", "Which position should the player move to on the z axis?"),
@@ -92,7 +101,7 @@ namespace HeavenStudio.Games.Loaders
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease")
}
},
- new GameAction("scroll", "Scrolling Background")
+ new GameAction("scroll", "Scrolling Background")
{
function = delegate { var e = eventCaller.currentEntity; SpaceSoccer.instance.UpdateScrollSpeed(e["x"], e["y"]); },
defaultLength = 1f,
@@ -118,8 +127,8 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("npc kickers instant enter or exit", "NPC Kickers Instant Enter or Exit")
{
- function = delegate
- {
+ function = delegate
+ {
var e = eventCaller.currentEntity;
int choice;
if (e["toggle"])
@@ -140,9 +149,9 @@ namespace HeavenStudio.Games.Loaders
hidden = true
},
},
- new List() {"ntr", "keep"},
+ new List() { "ntr", "keep" },
"ntrsoccer", "en",
- new List() {"en"}
+ new List() { "en" }
);
}
}
diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs
index 67494a26..17650d81 100644
--- a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs
+++ b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs
@@ -94,14 +94,31 @@ namespace HeavenStudio.Editor
DestroyParams();
+ Dictionary ePrefabs = new();
+
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));
+ }
- AddParam(propertyName, param, caption, tooltip);
+ foreach (var p in action.parameters)
+ {
+ if (p.collapseParams == null) return;
+ EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent();
+ foreach (var c in p.collapseParams)
+ {
+ List collapseables = new();
+ foreach (var s in c.collapseables)
+ {
+ collapseables.Add(ePrefabs[s]);
+ }
+ input.propertyCollapses.Add(new EventPropertyPrefab.PropertyCollapse(collapseables, c.CollapseOn));
+ }
+ input.SetCollapses(p.parameter);
}
active = true;
@@ -112,7 +129,7 @@ namespace HeavenStudio.Editor
}
}
- private void AddParam(string propertyName, object type, string caption, string tooltip = "")
+ private GameObject AddParam(string propertyName, object type, string caption, string tooltip = "")
{
GameObject prefab = IntegerP;
GameObject input;
@@ -164,8 +181,9 @@ namespace HeavenStudio.Editor
else
{
Debug.LogError("Can't make property interface of type: " + type.GetType());
- return;
+ return null;
}
+ return input;
}
private GameObject InitPrefab(GameObject prefab, string tooltip = "")
diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs
index 91af6a2f..606baf30 100644
--- a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs
+++ b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs
@@ -16,8 +16,10 @@ namespace HeavenStudio.Editor
public TMP_Text caption;
public EventParameterManager parameterManager;
public string propertyName;
+ public List propertyCollapses = new List();
public void SetProperties(string propertyName, object type, string caption) {}
+ public virtual void SetCollapses(object type) { }
public void InitProperties(string propertyName, string caption)
{
@@ -25,5 +27,28 @@ namespace HeavenStudio.Editor
this.propertyName = propertyName;
this.caption.text = caption;
}
+
+ public void UpdateCollapse(object type)
+ {
+ foreach (var p in propertyCollapses)
+ {
+ foreach (var c in p.collapseables)
+ {
+ c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
+ }
+ }
+ }
+
+ public class PropertyCollapse
+ {
+ public List collapseables;
+ public Func