Skip to content

Overlay not working #160

@jstroh

Description

@jstroh
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"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions