New visual style and multifloor support
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/** Module identifier for console logging */
|
||||
const MODULE_LOG_PREFIX = 'Quick Battlemap Importer';
|
||||
const MODULE_LOG_PREFIX = 'Myxeliums Battlemap Importer';
|
||||
|
||||
/**
|
||||
* @typedef {Object} ProcessedImageData
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
/** CSS selectors for frequently accessed elements */
|
||||
const PANEL_SELECTORS = {
|
||||
PANEL_ROOT: '#quick-battlemap-drop-area',
|
||||
PANEL_ROOT: '#myxeliums-battlemap-drop-area',
|
||||
CREATE_BUTTON: '.create-scene-button',
|
||||
RESET_BUTTON: '.reset-button',
|
||||
CLOSE_BUTTON: '.header-button.close',
|
||||
@@ -35,7 +35,7 @@ const PANEL_SELECTORS = {
|
||||
};
|
||||
|
||||
/** LocalStorage key for persisting no-grid preference */
|
||||
const NO_GRID_STORAGE_KEY = 'quick-battlemap:no-grid';
|
||||
const NO_GRID_STORAGE_KEY = 'myxeliums-battlemap:no-grid';
|
||||
|
||||
/**
|
||||
* View class that manages the import panel DOM and user interactions.
|
||||
@@ -83,7 +83,7 @@ export class ImportPanelView {
|
||||
}
|
||||
|
||||
// Remove any existing panel to prevent duplicates
|
||||
const existingPanel = document.getElementById('quick-battlemap-drop-area');
|
||||
const existingPanel = document.getElementById('myxeliums-battlemap-drop-area');
|
||||
if (existingPanel) {
|
||||
existingPanel.remove();
|
||||
}
|
||||
@@ -138,7 +138,7 @@ export class ImportPanelView {
|
||||
` : '';
|
||||
|
||||
return `
|
||||
<div id="quick-battlemap-drop-area" class="qbi-panel">
|
||||
<div id="myxeliums-battlemap-drop-area" class="qbi-panel">
|
||||
<header class="qbi-header">
|
||||
<div class="qbi-header-title">
|
||||
<i class="fas fa-map qbi-header-icon"></i>
|
||||
@@ -378,7 +378,7 @@ export class ImportPanelView {
|
||||
* @returns {HTMLElement|null} The panel element
|
||||
*/
|
||||
getPanelElement() {
|
||||
return document.getElementById('quick-battlemap-drop-area');
|
||||
return document.getElementById('myxeliums-battlemap-drop-area');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -554,7 +554,7 @@ export class SceneBuilder {
|
||||
|
||||
/**
|
||||
* Create floor tiles for multi-floor scenes using Levels module format.
|
||||
* Each additional floor is created as an overhead tile with proper elevation.
|
||||
* Each additional floor is created as a tile with proper elevation.
|
||||
*
|
||||
* @param {Scene} scene - The scene to add floor tiles to
|
||||
* @param {Array} additionalFloors - Array of floor data (excluding base floor)
|
||||
@@ -582,6 +582,7 @@ export class SceneBuilder {
|
||||
const rangeTop = elevation + floorHeight * 2 - 1;
|
||||
|
||||
// Create tile for this floor with Levels flags
|
||||
// Using overhead: false and proper Levels flags to avoid fade/zoom behavior
|
||||
const tileData = {
|
||||
texture: {
|
||||
src: floor.uploadedPath
|
||||
@@ -590,14 +591,17 @@ export class SceneBuilder {
|
||||
y: 0,
|
||||
width: baseDimensions.width || scene.width,
|
||||
height: baseDimensions.height || scene.height,
|
||||
overhead: true,
|
||||
overhead: false, // Not overhead - this is a floor tile
|
||||
roof: false,
|
||||
occlusion: { mode: 1 }, // Levels uses occlusion mode 1
|
||||
occlusion: { mode: 0 }, // No occlusion - controlled by Levels
|
||||
elevation: elevation,
|
||||
sort: 1000 + (i * 100),
|
||||
sort: 100 + (i * 10), // Lower sort order for floor tiles
|
||||
flags: {
|
||||
levels: {
|
||||
rangeTop: rangeTop
|
||||
rangeTop: rangeTop,
|
||||
showIfAbove: false, // Don't show when above this floor
|
||||
noCollision: true, // No 3D collision for floor tiles
|
||||
noFogHide: true // Don't hide in fog
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -183,12 +183,61 @@ export class SceneDataNormalizer {
|
||||
|
||||
/**
|
||||
* Normalize an array of wall data to Foundry's Wall document format.
|
||||
* Filters out regular walls that share exact coordinates with doors to prevent
|
||||
* duplicate walls blocking door functionality.
|
||||
*
|
||||
* @param {Array} wallsArray - Array of raw wall data objects
|
||||
* @returns {NormalizedWallData[]} Array of normalized wall documents
|
||||
*/
|
||||
normalizeWallsData(wallsArray) {
|
||||
return wallsArray.map(wall => this.normalizeWall(wall));
|
||||
const normalizedWalls = wallsArray.map(wall => this.normalizeWall(wall));
|
||||
return this.filterDuplicateWallsAtDoorLocations(normalizedWalls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out regular walls that have the same coordinates as doors.
|
||||
* Some map exports include both a wall segment and a door at the same location,
|
||||
* which causes the door to be blocked by the overlapping wall.
|
||||
*
|
||||
* @param {NormalizedWallData[]} walls - Array of normalized wall data
|
||||
* @returns {NormalizedWallData[]} Filtered array with duplicate walls removed
|
||||
*/
|
||||
filterDuplicateWallsAtDoorLocations(walls) {
|
||||
// Collect coordinates of all doors
|
||||
const doorCoordinates = new Set();
|
||||
|
||||
for (const wall of walls) {
|
||||
if (wall.door > 0 && Array.isArray(wall.c) && wall.c.length >= 4) {
|
||||
// Store both forward and reverse coordinate strings to handle different orderings
|
||||
const coordKey = wall.c.slice(0, 4).join(',');
|
||||
const reverseKey = [wall.c[2], wall.c[3], wall.c[0], wall.c[1]].join(',');
|
||||
doorCoordinates.add(coordKey);
|
||||
doorCoordinates.add(reverseKey);
|
||||
}
|
||||
}
|
||||
|
||||
// If no doors, return walls as-is
|
||||
if (doorCoordinates.size === 0) {
|
||||
return walls;
|
||||
}
|
||||
|
||||
// Filter out regular walls (door === 0) that share coordinates with doors
|
||||
return walls.filter(wall => {
|
||||
// Keep all doors
|
||||
if (wall.door > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if this regular wall overlaps with a door location
|
||||
if (Array.isArray(wall.c) && wall.c.length >= 4) {
|
||||
const coordKey = wall.c.slice(0, 4).join(',');
|
||||
if (doorCoordinates.has(coordKey)) {
|
||||
return false; // Remove this wall - there's a door here
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,16 +248,22 @@ export class SceneDataNormalizer {
|
||||
*/
|
||||
normalizeWall(wall) {
|
||||
const restrictionTypes = this.getWallRestrictionTypes();
|
||||
const doorType = this.ensureFiniteNumber(wall.door, 0);
|
||||
|
||||
// Doors should default to NORMAL restrictions (blocking) when closed,
|
||||
// while regular walls default to NONE (the source data usually specifies restrictions)
|
||||
const isDoor = doorType > 0;
|
||||
const defaultRestriction = isDoor ? restrictionTypes.NORMAL : restrictionTypes.NONE;
|
||||
|
||||
return {
|
||||
c: this.normalizeWallCoordinates(wall.c),
|
||||
door: this.ensureFiniteNumber(wall.door, 0),
|
||||
door: doorType,
|
||||
ds: this.ensureFiniteNumber(wall.ds, 0),
|
||||
dir: this.ensureFiniteNumber(wall.dir, 0),
|
||||
move: this.parseRestrictionValue(wall.move, restrictionTypes.NONE, restrictionTypes),
|
||||
sound: this.parseRestrictionValue(wall.sound, restrictionTypes.NONE, restrictionTypes),
|
||||
sight: this.parseRestrictionValue(wall.sense ?? wall.sight, restrictionTypes.NONE, restrictionTypes),
|
||||
light: this.parseRestrictionValue(wall.light, restrictionTypes.NONE, restrictionTypes),
|
||||
move: this.parseRestrictionValue(wall.move, defaultRestriction, restrictionTypes),
|
||||
sound: this.parseRestrictionValue(wall.sound, defaultRestriction, restrictionTypes),
|
||||
sight: this.parseRestrictionValue(wall.sense ?? wall.sight, defaultRestriction, restrictionTypes),
|
||||
light: this.parseRestrictionValue(wall.light, defaultRestriction, restrictionTypes),
|
||||
flags: wall.flags ?? {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -738,9 +738,10 @@ export class SceneImportController {
|
||||
}
|
||||
|
||||
// Set Levels module scene flags for floor definitions
|
||||
// Only set sceneLevels - let backgroundElevation default to 0
|
||||
// This prevents the background from incorrectly hiding/showing
|
||||
await createdScene.update({
|
||||
'flags.levels.sceneLevels': sceneLevels,
|
||||
'flags.levels.backgroundElevation': floorElevations[0]
|
||||
'flags.levels.sceneLevels': sceneLevels
|
||||
});
|
||||
|
||||
this.cleanupAfterMultiFloorCreation(sceneName);
|
||||
|
||||
Reference in New Issue
Block a user