mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
allow to focus by burg name
This commit is contained in:
parent
d3e1a6cdf4
commit
da0e788020
1 changed files with 29 additions and 17 deletions
40
main.js
40
main.js
|
|
@ -262,10 +262,12 @@ function focusOn() {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
const params = url.searchParams;
|
const params = url.searchParams;
|
||||||
|
|
||||||
if (params.get("from") === "MFCG" && document.referrer) {
|
const fromMGCG = params.get("from") === "MFCG" && document.referrer;
|
||||||
|
if (fromMGCG) {
|
||||||
if (params.get("seed").length === 13) {
|
if (params.get("seed").length === 13) {
|
||||||
// show back burg from MFCG
|
// show back burg from MFCG
|
||||||
params.set("burg", params.get("seed").slice(-4));
|
const burgSeed = params.get("seed").slice(-4);
|
||||||
|
params.set("burg", burgSeed);
|
||||||
} else {
|
} else {
|
||||||
// select burg for MFCG
|
// select burg for MFCG
|
||||||
findBurgForMFCG(params);
|
findBurgForMFCG(params);
|
||||||
|
|
@ -273,23 +275,33 @@ function focusOn() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const s = +params.get("scale") || 8;
|
const scaleParam = params.get("scale");
|
||||||
let x = +params.get("x");
|
const cellParam = params.get("cell");
|
||||||
let y = +params.get("y");
|
const burgParam = params.get("burg");
|
||||||
|
|
||||||
const c = +params.get("cell");
|
if (scaleParam || cellParam || burgParam) {
|
||||||
if (c) {
|
const scale = +scaleParam || 8;
|
||||||
x = pack.cells.p[c][0];
|
|
||||||
y = pack.cells.p[c][1];
|
if (cellParam) {
|
||||||
|
const cell = +params.get("cell");
|
||||||
|
const [x, y] = pack.cells.p[cell];
|
||||||
|
zoomTo(x, y, scale, 1600);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const b = +params.get("burg");
|
if (burgParam) {
|
||||||
if (b && pack.burgs[b]) {
|
const burg = isNaN(+burgParam) ? pack.burgs.find(burg => burg.name === burgParam) : pack.burgs[+burgParam];
|
||||||
x = pack.burgs[b].x;
|
if (!burg) return;
|
||||||
y = pack.burgs[b].y;
|
|
||||||
|
const {x, y} = burg;
|
||||||
|
zoomTo(x, y, scale, 1600);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x && y) zoomTo(x, y, s, 1600);
|
const x = +params.get("x") || graphWidth / 2;
|
||||||
|
const y = +params.get("y") || graphHeight / 2;
|
||||||
|
zoomTo(x, y, scale, 1600);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// find burg for MFCG and focus on it
|
// find burg for MFCG and focus on it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue