Editor ui improvements

This commit is contained in:
Braedon 2022-01-14 17:46:14 -05:00
parent bf7d7110bc
commit c92e369d37
13 changed files with 8258 additions and 3575 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 78e7291cdeccdfc4fa61249845605144
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,23 @@ namespace RhythmHeavenMania.Editor
GridGameSelector.GetComponent<GridGameSelector>().SelectGame("Game Manager", 1); GridGameSelector.GetComponent<GridGameSelector>().SelectGame("Game Manager", 1);
} }
public void Update()
{
// This is buggy
/*if (Conductor.instance.isPlaying || Conductor.instance.isPaused)
{
GetComponent<Selections>().enabled = false;
GetComponent<Selector>().enabled = false;
GetComponent<BoxSelection>().enabled = false;
}
else
{
GetComponent<Selections>().enabled = true;
GetComponent<Selector>().enabled = true;
GetComponent<BoxSelection>().enabled = true;
}*/
}
public static Sprite GameIcon(string name) public static Sprite GameIcon(string name)
{ {
return Resources.Load<Sprite>($"Sprites/Editor/GameIcons/{name}"); return Resources.Load<Sprite>($"Sprites/Editor/GameIcons/{name}");

View File

@ -4,6 +4,9 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using Newtonsoft.Json; using Newtonsoft.Json;
using TMPro;
using Starpelly;
namespace RhythmHeavenMania.Editor namespace RhythmHeavenMania.Editor
{ {
@ -13,7 +16,9 @@ namespace RhythmHeavenMania.Editor
public static Theme theme; public static Theme theme;
[Header("Components")] [Header("Components")]
[SerializeField] private Image[] Layers; [SerializeField] private Image layer;
[SerializeField] private Image tempoLayer;
[SerializeField] private Image musicLayer;
private void Awake() private void Awake()
{ {
@ -22,11 +27,38 @@ namespace RhythmHeavenMania.Editor
private void Start() private void Start()
{ {
tempoLayer.GetComponent<Image>().color = theme.properties.TempoLayerCol.Hex2RGB();
musicLayer.GetComponent<Image>().color = theme.properties.MusicLayerCol.Hex2RGB();
Layers[0].color = Starpelly.Colors.Hex2RGB(theme.properties.Layer1Col); layer.gameObject.SetActive(false);
Layers[1].color = Starpelly.Colors.Hex2RGB(theme.properties.Layer2Col);
Layers[2].color = Starpelly.Colors.Hex2RGB(theme.properties.Layer3Col); for (int i = 0; i < Timeline.instance.LayerCount; i++)
Layers[3].color = Starpelly.Colors.Hex2RGB(theme.properties.Layer4Col); {
GameObject layer = Instantiate(this.layer.gameObject, this.layer.transform.parent);
layer.SetActive(true);
layer.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Layer {i + 1}";
Color c = Color.white;
switch (i)
{
case 0:
c = theme.properties.Layer1Col.Hex2RGB();
break;
case 1:
c = theme.properties.Layer2Col.Hex2RGB();
break;
case 2:
c = theme.properties.Layer3Col.Hex2RGB();
break;
case 3:
c = theme.properties.Layer4Col.Hex2RGB();
break;
}
layer.GetComponent<Image>().color = c;
}
Destroy(layer);
} }
} }

View File

@ -12,6 +12,9 @@ namespace RhythmHeavenMania.Editor
[Serializable] [Serializable]
public class Properties public class Properties
{ {
public string TempoLayerCol;
public string MusicLayerCol;
public string Layer1Col; public string Layer1Col;
public string Layer2Col; public string Layer2Col;
public string Layer3Col; public string Layer3Col;

View File

@ -19,6 +19,7 @@ namespace RhythmHeavenMania.Editor
private Vector2 lastMousePos; private Vector2 lastMousePos;
public List<TimelineEventObj> eventObjs = new List<TimelineEventObj>(); public List<TimelineEventObj> eventObjs = new List<TimelineEventObj>();
private bool lastFrameDrag; private bool lastFrameDrag;
public int LayerCount = 4;
[Header("Timeline Components")] [Header("Timeline Components")]
[SerializeField] private RectTransform TimelineSlider; [SerializeField] private RectTransform TimelineSlider;
@ -26,6 +27,7 @@ namespace RhythmHeavenMania.Editor
[SerializeField] private RectTransform TimelineContent; [SerializeField] private RectTransform TimelineContent;
[SerializeField] private RectTransform TimelineSongPosLineRef; [SerializeField] private RectTransform TimelineSongPosLineRef;
[SerializeField] private RectTransform TimelineEventObjRef; [SerializeField] private RectTransform TimelineEventObjRef;
[SerializeField] private RectTransform LayersRect;
private RectTransform TimelineSongPosLine; private RectTransform TimelineSongPosLine;
public static Timeline instance { get; private set; } public static Timeline instance { get; private set; }
@ -41,7 +43,7 @@ namespace RhythmHeavenMania.Editor
var entity = GameManager.instance.Beatmap.entities[i]; var entity = GameManager.instance.Beatmap.entities[i];
var e = GameManager.instance.Beatmap.entities[i]; var e = GameManager.instance.Beatmap.entities[i];
AddEventObject(e.datamodel, false, new Vector3(e.beat, Mathp.Round2Nearest(Random.Range(0, -205.36f), 51.34f)), i); AddEventObject(e.datamodel, false, new Vector3(e.beat, Mathp.Round2Nearest(Random.Range(0, -LayersRect.rect.height), LayerHeight())), i);
} }
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB(); TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
@ -98,8 +100,8 @@ namespace RhythmHeavenMania.Editor
if (TimelineSongPosLine != null) if (TimelineSongPosLine != null)
{ {
TimelineSongPosLine.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats, TimelineSlider.transform.localPosition.y); TimelineSongPosLine.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats, TimelineSongPosLine.transform.localPosition.y);
TimelineSongPosLine.transform.localScale = new Vector3(1f / TimelineContent.transform.localScale.x, TimelineSlider.transform.localScale.y, 1); TimelineSongPosLine.transform.localScale = new Vector3(1f / TimelineContent.transform.localScale.x, TimelineSongPosLine.transform.localScale.y, 1);
} }
} }
@ -184,7 +186,7 @@ namespace RhythmHeavenMania.Editor
{ {
GameObject g = Instantiate(TimelineEventObjRef.gameObject, TimelineEventObjRef.parent); GameObject g = Instantiate(TimelineEventObjRef.gameObject, TimelineEventObjRef.parent);
g.transform.localPosition = pos; g.transform.localPosition = pos;
g.transform.GetChild(1).GetComponent<TMP_Text>().text = eventName.Split('/')[1]; g.transform.GetChild(2).GetComponent<TMP_Text>().text = eventName.Split('/')[1];
TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>(); TimelineEventObj eventObj = g.GetComponent<TimelineEventObj>();
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0)); eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0));
@ -193,7 +195,7 @@ namespace RhythmHeavenMania.Editor
if (gameAction != null) if (gameAction != null)
{ {
g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, g.GetComponent<RectTransform>().sizeDelta.y); g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight());
float length = gameAction.defaultLength; float length = gameAction.defaultLength;
eventObj.length = length; eventObj.length = length;
} }
@ -222,7 +224,7 @@ namespace RhythmHeavenMania.Editor
var e = GameManager.instance.Beatmap.entities[entityId]; var e = GameManager.instance.Beatmap.entities[entityId];
entity.eventObj = g.GetComponent<TimelineEventObj>(); entity.eventObj = g.GetComponent<TimelineEventObj>();
entity.track = (int)(g.transform.localPosition.y / 51.34f * -1); entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1);
} }
Editor.EventObjs.Add(eventObj); Editor.EventObjs.Add(eventObj);
@ -248,6 +250,17 @@ namespace RhythmHeavenMania.Editor
return Timeline.instance.eventObjs.FindAll(c => c.isDragging == true).Count > 0; return Timeline.instance.eventObjs.FindAll(c => c.isDragging == true).Count > 0;
} }
public float SnapToLayer(float y)
{
float size = LayerHeight();
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3, 0);
}
public float LayerHeight()
{
return LayersRect.rect.height / 4;
}
#endregion #endregion
#region Commands #region Commands

View File

@ -105,7 +105,7 @@ namespace RhythmHeavenMania.Editor
mousePos = Camera.main.ScreenToWorldPoint(mousePos); mousePos = Camera.main.ScreenToWorldPoint(mousePos);
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0); this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.y, 51.34f), -51.34f * 3, 0)); this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
if (lastPos != transform.localPosition) if (lastPos != transform.localPosition)
OnMove(); OnMove();
@ -117,7 +117,7 @@ namespace RhythmHeavenMania.Editor
private void OnMove() private void OnMove()
{ {
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == (int)(this.transform.localPosition.y / 51.34f * -1)).Count > 0) if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack()).Count > 0)
{ {
eligibleToMove = false; eligibleToMove = false;
} }
@ -210,12 +210,13 @@ namespace RhythmHeavenMania.Editor
break; break;
} }
// c = new Color(c.r, c.g, c.b, 0.85f);
transform.GetChild(0).GetComponent<Image>().color = c; transform.GetChild(0).GetComponent<Image>().color = c;
} }
public int GetTrack() public int GetTrack()
{ {
return (int)(this.transform.localPosition.y / 51.34f) * -1; return (int)(this.transform.localPosition.y / Timeline.instance.LayerHeight()) * -1;
} }
private void OnDestroy() private void OnDestroy()

View File

@ -1,11 +1,17 @@
// COLORS BASED ON https://coolors.co/ef476f-ffd166-06d6a0-118ab2-073b4c
{ {
"name": "Rhythm Heaven Mania Default Editor Theme", "name": "Rhythm Heaven Mania Default Editor Theme",
"properties": { "properties": {
"Layer1Col": "E1F1DD", "TempoLayerCol": "f8f7ff",
"Layer2Col": "CDC7BE", "MusicLayerCol": "a663cc",
"Layer3Col": "87A7B3",
"Layer4Col": "766161", "Layer1Col": "ef476f",
"Layer2Col": "ffd166",
"Layer3Col": "06d6a0",
"Layer4Col": "118ab2",
"EventSelectedCol": "ffbc36", "EventSelectedCol": "ffbc36",
"EventNormalCol": "FFFFFF", "EventNormalCol": "FFFFFF",

File diff suppressed because one or more lines are too long