|
1 | 1 | /*! |
2 | 2 | * a melonJS plugin to enable loading and parsing of compressed Tiled maps |
3 | | - * @melonjs/tiled-inflate-plugin - v1.1.0 |
| 3 | + * @melonjs/tiled-inflate-plugin - v1.1.1 |
4 | 4 | * @melonjs/tiled-inflate-plugin is licensed under the MIT License. |
5 | 5 | * http://www.opensource.org/licenses/mit-license |
6 | 6 | * @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd) |
7 | 7 | */ |
8 | | -import { plugin, utils } from 'melonjs'; |
| 8 | +import { plugin, TMXUtils } from 'melonjs'; |
9 | 9 |
|
10 | 10 | /** |
11 | 11 | * base64.ts |
@@ -7167,23 +7167,27 @@ class TiledInflatePlugin extends plugin.BasePlugin { |
7167 | 7167 | super(); |
7168 | 7168 |
|
7169 | 7169 | // minimum melonJS version expected to run this plugin |
7170 | | - this.version = "15.2.0"; |
| 7170 | + this.version = "15.2.1"; |
7171 | 7171 |
|
7172 | 7172 | /** |
7173 | 7173 | * decompress and decode zlib/gzip data |
7174 | 7174 | * @param {string} input - base64 encoded and compressed data |
7175 | 7175 | * @param {string} format - compressed data format ("gzip","zlib", "zstd") |
7176 | 7176 | * @returns {Uint32Array} decoded and decompressed data |
7177 | 7177 | */ |
7178 | | - utils.inflateb64 = (data, format) => { |
7179 | | - if (format === "gzip" || format === "zlib") { |
7180 | | - var output = pako.inflate(gBase64.toUint8Array(data)); |
7181 | | - return new Uint32Array(output.buffer); |
7182 | | - } else { |
7183 | | - // TODO: ztsd compression (since Tiled 1.3) |
7184 | | - throw new Error(format + " compressed TMX Tile Map not supported!"); |
| 7178 | + TMXUtils.setInflateFunction((data, format) => { |
| 7179 | + let output; |
| 7180 | + switch (format) { |
| 7181 | + case "gzip": |
| 7182 | + case "zlib": |
| 7183 | + output = pako.inflate(gBase64.toUint8Array(data)); |
| 7184 | + break; |
| 7185 | + case "zstd": |
| 7186 | + default: |
| 7187 | + throw new Error(format + " compressed TMX Tile Map not supported!"); |
7185 | 7188 | } |
7186 | | - }; |
| 7189 | + return new Uint32Array(output.buffer); |
| 7190 | + }); |
7187 | 7191 | } |
7188 | 7192 | } |
7189 | 7193 |
|
|
0 commit comments