Tempo change? (Don't update very buggy)

This commit is contained in:
Braedon
2022-01-27 21:50:57 -05:00
parent 8f268f4d60
commit 9185249dd1
36 changed files with 2630 additions and 39 deletions

View File

@ -5,6 +5,8 @@ using UnityEngine.UI;
using Starpelly;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor
{
public class BoxSelection : MonoBehaviour

View File

@ -3,11 +3,14 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor.Commands
{
public class Selection : IAction
{
List<TimelineEventObj> eventObjs;
List<TimelineEventObj> lastEventObjs;
public Selection(List<TimelineEventObj> eventObjs)
{
@ -20,14 +23,15 @@ namespace RhythmHeavenMania.Editor.Commands
public void Redo()
{
for (int i = 0; i < eventObjs.Count; i++)
for (int i = 0; i < lastEventObjs.Count; i++)
{
Selections.instance.ShiftClickSelect(eventObjs[i]);
Selections.instance.ShiftClickSelect(lastEventObjs[i]);
}
}
public void Undo()
{
lastEventObjs = eventObjs;
for (int i = 0; i < eventObjs.Count; i++)
{
Selections.instance.ShiftClickSelect(eventObjs[i]);
@ -102,6 +106,7 @@ namespace RhythmHeavenMania.Editor.Commands
public class Place : IAction
{
TimelineEventObj eventObj;
TimelineEventObj deletedObj;
public Place(TimelineEventObj eventObj)
{
@ -114,11 +119,12 @@ namespace RhythmHeavenMania.Editor.Commands
public void Redo()
{
throw new System.NotImplementedException();
deletedObj = Timeline.instance.AddEventObject(deletedObj.entity.datamodel, false, new Vector3(deletedObj.entity.beat, -deletedObj.entity.track * Timeline.instance.LayerHeight()), deletedObj.entity, true, deletedObj.entity.eventObj.eventObjID);
}
public void Undo()
{
deletedObj = eventObj;
Selections.instance.Deselect(eventObj);
Timeline.instance.DestroyEventObject(eventObj.entity);
// Beatmap.Entity e = deletedObjs[i].entity;

View File

@ -8,6 +8,8 @@ using Newtonsoft.Json;
using TMPro;
using Starpelly;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor
{
public class Editor : MonoBehaviour
@ -125,7 +127,10 @@ namespace RhythmHeavenMania.Editor
for (int i = 0; i < selectedEvents.Count; i++)
{
result.Add(selectedEvents[i]);
if (selectedEvents[i].isCreating == false)
{
result.Add(selectedEvents[i]);
}
selectedEvents[i].OnUp();
}
CommandManager.instance.Execute(new Commands.Move(result));

View File

@ -8,6 +8,8 @@ using TMPro;
using Starpelly;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor
{
public class EditorTheme : MonoBehaviour

View File

@ -7,6 +7,8 @@ using TMPro;
using DG.Tweening;
using Starpelly;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor
{
public class GridGameSelector : MonoBehaviour
@ -170,7 +172,10 @@ namespace RhythmHeavenMania.Editor
{
eventObj = Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0), null, true, Timeline.RandomID());
}
CommandManager.instance.Execute(new Commands.Place(eventObj));
eventObj.isCreating = true;
// CommandManager.instance.Execute(new Commands.Place(eventObj));
}
}

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using RhythmHeavenMania.Editor.Track;
namespace RhythmHeavenMania.Editor
{
public class Selections : MonoBehaviour

View File

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

View File

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using Starpelly;
namespace RhythmHeavenMania.Editor.Track
{
public class TempoTimeline : MonoBehaviour
{
[Header("Components")]
private RectTransform rectTransform;
[SerializeField] private RectTransform RefTempoChange;
private void Start()
{
rectTransform = this.GetComponent<RectTransform>();
}
private void Update()
{
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))
{
if (Input.GetMouseButtonDown(0))
{
AddTempoChange();
}
}
}
private void AddTempoChange()
{
GameObject tempoChange = Instantiate(RefTempoChange.gameObject, this.transform);
tempoChange.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
tempoChange.transform.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
tempoChange.transform.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
tempoChange.SetActive(true);
tempoChange.transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, tempoChange.transform.position.y);
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, 0.25f), tempoChange.transform.localPosition.y);
TempoTimelineObj tempoTimelineObj = tempoChange.AddComponent<TempoTimelineObj>();
Beatmap.TempoChange tempoC = new Beatmap.TempoChange();
tempoC.beat = tempoChange.transform.localPosition.x;
tempoC.tempo = GameManager.instance.Beatmap.bpm;
tempoTimelineObj.tempoChange = tempoC;
GameManager.instance.Beatmap.tempoChanges.Add(tempoC);
}
}
}

View File

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

View File

@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace RhythmHeavenMania.Editor.Track
{
public class TempoTimelineObj : MonoBehaviour
{
[Header("Components")]
[SerializeField] private RectTransform rectTransform;
[SerializeField] private TMP_Text tempoTXT;
public Beatmap.TempoChange tempoChange;
private void Start()
{
rectTransform = GetComponent<RectTransform>();
tempoTXT = transform.GetChild(2).GetComponent<TMP_Text>();
UpdateTempo();
}
private void Update()
{
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))
{
float newTempo = Input.mouseScrollDelta.y;
if (Input.GetKey(KeyCode.LeftShift))
newTempo *= 5f;
if (Input.GetKey(KeyCode.LeftControl))
newTempo /= 100f;
tempoChange.tempo += newTempo;
}
UpdateTempo();
}
private void UpdateTempo()
{
tempoTXT.text = $"{tempoChange.tempo} BPM";
}
}
}

View File

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

View File

@ -6,13 +6,15 @@ using UnityEngine.UI;
using TMPro;
using Starpelly;
namespace RhythmHeavenMania.Editor
namespace RhythmHeavenMania.Editor.Track
{
public class Timeline : MonoBehaviour
{
[Header("Song Positions")]
[SerializeField] private TMP_Text SongBeat;
[SerializeField] private TMP_Text SongPos;
[SerializeField] private TMP_Text CurrentTempo;
[SerializeField] private RectTransform StartingBPM;
[Header("Timeline Properties")]
private float lastBeatPos = 0;
@ -38,11 +40,19 @@ namespace RhythmHeavenMania.Editor
public Button StopBTN;
public Button MetronomeBTN;
public Button AutoplayBTN;
public Button SelectionsBTN;
public Button TempoChangeBTN;
public Button MusicVolumeBTN;
public static Timeline instance { get; private set; }
#region Initializers
public void UpdateLevelInfo()
{
StartingBPM.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
}
public void Init()
{
instance = this;
@ -106,6 +116,10 @@ namespace RhythmHeavenMania.Editor
}
});
Tooltip.AddTooltip(SongBeat.gameObject, "Current Beat");
Tooltip.AddTooltip(SongPos.gameObject, "Current Time");
Tooltip.AddTooltip(CurrentTempo.gameObject, "Current Tempo (BPM)");
Tooltip.AddTooltip(PlayBTN.gameObject, "Play <color=#adadad>[Space]</color>");
Tooltip.AddTooltip(PauseBTN.gameObject, "Pause <color=#adadad>[Shift + Space]</color>");
Tooltip.AddTooltip(StopBTN.gameObject, "Stop <color=#adadad>[Space]</color>");
@ -113,8 +127,14 @@ namespace RhythmHeavenMania.Editor
Tooltip.AddTooltip(MetronomeBTN.gameObject, "Metronome");
Tooltip.AddTooltip(AutoplayBTN.gameObject, "Autoplay");
Tooltip.AddTooltip(SelectionsBTN.gameObject, "Tool: Selection <color=#adadad>[1]</color>");
Tooltip.AddTooltip(TempoChangeBTN.gameObject, "Tool: Tempo Change <color=#adadad>[2]</color>");
Tooltip.AddTooltip(MusicVolumeBTN.gameObject, "Tool: Music Volume <color=#adadad>[3]</color>");
SetTimeButtonColors(true, false, false);
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
UpdateLevelInfo();
}
public static string RandomID()
@ -179,6 +199,20 @@ namespace RhythmHeavenMania.Editor
TimelineContent.transform.localPosition = new Vector3((-Conductor.instance.songPositionInBeats * 100) + 200, TimelineContent.transform.localPosition.y);
TimelineContent.transform.localPosition = new Vector3(Mathf.Clamp(TimelineContent.transform.localPosition.x, Mathf.NegativeInfinity, 0), TimelineContent.transform.localPosition.y);
CurrentTempo.text = $" = {Conductor.instance.songBpm}";
if (RectTransformUtility.RectangleContainsScreenPoint(StartingBPM, Input.mousePosition, Camera.main))
{
float increase = Input.mouseScrollDelta.y;
if (Input.GetKey(KeyCode.LeftControl))
increase /= 100f;
if (Input.GetKey(KeyCode.LeftShift))
increase *= 5f;
GameManager.instance.Beatmap.bpm += increase;
UpdateLevelInfo();
}
}
private void SliderControl()

View File

@ -6,7 +6,7 @@ using UnityEngine.UI;
using Starpelly;
using DG.Tweening;
namespace RhythmHeavenMania.Editor
namespace RhythmHeavenMania.Editor.Track
{
public class TimelineEventObj : MonoBehaviour
{
@ -41,6 +41,7 @@ namespace RhythmHeavenMania.Editor
private bool resizingRight;
private bool inResizeRegion;
public Vector2 lastMovePos;
public bool isCreating;
public string eventObjID;
[Header("Colors")]
@ -238,13 +239,17 @@ namespace RhythmHeavenMania.Editor
{
if (eligibleToMove)
{
OnComplete(true);
}
moving = false;
Cancel();
if (isCreating == true)
{
isCreating = false;
CommandManager.instance.Execute(new Commands.Place(this));
}
}
}

View File

@ -16,8 +16,8 @@
"EventSelectedCol": "61e5ff",
"EventNormalCol": "FFFFFF",
"BeatMarkerCol": "61e5ff",
"CurrentTimeMarkerCol": "61e5ff",
"BeatMarkerCol": "32FF32",
"CurrentTimeMarkerCol": "32FF32",
"BoxSelectionCol": "61e5ff",
"BoxSelectionOutlineCol": "61e5ff"