bleh :PPPPP

This commit is contained in:
lunarcleint
2025-03-18 01:43:10 -07:00
parent 6f102c6717
commit 37bfe39dfd
3 changed files with 91 additions and 64 deletions
+26 -1
View File
@@ -8,12 +8,29 @@ import flixel.math.FlxPoint;
final class DrawUtil {
public static var line:FlxSprite = null;
public static var dot:FlxSprite = null;
public static var sqaure:FlxSprite = null;
public static inline function drawSqaure(x:Float, y:Float, ?scale:Float = 1) {
if (sqaure == null) createDrawers();
sqaure.setPosition(x, y);
sqaure.scale.set(scale, scale);
sqaure.updateHitbox();
sqaure.x -= sqaure.width / 2;
sqaure.y -= sqaure.height / 2;
sqaure.draw();
}
public static inline function drawDot(x:Float, y:Float, ?scale:Float = 1) {
if (dot == null) createDrawers();
dot.setPosition(x, y);
dot.scale.set(0.7/dot.cameras[0].zoom * scale, 0.7/dot.cameras[0].zoom * scale);
dot.scale.set(scale, scale);
dot.updateHitbox();
dot.x -= dot.width / 2;
dot.y -= dot.height / 2;
dot.draw();
@@ -65,6 +82,10 @@ final class DrawUtil {
line = new FlxSprite().makeGraphic(1, 1, FlxColor.WHITE);
line.camera = FlxG.camera;
line.forceIsOnScreen = true;
sqaure = new FlxSprite().makeGraphic(32, 32, FlxColor.WHITE);
sqaure.camera = FlxG.camera;
sqaure.forceIsOnScreen = true;
}
public static function destroyDrawers() {
@@ -76,5 +97,9 @@ final class DrawUtil {
line.destroy();
line = null;
}
if(sqaure != null) {
sqaure.destroy();
sqaure = null;
}
}
}
@@ -265,7 +265,7 @@ class CharacterEditor extends UIState {
gizmosCamera = new FlxCamera();
gizmosCamera.bgColor = 0;
FlxG.cameras.add(gizmosCamera);
FlxG.cameras.add(gizmosCamera, false);
axisGizmo = new AxisGizmo();
axisGizmo.cameras = [gizmosCamera];
+64 -62
View File
@@ -10,6 +10,7 @@ import funkin.backend.utils.XMLUtil.AnimData;
import funkin.editors.stage.elements.*;
import funkin.editors.stage.elements.StageSpriteButton.StageSpriteEditScreen;
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
import funkin.editors.extra.AxisGizmo;
import funkin.game.Character;
import funkin.game.Stage;
import haxe.xml.Access;
@@ -46,6 +47,9 @@ class StageEditor extends UIState {
//public var guideCamera:FlxCamera;
public var uiCamera:FlxCamera;
public var gizmosCamera:FlxCamera;
public var axisGizmo:AxisGizmo;
public var selection:Selection = new Selection();
public var mouseMode:StageEditorMouseMode = NONE;
public var mousePoint:FlxPoint = new FlxPoint();
@@ -205,8 +209,13 @@ class StageEditor extends UIState {
stageCamera = FlxG.camera;
//guideCamera = new FlxCamera();
//guideCamera.bgColor = 0;
gizmosCamera = new FlxCamera();
gizmosCamera.bgColor = 0;
FlxG.cameras.add(gizmosCamera, false);
axisGizmo = new AxisGizmo();
axisGizmo.cameras = [gizmosCamera];
add(axisGizmo);
uiCamera = new FlxCamera();
uiCamera.bgColor = 0;
@@ -222,6 +231,9 @@ class StageEditor extends UIState {
loadStage(order, orderNodes);
// for (sprite => node in xmlMap)
// sprite.cameras = [stageCamera];
topMenuSpr = new UITopMenu(topMenu);
topMenuSpr.cameras = uiGroup.cameras = [uiCamera];
@@ -887,82 +899,72 @@ class StageEditor extends UIState {
override function draw() {
super.draw();
for(sprite in selection) {
if(sprite is FunkinSprite)
drawGuides(cast sprite);
}
for(sprite in selection)
if(sprite is FunkinSprite) drawGuides(cast sprite);
}
var lineColor:FlxColor = 0xFFb794b6;
var circleColor:FlxColor = 0xFF99a8f2;
var hollowColor:FlxColor = 0xffb2beff;
function drawGuides(sprite:FunkinSprite) {
//if(sprite._frame == null) return;
if(sprite.offset == null) return; // destroyed
if(sprite == null || sprite.offset == null) return; // destroyed
var corners = calcSpriteBounds(sprite);
var funkinSprite = sprite is FunkinSprite ? cast(sprite, FunkinSprite) : null;
if(funkinSprite != null) {
if(funkinSprite.extra.exists(exID("buttonBoxes"))) {
var oldButtonBoxes:Array<FlxPoint> = cast funkinSprite.extra.get(exID("buttonBoxes"));
if(oldButtonBoxes != null) {
for(point in oldButtonBoxes) {
point.put();
}
}
}
}
var buttonBoxes = [];
if(funkinSprite != null) {
funkinSprite.extra.set(exID("buttonBoxes"), buttonBoxes);
var corners:Array<FlxPoint> = calcSpriteBounds(sprite);
var transformedCorners:Array<FlxPoint> = [for (corner in corners) corner.clone()];
for (corner in transformedCorners) {
corner.x -= sprite.cameras[0].viewX;
corner.y -= sprite.cameras[0].viewY;
corner.x *= sprite.cameras[0].zoom;
corner.y *= sprite.cameras[0].zoom;
}
DrawUtil.drawLine(corners[0], corners[1]); // tl - tr
DrawUtil.drawLine(corners[0], corners[2]); // tl - bl
DrawUtil.drawLine(corners[1], corners[3]); // tr - br
DrawUtil.drawLine(corners[2], corners[3]); // bl - br
if (DrawUtil.line == null) DrawUtil.createDrawers();
DrawUtil.line.cameras = [gizmosCamera]; DrawUtil.line.alpha = 0.85;
DrawUtil.dot.cameras = [gizmosCamera]; DrawUtil.dot.alpha = 1;
DrawUtil.drawLine(corners[7], corners[9], 0.3); // tc - ac // top center to angle center
DrawUtil.drawLine(transformedCorners[0], transformedCorners[1], 1, 0xFF007B8F); // tl - tr
DrawUtil.drawLine(transformedCorners[0], transformedCorners[2], 1, 0xFF007B8F); // tl - bl
DrawUtil.drawLine(transformedCorners[1], transformedCorners[3], 1, 0xFF007B8F); // tr - br
DrawUtil.drawLine(transformedCorners[2], transformedCorners[3], 1, 0xFF007B8F); // bl - br
DrawUtil.drawLine(transformedCorners[7], transformedCorners[9], 1, 0xFF007B8F); // tc - ac // top center to angle center
// cross
//DrawUtil.drawLine(corners[0], corners[3]); // tl - br
//DrawUtil.drawLine(corners[1], corners[2]); // tr - bl
DrawUtil.dot.color = circleColor;
// DrawUtil.drawLine(transformedCorners[0], transformedCorners[3], 1, 0xFF007B8F); // tl - br
// DrawUtil.drawLine(transformedCorners[1], transformedCorners[2], 1, 0xFF007B8F); // tr - bl
final ANGLE_INDEX = StageEditorEdge.ROTATE_CIRCLE.toInt();
final CENTER_INDEX = StageEditorEdge.CENTER_CIRCLE.toInt();
DrawUtil.dot.animation.play("default");
for(i in 0...corners.length) {
var corner = corners[i];
if(i != CENTER_INDEX) {
if(i == ANGLE_INDEX) {
DrawUtil.dot.color = hollowColor;
DrawUtil.drawDot(corner.x, corner.y);
DrawUtil.dot.animation.play("hollow");
DrawUtil.dot.color = circleColor;
DrawUtil.drawDot(corner.x, corner.y);
} else {
DrawUtil.drawDot(corner.x, corner.y);
}
buttonBoxes.push(corner);
}
else if(sprite.visible){
DrawUtil.dot.color = circleColor;
DrawUtil.drawDot(corner.x, corner.y, 0.7);
DrawUtil.dot.animation.play("hollow");
buttonBoxes.push(corner);
}
if(sprite.extra.exists(exID("buttonBoxes"))) {
var oldButtonBoxes:Array<FlxPoint> = cast sprite.extra.get(exID("buttonBoxes"));
if(oldButtonBoxes != null)
for(point in oldButtonBoxes) point.put();
}
if(funkinSprite == null) {
for(corner in buttonBoxes) {
corner.put();
var buttonBoxes:Array<FlxPoint> = [];
if(sprite != null) sprite.extra.set(exID("buttonBoxes"), buttonBoxes);
DrawUtil.dot.color = 0xFFBBE4EA; DrawUtil.dot.animation.play("default");
for(i in 0...transformedCorners.length) {
var transformedCorner:FlxPoint = transformedCorners[i];
if (i != CENTER_INDEX) {
if (i == ANGLE_INDEX) {
DrawUtil.dot.animation.play("hollow"); DrawUtil.dot.color = 0xFFBBE4EA;
DrawUtil.drawDot(transformedCorner.x, transformedCorner.y, 0.5);
} else {
DrawUtil.dot.animation.play("default"); DrawUtil.dot.color = 0xFFF7A7A7;
DrawUtil.drawDot(transformedCorner.x, transformedCorner.y, 0.3);
DrawUtil.dot.animation.play("hollow"); DrawUtil.dot.color = 0xFFBBE4EA;
DrawUtil.drawDot(transformedCorner.x, transformedCorner.y, 0.5);
}
} else if (sprite.visible) {
DrawUtil.dot.color = 0xFFBBE4EA;
DrawUtil.drawDot(transformedCorner.x, transformedCorner.y, 0.7*0.5);
DrawUtil.dot.animation.play("hollow");
}
buttonBoxes.push(corners[i]);
}
}