diff --git a/src/scripts/options/about.js b/src/modules/ui/about.ts
similarity index 88%
rename from src/scripts/options/about.js
rename to src/modules/ui/about.ts
index 4db49c01..63fa9e9c 100644
--- a/src/scripts/options/about.js
+++ b/src/modules/ui/about.ts
@@ -1,3 +1,6 @@
+import {link} from "utils/linkUtils";
+import {byId} from "utils/shorthands";
+
// show info about the generator in a popup
export function showAboutDialog() {
const Discord = link("https://discordapp.com/invite/X7E84HU", "Discord");
@@ -11,7 +14,9 @@ export function showAboutDialog() {
const QAA = link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Q&A", "Q&A page");
const VideoTutorial = link("https://youtube.com/playlist?list=PLtgiuDC8iVR2gIG8zMTRn7T_L0arl9h1C", "Video tutorial");
- alertMessage.innerHTML = /* html */ `Fantasy Map Generator (FMG) is a free open-source application. It means that you own all created maps and can use them as
+ byId(
+ "alertMessage"
+ )!.innerHTML = /* html */ `Fantasy Map Generator (FMG) is a free open-source application. It means that you own all created maps and can use them as
you wish.
diff --git a/src/scripts/hotkeys.ts b/src/scripts/hotkeys.ts
index ef947035..39970ccf 100644
--- a/src/scripts/hotkeys.ts
+++ b/src/scripts/hotkeys.ts
@@ -1,7 +1,6 @@
import {openDialog} from "dialogs";
import {toggleLayer} from "layers";
-// @ts-expect-error js module
-import {showAboutDialog} from "scripts/options/about";
+import {showAboutDialog} from "modules/ui/about";
import {byId} from "utils/shorthands";
import {closeDialogs} from "dialogs/utils";
import {minmax} from "utils/numberUtils";
diff --git a/src/scripts/rankCells.js b/src/scripts/rankCells.ts
similarity index 99%
rename from src/scripts/rankCells.js
rename to src/scripts/rankCells.ts
index 37c3f214..b76c7501 100644
--- a/src/scripts/rankCells.js
+++ b/src/scripts/rankCells.ts
@@ -7,6 +7,7 @@ import {normalize} from "utils/numberUtils";
export function rankCells() {
TIME && console.time("rankCells");
const {cells, features} = pack;
+
cells.s = new Int16Array(cells.i.length); // cell suitability array
cells.pop = new Float32Array(cells.i.length); // cell population array
diff --git a/src/types/common.d.ts b/src/types/common.d.ts
index f8a7c118..f5a97eac 100644
--- a/src/types/common.d.ts
+++ b/src/types/common.d.ts
@@ -6,7 +6,8 @@ interface Dict {
[key: string]: T;
}
-type IntArray = Uint8Array | Uint16Array | Uint32Array;
+type UintArray = Uint8Array | Uint16Array | Uint32Array;
+type IntArray = Int8Array | Int16Array | Int32Array;
type RGB = `rgb(${number}, ${number}, ${number})`;
type Hex = `#${string}`;
diff --git a/src/types/grid.d.ts b/src/types/grid.d.ts
index bb4ba37e..82fd30f5 100644
--- a/src/types/grid.d.ts
+++ b/src/types/grid.d.ts
@@ -8,19 +8,19 @@ interface IGrid {
c: number[][];
};
cells: {
- i: IntArray;
- b: IntArray;
+ i: UintArray;
+ b: UintArray;
c: number[][];
v: number[][];
- h: IntArray;
- t: IntArray;
- f: IntArray;
- temp: IntArray;
- prec: IntArray;
+ h: UintArray;
+ t: UintArray;
+ f: UintArray;
+ temp: UintArray;
+ prec: UintArray;
};
- features: IFeature[];
+ features: IGridFeature[];
}
-interface IFeature {
+interface IGridFeature {
i: number;
land: boolean;
border: boolean;
diff --git a/src/types/pack.d.ts b/src/types/pack.d.ts
index d58c54f5..34c48b84 100644
--- a/src/types/pack.d.ts
+++ b/src/types/pack.d.ts
@@ -4,24 +4,26 @@ interface IPack {
v: number[][];
c: number[][];
};
- features: IFeature[];
+ features: TPackFeature[];
cells: {
- i: IntArray;
+ i: UintArray;
p: TPoints;
v: number[][];
c: number[][];
- g: IntArray;
- h: IntArray;
- t: IntArray;
- f: IntArray;
- biome: IntArray;
+ g: UintArray;
+ h: UintArray;
+ t: UintArray;
+ f: UintArray;
+ s: IntArray;
pop: Float32Array;
- area: IntArray;
- state: IntArray;
- culture: IntArray;
- religion: IntArray;
- province: IntArray;
- burg: IntArray;
+ fl: UintArray;
+ biome: UintArray;
+ area: UintArray;
+ state: UintArray;
+ culture: UintArray;
+ religion: UintArray;
+ province: UintArray;
+ burg: UintArray;
q: d3.Quadtree;
};
states: IState[];
@@ -32,11 +34,35 @@ interface IPack {
religions: IReligion[];
}
-interface IFeature {
- i: number;
+interface IPackFeatureBase {
+ i: number; // feature id starting from 1
+ border: boolean; // if touches map border
+ cells: number; // number of cells
+ firstCell: number; // index of the top left cell
+ vertices: number[]; // indexes of perimetric vertices
+}
+
+interface IPackFeatureOcean extends IPackFeatureBase {
+ land: false;
+ type: "ocean";
+ group: "ocean";
+}
+
+interface IPackFeatureIsland extends IPackFeatureBase {
+ land: true;
+ type: "island";
+ group: "continent" | "island" | "isle" | "lake_island";
+}
+
+interface IPackFeatureLake extends IPackFeatureBase {
+ land: false;
+ type: "lake";
+ group: "freshwater" | "salt" | "frozen" | "dry" | "sinkhole" | "lava";
name: string;
}
+type TPackFeature = IPackFeatureOcean | IPackFeatureIsland | IPackFeatureLake;
+
interface IState {
i: number;
name: string;