mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor(es modules): migrate numberUtils
This commit is contained in:
parent
b425a9daf6
commit
ad252b54e6
63 changed files with 97 additions and 56 deletions
|
|
@ -1,4 +1,6 @@
|
|||
window.handleZoom = function (isScaleChanged, isPositionChanged) {
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function handleZoom(isScaleChanged, isPositionChanged) {
|
||||
viewbox.attr("transform", `translate(${viewX} ${viewY}) scale(${scale})`);
|
||||
|
||||
if (isPositionChanged) drawCoordinates();
|
||||
|
|
@ -21,7 +23,7 @@ window.handleZoom = function (isScaleChanged, isPositionChanged) {
|
|||
ctx.setTransform(scale, 0, 0, scale, viewX, viewY);
|
||||
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// active zooming feature
|
||||
export function invokeActiveZooming() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {TIME} from "/src/config/logging";
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {layerIsOn} from "./ui/layers";
|
||||
import {getColors, getRandomColor, getMixedColor} from "/src/utils/colorUtils";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
window.BurgsAndStates = (function () {
|
||||
const generate = function () {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {TIME} from "/src/config/logging";
|
||||
import {getColors} from "/src/utils/colorUtils";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
window.Cultures = (function () {
|
||||
let cells;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// update old .map version to the current one
|
||||
export function resolveVersionConflicts(version) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
const $body = insertEditorHtml();
|
||||
addListeners();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
const $body = insertEditorHtml();
|
||||
addListeners();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
|||
import {byId} from "/src/utils/shorthands";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {getRandomColor, getMixedColor} from "/src/utils/colorUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
const $body = insertEditorHtml();
|
||||
addListeners();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {rollups} from "../../../utils/functionUtils.js";
|
|||
import {isWater} from "/src/utils/graphUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
const entitiesMap = {
|
||||
states: {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {getGridPolygon} from "/src/utils/graphUtils";
|
||||
import {unique} from "/src/utils/arrayUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// download map as SVG
|
||||
async function saveSVG() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {calculateVoronoi, findCell} from "/src/utils/graphUtils";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
function quickLoad() {
|
||||
ldb.get("lastMap", blob => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// functions to save project as .map file
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.Lakes = (function () {
|
||||
const setClimateData = function (h) {
|
||||
const cells = pack.cells;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {TIME} from "/src/config/logging";
|
||||
import {getFriendlyHeight} from "./ui/general";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.Markers = (function () {
|
||||
let config = [];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {TIME} from "/src/config/logging";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
window.Military = (function () {
|
||||
const generate = function () {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {TIME} from "/src/config/logging";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.OceanLayers = (function () {
|
||||
let cells, vertices, pointsN, used;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
window.ReliefIcons = (function () {
|
||||
const ReliefIcons = function () {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {TIME} from "/src/config/logging";
|
|||
import {findAll} from "/src/utils/graphUtils";
|
||||
import {unique} from "/src/utils/arrayUtils";
|
||||
import {getRandomColor, getMixedColor} from "/src/utils/colorUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.Religions = (function () {
|
||||
// name generation approach and relative chance to be selected
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {TIME} from "/src/config/logging";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.Rivers = (function () {
|
||||
const generate = function (allowErosion = true) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.Submap = (function () {
|
||||
const isWater = (pack, id) => pack.cells.h[id] < 20;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
window.ThreeD = (function () {
|
||||
const options = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
export class Battle {
|
||||
constructor(attacker, defender) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {getRandomColor} from "/src/utils/colorUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editBiomes() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editBurg(id) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {restoreDefaultEvents} from "/src/scripts/events";
|
||||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function overviewBurgs() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editCoastline(node = d3.event.target) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn, minmax, normalize} from "/src/utils/numberUtils";
|
||||
|
||||
// clear elSelected variable
|
||||
export function unselect() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function showEPForRoute(node) {
|
||||
const points = [];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {clearMainTip} from "/src/scripts/tooltips";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editEmblem(type, id, el) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {findCell, findGridCell} from "/src/utils/graphUtils";
|
||||
import {MOBILE} from "/src/constants";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// fit full-screen map if window is resized
|
||||
window.addEventListener("resize", function (e) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {findGridCell, findGridAll, findCell, getPackPolygon, getGridPolygon} fro
|
|||
import {last, createTypedArray} from "/src/utils/arrayUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {rn, minmax, lim} from "/src/utils/numberUtils";
|
||||
|
||||
export function editHeightmap(options) {
|
||||
const {mode, tool} = options || {};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {findGridCell, getGridPolygon} from "/src/utils/graphUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editIce() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {getPackPolygon} from "/src/utils/graphUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editLake() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {last} from "/src/utils/arrayUtils";
|
|||
import {stored, store} from "/src/utils/shorthands";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {byId} from "/src/utils/shorthands";
|
||||
import {rn, minmax, normalize} from "/src/utils/numberUtils";
|
||||
|
||||
let presets = {};
|
||||
restoreCustomPresets(); // run on-load
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {restoreDefaultEvents} from "/src/scripts/events";
|
||||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editMarker(markerI) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function overviewMilitary() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {unique} from "/src/utils/arrayUtils";
|
||||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editNamesbase() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {last} from "/src/utils/arrayUtils";
|
|||
import {lock, locked} from "/src/scripts/options/lock";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {byId, stored} from "/src/utils/shorthands";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
$("#optionsContainer").draggable({handle: ".drag-trigger", snap: "svg", snapMode: "both"});
|
||||
$("#exitCustomization").draggable({handle: "div"});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {findAll, findCell, getPackPolygon, isLand} from "/src/utils/graphUtils";
|
|||
import {unique} from "/src/utils/arrayUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {getRandomColor} from "/src/utils/colorUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editProvinces() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editRegiment(selector) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function overviewRegiments(state) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {restoreDefaultEvents} from "/src/scripts/events";
|
||||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editReliefIcon() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {getPackPolygon, findCell} from "/src/utils/graphUtils";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function createRiver() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {findCell, getPackPolygon} from "/src/utils/graphUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editRiver(id) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"use strict";
|
||||
function overviewRivers() {
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function overviewRivers() {
|
||||
if (customization) return;
|
||||
closeDialogs("#riversOverview, .stable");
|
||||
if (!layerIsOn("toggleRivers")) toggleRivers();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editRoute(onClick) {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// add available filters to lists
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {byId} from "/src/utils/shorthands";
|
||||
import {clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn, minmax} from "/src/utils/numberUtils";
|
||||
|
||||
window.UISubmap = (function () {
|
||||
byId("submapPointsInput").addEventListener("input", function () {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function showBurgTemperatureGraph(id) {
|
||||
const b = pack.burgs[id];
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findCell} from "/src/utils/graphUtils";
|
||||
import {last} from "/src/utils/arrayUtils";
|
||||
import {tip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
// module to control the Tools options (click to edit, to re-geenerate, tp add)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {tip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editWorld() {
|
||||
if (customization) return;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {restoreDefaultEvents} from "/src/scripts/events";
|
|||
import {findAll, findCell, getPackPolygon} from "/src/utils/graphUtils";
|
||||
import {unique} from "/src/utils/arrayUtils";
|
||||
import {tip, showMainTip, clearMainTip} from "/src/scripts/tooltips";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
|
||||
export function editZones() {
|
||||
closeDialogs();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue