From 8ef4595a729e6beccf0c7b8a5acc632c3e02ba91 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 11 Aug 2013 13:47:44 -0700 Subject: [PATCH] Deprecated the Map namespace. - Moved all loaders from the Map namespace to the MapLoaders namespace #70 --- .../EndGate.Core.JS/EndGate.Core.JS.csproj | 48 ++-- .../Map/Loaders/JSON/JSONFormat.js | 16 -- .../Map/Loaders/JSON/JSONLoader.js | 40 ---- .../Map/Loaders/JSON/TMX/OrthogonalLoader.js | 208 ------------------ .../Map/Loaders/JSON/TMX/TMXLoader.js | 36 --- .../Loaders => MapLoaders}/IHookFunction.js | 0 .../Loaders => MapLoaders}/IHookFunction.ts | 4 +- .../IMapLoadedResult.js | 0 .../IMapLoadedResult.ts | 4 +- .../{Map/Loaders => MapLoaders}/IMapLoader.js | 0 .../{Map/Loaders => MapLoaders}/IMapLoader.ts | 2 +- .../Loaders => MapLoaders}/IMapPreloadInfo.js | 0 .../Loaders => MapLoaders}/IMapPreloadInfo.ts | 4 +- .../Loaders => MapLoaders}/IPropertyHooks.js | 0 .../Loaders => MapLoaders}/IPropertyHooks.ts | 2 +- .../MapLoaders/JSON/JSONFormat.js | 13 ++ .../Loaders => MapLoaders}/JSON/JSONFormat.ts | 2 +- .../MapLoaders/JSON/JSONLoader.js | 37 ++++ .../Loaders => MapLoaders}/JSON/JSONLoader.ts | 2 +- .../Loaders => MapLoaders}/JSON/TMX/ITMX.js | 0 .../Loaders => MapLoaders}/JSON/TMX/ITMX.ts | 2 +- .../JSON/TMX/ITMXLayer.js | 0 .../JSON/TMX/ITMXLayer.ts | 2 +- .../JSON/TMX/ITMXTileset.js | 0 .../JSON/TMX/ITMXTileset.ts | 2 +- .../MapLoaders/JSON/TMX/OrthogonalLoader.js | 205 +++++++++++++++++ .../JSON/TMX/OrthogonalLoader.ts | 14 +- .../MapLoaders/JSON/TMX/TMXLoader.js | 33 +++ .../JSON/TMX/TMXLoader.ts | 2 +- .../Content/Samples/MapLoading/LoadHandler.js | 2 +- .../Samples/MapLoading/LoadHandler.js.map | 2 +- .../Content/Samples/MapLoading/LoadHandler.ts | 6 +- 32 files changed, 338 insertions(+), 350 deletions(-) delete mode 100644 EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.js delete mode 100644 EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.js delete mode 100644 EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.js delete mode 100644 EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.js rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IHookFunction.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IHookFunction.ts (70%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapLoadedResult.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapLoadedResult.ts (79%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapLoader.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapLoader.ts (95%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapPreloadInfo.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IMapPreloadInfo.ts (89%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IPropertyHooks.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/IPropertyHooks.ts (96%) create mode 100644 EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.js rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/JSONFormat.ts (80%) create mode 100644 EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.js rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/JSONLoader.ts (99%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMX.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMX.ts (89%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMXLayer.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMXLayer.ts (87%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMXTileset.js (100%) rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/ITMXTileset.ts (90%) create mode 100644 EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.js rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/OrthogonalLoader.ts (96%) create mode 100644 EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.js rename EndGate/EndGate.Core.JS/{Map/Loaders => MapLoaders}/JSON/TMX/TMXLoader.ts (96%) diff --git a/EndGate/EndGate.Core.JS/EndGate.Core.JS.csproj b/EndGate/EndGate.Core.JS/EndGate.Core.JS.csproj index 7b29c0ea..ca60669a 100644 --- a/EndGate/EndGate.Core.JS/EndGate.Core.JS.csproj +++ b/EndGate/EndGate.Core.JS/EndGate.Core.JS.csproj @@ -95,52 +95,52 @@ ICloneable.ts - - - - - - - + + + + + + + IHookFunction.ts - + IMapLoadedResult.ts - + IMapLoader.ts - - + + IMapPreloadInfo.ts - - + + IPropertyHooks.ts - + ITMX.ts - - + + ITMXLayer.ts - - + + ITMXTileset.ts - + JSONFormat.ts - + JSONLoader.ts - - - + + + OrthogonalLoader.ts - + TMXLoader.ts diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.js b/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.js deleted file mode 100644 index abc962b0..00000000 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.js +++ /dev/null @@ -1,16 +0,0 @@ -var EndGate; -(function (EndGate) { - (function (Map) { - (function (Loaders) { - /** - * Defines supported JSON formats for map loading. - */ - (function (JSONFormat) { - JSONFormat[JSONFormat["TMX"] = 0] = "TMX"; - })(Loaders.JSONFormat || (Loaders.JSONFormat = {})); - var JSONFormat = Loaders.JSONFormat; - })(Map.Loaders || (Map.Loaders = {})); - var Loaders = Map.Loaders; - })(EndGate.Map || (EndGate.Map = {})); - var Map = EndGate.Map; -})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.js b/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.js deleted file mode 100644 index f03027b2..00000000 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.js +++ /dev/null @@ -1,40 +0,0 @@ -var EndGate; -(function (EndGate) { - (function (Map) { - /// - /// - /// - /// - /// - /// - (function (Loaders) { - /** - * Defines a JSON loader that is used to load maps. - */ - var JSONLoader = (function () { - function JSONLoader() { - } - JSONLoader.Load = function (json, onComplete, propertyHooks, format) { - if (typeof format === "undefined") { format = Loaders.JSONFormat.TMX; } - if (!propertyHooks) { - // Defaults - propertyHooks = { - ResourceTileHooks: {}, - ResourceSheetHooks: {}, - LayerHooks: {} - }; - } - - return JSONLoader._loaders[Loaders.JSONFormat[format]].Load(json, propertyHooks, onComplete); - }; - JSONLoader._loaders = { - TMX: new Loaders._.TMX.TMXLoader() - }; - return JSONLoader; - })(); - Loaders.JSONLoader = JSONLoader; - })(Map.Loaders || (Map.Loaders = {})); - var Loaders = Map.Loaders; - })(EndGate.Map || (EndGate.Map = {})); - var Map = EndGate.Map; -})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.js b/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.js deleted file mode 100644 index 566429d8..00000000 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.js +++ /dev/null @@ -1,208 +0,0 @@ -var EndGate; -(function (EndGate) { - (function (Map) { - (function (Loaders) { - (function (_) { - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - (function (TMX) { - var OrthogonalLoader = (function () { - function OrthogonalLoader() { - } - OrthogonalLoader.prototype.Load = function (data, propertyHooks, onComplete) { - var _this = this; - // We're initially at 0%. - var percent = 0, tileCount = 0, onPartialLoad = new EndGate.EventHandler1(); - - // Load all the sources referenced within the data - this.LoadTilesetSources(data.tilesets, function (tileset) { - percent += (1 / data.tilesets.length) * OrthogonalLoader._imagePercentMax; - - onPartialLoad.Trigger(percent); - }, function (tilesetSources) { - // Triggered once all the sources have completed loading - // All the tiles extracted represent our resource list - var resources = _this.ExtractTilesetTiles(data.tilesets, tilesetSources, propertyHooks), mappings, layers = new Array(), layerPercentValue = (1 - OrthogonalLoader._imagePercentMax) / data.layers.length; - - percent = OrthogonalLoader._imagePercentMax; - - asyncLoop(function (next, i) { - if (data.layers[i].type !== "tilelayer") { - throw new Error("Invalid layer type. The layer type '" + data.layers[i].type + "' is not supported."); - } - - _this.AsyncBuildLayer(data, i, propertyHooks, resources, function (details, percentLoaded) { - onPartialLoad.Trigger(percent + percentLoaded * layerPercentValue); - }, function (layer) { - percent += layerPercentValue; - - onPartialLoad.Trigger(percent); - - layers.push(layer); - - next(); - }); - }, data.layers.length, function () { - // All layers loaded - onComplete({ - Layers: layers - }); - }); - }); - - for (var i = 0; i < data.layers.length; i++) { - tileCount += data.layers[i].data.length; - } - - return { - TileCount: tileCount, - LayerCount: data.layers.length, - ResourceSheetCount: data.tilesets.length, - OnPercentLoaded: onPartialLoad - }; - }; - - OrthogonalLoader.prototype.LoadTilesetSources = function (tilesets, onTilesetLoad, onComplete) { - var tilesetSources = {}, loadedCount = 0, onLoaded = function (source) { - onTilesetLoad(source); - - if (++loadedCount === tilesets.length) { - onComplete(tilesetSources); - } - }; - - for (var i = 0; i < tilesets.length; i++) { - tilesetSources[tilesets[i].name] = new EndGate.Graphics.ImageSource(tilesets[i].image, tilesets[i].imagewidth, tilesets[i].imageheight); - tilesetSources[tilesets[i].name].OnLoaded.Bind(onLoaded); - } - }; - - OrthogonalLoader.prototype.ExtractTilesetTiles = function (tilesets, tilesetSources, propertyHooks) { - var tilesetTiles = new Array(), resourceHooks = new Array(), sources, index; - - tilesets.sort(function (a, b) { - return a.firstgid - b.firstgid; - }); - - for (var i = 0; i < tilesets.length; i++) { - sources = EndGate.Graphics.SquareTileMap.ExtractTiles(tilesetSources[tilesets[i].name], tilesets[i].tilewidth, tilesets[i].tileheight); - - for (var property in tilesets[i].properties) { - if (typeof propertyHooks.ResourceSheetHooks[property] !== "undefined") { - for (var j = tilesets[i].firstgid - 1; j < tilesets[i].firstgid - 1 + sources.length; j++) { - if (typeof resourceHooks[j] === "undefined") { - resourceHooks[j] = new Array(); - } - - resourceHooks[j].push(this.BuildHookerFunction(tilesets[i].properties[property], propertyHooks.ResourceSheetHooks[property])); - } - } - } - - for (var tileIndex in tilesets[i].tileproperties) { - for (var property in tilesets[i].tileproperties[tileIndex]) - if (typeof propertyHooks.ResourceTileHooks[property] !== "undefined") { - index = parseInt(tileIndex) + tilesets[i].firstgid - 1; - - if (typeof resourceHooks[index] === "undefined") { - resourceHooks[index] = new Array(); - } - - resourceHooks[index].push(this.BuildHookerFunction(tilesets[i].tileproperties[tileIndex][property], propertyHooks.ResourceTileHooks[property])); - } - } - - tilesetTiles = tilesetTiles.concat(sources); - } - - return { - Resources: tilesetTiles, - ResourceHooks: resourceHooks - }; - }; - - // Not true async but it frees up the DOM - OrthogonalLoader.prototype.AsyncBuildLayer = function (tmxData, layerIndex, propertyHooks, resources, onTileLoad, onComplete) { - var _this = this; - setTimeout(function () { - // Convert the layer data to a 2 dimensional array and subtract 1 from all the data points (to make it 0 based) - var tmxLayer = tmxData.layers[layerIndex], mappings = _this.NormalizeLayerData(tmxLayer.data, tmxData.width), layer = new EndGate.Graphics.SquareTileMap(tmxLayer.x, tmxLayer.y, tmxData.tilewidth, tmxData.tileheight, resources.Resources, mappings), layerHooks = new Array(); - - for (var property in tmxLayer.properties) { - if (typeof propertyHooks.LayerHooks[property] !== "undefined") { - layerHooks.push(_this.BuildHookerFunction(tmxLayer.properties[property], propertyHooks.LayerHooks[property])); - } - } - - layer.ZIndex = layerIndex; - layer.Visible = tmxLayer.visible; - layer.Opacity = tmxLayer.opacity; - - // Enough delay to ensure that the page doesn't freeze - layer.RowLoadDelay = EndGate.TimeSpan.FromMilliseconds(5); - - layer.OnTileLoad.Bind(function (details, percentComplete) { - if (resources.ResourceHooks[details.ResourceIndex]) { - for (var i = 0; i < resources.ResourceHooks[details.ResourceIndex].length; i++) { - resources.ResourceHooks[details.ResourceIndex][i](details); - } - } - - for (var i = 0; i < layerHooks.length; i++) { - layerHooks[i](details); - } - - onTileLoad(details, percentComplete); - }); - - layer.OnLoaded.Bind(function () { - onComplete(layer); - }); - }, 0); - }; - - OrthogonalLoader.prototype.BuildHookerFunction = function (propertyValue, fn) { - return function (details) { - return fn(details, propertyValue); - }; - }; - - OrthogonalLoader.prototype.NormalizeLayerData = function (data, columns) { - var normalized = new Array(), index; - - for (var i = 0; i < data.length; i++) { - index = Math.floor(i / columns); - - if (!(normalized[index] instanceof Array)) { - normalized[index] = new Array(); - } - - // Subtract 1 because TMX format starts at 1 - normalized[index].push(data[i] - 1); - } - - return normalized; - }; - OrthogonalLoader._imagePercentMax = .2; - return OrthogonalLoader; - })(); - TMX.OrthogonalLoader = OrthogonalLoader; - })(_.TMX || (_.TMX = {})); - var TMX = _.TMX; - })(Loaders._ || (Loaders._ = {})); - var _ = Loaders._; - })(Map.Loaders || (Map.Loaders = {})); - var Loaders = Map.Loaders; - })(EndGate.Map || (EndGate.Map = {})); - var Map = EndGate.Map; -})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.js b/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.js deleted file mode 100644 index bb0bdf7e..00000000 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.js +++ /dev/null @@ -1,36 +0,0 @@ -var EndGate; -(function (EndGate) { - (function (Map) { - (function (Loaders) { - (function (_) { - /// - /// - /// - /// - /// - (function (TMX) { - var TMXLoader = (function () { - function TMXLoader() { - this._orientationLoaders = { - orthogonal: new TMX.OrthogonalLoader() - }; - } - TMXLoader.prototype.Load = function (data, propertyHooks, onComplete) { - if (!this._orientationLoaders[data.orientation]) { - throw new Error("Invalid orientation. The orientation '" + data.orientation + "' is not supported."); - } - - return this._orientationLoaders[data.orientation].Load(data, propertyHooks, onComplete); - }; - return TMXLoader; - })(); - TMX.TMXLoader = TMXLoader; - })(_.TMX || (_.TMX = {})); - var TMX = _.TMX; - })(Loaders._ || (Loaders._ = {})); - var _ = Loaders._; - })(Map.Loaders || (Map.Loaders = {})); - var Loaders = Map.Loaders; - })(EndGate.Map || (EndGate.Map = {})); - var Map = EndGate.Map; -})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.js b/EndGate/EndGate.Core.JS/MapLoaders/IHookFunction.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.js rename to EndGate/EndGate.Core.JS/MapLoaders/IHookFunction.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.ts b/EndGate/EndGate.Core.JS/MapLoaders/IHookFunction.ts similarity index 70% rename from EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.ts rename to EndGate/EndGate.Core.JS/MapLoaders/IHookFunction.ts index 3dce4396..1b0b3136 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/IHookFunction.ts @@ -1,6 +1,6 @@ -/// +/// -declare module EndGate.Map.Loaders { +declare module EndGate.MapLoaders { /** * Defines an IHookFunction that represents a function that can be used to hook into map loading tiles. diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.js b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoadedResult.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.js rename to EndGate/EndGate.Core.JS/MapLoaders/IMapLoadedResult.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.ts b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoadedResult.ts similarity index 79% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.ts rename to EndGate/EndGate.Core.JS/MapLoaders/IMapLoadedResult.ts index 77e5eb53..a8dd4d6a 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoadedResult.ts @@ -1,6 +1,6 @@ -/// +/// -declare module EndGate.Map.Loaders { +declare module EndGate.MapLoaders { /** * Defines an object that contains all the information needed to create a scenic map. diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.js b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoader.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.js rename to EndGate/EndGate.Core.JS/MapLoaders/IMapLoader.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.ts b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoader.ts similarity index 95% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.ts rename to EndGate/EndGate.Core.JS/MapLoaders/IMapLoader.ts index 90ef71fa..f8532c81 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/IMapLoader.ts @@ -1,7 +1,7 @@ /// /// -declare module EndGate.Map.Loaders { +declare module EndGate.MapLoaders { /** * Defines an object that can load data and output a result asynchronously. diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapPreloadInfo.js b/EndGate/EndGate.Core.JS/MapLoaders/IMapPreloadInfo.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapPreloadInfo.js rename to EndGate/EndGate.Core.JS/MapLoaders/IMapPreloadInfo.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IMapPreloadInfo.ts b/EndGate/EndGate.Core.JS/MapLoaders/IMapPreloadInfo.ts similarity index 89% rename from EndGate/EndGate.Core.JS/Map/Loaders/IMapPreloadInfo.ts rename to EndGate/EndGate.Core.JS/MapLoaders/IMapPreloadInfo.ts index 78f8b87c..94ea624a 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/IMapPreloadInfo.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/IMapPreloadInfo.ts @@ -1,6 +1,6 @@ -/// +/// -declare module EndGate.Map.Loaders { +declare module EndGate.MapLoaders { /** * Defines an object that contains some immediately available information about the map that is about to be loaded. diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IPropertyHooks.js b/EndGate/EndGate.Core.JS/MapLoaders/IPropertyHooks.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/IPropertyHooks.js rename to EndGate/EndGate.Core.JS/MapLoaders/IPropertyHooks.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/IPropertyHooks.ts b/EndGate/EndGate.Core.JS/MapLoaders/IPropertyHooks.ts similarity index 96% rename from EndGate/EndGate.Core.JS/Map/Loaders/IPropertyHooks.ts rename to EndGate/EndGate.Core.JS/MapLoaders/IPropertyHooks.ts index 6ad1ce27..cfb7b74a 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/IPropertyHooks.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/IPropertyHooks.ts @@ -1,6 +1,6 @@ /// -declare module EndGate.Map.Loaders { +declare module EndGate.MapLoaders { /** * Defines an object that can be used to provide hooks to adjust tiles as they are built. diff --git a/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.js new file mode 100644 index 00000000..777cb001 --- /dev/null +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.js @@ -0,0 +1,13 @@ +var EndGate; +(function (EndGate) { + (function (MapLoaders) { + /** + * Defines supported JSON formats for map loading. + */ + (function (JSONFormat) { + JSONFormat[JSONFormat["TMX"] = 0] = "TMX"; + })(MapLoaders.JSONFormat || (MapLoaders.JSONFormat = {})); + var JSONFormat = MapLoaders.JSONFormat; + })(EndGate.MapLoaders || (EndGate.MapLoaders = {})); + var MapLoaders = EndGate.MapLoaders; +})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.ts similarity index 80% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.ts index 6452ddf2..5f493b99 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONFormat.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONFormat.ts @@ -1,4 +1,4 @@ -module EndGate.Map.Loaders { +module EndGate.MapLoaders { /** * Defines supported JSON formats for map loading. diff --git a/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.js new file mode 100644 index 00000000..9652e3b7 --- /dev/null +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.js @@ -0,0 +1,37 @@ +var EndGate; +(function (EndGate) { + /// + /// + /// + /// + /// + /// + (function (MapLoaders) { + /** + * Defines a JSON loader that is used to load maps. + */ + var JSONLoader = (function () { + function JSONLoader() { + } + JSONLoader.Load = function (json, onComplete, propertyHooks, format) { + if (typeof format === "undefined") { format = MapLoaders.JSONFormat.TMX; } + if (!propertyHooks) { + // Defaults + propertyHooks = { + ResourceTileHooks: {}, + ResourceSheetHooks: {}, + LayerHooks: {} + }; + } + + return JSONLoader._loaders[MapLoaders.JSONFormat[format]].Load(json, propertyHooks, onComplete); + }; + JSONLoader._loaders = { + TMX: new MapLoaders._.TMX.TMXLoader() + }; + return JSONLoader; + })(); + MapLoaders.JSONLoader = JSONLoader; + })(EndGate.MapLoaders || (EndGate.MapLoaders = {})); + var MapLoaders = EndGate.MapLoaders; +})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.ts similarity index 99% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.ts index c6675ae8..6dd95068 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/JSONLoader.ts @@ -5,7 +5,7 @@ /// /// -module EndGate.Map.Loaders { +module EndGate.MapLoaders { /** * Defines a JSON loader that is used to load maps. diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMX.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMX.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMX.js rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMX.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMX.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMX.ts similarity index 89% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMX.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMX.ts index bf920183..7c659022 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMX.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMX.ts @@ -1,7 +1,7 @@ /// /// -declare module EndGate.Map.Loaders._.TMX { +declare module EndGate.MapLoaders._.TMX { export interface ITMX { version: number; diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXLayer.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXLayer.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXLayer.js rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXLayer.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXLayer.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXLayer.ts similarity index 87% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXLayer.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXLayer.ts index fff8748e..5865e55f 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXLayer.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXLayer.ts @@ -1,4 +1,4 @@ -declare module EndGate.Map.Loaders._.TMX { +declare module EndGate.MapLoaders._.TMX { export interface ITMXLayer { name: string; diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXTileset.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXTileset.js similarity index 100% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXTileset.js rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXTileset.js diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXTileset.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXTileset.ts similarity index 90% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXTileset.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXTileset.ts index 677452b0..fba0d3c1 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/ITMXTileset.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/ITMXTileset.ts @@ -1,4 +1,4 @@ -declare module EndGate.Map.Loaders._.TMX { +declare module EndGate.MapLoaders._.TMX { export interface ITMXTileset { firstgid: number; diff --git a/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.js new file mode 100644 index 00000000..d6b99336 --- /dev/null +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.js @@ -0,0 +1,205 @@ +var EndGate; +(function (EndGate) { + (function (MapLoaders) { + (function (_) { + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + (function (TMX) { + var OrthogonalLoader = (function () { + function OrthogonalLoader() { + } + OrthogonalLoader.prototype.Load = function (data, propertyHooks, onComplete) { + var _this = this; + // We're initially at 0%. + var percent = 0, tileCount = 0, onPartialLoad = new EndGate.EventHandler1(); + + // Load all the sources referenced within the data + this.LoadTilesetSources(data.tilesets, function (tileset) { + percent += (1 / data.tilesets.length) * OrthogonalLoader._imagePercentMax; + + onPartialLoad.Trigger(percent); + }, function (tilesetSources) { + // Triggered once all the sources have completed loading + // All the tiles extracted represent our resource list + var resources = _this.ExtractTilesetTiles(data.tilesets, tilesetSources, propertyHooks), mappings, layers = new Array(), layerPercentValue = (1 - OrthogonalLoader._imagePercentMax) / data.layers.length; + + percent = OrthogonalLoader._imagePercentMax; + + asyncLoop(function (next, i) { + if (data.layers[i].type !== "tilelayer") { + throw new Error("Invalid layer type. The layer type '" + data.layers[i].type + "' is not supported."); + } + + _this.AsyncBuildLayer(data, i, propertyHooks, resources, function (details, percentLoaded) { + onPartialLoad.Trigger(percent + percentLoaded * layerPercentValue); + }, function (layer) { + percent += layerPercentValue; + + onPartialLoad.Trigger(percent); + + layers.push(layer); + + next(); + }); + }, data.layers.length, function () { + // All layers loaded + onComplete({ + Layers: layers + }); + }); + }); + + for (var i = 0; i < data.layers.length; i++) { + tileCount += data.layers[i].data.length; + } + + return { + TileCount: tileCount, + LayerCount: data.layers.length, + ResourceSheetCount: data.tilesets.length, + OnPercentLoaded: onPartialLoad + }; + }; + + OrthogonalLoader.prototype.LoadTilesetSources = function (tilesets, onTilesetLoad, onComplete) { + var tilesetSources = {}, loadedCount = 0, onLoaded = function (source) { + onTilesetLoad(source); + + if (++loadedCount === tilesets.length) { + onComplete(tilesetSources); + } + }; + + for (var i = 0; i < tilesets.length; i++) { + tilesetSources[tilesets[i].name] = new EndGate.Graphics.ImageSource(tilesets[i].image, tilesets[i].imagewidth, tilesets[i].imageheight); + tilesetSources[tilesets[i].name].OnLoaded.Bind(onLoaded); + } + }; + + OrthogonalLoader.prototype.ExtractTilesetTiles = function (tilesets, tilesetSources, propertyHooks) { + var tilesetTiles = new Array(), resourceHooks = new Array(), sources, index; + + tilesets.sort(function (a, b) { + return a.firstgid - b.firstgid; + }); + + for (var i = 0; i < tilesets.length; i++) { + sources = EndGate.Graphics.SquareTileMap.ExtractTiles(tilesetSources[tilesets[i].name], tilesets[i].tilewidth, tilesets[i].tileheight); + + for (var property in tilesets[i].properties) { + if (typeof propertyHooks.ResourceSheetHooks[property] !== "undefined") { + for (var j = tilesets[i].firstgid - 1; j < tilesets[i].firstgid - 1 + sources.length; j++) { + if (typeof resourceHooks[j] === "undefined") { + resourceHooks[j] = new Array(); + } + + resourceHooks[j].push(this.BuildHookerFunction(tilesets[i].properties[property], propertyHooks.ResourceSheetHooks[property])); + } + } + } + + for (var tileIndex in tilesets[i].tileproperties) { + for (var property in tilesets[i].tileproperties[tileIndex]) + if (typeof propertyHooks.ResourceTileHooks[property] !== "undefined") { + index = parseInt(tileIndex) + tilesets[i].firstgid - 1; + + if (typeof resourceHooks[index] === "undefined") { + resourceHooks[index] = new Array(); + } + + resourceHooks[index].push(this.BuildHookerFunction(tilesets[i].tileproperties[tileIndex][property], propertyHooks.ResourceTileHooks[property])); + } + } + + tilesetTiles = tilesetTiles.concat(sources); + } + + return { + Resources: tilesetTiles, + ResourceHooks: resourceHooks + }; + }; + + // Not true async but it frees up the DOM + OrthogonalLoader.prototype.AsyncBuildLayer = function (tmxData, layerIndex, propertyHooks, resources, onTileLoad, onComplete) { + var _this = this; + setTimeout(function () { + // Convert the layer data to a 2 dimensional array and subtract 1 from all the data points (to make it 0 based) + var tmxLayer = tmxData.layers[layerIndex], mappings = _this.NormalizeLayerData(tmxLayer.data, tmxData.width), layer = new EndGate.Graphics.SquareTileMap(tmxLayer.x, tmxLayer.y, tmxData.tilewidth, tmxData.tileheight, resources.Resources, mappings), layerHooks = new Array(); + + for (var property in tmxLayer.properties) { + if (typeof propertyHooks.LayerHooks[property] !== "undefined") { + layerHooks.push(_this.BuildHookerFunction(tmxLayer.properties[property], propertyHooks.LayerHooks[property])); + } + } + + layer.ZIndex = layerIndex; + layer.Visible = tmxLayer.visible; + layer.Opacity = tmxLayer.opacity; + + // Enough delay to ensure that the page doesn't freeze + layer.RowLoadDelay = EndGate.TimeSpan.FromMilliseconds(5); + + layer.OnTileLoad.Bind(function (details, percentComplete) { + if (resources.ResourceHooks[details.ResourceIndex]) { + for (var i = 0; i < resources.ResourceHooks[details.ResourceIndex].length; i++) { + resources.ResourceHooks[details.ResourceIndex][i](details); + } + } + + for (var i = 0; i < layerHooks.length; i++) { + layerHooks[i](details); + } + + onTileLoad(details, percentComplete); + }); + + layer.OnLoaded.Bind(function () { + onComplete(layer); + }); + }, 0); + }; + + OrthogonalLoader.prototype.BuildHookerFunction = function (propertyValue, fn) { + return function (details) { + return fn(details, propertyValue); + }; + }; + + OrthogonalLoader.prototype.NormalizeLayerData = function (data, columns) { + var normalized = new Array(), index; + + for (var i = 0; i < data.length; i++) { + index = Math.floor(i / columns); + + if (!(normalized[index] instanceof Array)) { + normalized[index] = new Array(); + } + + // Subtract 1 because TMX format starts at 1 + normalized[index].push(data[i] - 1); + } + + return normalized; + }; + OrthogonalLoader._imagePercentMax = .2; + return OrthogonalLoader; + })(); + TMX.OrthogonalLoader = OrthogonalLoader; + })(_.TMX || (_.TMX = {})); + var TMX = _.TMX; + })(MapLoaders._ || (MapLoaders._ = {})); + var _ = MapLoaders._; + })(EndGate.MapLoaders || (EndGate.MapLoaders = {})); + var MapLoaders = EndGate.MapLoaders; +})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.ts similarity index 96% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.ts index 9ebe6316..c55112d2 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/OrthogonalLoader.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/OrthogonalLoader.ts @@ -1,17 +1,17 @@ -/// +/// /// /// /// /// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// /// /// -module EndGate.Map.Loaders._.TMX { +module EndGate.MapLoaders._.TMX { interface TileExtractResult { ResourceHooks: Array any>>; diff --git a/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.js b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.js new file mode 100644 index 00000000..118a24b9 --- /dev/null +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.js @@ -0,0 +1,33 @@ +var EndGate; +(function (EndGate) { + (function (MapLoaders) { + (function (_) { + /// + /// + /// + /// + /// + (function (TMX) { + var TMXLoader = (function () { + function TMXLoader() { + this._orientationLoaders = { + orthogonal: new TMX.OrthogonalLoader() + }; + } + TMXLoader.prototype.Load = function (data, propertyHooks, onComplete) { + if (!this._orientationLoaders[data.orientation]) { + throw new Error("Invalid orientation. The orientation '" + data.orientation + "' is not supported."); + } + + return this._orientationLoaders[data.orientation].Load(data, propertyHooks, onComplete); + }; + return TMXLoader; + })(); + TMX.TMXLoader = TMXLoader; + })(_.TMX || (_.TMX = {})); + var TMX = _.TMX; + })(MapLoaders._ || (MapLoaders._ = {})); + var _ = MapLoaders._; + })(EndGate.MapLoaders || (EndGate.MapLoaders = {})); + var MapLoaders = EndGate.MapLoaders; +})(EndGate || (EndGate = {})); diff --git a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.ts b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.ts similarity index 96% rename from EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.ts rename to EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.ts index 84f21c8c..4de92438 100644 --- a/EndGate/EndGate.Core.JS/Map/Loaders/JSON/TMX/TMXLoader.ts +++ b/EndGate/EndGate.Core.JS/MapLoaders/JSON/TMX/TMXLoader.ts @@ -4,7 +4,7 @@ /// /// -module EndGate.Map.Loaders._.TMX { +module EndGate.MapLoaders._.TMX { export class TMXLoader implements IMapLoader { private _orientationLoaders: { [orientation: string]: IMapLoader }; diff --git a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js index b8d67b97..05813714 100644 --- a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js +++ b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js @@ -24,7 +24,7 @@ var MapLoading; // We use jquery to retrieve the map json from a url location ($.getJSON(url, function (mapJson) { // Use the JSONLoader to load the map json - var preloadInfo = eg.Map.Loaders.JSONLoader.Load(mapJson, function (result) { + var preloadInfo = eg.MapLoaders.JSONLoader.Load(mapJson, function (result) { // We get an array of square tile maps that we then need to add to the scene // Note that the ZIndexes of the layers are already set from 0 - (layers.length-1) _this.LoadLayers(result.Layers); diff --git a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js.map b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js.map index 9e1e3bc8..b8209770 100644 --- a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js.map +++ b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.js.map @@ -1 +1 @@ -{"version":3,"file":"LoadHandler.js","sources":["LoadHandler.ts"],"names":["MapLoading","MapLoading.LoadHandler","MapLoading.LoadHandler.constructor","MapLoading.LoadHandler.Load","","","","","MapLoading.LoadHandler.ClearInfo","MapLoading.LoadHandler.SetInfo","MapLoading.LoadHandler.UpdateLoadedPercent","MapLoading.LoadHandler.ToFormattedNumberString","MapLoading.LoadHandler.LoadLayers"],"mappings":"AAAA,sDAAsD;AACtD,qDAAqD;AACrD,gCAAgC;AAEhC,kDAAkD;AAClD,IAAO,UAAU;AAyGhB,CAzGD,UAAO,UAAU;IAEbA;QASIC,qBAAYA,KAAmBA,EAAEA,UAAkBA;YAAvCC,UAAaA,GAALA,KAAKA;AAAMA,YAC3BA,IAAIA,CAACA,UAAUA,GAAGA,IAAIA,KAAKA,EAA4BA,CAAEA;;YAEzDA,IAAIA,CAACA,WAAWA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,aAAaA,CAAAA,CAAEA;YAClDA,IAAIA,CAACA,YAAYA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,cAAcA,CAAAA,CAAEA;YACpDA,IAAIA,CAACA,eAAeA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,iBAAiBA,CAAAA,CAAEA;YAC1DA,IAAIA,CAACA,cAAcA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,gBAAgBA,CAAAA,CAAEA;YACxDA,IAAIA,CAACA,iBAAiBA,GAAGA,UAAUA,CAACA,IAAIA,CAACA,mBAAmBA,CAAAA,CAAEA;QAClEA,CAACA;QAEDD,6BAAAA,UAAYA,GAAWA,EAAEA,YAAwBA;YAAjDE,iBA2BCA;YA1BGA,mCAAmCA;YACnCA,IAAIA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,CAAEA;gBAC7CA,IAAIA,CAACA,KAAKA,CAACA,KAAKA,CAACA,MAAMA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAAAA,CAAEA;aAC/CA;;YAEDA,IAAIA,MAAMA,CAAEA;gBACRA,IAAIA,CAACA,UAAUA,GAAGA,MAAMA,CAACA;aAC5BA;;YAGDA,KAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAAEA;gBAC7CA,IAAIA,CAACA,KAAKA,CAACA,KAAKA,CAACA,GAAGA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAAAA,CAAEA;aAC5CA;;YAGDA,IAAIA,IAAIA,CAACA,UAAUA,CAACA,MAAMA,GAAGA,CAACA,CAAEA;gBAC5BA,IAAIA,CAACA,KAAKA,CAACA,KAAKA,CAACA,MAAMA,CAACA,QAAQA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,CAACA,QAAQA,CAACA;aAClEA;QACLA,CAACA;QACLX;AAACA,IAADA,CAACA,IAAAD;IArGDA,qCAqGCA;AAELA,CAACA,mCAAA"} \ No newline at end of file +{"version":3,"file":"LoadHandler.js","sources":["LoadHandler.ts"],"names":["MapLoading","MapLoading.LoadHandler","MapLoading.LoadHandler.constructor","MapLoading.LoadHandler.Load","","","","","MapLoading.LoadHandler.ClearInfo","MapLoading.LoadHandler.SetInfo","MapLoading.LoadHandler.UpdateLoadedPercent","MapLoading.LoadHandler.ToFormattedNumberString","MapLoading.LoadHandler.LoadLayers"],"mappings":"AAAA,sDAAsD;AACtD,qDAAqD;AACrD,gCAAgC;AAEhC,kDAAkD;AAClD,IAAO,UAAU;AAyGhB,CAzGD,UAAO,UAAU;IAEbA;QASIC,qBAAYA,KAAmBA,EAAEA,UAAkBA;YAAvCC,UAAaA,GAALA,KAAKA;AAAMA,YAC3BA,IAAIA,CAACA,U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CAACA;aAClEA;QACZA,CAACA;QACEX;AAACA,IAADA,CAACA,IAAAD;IArGDA,qCAqGCA;AAELA,CAACA,mCAAA"} \ No newline at end of file diff --git a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.ts b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.ts index 3207f323..0685769f 100644 --- a/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.ts +++ b/EndGate/samples/EndGate.Core.JS.Samples/Content/Samples/MapLoading/LoadHandler.ts @@ -32,10 +32,10 @@ module MapLoading { // We use jquery to retrieve the map json from a url location ($.getJSON(url, (mapJson) => { // Use the JSONLoader to load the map json - var preloadInfo = eg.Map.Loaders.JSONLoader.Load(mapJson, (result: eg.Map.Loaders.IMapLoadedResult) => { + var preloadInfo = eg.MapLoaders.JSONLoader.Load(mapJson, (result: eg.MapLoaders.IMapLoadedResult) => { // We get an array of square tile maps that we then need to add to the scene // Note that the ZIndexes of the layers are already set from 0 - (layers.length-1) - this.LoadLayers(>result.Layers); + this.LoadLayers(>result.Layers); // Notify the caller that the load has completed. loadComplete(); @@ -64,7 +64,7 @@ module MapLoading { } // Set the load information based on the preload information gathered from the EndGate json loader. - private SetInfo(info: eg.Map.Loaders.IMapPreloadInfo): void { + private SetInfo(info: eg.MapLoaders.IMapPreloadInfo): void { this._totalTiles.html(this.ToFormattedNumberString(info.TileCount)); this._totalLayers.html(this.ToFormattedNumberString(info.LayerCount)); this._totalResources.html(this.ToFormattedNumberString(info.ResourceSheetCount));