Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various debug tool improvements #3366

Open
wants to merge 54 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8b50be7
add log bitmap interaction
Geokureli Feb 6, 2025
398304b
fix cursor offset
Feb 7, 2025
f758154
add FlxGraphicAsset.resolveBitmap()
Feb 7, 2025
f88e63d
add capitalizeFirstLetters and isRomanNumeral
Geokureli Feb 7, 2025
8e72c8c
add cursor offset
Geokureli Feb 9, 2025
e6da60e
fix interaction bugs
Geokureli Feb 9, 2025
a1fa4ba
small changes to LogBitmap
Geokureli Feb 9, 2025
215fffc
add FlxG.debugger.tools and windows
Geokureli Feb 9, 2025
c7e055c
add TrackObject
Geokureli Feb 9, 2025
a8d0502
add remove button to BitmapLog window
Geokureli Feb 9, 2025
a22c574
major changes to Watch window
Geokureli Feb 9, 2025
4dd985d
Merge remote-tracking branch 'origin/dev' into image-debugging
Geokureli Feb 9, 2025
9a4ff68
add window shortcut
Geokureli Feb 12, 2025
497e39a
only update visible watch entries
Geokureli Feb 12, 2025
c625305
CI
Geokureli Feb 12, 2025
e2015d6
optional arg
Geokureli Feb 14, 2025
855a7c1
fix CI
Geokureli Feb 14, 2025
5fda4bd
add scroll bars to watch
Geokureli Feb 14, 2025
61a5ad4
move ScrollSprite to separate class
Geokureli Feb 15, 2025
0f11cb6
refactor Pointer
Geokureli Feb 15, 2025
62570fc
don't dispose bitmaps in BitmapLog
Geokureli Feb 15, 2025
91bfa2a
fix weird HL issue
Geokureli Feb 16, 2025
f360e0c
Use Icons.hx for all debug bitmaps
Geokureli Feb 16, 2025
74ba394
revert sprite overlap check
Geokureli Feb 17, 2025
b8cf234
use watch cursor in track obj tool
Geokureli Feb 17, 2025
df10203
lower alpha threshold on pointer
Geokureli Feb 17, 2025
82be413
refactor transform tool
Geokureli Feb 17, 2025
cb024ef
remove watch logs
Geokureli Feb 18, 2025
d934936
Merge branch 'dev' into image-debugging
Geokureli Feb 18, 2025
872c7df
Fix release CI
Geokureli Feb 18, 2025
9f1b385
fix flash cursor
Geokureli Feb 18, 2025
e480eb7
Merge branch 'dev' into image-debugging
Geokureli Feb 18, 2025
05df330
refactor BitmapLog window
Geokureli Feb 19, 2025
4bdaea7
Fix drag handle
Geokureli Feb 19, 2025
e3733fb
final touches
Geokureli Feb 19, 2025
954c3b2
fix coverage
Geokureli Feb 19, 2025
e8d8cce
fix flash
Geokureli Feb 19, 2025
052c07f
revert transform test CI
Geokureli Feb 19, 2025
ec67bfc
add private classes (test CI)
Geokureli Feb 19, 2025
44ae446
more CI tests
Geokureli Feb 19, 2025
63e3926
even more CI tests
Geokureli Feb 19, 2025
672ff11
d'oh
Geokureli Feb 19, 2025
0829bda
more ci 2
Geokureli Feb 19, 2025
6e9591c
ci test 3
Geokureli Feb 19, 2025
ca6ffcb
ci test 4
Geokureli Feb 19, 2025
019eeb0
ci test 5
Geokureli Feb 19, 2025
1967071
D'OH
Geokureli Feb 19, 2025
21fdf87
fingers crossed
Geokureli Feb 19, 2025
670b83f
finalize after CI tests
Geokureli Feb 19, 2025
f87723c
more testing BOO
Geokureli Feb 20, 2025
4b91732
more tests 2-2
Geokureli Feb 20, 2025
23e9c1a
test ci 2-3
Geokureli Feb 20, 2025
3979fdc
test ci 2-4
Geokureli Feb 20, 2025
0545e37
test CI 2-5
Geokureli Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
major changes to Watch window
  • Loading branch information
Geokureli committed Feb 9, 2025
commit a22c574e748c82678fb923af3fde0986a5f7a638
10 changes: 7 additions & 3 deletions flixel/system/debug/watch/EditableTextField.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package flixel.system.debug.watch;

import flixel.math.FlxMath;
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
import flixel.util.FlxDestroyUtil;
import flixel.util.FlxColor;
import openfl.events.FocusEvent;
import openfl.events.KeyboardEvent;
import openfl.events.MouseEvent;
Expand All @@ -11,6 +12,8 @@ import openfl.text.TextFormat;
import openfl.ui.Keyboard;
import Type.ValueType;

using StringTools;

class EditableTextField extends TextField implements IFlxDestroyable
{
public var isEditing(default, null):Bool;
Expand Down Expand Up @@ -142,10 +145,11 @@ class EditableTextField extends TextField implements IFlxDestroyable
{
var value:Dynamic = switch (expectedType)
{
#if neko
// #if neko
case TInt if (text.startsWith("#") || text.startsWith("0x")): FlxColor.fromString(text);
case TInt: Std.parseInt(text);
case TFloat: Std.parseFloat(text);
#end
// #end
case TBool if (text == "true"): true;
case TBool if (text == "false"): false;
case TEnum(e):
Expand Down
147 changes: 119 additions & 28 deletions flixel/system/debug/watch/Watch.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package flixel.system.debug.watch;

import openfl.display.DisplayObject;
import flixel.FlxG;
import flixel.math.FlxPoint;
import flixel.system.debug.FlxDebugger.GraphicWatch;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.events.MouseEvent;
import openfl.geom.Rectangle;

using flixel.util.FlxStringUtil;
using flixel.util.FlxArrayUtil;
Expand All @@ -12,32 +16,47 @@ using flixel.util.FlxArrayUtil;
* A Visual Studio-style "watch" window, for use in the debugger overlay.
* Track the values of any public variable in real-time, and/or edit their values on the fly.
*/
class Watch extends Window
class Watch extends WatchBase<WatchEntry>
{
#if FLX_DEBUG
static inline var LINE_HEIGHT:Int = 15;

var entriesContainer:Sprite;
var entriesContainerOffset:FlxPoint = FlxPoint.get(2, 15);
var entries:Array<WatchEntry> = [];

public function new(closable:Bool = false)
public function new(closable = false)
{
super("Watch", new GraphicWatch(0, 0), 0, 0, true, null, closable);
super(WatchEntry.new, "Watch", new GraphicWatch(0, 0), true, null, closable);
}
#end
}

entriesContainer = new Sprite();
entriesContainer.x = entriesContainerOffset.x;
entriesContainer.y = entriesContainerOffset.y;
class WatchBase<TEntry:WatchEntry> extends Window
{
#if FLX_DEBUG
static inline var LINE_HEIGHT:Int = 15;

public var alwaysOnTop(get, set):Bool;
inline function get_alwaysOnTop() return _alwaysOnTop;
inline function set_alwaysOnTop(value:Bool) return _alwaysOnTop = value;

final entriesContainer:ScrollSprite;
final entries:Array<TEntry> = [];
var create:(displayName:String, data:WatchEntryData)->TEntry;

public function new(entryConstructor, title, ?icon, resizable = true, ?bounds, closable = false, alwaysOnTop = true)
{
create = entryConstructor;
super(title, icon, 0, 0, resizable, bounds, closable, alwaysOnTop);

entriesContainer = new ScrollSprite();
entriesContainer.x = 2;
entriesContainer.y = 15;
addChild(entriesContainer);

FlxG.signals.preStateSwitch.add(clear);
}

public function add(displayName:String, data:WatchEntryData):Void
{
if (isInvalid(displayName, data))
return;

var existing = getExistingEntry(displayName, data);
if (existing != null)
{
Expand Down Expand Up @@ -67,7 +86,7 @@ class Watch extends Window
}
}

function getExistingEntry(displayName:String, data:WatchEntryData):WatchEntry
function getExistingEntry(displayName:String, data:WatchEntryData):TEntry
{
for (entry in entries)
{
Expand All @@ -82,22 +101,24 @@ class Watch extends Window
return null;
}

function addEntry(displayName:String, data:WatchEntryData):Void
function addEntry(displayName:String, data:WatchEntryData, redraw = true)
{
var entry = new WatchEntry(displayName, data, removeEntry);
final entry = create(displayName, data);
entry.onRemove.addOnce(removeEntry.bind(entry));
entries.push(entry);
entriesContainer.addChild(entry);
updateSize();
if (redraw)
updateSize();
}

public function remove(displayName:String, data:WatchEntryData):Void
{
var existing = getExistingEntry(displayName, data);
final existing = getExistingEntry(displayName, data);
if (existing != null)
removeEntry(existing);
}

function removeEntry(entry:WatchEntry):Void
function removeEntry(entry:TEntry)
{
entries.fastSplice(entry);
entriesContainer.removeChild(entry);
Expand All @@ -122,7 +143,6 @@ class Watch extends Window
public function removeAll():Void
{
clear();
updateSize();
}

override public function update():Void
Expand All @@ -133,19 +153,34 @@ class Watch extends Window

override function updateSize():Void
{
resetEntries();
minSize.setTo(getMaxMinWidth() + entriesContainerOffset.x, entriesContainer.height + entriesContainerOffset.y);
final oldMinSize = minSize.x;
super.updateSize();
reposition(x, y);
minSize.x = oldMinSize;

entriesContainer.setScrollSize(getMarginWidth(), getMarginHeight());
resetEntries();
}


function getMarginWidth()
{
return _width - entriesContainer.x - (_resizable ? 5 : 3);
}

function getMarginHeight()
{
return _height - entriesContainer.y - 3;
}

function resetEntries():Void
{
final width = getMarginWidth();
final sansNameWidth = Math.min(width * 0.8, getMaxMinWidth());
final nameWidth = Math.min(getMaxNameWidth(), width - sansNameWidth);
for (i in 0...entries.length)
{
var entry = entries[i];
final entry = entries[i];
entry.y = i * LINE_HEIGHT;
entry.updateSize(getMaxNameWidth(), _width);
entry.updateSize(nameWidth, width);
}
}

Expand All @@ -172,3 +207,59 @@ class Watch extends Window
}
#end
}

class ScrollSprite extends Sprite
{
var scroll = new Rectangle();

public function new ()
{
super();

addEventListener(Event.ADDED_TO_STAGE, function (e)
{
final stage = this.stage;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseScroll);
addEventListener(Event.REMOVED_FROM_STAGE, (_)->stage.removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseScroll));
});
}

function onMouseScroll(e:MouseEvent)
{
FlxG.watch.addQuick("mouseX", mouseX);
FlxG.watch.addQuick("mouseY", mouseY);
FlxG.watch.addQuick("scroll", scroll);
if (mouseX > 0 && mouseX < scroll.width && mouseY - scroll.y > 0 && mouseY - scroll.y < scroll.height)
{
scroll.y -= e.delta;
updateScroll();
}
}

public function setScrollSize(width:Float, height:Float)
{
scroll.width = width;
scroll.height = height;
updateScroll();
}

function updateScroll()
{
scrollRect = null;

if (scroll.bottom > this.height)
scroll.y = height - scroll.height;

if (scroll.y < 0)
scroll.y = 0;

scrollRect = scroll;
}

override function addChild(child)
{
super.addChild(child);
updateScroll();
return child;
}
}
Loading