grah it's ALMOST DONE

This commit is contained in:
AstrlJelly 2024-02-22 22:36:10 -05:00
parent 1a1ae0135d
commit e2a544f154
11 changed files with 94 additions and 123 deletions

View file

@ -55,6 +55,9 @@ MonoBehaviour:
caption: {fileID: 161819469598736649} caption: {fileID: 161819469598736649}
parameterManager: {fileID: 0} parameterManager: {fileID: 0}
propertyName: propertyName:
minButtonSize: 100
buttonTextRect: {fileID: 1122443660375095479}
buttonRect: {fileID: 1122443659071379076}
buttonText: {fileID: 1122443660375095464} buttonText: {fileID: 1122443660375095464}
--- !u!114 &1492239408036616687 --- !u!114 &1492239408036616687
MonoBehaviour: MonoBehaviour:
@ -233,8 +236,6 @@ GameObject:
- component: {fileID: 1122443659071379079} - component: {fileID: 1122443659071379079}
- component: {fileID: 1122443659071379078} - component: {fileID: 1122443659071379078}
- component: {fileID: 1122443659071379077} - component: {fileID: 1122443659071379077}
- component: {fileID: 3024171755225952565}
- component: {fileID: 5920247012653829200}
m_Layer: 5 m_Layer: 5
m_Name: Button m_Name: Button
m_TagString: Untagged m_TagString: Untagged
@ -260,8 +261,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 527.08514, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 30} m_SizeDelta: {x: 213.47, y: 30}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1122443659071379079 --- !u!222 &1122443659071379079
CanvasRenderer: CanvasRenderer:
@ -357,46 +358,6 @@ MonoBehaviour:
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 0
m_CallState: 2 m_CallState: 2
--- !u!114 &3024171755225952565
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1122443659071379075}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 3
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 1
m_ChildControlHeight: 0
m_ChildScaleWidth: 1
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &5920247012653829200
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1122443659071379075}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0
--- !u!1 &1122443660375095478 --- !u!1 &1122443660375095478
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -408,6 +369,7 @@ GameObject:
- component: {fileID: 1122443660375095479} - component: {fileID: 1122443660375095479}
- component: {fileID: 1122443660375095465} - component: {fileID: 1122443660375095465}
- component: {fileID: 1122443660375095464} - component: {fileID: 1122443660375095464}
- component: {fileID: 1641598248478253416}
m_Layer: 5 m_Layer: 5
m_Name: Text (TMP) m_Name: Text (TMP)
m_TagString: Untagged m_TagString: Untagged
@ -430,9 +392,9 @@ RectTransform:
m_Father: {fileID: 1122443659071379076} m_Father: {fileID: 1122443659071379076}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: -0.2649994, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1122443660375095465 --- !u!222 &1122443660375095465
@ -534,3 +496,17 @@ MonoBehaviour:
m_hasFontAssetChanged: 0 m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0} m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &1641598248478253416
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1122443660375095478}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0

View file

@ -1480,3 +1480,4 @@ MonoBehaviour:
parameterManager: {fileID: 0} parameterManager: {fileID: 0}
propertyName: propertyName:
dropdown: {fileID: 2779900777391844534} dropdown: {fileID: 2779900777391844534}
scrollbar: {fileID: 2779900776400187972}

View file

@ -620,9 +620,9 @@ namespace HeavenStudio
} }
} }
public static void PlaySFXArbitrary(double beat, string game, string name, float pitch, float offset) public static void PlaySFXArbitrary(double beat, string game, string name, float pitch, int offset)
{ {
if (string.IsNullOrEmpty(game) || string.IsNullOrEmpty(name)) return; if (string.IsNullOrEmpty(name)) return;
if (string.IsNullOrEmpty(game)) { if (string.IsNullOrEmpty(game)) {
SoundByte.PlayOneShot(name, beat, pitch, offset: offset); SoundByte.PlayOneShot(name, beat, pitch, offset: offset);
} else { } else {
@ -633,7 +633,6 @@ namespace HeavenStudio
public void PlayAnimationArbitrary(string animator, string animation, float scale) public void PlayAnimationArbitrary(string animator, string animation, float scale)
{ {
// if possible (efficient enough) id like to find the object recursively, but for now this works
Transform animTrans = minigameObj.transform.Find(animator); Transform animTrans = minigameObj.transform.Find(animator);
if (animTrans != null && animTrans.TryGetComponent(out Animator anim)) { if (animTrans != null && animTrans.TryGetComponent(out Animator anim)) {
anim.DoScaledAnimationAsync(animation, scale); anim.DoScaledAnimationAsync(animation, scale);

View file

@ -140,13 +140,11 @@ namespace HeavenStudio.Editor
} }
print(propertyPrefab.name); print(propertyPrefab.name);
GameObject input = Instantiate(propertyPrefab); GameObject input = Instantiate(propertyPrefab, transform);
input.transform.SetParent(this.gameObject.transform);
input.SetActive(true); input.SetActive(true);
input.transform.localScale = Vector3.one; input.transform.localScale = Vector3.one;
if (tooltip != string.Empty) { if (tooltip != string.Empty) {
Debug.Log(PersistentDataManager.gameSettings.showParamTooltips);
if (PersistentDataManager.gameSettings.showParamTooltips) { if (PersistentDataManager.gameSettings.showParamTooltips) {
Tooltip.AddTooltip(input, tooltip); Tooltip.AddTooltip(input, tooltip);
} else { } else {
@ -160,20 +158,6 @@ namespace HeavenStudio.Editor
return input; return input;
} }
// private GameObject InitPrefab(GameObject prefab, string tooltip = "")
// {
// GameObject input = Instantiate(prefab);
// input.transform.SetParent(this.gameObject.transform);
// input.SetActive(true);
// input.transform.localScale = Vector3.one;
// if (tooltip != string.Empty) {
// Tooltip.AddTooltip(input, "", tooltip);
// }
// return input;
// }
private void DestroyParams() private void DestroyParams()
{ {
Editor.instance.editingInputField = false; Editor.instance.editingInputField = false;

View file

@ -1,6 +1,7 @@
using System; using System;
using UnityEngine; using UnityEngine;
using TMPro; using TMPro;
using UnityEngine.UI;
namespace HeavenStudio.Editor namespace HeavenStudio.Editor
{ {
@ -8,7 +9,9 @@ namespace HeavenStudio.Editor
{ {
[Header("Boolean")] [Header("Boolean")]
[Space(10)] [Space(10)]
// public Button buttonObj; public float minButtonSize;
public RectTransform buttonTextRect;
public RectTransform buttonRect;
public TMP_Text buttonText; public TMP_Text buttonText;
public EntityTypes.Button button; public EntityTypes.Button button;
@ -31,15 +34,30 @@ namespace HeavenStudio.Editor
if (text != null) { if (text != null) {
buttonText.text = entity[propertyName] = text; buttonText.text = entity[propertyName] = text;
} }
UpdateCollapse(entity[propertyName]);
} }
// OnClick() already handles this. private void LateUpdate()
// if somebody wants to uncomment this for their thing feel free but it's unused for now -AJ {
// 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) { // if (entity[propertyName] != buttonText.text) {
// buttonText.text = entity[propertyName]; // buttonText.text = entity[propertyName];
// } // }
// }
Debug.Log(buttonTextRect.sizeDelta.x > minButtonSize ? "buttonTextRect.sizeDelta.x : " + buttonTextRect.sizeDelta.x : "minButtonSize : " + minButtonSize);
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]);
}
} }
} }

View file

@ -17,6 +17,7 @@ namespace HeavenStudio.Editor
[Header("Dropdown")] [Header("Dropdown")]
[Space(10)] [Space(10)]
public LeftClickTMP_Dropdown dropdown; public LeftClickTMP_Dropdown dropdown;
public Scrollbar scrollbar;
private int _defaultValue; private int _defaultValue;
@ -32,20 +33,23 @@ namespace HeavenStudio.Editor
{ {
case EntityTypes.Dropdown dropdownEntity: case EntityTypes.Dropdown dropdownEntity:
// entity[propertyName].ChangeValues(dropdownEntity.Values); // entity[propertyName].ChangeValues(dropdownEntity.Values);
_defaultValue = dropdownEntity.defaultValue;
EntityTypes.DropdownObj dropdownObj = entity[propertyName]; EntityTypes.DropdownObj dropdownObj = entity[propertyName];
selected = dropdownObj.currentIndex; selected = dropdownObj.value;
dropdown.AddOptions(dropdownObj.Values); dropdown.AddOptions(dropdownObj.Values);
dropdown.onValueChanged.AddListener(newVal => dropdownObj.currentIndex = newVal); dropdown.onValueChanged.AddListener(newVal => dropdownObj.value = newVal);
dropdownObj.onValueChanged = new Action<List<string>>(newValues => dropdownObj.onValueChanged = new Action<List<string>>(newValues =>
{ {
if (dropdown == null) return; if (dropdown == null) return;
dropdown.ClearOptions(); dropdown.ClearOptions();
dropdown.AddOptions(newValues); dropdown.AddOptions(newValues);
dropdown.enabled = newValues.Count > 0; dropdown.enabled = newValues.Count > 0;
dropdownObj.value = _defaultValue;
}); });
break; break;
case Enum enumEntity: case Enum enumEntity:
Type enumType = enumEntity.GetType(); Type enumType = enumEntity.GetType();
_defaultValue = (int)type;
int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray(); int[] keys = Enum.GetValues(enumType).Cast<int>().ToArray();
selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]); selected = Array.FindIndex(keys, val => val == (int)entity[propertyName]);
@ -76,9 +80,6 @@ namespace HeavenStudio.Editor
private void Update() private void Update()
{ {
var scrollbar = GetComponentInChildren<ScrollRect>()?.verticalScrollbar;
// This is bad but we'll fix it later.
if (scrollbar != null) if (scrollbar != null)
{ {
if (openedDropdown == false) if (openedDropdown == false)

View file

@ -891,7 +891,7 @@ namespace HeavenStudio.Editor.Track
object returnVal = ep[i].parameter switch { object returnVal = ep[i].parameter switch {
EntityTypes.Integer intVal => intVal.val, EntityTypes.Integer intVal => intVal.val,
EntityTypes.Float floatVal => floatVal.val, EntityTypes.Float floatVal => floatVal.val,
EntityTypes.Button buttonVal => buttonVal.label, EntityTypes.Button buttonVal => buttonVal.defaultLabel,
EntityTypes.Dropdown ddVal => new EntityTypes.DropdownObj(ddVal.defaultValue, ddVal.values), EntityTypes.Dropdown ddVal => new EntityTypes.DropdownObj(ddVal.defaultValue, ddVal.values),
_ => ep[i].parameter, _ => ep[i].parameter,
}; };

View file

@ -1176,14 +1176,17 @@ namespace HeavenStudio
}).ToList()); }).ToList());
} }
return game?.displayName ?? "No Game"; return game?.displayName ?? "No Game";
}), "Get Animators", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"), }), "Get Animators", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)", new() {
new((x, _) => { Debug.Log(x.GetType()); return (string)x != "No Game"; }, "animator", "getAnimations")
}),
new Param("animator", new EntityTypes.Dropdown(), "Animator", "Specify which animator in the scene to play an animation on."), new Param("animator", new EntityTypes.Dropdown(), "Animator", "Specify which animator in the scene to play an animation on."),
new Param("getAnimations", new EntityTypes.Button("", e => { new Param("getAnimations", new EntityTypes.Button("", e => {
var gm = GameManager.instance; var gm = GameManager.instance;
Minigame game = gm.GetGameInfo(gm.currentGame); Minigame game = gm.GetGameInfo(gm.currentGame);
string animPath = ((EntityTypes.DropdownObj)e["animator"]).CurrentValue; string animPath = ((EntityTypes.DropdownObj)e["animator"]).CurrentValue;
Debug.Log(animPath);
Animator animator = null; Animator animator = null;
if (animPath != null) { if (!string.IsNullOrEmpty(animPath)) {
var animObj = gm.minigameObj.transform.Find(animPath); var animObj = gm.minigameObj.transform.Find(animPath);
if (animObj != null && animObj.TryGetComponent(out animator) && animator != null) { if (animObj != null && animObj.TryGetComponent(out animator) && animator != null) {
var animations = animator var animations = animator
@ -1194,8 +1197,10 @@ namespace HeavenStudio
((EntityTypes.DropdownObj)e["animation"]).SetValues(animations); ((EntityTypes.DropdownObj)e["animation"]).SetValues(animations);
} }
} }
return animator != null ? animator.name : "N/A"; return animator != null ? animator.name : "";
}), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"), }), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)", new() {
new((x, _) => (string)x != "", "animation", "scale")
}),
new Param("animation", new EntityTypes.Dropdown(), "Animation", "Specify the name of the animation to play."), new Param("animation", new EntityTypes.Dropdown(), "Animation", "Specify the name of the animation to play."),
new Param("scale", new EntityTypes.Float(0, 5, 0.5f), "Animation Scale", "The time scale of the animation. Higher values are faster."), new Param("scale", new EntityTypes.Float(0, 5, 0.5f), "Animation Scale", "The time scale of the animation. Higher values are faster."),
}, },
@ -1207,33 +1212,22 @@ namespace HeavenStudio
new GameAction("play sfx", "Play SFX", 0.5f, false, new GameAction("play sfx", "Play SFX", 0.5f, false,
new List<Param>() new List<Param>()
{ {
new Param("game", new EntityTypes.Dropdown(), "Which Game", "Specify the game's sfx to play. An empty input will play global sfx.", new() { new Param("game", new EntityTypes.Dropdown(), "Which Game", "Specify the game's sfx to play. An empty input will play global sfx."),
new((x, e) => { new Param("getAnimations", new EntityTypes.Button("", e => {
// Minigame game = eventCaller.minigames[((EntityTypes.DropdownObj)x).CurrentValue]; string gameName = ((EntityTypes.DropdownObj)e["game"]).CurrentValue;
string gameName = ((EntityTypes.DropdownObj)e["game"]).CurrentValue; Minigame game = eventCaller.minigames[gameName];
Minigame game = eventCaller.minigames[gameName]; IEnumerable<AudioClip> audioClips = game.GetCommonAssetBundle().LoadAllAssets<AudioClip>();
int startFrom = "assets/resources/sfx/".Length - 1; var localAssBun = game.GetLocalizedAssetBundle();
foreach (var thing in game.GetCommonAssetBundle().GetAllAssetNames()) if (localAssBun != null) {
{ audioClips = audioClips.Concat(localAssBun.LoadAllAssets<AudioClip>());
Debug.Log(thing); }
} EntityTypes.DropdownObj sfxDD = e["sfxName"];
List<string> clips = new() { "" }; sfxDD.SetValues(audioClips.Select(x => x.name).ToList());
foreach (var clip in game.GetCommonAssetBundle().GetAllAssetNames().Concat(game.GetLocalizedAssetBundle().GetAllAssetNames())) return !string.IsNullOrEmpty(gameName) ? eventCaller.minigames[gameName]?.displayName : "N/A";
{ }), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"),
string[] splitClip = clip[startFrom..].Split('/');
if (splitClip[0] == "games" && splitClip[1] == gameName) {
clips.Add(splitClip[2]);
Debug.Log(splitClip[2]);
}
}
EntityTypes.DropdownObj sfxDD = e["sfxName"];
sfxDD.SetValues(clips);
return true;
}),
}),
new Param("sfxName", new EntityTypes.Dropdown(), "SFX Name", "The name of the sfx to play."), new Param("sfxName", new EntityTypes.Dropdown(), "SFX Name", "The name of the sfx to play."),
new Param("pitch", new EntityTypes.Float(0, 5, 1), "Pitch", "The sfx's pitch."), new Param("pitch", new EntityTypes.Float(0, 5, 1), "Pitch", "The sfx's pitch."),
new Param("offset", new EntityTypes.Float(-500, 500), "Offset (ms)", "The sfx's offset in milliseconds."), new Param("offset", new EntityTypes.Integer(-500, 500), "Offset (ms)", "The sfx's offset in milliseconds."),
}, },
preFunction : delegate { preFunction : delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
@ -1250,8 +1244,9 @@ namespace HeavenStudio
LoadMinigames(eventCaller); LoadMinigames(eventCaller);
// im so sorry
eventCaller.minigames["advanced"].actions eventCaller.minigames["advanced"].actions
.Find(a => a.actionName == "play sfx").parameters[0].parameter = new EntityTypes.Dropdown(0, eventCaller.minigames.Keys.Skip(defaultGames.Count).ToArray()); .Find(a => a.actionName == "play sfx").parameters[0].parameter = new EntityTypes.Dropdown(0, eventCaller.minigames.Keys.Skip(defaultGames.Count).Concat(new string[] { "" }).ToArray());
} }
} }
} }

View file

@ -64,12 +64,12 @@ namespace HeavenStudio
public struct Button public struct Button
{ {
public string label; public string defaultLabel;
public Func<RiqEntity, string> onClick; public Func<RiqEntity, string> onClick;
public Button(string defaultLabel, Func<RiqEntity, string> onClick) public Button(string defaultLabel, Func<RiqEntity, string> onClick)
{ {
this.label = defaultLabel; this.defaultLabel = defaultLabel;
this.onClick = onClick; this.onClick = onClick;
} }
} }
@ -90,21 +90,19 @@ namespace HeavenStudio
{ {
public void SetValues(List<string> values) public void SetValues(List<string> values)
{ {
this.Values = values ?? new(); Values = values ?? new();
onValueChanged?.Invoke(values); onValueChanged?.Invoke(values);
} }
public int value; public int value;
public List<string> Values { get; private set; } public List<string> Values { get; private set; }
public int currentIndex; [JsonIgnore] public string CurrentValue => value < Values?.Count - 1 ? Values?[value] : null;
public string CurrentValue => currentIndex < Values?.Count - 1 ? Values?[currentIndex] : null;
[JsonIgnore] public Action<List<string>> onValueChanged; [JsonIgnore] public Action<List<string>> onValueChanged;
public DropdownObj(int value = 0, List<string> values = null) public DropdownObj(int defaultValue = 0, List<string> values = null)
{ {
this.value = value; value = defaultValue;
this.Values = values ?? new(); Values = values ?? new();
currentIndex = 0;
onValueChanged = null; onValueChanged = null;
} }
} }

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Triggers;
namespace HeavenStudio.Util namespace HeavenStudio.Util
{ {

View file

@ -14,7 +14,7 @@ namespace HeavenStudio.Util
static AudioSource oneShotAudioSource; static AudioSource oneShotAudioSource;
static int soundIdx = 0; static int soundIdx = 0;
static Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>(); public static Dictionary<string, AudioClip> audioClips { get; private set; } = new Dictionary<string, AudioClip>();
public enum AudioType public enum AudioType
{ {