Better debug character stuff

This commit is contained in:
lunarcleint
2024-07-19 01:40:45 -07:00
parent 6b537da762
commit dfe37ffaaf
4 changed files with 55 additions and 2 deletions
@@ -11,6 +11,7 @@ import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
import funkin.game.Character;
import haxe.xml.Access;
import haxe.xml.Printer;
import funkin.editors.extra.DrawAxis;
class CharacterEditor extends UIState {
static var __character:String;
@@ -27,6 +28,7 @@ class CharacterEditor extends UIState {
public var topMenuSpr:UITopMenu;
public var drawAxis:DrawAxis;
public var uiGroup:FlxTypedGroup<FlxSprite> = new FlxTypedGroup<FlxSprite>();
public var cameraHoverDummy:CameraHoverDummy;
@@ -180,6 +182,11 @@ class CharacterEditor extends UIState {
label: "Character Camera?",
onSelect: _view_character_show_camera,
icon: Options.characterCamera ? 1 : 0
},
{
label: "XY Axis?",
onSelect: _view_character_show_axis,
icon: Options.characterAxis ? 1 : 0
}
]
},
@@ -224,6 +231,10 @@ class CharacterEditor extends UIState {
add(character);
drawAxis = new DrawAxis();
drawAxis.cameras = [charCamera];
add(drawAxis);
uiGroup.cameras = [uiCamera];
add(cameraHoverDummy = new CameraHoverDummy(uiGroup, FlxPoint.weak(0, 0)));
@@ -302,6 +313,11 @@ class CharacterEditor extends UIState {
}
animationText.text = '"${character.getAnimName()}"';
// members.remove(drawAxis);
// var characterIndex:Int = members.indexOf(character);
// if (characterIndex != -1)
// members.insert(characterIndex, drawAxis);
super.update(elapsed);
}
@@ -480,6 +496,11 @@ class CharacterEditor extends UIState {
character.debugCamera = Options.characterCamera;
}
function _view_character_show_axis(t) {
t.icon = (Options.characterAxis = !Options.characterAxis) ? 1 : 0;
drawAxis.visible = Options.characterAxis;
}
function _view_focus_character(_) {
if (character == null) return;
+31
View File
@@ -0,0 +1,31 @@
package funkin.editors.extra;
import openfl.display.Graphics;
import flixel.util.FlxSpriteUtil;
class DrawAxis extends FlxObject {
public override function draw() {
super.draw();
for (camera in cameras) {
var gfx:Graphics = FlxG.renderBlit ? {
FlxSpriteUtil.flashGfx.clear();
FlxSpriteUtil.flashGfx;
} : camera.debugLayer.graphics;
// Stole these colors directly from godot
gfx.lineStyle(2, 0xFF76BC02, 1);
gfx.moveTo(-camera.scroll.x, camera.viewMarginTop);
gfx.lineTo(-camera.scroll.x, camera.viewMarginBottom);
gfx.lineStyle(2, 0xFFD72C47, 1);
gfx.moveTo(camera.viewMarginLeft, -camera.scroll.y);
gfx.lineTo(camera.viewMarginRight, -camera.scroll.y);
if (FlxG.renderBlit)
camera.buffer.draw(FlxSpriteUtil.flashGfxSprite);
}
}
}
+2 -2
View File
@@ -229,7 +229,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
_rect.set(_matrix.tx, _matrix.ty, frame.frame.width * _matrix.a, frame.frame.height * _matrix.d);
@:privateAccess _rect = camera.transformRect(_rect);
gfx.lineStyle(2, 0xFF00FF00, 0.75);
gfx.lineStyle(2, 0xFF007B8F, 1);
gfx.drawRect(_rect.x, _rect.y, _rect.width, _rect.height);
if (FlxG.renderBlit)
@@ -247,7 +247,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
var camPos:FlxPoint = getCameraPosition();
camPos -= camera.scroll;
gfx.lineStyle(2, 0xFF00FF00, 0.75);
gfx.lineStyle(2, 0xFF00A0B9, 1);
gfx.moveTo(camPos.x - 8, camPos.y);
gfx.lineTo(camPos.x + 8, camPos.y);
+1
View File
@@ -74,6 +74,7 @@ class Options
public static var stageSelected:String = null;
public static var characterHitbox:Bool = true;
public static var characterCamera:Bool = true;
public static var characterAxis:Bool = true;
/**
* PLAYER 1 CONTROLS