Skip to content

Commit ad0ff4d

Browse files
committed
Added BuildFromConfig for Text object.
Updated TextStyle to use advanced object getter.
1 parent c0254bb commit ad0ff4d

5 files changed

Lines changed: 54 additions & 7 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'c643e530-2635-11e7-8f31-f17aeae256a1'
2+
build: '03e0ccd0-29d0-11e7-a448-d72a056ead60'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/text/TextStyle.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Class = require('../../utils/Class');
2-
var GetObjectValue = require('../../utils/object/GetObjectValue');
2+
// var GetObjectValue = require('../../utils/object/GetObjectValue');
3+
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
34
var MeasureText = require('./MeasureText');
45

56
// Key: [ Object Key, Default Value ]
@@ -51,11 +52,12 @@ var TextStyle = new Class({
5152
// Set to defaults
5253
this.reset();
5354

54-
if (style !== undefined)
55+
if (style)
5556
{
5657
for (var key in propertyMap)
5758
{
58-
this[key] = GetObjectValue(style, propertyMap[key][0], this[key]);
59+
// this[key] = GetObjectValue(style, propertyMap[key][0], this[key]);
60+
this[key] = GetAdvancedValue(style, propertyMap[key][0], this[key]);
5961
}
6062
}
6163

@@ -122,7 +124,8 @@ var TextStyle = new Class({
122124
{
123125
for (var key in propertyMap)
124126
{
125-
this[key] = GetObjectValue(style, propertyMap[key][0], this[key]);
127+
// this[key] = GetObjectValue(style, propertyMap[key][0], this[key]);
128+
this[key] = GetAdvancedValue(style, propertyMap[key][0], this[key]);
126129
}
127130

128131
return this.update(true);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var Text = require('./Text');
2+
var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue');
3+
var BuildGameObject = require('../../BuildGameObject');
4+
5+
var BuildFromConfig = function (state, config)
6+
{
7+
// style Object = {
8+
// font: [ 'font', '16px Courier' ],
9+
// backgroundColor: [ 'backgroundColor', null ],
10+
// fill: [ 'fill', '#fff' ],
11+
// stroke: [ 'stroke', '#fff' ],
12+
// strokeThickness: [ 'strokeThickness', 0 ],
13+
// shadowOffsetX: [ 'shadow.offsetX', 0 ],
14+
// shadowOffsetY: [ 'shadow.offsetY', 0 ],
15+
// shadowColor: [ 'shadow.color', '#000' ],
16+
// shadowBlur: [ 'shadow.blur', 0 ],
17+
// shadowStroke: [ 'shadow.stroke', false ],
18+
// shadowFill: [ 'shadow.fill', false ],
19+
// align: [ 'align', 'left' ],
20+
// maxLines: [ 'maxLines', 0 ],
21+
// fixedWidth: [ 'fixedWidth', false ],
22+
// fixedHeight: [ 'fixedHeight', false ],
23+
// rtl: [ 'rtl', false ]
24+
// }
25+
26+
var content = GetAdvancedValue(config, 'text', '');
27+
var style = GetAdvancedValue(config, 'style', null);
28+
29+
var text = new Text(state, 0, 0, content, style);
30+
31+
BuildGameObject(state, text, config);
32+
33+
// Text specific config options:
34+
35+
text.autoRound = GetAdvancedValue(config, 'autoRound', true);
36+
text.resolution = GetAdvancedValue(config, 'resolution', 1);
37+
38+
return text;
39+
};
40+
41+
module.exports = BuildFromConfig;

v3/src/gameobjects/text/static/Text.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var Text = new Class({
6363

6464
this.resolution = 1;
6565

66+
// Move to TextStyle?
6667
this.padding = { x: 0, y: 0 };
6768

6869
this.width = 1;

v3/src/gameobjects/text/static/TextFactory.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
12
var Text = require('./Text');
3+
var BuildFromConfig = require('./BuildFromConfig');
24
var FactoryContainer = require('../../FactoryContainer');
35

46
var TextFactory = {
@@ -10,9 +12,9 @@ var TextFactory = {
1012
return this.children.add(new Text(this.state, x, y, text, style));
1113
},
1214

13-
make: function (x, y, text, style)
15+
make: function (config)
1416
{
15-
return new Text(this.state, x, y, text, style);
17+
return BuildFromConfig(this.state, config);
1618
}
1719

1820
};

0 commit comments

Comments
 (0)