mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
allow to edit MFCG link
This commit is contained in:
parent
6981d0f710
commit
e06356aa57
5 changed files with 45 additions and 15 deletions
|
|
@ -2277,10 +2277,10 @@ svg.button {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
max-width: 22em;
|
max-width: 23em;
|
||||||
background-color: #fff;
|
|
||||||
padding: 1.2em;
|
padding: 1.2em;
|
||||||
border: solid 1px #000;
|
background-color: var(--bg-dialogs);
|
||||||
|
border: solid 1px var(--dark-solid);
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2036,9 +2036,12 @@
|
||||||
<div id="mfcgPreviewSection" data-tip="Burg preview in the Medieval Fantasy City Generator. Default seed is a combination of map seed and burg id" style="display: flex; flex-direction: column">
|
<div id="mfcgPreviewSection" data-tip="Burg preview in the Medieval Fantasy City Generator. Default seed is a combination of map seed and burg id" style="display: flex; flex-direction: column">
|
||||||
<div>
|
<div>
|
||||||
See in <a id="mfcgLink" target="_blank">City Generator by Watabou</a>.
|
See in <a id="mfcgLink" target="_blank">City Generator by Watabou</a>.
|
||||||
|
<div id="mfcgBurgSeedSection">
|
||||||
Seed: <input id="mfcgBurgSeed" style="width: 10em" type="number" min=1 max="1e13" step="1" />
|
Seed: <input id="mfcgBurgSeed" style="width: 10em" type="number" min=1 max="1e13" step="1" />
|
||||||
<i id="regenerateMFCGBurgSeed" data-tip="Randomize Medieval Fantasy City Generator burg seed" class="icon-arrows-cw pointer" style="margin-left: .1em"></i>
|
<i id="regenerateMFCGBurgSeed" data-tip="Randomize Medieval Fantasy City Generator burg seed" class="icon-arrows-cw pointer" style="margin-left: .1em"></i>
|
||||||
</div>
|
</div>
|
||||||
|
<i id="addCustomMFCGBurgLink" data-tip="Provide custom link to the burg map" class="icon-pencil pointer" style="margin-left: .1em"></i>
|
||||||
|
</div>
|
||||||
<iframe id="mfcgPreview" sandbox="allow-scripts allow-same-origin"></iframe>
|
<iframe id="mfcgPreview" sandbox="allow-scripts allow-same-origin"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -3656,7 +3659,7 @@
|
||||||
<div id="prompt" style="display: none" class="dialog">
|
<div id="prompt" style="display: none" class="dialog">
|
||||||
<form id="promptForm">
|
<form id="promptForm">
|
||||||
<div id="promptText"></div>
|
<div id="promptText"></div>
|
||||||
<input id="promptInput" type="number" step=.01 placeholder="type value" autocomplete="off" required>
|
<input id="promptInput" type="number" step=.01 placeholder="type value" autocomplete="off">
|
||||||
<button type="submit">Confirm</button>
|
<button type="submit">Confirm</button>
|
||||||
<button type="button" id="promptCancel" formnovalidate>Cancel</button>
|
<button type="button" id="promptCancel" formnovalidate>Cancel</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ function editBurg(id) {
|
||||||
burgBody.querySelectorAll(".burgFeature").forEach(el => el.addEventListener("click", toggleFeature));
|
burgBody.querySelectorAll(".burgFeature").forEach(el => el.addEventListener("click", toggleFeature));
|
||||||
document.getElementById("mfcgBurgSeed").addEventListener("change", changeSeed);
|
document.getElementById("mfcgBurgSeed").addEventListener("change", changeSeed);
|
||||||
document.getElementById("regenerateMFCGBurgSeed").addEventListener("click", randomizeSeed);
|
document.getElementById("regenerateMFCGBurgSeed").addEventListener("click", randomizeSeed);
|
||||||
|
document.getElementById("addCustomMFCGBurgLink").addEventListener("click", addCustomMfcgLink);
|
||||||
|
|
||||||
document.getElementById("burgStyleShow").addEventListener("click", showStyleSection);
|
document.getElementById("burgStyleShow").addEventListener("click", showStyleSection);
|
||||||
document.getElementById("burgStyleHide").addEventListener("click", hideStyleSection);
|
document.getElementById("burgStyleHide").addEventListener("click", hideStyleSection);
|
||||||
|
|
@ -112,7 +113,13 @@ function editBurg(id) {
|
||||||
if (options.showMFCGMap) {
|
if (options.showMFCGMap) {
|
||||||
document.getElementById("mfcgPreviewSection").style.display = "block";
|
document.getElementById("mfcgPreviewSection").style.display = "block";
|
||||||
updateMFCGFrame(b);
|
updateMFCGFrame(b);
|
||||||
|
|
||||||
|
if (b.link) {
|
||||||
|
document.getElementById("mfcgBurgSeedSection").style.display = "none";
|
||||||
|
} else {
|
||||||
|
document.getElementById("mfcgBurgSeedSection").style.display = "inline-block";
|
||||||
document.getElementById("mfcgBurgSeed").value = getBurgSeed(b);
|
document.getElementById("mfcgBurgSeed").value = getBurgSeed(b);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("mfcgPreviewSection").style.display = "none";
|
document.getElementById("mfcgPreviewSection").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
@ -428,6 +435,17 @@ function editBurg(id) {
|
||||||
document.getElementById("mfcgBurgSeed").value = burgSeed;
|
document.getElementById("mfcgBurgSeed").value = burgSeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addCustomMfcgLink() {
|
||||||
|
const id = +elSelected.attr("data-id");
|
||||||
|
const burg = pack.burgs[id];
|
||||||
|
const message = "Enter custom link to the burg map. It can be a link to Medieval Fantasy City Generator or other tool. Keep empty to use MFCG seed";
|
||||||
|
prompt(message, {default: burg.link || "", required: false}, link => {
|
||||||
|
if (link) burg.link = link;
|
||||||
|
else delete burg.link;
|
||||||
|
updateMFCGFrame(burg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function openEmblemEdit() {
|
function openEmblemEdit() {
|
||||||
const id = +elSelected.attr("data-id"),
|
const id = +elSelected.attr("data-id"),
|
||||||
burg = pack.burgs[id];
|
burg = pack.burgs[id];
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,8 @@ function getBurgSeed(burg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMFCGlink(burg) {
|
function getMFCGlink(burg) {
|
||||||
|
if (burg.link) return burg.link;
|
||||||
|
|
||||||
const {cells} = pack;
|
const {cells} = pack;
|
||||||
const {name, population, cell} = burg;
|
const {name, population, cell} = burg;
|
||||||
const burgSeed = getBurgSeed(burg);
|
const burgSeed = getBurgSeed(burg);
|
||||||
|
|
|
||||||
|
|
@ -154,18 +154,23 @@ void (function () {
|
||||||
const prompt = document.getElementById("prompt");
|
const prompt = document.getElementById("prompt");
|
||||||
const form = prompt.querySelector("#promptForm");
|
const form = prompt.querySelector("#promptForm");
|
||||||
|
|
||||||
window.prompt = function (promptText = "Please provide an input", options = {default: 1, step: 0.01, min: 0, max: 100}, callback) {
|
const defaultText = "Please provide an input";
|
||||||
if (options.default === undefined) {
|
const defaultOptions = {default: 1, step: 0.01, min: 0, max: 100, required: true};
|
||||||
ERROR && console.error("Prompt: options object does not have default value defined");
|
|
||||||
return;
|
window.prompt = function (promptText = defaultText, options = defaultOptions, callback) {
|
||||||
}
|
if (options.default === undefined) return ERROR && console.error("Prompt: options object does not have default value defined");
|
||||||
|
|
||||||
const input = prompt.querySelector("#promptInput");
|
const input = prompt.querySelector("#promptInput");
|
||||||
prompt.querySelector("#promptText").innerHTML = promptText;
|
prompt.querySelector("#promptText").innerHTML = promptText;
|
||||||
|
|
||||||
const type = typeof options.default === "number" ? "number" : "text";
|
const type = typeof options.default === "number" ? "number" : "text";
|
||||||
input.type = type;
|
input.type = type;
|
||||||
|
|
||||||
if (options.step !== undefined) input.step = options.step;
|
if (options.step !== undefined) input.step = options.step;
|
||||||
if (options.min !== undefined) input.min = options.min;
|
if (options.min !== undefined) input.min = options.min;
|
||||||
if (options.max !== undefined) input.max = options.max;
|
if (options.max !== undefined) input.max = options.max;
|
||||||
|
|
||||||
|
input.required = options.required === false ? false : true;
|
||||||
input.placeholder = "type a " + type;
|
input.placeholder = "type a " + type;
|
||||||
input.value = options.default;
|
input.value = options.default;
|
||||||
prompt.style.display = "block";
|
prompt.style.display = "block";
|
||||||
|
|
@ -173,9 +178,9 @@ void (function () {
|
||||||
form.addEventListener(
|
form.addEventListener(
|
||||||
"submit",
|
"submit",
|
||||||
event => {
|
event => {
|
||||||
|
event.preventDefault();
|
||||||
prompt.style.display = "none";
|
prompt.style.display = "none";
|
||||||
const v = type === "number" ? +input.value : input.value;
|
const v = type === "number" ? +input.value : input.value;
|
||||||
event.preventDefault();
|
|
||||||
if (callback) callback(v);
|
if (callback) callback(v);
|
||||||
},
|
},
|
||||||
{once: true}
|
{once: true}
|
||||||
|
|
@ -183,7 +188,9 @@ void (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancel = prompt.querySelector("#promptCancel");
|
const cancel = prompt.querySelector("#promptCancel");
|
||||||
cancel.addEventListener("click", () => (prompt.style.display = "none"));
|
cancel.addEventListener("click", () => {
|
||||||
|
prompt.style.display = "none";
|
||||||
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// indexedDB; ldb object
|
// indexedDB; ldb object
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue