1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Achievements (#1087)

* [WIP] Add boilerplate for achievement implementation

* Add config.local.template.js and rm cached copy of config.local.js

* [WIP] Implement painting, cutting, rotating achievements (to log only)

* [WIP] Refactor achievements, jsdoc fixes, add npm script

- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts

* Add steam/greenworks IPC calls and optional private-artifact dependency

* Include private artifacts in standalone builds

* Uncomment appid include

* [WIP] Add steam overlay fix, add hash to artifact dependency

* Update electron, greenworks. Add task to add local config if not present

* Add more achievements, refactor achievement code

* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked

* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements

* Add achievements, ids. Update names, keys for consistency

* Add play time achievements

* [WIP] Add more achievements

* Add more achievements. Add bulk achievement check signal

* [WIP] Add achievements. Start savefile migration

* Add achievements. Add savefile migration

* Remove superfluous achievement stat

* Update lock files, fix merge conflict
This commit is contained in:
Greg Considine
2021-03-10 01:33:39 -05:00
committed by GitHub
parent afdce2268e
commit 26b842494f
37 changed files with 26397 additions and 23269 deletions

View File

@@ -50,6 +50,9 @@ css.gulptasksCSS($, gulp, buildFolder, browserSync);
const sounds = require("./sounds");
sounds.gulptasksSounds($, gulp, buildFolder);
const localConfig = require("./local-config");
localConfig.gulptasksLocalConfig($, gulp);
const js = require("./js");
js.gulptasksJS($, gulp, buildFolder, browserSync);
@@ -225,6 +228,7 @@ gulp.task(
gulp.series(
"utils.cleanup",
"utils.copyAdditionalBuildFiles",
"localConfig.findOrCreate",
"imgres.buildAtlas",
"imgres.atlasToJson",
"imgres.atlas",
@@ -242,6 +246,7 @@ gulp.task(
"build.standalone.dev",
gulp.series(
"utils.cleanup",
"localConfig.findOrCreate",
"imgres.buildAtlas",
"imgres.atlasToJson",
"imgres.atlas",

18
gulp/local-config.js Normal file
View File

@@ -0,0 +1,18 @@
const path = require("path");
const fs = require("fs");
const fse = require("fs-extra");
const configTemplatePath = path.join(__dirname, "../src/js/core/config.local.template.js");
const configPath = path.join(__dirname, "../src/js/core/config.local.js");
function gulptasksLocalConfig($, gulp) {
gulp.task("localConfig.findOrCreate", cb => {
if (!fs.existsSync(configPath)) {
fse.copySync(configTemplatePath, configPath);
}
cb();
});
}
module.exports = { gulptasksLocalConfig };

View File

@@ -1,5 +1,6 @@
require("colors");
const packager = require("electron-packager");
const pj = require("../electron/package.json");
const path = require("path");
const { getVersion } = require("./buildutils");
const fs = require("fs");
@@ -9,49 +10,53 @@ const execSync = require("child_process").execSync;
function gulptasksStandalone($, gulp) {
const electronBaseDir = path.join(__dirname, "..", "electron");
for (const { tempDestDir, suffix, taskPrefix } of [
{ tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"), suffix: "", taskPrefix: "" },
const targets = [
{
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"),
suffix: "",
taskPrefix: ""
},
{
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"),
suffix: "china",
taskPrefix: "china.",
},
]) {
];
for (const { tempDestDir, suffix, taskPrefix } of targets) {
const tempDestBuildDir = path.join(tempDestDir, "built");
gulp.task(taskPrefix + "standalone.prepare.cleanup", () => {
return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
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, "steam_appid.txt"),
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));
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
)
);
const packageJsonString = JSON.stringify({
scripts: {
start: pj.scripts.start
},
devDependencies: pj.devDependencies,
optionalDependencies: pj.optionalDependencies
}, null, 4);
fs.writeFileSync(path.join(tempDestBuildDir, "package.json"), packageJsonString);
cb();
});
@@ -74,7 +79,8 @@ function gulptasksStandalone($, gulp) {
});
gulp.task(taskPrefix + "standalone.prepare.copyGamefiles", () => {
return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir));
return gulp.src("../build/**/*.*", { base: "../build" })
.pipe(gulp.dest(tempDestBuildDir));
});
gulp.task(taskPrefix + "standalone.killRunningInstances", cb => {
@@ -106,6 +112,14 @@ function gulptasksStandalone($, gulp) {
*/
function packageStandalone(platform, arch, cb) {
const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml"));
const privateArtifactsPath = "node_modules/shapez.io-private-artifacts";
let asar;
if (fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) {
asar = { unpackDir: privateArtifactsPath };
} else {
asar = true;
}
packager({
dir: tempDestBuildDir,
@@ -114,7 +128,7 @@ function gulptasksStandalone($, gulp) {
buildVersion: "1.0.0",
arch,
platform,
asar: true,
asar: asar,
executableName: "shapezio",
icon: path.join(electronBaseDir, "favicon"),
name: "shapez.io-standalone" + suffix,
@@ -136,6 +150,11 @@ function gulptasksStandalone($, gulp) {
fs.readFileSync(path.join(__dirname, "..", "LICENSE"))
);
fse.copySync(
path.join(tempDestBuildDir, "steam_appid.txt"),
path.join(appPath, "steam_appid.txt")
);
fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile);
if (platform === "linux") {
@@ -156,7 +175,9 @@ function gulptasksStandalone($, gulp) {
);
}
gulp.task(taskPrefix + "standalone.package.prod.win64", cb => packageStandalone("win32", "x64", 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)
);

File diff suppressed because it is too large Load Diff