Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contextIsolation false or true? electronEnableSteamOverlay has to be called? #121

Open
IlTimido opened this issue Oct 24, 2023 · 4 comments

Comments

@IlTimido
Copy link

Hi,

I was going through the documentation and noted that to utilize steamworks.js, the recommended setup is:

const mainWindow = new BrowserWindow({
    // ...
    webPreferences: {
        // ...
        contextIsolation: false,
        nodeIntegration: true
    }
});

Followed by:

require('steamworks.js').electronEnableSteamOverlay()

Interestingly, when I set contextIsolation to false, things don't seem to work. But, when it's set to true, everything functions smoothly even without invoking electronEnableSteamOverlay.

I'd like to confirm that I'm not overlooking any details. Have you encountered a similar situation?

Thank you in advance for any insights.

P.S.: I'm using Windows 10, and my build targets the same platform.

@ghost
Copy link

ghost commented Nov 14, 2023

I think I've encountered the same thing. When contextIsolation is set to false, I get an infinite loading animation, even when not 'packaged' (just running npm start without making an actual packaged .exe). If I set to true, things load instantly.

Windows 10 (22H2)
Node 20.9.0
Electron 27.0.4

@IlTimido
Copy link
Author

However my game is published live on Steam, achievement works, cloud saves works, all works perfectly, so contextIsolation: true is okay.

@ghost
Copy link

ghost commented Nov 15, 2023

I'd be interested in how you got the achievements working with contextIsolation: true! That's what I'm trying to do (in an HTML/JS game that I'm packaging with an Electron wrapper) but while it's true that I can't make any API calls between the Electron/Node side (where steamworks.js lives) and the renderer (my browser window that actually has the game).

@IlTimido
Copy link
Author

IlTimido commented Nov 15, 2023

Here it is what I do and that works;

In preload.js

contextBridge.exposeInMainWorld("electronAPI", {
    gotAchievement: (code) => ipcRenderer.send("got-achievement", code),
    ...
    ...

In main.js

...
ipcMain.on("got-achievement", (event, code) => {
    const steamworks = require("steamworks.js");
    const client = steamworks.init();
    client.achievement.activate(code);
});
...

And in my renderer.js

...
window.electronAPI.gotAchievement(type);
...

I Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant