Skip to content

Instantly share code, notes, and snippets.

@dfabulich
Last active March 9, 2017 15:30
Show Gist options
  • Save dfabulich/90a02ed6fe0933025da0 to your computer and use it in GitHub Desktop.
Save dfabulich/90a02ed6fe0933025da0 to your computer and use it in GitHub Desktop.
  1. Save greenwtf.ps1 (included in the gist below) to a directory of your choosing.

  2. Copy steam_api.dll to that directory, from the Steamworks SDK 1.34 (that exact version)

  3. Create a steam_appid.txt file in that directory, containing an app ID that you own.

  4. Launch Steam, logged in as your developer account.

  5. Run the script like this:

powershell -ExecutionPolicy Bypass -File greenwtf.ps1
  1. nw.js will start; the UI will say, "SteamAPI Init: true" to indicate that everything's working so far.

  2. Click the "overlay" button. The app will crash.

Don't trust the script? You can read it and reproduce the effect yourself.

  1. Download and extract http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-ia32.zip

  2. Download and extract https://github.com/greenheartgames/greenworks/releases/download/0.5.1/greenworks-v0.5.1-nw-0.12.1.zip

  3. Copy greenworks.js into the nwjs directory containing nw.exe

  4. Copy steam_api.dll into the greenworks lib directory

  5. Copy the greenworks lib directory into the nwjs directory containing nw.exe

  6. Copy steam_appid.txt next to nw.exe

  7. Create this index.html file next to nw.exe

<html>
<head>
  <meta charset="utf-8">
  <title>Hello Greenworks</title>
</head>

<body>
  <h1>Greenworks Test</h1>
  SteamAPI Init:
  <script>
    var greenworks = require('./greenworks');
    document.write(greenworks.initAPI());
  </script>
  <button id="overlay">overlay</button>
  <script>
  	var overlay = document.getElementById("overlay");
  	overlay.onclick = function() {
  		greenworks.activateGameOverlayToWebPage("http://store.steampowered.com/")

  	}
  </script>
</body>
  1. Create this package.json next to nw.exe.
{
  "name": "greenworks-nw-demo",
  "main": "index.html",
  "chromium-args": "--in-process-gpu --disable-transparency"
}
  1. Launch nw.exe; the UI will say, "SteamAPI Init: true" to indicate that everything's working so far.

  2. Click the overlay button; the app will crash.

if (-Not (Test-Path .\steam_api.dll)) {
echo "Please copy steam_api.dll next to this script"
Exit(1)
}
if (-Not (Test-Path .\steam_appid.txt)) {
echo "Please create a steam_appid.txt next to this script"
Exit(1)
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
if (-Not (Test-Path .\downloads)) {
New-Item .\downloads -type directory -force
}
if (Test-Path .\app) {
Remove-Item -recurse -force .\app
}
New-Item -type directory -force .\app
$wc = New-Object net.webclient
$source = "http://dl.nwjs.io/v0.12.1/nwjs-v0.12.1-win-ia32.zip"
$outfile = ".\downloads\nwjs-v0.12.1-win-ia32.zip"
if (-Not (Test-Path $outfile)) {
$wc.DownloadFile($source, $outfile)
#Invoke-WebRequest $source -OutFile $outfile
}
Unzip $outfile .\app
$source = "https://github.com/greenheartgames/greenworks/releases/download/0.5.1/greenworks-v0.5.1-nw-0.12.1.zip"
$outfile = ".\downloads\greenworks-v0.5.1-nw-0.12.1.zip"
if (-Not (Test-Path $outfile)) {
$wc.DownloadFile($source, $outfile)
#Invoke-WebRequest $source -OutFile $outfile
}
Unzip $outfile .\app
Move-Item .\app\greenworks-v0.5.1-nw-0.12.1\greenworks.js .\app\nwjs-v0.12.1-win-ia32
Move-Item .\app\greenworks-v0.5.1-nw-0.12.1\lib .\app\nwjs-v0.12.1-win-ia32
Copy-Item .\steam_api.dll .\app\nwjs-v0.12.1-win-ia32\lib
Copy-Item .\steam_appid.txt .\app\nwjs-v0.12.1-win-ia32
$indexHtml = @"
<html>
<head>
<meta charset="utf-8">
<title>Hello Greenworks</title>
</head>
<body>
<h1>Greenworks Test</h1>
SteamAPI Init:
<script>
var greenworks = require('./greenworks');
document.write(greenworks.initAPI());
</script>
<button id="overlay">overlay</button>
<script>
var overlay = document.getElementById("overlay");
overlay.onclick = function() {
greenworks.activateGameOverlayToWebPage("http://store.steampowered.com/")
}
</script>
</body>
"@
$indexHtml | Out-File -Encoding ascii .\app\nwjs-v0.12.1-win-ia32\index.html
$packageJson = @"
{
"name": "greenworks-nw-demo",
"main": "index.html",
"chromium-args": "--in-process-gpu --disable-transparency"
}
"@
$packageJson | Out-File -Encoding ascii .\app\nwjs-v0.12.1-win-ia32\package.json
Start-Process .\app\nwjs-v0.12.1-win-ia32\nw.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment