Skip to content

Commit

Permalink
Added a padding field and custom text function
Browse files Browse the repository at this point in the history
  • Loading branch information
sammoh94 committed Nov 6, 2017
1 parent 7de9834 commit ee7b6ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
20 changes: 15 additions & 5 deletions src/uiwidgets/DialogBox.as
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ public class DialogBox extends Sprite {
}
}

public function addTextWithCustomFunction(text:String, makeLabelFunc:Function):void {
for each (var s:String in text.split('\n')) {
var line:TextField = makeLabelFunc(Translator.map(s));
addChild(line);
textLines.push(line);
}
}

public function addWidget(o:DisplayObject):void {
widget = o;
addChild(o);
Expand Down Expand Up @@ -205,8 +213,8 @@ public class DialogBox extends Sprite {
buttons.push(b);
}

public function showOnStage(stage:Stage, center:Boolean = true):void {
fixLayout();
public function showOnStage(stage:Stage, center:Boolean = true, padding:Number = 0):void {
fixLayout(padding);
if (center) {
x = (stage.stageWidth - width) / 2;
y = (stage.stageHeight - height) / 2;
Expand Down Expand Up @@ -295,16 +303,17 @@ public class DialogBox extends Sprite {
return result;
}

public function fixLayout():void {
public function fixLayout(padding:Number = 0):void {
var label:TextField;
var i:int, totalW:int;
fixSize();
fixSize(padding);
var fieldX:int = maxLabelWidth + 17;
var fieldY:int = 15;
if (title != null) {
title.x = (w - title.width) / 2;
title.y = 5;
fieldY = title.y + title.height + 20;
fieldY += padding;
}
if (xButton != null) {
xButton.x = this.width-20;
Expand Down Expand Up @@ -362,13 +371,14 @@ public class DialogBox extends Sprite {
}
}

private function fixSize():void {
private function fixSize(padding:Number = 0):void {
var i:int, totalW:int;
w = h = 0;
// title
if (title != null) {
w = Math.max(w, title.width);
h += 10 + title.height;
h += padding;
}
// fields
maxLabelWidth = 0;
Expand Down
22 changes: 0 additions & 22 deletions src/util/OfflineTelemetry.as

This file was deleted.

0 comments on commit ee7b6ce

Please sign in to comment.