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
|
||||
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 */ `<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.
|
||||
|
||||
<p>
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
3
src/types/common.d.ts
vendored
3
src/types/common.d.ts
vendored
|
|
@ -6,7 +6,8 @@ interface Dict<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 Hex = `#${string}`;
|
||||
|
|
|
|||
18
src/types/grid.d.ts
vendored
18
src/types/grid.d.ts
vendored
|
|
@ -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;
|
||||
|
|
|
|||
56
src/types/pack.d.ts
vendored
56
src/types/pack.d.ts
vendored
|
|
@ -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<number[]>;
|
||||
};
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue