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

Overlay not working #160

Open
jstroh opened this issue Aug 26, 2024 · 2 comments
Open

Overlay not working #160

jstroh opened this issue Aug 26, 2024 · 2 comments

Comments

@jstroh
Copy link

jstroh commented Aug 26, 2024

const { Menu, app, BrowserWindow, ipcMain } = require("electron");
const serve = require("electron-serve");
const { join } = require("path");
Menu.setApplicationMenu(null);
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;
const steamworks = require("steamworks.js");
const steamClient = steamworks.init(2957110);

const appServe = app.isPackaged ? serve({
  directory: join(__dirname, "../out")
}) : null;

const createWindow = () => {
  let browserWindowOptions;
  if (steamClient.utils.isSteamRunningOnSteamDeck()) {
    browserWindowOptions = {
      backgroundColor: "#000000",
      show: false,
      webPreferences: {
        preload: join(__dirname, "preload.js"),
        nodeIntegration: true,
        contextIsolation: true,
        enableRemoteModule: false,
        webSecurity: true,
        sandbox: true,
        webgl: true,
        backgroundThrottling: false
      }
    }
  } else {
    browserWindowOptions = {
      width: 1280,
      height: 720,
      minWidth: 640,
      minHeight: 480,
      backgroundColor: "#000000",
      show: false,
      webPreferences: {
        preload: join(__dirname, "preload.js"),
        nodeIntegration: true,
        contextIsolation: true,
        enableRemoteModule: false,
        webSecurity: true,
        sandbox: true,
        webgl: true,
        backgroundThrottling: false
      }
    }
  }
  const win = new BrowserWindow(browserWindowOptions);
  if (steamClient.utils.isSteamRunningOnSteamDeck()) {
    win.setFullScreen(true);
  }
  win.show();

  ipcMain.handle('getSteamId', async (_event) => {
    return steamClient.localplayer.getSteamId().steamId64;
  });

  ipcMain.handle('getAuthTicketForWebApi', async (_event) => {
    try {
      const ticket = await steamClient.auth.getAuthTicketForWebApi();
      return ticket.getBytes();
    } catch (e) {
      console.log(e);
    }
  });
  if (app.isPackaged) {
    appServe(win).then(() => {
      win.loadURL("app://-");
    });
  } else {
    win.loadURL("http://localhost:3000");
    win.webContents.openDevTools();
    win.webContents.on("did-fail-load", (e, code, desc) => {
      win.webContents.reloadIgnoringCache();
    });
  }
}

app.on("ready", () => {
  createWindow();
});

app.on("window-all-closed", () => {
  app.quit();
});

steamworks.electronEnableSteamOverlay();

There's my main.js

The SHIFT+TAB does not show up on macOS.

The steamClient calls work fine. I just started integrating the microtransaction api and I can't get the overlay to show up to to complete a transaction.

I tried successful calls to https://partner.steam-api.com/ISteamMicroTxn/InitTxn/v3/ and nothing pops up on macOS or on Steam Deck.

Help! Any ideas?

Here's my current package.json

{
  "name": "fov4-steam",
  "version": "0.1.0",
  "private": true,
  "main": "main/main.js",
  "scripts": {
    "dev": "concurrently -n \"NEXT,ELECTRON\" -c \"yellow,blue\" --kill-others \"next dev\" \"electron .\"",
    "build": "next build && electron-builder",
    "dist": "npm run dist:mac && npm run dist:win && npm run dist:linux",
    "dist:mac": "next build && electron-builder --mac",
    "postdist:mac": "cp ./steam-selector dist/mac/mas-universal/",
    "dist:win": "next build && electron-builder --win",
    "dist:linux": "next build && electron-builder --linux",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "axios": "^1.7.2",
    "electron-serve": "^1.3.0",
    "next": "14.2.4",
    "react": "^18",
    "react-dom": "^18",
    "steamworks.js": "^0.4.0"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "18.3.3",
    "@types/react-dom": "^18",
    "concurrently": "^8.2.2",
    "electron": "^30.1.1",
    "electron-builder": "^24.13.3",
    "eslint": "^8",
    "eslint-config-next": "14.2.4",
    "postcss": "^8",
    "typescript": "5.4.5"
  }
}

@malero
Copy link

malero commented Nov 1, 2024

I'm having the same issue. I need the overlay for the same reason you do, the microtransaction API, and I can't get the overlay to work. It is doing something when I call steamworks.electronEnableSteamOverlay, everything that usually requires a single click now takes a double click. Very strange. Were you ever able to get this working?

@Canubiz
Copy link

Canubiz commented Nov 24, 2024

Same problem here – the Steam overlay won't show up on macOS build, but it works on Windows - and for other Steam games it also works on macOS.

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

7 participants
@jstroh @malero @Canubiz and others