mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor: interfaces
This commit is contained in:
parent
ff97c9227d
commit
3184a29449
6 changed files with 60 additions and 28 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
import {link} from "utils/linkUtils";
|
||||||
|
import {byId} from "utils/shorthands";
|
||||||
|
|
||||||
// show info about the generator in a popup
|
// show info about the generator in a popup
|
||||||
export function showAboutDialog() {
|
export function showAboutDialog() {
|
||||||
const Discord = link("https://discordapp.com/invite/X7E84HU", "Discord");
|
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 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");
|
const VideoTutorial = link("https://youtube.com/playlist?list=PLtgiuDC8iVR2gIG8zMTRn7T_L0arl9h1C", "Video tutorial");
|
||||||
|
|
||||||
alertMessage.innerHTML = /* html */ `<b>Fantasy Map Generator</b> (FMG) is a free open-source application. It means that you own all created maps and can use them as
|
byId(
|
||||||
|
"alertMessage"
|
||||||
|
)!.innerHTML = /* html */ `<b>Fantasy Map Generator</b> (FMG) is a free open-source application. It means that you own all created maps and can use them as
|
||||||
you wish.
|
you wish.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {openDialog} from "dialogs";
|
import {openDialog} from "dialogs";
|
||||||
import {toggleLayer} from "layers";
|
import {toggleLayer} from "layers";
|
||||||
// @ts-expect-error js module
|
import {showAboutDialog} from "modules/ui/about";
|
||||||
import {showAboutDialog} from "scripts/options/about";
|
|
||||||
import {byId} from "utils/shorthands";
|
import {byId} from "utils/shorthands";
|
||||||
import {closeDialogs} from "dialogs/utils";
|
import {closeDialogs} from "dialogs/utils";
|
||||||
import {minmax} from "utils/numberUtils";
|
import {minmax} from "utils/numberUtils";
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {normalize} from "utils/numberUtils";
|
||||||
export function rankCells() {
|
export function rankCells() {
|
||||||
TIME && console.time("rankCells");
|
TIME && console.time("rankCells");
|
||||||
const {cells, features} = pack;
|
const {cells, features} = pack;
|
||||||
|
|
||||||
cells.s = new Int16Array(cells.i.length); // cell suitability array
|
cells.s = new Int16Array(cells.i.length); // cell suitability array
|
||||||
cells.pop = new Float32Array(cells.i.length); // cell population array
|
cells.pop = new Float32Array(cells.i.length); // cell population array
|
||||||
|
|
||||||
3
src/types/common.d.ts
vendored
3
src/types/common.d.ts
vendored
|
|
@ -6,7 +6,8 @@ interface Dict<T> {
|
||||||
[key: string]: T;
|
[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 RGB = `rgb(${number}, ${number}, ${number})`;
|
||||||
type Hex = `#${string}`;
|
type Hex = `#${string}`;
|
||||||
|
|
|
||||||
18
src/types/grid.d.ts
vendored
18
src/types/grid.d.ts
vendored
|
|
@ -8,19 +8,19 @@ interface IGrid {
|
||||||
c: number[][];
|
c: number[][];
|
||||||
};
|
};
|
||||||
cells: {
|
cells: {
|
||||||
i: IntArray;
|
i: UintArray;
|
||||||
b: IntArray;
|
b: UintArray;
|
||||||
c: number[][];
|
c: number[][];
|
||||||
v: number[][];
|
v: number[][];
|
||||||
h: IntArray;
|
h: UintArray;
|
||||||
t: IntArray;
|
t: UintArray;
|
||||||
f: IntArray;
|
f: UintArray;
|
||||||
temp: IntArray;
|
temp: UintArray;
|
||||||
prec: IntArray;
|
prec: UintArray;
|
||||||
};
|
};
|
||||||
features: IFeature[];
|
features: IGridFeature[];
|
||||||
}
|
}
|
||||||
interface IFeature {
|
interface IGridFeature {
|
||||||
i: number;
|
i: number;
|
||||||
land: boolean;
|
land: boolean;
|
||||||
border: boolean;
|
border: boolean;
|
||||||
|
|
|
||||||
56
src/types/pack.d.ts
vendored
56
src/types/pack.d.ts
vendored
|
|
@ -4,24 +4,26 @@ interface IPack {
|
||||||
v: number[][];
|
v: number[][];
|
||||||
c: number[][];
|
c: number[][];
|
||||||
};
|
};
|
||||||
features: IFeature[];
|
features: TPackFeature[];
|
||||||
cells: {
|
cells: {
|
||||||
i: IntArray;
|
i: UintArray;
|
||||||
p: TPoints;
|
p: TPoints;
|
||||||
v: number[][];
|
v: number[][];
|
||||||
c: number[][];
|
c: number[][];
|
||||||
g: IntArray;
|
g: UintArray;
|
||||||
h: IntArray;
|
h: UintArray;
|
||||||
t: IntArray;
|
t: UintArray;
|
||||||
f: IntArray;
|
f: UintArray;
|
||||||
biome: IntArray;
|
s: IntArray;
|
||||||
pop: Float32Array;
|
pop: Float32Array;
|
||||||
area: IntArray;
|
fl: UintArray;
|
||||||
state: IntArray;
|
biome: UintArray;
|
||||||
culture: IntArray;
|
area: UintArray;
|
||||||
religion: IntArray;
|
state: UintArray;
|
||||||
province: IntArray;
|
culture: UintArray;
|
||||||
burg: IntArray;
|
religion: UintArray;
|
||||||
|
province: UintArray;
|
||||||
|
burg: UintArray;
|
||||||
q: d3.Quadtree<number[]>;
|
q: d3.Quadtree<number[]>;
|
||||||
};
|
};
|
||||||
states: IState[];
|
states: IState[];
|
||||||
|
|
@ -32,11 +34,35 @@ interface IPack {
|
||||||
religions: IReligion[];
|
religions: IReligion[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IFeature {
|
interface IPackFeatureBase {
|
||||||
i: number;
|
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;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TPackFeature = IPackFeatureOcean | IPackFeatureIsland | IPackFeatureLake;
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
i: number;
|
i: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue