11package funkin .objects .ui ;
22
33import flixel .util .FlxStringUtil ;
4+ import openfl .display .Sprite ;
45import openfl .text .TextField ;
56import openfl .text .TextFormat ;
67
78/**
89 * The performance stats TextField keeps track of FPS and Memory in-game.
910 */
10- class PerformanceStats extends TextField
11+ class PerformanceStats extends Sprite
1112{
1213 /**
1314 * How many frames have passed since the last second.
@@ -19,23 +20,67 @@ class PerformanceStats extends TextField
1920 */
2021 public var randomAccessMemory (get , null ): Null <Float >;
2122
23+ /**
24+ * The main text that shows FPS and RAM Usage.
25+ */
26+ public var mainText : TextField ;
27+
28+ /**
29+ * The outline text group.
30+ */
31+ public var outlineTextGrp : Sprite ;
32+
2233 var cacheCount : Int ;
2334 var currentTime : Float ;
2435 var times : Array <Float >;
2536
26- public function new (x : Float = 10 , y : Float = 10 , color : Int = 0x000000 )
37+ public function new (x : Float = 10 , y : Float = 10 )
2738 {
2839 super ();
40+ visible = true ;
41+
42+ outlineTextGrp = new Sprite ();
43+ addChild (outlineTextGrp );
44+
45+ mainText = new TextField ();
46+ mainText .x = x ;
47+ mainText .y = y ;
48+ addChild (mainText );
49+
50+ var outlinePosArray : Array <Array <Int >> = [];
2951
30- this .x = x ;
31- this .y = y ;
52+ // stolen from FlxText
53+ outlinePosArray .push ([- 1 , - 1 ]); // upper-left
54+ outlinePosArray .push ([1 , 0 ]); // upper-middle
55+ outlinePosArray .push ([1 , 0 ]); // upper-right
56+ outlinePosArray .push ([0 , 1 ]); // middle-right
57+ outlinePosArray .push ([0 , 1 ]); // lower-right
58+ outlinePosArray .push ([- 1 , 0 ]); // lower-middle
59+ outlinePosArray .push ([- 1 , 0 ]); // lower-left
60+ outlinePosArray .push ([0 , - 1 ]); // lower-left
61+
62+ for (pos in outlinePosArray )
63+ {
64+ var outlineText : TextField = new TextField ();
65+ outlineText .x = x + pos [0 ];
66+ outlineText .y = y + pos [1 ];
67+ outlineTextGrp .addChild (outlineText );
68+ }
3269
3370 framesPerSecond = 0 ;
3471
35- selectable = false ;
72+ mainText . selectable = false ;
3673 mouseEnabled = false ;
37- defaultTextFormat = new TextFormat (Paths .location .get (' ui/fonts/vcr.ttf' ), 12 , color );
38- text = ' ' ;
74+ mainText .defaultTextFormat = new TextFormat (Paths .location .get (' ui/fonts/vcr.ttf' ), 12 , 0xFFFFFF );
75+ mainText .text = ' ' ;
76+
77+ for (i in 0 ... outlineTextGrp .numChildren )
78+ {
79+ var outlineText : TextField = cast outlineTextGrp .getChildAt (i );
80+ outlineText .selectable = false ;
81+ outlineText .defaultTextFormat = new TextFormat (Paths .location .get (' ui/fonts/vcr.ttf' ), 12 , 0x000000 );
82+ outlineText .text = ' ' ;
83+ }
3984
4085 cacheCount = 0 ;
4186 currentTime = 0 ;
@@ -57,10 +102,18 @@ class PerformanceStats extends TextField
57102
58103 if (currentCount != cacheCount )
59104 {
60- text = getFramesPerSecond () + getRandomAccessMemory ();
105+ mainText .text = getFramesPerSecond () + getRandomAccessMemory ();
106+
107+ for (i in 0 ... outlineTextGrp .numChildren )
108+ {
109+ var outlineText : TextField = cast outlineTextGrp .getChildAt (i );
110+ outlineText .text = getFramesPerSecond () + getRandomAccessMemory ();
111+ }
61112 }
62113
63114 cacheCount = currentCount ;
115+
116+ super .__enterFrame (cast deltaTime );
64117 }
65118
66119 function getFramesPerSecond (): String
0 commit comments