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
2021-03-10 06:33:39 +00:00
|
|
|
import { NoAchievementProvider } from "../browser/no_achievement_provider";
|
2020-10-07 07:48:31 +00:00
|
|
|
import { PlatformWrapperImplBrowser } from "../browser/wrapper";
|
|
|
|
import { getIPCRenderer } from "../../core/utils";
|
|
|
|
import { createLogger } from "../../core/logging";
|
|
|
|
import { StorageImplElectron } from "./storage";
|
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
2021-03-10 06:33:39 +00:00
|
|
|
import { SteamAchievementProvider } from "./steam_achievement_provider";
|
2020-10-07 07:48:31 +00:00
|
|
|
import { PlatformWrapperInterface } from "../wrapper";
|
|
|
|
|
|
|
|
const logger = createLogger("electron-wrapper");
|
|
|
|
|
|
|
|
export class PlatformWrapperImplElectron extends PlatformWrapperImplBrowser {
|
|
|
|
initialize() {
|
2021-05-23 15:34:13 +00:00
|
|
|
this.dlcs = {
|
|
|
|
puzzle: false,
|
|
|
|
};
|
|
|
|
|
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
2021-03-10 06:33:39 +00:00
|
|
|
this.steamOverlayCanvasFix = document.createElement("canvas");
|
|
|
|
this.steamOverlayCanvasFix.width = 1;
|
|
|
|
this.steamOverlayCanvasFix.height = 1;
|
|
|
|
this.steamOverlayCanvasFix.id = "steamOverlayCanvasFix";
|
|
|
|
|
|
|
|
this.steamOverlayContextFix = this.steamOverlayCanvasFix.getContext("2d");
|
|
|
|
document.documentElement.appendChild(this.steamOverlayCanvasFix);
|
|
|
|
|
|
|
|
this.app.ticker.frameEmitted.add(this.steamOverlayFixRedrawCanvas, this);
|
|
|
|
|
2020-10-07 07:48:31 +00:00
|
|
|
this.app.storage = new StorageImplElectron(this);
|
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
2021-03-10 06:33:39 +00:00
|
|
|
this.app.achievementProvider = new SteamAchievementProvider(this.app);
|
|
|
|
|
2021-05-23 15:34:13 +00:00
|
|
|
return this.initializeAchievementProvider()
|
|
|
|
.then(() => this.initializeDlcStatus())
|
|
|
|
.then(() => PlatformWrapperInterface.prototype.initialize.call(this));
|
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
2021-03-10 06:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
steamOverlayFixRedrawCanvas() {
|
|
|
|
this.steamOverlayContextFix.clearRect(0, 0, 1, 1);
|
2020-10-07 07:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
|
|
|
return "electron";
|
|
|
|
}
|
|
|
|
|
|
|
|
getSupportsRestart() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
openExternalLink(url) {
|
|
|
|
logger.log(this, "Opening external:", url);
|
|
|
|
window.open(url, "about:blank");
|
|
|
|
}
|
|
|
|
|
|
|
|
getSupportsAds() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
performRestart() {
|
|
|
|
logger.log(this, "Performing restart");
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeAdProvider() {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
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
2021-03-10 06:33:39 +00:00
|
|
|
initializeAchievementProvider() {
|
2021-03-11 05:11:29 +00:00
|
|
|
return this.app.achievementProvider.initialize().catch(err => {
|
|
|
|
logger.error("Failed to initialize achievement provider, disabling:", err);
|
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
2021-03-10 06:33:39 +00:00
|
|
|
|
2021-03-11 05:11:29 +00:00
|
|
|
this.app.achievementProvider = new NoAchievementProvider(this.app);
|
|
|
|
});
|
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
2021-03-10 06:33:39 +00:00
|
|
|
}
|
|
|
|
|
2021-05-23 15:34:13 +00:00
|
|
|
initializeDlcStatus() {
|
|
|
|
const renderer = getIPCRenderer();
|
|
|
|
|
2021-05-25 19:29:44 +00:00
|
|
|
if (G_WEGAME_VERSION) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
2021-05-23 15:34:13 +00:00
|
|
|
logger.log("Checking DLC ownership ...");
|
|
|
|
// @todo: Don't hardcode the app id
|
|
|
|
return renderer.invoke("steam:check-app-ownership", 1625400).then(
|
|
|
|
res => {
|
|
|
|
logger.log("Got DLC ownership:", res);
|
|
|
|
this.dlcs.puzzle = Boolean(res);
|
2021-06-27 13:52:37 +00:00
|
|
|
|
|
|
|
if (this.dlcs.puzzle && !G_IS_DEV) {
|
|
|
|
this.app.gameAnalytics.activateDlc("puzzle").then(
|
|
|
|
() => {
|
|
|
|
logger.log("Puzzle DLC successfully activated");
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
logger.error("Failed to activate puzzle DLC:", error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2021-05-23 15:34:13 +00:00
|
|
|
},
|
|
|
|
err => {
|
|
|
|
logger.error("Failed to get DLC ownership:", err);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-07 07:48:31 +00:00
|
|
|
getSupportsFullscreen() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
setFullscreen(flag) {
|
|
|
|
getIPCRenderer().send("set-fullscreen", flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
getSupportsAppExit() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
exitApp() {
|
|
|
|
logger.log(this, "Sending app exit signal");
|
|
|
|
getIPCRenderer().send("exit-app");
|
|
|
|
}
|
|
|
|
}
|