mirror of
				https://github.com/tobspr/shapez.io.git
				synced 2025-06-13 13:04:03 +00:00 
			
		
		
		
	* [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
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const fs = require('fs');
 | |
| const path = require('path');
 | |
| const { ipcMain } = require("electron");
 | |
| 
 | |
| let greenworks = null;
 | |
| let appId = null;
 | |
| let initialized = false;
 | |
| 
 | |
| try {
 | |
|     greenworks = require("shapez.io-private-artifacts/steam/greenworks");
 | |
|     appId = parseInt(fs.readFileSync(path.join(__dirname, "steam_appid.txt"), "utf8"));
 | |
| } catch (err) {
 | |
|     // greenworks is not installed
 | |
|     // throw err;
 | |
| }
 | |
| 
 | |
| function init (isDev) {
 | |
|     if (!greenworks) {
 | |
|         return;
 | |
|     }
 | |
| 
 | |
|     if (!isDev) {
 | |
|         if (greenworks.restartAppIfNecessary(appId)) {
 | |
|             console.log("Restarting ...");
 | |
|             process.exit(0);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     if (!greenworks.init()) {
 | |
|         console.log("Failed to initialize greenworks");
 | |
|         process.exit(1);
 | |
|     }
 | |
| 
 | |
|     initialized = true;
 | |
| }
 | |
| 
 | |
| function listen () {
 | |
|     ipcMain.handle("steam:is-initialized", isInitialized);
 | |
| 
 | |
|     if (!greenworks || !initialized) {
 | |
|         console.log("Ignoring Steam IPC events");
 | |
|         return;
 | |
|     }
 | |
| 
 | |
|     ipcMain.handle("steam:get-achievement-names", getAchievementNames);
 | |
|     ipcMain.handle("steam:activate-achievement", activateAchievement);
 | |
| }
 | |
| 
 | |
| function isInitialized(event) {
 | |
|     return Promise.resolve(initialized);
 | |
| }
 | |
| 
 | |
| function getAchievementNames(event) {
 | |
|     return new Promise((resolve, reject) => {
 | |
|         try {
 | |
|             const achievements = greenworks.getAchievementNames()
 | |
|             resolve(achievements);
 | |
|         } catch (err) {
 | |
|             reject(err);
 | |
|         }
 | |
|     });
 | |
| }
 | |
| 
 | |
| function activateAchievement(event, id) {
 | |
|     return new Promise((resolve, reject) => {
 | |
|         greenworks.activateAchievement(id, () => resolve(), err => reject(err))
 | |
|     });
 | |
| }
 | |
| 
 | |
| module.exports = {
 | |
|     init,
 | |
|     listen
 | |
| };
 |