version v0.1.2
This commit is contained in:
46
client/lib/ui/objects/ui_input_text.js
Normal file
46
client/lib/ui/objects/ui_input_text.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @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,
|
||||
|
||||
//
|
||||
updateState: function() {
|
||||
var self = this;
|
||||
if (NPGClient.SocketIO.isConnected) self.currText = self.text.online;
|
||||
else self.currText = self.text.offline;
|
||||
},
|
||||
|
||||
//
|
||||
draw: function(ctx, state) {
|
||||
var self = this;
|
||||
self.updateState();
|
||||
NPGClient.Utils.setTxtStyle(ctx, self.s);
|
||||
ctx.fillText(self.text + self.input, self.x, self.y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -12,12 +12,11 @@ NPGClient.UILabel = function(n, o) {
|
||||
// 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 : '';
|
||||
// font
|
||||
this.font = o.f !== undefined ? o.f : '';
|
||||
// color
|
||||
this.col = o.c !== undefined ? o.c : '';
|
||||
// text style
|
||||
this.s = o.style !== undefined ? o.style : new NPGClient.UITextStyle();
|
||||
|
||||
};
|
||||
|
||||
@@ -31,9 +30,13 @@ NPGClient.UILabel.prototype = {
|
||||
draw: function(ctx) {
|
||||
var self = this;
|
||||
//self.rect.draw(ctx);
|
||||
NPGClient.Utils.setTxtStyle(ctx, self.s);
|
||||
ctx.fillText(self.text, self.x, self.y);
|
||||
/*
|
||||
ctx.font = self.font
|
||||
ctx.fillStyle = self.col;
|
||||
ctx.fillText(self.text, self.x, self.y);
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
49
client/lib/ui/objects/ui_menu.js
Normal file
49
client/lib/ui/objects/ui_menu.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file ui_menu.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.UIMenu = function(n, o) {
|
||||
|
||||
// obj name
|
||||
this.name = n !== undefined ? n : '';
|
||||
// type (vertical/horizontal)
|
||||
this.type = o.type !== undefined ? o.type : '';
|
||||
// pos
|
||||
this.x = o.x !== undefined ? o.x : 0;
|
||||
this.y = o.y !== undefined ? o.y : 0;
|
||||
// item list
|
||||
this.items = [];
|
||||
//
|
||||
|
||||
|
||||
};
|
||||
|
||||
NPGClient.UIMenu.prototype = {
|
||||
|
||||
// Constructor
|
||||
constructor: NPGClient.UIMenu,
|
||||
|
||||
//
|
||||
addItem: function(t) {
|
||||
var self = this;
|
||||
self.itemsList.push(t);
|
||||
},
|
||||
|
||||
//
|
||||
draw: function(ctx) {
|
||||
var self = this;
|
||||
var y = self.y
|
||||
if (self.items !== undefined && self.items.length > 0) {
|
||||
for (var i = 0; i < self.items.length; i++) {
|
||||
ctx.font = self.items[i].font;
|
||||
ctx.fillStyle = self.items[i].col;
|
||||
ctx.fillText(self.text, self.x, self.y);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
NPGClient.UIRect = function(n, p, w, h, s) {
|
||||
|
||||
//
|
||||
//NPGClient.UIObject.call(this, n, s);
|
||||
|
||||
// obj name
|
||||
this.name = n !== undefined ? n : '';
|
||||
// geom
|
||||
|
||||
46
client/lib/ui/objects/ui_status_text.js
Normal file
46
client/lib/ui/objects/ui_status_text.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file ui_status_text.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.UIStatusText = 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.currText = 0;
|
||||
|
||||
// text style
|
||||
this.s = o.style !== undefined ? o.style : new NPGClient.UITextStyle();
|
||||
|
||||
};
|
||||
|
||||
|
||||
NPGClient.UIStatusText.prototype = {
|
||||
|
||||
// Constructor
|
||||
constructor: NPGClient.UIStatusText,
|
||||
|
||||
//
|
||||
updateState: function() {
|
||||
var self = this;
|
||||
if (NPGClient.SocketIO.isConnected) self.currText = self.text.online;
|
||||
else self.currText = self.text.offline;
|
||||
},
|
||||
|
||||
//
|
||||
draw: function(ctx, state) {
|
||||
var self = this;
|
||||
self.updateState();
|
||||
NPGClient.Utils.setTxtStyle(ctx, self.s);
|
||||
ctx.fillText(self.currText, self.x, self.y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
19
client/lib/ui/objects/ui_text_style_.js
Normal file
19
client/lib/ui/objects/ui_text_style_.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file ui_text_style.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.UITextStyle = function(f, c, a) {
|
||||
|
||||
this.font = f !== undefined ? f : '';
|
||||
this.color = c !== undefined ? c : '';
|
||||
this.align = a !== undefined ? a : '';
|
||||
|
||||
};
|
||||
|
||||
NPGClient.UITextStyle.prototype = {
|
||||
|
||||
constructor: NPGClient.UITextStyle,
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user