From 68264acf6615246f0c3f359ebc64c0daf9801fbf Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 18 Apr 2024 03:12:10 +0200 Subject: [PATCH] Implemented rotation + new dot sprite --- assets/data/states/StageEditor.hx | 38 +++++-- assets/images/editors/stage/selectionDot.png | Bin 0 -> 793 bytes source/funkin/editors/stage/StageEditor.hx | 114 +++++++++++++++---- 3 files changed, 117 insertions(+), 35 deletions(-) create mode 100644 assets/images/editors/stage/selectionDot.png diff --git a/assets/data/states/StageEditor.hx b/assets/data/states/StageEditor.hx index f18d377a..e8624bf5 100644 --- a/assets/data/states/StageEditor.hx +++ b/assets/data/states/StageEditor.hx @@ -10,6 +10,7 @@ import funkin.editors.stage.StageEditor; import funkin.editors.ui.UIWarningSubstate; import funkin.backend.utils.WindowUtils; +import flixel.math.FlxAngle; import openfl.Lib; var exID = StageEditor.exID; @@ -130,12 +131,9 @@ function SCALE_BOTTOM_RIGHT(sprite, relative) { ROTATION **/ function preRotBullshit(sprite, relative) { - // just remove the other line in source - rotateByDegrees(relative, -sprite.angle); - if (sprite.angle != 0) relative = rotateAround(relative, FlxPoint.weak(0, 0), -sprite.angle); - + if (FlxG.mouse.justPressed) { oldSpritePos.x = sprite.x; oldSpritePos.y = sprite.y; @@ -149,16 +147,16 @@ function postRotBullshit(sprite, relative) { sprite.y = p.y; } } -import flixel.math.FlxAngle; function rotateAround(p, origin, angle) { var rel = FlxPoint.get(p.x - origin.x, p.y - origin.y); rotateByDegrees(rel, angle); p.x = origin.x + rel.x; p.y = origin.y + rel.y; + rel.put(); return p; } - function rotateByDegrees(p, angle) { +function rotateByDegrees(p, angle) { var rads = angle * FlxAngle.TO_RAD; var s:Float = Math.sin(rads); var c:Float = Math.cos(rads); @@ -166,9 +164,7 @@ function rotateAround(p, origin, angle) { p.x = tempX * c - p.y * s; p.y = tempX * s + p.y * c; - - return this; - } +} /** END OF ROTATION **/ @@ -226,6 +222,28 @@ function SKEW_TOP(sprite, relative) {} function SKEW_RIGHT(sprite, relative) {} -function ROTATE(sprite, relative) {} +/*var storedCenter = FlxPoint.get(); +var storedRelative = FlxPoint.get();*/ + +function ROTATE(sprite, relative) { + var buttonBoxes:Array = sprite.extra.get(exID("buttonBoxes")); + var p:FlxPoint = buttonBoxes[8]; + + FlxG.mouse.getWorldPosition(stageCamera, _point); + + var dx:Float = _point.x - p.x; + var dy:Float = _point.y - p.y; + var angle = FlxAngle.angleFromOrigin(dx, dy, true) + 90; + if(FlxG.keys.pressed.SHIFT) angle = Std.int(angle / 45) * 45; + sprite.angle = angle; + + //storedCenter.set(p.x, p.y); + //storedRelative.set(_point.x, _point.y); +} +/*function postDraw() { + if(storedCenter.x != 0 || storedCenter.y != 0) { + drawLine(storedCenter, storedRelative, 0.3); + } +}*/ \ No newline at end of file diff --git a/assets/images/editors/stage/selectionDot.png b/assets/images/editors/stage/selectionDot.png new file mode 100644 index 0000000000000000000000000000000000000000..d5aa449e24d3233da0ba7b19a038c94e4b81b7db GIT binary patch literal 793 zcmV+!1LpjRP)BRh|zeIkl-JLUD?aeL#HxZJKYxADT%-2O{STd_nEhynYQl) zlE|qmz$0KDxC`6@u9>=@z!zW}cn`bRXDB~yz3rD1Z>si{Jrk1ro}{Oef{Z>c3ryc$7T@kL zCTY9ecvH1)Sjhn=`QIhYq_it)Gm^f!_;$nPk^{}sa>_t$eoxYLN}IFVv<7FwU%tKR z^h*!Zt-fKp_)97;_}G@x_;KZG`7sXFnob92^E*1*n$NQ**c;=TBmzlSfv>>jGC$jL z=opwVWt%?-e5i;y3v_IL6IjH5@EGQzRR##DE_jUZ5SWVjP2gdLz+qYd?4OZ!56pF< z8vwA-v@Yt<6oWUQ%BLTzW0j|xK-&Yp4*8|gLv;s-LflD61Y3dWrfS5lDoK(yl zu^9bE#jp#n2Jov!{$YZD!voW195#SY9-uCLPVjGgVBWF$4WjpAT?!NYIS)*m5jKE# z9-uC5B=}D}Fm1+0ou9&8VBC~_eG1>Ve0PEIcoTeG5im=y3_Hnx0R$EB0^sF8eAV|m zY-eWb_#JL5kq}uaJxsS&QU+-AyDC2+(oN&rjm9MHlpSe`cH~Zp+57{Qml8X0@so}J z>!fIG7cniqsp4tz%{=_9CsF2d*io^A5f?v{^i0vg$b?Q0MkXXJC|cVei}14sF=`y1 z=k3tf`Hsda=jR#7q@twdaRG2wQPOcThyPmnfmG;t{4s;a)7MSi4+f8?-%!o*c