mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
feat: change load from cloud format and order
This commit is contained in:
parent
3694d77b87
commit
44e98d853f
4 changed files with 2362 additions and 525 deletions
2821
index.html
2821
index.html
File diff suppressed because one or more lines are too long
|
|
@ -73,7 +73,13 @@ window.Cloud = (function () {
|
||||||
|
|
||||||
async list() {
|
async list() {
|
||||||
const resp = await this.call("filesListFolder", {path: ""});
|
const resp = await this.call("filesListFolder", {path: ""});
|
||||||
return resp.result.entries.map(e => ({name: e.name, path: e.path_lower}));
|
const filesData = resp.result.entries.map(({name, client_modified, size, path_lower}) => ({
|
||||||
|
name: name,
|
||||||
|
updated: client_modified,
|
||||||
|
size,
|
||||||
|
path: path_lower
|
||||||
|
}));
|
||||||
|
return filesData.filter(({size}) => size).reverse();
|
||||||
},
|
},
|
||||||
|
|
||||||
auth() {
|
auth() {
|
||||||
|
|
@ -117,7 +123,13 @@ window.Cloud = (function () {
|
||||||
if (sharedLinks.result.links.length) return resp.result.links[0].url;
|
if (sharedLinks.result.links.length) return resp.result.links[0].url;
|
||||||
|
|
||||||
// create new shared link
|
// create new shared link
|
||||||
const settings = {require_password: false, audience: "public", access: "viewer", requested_visibility: "public", allow_download: true};
|
const settings = {
|
||||||
|
require_password: false,
|
||||||
|
audience: "public",
|
||||||
|
access: "viewer",
|
||||||
|
requested_visibility: "public",
|
||||||
|
allow_download: true
|
||||||
|
};
|
||||||
const resp = await this.call("sharingCreateSharedLinkWithSettings", {path, settings});
|
const resp = await this.call("sharingCreateSharedLinkWithSettings", {path, settings});
|
||||||
DEBUG && console.log("Dropbox link object:", resp.result);
|
DEBUG && console.log("Dropbox link object:", resp.result);
|
||||||
return resp.result.url;
|
return resp.result.url;
|
||||||
|
|
|
||||||
|
|
@ -69,15 +69,22 @@ document
|
||||||
if (id === "layersTab") layersContent.style.display = "block";
|
if (id === "layersTab") layersContent.style.display = "block";
|
||||||
else if (id === "styleTab") styleContent.style.display = "block";
|
else if (id === "styleTab") styleContent.style.display = "block";
|
||||||
else if (id === "optionsTab") optionsContent.style.display = "block";
|
else if (id === "optionsTab") optionsContent.style.display = "block";
|
||||||
else if (id === "toolsTab") customization === 1 ? (customizationMenu.style.display = "block") : (toolsContent.style.display = "block");
|
else if (id === "toolsTab")
|
||||||
|
customization === 1 ? (customizationMenu.style.display = "block") : (toolsContent.style.display = "block");
|
||||||
else if (id === "aboutTab") aboutContent.style.display = "block";
|
else if (id === "aboutTab") aboutContent.style.display = "block";
|
||||||
});
|
});
|
||||||
|
|
||||||
// show popup with a list of Patreon supportes (updated manually)
|
// show popup with a list of Patreon supportes (updated manually)
|
||||||
async function showSupporters() {
|
async function showSupporters() {
|
||||||
const {supporters} = await import("../dynamic/supporters.js?v=01062022");
|
const {supporters} = await import("../dynamic/supporters.js?v=01062022");
|
||||||
alertMessage.innerHTML = "<ul style='column-count: 5; column-gap: 2em'>" + supporters.map(n => `<li>${n}</li>`).join("") + "</ul>";
|
alertMessage.innerHTML =
|
||||||
$("#alert").dialog({resizable: false, title: "Patreon Supporters", width: "54vw", position: {my: "center", at: "center", of: "svg"}});
|
"<ul style='column-count: 5; column-gap: 2em'>" + supporters.map(n => `<li>${n}</li>`).join("") + "</ul>";
|
||||||
|
$("#alert").dialog({
|
||||||
|
resizable: false,
|
||||||
|
title: "Patreon Supporters",
|
||||||
|
width: "54vw",
|
||||||
|
position: {my: "center", at: "center", of: "svg"}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// on any option or dialog change
|
// on any option or dialog change
|
||||||
|
|
@ -292,7 +299,9 @@ function restoreDefaultZoomExtent() {
|
||||||
|
|
||||||
function copyMapURL() {
|
function copyMapURL() {
|
||||||
const locked = document.querySelectorAll("i.icon-lock").length; // check if some options are locked
|
const locked = document.querySelectorAll("i.icon-lock").length; // check if some options are locked
|
||||||
const search = `?seed=${optionsSeed.value}&width=${graphWidth}&height=${graphHeight}${locked ? "" : "&options=default"}`;
|
const search = `?seed=${optionsSeed.value}&width=${graphWidth}&height=${graphHeight}${
|
||||||
|
locked ? "" : "&options=default"
|
||||||
|
}`;
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
.writeText(location.host + location.pathname + search)
|
.writeText(location.host + location.pathname + search)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
@ -345,7 +354,8 @@ function changeEmblemShape(emblemShape) {
|
||||||
shapePath ? image.setAttribute("d", shapePath) : image.removeAttribute("d");
|
shapePath ? image.setAttribute("d", shapePath) : image.removeAttribute("d");
|
||||||
|
|
||||||
const specificShape = ["culture", "state", "random"].includes(emblemShape) ? null : emblemShape;
|
const specificShape = ["culture", "state", "random"].includes(emblemShape) ? null : emblemShape;
|
||||||
if (emblemShape === "random") pack.cultures.filter(c => !c.removed).forEach(c => (c.shield = Cultures.getRandomShield()));
|
if (emblemShape === "random")
|
||||||
|
pack.cultures.filter(c => !c.removed).forEach(c => (c.shield = Cultures.getRandomShield()));
|
||||||
|
|
||||||
const rerenderCOA = (id, coa) => {
|
const rerenderCOA = (id, coa) => {
|
||||||
const coaEl = document.getElementById(id);
|
const coaEl = document.getElementById(id);
|
||||||
|
|
@ -541,8 +551,10 @@ function randomizeOptions() {
|
||||||
if (randomize || !locked("prec")) precInput.value = precOutput.value = gauss(100, 40, 5, 500);
|
if (randomize || !locked("prec")) precInput.value = precOutput.value = gauss(100, 40, 5, 500);
|
||||||
const tMax = 30,
|
const tMax = 30,
|
||||||
tMin = -30; // temperature extremes
|
tMin = -30; // temperature extremes
|
||||||
if (randomize || !locked("temperatureEquator")) temperatureEquatorOutput.value = temperatureEquatorInput.value = rand(tMax - 10, tMax);
|
if (randomize || !locked("temperatureEquator"))
|
||||||
if (randomize || !locked("temperaturePole")) temperaturePoleOutput.value = temperaturePoleInput.value = rand(tMin, tMin + 30);
|
temperatureEquatorOutput.value = temperatureEquatorInput.value = rand(tMax - 10, tMax);
|
||||||
|
if (randomize || !locked("temperaturePole"))
|
||||||
|
temperaturePoleOutput.value = temperaturePoleInput.value = rand(tMin, tMin + 30);
|
||||||
|
|
||||||
// 'Units Editor' settings
|
// 'Units Editor' settings
|
||||||
const US = navigator.language === "en-US";
|
const US = navigator.language === "en-US";
|
||||||
|
|
@ -644,7 +656,8 @@ document.getElementById("sticked").addEventListener("click", function (event) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function regeneratePrompt(options) {
|
function regeneratePrompt(options) {
|
||||||
if (customization) return tip("New map cannot be generated when edit mode is active, please exit the mode and retry", false, "error");
|
if (customization)
|
||||||
|
return tip("New map cannot be generated when edit mode is active, please exit the mode and retry", false, "error");
|
||||||
const workingTime = (Date.now() - last(mapHistory).created) / 60000; // minutes
|
const workingTime = (Date.now() - last(mapHistory).created) / 60000; // minutes
|
||||||
if (workingTime < 5) return regenerateMap(options);
|
if (workingTime < 5) return regenerateMap(options);
|
||||||
|
|
||||||
|
|
@ -735,11 +748,12 @@ async function showLoadPane() {
|
||||||
|
|
||||||
loadFromDropboxButtons.style.display = "block";
|
loadFromDropboxButtons.style.display = "block";
|
||||||
fileSelect.innerHTML = "";
|
fileSelect.innerHTML = "";
|
||||||
files.forEach(file => {
|
files.forEach(({name, updated, size, path}) => {
|
||||||
const opt = document.createElement("option");
|
const sizeMB = rn(size / 1024 / 1024, 2) + " MB";
|
||||||
opt.innerText = file.name;
|
const updatedOn = new Date(updated).toLocaleDateString();
|
||||||
opt.value = file.path;
|
const nameFormatted = `${updatedOn}: ${name} [${sizeMB}]`;
|
||||||
fileSelect.appendChild(opt);
|
const option = new Option(nameFormatted, path);
|
||||||
|
fileSelect.options.add(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
@ -860,7 +874,10 @@ function updateTilesOptions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const rectsG = "<g fill='none' stroke='#000'>" + rects.join("") + "</g>";
|
const rectsG = "<g fill='none' stroke='#000'>" + rects.join("") + "</g>";
|
||||||
const labelsG = "<g fill='#000' stroke='none' text-anchor='middle' dominant-baseline='central' font-size='24px'>" + labels.join("") + "</g>";
|
const labelsG =
|
||||||
|
"<g fill='#000' stroke='none' text-anchor='middle' dominant-baseline='central' font-size='24px'>" +
|
||||||
|
labels.join("") +
|
||||||
|
"</g>";
|
||||||
debug.html(rectsG + labelsG);
|
debug.html(rectsG + labelsG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -912,7 +929,8 @@ async function enter3dView(type) {
|
||||||
|
|
||||||
canvas.style.display = "block";
|
canvas.style.display = "block";
|
||||||
canvas.onmouseenter = () => {
|
canvas.onmouseenter = () => {
|
||||||
const help = "Left mouse to change angle, middle mouse / mousewheel to zoom, right mouse to pan. <b>O</b> to toggle options";
|
const help =
|
||||||
|
"Left mouse to change angle, middle mouse / mousewheel to zoom, right mouse to pan. <b>O</b> to toggle options";
|
||||||
+canvas.dataset.hovered > 2 ? tip("") : tip(help);
|
+canvas.dataset.hovered > 2 ? tip("") : tip(help);
|
||||||
canvas.dataset.hovered = (+canvas.dataset.hovered | 0) + 1;
|
canvas.dataset.hovered = (+canvas.dataset.hovered | 0) + 1;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
// version and caching control
|
// version and caching control
|
||||||
|
|
||||||
const version = "1.84.12"; // generator version, update each time
|
const version = "1.85.00"; // generator version, update each time
|
||||||
|
|
||||||
{
|
{
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue