Spaces:
Sleeping
Sleeping
File size: 2,639 Bytes
90cbf22 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import * as PIXI from 'pixi.js'
import { g_ctx } from './secontext.js' // global context
import * as CONFIG from './seconfig.js'
// --
// Set sizes and limits for HTML in main UI
// --
export function initMainHTMLWindow() {
document.getElementById("layer0pane").style.maxWidth = ""+CONFIG.htmlLayerPaneW+"px";
document.getElementById("layer0pane").style.maxHeight = ""+CONFIG.htmlLayerPaneH+"px";
document.getElementById("layer1pane").style.maxWidth = ""+CONFIG.htmlLayerPaneW+"px";
document.getElementById("layer1pane").style.maxHeight = ""+CONFIG.htmlLayerPaneH+"px";
document.getElementById("layer2pane").style.maxWidth = ""+CONFIG.htmlLayerPaneW+"px";
document.getElementById("layer2pane").style.maxHeight = ""+CONFIG.htmlLayerPaneH+"px";
document.getElementById("layer3pane").style.maxWidth = ""+CONFIG.htmlLayerPaneW+"px";
document.getElementById("layer3pane").style.maxHeight = ""+CONFIG.htmlLayerPaneH+"px";
document.getElementById("tilesetpane").style.maxWidth = ""+CONFIG.htmlTilesetPaneW+"px";
document.getElementById("tilesetpane").style.maxHeight = ""+CONFIG.htmlTilesetPaneH+"px";
document.getElementById("compositepane").style.maxWidth = ""+CONFIG.htmlCompositePaneW+"px";
document.getElementById("compositepane").style.maxHeight = ""+CONFIG.htmlCompositePaneH+"px";
// hide map tab
let mappane = document.getElementById("map");
mappane.style.display = "none";
}
// --
// Initialize handlers loading a PNG file into the composite window
// --
export function initCompositePNGLoader() {
const fileInput = document.getElementById('compositepng');
fileInput.onchange = (evt) => {
if (!window.FileReader) return; // Browser is not compatible
if (g_ctx.debug_flag) {
console.log("compositepng ", fileInput.files[0].name);
}
let bgname = fileInput.files[0].name;
const texture = PIXI.Texture.from("./"+bgname);
const bg = new PIXI.Sprite(texture);
bg.zIndex = 0;
g_ctx.composite.container.addChild(bg);
}
}
// --
// initailized handler to load a new tileset
// --
export function initTilesetLoader(callme) {
const fileInput = document.getElementById('tilesetfile');
fileInput.onchange = async (evt) => {
if (!window.FileReader) return; // Browser is not compatible
if (g_ctx.debug_flag) {
console.log("spritesheet ", fileInput.files[0].name);
}
g_ctx.tilesetpath = "./spritesheets/"+fileInput.files[0].name;
g_ctx.tiledimx = 16;
g_ctx.tiledimy = 16;
callme();
}
}
|