Skip to content

Commit e360343

Browse files
committed
updating console and default text
1 parent a8de2c8 commit e360343

File tree

5 files changed

+120
-118
lines changed

5 files changed

+120
-118
lines changed

net/flashpunk/Screen.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,6 @@
234234
/** @private */ private var _scaleY:Number = 1;
235235
/** @private */ private var _scale:Number = 1;
236236
/** @private */ private var _angle:Number = 0;
237-
/** @private */ private var _color:uint = 0xFF202020;
237+
/** @private */ private var _color:uint = 0xfff9f9f9;
238238
}
239239
}

net/flashpunk/debug/Console.as

Lines changed: 112 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -97,80 +97,86 @@ package net.flashpunk.debug
9797

9898
// Used to determine some text sizing.
9999
var big:Boolean = width >= 480;
100-
101-
// The transparent FlashPunk logo overlay bitmap.
100+
101+
// Draw the background.
102102
_sprite.addChild(_back);
103-
_back.bitmapData = new BitmapData(width, height, true, 0xFFFFFFFF);
104-
var b:BitmapData = (new CONSOLE_LOGO).bitmapData;
105-
FP.matrix.identity();
106-
FP.matrix.tx = Math.max((_back.bitmapData.width - b.width) / 2, 0);
107-
FP.matrix.ty = Math.max((_back.bitmapData.height - b.height) / 2, 0);
108-
FP.matrix.scale(Math.min(width / _back.bitmapData.width, 1), Math.min(height / _back.bitmapData.height, 1));
109-
_back.bitmapData.draw(b, FP.matrix, null, BlendMode.MULTIPLY);
110-
_back.bitmapData.draw(_back.bitmapData, null, null, BlendMode.INVERT);
111-
_back.bitmapData.colorTransform(_back.bitmapData.rect, new ColorTransform(1, 1, 1, 0.5));
103+
_back.graphics.clear();
104+
_back.graphics.beginFill(0x000000, 0.25);
105+
_back.graphics.drawRect(0, 0, width, height);
112106

113107
// The entity and selection sprites.
114108
_sprite.addChild(_entScreen);
115109
_entScreen.addChild(_entSelect);
116110

111+
// The top tray.
112+
_sprite.addChild(_topTray);
113+
_topTray.graphics.clear();
114+
_topTray.graphics.beginFill(0x000000, 0.6);
115+
_topTray.graphics.drawRect(0, 0, width, 20);
116+
_topTray.graphics.beginFill(0x000000, 0.7);
117+
_topTray.graphics.drawRect(0, 20, width, 1);
118+
117119
// The entity count text.
118-
_sprite.addChild(_entRead);
119-
_entRead.addChild(_entReadText);
120-
_entReadText.defaultTextFormat = format(16, 0xFFFFFF, "right");
120+
_topTray.addChild(_entReadText);
121+
_entReadText.defaultTextFormat = format(12, 0xffffff, "right", true);
121122
_entReadText.embedFonts = true;
122123
_entReadText.width = 100;
123124
_entReadText.height = 20;
124-
_entRead.x = width - _entReadText.width;
125-
126-
// The entity count panel.
127-
_entRead.graphics.clear();
128-
_entRead.graphics.beginFill(0, .5);
129-
_entRead.graphics.drawRoundRectComplex(0, 0, _entReadText.width, 20, 0, 0, 20, 0);
125+
_entReadText.x = width - _entReadText.width;
130126

131127
// The FPS text.
132-
_sprite.addChild(_fpsRead);
133-
_fpsRead.addChild(_fpsReadText);
134-
_fpsReadText.defaultTextFormat = format(16);
128+
_topTray.addChild(_fpsReadText);
129+
_fpsReadText.defaultTextFormat = format(12, 0xffffff, "left", true);
135130
_fpsReadText.embedFonts = true;
136131
_fpsReadText.width = 70;
137132
_fpsReadText.height = 20;
138133
_fpsReadText.x = 2;
139134
_fpsReadText.y = 1;
140135

141-
// The FPS and frame timing panel.
142-
_fpsRead.graphics.clear();
143-
_fpsRead.graphics.beginFill(0, .75);
144-
_fpsRead.graphics.drawRoundRectComplex(0, 0, big ? 320 : 160, 20, 0, 0, 0, 20);
145-
146136
// The frame timing text.
147-
if (big) _sprite.addChild(_fpsInfo);
148-
_fpsInfo.addChild(_fpsInfoText0);
149-
_fpsInfo.addChild(_fpsInfoText1);
150-
_fpsInfoText0.defaultTextFormat = format(8, 0xAAAAAA);
151-
_fpsInfoText1.defaultTextFormat = format(8, 0xAAAAAA);
152-
_fpsInfoText0.embedFonts = true;
153-
_fpsInfoText1.embedFonts = true;
154-
_fpsInfoText0.width = _fpsInfoText1.width = 60;
155-
_fpsInfoText0.height = _fpsInfoText1.height = 20;
156-
_fpsInfo.x = 75;
157-
_fpsInfoText1.x = 60;
137+
if (big)
138+
{
139+
_topTray.addChild(_fpsInfo);
140+
// Add text fields.
141+
for (var i:uint = 0; i < _fpsInfoText.length; i++)
142+
{
143+
_fpsInfoText[i] = new TextField();
144+
_fpsInfoText[i].defaultTextFormat = format(12);
145+
_fpsInfoText[i].embedFonts = true;
146+
_fpsInfoText[i].width = 100;
147+
_fpsInfoText[i].height = 20;
148+
_fpsInfoText[i].x = 100 * i;
149+
_fpsInfoText[i].y = 1;
150+
_fpsInfo.addChild(_fpsInfoText[i]);
151+
}
152+
153+
_fpsInfo.x = 75;
154+
}
158155

159156
// The memory usage
160-
_fpsRead.addChild(_memReadText);
161-
_memReadText.defaultTextFormat = format(16);
157+
_topTray.addChild(_memReadText);
158+
_memReadText.defaultTextFormat = format(12, 0xffffff, "left", true);
162159
_memReadText.embedFonts = true;
163160
_memReadText.width = 110;
164161
_memReadText.height = 20;
165162
_memReadText.x = _fpsInfo.x + _fpsInfo.width + 5;
166163
_memReadText.y = 1;
164+
165+
// The bottom tray.
166+
_sprite.addChild(_bottomTray);
167+
_bottomTray.graphics.clear();
168+
_bottomTray.graphics.beginFill(0x000000, 0.6);
169+
_bottomTray.graphics.drawRect(0, 1, width, 20);
170+
_bottomTray.graphics.beginFill(0x000000, 0.7);
171+
_bottomTray.graphics.drawRect(0, 0, width, 1);
172+
_bottomTray.y = height - 21;
167173

168174
// The output log text.
169-
_sprite.addChild(_logRead);
170-
_logRead.addChild(_logReadText0);
175+
_bottomTray.addChild(_logRead);
176+
// TODO: Removed _logReadText0. Need to remove all traces.
171177
_logRead.addChild(_logReadText1);
172-
_logReadText0.defaultTextFormat = format(16, 0xFFFFFF);
173-
_logReadText1.defaultTextFormat = format(big ? 16 : 8, 0xFFFFFF);
178+
_logReadText0.defaultTextFormat = format(12, 0xFFFFFF);
179+
_logReadText1.defaultTextFormat = format(12, 0xFFFFFF);
174180
_logReadText0.embedFonts = true;
175181
_logReadText1.embedFonts = true;
176182
_logReadText0.selectable = false;
@@ -179,20 +185,19 @@ package net.flashpunk.debug
179185
_logReadText1.width = width;
180186
_logReadText0.x = 2;
181187
_logReadText0.y = 3;
182-
_logReadText0.text = "OUTPUT:";
188+
_logReadText0.text = "OUTPUT";
183189
_logHeight = height - 60;
184-
_logBar = new Rectangle(8, 24, 16, _logHeight - 8);
190+
_logBar = new Rectangle(4, 4, 16, _logHeight - 8);
185191
_logBarGlobal = _logBar.clone();
186-
_logBarGlobal.y += 40;
187-
if (big) _logLines = _logHeight / 16.5;
188-
else _logLines = _logHeight / 8.5;
192+
_logBarGlobal.y += 60;
193+
_logLines = _logHeight / 15.7;
189194

190195
// The debug text.
191196
_sprite.addChild(_debRead);
192197
_debRead.addChild(_debReadText0);
193198
_debRead.addChild(_debReadText1);
194-
_debReadText0.defaultTextFormat = format(16, 0xFFFFFF);
195-
_debReadText1.defaultTextFormat = format(8, 0xFFFFFF);
199+
_debReadText0.defaultTextFormat = format(12, 0xFFFFFF);
200+
_debReadText1.defaultTextFormat = format(12, 0xFFFFFF);
196201
_debReadText0.embedFonts = true;
197202
_debReadText1.embedFonts = true;
198203
_debReadText0.selectable = false;
@@ -638,23 +643,22 @@ package net.flashpunk.debug
638643
if (_paused)
639644
{
640645
// Draw the log panel.
641-
_logRead.y = 40;
642-
_logRead.graphics.clear();
643-
_logRead.graphics.beginFill(0, .75);
644-
_logRead.graphics.drawRoundRectComplex(0, 0, _logReadText0.width, 20, 0, 20, 0, 0);
645-
_logRead.graphics.drawRect(0, 20, width, _logHeight);
646-
647-
// Draw the log scrollbar.
648-
_logRead.graphics.beginFill(0x202020, 1);
649-
_logRead.graphics.drawRoundRectComplex(_logBar.x, _logBar.y, _logBar.width, _logBar.height, 8, 8, 8, 8);
646+
_bottomTray.y = 60;
647+
_bottomTray.graphics.clear();
648+
_bottomTray.graphics.beginFill(0, .7);
649+
_bottomTray.graphics.drawRect(0, 1, width, _logHeight);
650+
_bottomTray.graphics.beginFill(0, .8);
651+
_bottomTray.graphics.drawRect(0, 0, width, 1);
652+
_bottomTray.graphics.beginFill(0, 0.5);
653+
_bottomTray.graphics.drawRoundRectComplex(_logBar.x, _logBar.y, _logBar.width, _logBar.height, 5, 5, 5, 5);
650654

651655
// If the log has more lines than the display limit.
652656
if (LOG.length > _logLines)
653657
{
654658
// Draw the log scrollbar handle.
655-
_logRead.graphics.beginFill(0xFFFFFF, 1);
656659
var y:uint = _logBar.y + 2 + (_logBar.height - 16) * _logScroll;
657-
_logRead.graphics.drawRoundRectComplex(_logBar.x + 2, y, 12, 12, 6, 6, 6, 6);
660+
_bottomTray.graphics.beginFill(0xFFFFFF, 1);
661+
_bottomTray.graphics.drawRoundRectComplex(_logBar.x + 2, y, 12, 12, 4, 4, 4, 4);
658662
}
659663

660664
// Display the log text lines.
@@ -677,54 +681,46 @@ package net.flashpunk.debug
677681

678682
// Indent the text for the scrollbar and size it to the log panel.
679683
_logReadText1.height = _logHeight;
680-
_logReadText1.x = 32;
681-
_logReadText1.y = 24;
682-
683-
// Make text selectable in paused mode.
684-
_fpsReadText.selectable = true;
685-
_fpsInfoText0.selectable = true;
686-
_fpsInfoText1.selectable = true;
687-
_memReadText.selectable = true;
688-
_entReadText.selectable = true;
689-
_debReadText1.selectable = true;
684+
_logReadText1.x = _logBar.right + 4;
685+
_logReadText1.y = 4;
690686
}
691687
else
692-
{
693-
// Draw the single-line log panel.
694-
_logRead.y = height - 40;
695-
_logReadText1.height = 20;
696-
_logRead.graphics.clear();
697-
_logRead.graphics.beginFill(0, .75);
698-
_logRead.graphics.drawRoundRectComplex(0, 0, _logReadText0.width, 20, 0, 20, 0, 0);
699-
_logRead.graphics.drawRect(0, 20, width, 20);
700-
688+
{
701689
// Draw the single-line log text with the latests logged text.
690+
_bottomTray.graphics.clear();
691+
_bottomTray.graphics.beginFill(0x000000, 0.6);
692+
_bottomTray.graphics.drawRect(0, 1, width, 20);
693+
_bottomTray.graphics.beginFill(0x000000, 0.7);
694+
_bottomTray.graphics.drawRect(0, 0, width, 1);
695+
_bottomTray.y = height - 21;
696+
702697
_logReadText1.text = LOG.length ? LOG[LOG.length - 1] : "";
703698
_logReadText1.x = 2;
704-
_logReadText1.y = 21;
705-
706-
// Make text non-selectable while running.
707-
_logReadText1.selectable = false;
708-
_fpsReadText.selectable = false;
709-
_fpsInfoText0.selectable = false;
710-
_fpsInfoText1.selectable = false;
711-
_memReadText.selectable = false;
712-
_entReadText.selectable = false;
713-
_debReadText0.selectable = false;
714-
_debReadText1.selectable = false;
699+
_logReadText1.y = 1;
715700
}
701+
702+
// Update selectability of TextFields.
703+
_logReadText1.selectable = _paused;
704+
_fpsReadText.selectable = _paused;
705+
for each (var textField:TextField in _fpsInfoText)
706+
{
707+
textField.selectable = _paused;
708+
}
709+
_memReadText.selectable = _paused;
710+
_entReadText.selectable = _paused;
711+
_debReadText0.selectable = _paused;
712+
_debReadText1.selectable = _paused;
716713
}
717714

718715
/** @private Update the FPS/frame timing panel text. */
719716
private function updateFPSRead():void
720717
{
721718
_fpsReadText.text = "FPS: " + FP.frameRate.toFixed();
722-
_fpsInfoText0.text =
723-
"Update: " + String(FP._updateTime) + "ms\n" +
724-
"Render: " + String(FP._renderTime) + "ms";
725-
_fpsInfoText1.text =
726-
"Game: " + String(FP._gameTime) + "ms\n" +
727-
"Flash: " + String(FP._flashTime) + "ms";
719+
_fpsReadText.textColor = FP.frameRate > 30 ? FP.frameRate > 45 ? 0x91ff00 : 0xffe500 : 0xff4d00;
720+
_fpsInfoText[0].text = "Update: " + String(FP._updateTime) + "ms";
721+
_fpsInfoText[1].text = "Render: " + String(FP._renderTime) + "ms";
722+
_fpsInfoText[2].text = "Game: " + String(FP._gameTime) + "ms";
723+
_fpsInfoText[3].text = "Flash: " + String(FP._flashTime) + "ms";
728724
_memReadText.text = "MEM: " + Number(System.totalMemory/1024/1024).toFixed(2) + "MB";
729725
}
730726

@@ -815,11 +811,12 @@ package net.flashpunk.debug
815811
}
816812

817813
/** @private Gets a TextFormat object with the formatting. */
818-
private function format(size:uint = 16, color:uint = 0xFFFFFF, align:String = "left"):TextFormat
814+
private function format(size:uint = 12, color:uint = 0xFFFFFF, align:String = "left", isBold:Boolean = false):TextFormat
819815
{
820816
_format.size = size;
821817
_format.color = color;
822818
_format.align = align;
819+
_format.bold = isBold;
823820
return _format;
824821
}
825822

@@ -840,15 +837,16 @@ package net.flashpunk.debug
840837

841838
// Console display objects.
842839
/** @private */ private var _sprite:Sprite = new Sprite;
843-
/** @private */ private var _format:TextFormat = new TextFormat("default");
844-
/** @private */ private var _back:Bitmap = new Bitmap;
840+
/** @private */ private var _format:TextFormat = new TextFormat("Source Code Pro");
841+
/** @private */ private var _back:Sprite = new Sprite;
842+
/** @private */ private var _topTray:Sprite = new Sprite;
843+
/** @private */ private var _bottomTray:Sprite = new Sprite;
845844

846845
// FPS panel information.
847846
/** @private */ private var _fpsRead:Sprite = new Sprite;
848847
/** @private */ private var _fpsReadText:TextField = new TextField;
849848
/** @private */ private var _fpsInfo:Sprite = new Sprite;
850-
/** @private */ private var _fpsInfoText0:TextField = new TextField;
851-
/** @private */ private var _fpsInfoText1:TextField = new TextField;
849+
/** @private */ private var _fpsInfoText:Vector.<TextField> = new Vector.<TextField>(4);
852850
/** @private */ private var _memReadText:TextField = new TextField;
853851

854852
// Output panel information.
@@ -895,12 +893,16 @@ package net.flashpunk.debug
895893
/** @private */ private const WATCH_LIST:Vector.<String> = Vector.<String>(["x", "y"]);
896894

897895
// Embedded assets.
898-
[Embed(source = 'console_logo.png')] private const CONSOLE_LOGO:Class;
899-
[Embed(source = 'console_debug.png')] private const CONSOLE_DEBUG:Class;
900-
[Embed(source = 'console_output.png')] private const CONSOLE_OUTPUT:Class;
901-
[Embed(source = 'console_play.png')] private const CONSOLE_PLAY:Class;
902-
[Embed(source = 'console_pause.png')] private const CONSOLE_PAUSE:Class;
903-
[Embed(source = 'console_step.png')] private const CONSOLE_STEP:Class;
896+
[Embed(source = 'console_debug.png')]
897+
/** @private */ private const CONSOLE_DEBUG:Class;
898+
[Embed(source = 'console_output.png')]
899+
/** @private */ private const CONSOLE_OUTPUT:Class;
900+
[Embed(source = 'console_play.png')]
901+
/** @private */ private const CONSOLE_PLAY:Class;
902+
[Embed(source = 'console_pause.png')]
903+
/** @private */ private const CONSOLE_PAUSE:Class;
904+
[Embed(source = 'console_step.png')]
905+
/** @private */ private const CONSOLE_STEP:Class;
904906

905907
// Reference the Text class so we can access its embedded font
906908
private static var textRef:Text;
90.5 KB
Binary file not shown.
87.9 KB
Binary file not shown.

net/flashpunk/graphics/Text.as

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/**
1919
* The font to assign to new Text objects.
2020
*/
21-
public static var font:String = "default";
21+
public static var font:String = "Source Code Pro";
2222

2323
/**
2424
* The font size to assign to new Text objects.
2525
*/
26-
public static var size:uint = 16;
26+
public static var size:uint = 12;
2727

2828
/**
2929
* The alignment to assign to new Text objects.
@@ -106,7 +106,7 @@
106106

107107
_field.embedFonts = true;
108108
_field.wordWrap = _wordWrap;
109-
_form = new TextFormat(_font, _size, 0xFFFFFF);
109+
_form = new TextFormat(_font, _size, 0x333333);
110110
_form.align = _align;
111111
_form.leading = _leading;
112112
_field.defaultTextFormat = _form;
@@ -544,10 +544,10 @@
544544
/** @protected */ protected var _wordWrap:Boolean;
545545

546546
// Default font family.
547-
// Use this option when compiling with Flex SDK 3 or lower
548-
// [Embed(source = '04B_03__.TTF', fontFamily = 'default')]
549-
// Use this option when compiling with Flex SDK 4
550-
[Embed(source = '04B_03__.TTF', embedAsCFF="false", fontFamily = 'default')]
547+
[Embed(source = 'SourceCodePro-Regular.otf', embedAsCFF="false", fontFamily = "Source Code Pro")]
551548
/** @private */ private static var _FONT_DEFAULT:Class;
549+
550+
[Embed(source = 'SourceCodePro-Bold.otf', embedAsCFF="false", fontFamily = "Source Code Pro", fontWeight = "bold")]
551+
/** @private */ private static var _FONT_BOLD:Class;
552552
}
553553
}

0 commit comments

Comments
 (0)