mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:17:37 +02:00
selecting crap works properly now
This commit is contained in:
@ -23,6 +23,9 @@ namespace HeavenStudio.Editor
|
||||
private bool clickedInTimeline = false;
|
||||
|
||||
private TMPro.TMP_Text sizeText;
|
||||
private RectTransform text;
|
||||
|
||||
private float timelineLastX;
|
||||
|
||||
public static BoxSelection instance { get; private set; }
|
||||
|
||||
@ -40,10 +43,19 @@ namespace HeavenStudio.Editor
|
||||
boxVisual.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BoxSelectionOutlineCol.Hex2RGB();
|
||||
|
||||
sizeText = boxVisual.transform.GetChild(1).GetComponent<TMPro.TMP_Text>();
|
||||
text = boxVisual.transform.GetChild(1).GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float deltaTimelineX = timelineContent.transform.localPosition.x - timelineLastX;
|
||||
|
||||
Camera camera = Editor.instance.EditorCamera;
|
||||
Vector3 scale = Editor.instance.MainCanvas.transform.localScale;
|
||||
|
||||
boxVisual.transform.localScale = new Vector2(0.01f/scale.x, 1f/scale.y);
|
||||
text.transform.localScale = scale;
|
||||
|
||||
if (Selections.instance.eventsSelected.Count > 0 && Timeline.instance.InteractingWithEvents())
|
||||
{
|
||||
startPosition = Vector2.zero;
|
||||
@ -60,10 +72,11 @@ namespace HeavenStudio.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
if (boxVisual.rect.width * boxVisual.transform.localScale.x >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", boxVisual.rect.width * boxVisual.transform.localScale.x)}";
|
||||
float beatLen = boxVisual.rect.width * boxVisual.transform.localScale.x;
|
||||
if (beatLen >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", beatLen)}";
|
||||
else
|
||||
sizeText.text = string.Empty; // i'm lazy
|
||||
sizeText.text = string.Empty;
|
||||
|
||||
|
||||
// click
|
||||
@ -78,9 +91,11 @@ namespace HeavenStudio.Editor
|
||||
// dragging
|
||||
if (Input.GetMouseButton(0) && clickedInTimeline)
|
||||
{
|
||||
startPosition.x += deltaTimelineX * scale.x;
|
||||
endPosition = MousePosition();
|
||||
DrawVisual();
|
||||
DrawSelection();
|
||||
SelectEvents(); //kek
|
||||
DrawVisual();
|
||||
}
|
||||
|
||||
// release click
|
||||
@ -92,9 +107,7 @@ namespace HeavenStudio.Editor
|
||||
DrawVisual();
|
||||
}
|
||||
|
||||
// selecting = (selectionBox.size != Vector2.zero); -- doesn't work really
|
||||
|
||||
// for real time selection just move SelectEvents() to here, but that breaks some shit. might fix soon idk --pelly
|
||||
timelineLastX = timelineContent.transform.localPosition.x;
|
||||
}
|
||||
|
||||
private void DrawVisual()
|
||||
@ -102,15 +115,12 @@ namespace HeavenStudio.Editor
|
||||
Vector2 boxStart = startPosition;
|
||||
Vector2 boxEnd = endPosition;
|
||||
|
||||
// boxEnd = new Vector2(Mathf.Clamp(boxEnd.x, -5.78f, Mathf.Infinity), boxEnd.y);
|
||||
|
||||
Vector2 boxCenter = (boxStart + boxEnd) / 2;
|
||||
boxVisual.position = boxCenter;
|
||||
|
||||
Vector2 boxSize = new Vector2(Mathf.Abs(boxStart.x - boxEnd.x), Mathf.Abs(boxStart.y - boxEnd.y));
|
||||
|
||||
// boxVisual.sizeDelta = new Vector2(boxSize.x / boxVisual.localScale.x, boxSize.y / boxVisual.localScale.y);
|
||||
boxVisual.sizeDelta = new Vector2(boxSize.x, boxSize.y);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxSize.x);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxSize.y);
|
||||
}
|
||||
|
||||
private void DrawSelection()
|
||||
@ -168,7 +178,7 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
var mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
// var mousePos = new Vector2();
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Camera.main, out mousePos);
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Editor.instance.EditorCamera, out mousePos);
|
||||
return new Vector3(mousePos.x, mousePos.y, 0);
|
||||
}
|
||||
|
||||
|
@ -113,21 +113,68 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
#region Keyboard Shortcuts
|
||||
if (!editingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
Fullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
List<TimelineEventObj> ev = new List<TimelineEventObj>();
|
||||
for (int i = 0; i < Selections.instance.eventsSelected.Count; i++) ev.Add(Selections.instance.eventsSelected[i]);
|
||||
CommandManager.instance.Execute(new Commands.Deletion(ev));
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Z))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
CommandManager.instance.Redo();
|
||||
else
|
||||
CommandManager.instance.Undo();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Y))
|
||||
{
|
||||
CommandManager.instance.Redo();
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (CommandManager.instance.canUndo())
|
||||
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = "BD8CFF".Hex2RGB();
|
||||
@ -139,29 +186,6 @@ namespace HeavenStudio.Editor
|
||||
else
|
||||
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Z))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
CommandManager.instance.Redo();
|
||||
else
|
||||
CommandManager.instance.Undo();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Y))
|
||||
{
|
||||
CommandManager.instance.Redo();
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Timeline.instance.timelineState.selected && Editor.instance.canSelect)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
@ -184,37 +208,6 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isEditor)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
// SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Sprite GameIcon(string name)
|
||||
|
@ -259,9 +259,11 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
SliderControl();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
#region Keyboard Shortcuts
|
||||
if (!userIsEditingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
@ -272,20 +274,44 @@ namespace HeavenStudio.Editor.Track
|
||||
PlayCheck(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
AutoPlayToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
MetronomeToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2))
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3))
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && Editor.MouseInRectTransform(TimelineGridSelect))
|
||||
{
|
||||
@ -307,21 +333,6 @@ namespace HeavenStudio.Editor.Track
|
||||
lastBeatPos = TimelineSlider.localPosition.x;
|
||||
}
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (!Editor.instance.editingInputField)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.isPlaying)
|
||||
TimelineContent.transform.localPosition = new Vector3((-Conductor.instance.songPositionInBeats * 100) + 200, TimelineContent.transform.localPosition.y);
|
||||
|
||||
@ -329,28 +340,13 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
CurrentTempo.text = $" = {Conductor.instance.songBpm}";
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
|
||||
LayersRect.GetWorldCorners(LayerCorners);
|
||||
}
|
||||
|
||||
public static float GetScaleModifier()
|
||||
{
|
||||
Camera cam = Editor.instance.EditorCamera;
|
||||
Vector2 scalerReferenceResolution = new Vector2(1280, 720);
|
||||
return Mathf.Pow(cam.pixelWidth/scalerReferenceResolution.x, 1f)*
|
||||
Mathf.Pow(cam.pixelHeight/scalerReferenceResolution.y, 0f);
|
||||
return Mathf.Pow(cam.pixelWidth/1280f, 1f) * Mathf.Pow(cam.pixelHeight/720f, 0f);
|
||||
}
|
||||
|
||||
public Vector2 LayerCornersToDist()
|
||||
|
Reference in New Issue
Block a user