1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 10:11:50 +00:00

Allow specifying minimumGameVersion

This commit is contained in:
tobspr 2022-01-22 09:03:42 +01:00
parent 7741d1590e
commit 1287bc9bf1
23 changed files with 67 additions and 0 deletions

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "add-building-basic",
description: "Shows how to add a new basic building",
minimumGameVersion: "^1.5.0",
};
class MetaDemoModBuilding extends shapez.ModMetaBuilding {

View File

@ -7,6 +7,7 @@ const METADATA = {
id: "add-building-extended",
description:
"Shows how to add a new building with logic, in this case it flips/mirrors shapez from top to down",
minimumGameVersion: "^1.5.0",
};
// Declare a new type of item processor

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "base",
description: "The most basic mod",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "patch-methods",
description: "Shows how to patch existing methods to change the game by making the belts cost shapes",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "class-extensions",
description: "Shows how to extend builtin classes",
minimumGameVersion: "^1.5.0",
};
const BeltExtension = ({ $super, $old }) => ({

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "custom-css",
description: "Shows how to add custom css",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "base",
description: "Displays an indicator on every item processing building when its working",
minimumGameVersion: "^1.5.0",
};
class ItemProcessorStatusGameSystem extends shapez.GameSystem {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "base",
description: "Shows how to add a new keybinding",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "custom-sub-shapes",
description: "Shows how to add custom sub shapes",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "custom-theme",
description: "Shows how to add a custom game theme",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "mod-settings",
description: "Shows how to add settings to your mod",
minimumGameVersion: "^1.5.0",
settings: {
timesLaunched: 0,

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "modify-existing-building",
description: "Shows how to modify an existing building",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "modify-theme",
description: "Shows how to modify builtin themes",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "modify-ui",
description: "Shows how to modify a builtin game state, in this case the main menu",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "new-item-type",
description: "Shows how to add a new item type (fluid)",
minimumGameVersion: "^1.5.0",
};
// Define which fluid types there are

View File

@ -7,6 +7,8 @@ const METADATA = {
id: "notification-blocks",
description:
"Adds a new building to the wires layer, 'Notification Blocks' which show a custom notification when they get a truthy signal.",
minimumGameVersion: "^1.5.0",
};
////////////////////////////////////////////////////////////////////////

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "pasting",
description: "Shows how to properly receive paste events ingame",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "replace-builtin-sprites",
description: "Shows how to replace builtin sprites",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -6,6 +6,7 @@ const METADATA = {
version: "1",
id: "translations",
description: "Shows how to add and modify translations",
minimumGameVersion: "^1.5.0",
};
class Mod extends shapez.Mod {

View File

@ -7,6 +7,8 @@ const METADATA = {
id: "usage-statistics",
description:
"Shows how to add a new component to the game, how to save additional data and how to add custom logic and drawings",
minimumGameVersion: "^1.5.0",
};
/**

View File

@ -56,6 +56,7 @@
"promise-polyfill": "^8.1.0",
"query-string": "^6.8.1",
"rusha": "^0.8.13",
"semver": "^7.3.5",
"serialize-error": "^3.0.0",
"strictdom": "^1.0.1",
"string-replace-webpack-plugin": "^0.1.3",

View File

@ -10,6 +10,9 @@ import { Mod } from "./mod";
import { ModInterface } from "./mod_interface";
import { MOD_SIGNALS } from "./mod_signals";
import semverValidRange from "semver/ranges/valid";
import semverSatisifies from "semver/functions/satisfies";
const LOG = createLogger("mods");
/**
@ -20,6 +23,7 @@ const LOG = createLogger("mods");
* website: string;
* description: string;
* id: string;
* minimumGameVersion?: string;
* settings: []
* }} ModMetadata
*/
@ -158,6 +162,27 @@ export class ModLoader {
const { modClass, meta } = this.modLoadQueue[i];
const modDataFile = "modsettings_" + meta.id + "__" + meta.version + ".json";
if (meta.minimumGameVersion) {
console.warn(meta.minimumGameVersion, G_BUILD_VERSION);
const minimumGameVersion = meta.minimumGameVersion;
if (!semverValidRange(minimumGameVersion)) {
alert("Mod " + meta.id + " has invalid minimumGameVersion: " + minimumGameVersion);
continue;
}
if (!semverSatisifies(G_BUILD_VERSION, minimumGameVersion)) {
alert(
"Mod '" +
meta.id +
"' is incompatible with this version of the game: \n\n" +
"Mod requires version " +
minimumGameVersion +
" but this game has version " +
G_BUILD_VERSION
);
continue;
}
}
let settings = meta.settings;
if (meta.settings) {

View File

@ -5245,6 +5245,13 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"
lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"
lz-string@^1.4.4:
version "1.4.4"
resolved "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz"
@ -7496,6 +7503,13 @@ semver@^7.2.1, semver@^7.3.2:
resolved "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
semver@^7.3.5:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
dependencies:
lru-cache "^6.0.0"
send@0.17.1:
version "0.17.1"
resolved "https://registry.npmjs.org/send/-/send-0.17.1.tgz"
@ -8800,6 +8814,11 @@ yallist@^3.0.2:
resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz"
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yaml-js@^0.1.3:
version "0.1.5"
resolved "https://registry.npmjs.org/yaml-js/-/yaml-js-0.1.5.tgz"