selecting crap works properly now

This commit is contained in:
minenice55 2022-07-01 22:03:15 -04:00
parent 8e16e9be04
commit ae944062c5
4 changed files with 139 additions and 140 deletions

View file

@ -1798,7 +1798,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -94.99997, y: 0}
m_AnchoredPosition: {x: -94.99994, y: 0}
m_SizeDelta: {x: 39.99997, y: 40}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &121871281
@ -1938,7 +1938,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -49.99997, y: 0}
m_AnchoredPosition: {x: -49.99994, y: 0}
m_SizeDelta: {x: 39.99997, y: 40}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &129013734
@ -2328,7 +2328,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -289.15002, y: 2}
m_AnchoredPosition: {x: -289.15, y: 2}
m_SizeDelta: {x: -578.29, y: 49.92}
m_Pivot: {x: 0.5, y: 0}
--- !u!114 &156962255
@ -5728,7 +5728,7 @@ RectTransform:
m_GameObject: {fileID: 411779173}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.71994287, y: 71.994286, z: 71.994286}
m_LocalScale: {x: 80.17311, y: 80.17311, z: 1}
m_Children:
- {fileID: 1310571274}
- {fileID: 1207455550}
@ -5737,8 +5737,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -155.8399, y: 179.8523}
m_SizeDelta: {x: 100, y: 100}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &411779175
MonoBehaviour:
@ -8539,7 +8539,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 704039020}
m_Direction: 0
m_Value: 0
m_Size: 0.03287128
m_Size: 0.032871284
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@ -12023,8 +12023,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1589389272}
m_HandleRect: {fileID: 1589389271}
m_Direction: 2
m_Value: -0.0000033002277
m_Size: 0.5285789
m_Value: 0.14881732
m_Size: 0.52981937
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@ -13928,7 +13928,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 120.830025, y: -19.690994}
m_AnchoredPosition: {x: 120.830025, y: -19.690979}
m_SizeDelta: {x: 576.29, y: -43.38}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1056099133
@ -14607,7 +14607,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -408.98004, y: -17}
m_AnchoredPosition: {x: -408.97998, y: -17}
m_SizeDelta: {x: -817.96, y: -46.29}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1121370303
@ -15065,7 +15065,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 361.0897}
m_AnchoredPosition: {x: 0, y: 326.57358}
m_SizeDelta: {x: 0, y: 491}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1154875944
@ -15878,7 +15878,7 @@ RectTransform:
m_GameObject: {fileID: 1207455549}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.01111111, y: 0.01111111, z: 1}
m_LocalScale: {x: 0.0124730095, y: 0.0124730095, z: 1}
m_Children: []
m_Father: {fileID: 411779174}
m_RootOrder: 1
@ -15908,7 +15908,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0.0
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 78e7291cdeccdfc4fa61249845605144, type: 2}
m_sharedMaterial: {fileID: 5250768452915780979, guid: 78e7291cdeccdfc4fa61249845605144, type: 2}
@ -17218,7 +17218,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 49.99997, y: 0}
m_AnchoredPosition: {x: 49.99994, y: 0}
m_SizeDelta: {x: 39.999985, y: 40}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1345846031
@ -20487,7 +20487,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 111.50012, y: -14.244019}
m_AnchoredPosition: {x: 111.50012, y: -14.244171}
m_SizeDelta: {x: 223, y: -138.84}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1671351976
@ -22107,7 +22107,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 94.99997, y: 0}
m_AnchoredPosition: {x: 94.99994, y: 0}
m_SizeDelta: {x: 39.999985, y: 40}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1783491359
@ -22694,7 +22694,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -84.09503}
m_AnchoredPosition: {x: 0, y: -84.095}
m_SizeDelta: {x: 320, y: -115.28}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1852819572
@ -24172,7 +24172,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -14.242737}
m_AnchoredPosition: {x: 0, y: -14.242828}
m_SizeDelta: {x: 0, y: -138.84}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1980243267
@ -25573,19 +25573,19 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2066632679}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.01, y: 1, z: 1}
m_Children:
- {fileID: 411779174}
m_Father: {fileID: 1852819573}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -26.50586}
m_SizeDelta: {x: 0, y: -113.39}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -26.463135}
m_SizeDelta: {x: 1054, y: -115.3}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &2066632681
MonoBehaviour:
m_ObjectHideFlags: 0

View file

@ -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);
}

View file

@ -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)

View file

@ -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()