mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
refactor(es modules): continue migration
This commit is contained in:
parent
030caec6e8
commit
a929667796
16 changed files with 30 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
const $body = insertEditorHtml();
|
const $body = insertEditorHtml();
|
||||||
addListeners();
|
addListeners();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {shouldRegenerateGrid, generateGrid} from "/src/utils/graphUtils";
|
import {shouldRegenerateGrid, generateGrid} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
const initialSeed = generateSeed();
|
const initialSeed = generateSeed();
|
||||||
let graph = getGraph(grid);
|
let graph = getGraph(grid);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
appendStyleSheet();
|
appendStyleSheet();
|
||||||
insertHtml();
|
insertHtml();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {rollups} from "../../../utils/functionUtils.js";
|
import {rollups} from "../../../utils/functionUtils.js";
|
||||||
import {isWater} from "/src/utils/graphUtils";
|
import {isWater} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
const entitiesMap = {
|
const entitiesMap = {
|
||||||
states: {
|
states: {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {TIME} from "/src/config/logging";
|
import {TIME} from "/src/config/logging";
|
||||||
import {createTypedArray} from "/src/utils/arrayUtils";
|
import {createTypedArray} from "/src/utils/arrayUtils";
|
||||||
import {findGridCell} from "/src/utils/graphUtils";
|
import {findGridCell} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
window.HeightmapGenerator = (function () {
|
window.HeightmapGenerator = (function () {
|
||||||
let grid = null;
|
let grid = null;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {getGridPolygon} from "/src/utils/graphUtils";
|
import {getGridPolygon} from "/src/utils/graphUtils";
|
||||||
|
import {unique} from "/src/utils/arrayUtils";
|
||||||
|
|
||||||
// download map as SVG
|
// download map as SVG
|
||||||
async function saveSVG() {
|
async function saveSVG() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {TIME} from "/src/config/logging";
|
import {TIME} from "/src/config/logging";
|
||||||
import {findAll} from "/src/utils/graphUtils";
|
import {findAll} from "/src/utils/graphUtils";
|
||||||
|
import {unique} from "/src/utils/arrayUtils";
|
||||||
|
|
||||||
window.Religions = (function () {
|
window.Religions = (function () {
|
||||||
// name generation approach and relative chance to be selected
|
// name generation approach and relative chance to be selected
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {findCell} from "/src/utils/graphUtils";
|
import {findCell} from "/src/utils/graphUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
// restore default viewbox events
|
// restore default viewbox events
|
||||||
function restoreDefaultEvents() {
|
function restoreDefaultEvents() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {findGridCell, findGridAll, findCell, getPackPolygon, getGridPolygon} from "/src/utils/graphUtils";
|
import {findGridCell, findGridAll, findCell, getPackPolygon, getGridPolygon} from "/src/utils/graphUtils";
|
||||||
import {last} from "/src/utils/arrayUtils";
|
import {last, createTypedArray} from "/src/utils/arrayUtils";
|
||||||
|
import {byId} from "/src/utils/shorthands";
|
||||||
|
|
||||||
export function editHeightmap(options) {
|
export function editHeightmap(options) {
|
||||||
const {mode, tool} = options || {};
|
const {mode, tool} = options || {};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
import {unique} from "/src/utils/arrayUtils";
|
||||||
function editNamesbase() {
|
|
||||||
|
export function editNamesbase() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
closeDialogs("#namesbaseEditor, .stable");
|
closeDialogs("#namesbaseEditor, .stable");
|
||||||
$("#namesbaseEditor").dialog();
|
$("#namesbaseEditor").dialog();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {stored, lock, locked, applyOption} from "./general";
|
import {stored, lock, locked, applyOption} from "./general";
|
||||||
import {last} from "/src/utils/arrayUtils";
|
import {last} from "/src/utils/arrayUtils";
|
||||||
import {byId} from "/src/utils/shorthands";
|
import {byId} from "/src/utils/shorthands";
|
||||||
import {last} from "/src/utils/arrayUtils";
|
|
||||||
|
|
||||||
$("#optionsContainer").draggable({handle: ".drag-trigger", snap: "svg", snapMode: "both"});
|
$("#optionsContainer").draggable({handle: ".drag-trigger", snap: "svg", snapMode: "both"});
|
||||||
$("#exitCustomization").draggable({handle: "div"});
|
$("#exitCustomization").draggable({handle: "div"});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||||
|
import {unique} from "/src/utils/arrayUtils";
|
||||||
|
|
||||||
export function editProvinces() {
|
export function editProvinces() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {findAll, findCell, getPackPolygon} from "/src/utils/graphUtils";
|
import {findAll, findCell, getPackPolygon} from "/src/utils/graphUtils";
|
||||||
|
import {unique} from "/src/utils/arrayUtils";
|
||||||
|
|
||||||
export function editZones() {
|
export function editZones() {
|
||||||
closeDialogs();
|
closeDialogs();
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,6 @@ export function unique<T>(array: T[]) {
|
||||||
return [...new Set(array)];
|
return [...new Set(array)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTypedArray(maxValue: number) {
|
|
||||||
console.assert(
|
|
||||||
Number.isInteger(maxValue) && maxValue >= 0 && maxValue <= UINT32_MAX,
|
|
||||||
`Array maxValue must be an integer between 0 and ${UINT32_MAX}, got ${maxValue}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (maxValue <= UINT8_MAX) return Uint8Array;
|
|
||||||
if (maxValue <= UINT16_MAX) return Uint16Array;
|
|
||||||
if (maxValue <= UINT32_MAX) return Uint32Array;
|
|
||||||
return Uint32Array;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ICreateTypedArray {
|
interface ICreateTypedArray {
|
||||||
maxValue: number;
|
maxValue: number;
|
||||||
length: number;
|
length: number;
|
||||||
|
|
@ -31,3 +19,15 @@ export function createTypedArray({maxValue, length, from}: ICreateTypedArray) {
|
||||||
if (!from) return new typedArray(length);
|
if (!from) return new typedArray(length);
|
||||||
return typedArray.from(from);
|
return typedArray.from(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTypedArray(maxValue: number) {
|
||||||
|
console.assert(
|
||||||
|
Number.isInteger(maxValue) && maxValue >= 0 && maxValue <= UINT32_MAX,
|
||||||
|
`Array maxValue must be an integer between 0 and ${UINT32_MAX}, got ${maxValue}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (maxValue <= UINT8_MAX) return Uint8Array;
|
||||||
|
if (maxValue <= UINT16_MAX) return Uint16Array;
|
||||||
|
if (maxValue <= UINT32_MAX) return Uint32Array;
|
||||||
|
return Uint32Array;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue