@@ -3,25 +3,25 @@ package flixel.system.debug;
33import openfl .display .BitmapData ;
44import openfl .display .Sprite ;
55#if FLX_DEBUG
6- import openfl .events .MouseEvent ;
7- import openfl .geom .Point ;
8- import openfl .geom .Rectangle ;
9- import openfl .text .TextField ;
10- import openfl .text .TextFieldAutoSize ;
11- import openfl .text .TextFormat ;
12- import openfl .display .DisplayObject ;
136import flixel .FlxG ;
7+ import flixel .system .FlxAssets ;
8+ import flixel .system .debug .completion .CompletionList ;
149import flixel .system .debug .console .Console ;
10+ import flixel .system .debug .interaction .Interaction ;
11+ import flixel .system .debug .log .BitmapLog ;
1512import flixel .system .debug .log .Log ;
1613import flixel .system .debug .stats .Stats ;
17- import flixel .system .debug .watch .Watch ;
1814import flixel .system .debug .watch .Tracker ;
19- import flixel .system .debug .completion .CompletionList ;
20- import flixel .system .debug .log .BitmapLog ;
21- import flixel .system .debug .interaction .Interaction ;
22- import flixel .system .FlxAssets ;
15+ import flixel .system .debug .watch .Watch ;
2316import flixel .system .ui .FlxSystemButton ;
2417import flixel .util .FlxHorizontalAlign ;
18+ import openfl .display .DisplayObject ;
19+ import openfl .events .MouseEvent ;
20+ import openfl .geom .Point ;
21+ import openfl .geom .Rectangle ;
22+ import openfl .text .TextField ;
23+ import openfl .text .TextFieldAutoSize ;
24+ import openfl .text .TextFormat ;
2525
2626using flixel .util .FlxArrayUtil ;
2727#end
@@ -33,6 +33,20 @@ using flixel.util.FlxArrayUtil;
3333class FlxDebugger extends openfl.display. Sprite
3434{
3535 #if FLX_DEBUG
36+
37+
38+ /**
39+ * The scale of the debug windows must be set before the `FlxGame` is made.
40+ * Can also use the compile flag `-DFLX_DEBUGGER_SCALE=2`
41+ */
42+ public static var defaultScale : Int
43+ #if FLX_DEBUGGER_SCALE
44+ = Std .parseInt (' ${haxe.macro. Compiler .getDefine (" FLX_DEBUGGER_SCALE" )}' );
45+ #else
46+ = 1 ;
47+ #end
48+
49+
3650 /**
3751 * Internal, used to space out windows from the edges.
3852 */
@@ -50,6 +64,7 @@ class FlxDebugger extends openfl.display.Sprite
5064 public var vcr : VCR ;
5165 public var console : Console ;
5266 public var interaction : Interaction ;
67+ public var scale : Int ;
5368
5469 var completionList : CompletionList ;
5570
@@ -84,13 +99,18 @@ class FlxDebugger extends openfl.display.Sprite
8499 /**
85100 * Instantiates the debugger overlay.
86101 *
87- * @param Width The width of the screen.
88- * @param Height The height of the screen.
102+ * @param width The width of the screen.
103+ * @param height The height of the screen.
104+ * @param scale The scale of the debugger relative to the stage size
89105 */
90106 @:allow (flixel. FlxGame )
91- function new (Width : Float , Height : Float )
107+ function new (width : Float , height : Float , scale = 0 )
92108 {
93109 super ();
110+ if (scale == 0 )
111+ scale = defaultScale ;
112+ scaleX = scale ;
113+ scaleY = scale ;
94114
95115 visible = false ;
96116 tabChildren = false ;
@@ -99,7 +119,7 @@ class FlxDebugger extends openfl.display.Sprite
99119
100120 _topBar = new Sprite ();
101121 _topBar .graphics .beginFill (0x000000 , 0xAA / 255 );
102- _topBar .graphics .drawRect (0 , 0 , FlxG .stage .stageWidth , TOP_HEIGHT );
122+ _topBar .graphics .drawRect (0 , 0 , FlxG .stage .stageWidth / scaleX , TOP_HEIGHT );
103123 _topBar .graphics .endFill ();
104124 addChild (_topBar );
105125
@@ -148,7 +168,7 @@ class FlxDebugger extends openfl.display.Sprite
148168
149169 addChild (completionList );
150170
151- onResize (Width , Height );
171+ onResize (width , height );
152172
153173 addEventListener (MouseEvent .MOUSE_OVER , onMouseOver );
154174 addEventListener (MouseEvent .MOUSE_OUT , onMouseOut );
@@ -292,16 +312,19 @@ class FlxDebugger extends openfl.display.Sprite
292312 }
293313 }
294314
295- public function onResize (Width : Float , Height : Float ): Void
315+ public function onResize (width : Float , height : Float , scale = 0 ): Void
296316 {
297- _screen .x = Width ;
298- _screen .y = Height ;
317+ if (scale == 0 )
318+ scale = defaultScale ;
319+ this .scale = scale ;
320+ _screen .x = width / scale ;
321+ _screen .y = height / scale ;
299322
300323 updateBounds ();
301- _topBar .width = FlxG .stage .stageWidth ;
324+ _topBar .width = FlxG .stage .stageWidth / scaleX ;
302325 resetButtonLayout ();
303326 resetLayout ();
304- scaleX = scaleY = 1 ;
327+ scaleX = scaleY = scale ;
305328 x = - FlxG .scaleMode .offset .x ;
306329 y = - FlxG .scaleMode .offset .y ;
307330 }
@@ -342,10 +365,10 @@ class FlxDebugger extends openfl.display.Sprite
342365 {
343366 hAlignButtons (_buttons [FlxHorizontalAlign .LEFT ], 10 , true , 10 );
344367
345- var offset = FlxG .stage .stageWidth * 0.5 - hAlignButtons (_buttons [FlxHorizontalAlign .CENTER ], 10 , false ) * 0.5 ;
368+ var offset = FlxG .stage .stageWidth / scaleX * 0.5 - hAlignButtons (_buttons [FlxHorizontalAlign .CENTER ], 10 , false ) * 0.5 ;
346369 hAlignButtons (_buttons [FlxHorizontalAlign .CENTER ], 10 , true , offset );
347370
348- var offset = FlxG .stage .stageWidth - hAlignButtons (_buttons [FlxHorizontalAlign .RIGHT ], 10 , false );
371+ var offset = FlxG .stage .stageWidth / scaleX - hAlignButtons (_buttons [FlxHorizontalAlign .RIGHT ], 10 , false );
349372 hAlignButtons (_buttons [FlxHorizontalAlign .RIGHT ], 10 , true , offset );
350373 }
351374
0 commit comments