mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Merge branch 'master' into react-to-drag-and-drop
This commit is contained in:
commit
b6113a1007
23 files changed
+252
-48
No files matched your search
@@ -3,7 +3,7 @@
|
||||
"description": "Implementation of Clusterio controller",
|
||||
"author": "Hornwitser",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build && webpack-cli --env production",
|
||||
@@ -19,7 +19,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clusterio/lib": "^2.0.0-alpha.17",
|
||||
"@clusterio/lib": "^2.0.0-alpha.18",
|
||||
"@sinclair/typebox": "^0.30.4",
|
||||
"busboy": "^1.6.0",
|
||||
"compression": "^1.7.4",
|
||||
@@ -36,7 +36,7 @@
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@clusterio/web_ui": "^2.0.0-alpha.17",
|
||||
"@clusterio/web_ui": "^2.0.0-alpha.18",
|
||||
"@swc/core": "^1.4.0",
|
||||
"@types/busboy": "^1.5.0",
|
||||
"@types/compression": "^1.7.2",
|
||||
|
||||
@@ -108,7 +108,7 @@ async function safeOutputFile(file, data, options={}) {
|
||||
async function execFile(cmd, args) {
|
||||
logger.verbose(`executing ${cmd} ${args.join(" ")}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
let child = child_process.execFile(cmd, args, (err, stdout, stderr) => {
|
||||
let child = child_process.execFile(cmd, args, { shell: true }, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Installer for clusterio",
|
||||
"author": "Hornwitser",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"main": "create.js",
|
||||
"bin": {
|
||||
"clusteriocreate": "./create.js"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Clusterio command line management tool",
|
||||
"author": "Hornwitser",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build",
|
||||
@@ -19,7 +19,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clusterio/lib": "^2.0.0-alpha.17",
|
||||
"@clusterio/lib": "^2.0.0-alpha.18",
|
||||
"as-table": "^1.0.55",
|
||||
"fs-extra": "^11.1.1",
|
||||
"phin": "^3.7.0",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Implementation of Clusterio host server",
|
||||
"author": "Hornwitser",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build",
|
||||
@@ -19,7 +19,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clusterio/lib": "^2.0.0-alpha.17",
|
||||
"@clusterio/lib": "^2.0.0-alpha.18",
|
||||
"@sinclair/typebox": "^0.30.4",
|
||||
"fs-extra": "^11.1.1",
|
||||
"jimp": "^0.22.8",
|
||||
|
||||
@@ -77,9 +77,16 @@ export class SaveModule {
|
||||
|
||||
static async fromSave(json: Static<typeof SaveModule.jsonSchema>, root: JSZip) {
|
||||
const module = new this(lib.ModuleInfo.fromJSON(json));
|
||||
module.files = new Map(
|
||||
await Promise.all(json.files.map(async f => [f, await root.file(f)!.async("nodebuffer")] as const))
|
||||
);
|
||||
module.files = new Map(await Promise.all(json.files
|
||||
.map(filename => ({filename, file: root.file(filename)}))
|
||||
.filter(({filename, file}) => {
|
||||
if (file === null) {
|
||||
lib.logger.warn(`Missing file ${filename} in save`);
|
||||
}
|
||||
return file !== null;
|
||||
})
|
||||
.map(async ({filename, file}) => [filename, await file!.async("nodebuffer")] as const)
|
||||
));
|
||||
return module;
|
||||
}
|
||||
|
||||
@@ -395,8 +402,11 @@ export async function patch(savePath: string, modules: SaveModule[]) {
|
||||
}
|
||||
} else {
|
||||
for (let module of patchInfo.modules) {
|
||||
for (let file of module.files.keys()) {
|
||||
zip.remove(root.file(file)!.name);
|
||||
for (let filepath of module.files.keys()) {
|
||||
const file = root.file(filepath);
|
||||
if (file !== null) {
|
||||
zip.remove(file.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
patchInfo.modules = [];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@clusterio/lib",
|
||||
"description": "Shared library for Clusterio",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"repository": "https://github.com/clusterio/clusterio",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -334,10 +334,11 @@ export default class ModPack {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in missing settings with their default values
|
||||
* Fill in missing and incorrect settings with their default values
|
||||
*
|
||||
* Uses the provided setting prototypes to add any missing mod settings
|
||||
* in the mod pack with the default value from the prototype.
|
||||
* Uses the provided setting prototypes to correct any missing and or
|
||||
* incorrect mod settings in the mod pack with the default value from
|
||||
* the prototype.
|
||||
*
|
||||
* @param settingPrototypes -
|
||||
* Setting prototypes exported from the game.
|
||||
@@ -360,13 +361,20 @@ export default class ModPack {
|
||||
logger.warn(`Ignoring ${prototype.name} with missing default_value`);
|
||||
continue;
|
||||
}
|
||||
if (this.settings[settingType].get(prototype.name)) {
|
||||
continue;
|
||||
let value = this.settings[settingType].get(prototype.name)?.value ?? prototype.default_value;
|
||||
const type = prototype.type;
|
||||
if (
|
||||
type === "bool-setting" && typeof value !== "boolean"
|
||||
|| type === "color-setting" && typeof value !== "object"
|
||||
|| (type === "int-setting" || type === "double-setting") && typeof value !== "number"
|
||||
) {
|
||||
value = prototype.default_value;
|
||||
}
|
||||
|
||||
let value = prototype.default_value;
|
||||
if (prototype.type === "color-setting") {
|
||||
value = libLuaTools.normalizeColor(value);
|
||||
if (type === "string-setting" && typeof value !== "string") {
|
||||
value = typeof value === "object" ? prototype.default_value : String(value ?? "");
|
||||
}
|
||||
if (type === "color-setting") {
|
||||
value = libLuaTools.normalizeColor(value as object);
|
||||
}
|
||||
this.settings[settingType].set(prototype.name, { value });
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Clusterio web interface implementation",
|
||||
"author": "Hornwitser",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-alpha.17",
|
||||
"version": "2.0.0-alpha.18",
|
||||
"browser": "src/index.ts",
|
||||
"main": "dist/browser/src/index.js",
|
||||
"scripts": {
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.1.4",
|
||||
"@clusterio/lib": "^2.0.0-alpha.17",
|
||||
"@clusterio/lib": "^2.0.0-alpha.18",
|
||||
"@swc/core": "^1.4.0",
|
||||
"antd": "^5.13.0",
|
||||
"assert": "^2.0.0",
|
||||
|
||||
@@ -424,7 +424,15 @@ function InputColor(props: {
|
||||
value: lib.ModSettingColor,
|
||||
onChange: (value: lib.ModSettingColor) => void,
|
||||
}) {
|
||||
const value = props.value;
|
||||
// In certain edge cases it's possible a value for this mod setting does not exist
|
||||
// or is of the wrong type. Fallback to black if this is the case.
|
||||
function isColor(input: unknown) {
|
||||
if (typeof input !== "object" || input === null) {
|
||||
return false;
|
||||
}
|
||||
return "r" in input && "g" in input && "b" in input && "a" in input;
|
||||
}
|
||||
const value = isColor(props.value) ? props.value : { r: 0, g: 0, b: 0, a: 1 };
|
||||
return <ColorPicker
|
||||
defaultFormat="rgb"
|
||||
defaultValue={`rgba(${value.r * 255}, ${value.g * 255}, ${value.b * 255}, ${value.a}`}
|
||||
@@ -774,7 +782,7 @@ export default function ModPackViewPage() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (modifiedModPack!.settings[scope].get(settingName)!.value !== value) {
|
||||
if (modifiedModPack!.settings[scope].get(settingName)?.value !== value) {
|
||||
pushChange({ type: "settings.set", scope, name: settingName, value: { value }});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user