nodePong/client/lib/ui/objects/ui_input_text.js

48 lines
874 B
JavaScript
Raw Normal View History

2016-02-14 00:23:22 +01:00
/**
* @file ui_input_text.js
* @author frtk@tetalab
*/
NPGClient.UIInputText = function(n, o) {
// obj name
this.name = n !== undefined ? n : '';
// pos
this.x = o.x !== undefined ? o.x : 0;
this.y = o.y !== undefined ? o.y : 0;
// text
this.text = o.text !== undefined ? o.text : '';
//
this.input = '';
// text style
this.s = o.style !== undefined ? o.style : new NPGClient.UITextStyle();
};
NPGClient.UIInputText.prototype = {
// Constructor
constructor: NPGClient.UIInputText,
//
2016-02-14 04:37:31 +01:00
updateInput: function() {
2016-02-14 00:23:22 +01:00
var self = this;
2016-02-14 04:37:31 +01:00
self.input = NPGClient.userName;
2016-02-14 00:23:22 +01:00
},
//
draw: function(ctx, state) {
var self = this;
2016-02-16 00:47:28 +01:00
var t = self.text + self.input;
2016-02-14 04:37:31 +01:00
self.updateInput();
2016-02-16 00:47:28 +01:00
//console.log(self.s);
2016-02-14 00:23:22 +01:00
NPGClient.Utils.setTxtStyle(ctx, self.s);
2016-02-16 00:47:28 +01:00
ctx.fillText(t, self.x, self.y);
2016-02-14 00:23:22 +01:00
}
};