Coder Social home page Coder Social logo

steamwrap's Introduction

SteamWrap

Simple Haxe native extension Steam API wrapper. This code originally shipped in Papers, Please and the changes in this fork were made for the PC release of rymdkapsel. Windows, OS X and Linux/SteamOS builds are supported.

Current Features:

  • Achievements & Leaderboards
  • Steam Controller Support
  • UGC (user generated content)
  • Stats (not well-tested)

This repository comes with prebuilt binaries, which means it should work "out of the box".

(I'm in the process of updating the binaries, right now all it has is Windows)

Dependencies / Requirements:

  • Haxe 3.2 or greater
  • hxcpp 3.2.205 or greater
  • OpenFL 3.6 or greater
  • lime 2.8.3 or greater

Probably works with NME as well but I'm unsure of the requirements there. Ask Hugh.

To include steamwrap.ndll in your OpenFL or NME project:

  1. Install the library:

    latest git version: haxelib git steamwrap https://github.com/larsiusprime/SteamWrap

  2. Add the following nodes to your project.xml (assumes OpenFL or NME for now):

   <!-- Replace the question marks with your Steam App ID -->
   <setenv name="STEAM_APP_ID" value="??????" />

   <!-- OS X only: Set this value to the same value as the file property of your <app> node, this is needed to embed things into the generated .app file -->
   <!-- Setting this for other platforms won't do any harm, so you can safely leave it enabled for everything -->
   <set name="APP_FILE" value="??????" />
   
   <haxelib name="steamwrap"/>
  1. If you are doing non-Steam builds as well, it is practical to wrap this in a conditional. Run your builds as: openfl test <platform> -Dsteam to enable it, for example: openfl test windows -Dsteam.
   <section if="steam">
   	<!-- Steam specifics go here -->
   </section>
**!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!**

**This extension will automatically create a steam_appid.txt in your binary folder.**
**Do not ship your game with this file. Make sure it's stripped during the publishing stage.**

**Compiling with the "-Dfinal" flag should suppress creation of the steam_appid.txt**

```openfl test windows -Dsteam -Dfinal``` (for instance)

**!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!**

Usage:

See steamwrap/example/Test.hx for a basic example.

To build steamwrap.ndll from source:

Automatic steps

  1. Run setup.bat (windows) or setup.sh (mac/linux) and enter the values it asks you for

Or you can set it up manually:


Manual steps:

  1. Copy the hxcpp headers:

     HAXE_DIR/lib/hxcpp/VERSION/include/hx/*.h -> STEAMWRAP_DIR/native/include/hx/*.h
    
  2. Copy the Steam SDK headers and libs:

     STEAMSDK_DIR/public/steam/*.h -> native/include/steam/*.h
     STEAMSDK_DIR/redistributable_bin/steam_api.dll -> native/lib/win32/
     STEAMSDK_DIR/redistributable_bin/steam_api.lib -> native/lib/win32/
     STEAMSDK_DIR/redistributable_bin/osx32/libsteam_api.dylib -> native/lib/osx64/
     STEAMSDK_DIR/redistributable_bin/linux32/libsteam_api.so -> native/lib/linux32/
     STEAMSDK_DIR/redistributable_bin/linux64/libsteam_api.so -> native/lib/linux64/
    
  3. Put some files in the build dir:

    Windows:

    	ndll/Windows/steam_appid.txt
    	STEAMSDK_DIR/redistributable_bin/steam_api.dll -> ndll/Windows
    

    Mac:

    	ndll/Mac64/steam_appid.txt
    	STEAMSDK_DIR/redistributable_bin/steam_api.lib -> ndll/Mac64/
    

    Linux:

    	ndll/Linux/steam_appid.txt
    	STEAMSDK_DIR/redistributable_bin/steam_api.so -> ndll/Linux/
    	
    	ndll/Linux64/steam_appid.txt
    	STEAMSDK_DIR/redistributable_bin/steam_api.so -> ndll/Linux64/
    

    WHAT THIS DOES:

    The steam_api dll/dylib/so file must be next to your platform's steamwrap.ndll file in order for the extension to work. The dll/dylib/so file has all of the actual Steam API functionality, and the ndll file allows your Haxe project to communicate with it.

    As for the steam_appid.txt file, it's only there to make the "Test" program work. That's because the "Test" program will appear in your platform's ndll/ folder when you use the "build.bat" or "build" script to compile it.

    In order for your test program to work it must be able to find:

    • steamwrap.ndll (so Haxe can talk to Steam)
    • steam_api.dll/dylib/so (to provide the Steam API)
    • steam_appid.txt (to make the Steam Client recognize your app as a particular Steam Game when testing)

Final Steps:

  1. Run the "build" script (it's a basic haxelib command shortcut). steamwrap.ndll will be output to ndll/[PLATFORM]

Note: For linux you should have g++-multilib installed.

That's great, but we want to make sure it works! Let's run something with it. If you run the Test program now, you'll notice it exits immediately, asking you to supply an app ID.

  1. Edit steamwrap/example/Test.hx to include your Steam App ID and achievement ID's, etc.

    Now you are ready to compile example/Test.hx. Run the build script again.

  2. Start the Steam client, leave it open in the background, and run the Test app to make sure it connects.

steamwrap's People

Contributors

larsiusprime avatar grapefrukt avatar leolannenmaki avatar yellowafterlife avatar nospoone avatar increpare avatar jcward avatar gama11 avatar markknol avatar yanrishatum avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.