diff --git a/.gitignore b/.gitignore index a0e08a62..f7557646 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ res_built gulp/runnable-texturepacker.jar tmp_standalone_files +tmp_standalone_files_china # Local config config.local.js diff --git a/gulp/css.js b/gulp/css.js index 2b51f153..46e44247 100644 --- a/gulp/css.js +++ b/gulp/css.js @@ -21,7 +21,6 @@ function gulptasksCSS($, gulp, buildFolder, browserSync) { const plugins = [postcssAssetsPlugin(cachebust)]; if (prod) { plugins.unshift( - $.postcssUnprefix(), $.postcssPresetEnv({ browsers: ["> 0.1%"], }) diff --git a/gulp/gulpfile.js b/gulp/gulpfile.js index 7b0416ca..f2f4174e 100644 --- a/gulp/gulpfile.js +++ b/gulp/gulpfile.js @@ -136,7 +136,7 @@ gulp.task("main.webserver", () => { ); }); -function serve({ standalone }) { +function serve({ standalone, chineseVersion = false }) { browserSync.init({ server: buildFolder, port: 3005, @@ -200,7 +200,11 @@ function serve({ standalone }) { if (standalone) { gulp.series("js.standalone-dev.watch")(() => true); } else { - gulp.series("js.dev.watch")(() => true); + if (chineseVersion) { + gulp.series("china.js.dev.watch")(() => true); + } else { + gulp.series("js.dev.watch")(() => true); + } } } @@ -284,30 +288,28 @@ gulp.task( ); // Builds everything (standalone-prod) -gulp.task( - "step.standalone-prod.code", - gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "js.standalone-prod") -); -gulp.task("step.standalone-prod.mainbuild", gulp.parallel("step.baseResources", "step.standalone-prod.code")); -gulp.task( - "step.standalone-prod.all", - gulp.series("step.standalone-prod.mainbuild", "css.prod-standalone", "html.standalone-prod") -); -gulp.task( - "build.standalone-prod", - gulp.series("utils.cleanup", "step.standalone-prod.all", "step.postbuild") -); -// OS X build and release upload -gulp.task( - "build.darwin64-prod", - gulp.series( - "build.standalone-prod", - "standalone.prepare", - "standalone.package.prod.darwin64", - "standalone.uploadRelease.darwin64" - ) -); +for (const prefix of ["", "china."]) { + gulp.task( + prefix + "step.standalone-prod.code", + gulp.series("sounds.fullbuildHQ", "translations.fullBuild", prefix + "js.standalone-prod") + ); + + gulp.task( + prefix + "step.standalone-prod.mainbuild", + gulp.parallel("step.baseResources", prefix + "step.standalone-prod.code") + ); + + gulp.task( + prefix + "step.standalone-prod.all", + gulp.series(prefix + "step.standalone-prod.mainbuild", "css.prod-standalone", "html.standalone-prod") + ); + + gulp.task( + prefix + "build.standalone-prod", + gulp.series("utils.cleanup", prefix + "step.standalone-prod.all", "step.postbuild") + ); +} // Deploying! gulp.task( @@ -320,7 +322,12 @@ gulp.task( ); gulp.task("main.deploy.prod", gulp.series("utils.requireCleanWorkingTree", "build.prod", "ftp.upload.prod")); gulp.task("main.deploy.all", gulp.series("main.deploy.staging", "main.deploy.prod")); -gulp.task("main.standalone", gulp.series("build.standalone-prod", "standalone.package.prod")); +gulp.task("regular.main.standalone", gulp.series("build.standalone-prod", "standalone.package.prod")); +gulp.task( + "china.main.standalone", + gulp.series("china.build.standalone-prod", "china.standalone.package.prod") +); +gulp.task("standalone.all", gulp.series("regular.main.standalone", "china.main.standalone")); // Live-development gulp.task( @@ -331,5 +338,9 @@ gulp.task( "main.serveStandalone", gulp.series("build.standalone.dev", () => serve({ standalone: true })) ); +gulp.task( + "china.main.serveDev", + gulp.series("build.dev", () => serve({ standalone: false, chineseVersion: true })) +); gulp.task("default", gulp.series("main.serveDev")); diff --git a/gulp/js.js b/gulp/js.js index 28c037bd..cfaedb8c 100644 --- a/gulp/js.js +++ b/gulp/js.js @@ -6,7 +6,6 @@ function requireUncached(module) { } function gulptasksJS($, gulp, buildFolder, browserSync) { - //// DEV gulp.task("js.dev.watch", () => { @@ -30,6 +29,36 @@ function gulptasksJS($, gulp, buildFolder, browserSync) { .pipe(gulp.dest(buildFolder)); }); + //// DEV CHINA + + gulp.task("china.js.dev.watch", () => { + return gulp + .src("../src/js/main.js") + .pipe( + $.webpackStream( + requireUncached("./webpack.config.js")({ + watch: true, + chineseVersion: true, + }) + ) + ) + .pipe(gulp.dest(buildFolder)) + .pipe(browserSync.stream()); + }); + + gulp.task("china.js.dev", () => { + return gulp + .src("../src/js/main.js") + .pipe( + $.webpackStream( + requireUncached("./webpack.config.js")({ + chineseVersion: true, + }) + ) + ) + .pipe(gulp.dest(buildFolder)); + }); + //// STAGING gulp.task("js.staging.transpiled", () => { @@ -162,6 +191,23 @@ function gulptasksJS($, gulp, buildFolder, browserSync) { ) .pipe(gulp.dest(buildFolder)); }); + + gulp.task("china.js.standalone-prod", () => { + return gulp + .src("../src/js/main.js") + .pipe( + $.webpackStream( + requireUncached("./webpack.production.config.js")({ + enableAssert: false, + environment: "prod", + es6: true, + standalone: true, + chineseVersion: true, + }) + ) + ) + .pipe(gulp.dest(buildFolder)); + }); } module.exports = { diff --git a/gulp/package.json b/gulp/package.json index 28a83253..0e1052b1 100644 --- a/gulp/package.json +++ b/gulp/package.json @@ -34,6 +34,7 @@ "fastdom": "^1.0.9", "flatted": "^2.0.1", "fs-extra": "^8.1.0", + "gifsicle": "^5.2.0", "gulp-audiosprite": "^1.1.0", "howler": "^2.1.2", "html-loader": "^0.5.5", diff --git a/gulp/standalone.js b/gulp/standalone.js index 8d247672..21c64595 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -10,226 +10,168 @@ const execSync = require("child_process").execSync; function gulptasksStandalone($, gulp) { const electronBaseDir = path.join(__dirname, "..", "electron"); - const tempDestDir = path.join(__dirname, "..", "tmp_standalone_files"); - const tempDestBuildDir = path.join(tempDestDir, "built"); - - gulp.task("standalone.prepare.cleanup", () => { - return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true })); - }); - - gulp.task("standalone.prepare.copyPrefab", () => { - // const requiredFiles = $.glob.sync("../electron/"); - const requiredFiles = [ - path.join(electronBaseDir, "lib", "**", "*.node"), - path.join(electronBaseDir, "node_modules", "**", "*.*"), - path.join(electronBaseDir, "node_modules", "**", ".*"), - path.join(electronBaseDir, "favicon*"), - - // fails on platforms which support symlinks - // https://github.com/gulpjs/gulp/issues/1427 - // path.join(electronBaseDir, "node_modules", "**", "*"), - ]; - return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir)); - }); - - gulp.task("standalone.prepare.writePackageJson", cb => { - fs.writeFileSync( - path.join(tempDestBuildDir, "package.json"), - JSON.stringify( - { - devDependencies: { - electron: "6.1.12", + for (const { tempDestDir, suffix, taskPrefix } of [ + { tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"), suffix: "", taskPrefix: "" }, + { + tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"), + suffix: "china", + taskPrefix: "china.", + }, + ]) { + const tempDestBuildDir = path.join(tempDestDir, "built"); + + gulp.task(taskPrefix + "standalone.prepare.cleanup", () => { + return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true })); + }); + + gulp.task(taskPrefix + "standalone.prepare.copyPrefab", () => { + // const requiredFiles = $.glob.sync("../electron/"); + const requiredFiles = [ + path.join(electronBaseDir, "lib", "**", "*.node"), + path.join(electronBaseDir, "node_modules", "**", "*.*"), + path.join(electronBaseDir, "node_modules", "**", ".*"), + path.join(electronBaseDir, "favicon*"), + + // fails on platforms which support symlinks + // https://github.com/gulpjs/gulp/issues/1427 + // path.join(electronBaseDir, "node_modules", "**", "*"), + ]; + return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir)); + }); + + gulp.task(taskPrefix + "standalone.prepare.writePackageJson", cb => { + fs.writeFileSync( + path.join(tempDestBuildDir, "package.json"), + JSON.stringify( + { + devDependencies: { + electron: "6.1.12", + }, }, - }, - null, - 4 + null, + 4 + ) + ); + cb(); + }); + + gulp.task(taskPrefix + "standalone.prepareVDF", cb => { + const hash = buildutils.getRevision(); + + const steampipeDir = path.join(__dirname, "steampipe", "scripts"); + const templateContents = fs + .readFileSync(path.join(steampipeDir, "app.vdf.template"), { encoding: "utf-8" }) + .toString(); + + const convertedContents = templateContents.replace("$DESC$", "Commit " + hash); + fs.writeFileSync(path.join(steampipeDir, "app.vdf"), convertedContents); + + cb(); + }); + + gulp.task(taskPrefix + "standalone.prepare.minifyCode", () => { + return gulp.src(path.join(electronBaseDir, "*.js")).pipe(gulp.dest(tempDestBuildDir)); + }); + + gulp.task(taskPrefix + "standalone.prepare.copyGamefiles", () => { + return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir)); + }); + + gulp.task(taskPrefix + "standalone.killRunningInstances", cb => { + try { + execSync("taskkill /F /IM shapezio.exe"); + } catch (ex) { + console.warn("Failed to kill running instances, maybe none are up."); + } + cb(); + }); + + gulp.task( + taskPrefix + "standalone.prepare", + gulp.series( + taskPrefix + "standalone.killRunningInstances", + taskPrefix + "standalone.prepare.cleanup", + taskPrefix + "standalone.prepare.copyPrefab", + taskPrefix + "standalone.prepare.writePackageJson", + taskPrefix + "standalone.prepare.minifyCode", + taskPrefix + "standalone.prepare.copyGamefiles" ) ); - cb(); - }); - - gulp.task("standalone.prepareVDF", cb => { - const hash = buildutils.getRevision(); - - const steampipeDir = path.join(__dirname, "steampipe", "scripts"); - const templateContents = fs - .readFileSync(path.join(steampipeDir, "app.vdf.template"), { encoding: "utf-8" }) - .toString(); - - const convertedContents = templateContents.replace("$DESC$", "Commit " + hash); - fs.writeFileSync(path.join(steampipeDir, "app.vdf"), convertedContents); - - cb(); - }); - - gulp.task("standalone.prepare.minifyCode", () => { - return gulp.src(path.join(electronBaseDir, "*.js")).pipe(gulp.dest(tempDestBuildDir)); - }); - gulp.task("standalone.prepare.copyGamefiles", () => { - return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir)); - }); - - gulp.task("standalone.killRunningInstances", cb => { - try { - execSync("taskkill /F /IM shapezio.exe"); - } catch (ex) { - console.warn("Failed to kill running instances, maybe none are up."); - } - cb(); - }); - - gulp.task( - "standalone.prepare", - gulp.series( - "standalone.killRunningInstances", - "standalone.prepare.cleanup", - "standalone.prepare.copyPrefab", - "standalone.prepare.writePackageJson", - "standalone.prepare.minifyCode", - "standalone.prepare.copyGamefiles" - ) - ); - - /** - * - * @param {'win32'|'linux'|'darwin'} platform - * @param {'x64'|'ia32'} arch - * @param {function():void} cb - * @param {boolean=} isRelease - */ - function packageStandalone(platform, arch, cb, isRelease = true) { - const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml")); - - packager({ - dir: tempDestBuildDir, - appCopyright: "Tobias Springer", - appVersion: getVersion(), - buildVersion: "1.0.0", - arch, - platform, - asar: true, - executableName: "shapezio", - icon: path.join(electronBaseDir, "favicon"), - name: "shapez.io-standalone", - out: tempDestDir, - overwrite: true, - appBundleId: "io.shapez.standalone", - appCategoryType: "public.app-category.games", - ...(isRelease && - platform === "darwin" && { - osxSign: { - "identity": process.env.SHAPEZ_CLI_APPLE_CERT_NAME, - "hardened-runtime": true, - "hardenedRuntime": true, - "entitlements": "entitlements.plist", - "entitlements-inherit": "entitlements.plist", - "signature-flags": "library", - }, - osxNotarize: { - appleId: process.env.SHAPEZ_CLI_APPLE_ID, - appleIdPassword: "@keychain:SHAPEZ_CLI_APPLE_ID", - }, - }), - }).then( - appPaths => { - console.log("Packages created:", appPaths); - appPaths.forEach(appPath => { - if (!fs.existsSync(appPath)) { - console.error("Bad app path gotten:", appPath); - return; - } - - fs.writeFileSync( - path.join(appPath, "LICENSE"), - fs.readFileSync(path.join(__dirname, "..", "LICENSE")) - ); - - fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile); - - if (platform === "linux") { - fs.writeFileSync( - path.join(appPath, "play.sh"), - '#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n' - ); - fs.chmodSync(path.join(appPath, "play.sh"), 0o775); - } - - if (process.platform === "win32" && platform === "darwin") { - console.warn( - "Cross-building for macOS on Windows: dereferencing symlinks.\n".red + - "This will nearly double app size and make code signature invalid. Sorry!\n" - .red.bold + - "For more information, see " + - "https://github.com/electron/electron-packager/issues/71".underline - ); + /** + * + * @param {'win32'|'linux'} platform + * @param {'x64'|'ia32'} arch + * @param {function():void} cb + */ + function packageStandalone(platform, arch, cb) { + const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml")); + + packager({ + dir: tempDestBuildDir, + appCopyright: "Tobias Springer", + appVersion: getVersion(), + buildVersion: "1.0.0", + arch, + platform, + asar: true, + executableName: "shapezio", + icon: path.join(electronBaseDir, "favicon"), + name: "shapez.io-standalone" + suffix, + out: tempDestDir, + overwrite: true, + appBundleId: "io.shapez.standalone", + appCategoryType: "public.app-category.games", + }).then( + appPaths => { + console.log("Packages created:", appPaths); + appPaths.forEach(appPath => { + if (!fs.existsSync(appPath)) { + console.error("Bad app path gotten:", appPath); + return; + } - // Clear up framework folders fs.writeFileSync( - path.join(appPath, "play.sh"), - '#!/usr/bin/env bash\n./shapez.io-standalone.app/Contents/MacOS/shapezio --no-sandbox "$@"\n' - ); - fs.chmodSync(path.join(appPath, "play.sh"), 0o775); - fs.chmodSync( - path.join(appPath, "shapez.io-standalone.app", "Contents", "MacOS", "shapezio"), - 0o775 + path.join(appPath, "LICENSE"), + fs.readFileSync(path.join(__dirname, "..", "LICENSE")) ); - const finalPath = path.join(appPath, "shapez.io-standalone.app"); + fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile); - const frameworksDir = path.join(finalPath, "Contents", "Frameworks"); - const frameworkFolders = fs - .readdirSync(frameworksDir) - .filter(fname => fname.endsWith(".framework")); - - for (let i = 0; i < frameworkFolders.length; ++i) { - const folderName = frameworkFolders[i]; - const frameworkFolder = path.join(frameworksDir, folderName); - console.log(" -> ", frameworkFolder); + if (platform === "linux") { + fs.writeFileSync( + path.join(appPath, "play.sh"), + '#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n' + ); + fs.chmodSync(path.join(appPath, "play.sh"), 0o775); + } + }); - const filesToDelete = fs - .readdirSync(frameworkFolder) - .filter(fname => fname.toLowerCase() !== "versions"); - filesToDelete.forEach(fname => { - console.log(" -> Deleting", fname); - fs.unlinkSync(path.join(frameworkFolder, fname)); - }); + cb(); + }, + err => { + console.error("Packaging error:", err); + cb(); + } + ); + } - const frameworkSourceDir = path.join(frameworkFolder, "Versions", "A"); - fse.copySync(frameworkSourceDir, frameworkFolder); - } - } - }); - - cb(); - }, - err => { - console.error("Packaging error:", err); - cb(); - } + gulp.task(taskPrefix + "standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb)); + gulp.task(taskPrefix + "standalone.package.prod.linux64", cb => + packageStandalone("linux", "x64", cb) ); - } - gulp.task("standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb)); - gulp.task("standalone.package.prod.win32", cb => packageStandalone("win32", "ia32", cb)); - gulp.task("standalone.package.prod.linux64", cb => packageStandalone("linux", "x64", cb)); - gulp.task("standalone.package.prod.linux32", cb => packageStandalone("linux", "ia32", cb)); - gulp.task("standalone.package.prod.darwin64", cb => packageStandalone("darwin", "x64", cb)); - gulp.task("standalone.package.prod.darwin64.unsigned", cb => - packageStandalone("darwin", "x64", cb, false) - ); - - gulp.task( - "standalone.package.prod", - gulp.series( - "standalone.prepare", - gulp.parallel( - "standalone.package.prod.win64", - "standalone.package.prod.linux64", - "standalone.package.prod.darwin64" + gulp.task( + taskPrefix + "standalone.package.prod", + gulp.series( + taskPrefix + "standalone.prepare", + gulp.parallel( + taskPrefix + "standalone.package.prod.win64", + taskPrefix + "standalone.package.prod.linux64" + ) ) - ) - ); + ); + } } module.exports = { gulptasksStandalone }; diff --git a/gulp/steampipe/scripts/app.vdf.template b/gulp/steampipe/scripts/app.vdf.template index a13a9db3..32634060 100644 --- a/gulp/steampipe/scripts/app.vdf.template +++ b/gulp/steampipe/scripts/app.vdf.template @@ -2,14 +2,16 @@ { "appid" "1318690" "desc" "$DESC$" - "buildoutput" "C:\work\shapez\shapez.io\gulp\steampipe\steamtemp" + "buildoutput" "C:\work\shapez.io\gulp\steampipe\steamtemp" "contentroot" "" "setlive" "" "preview" "0" "local" "" "depots" { - "1318691" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\windows.vdf" - "1318692" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\linux.vdf" + "1318691" "C:\work\shapez.io\gulp\steampipe\scripts\windows.vdf" + "1318694" "C:\work\shapez.io\gulp\steampipe\scripts\china-windows.vdf" + "1318692" "C:\work\shapez.io\gulp\steampipe\scripts\linux.vdf" + "1318695" "C:\work\shapez.io\gulp\steampipe\scripts\china-linux.vdf" } } diff --git a/gulp/steampipe/scripts/china-linux.vdf b/gulp/steampipe/scripts/china-linux.vdf new file mode 100644 index 00000000..a1c56a96 --- /dev/null +++ b/gulp/steampipe/scripts/china-linux.vdf @@ -0,0 +1,12 @@ +"DepotBuildConfig" +{ + "DepotID" "1318695" + "contentroot" "C:\work\shapez.io\tmp_standalone_files_china\shapez.io-standalone-linux-x64" + "FileMapping" + { + "LocalPath" "*" + "DepotPath" "." + "recursive" "1" + } + "FileExclusion" "*.pdb" +} \ No newline at end of file diff --git a/gulp/steampipe/scripts/china-windows.vdf b/gulp/steampipe/scripts/china-windows.vdf new file mode 100644 index 00000000..8acc894d --- /dev/null +++ b/gulp/steampipe/scripts/china-windows.vdf @@ -0,0 +1,12 @@ +"DepotBuildConfig" +{ + "DepotID" "1318694" + "contentroot" "C:\work\shapez.io\tmp_standalone_files_china\shapez.io-standalone-win32-x64" + "FileMapping" + { + "LocalPath" "*" + "DepotPath" "." + "recursive" "1" + } + "FileExclusion" "*.pdb" +} \ No newline at end of file diff --git a/gulp/steampipe/scripts/linux.vdf b/gulp/steampipe/scripts/linux.vdf index 60dfcca5..df1a86cc 100644 --- a/gulp/steampipe/scripts/linux.vdf +++ b/gulp/steampipe/scripts/linux.vdf @@ -1,7 +1,7 @@ "DepotBuildConfig" { "DepotID" "1318692" - "contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files\shapez.io-standalone-linux-x64" + "contentroot" "C:\work\shapez.io\tmp_standalone_files\shapez.io-standalone-linux-x64" "FileMapping" { "LocalPath" "*" diff --git a/gulp/steampipe/scripts/windows.vdf b/gulp/steampipe/scripts/windows.vdf index 7d0db436..bf0e8721 100644 --- a/gulp/steampipe/scripts/windows.vdf +++ b/gulp/steampipe/scripts/windows.vdf @@ -1,7 +1,7 @@ "DepotBuildConfig" { "DepotID" "1318691" - "contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files\shapez.io-standalone-win32-x64" + "contentroot" "C:\work\shapez.io\tmp_standalone_files\shapez.io-standalone-win32-x64" "FileMapping" { "LocalPath" "*" diff --git a/gulp/webpack.config.js b/gulp/webpack.config.js index 6e1d7388..3f666e73 100644 --- a/gulp/webpack.config.js +++ b/gulp/webpack.config.js @@ -6,7 +6,7 @@ const { getRevision, getVersion, getAllResourceImages } = require("./buildutils" const lzString = require("lz-string"); const CircularDependencyPlugin = require("circular-dependency-plugin"); -module.exports = ({ watch = false, standalone = false }) => { +module.exports = ({ watch = false, standalone = false, chineseVersion = false }) => { return { mode: "development", devtool: "cheap-source-map", @@ -34,6 +34,7 @@ module.exports = ({ watch = false, standalone = false }) => { G_TRACKING_ENDPOINT: JSON.stringify( lzString.compressToEncodedURIComponent("http://localhost:10005/v1") ), + G_CHINA_VERSION: JSON.stringify(chineseVersion), G_IS_DEV: "true", G_IS_RELEASE: "false", G_IS_MOBILE_APP: "false", diff --git a/gulp/webpack.production.config.js b/gulp/webpack.production.config.js index c26bca68..1779a76f 100644 --- a/gulp/webpack.production.config.js +++ b/gulp/webpack.production.config.js @@ -16,12 +16,15 @@ module.exports = ({ standalone = false, isBrowser = true, mobileApp = false, + chineseVersion = false, }) => { const globalDefs = { assert: enableAssert ? "window.assert" : "false && window.assert", assertAlways: "window.assert", abstract: "window.assert(false, 'abstract method called');", G_IS_DEV: "false", + + G_CHINA_VERSION: JSON.stringify(chineseVersion), G_IS_RELEASE: environment === "prod" ? "true" : "false", G_IS_STANDALONE: standalone ? "true" : "false", G_IS_BROWSER: isBrowser ? "true" : "false", diff --git a/gulp/yarn.lock b/gulp/yarn.lock index 12959102..854ca274 100644 --- a/gulp/yarn.lock +++ b/gulp/yarn.lock @@ -3402,7 +3402,7 @@ cross-spawn@^5.0.1: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0: +cross-spawn@^7.0.0, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -4746,6 +4746,21 @@ execa@^4.0.0: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +execa@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.0.0.tgz#4029b0007998a841fbd1032e5f4de86a3c1e3376" + integrity sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + executable@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/executable/-/executable-4.1.1.tgz#41532bff361d3e57af4d763b70582db18f5d133c" @@ -5517,6 +5532,11 @@ get-stream@^5.0.0, get-stream@^5.1.0: dependencies: pump "^3.0.0" +get-stream@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.0.tgz#3e0012cb6827319da2706e601a1583e8629a6718" + integrity sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg== + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -5539,6 +5559,16 @@ gifsicle@^5.0.0: execa "^4.0.0" logalot "^2.0.0" +gifsicle@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/gifsicle/-/gifsicle-5.2.0.tgz#b06b25ed7530f033f6ed2c545d6f9b546cc182fb" + integrity sha512-vOIS3j0XoTCxq9pkGj43gEix82RkI5FveNgaFZutjbaui/HH+4fR8Y56dwXDuxYo8hR4xOo6/j2h1WHoQW6XLw== + dependencies: + bin-build "^3.0.0" + bin-wrapper "^4.0.0" + execa "^5.0.0" + logalot "^2.0.0" + glob-all@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-all/-/glob-all-3.1.0.tgz#8913ddfb5ee1ac7812656241b03d5217c64b02ab" @@ -6520,6 +6550,11 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -8772,7 +8807,7 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npm-run-path@^4.0.0: +npm-run-path@^4.0.0, npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -8985,6 +9020,13 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + open@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc" @@ -11469,6 +11511,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +signal-exit@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" diff --git a/res/logo_cn.png b/res/logo_cn.png new file mode 100644 index 00000000..5ef18416 Binary files /dev/null and b/res/logo_cn.png differ diff --git a/src/css/states/main_menu.scss b/src/css/states/main_menu.scss index 008bd30d..d2c04763 100644 --- a/src/css/states/main_menu.scss +++ b/src/css/states/main_menu.scss @@ -451,6 +451,10 @@ box-sizing: border-box; @include S(grid-gap, 4px); + &.china { + grid-template-columns: auto auto 1fr; + } + .author { flex-grow: 1; text-align: right; diff --git a/src/js/core/background_resources_loader.js b/src/js/core/background_resources_loader.js index bbd37036..46ec20e6 100644 --- a/src/js/core/background_resources_loader.js +++ b/src/js/core/background_resources_loader.js @@ -13,7 +13,7 @@ import { cachebust } from "./cachebust"; const logger = createLogger("background_loader"); const essentialMainMenuSprites = [ - "logo.png", + G_CHINA_VERSION ? "logo_cn.png" : "logo.png", ...G_ALL_UI_IMAGES.filter(src => src.startsWith("ui/") && src.indexOf(".gif") < 0), ]; const essentialMainMenuSounds = [ diff --git a/src/js/globals.d.ts b/src/js/globals.d.ts index 642745ca..4a903437 100644 --- a/src/js/globals.d.ts +++ b/src/js/globals.d.ts @@ -19,6 +19,8 @@ declare const G_BUILD_VERSION: string; declare const G_ALL_UI_IMAGES: Array; declare const G_IS_RELEASE: boolean; +declare const G_CHINA_VERSION : boolean; + // Polyfills declare interface String { replaceAll(search: string, replacement: string): string; diff --git a/src/js/states/about.js b/src/js/states/about.js index db06d8de..b8f465b7 100644 --- a/src/js/states/about.js +++ b/src/js/states/about.js @@ -15,7 +15,9 @@ export class AboutState extends TextualGameState { getMainContentHTML() { return `
- shapez.io Logo + shapez.io Logo
${T.about.body diff --git a/src/js/states/main_menu.js b/src/js/states/main_menu.js index dc8d30ce..2e20b05b 100644 --- a/src/js/states/main_menu.js +++ b/src/js/states/main_menu.js @@ -42,7 +42,12 @@ export class MainMenuState extends GameState { return `
- + ${ + G_CHINA_VERSION + ? "" + : `` + } + ${ G_IS_STANDALONE || G_IS_DEV @@ -58,7 +63,9 @@ export class MainMenuState extends GameState { @@ -77,11 +84,17 @@ export class MainMenuState extends GameState {
-