Make sure the following programs are installed:
- Node JS (with NPM)
- Rust (Optional - only required if editing
steamworks-rs/steamworks.jsdependencies) - git (Optional)
🐧 On Linux, the
build-essentialpackage must be installed to build Rust native addons:sudo apt-get install build-essential
ℹ Builds tested and verified as working on Windows 10/Ubuntu 22.04
🪟 When using the latest LTS versions of NodeJS on Windows, an NPM bug exists where the
registry-jsdependency (used by thenode-addon-apipackage) will throw an error when reaching thenode-gyp rebuildstep.To bypass this:
- If you currently have the latest LTS release of NodeJS installed, temporarily uninstall it
- Download version
14.16.0of NodeJS (Direct download link)- Run through the installer with default options
- Once Step 2 of the Basic Installation section is complete, reinstall the latest LTS version of NodeJS
ℹ Rust is not required for basic installation
- Clone the repository:
git clone https://github.com/SteamAchievementNotifier/SteamAchievementNotifier.git -b master
ℹ If you do not have
gitinstalled, select Code > Download ZIP and extract it.
- In the project root, run the following command to build all dependencies:
npm i
- Once complete, run the following command to start Steam Achievement Notifier in
devmode:
npm run dev
- Run the following command to build the executable:
// Windows
npm run win
// Linux
npm run linux
ℹ The output directory for executables is
_release.
The project follows a standard TS structure:
- Source
.tsfiles are located under./src - Compiled
.jsfiles are located under./dist
Within src/dist, there are several subfolders to separate core app functionality from additional features:
-
app: Contains.ts/.jsfiles and associatedHTML/CSSfor coreBrowserWindowinstances used for in-app pages, menus and dialogs. Also contains:app.ts: The entry point to the Electron appmain.ts: The "Main process"listeners.ts: An extension ofmain.tsthat focuses on managing various event listenersworker.ts: A backgroundBrowserWindowinstance that initialises Steamworks when a game process is detected. Dynamically spawned/destroyed in order to initialise/release Steamworks between game instances
-
lang: Contains modules for each supported app language.
ℹ These files only provide translation strings via the exported object -
./src/app/language.tscontains the logic to apply these translations to elements within the app
notify: Contains.ts/.jsto controlBrowserWindowinstances that are used by notification windows
In Steam Achievement Notifier (V1.9), there are two projects that provide Steamworks integration via Rust - steamworks-rs and steamworks.js.
ℹ
steamworks-rsconverts the original Steamworks functions into Rust.
ℹ
steamworks.jstakes the functions provided bysteamworks-rs, and converts them from Rust to Javascript using a.nodeaddon. This then allows the original Steamworks functions to be made available for use in Electron apps.
Both of these projects have been customised specifically for use within Steam Achievement Notifier, both by extending functionality in terms of achievement info, and removing certain functions beyond the scope of this application (e.g. unlocking/relocking achievements, UGC/Workshop content, networking etc.)
⚠ Under normal circumstances, if you only want to edit Steam Achievement Notifier itself, you will not need to install the Steamworks dependencies outlined below - the Basic Installation section will be enough!
Clone both the steamworks-rs and steamworks.js repositories into ./deps:
cd deps
git clone https://github.com/SteamAchievementNotifier/san_steamworks-rs.git
git clone https://github.com/SteamAchievementNotifier/san_steamworks.js.git
The ./deps/san_steamworks-rs/steamworks-sys/src/windows_bindings.rs file makes the current Steamworks functions (written in C) available for use in Rust.
- You can add other available Steamworks functions by checking the existing mappings and mimicking them (although most are already available).
- The current Steamworks SDK version is 1.57.
steamworks.js requires the Steamworks functions present in steamworks-rs to enable their use in JS, so any required functionality that is not present in steamworks.js needs to be written into steamworks-rs first.
- The two projects here are linked via
./deps/san_steamworks.js/cargo.toml.
- You shouldn't need to rebuild
steamworks-rswhen buildingsteamworks.js(as it will rebuild automatically), so it's okay to just save the files you have changed insteamworks-rswithout runningcargo build --release.
If you have written a function in steamworks-rs that you want to make available to JS (via steamworks.js), you'll need to create a new function like so:
// Example
#[napi]
pub fn shutdown() {
unsafe { sys::SteamAPI_Shutdown() }
}The steamworks.js build script does all the Rust > JS conversion for you, so as long as you're not getting any errors, your function should be available in JS after building.
To build a release version of steamworks.js,navigate to ./deps/san_steamworks.js and run:
npm run build
This will generate a release (i.e. optimised) .node file in ./deps/san_steamworks/dist/win64 (or ./deps/san_steamworks/dist/linux on Linux), which is the module needed to load the functions created in steamworks.js into Node/Electron.
Including the entirety of both the `steamworks-rs`/`steamworks.js` projects would make GitHub repos/application executables way too big.
A better way to do this is to just include the required dependencies for steamworks.js to work as a Node module.
- The
steamworks-rs/steamworks.jsproject files are only required to edit the functions and build the resulting module.
// TODO: This could probably be automated via a `package.json` command...- Go to
./deps/san_steamworks.jsand copy the following:
distfolder (and all contents)callback.d.tsclient.d.tsindex.d.tsindex.jsLICENSEpackage.jsonREADME.md
- Paste into
./deps/steamworks.js(create if not present) - Go back to the project root
- If not done already, open
package.jsonand add the following:
"dependencies": {
"steamworks.js": "./deps/steamworks.js"
}- Run the following command in the root directory:
npm i
This will add ./deps/steamworks.js as a dependency (and recreate it in ./node_modules/steamworks.js), so you can now use steamworks.js within Electron - including all your changes!