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

electron-builder example #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/electron-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
18 changes: 18 additions & 0 deletions test/electron-builder/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<title>Test steamworks.js</title>
</head>

<body>
<h1>Your steam name: <span id="name"></span></h1>
<button id="activateOverlay">activate overlay</button>
<script src="./renderer.js"></script>
</body>

</html>
37 changes: 37 additions & 0 deletions test/electron-builder/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { app, BrowserWindow } = require('electron')
const steamworks = require('steamworks.js')

function createWindow() {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
})

// will be true when opened from steam big picture
if (process.env.SteamTenfoot) {
mainWindow.setFullScreen(true)
} else {
mainWindow.maximize()
}

mainWindow.webContents.openDevTools()
mainWindow.loadFile('index.html')
}

app.whenReady().then(() => {
createWindow()

app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})

steamworks.electronEnableSteamOverlay()
24 changes: 24 additions & 0 deletions test/electron-builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "steamworks.js-electron-test",
"author": "(author and version fields required for electron-builder)",
"version": "0.0.1",
"private": true,
"dependencies": {
"steamworks.js": "../.."
},
"devDependencies": {
"electron": "24.2.0",
"electron-builder": "24.6.3"
},
"main": "main.js",
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder -m"
},
"build": {
"mac": {
"target": "zip"
}
}
}
10 changes: 10 additions & 0 deletions test/electron-builder/renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('steamworks.js')} */
const steamworks = require('steamworks.js');
const client = steamworks.init(480);

const playerName = client.localplayer.getName()
document.getElementById('name').innerText = playerName

document.getElementById('activateOverlay').addEventListener('click', function() {
client.overlay.activateToWebPage('https://www.example.com/')
})