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

Add a button to test the overlay #98

Merged
merged 2 commits into from
Jul 4, 2023
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ Make sure you have the latest [node.js](https://nodejs.org/en/), [Rust](https://
Install dependencies with `npm install` and then run `npm run build:debug` to build the library.

There is no way to build for all targets easily. The good news is that you don't need to. You can develop and test on your current target, and open a PR. When the code is merged to main, a github action will build for all targets and publish a new version.

### Testing Electron

Go to the [test/electron](./test/electron) directory. There, you can run `npm install` and then `npm start` to run the Electron app.

Click "activate overlay" to test the overlay.
1 change: 1 addition & 0 deletions test/electron/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

Expand Down
6 changes: 5 additions & 1 deletion test/electron/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ const steamworks = require('steamworks.js');
const client = steamworks.init(480);

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

document.getElementById('activateOverlay').addEventListener('click', function() {
client.overlay.activateToWebPage('https://www.example.com/')
})
10 changes: 10 additions & 0 deletions test/overlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { init } = require('../index.js')

const client = init(480)

/*
This node script is "headless." It has no graphical context into which Steam can inject an overlay.

Therefore, when you run this script while the Steam app is running, Steam will foreground the Steam app, and display example.com in the Steam app's window.
*/
client.overlay.activateToWebPage('https://www.example.com/');