2020-07-31 17:11:44 +02:00
|
|
|
import {LayerDefinition} from "./LayerDefinition";
|
|
|
|
import {Layout} from "./Layout";
|
2020-08-30 01:13:18 +02:00
|
|
|
import {FromJSON} from "./JSON/FromJSON";
|
2020-08-22 02:12:46 +02:00
|
|
|
import * as bookcases from "../assets/themes/bookcases/Bookcases.json";
|
|
|
|
import * as aed from "../assets/themes/aed/aed.json";
|
2020-08-22 16:00:33 +02:00
|
|
|
import * as toilets from "../assets/themes/toilets/toilets.json";
|
2020-08-25 02:12:26 +02:00
|
|
|
import * as artworks from "../assets/themes/artwork/artwork.json";
|
2020-08-27 18:44:16 +02:00
|
|
|
import * as cyclestreets from "../assets/themes/cyclestreets/cyclestreets.json";
|
2020-08-31 02:59:47 +02:00
|
|
|
import * as ghostbikes from "../assets/themes/ghostbikes/ghostbikes.json"
|
2020-09-17 13:13:02 +02:00
|
|
|
import * as cyclofix from "../assets/themes/cyclofix/cyclofix.json"
|
|
|
|
import * as buurtnatuur from "../assets/themes/buurtnatuur/buurtnatuur.json"
|
2020-09-19 13:37:04 +02:00
|
|
|
import * as nature from "../assets/themes/nature/nature.json"
|
|
|
|
import * as maps from "../assets/themes/maps/maps.json"
|
2020-08-26 15:36:04 +02:00
|
|
|
import {PersonalLayout} from "../Logic/PersonalLayout";
|
2020-09-20 23:01:08 +02:00
|
|
|
import {StreetWidth} from "./StreetWidth/StreetWidth";
|
2020-07-05 18:59:47 +02:00
|
|
|
|
|
|
|
export class AllKnownLayouts {
|
|
|
|
|
2020-07-31 04:58:58 +02:00
|
|
|
public static allLayers: Map<string, LayerDefinition> = undefined;
|
2020-08-31 02:59:47 +02:00
|
|
|
|
2020-09-17 13:13:02 +02:00
|
|
|
private static GenerateCycloFix(): Layout {
|
|
|
|
const layout = FromJSON.LayoutFromJSON(cyclofix)
|
|
|
|
const now = new Date();
|
|
|
|
const m = now.getMonth() + 1;
|
|
|
|
const day = new Date().getDay() + 1;
|
|
|
|
const date = day + "/" + m;
|
|
|
|
if (date === "31/10" || date === "1/11" || date === "2/11") {
|
|
|
|
// Around Halloween/Fiesta de muerte/Allerzielen, we remember the dead
|
|
|
|
layout.layers.push(
|
|
|
|
FromJSON.sharedLayers.get("ghost_bike")
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
return layout;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static GenerateBuurtNatuur(): Layout {
|
|
|
|
const layout = FromJSON.LayoutFromJSON(buurtnatuur);
|
|
|
|
layout.enableMoreQuests = false;
|
|
|
|
layout.enableShareScreen = false;
|
2020-09-20 23:01:08 +02:00
|
|
|
layout.hideFromOverview = true;
|
2020-09-17 13:13:02 +02:00
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2020-07-31 04:58:58 +02:00
|
|
|
public static layoutsList: Layout[] = [
|
2020-08-26 15:36:04 +02:00
|
|
|
new PersonalLayout(),
|
2020-09-20 23:01:08 +02:00
|
|
|
|
2020-08-30 01:13:18 +02:00
|
|
|
FromJSON.LayoutFromJSON(bookcases),
|
2020-08-31 02:59:47 +02:00
|
|
|
FromJSON.LayoutFromJSON(aed),
|
|
|
|
FromJSON.LayoutFromJSON(toilets),
|
|
|
|
FromJSON.LayoutFromJSON(artworks),
|
2020-09-20 23:01:08 +02:00
|
|
|
AllKnownLayouts.GenerateCycloFix(),
|
2020-08-31 02:59:47 +02:00
|
|
|
FromJSON.LayoutFromJSON(ghostbikes),
|
2020-09-19 13:37:04 +02:00
|
|
|
FromJSON.LayoutFromJSON(nature),
|
2020-09-20 23:01:08 +02:00
|
|
|
FromJSON.LayoutFromJSON(cyclestreets),
|
2020-09-19 13:37:04 +02:00
|
|
|
FromJSON.LayoutFromJSON(maps),
|
2020-09-20 23:01:08 +02:00
|
|
|
AllKnownLayouts.GenerateBuurtNatuur(),
|
2020-09-17 13:13:02 +02:00
|
|
|
|
2020-09-20 23:01:08 +02:00
|
|
|
new StreetWidth(), // The ugly duckling
|
2020-07-31 04:58:58 +02:00
|
|
|
];
|
2020-09-17 13:13:02 +02:00
|
|
|
|
2020-07-31 04:58:58 +02:00
|
|
|
|
|
|
|
public static allSets: Map<string, Layout> = AllKnownLayouts.AllLayouts();
|
2020-07-25 01:07:02 +02:00
|
|
|
|
2020-07-31 04:58:58 +02:00
|
|
|
private static AllLayouts(): Map<string, Layout> {
|
|
|
|
this.allLayers = new Map<string, LayerDefinition>();
|
|
|
|
for (const layout of this.layoutsList) {
|
2020-08-31 02:59:47 +02:00
|
|
|
for (let i = 0; i < layout.layers.length; i++) {
|
|
|
|
let layer = layout.layers[i];
|
|
|
|
if (typeof (layer) === "string") {
|
|
|
|
layer = layout.layers[i] = FromJSON.sharedLayers.get(layer);
|
2020-09-11 02:14:16 +02:00
|
|
|
if(layer === undefined){
|
|
|
|
console.log("Defined layers are ", FromJSON.sharedLayers.keys())
|
|
|
|
throw `Layer ${layer} was not found or defined - probably a type was made`
|
|
|
|
}
|
2020-08-31 02:59:47 +02:00
|
|
|
}
|
|
|
|
|
2020-07-31 04:58:58 +02:00
|
|
|
if (this.allLayers[layer.id] !== undefined) {
|
2020-07-25 01:07:02 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-07-31 04:58:58 +02:00
|
|
|
this.allLayers[layer.id] = layer;
|
2020-08-28 03:16:21 +02:00
|
|
|
this.allLayers[layer.id.toLowerCase()] = layer;
|
2020-07-25 01:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-20 12:39:43 +02:00
|
|
|
const allSets: Map<string, Layout> = new Map();
|
2020-07-31 04:58:58 +02:00
|
|
|
for (const layout of this.layoutsList) {
|
2020-08-30 01:13:18 +02:00
|
|
|
allSets[layout.id] = layout;
|
|
|
|
allSets[layout.id.toLowerCase()] = layout;
|
2020-07-05 18:59:47 +02:00
|
|
|
}
|
|
|
|
return allSets;
|
|
|
|
}
|
2020-07-15 15:55:08 +02:00
|
|
|
|
2020-07-05 18:59:47 +02:00
|
|
|
}
|