Editor Refresh (R1) (#911)

* put things in better places

oh this looks. so much fucking better. wow

* new icons and stuff

* modifier, zoom formula, tab name

tab name is future proofing.
also, dllnotfoundexception when using the file explorer? wtf

* dialog placement mostly working

basically ready to pr. just gotta merge stuff into it

* a few tweaks! all good now

---------

Co-authored-by: ev <85412919+iloveoatmeal2022@users.noreply.github.com>
This commit is contained in:
AstrlJelly
2024-05-08 15:26:43 -04:00
committed by minenice55
parent d8a99fb160
commit 8ae5a80c0d
36 changed files with 6873 additions and 2285 deletions

View File

@ -9,7 +9,8 @@ namespace HeavenStudio.Editor
{
public class Dialog : MonoBehaviour
{
public bool IsOpen { get { return dialog.activeSelf; } }
public bool IsOpen => dialog.activeSelf;
[SerializeField] internal RectTransform rectTransform;
[SerializeField] protected GameObject dialog;
public void ForceState(bool onoff = false)
{
@ -26,5 +27,26 @@ namespace HeavenStudio.Editor
dialog.ForceState(false);
}
}
public void SwitchDialogue()
{
if (dialog.activeSelf) {
dialog.SetActive(false);
} else {
ResetAllDialogs();
dialog.SetActive(true);
}
}
public void SetPosRelativeToButtonPos(RectTransform buttonRect, Vector2? relativePos = null)
{
// janky? maybe. does it work? you bet it does
rectTransform.SetParent(buttonRect);
rectTransform.localPosition = relativePos ?? new Vector2(210, 120);
// rectTransform.localPosition = new Vector2((rectTransform.rect.width - buttonRect.rect.width) / 2, (rectTransform.rect.height + buttonRect.rect.height) / 2);
// rectTransform.offsetMin = Vector2.up * (buttonRect.rect.height + 7);
rectTransform.SetParent(Editor.instance.MainCanvas.transform, true);
}
}
}

View File

@ -16,6 +16,10 @@ using Jukebox;
using UnityEditor;
using System.Linq;
using BurstLinq;
using HeavenStudio.InputSystem;
using UnityEngine.U2D;
using UnityEditor.U2D;
using UnityEditor.Sprites;
namespace HeavenStudio.Editor
{
@ -89,9 +93,13 @@ namespace HeavenStudio.Editor
public static Editor instance { get; private set; }
private void Start()
private void Awake()
{
instance = this;
}
private void Start()
{
Initializer = GetComponent<GameInitializer>();
canSelect = true;
}
@ -127,7 +135,7 @@ namespace HeavenStudio.Editor
GameIcon_.GetComponent<Image>().sprite = GameIcon(minigame.name);
GameIcon_.GetComponent<GridGameSelectorGame>().MaskTex = GameIconMask(minigame.name);
GameIcon_.GetComponent<GridGameSelectorGame>().UnClickIcon();
GameIcon_.gameObject.SetActive(true);
GameIcon_.SetActive(true);
GameIcon_.name = minigame.name;
var ggs = GridGameSelectorRect.GetComponent<GridGameSelector>();
@ -178,7 +186,7 @@ namespace HeavenStudio.Editor
CommandManager.Instance.AddCommand(new Commands.Delete(Selections.instance.eventsSelected.Select(c => c.entity.guid).ToList()));
}
if (Input.GetKey(KeyCode.LeftControl) && !fullscreen)
if (Input.GetKey(InputKeyboard.MODIFIER) && !fullscreen)
{
if (Input.GetKeyDown(KeyCode.Z))
{
@ -213,7 +221,7 @@ namespace HeavenStudio.Editor
}
}
if (Input.GetKey(KeyCode.LeftControl))
if (Input.GetKey(InputKeyboard.MODIFIER))
{
if (Input.GetKeyDown(KeyCode.N))
{
@ -248,24 +256,12 @@ namespace HeavenStudio.Editor
#endregion
// Undo+Redo
if (CommandManager.Instance.CanUndo())
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
else
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (CommandManager.Instance.CanRedo())
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
else
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = CommandManager.Instance.CanUndo() ? Color.white : Color.gray;
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = CommandManager.Instance.CanRedo() ? Color.white : Color.gray;
// Copy+Paste
if (Selections.instance.eventsSelected.Count > 0)
CopyBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
else
CopyBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (Timeline.instance.CopiedEntities.Count > 0)
PasteBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
else
PasteBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
CopyBTN.transform.GetChild(0).GetComponent<Image>().color = Selections.instance.eventsSelected.Count > 0 ? Color.white : Color.gray;
PasteBTN.transform.GetChild(0).GetComponent<Image>().color = Timeline.instance.CopiedEntities.Count > 0 ? Color.white : Color.gray;
}
public static Sprite GameIcon(string name)
@ -350,37 +346,29 @@ namespace HeavenStudio.Editor
public void SaveRemix(bool saveAs = true)
{
Debug.Log(GameManager.instance.Beatmap["propertiesmodified"]);
if (!(bool)GameManager.instance.Beatmap["propertiesmodified"])
{
foreach (var dialog in Dialogs)
{
if (dialog.GetType() == typeof(RemixPropertiesDialog))
if (dialog is not null and RemixPropertiesDialog propDialog)
{
if (fullscreen) Fullscreen();
GlobalGameManager.ShowErrorMessage("Set Remix Properties", "Set remix properties before saving.");
(dialog as RemixPropertiesDialog).SwitchPropertiesDialog();
(dialog as RemixPropertiesDialog).SetSaveOnClose(true, saveAs);
propDialog.SwitchPropertiesDialog();
propDialog.SetSaveOnClose(true, saveAs);
return;
}
}
}
else
{
if (saveAs)
if (saveAs || string.IsNullOrEmpty(currentRemixPath))
{
SaveRemixFilePanel();
}
else
{
if (currentRemixPath is "" or null)
{
SaveRemixFilePanel();
}
else
{
SaveRemixFile(currentRemixPath);
}
SaveRemixFile(currentRemixPath);
}
}
}
@ -421,7 +409,7 @@ namespace HeavenStudio.Editor
public void NewRemix()
{
if (Timeline.instance != null)
Timeline.instance?.Stop(0);
Timeline.instance.Stop(0);
else
GameManager.instance.Stop(0);
LoadRemix(true);

View File

@ -82,7 +82,8 @@ namespace HeavenStudio.Editor
eventSelector.SetActive(true);
DestroyParams();
Editor.instance.SetGameEventTitle($"Select game event for {gridGameSelector.SelectedMinigame.displayName.Replace("\n", "")}");
// Editor.instance.SetGameEventTitle($"Select game event for {gridGameSelector.SelectedMinigame.displayName.Replace("\n", "")}");
Editor.instance?.SetGameEventTitle(gridGameSelector.SelectedMinigame.displayName.Replace("\n", ""));
}
public void StartParams(RiqEntity entity)
@ -95,8 +96,7 @@ namespace HeavenStudio.Editor
{
string[] split = entity.datamodel.Split('/');
var minigame = EventCaller.instance.GetMinigame(split[0]);
int actionIndex = minigame.actions.IndexOf(minigame.actions.Find(c => c.actionName == split[1]));
Minigames.GameAction action = minigame.actions[actionIndex];
Minigames.GameAction action = minigame.actions.Find(c => c.actionName == split[1]);
if (action.parameters != null)
{
@ -111,7 +111,13 @@ namespace HeavenStudio.Editor
4 => EditorTheme.theme.properties.Layer5Col,
_ => EditorTheme.theme.properties.Layer1Col
};
Editor.instance.SetGameEventTitle($"Properties for <color=#{col}>{action.displayName}</color> on Beat {entity.beat.ToString("F2")} on <color=#{col}>Track {(int)entity["track"] + 1}</color>");
string gameName = action.displayName;
const int cutOff = 20;
if (gameName.Length > (cutOff + 3)) {
gameName = gameName[..cutOff] + "...";
}
Editor.instance.SetGameEventTitle($"<color=#{col}>{gameName}</color> at ♪ {entity.beat:F2} on <color=#{col}>Track {(int)entity["track"] + 1}</color>");
DestroyParams();

View File

@ -11,10 +11,14 @@ using DG.Tweening;
using HeavenStudio.Util;
using HeavenStudio.Editor.Track;
using System.Text;
using System.Configuration;
using System;
using HeavenStudio.InputSystem;
using UnityEngine.U2D;
namespace HeavenStudio.Editor
{
// I hate the antichrist.
// I LOVE the antichrist!
public class GridGameSelector : MonoBehaviour
{
public Minigames.Minigame SelectedMinigame;
@ -33,8 +37,10 @@ namespace HeavenStudio.Editor
[Header("Properties")]
[SerializeField] private int currentEventIndex;
public List<RectTransform> mgsActive = new List<RectTransform>();
public List<RectTransform> fxActive = new List<RectTransform>();
public Texture Square;
public Texture Circle;
public List<RectTransform> mgsActive = new();
public List<RectTransform> fxActive = new();
public float posDif;
public int ignoreSelectCount;
private int dragTimes;
@ -45,9 +51,13 @@ namespace HeavenStudio.Editor
public static GridGameSelector instance;
private void Start()
private void Awake()
{
instance = this;
}
private void Start()
{
GameEventSelectorRect = GameEventSelector.GetComponent<RectTransform>();
selectorHeight = GameEventSelectorRect.rect.height;
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
@ -159,7 +169,8 @@ namespace HeavenStudio.Editor
currentEventIndex = index;
UpdateIndex(index, false);
Editor.instance?.SetGameEventTitle($"Select game event for {SelectedMinigame.displayName.Replace("\n", "")}");
// Editor.instance?.SetGameEventTitle($"Select game event for {SelectedMinigame.displayName.Replace("\n", "")}");
if (Editor.instance != null) Editor.instance.SetGameEventTitle(SelectedMinigame.displayName.Replace("\n", ""));
}
private void AddEvents(int index = 0)
@ -169,7 +180,9 @@ namespace HeavenStudio.Editor
GameObject sg = Instantiate(EventRef, eventsParent);
sg.GetComponentInChildren<TMP_Text>().text = "Switch Game";
sg.SetActive(true);
if (index == 0) sg.GetComponentInChildren<TMP_Text>().color = EditorTheme.theme.properties.EventSelectedCol.Hex2RGB();
if (index == 0) {
sg.GetComponentInChildren<TMP_Text>().color = EditorTheme.theme.properties.EventSelectedCol.Hex2RGB();
}
} else {
index++;
if (SelectedMinigame.name == "gameManager") index++;
@ -185,13 +198,12 @@ namespace HeavenStudio.Editor
label.text = action.displayName;
if (action.parameters != null && action.parameters.Count > 0)
g.transform.GetChild(1).gameObject.SetActive(true);
g.transform.GetChild(0).GetChild(0).gameObject.SetActive(true);
if (index - 1 == i)
label.color = EditorTheme.theme.properties.EventSelectedCol.Hex2RGB();
g.SetActive(true);
}
}
@ -232,61 +244,65 @@ namespace HeavenStudio.Editor
}
}
// TODO: find the equation to get the sizes automatically, nobody's been able to figure one out yet (might have to be manual?)
public void Zoom()
{
if (!Input.GetKey(KeyCode.LeftControl)) return;
if (!Input.GetKey(InputKeyboard.MODIFIER)) return;
var glg = GetComponent<GridLayoutGroup>();
var sizes = new List<float>() {
209.5f,
102.3f,
66.6f,
48.6f,
37.9f,
30.8f,
25.7f,
//21.9f,
};
int max = 20; // arbitrary
if (glg.constraintCount + 1 > sizes.Count && Input.GetAxisRaw("Mouse ScrollWheel") < 0) return;
if (glg.constraintCount + 1 > max && Input.mouseScrollDelta.y < 0) return;
glg.constraintCount += (Input.GetAxisRaw("Mouse ScrollWheel") > 0) ? -1 : 1;
glg.cellSize = Vector2.one * sizes[glg.constraintCount - 1];
glg.constraintCount += (Input.mouseScrollDelta.y > 0) ? -1 : 1;
// thanks to blank3times (tri) for helping me with this
var size = (1 / (0.00317 * glg.constraintCount)) - 4.75248;
// this, however, doesn't work
// var totalWidth = Editor.instance.GridGameSelectorRect.rect.width;
// var size = (totalWidth - glg.padding.right) * (glg.constraintCount + 1) / glg.constraintCount;
glg.cellSize = Vector2.one * (float)size;
}
// method called when clicking the sort button in the editor, skips sorting fx only "games"
// sorts depending on which sorting button you click
public void Sort(string type)
{
var mgsSort = mgsActive;
List<RectTransform> mgsSort = mgsActive;
mgsSort.Sort((x, y) => string.Compare(x.name, y.name));
switch (type)
{
case "favorites":
SortFavorites(mgsSort);
break;
case "chronologic":
SortChronologic(mgsSort);
break;
default: // "alphabet"
SortAlphabet(mgsSort);
break;
}
Action<List<RectTransform>> action = type switch {
"favorites" => SortFavorites,
"chronologic" => SortChronologic,
"usage" => SortUsage,
_ => SortAlphabet
};
action.Invoke(mgsSort);
}
void SortAlphabet(List<RectTransform> mgs)
{
for (int i = 0; i < mgsActive.Count; i++) {
mgs[i].SetSiblingIndex(i + fxActive.Count + 1);
List<RectTransform> alph = mgs.OrderBy(AlphabetSortKey).ToList();
for (int i = 0; i < alph.Count; i++) {
alph[i].SetSiblingIndex(i + fxActive.Count + 1);
}
}
string AlphabetSortKey(RectTransform minigame)
{
Minigames.Minigame mg = EventCaller.instance.GetMinigame(minigame.name);
if (mg.displayName.StartsWith("the ", StringComparison.InvariantCultureIgnoreCase))
return mg.displayName[4..];
else
return mg.displayName;
}
// if there are no favorites, the games will sort alphabetically
void SortFavorites(List<RectTransform> allMgs)
{
var favs = allMgs.FindAll(mg => mg.GetComponent<GridGameSelectorGame>().StarActive);
var mgs = allMgs.FindAll(mg => !mg.GetComponent<GridGameSelectorGame>().StarActive);
List<RectTransform> favs = allMgs.FindAll(mg => mg.GetComponent<GridGameSelectorGame>().StarActive).OrderBy(AlphabetSortKey).ToList();
List<RectTransform> mgs = allMgs.FindAll(mg => !mg.GetComponent<GridGameSelectorGame>().StarActive).OrderBy(AlphabetSortKey).ToList();
if (Input.GetKey(KeyCode.LeftShift)) {
foreach (var fav in favs)
@ -304,43 +320,49 @@ namespace HeavenStudio.Editor
void SortChronologic(List<RectTransform> mgs)
{
var systems = new List<RectTransform>[] {
new List<RectTransform>(),
new List<RectTransform>(),
new List<RectTransform>(),
new List<RectTransform>(),
new List<RectTransform>(),
new List<RectTransform>(),
};
for (int i = 0; i < mgs.Count; i++)
{
var mg = EventCaller.instance.GetMinigame(mgs[i].name);
var tags = mg.tags;
if (tags.Count != 0) {
systems[tags[0] switch {
"agb" => 0,
"ntr" => 1,
"rvl" => 2,
"ctr" => 3,
"mob" => 4,
_ => 5,
}].Add(mgs[i]);
} else if (mg.inferred) {
systems[^1].Add(mgs[i]);
} else {
Debug.LogWarning($"Chronological sorting has failed, does \"{mg.displayName}\" ({mg.name}) have an asset bundle assigned to it?");
}
List<RectTransform> chrono = mgs.OrderBy(GameOriginSortKey).ThenBy(ChronologicSortKey).ThenBy(AlphabetSortKey).ToList();
for (int i = 0; i < chrono.Count; i++) {
chrono[i].SetSiblingIndex(i + fxActive.Count + 1);
}
int j = fxActive.Count + 1;
foreach (var system in systems)
}
int GameOriginSortKey(RectTransform minigame)
{
Minigames.Minigame mg = EventCaller.instance.GetMinigame(minigame.name);
if (mg.tags.Count > 0)
{
system.OrderBy(mg => mg.name);
for (int i = 0; i < system.Count; i++)
return mg.tags[0] switch
{
system[i].SetSiblingIndex(j);
j++;
}
"agb" => 0,
"ntr" => 1,
"rvl" => 2,
"ctr" => 3,
_ => 10,
};
}
return 10;
}
uint ChronologicSortKey(RectTransform minigame)
{
Minigames.Minigame mg = EventCaller.instance.GetMinigame(minigame.name);
if (mg.chronologicalSortKey is uint i)
return i;
return uint.MaxValue;
}
void SortUsage(List<RectTransform> mgs)
{
List<RectTransform> usage = mgs.OrderByDescending(UsageSortKey).ThenBy(AlphabetSortKey).ToList();
for (int i = 0; i < usage.Count; i++) {
usage[i].SetSiblingIndex(i + fxActive.Count + 1);
}
}
int UsageSortKey(RectTransform minigame)
{
return EventCaller.GetAllInGameManagerList(minigame.name).Count;
}
public void Search()
@ -388,7 +410,12 @@ namespace HeavenStudio.Editor
public void Drag()
{
if (Conductor.instance.NotStopped() || Editor.instance.inAuthorativeMenu) return;
if (Conductor.instance.NotStopped() || Editor.instance.inAuthorativeMenu) {
if (Conductor.instance.isPaused) {
Debug.Log("it's fuckin paused dude");
}
return;
}
if (Timeline.instance.MouseInTimeline && dragTimes < 1)
{

View File

@ -18,10 +18,12 @@ namespace HeavenStudio.Editor
public Texture MaskTex;
public Texture BgTex;
private Material m_Material;
private Image image;
private void Start()
{
Tooltip.AddTooltip(this.gameObject, EventCaller.instance.GetMinigame(this.gameObject.name).displayName);
// image = GetComponent<Image>();
Tooltip.AddTooltip(gameObject, EventCaller.instance.GetMinigame(gameObject.name).displayName);
}
private void OnEnable()
@ -33,8 +35,10 @@ namespace HeavenStudio.Editor
{
if (m_Material == null)
{
m_Material = Instantiate(GetComponent<Image>().material);
GetComponent<Image>().material = m_Material;
if (image == null) image = GetComponent<Image>();
m_Material = Instantiate(image.material);
image.material = m_Material;
}
m_Material.SetTexture("_MaskTex", MaskTex);
m_Material.SetTexture("_BgTex", BgTex);
@ -53,10 +57,8 @@ namespace HeavenStudio.Editor
if (Input.GetMouseButtonDown(1))
{
// while holding shift and the game icon clicked has a star, it will disable all stars.
if (Input.GetKey(KeyCode.LeftShift)) {
if (!StarActive) return;
for (int i = 0; i < transform.parent.childCount; i++)
{
if (Input.GetKey(KeyCode.LeftShift) && StarActive) {
for (int i = 0; i < transform.parent.childCount; i++) {
var ggsg = transform.parent.GetChild(i).GetComponent<GridGameSelectorGame>();
if (ggsg.StarActive) ggsg.Star();
}
@ -76,14 +78,14 @@ namespace HeavenStudio.Editor
public void ClickIcon()
{
transform.DOScale(new Vector3(1.15f, 1.15f, 1f), 0.1f);
BgTex = Resources.Load<Texture>($"Sprites/GeneralPurpose/Circle");
BgTex = GridGameSelector.Circle;
SetupTextures();
}
public void UnClickIcon()
{
transform.DOScale(new Vector3(1f, 1f, 1f), 0.1f);
BgTex = Resources.Load<Texture>($"Sprites/GeneralPurpose/Square");
BgTex = GridGameSelector.Square;
SetupTextures();
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using UnityEngine;
using HeavenStudio.Editor.Track;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Editor
{
@ -31,7 +32,7 @@ namespace HeavenStudio.Editor
*/
if (Editor.instance.isShortcutsEnabled)
{
if (Input.GetKey(KeyCode.LeftControl))
if (Input.GetKey(InputKeyboard.MODIFIER))
if (Input.GetKeyDown(KeyCode.A))
SelectAll();
}

View File

@ -10,37 +10,41 @@ namespace HeavenStudio.Editor
public class SnapDialog : Dialog
{
[SerializeField] private TMP_Text snapText;
[SerializeField] RectTransform btnRectTransform;
private Timeline timeline;
private static float[] CommonDenominators = { 1, 2, 3, 4, 6, 8, 12, 16};
private static float[] CommonDenominators = { 1, 2, 3, 4, 6, 8, 12, 16 };
private int currentCommon = 3;
private void Start()
private void Start()
{
timeline = Timeline.instance;
}
public void SwitchSnapDialog()
{
if(dialog.activeSelf) {
if (dialog.activeSelf) {
dialog.SetActive(false);
} else {
ResetAllDialogs();
SetPosRelativeToButtonPos(btnRectTransform);
// rectTransform.SetParent(btnRectTransform);
// rectTransform.localPosition = new Vector2(210, 120);
// rectTransform.SetParent(Editor.instance.MainCanvas.transform, true);
dialog.SetActive(true);
}
}
public void ChangeCommon(bool down = false)
{
if(down) {
currentCommon--;
} else {
currentCommon++;
}
currentCommon += down ? -1 : 1;
if(currentCommon < 0) {
currentCommon = 0;
} else if(currentCommon >= CommonDenominators.Length) {
currentCommon = CommonDenominators.Length - 1;
}
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
}

View File

@ -9,6 +9,7 @@ using HeavenStudio.Util;
using TMPro;
using Jukebox;
using Jukebox.Legacy;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Editor.Track
{
@ -155,7 +156,7 @@ namespace HeavenStudio.Editor.Track
{
lastTempo *= 2f;
}
else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
else if (Input.GetKey(InputKeyboard.MODIFIER) || Input.GetKey(KeyCode.RightCommand))
{
lastTempo /= 2f;
}

View File

@ -7,6 +7,7 @@ using TMPro;
using DG.Tweening;
using Jukebox;
using Jukebox.Legacy;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Editor.Track
{
@ -30,8 +31,9 @@ namespace HeavenStudio.Editor.Track
if (Input.GetKey(KeyCode.LeftShift))
newTempo *= 5f;
if (Input.GetKey(KeyCode.LeftControl))
if (Input.GetKey(InputKeyboard.MODIFIER)) {
newTempo *= 0.01f;
}
if (newTempo != 0)
{

View File

@ -7,6 +7,7 @@ using TMPro;
using DG.Tweening;
using Jukebox;
using Jukebox.Legacy;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Editor.Track
{
@ -30,9 +31,9 @@ namespace HeavenStudio.Editor.Track
if (Input.GetKey(KeyCode.LeftShift))
newVolume *= 5f;
if (Input.GetKey(KeyCode.LeftControl))
if (Input.GetKey(InputKeyboard.MODIFIER)) {
newVolume *= 0.01f;
}
if (newVolume != 0)
{
SetVolume(chartEntity["volume"] + newVolume);

View File

@ -12,6 +12,7 @@ using System.Linq;
using BurstLinq;
using HeavenStudio.Util;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Editor.Track
{
@ -44,6 +45,7 @@ namespace HeavenStudio.Editor.Track
public float MousePos2Beat { get; private set; }
public float MousePos2Layer { get; private set; }
public float MousePos2BeatSnap => HeavenStudio.Util.MathUtils.Round2Nearest(MousePos2Beat + (SnapInterval() * 0.5f), SnapInterval());
// public float MousePos2BeatSnap => HeavenStudio.Util.MathUtils.Round2Nearest(MousePos2Beat, SnapInterval());
public bool MouseInTimeline { get; private set; }
private Vector2 relativeMousePos;
@ -110,28 +112,28 @@ namespace HeavenStudio.Editor.Track
if (selected)
{
instance.SelectionsBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
instance.SelectionsBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
// instance.SelectionsBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
}
else
instance.SelectionsBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (tempoChange)
{
instance.TempoChangeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
instance.TempoChangeBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
// instance.TempoChangeBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
}
else
instance.TempoChangeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (musicVolume)
{
instance.MusicVolumeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
instance.MusicVolumeBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
// instance.MusicVolumeBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
}
else
instance.MusicVolumeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (chartSection)
{
instance.ChartSectionBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
instance.ChartSectionBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
// instance.ChartSectionBTN.GetComponent<TabButton>().Invoke("OnClick", 0);
}
else
instance.ChartSectionBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
@ -179,7 +181,6 @@ namespace HeavenStudio.Editor.Track
public Button ZoomInBTN;
public Button ZoomOutBTN;
public Button ZoomResetBTN;
public Button WaveformBTN;
public Slider PlaybackSpeed;
public Vector3[] LayerCorners = new Vector3[4];
@ -244,40 +245,13 @@ namespace HeavenStudio.Editor.Track
LoadRemix();
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSlider.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSlider.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSlider.GetChild(3).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSongPosLineRef.GetComponent<Image>().color = EditorTheme.theme.properties.CurrentTimeMarkerCol.Hex2RGB();
// TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
// TimelineSlider.GetChild(1).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
// TimelineSlider.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
// TimelineSlider.GetChild(3).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
// TimelineSongPosLineRef.GetComponent<Image>().color = EditorTheme.theme.properties.CurrentTimeMarkerCol.Hex2RGB();
TimelineSongPosLineRef.gameObject.SetActive(false);
PlayBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPaused)
PlayCheck(false);
else
PlayCheck(true);
});
PauseBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
PlayCheck(false);
});
StopBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPlaying || Conductor.instance.isPaused)
PlayCheck(true);
});
MetronomeBTN.onClick.AddListener(delegate
{
MetronomeToggle();
});
AutoplayBTN.onClick.AddListener(delegate
{
AutoPlayToggle();
});
SelectionsBTN.onClick.AddListener(delegate
{
timelineState.SetState(CurrentTimelineState.State.Selection);
@ -295,25 +269,6 @@ namespace HeavenStudio.Editor.Track
timelineState.SetState(CurrentTimelineState.State.ChartSection);
});
ZoomInBTN.onClick.AddListener(delegate
{
zoomComponent.Zoom(0.25f * zoomComponent.Scale.x, Vector2.zero, true);
});
ZoomOutBTN.onClick.AddListener(delegate
{
zoomComponent.Zoom(-0.2f * zoomComponent.Scale.x, Vector2.zero, true);
});
ZoomResetBTN.onClick.AddListener(delegate
{
zoomComponent.ResetZoom();
});
WaveformBTN.onClick.AddListener(delegate
{
WaveformToggle();
});
Tooltip.AddTooltip(WaveformBTN.gameObject, "Waveform Toggle");
SetTimeButtonColors(true, false, false);
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = Color.gray;
@ -326,6 +281,33 @@ namespace HeavenStudio.Editor.Track
resizeCursor = Resources.Load<Texture2D>("Cursors/horizontal_resize");
}
public void PressPlay()
{
PlayCheck(!Conductor.instance.isPaused);
}
public void PressPause()
{
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused) {
PlayCheck(false);
}
}
public void PressStop()
{
if (Conductor.instance.isPlaying || Conductor.instance.isPaused) {
PlayCheck(true);
}
}
// public void SetState(CurrentTimelineState.State state)
// {
// timelineState.SetState(state);
// }
public void SetState(string state)
{
timelineState.SetState(Enum.Parse<CurrentTimelineState.State>(state));
}
public void FitToSong()
{
var currentSizeDelta = RealTimelineContent.sizeDelta;
@ -338,12 +320,6 @@ namespace HeavenStudio.Editor.Track
RealTimelineContent.sizeDelta = new Vector2(TimelineContent.sizeDelta.x / Zoom, RealTimelineContent.sizeDelta.y);
}
public void CreateWaveform()
{
// DrawWaveform();
// StartCoroutine(DrawWaveformRealtime());
}
public void AutoBtnUpdate()
{
var animName = GameManager.instance.autoplay ? "Idle" : "Disabled";
@ -500,11 +476,11 @@ namespace HeavenStudio.Editor.Track
float moveSpeed = 750;
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) moveSpeed *= 6;
if (Input.GetKey(KeyCode.LeftArrow) || (!Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.A)))
if (Input.GetKey(KeyCode.LeftArrow) || (!Input.GetKey(InputKeyboard.MODIFIER) && Input.GetKey(KeyCode.A)))
{
RealTimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
}
else if (Input.GetKey(KeyCode.RightArrow) || (!Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.D)))
else if (Input.GetKey(KeyCode.RightArrow) || (!Input.GetKey(InputKeyboard.MODIFIER) && Input.GetKey(KeyCode.D)))
{
RealTimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
}
@ -584,7 +560,7 @@ namespace HeavenStudio.Editor.Track
private void SliderControl()
{
TimelinePlaybackBeat.text = $"Beat {string.Format("{0:0.000}", PlaybackBeat)}";
TimelinePlaybackBeat.text = $" {string.Format("{0:0.000}", PlaybackBeat)}";
if (TimelineSongPosLineRef != null && !Conductor.instance.WaitingForDsp)
{
@ -1076,7 +1052,7 @@ namespace HeavenStudio.Editor.Track
public void UpdateOffsetFromText()
{
// Failsafe against empty string.
if (String.IsNullOrEmpty(FirstBeatOffset.text))
if (string.IsNullOrEmpty(FirstBeatOffset.text))
FirstBeatOffset.text = "0";
// Convert ms to s.

View File

@ -1,3 +1,4 @@
using HeavenStudio.InputSystem;
using UnityEngine;
using UnityEngine.EventSystems;
@ -15,6 +16,7 @@ namespace HeavenStudio.Editor.Track
private Vector2 relMousePos;
private RectTransform rectTransform;
private RectTransform timelineContentRectTrans;
private void Awake()
{
@ -28,10 +30,9 @@ namespace HeavenStudio.Editor.Track
private void Update()
{
var scrollDeltaY = Input.mouseScrollDelta.y;
if (scrollDeltaY != 0)
if (scrollDeltaY != 0 && Timeline.instance.MouseInTimeline)
{
if (Timeline.instance.MouseInTimeline)
OnScroll(scrollDeltaY);
OnScroll(scrollDeltaY);
}
}
@ -41,41 +42,51 @@ namespace HeavenStudio.Editor.Track
relMousePos = rectTransform.anchoredPosition;
Vector2 relativeMousePosition;
var cam = Editor.instance.EditorCamera;
if (cam == null)
{
Debug.LogError("Camera not set!");
return;
}
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, cam, out relativeMousePosition);
if (scrollDeltaY > 0)
{
if (Input.GetKey(KeyCode.LeftControl))
{
Zoom(0.25f * _scale.y, relativeMousePosition, false);
if (scrollDeltaY > 0) {
if (Input.GetKey(InputKeyboard.MODIFIER)) {
ZoomInVertical();
} else {
ZoomInHorizontal();
}
else
{
Zoom(0.25f * _scale.x, relativeMousePosition, true);
} else if (scrollDeltaY < 0) {
if (Input.GetKey(InputKeyboard.MODIFIER)) {
ZoomOutVertical();
} else {
ZoomOutHorizontal();
}
}
else if (scrollDeltaY < 0)
{
if (Input.GetKey(KeyCode.LeftControl))
{
var incre = -0.2f * _scale.y;
if (_scale.y + incre > minScale - 0.1f)
Zoom(-0.2f * _scale.y, relativeMousePosition, false);
}
else
{
var incre = -0.2f * _scale.x;
if (_scale.x + incre > minScale - 0.1f)
Zoom(-0.2f * _scale.x, relativeMousePosition, true);
}
}
public void ZoomInVertical()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out Vector2 mousePos);
Zoom(0.25f * _scale.y, mousePos, false);
}
public void ZoomInHorizontal()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out Vector2 mousePos);
Zoom(0.25f * _scale.x, mousePos, true);
}
public void ZoomOutVertical()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out Vector2 mousePos);
var incre = -0.2f * _scale.y;
if (_scale.y + incre > minScale - 0.1f)
Zoom(-0.2f * _scale.y, mousePos, false);
}
public void ZoomOutHorizontal()
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Editor.instance.EditorCamera, out Vector2 mousePos);
var incre = -0.2f * _scale.x;
if (_scale.x + incre > minScale - 0.1f) {
Zoom(-0.2f * _scale.x, mousePos, true);
}
}
@ -85,10 +96,10 @@ namespace HeavenStudio.Editor.Track
if (horiz)
{
var newScale = Mathf.Clamp(_scale.x + incre, minScale, maxScale);
float newScale = Mathf.Clamp(_scale.x + incre, minScale, maxScale);
_scale.Set(newScale, _scale.y, 1);
relativeMousePosition = new Vector2(relativeMousePosition.x, 0);
relMousePos -= (relativeMousePosition * incre);
relMousePos -= relativeMousePosition * incre;
rectTransform.localScale = _scale;
rectTransform.anchoredPosition = relMousePos;
@ -101,10 +112,10 @@ namespace HeavenStudio.Editor.Track
}
else
{
var newScale = Mathf.Clamp(_scale.y + incre, 1.0f, maxScale);
float newScale = Mathf.Clamp(_scale.y + incre, 1.0f, maxScale);
_scale.Set(_scale.x, newScale, 1);
relativeMousePosition = new Vector2(0, relativeMousePosition.y);
relMousePos -= (relativeMousePosition * incre);
relMousePos -= relativeMousePosition * incre;
rectTransform.localScale = _scale;
rectTransform.anchoredPosition = relMousePos;
@ -126,7 +137,9 @@ namespace HeavenStudio.Editor.Track
{
_scale.Set(1, 1, 1);
rectTransform.localScale = _scale;
rectTransform.localPosition = new Vector2(rectTransform.localPosition.x, 0);
Timeline.instance.OnZoom(_scale.x);
Timeline.instance.OnZoomVertical(_scale.y);
}
}
}

View File

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

View File

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Editor.Track;
using TMPro;
namespace HeavenStudio.Editor
{
public class ZoomDialog : Dialog
{
// [SerializeField] private TMP_Text snapText;
[SerializeField] RectTransform btnRectTransform;
public void SwitchZoomDialog()
{
if (dialog.activeSelf) {
dialog.SetActive(false);
} else {
ResetAllDialogs();
SetPosRelativeToButtonPos(btnRectTransform, new Vector2(146, 120));
dialog.SetActive(true);
}
}
}
}

View File

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