mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.4.48
This commit is contained in:
parent
d5d9057621
commit
6214269a91
10 changed files with 154 additions and 133 deletions
|
|
@ -516,26 +516,15 @@ function getNextId(core, i = 1) {
|
|||
return core + i;
|
||||
}
|
||||
|
||||
// from https://davidwalsh.name/javascript-debounce-function
|
||||
function debounce(func, wait, immediate) {
|
||||
var timeout;
|
||||
return function() {
|
||||
var context = this, args = arguments;
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
}
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
}
|
||||
}
|
||||
function debounce(f, ms) {
|
||||
let isCooldown = false;
|
||||
|
||||
// pause/block JS execution for a while
|
||||
function sleep(delay) {
|
||||
const start = new Date().getTime();
|
||||
while (new Date().getTime() < start + delay);
|
||||
return function() {
|
||||
if (isCooldown) return;
|
||||
f.apply(this, arguments);
|
||||
isCooldown = true;
|
||||
setTimeout(() => isCooldown = false, ms);
|
||||
};
|
||||
}
|
||||
|
||||
// parse error to get the readable string in Chrome and Firefox
|
||||
|
|
@ -597,6 +586,12 @@ function generateDate(from = 100, to = 1000) {
|
|||
return new Date(rand(from, to),rand(12),rand(31)).toLocaleDateString("en", {year:'numeric', month:'long', day:'numeric'});
|
||||
}
|
||||
|
||||
function getQGIScoordinates(x, y) {
|
||||
const cx = mapCoordinates.lonW + (x / graphWidth) * mapCoordinates.lonT;
|
||||
const cy = mapCoordinates.latN - (y / graphHeight) * mapCoordinates.latT; // this is inverted in QGIS otherwise
|
||||
return [cx, cy];
|
||||
}
|
||||
|
||||
// prompt replacer (prompt does not work in Electron)
|
||||
void function() {
|
||||
const prompt = document.getElementById("prompt");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue