93 lines
1.8 KiB
JavaScript
93 lines
1.8 KiB
JavaScript
/**
|
|
* Font Superset - The apiFont properties get moved into the Font object itself, and then the instance is created
|
|
* @param graphics GameLib.D3.Graphics
|
|
* @param apiFont GameLib.D3.API.Font
|
|
* @constructor
|
|
*/
|
|
GameLib.D3.Font = function(
|
|
graphics,
|
|
apiFont
|
|
) {
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(apiFont)) {
|
|
apiFont = {};
|
|
}
|
|
|
|
if (apiFont instanceof GameLib.D3.Font) {
|
|
return apiFont;
|
|
}
|
|
|
|
GameLib.D3.API.Font.call(
|
|
this,
|
|
apiFont.id,
|
|
apiFont.name,
|
|
apiFont.url,
|
|
apiFont.parentEntity
|
|
);
|
|
|
|
GameLib.Component.call(
|
|
this,
|
|
GameLib.Component.COMPONENT_FONT
|
|
);
|
|
};
|
|
|
|
GameLib.D3.Font.prototype = Object.create(GameLib.D3.API.Font.prototype);
|
|
GameLib.D3.Font.prototype.constructor = GameLib.D3.Font;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
GameLib.D3.Font.prototype.createInstance = function() {
|
|
|
|
GameLib.Event.Emit(
|
|
GameLib.Event.LOAD_FONT,
|
|
{
|
|
font : this
|
|
}
|
|
);
|
|
|
|
return null;
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
GameLib.D3.Font.prototype.updateInstance = function() {
|
|
GameLib.Event.Emit(
|
|
GameLib.Event.LOAD_FONT,
|
|
{
|
|
font : this
|
|
}
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Converts a GameLib.D3.Font to a GameLib.D3.API.Font
|
|
* @returns {GameLib.D3.API.Font}
|
|
*/
|
|
GameLib.D3.Font.prototype.toApiObject = function() {
|
|
return new GameLib.D3.API.Font(
|
|
this.id,
|
|
this.name,
|
|
this.url,
|
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Returns a new GameLib.D3.Font from a GameLib.D3.API.Font
|
|
* @param graphics GameLib.D3.Graphics
|
|
* @param objectFont GameLib.D3.API.Font
|
|
* @returns {GameLib.D3.Font}
|
|
*/
|
|
GameLib.D3.Font.FromObject = function(graphics, objectFont) {
|
|
|
|
return new GameLib.D3.Font(
|
|
graphics,
|
|
GameLib.D3.API.Font.FromObject(objectFont)
|
|
);
|
|
|
|
}; |