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

46 lines
832 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-14 04:37:31 +01:00
self.updateInput();
2016-02-14 00:23:22 +01:00
NPGClient.Utils.setTxtStyle(ctx, self.s);
ctx.fillText(self.text + self.input, self.x, self.y);
}
};