ELECTRON: Use steamworks.js to integrate with Steamworks SDK (#1563)

This commit is contained in:
catloversg
2025-04-15 06:19:17 +07:00
committed by GitHub
parent d592e07719
commit 44b8baa8ad
28 changed files with 162 additions and 431 deletions

View File

@@ -5,6 +5,7 @@ const Store = require("electron-store");
const utils = require("./utils");
const storage = require("./storage");
const store = new Store();
const { steamworksClient } = require("./steamworksUtils");
function getMenu(window) {
const canZoomIn = utils.getZoomFactor() <= 2;
@@ -54,7 +55,7 @@ function getMenu(window) {
},
{
label: "Export Scripts",
click: async () => window.webContents.send("trigger-scripts-export"),
click: () => window.webContents.send("trigger-scripts-export"),
},
{
type: "separator",
@@ -74,7 +75,7 @@ function getMenu(window) {
{
label: "Load From File",
click: async () => {
const defaultPath = await storage.getSaveFolder(window);
const defaultPath = storage.getSaveFolder(window);
const result = await dialog.showOpenDialog(window, {
title: "Load From File",
defaultPath: defaultPath,
@@ -103,7 +104,7 @@ function getMenu(window) {
click: async () => {
try {
const saveData = await storage.getSteamCloudSaveData();
await storage.pushSaveGameForImport(window, saveData, false);
storage.pushSaveGameForImport(window, saveData, false);
} catch (error) {
log.error(error);
utils.writeToast(window, "Could not load from Steam Cloud", "error", 5000);
@@ -126,7 +127,7 @@ function getMenu(window) {
{
label: "Auto-Save to Steam Cloud",
type: "checkbox",
enabled: !global.greenworksError,
enabled: steamworksClient !== undefined,
checked: storage.isCloudEnabled(),
click: (menuItem) => {
storage.setCloudEnabledConfig(menuItem.checked);
@@ -166,8 +167,8 @@ function getMenu(window) {
},
{
label: "Open Saves Directory",
click: async () => {
const path = await storage.getSaveFolder(window);
click: () => {
const path = storage.getSaveFolder(window);
shell.openPath(path);
},
},
@@ -289,10 +290,15 @@ function getMenu(window) {
},
{
label: "Delete Steam Cloud Data",
enabled: !global.greenworksError,
click: async () => {
enabled: steamworksClient !== undefined,
click: () => {
if (steamworksClient.cloud.listFiles().length === 0) {
return;
}
try {
await storage.deleteCloudFile();
if (!storage.deleteCloudFile()) {
log.warn("Cannot delete Steam Cloud data");
}
} catch (error) {
log.error(error);
}