Ice Layer Data Model (#1262)

* prototype for ice seperation

* feat: migrate ice data to new data model and update version to 1.110.0

* refactor: update ice data handling and rendering for improved performance

* feat: integrate ice generation and recalculation in heightmap editing

* fix ice selection(hopefully)

* fix ice selection better(pls)

* refactor: remove redundant element selection in ice editing functions

* fix: clear ice data before generating glaciers and icebergs

* sparse array implementation with reduced updates

* fix logic chech in modules/dynamic/auto-update.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: migrate ice data to new data model structure

* refactor: streamline ice generation process and clean up rendering functions

* refactor: simplify ice rendering logic by removing redundant clearing of old SVG

* fix: update editIce function to accept element parameter and improve logic for glacier handling

* ice drawing with only type on less occuring glaciers

* feat: add compactPackData function to filter out undefined glaciers and icebergs

* fix: clear existing ice elements before redrawing in editHeightmap function

* fix compact problems on autosave

* refactor: unify ice data structure and streamline ice element handling

* refactor: improve getNextId function to fill gaps in ice element IDs(optional commit)

* just to be sure

* bump version in html

* fix index.html script import

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
kruschen 2026-01-22 17:33:30 +01:00 committed by GitHub
parent b223dc62da
commit e597d905eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 402 additions and 118 deletions

View file

@ -32,12 +32,13 @@ async function saveMap(method) {
$(this).dialog("close");
}
},
position: {my: "center", at: "center", of: "svg"}
position: { my: "center", at: "center", of: "svg" }
});
}
}
function prepareMapData() {
const date = new Date();
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
@ -89,8 +90,8 @@ function prepareMapData() {
const serializedSVG = new XMLSerializer().serializeToString(cloneEl);
const {spacing, cellsX, cellsY, boundary, points, features, cellsDesired} = grid;
const gridGeneral = JSON.stringify({spacing, cellsX, cellsY, boundary, points, features, cellsDesired});
const { spacing, cellsX, cellsY, boundary, points, features, cellsDesired } = grid;
const gridGeneral = JSON.stringify({ spacing, cellsX, cellsY, boundary, points, features, cellsDesired });
const packFeatures = JSON.stringify(pack.features);
const cultures = JSON.stringify(pack.cultures);
const states = JSON.stringify(pack.states);
@ -102,6 +103,7 @@ function prepareMapData() {
const cellRoutes = JSON.stringify(pack.cells.routes);
const routes = JSON.stringify(pack.routes);
const zones = JSON.stringify(pack.zones);
const ice = JSON.stringify(pack.ice);
// store name array only if not the same as default
const defaultNB = Names.getNameBases();
@ -155,21 +157,22 @@ function prepareMapData() {
markers,
cellRoutes,
routes,
zones
zones,
ice
].join("\r\n");
return mapData;
}
// save map file to indexedDB
async function saveToStorage(mapData, showTip = false) {
const blob = new Blob([mapData], {type: "text/plain"});
const blob = new Blob([mapData], { type: "text/plain" });
await ldb.set("lastMap", blob);
showTip && tip("Map is saved to the browser storage", false, "success");
}
// download map file
function saveToMachine(mapData, filename) {
const blob = new Blob([mapData], {type: "text/plain"});
const blob = new Blob([mapData], { type: "text/plain" });
const URL = window.URL.createObjectURL(blob);
const link = document.createElement("a");