r3-legacy/src/game-lib-d3-api-font.js

53 lines
1.1 KiB
JavaScript

/**
* Raw Font API object - should always correspond with the Font Schema
* @param id
* @param name
* @param url
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Font = function(
id,
name,
url,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Font (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(url)) {
url = '/apiRelative/path/to/font';
}
this.url = url;
GameLib.API.Component.call(
this,
GameLib.Component.FONT,
parentEntity
);
};
GameLib.D3.API.Font.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.D3.API.Font.prototype.constructor = GameLib.D3.API.Font;
/**
* Returns an API light from an Object light
* @param objectFont
* @constructor
*/
GameLib.D3.API.Font.FromObject = function(objectFont) {
return new GameLib.D3.API.Font(
objectFont.id,
objectFont.name,
objectFont.url,
objectFont.parentEntity
);
};