saving to API

beta.r3js.org
Theunis J. Botha 2017-06-13 16:35:19 +02:00
parent e06bccbb95
commit 928b018ae2
3 changed files with 74 additions and 28 deletions

View File

@ -44,34 +44,77 @@ GameLib.Component.prototype.toString = function() {
GameLib.Component.COMPONENT_PATH_FOLLOWING = 0x1; GameLib.Component.COMPONENT_PATH_FOLLOWING = 0x1;
GameLib.Component.COMPONENT_MATERIAL = 0x2; GameLib.Component.COMPONENT_MATERIAL = 0x2;
GameLib.Component.COMPONENT_RENDERER = 0x3; GameLib.Component.COMPONENT_RENDERER = 0x3;
GameLib.Component.COMPONENT_LOOK_AT = 0x5; GameLib.Component.COMPONENT_LOOK_AT = 0x4;
GameLib.Component.COMPONENT_CAMERA = 0x6; GameLib.Component.COMPONENT_CAMERA = 0x5;
GameLib.Component.COMPONENT_FOLLOW = 0x7; GameLib.Component.COMPONENT_FOLLOW = 0x6;
GameLib.Component.COMPONENT_MESH = 0x8; GameLib.Component.COMPONENT_MESH = 0x7;
GameLib.Component.COMPONENT_SPLINE = 0x9; GameLib.Component.COMPONENT_SPLINE = 0x8;
GameLib.Component.COMPONENT_LIGHT = 0xa; GameLib.Component.COMPONENT_LIGHT = 0x9;
GameLib.Component.COMPONENT_INPUT_DRIVE = 0xb; GameLib.Component.COMPONENT_INPUT_DRIVE = 0xa;
GameLib.Component.COMPONENT_COMPOSER = 0xc; GameLib.Component.COMPONENT_COMPOSER = 0xb;
GameLib.Component.COMPONENT_RENDER_TARGET = 0xd; GameLib.Component.COMPONENT_RENDER_TARGET = 0xc;
GameLib.Component.COMPONENT_PASS = 0xe; GameLib.Component.COMPONENT_PASS = 0xd;
GameLib.Component.COMPONENT_SCENE = 0xf; GameLib.Component.COMPONENT_SCENE = 0xe;
GameLib.Component.COMPONENT_GAME = 0x10; GameLib.Component.COMPONENT_GAME = 0xf;
GameLib.Component.COMPONENT_INPUT_EDITOR = 0x11; GameLib.Component.COMPONENT_INPUT_EDITOR = 0x10;
GameLib.Component.COMPONENT_EDITOR = 0x12; GameLib.Component.COMPONENT_EDITOR = 0x11;
GameLib.Component.COMPONENT_VIEWPORT = 0x13; GameLib.Component.COMPONENT_VIEWPORT = 0x12;
GameLib.Component.COMPONENT_SYSTEM = 0x14; GameLib.Component.COMPONENT_SYSTEM = 0x13;
GameLib.Component.COMPONENT_GRAPHICS = 0x15; GameLib.Component.COMPONENT_GRAPHICS = 0x14;
GameLib.Component.COMPONENT_HELPER = 0x16; GameLib.Component.COMPONENT_HELPER = 0x15;
GameLib.Component.COMPONENT_CUSTOM_CODE = 0x17; GameLib.Component.COMPONENT_CUSTOM_CODE = 0x16;
GameLib.Component.COMPONENT_MOUSE = 0x18; GameLib.Component.COMPONENT_MOUSE = 0x17;
GameLib.Component.COMPONENT_SKELETON = 0x19; GameLib.Component.COMPONENT_SKELETON = 0x18;
GameLib.Component.COMPONENT_TEXTURE = 0x1a; GameLib.Component.COMPONENT_TEXTURE = 0x19;
GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1b; GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1a;
GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1c; GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1b;
GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1d; GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1c;
GameLib.Component.COMPONENT_STATS = 0x1e; GameLib.Component.COMPONENT_STATS = 0x1d;
GameLib.Component.COMPONENT_GUI = 0x1f; GameLib.Component.COMPONENT_GUI = 0x1e;
GameLib.Component.COMPONENT_IMAGE = 0x20; GameLib.Component.COMPONENT_IMAGE = 0x1f;
/**
* Returns string name for component number
* @param number
* @returns {*}
* @constructor
*/
GameLib.Component.GetComponentName = function(number) {
switch(number) {
case 0x1 : return 'PathFollowing';
case 0x2 : return 'Material';
case 0x3 : return 'Renderer';
case 0x4 : return 'LookAt';
case 0x5 : return 'Camera';
case 0x6 : return 'Follow';
case 0x7 : return 'Mesh';
case 0x8 : return 'Spline';
case 0x9 : return 'Light';
case 0xa : return 'InputDrive';
case 0xb : return 'Composer';
case 0xc : return 'RenderTarget';
case 0xd : return 'Pass';
case 0xe : return 'Scene';
case 0xf : return 'Game';
case 0x10 : return 'InputEditor';
case 0x11 : return 'Editor';
case 0x12 : return 'Viewport';
case 0x13 : return 'System';
case 0x14 : return 'Graphics';
case 0x15 : return 'Helper';
case 0x16 : return 'CustomCode';
case 0x17 : return 'Mouse';
case 0x18 : return 'Skeleton';
case 0x19 : return 'Texture';
case 0x1a : return 'EntityManager';
case 0x1b : return 'DomElement';
case 0x1c : return 'ImageFactory';
case 0x1d : return 'Stats';
case 0x1e : return 'GUI';
case 0x1f : return 'Image';
break;
}
};
/** /**
* Components are linked at runtime - for storing, we just store the ID * Components are linked at runtime - for storing, we just store the ID

View File

@ -22,6 +22,7 @@ GameLib.D3.Image = function(
apiImage.name, apiImage.name,
apiImage.path, apiImage.path,
apiImage.contentType, apiImage.contentType,
apiImage.size,
apiImage.parentEntity apiImage.parentEntity
); );
@ -161,6 +162,7 @@ GameLib.D3.Image.prototype.toApiObject = function() {
this.name, this.name,
this.path, this.path,
this.contentType, this.contentType,
this.size,
GameLib.Utils.IdOrNull(this.parentEntity) GameLib.Utils.IdOrNull(this.parentEntity)
); );

View File

@ -104,6 +104,7 @@ GameLib.System.Storage.prototype.save = function(data) {
* 'Loads' data from baseURL * 'Loads' data from baseURL
*/ */
GameLib.System.Storage.prototype.load = function(data) { GameLib.System.Storage.prototype.load = function(data) {
if (typeof XMLHttpRequest === 'undefined') { if (typeof XMLHttpRequest === 'undefined') {
console.log('Implement server side load here'); console.log('Implement server side load here');
return; return;