mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: hierarchy-tree - make sure nodes have parents not removed
This commit is contained in:
parent
3883933385
commit
4ab0311d01
6 changed files with 32 additions and 15 deletions
|
|
@ -7864,7 +7864,7 @@
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.87.07"></script>
|
<script defer src="modules/ui/editors.js?v=1.88.06"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.88.05"></script>
|
<script defer src="modules/ui/tools.js?v=1.88.05"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script defer src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/heightmap-editor.js?v=1.88.03"></script>
|
<script defer src="modules/ui/heightmap-editor.js?v=1.88.03"></script>
|
||||||
|
|
|
||||||
|
|
@ -630,7 +630,7 @@ function togglePercentageMode() {
|
||||||
|
|
||||||
async function showHierarchy() {
|
async function showHierarchy() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.87.01");
|
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.88.06");
|
||||||
|
|
||||||
const getDescription = culture => {
|
const getDescription = culture => {
|
||||||
const {name, type, rural, urban} = culture;
|
const {name, type, rural, urban} = culture;
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,7 @@ function togglePercentageMode() {
|
||||||
|
|
||||||
async function showHierarchy() {
|
async function showHierarchy() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.87.01");
|
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.88.06");
|
||||||
|
|
||||||
const getDescription = religion => {
|
const getDescription = religion => {
|
||||||
const {name, type, form, rural, urban} = religion;
|
const {name, type, form, rural, urban} = religion;
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@ export function open(props) {
|
||||||
closeDialogs("#hierarchyTree, .stable");
|
closeDialogs("#hierarchyTree, .stable");
|
||||||
|
|
||||||
dataElements = props.data;
|
dataElements = props.data;
|
||||||
dataElements[0].origins = [null];
|
validElements = cleanupOrigins(dataElements);
|
||||||
validElements = dataElements.filter(r => !r.removed);
|
|
||||||
if (validElements.length < 3) return tip(`Not enough ${props.type} to show hierarchy`, false, "error");
|
if (validElements.length < 3) return tip(`Not enough ${props.type} to show hierarchy`, false, "error");
|
||||||
|
|
||||||
onNodeEnter = props.onNodeEnter;
|
onNodeEnter = props.onNodeEnter;
|
||||||
|
|
@ -39,6 +38,8 @@ export function open(props) {
|
||||||
getShape = props.getShape;
|
getShape = props.getShape;
|
||||||
|
|
||||||
const root = getRoot();
|
const root = getRoot();
|
||||||
|
if (!root) return;
|
||||||
|
|
||||||
const treeWidth = root.leaves().length * 50;
|
const treeWidth = root.leaves().length * 50;
|
||||||
const treeHeight = root.height * 50;
|
const treeHeight = root.height * 50;
|
||||||
|
|
||||||
|
|
@ -175,7 +176,19 @@ function insertHtml() {
|
||||||
byId("dialogs").insertAdjacentHTML("beforeend", html);
|
byId("dialogs").insertAdjacentHTML("beforeend", html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanupOrigins(elements) {
|
||||||
|
const existingElements = elements.filter(d => !d.removed);
|
||||||
|
|
||||||
|
return existingElements.map(d => {
|
||||||
|
if (d.i === 0) d.origins = [null]; // root element
|
||||||
|
else if (!d.origins.length) d.origins = [0];
|
||||||
|
else if (!existingElements.find(el => d.origins[0] === el.i)) d.origins = [0];
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getRoot() {
|
function getRoot() {
|
||||||
|
try {
|
||||||
const root = d3
|
const root = d3
|
||||||
.stratify()
|
.stratify()
|
||||||
.id(d => d.i)
|
.id(d => d.i)
|
||||||
|
|
@ -183,6 +196,10 @@ function getRoot() {
|
||||||
|
|
||||||
oldRoot = root;
|
oldRoot = root;
|
||||||
return root;
|
return root;
|
||||||
|
} catch (error) {
|
||||||
|
tip("Hierarchy data issue. " + error, false, "error", 6000);
|
||||||
|
return oldRoot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLinkKey(d) {
|
function getLinkKey(d) {
|
||||||
|
|
|
||||||
|
|
@ -1182,12 +1182,12 @@ async function editStates() {
|
||||||
|
|
||||||
async function editCultures() {
|
async function editCultures() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.87.06");
|
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.88.06");
|
||||||
Editor.open();
|
Editor.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editReligions() {
|
async function editReligions() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.87.01");
|
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.88.06");
|
||||||
Editor.open();
|
Editor.open();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// version and caching control
|
// version and caching control
|
||||||
const version = "1.88.05"; // generator version, update each time
|
const version = "1.88.06"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue