├── .gitattributes ├── .gitignore ├── Documentation ├── ConditionalCompilationSymbols.JPG ├── ConfigurationManager.JPG ├── MonoGameSteamworksNet_01.png └── MonoGameSteamworksNet_03.jpg ├── LICENSE.txt ├── README.md ├── Samples ├── AchievementHunter │ ├── AchievementHunter.csproj │ ├── AchievementSample.cs │ ├── Classes │ │ └── StatsAndAchievements.cs │ ├── Content │ │ ├── Content.mgcb │ │ ├── Font.spritefont │ │ └── Ship.png │ ├── Icon.bmp │ ├── Icon.ico │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── app.manifest │ ├── steam_api.dll │ └── steam_appid.txt ├── Hello Steamworks.Net │ ├── Content │ │ ├── Content.mgcb │ │ └── Font.spritefont │ ├── Hello Steamworks.Net.csproj │ ├── HelloSteamworks.cs │ ├── Icon.bmp │ ├── Icon.ico │ ├── MonoGame.Framework.dll.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── app.manifest │ ├── packages.config │ ├── steam_api.dll │ └── steam_appid.txt └── Steamworks.Net MonoGame Integration │ ├── Content │ ├── Content.mgcb │ └── Font.spritefont │ ├── Icon.bmp │ ├── Icon.ico │ ├── MonoGame.Framework.dll.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Steamworks.Net MonoGame Integration.csproj │ ├── SteamworksIntegration.cs │ ├── app.manifest │ ├── packages.config │ ├── steam_api.dll │ └── steam_appid.txt ├── Steamworks.Net MonoGame Integration.sln ├── Steamworks.Net MonoGame Integration.sln.DotSettings └── Steamworks.Net ├── LICENSE.txt ├── README.md ├── libs-x86 ├── OSX-Linux │ ├── Steamworks.NET.dll │ └── libsteam_api.so └── Windows │ ├── Steamworks.NET.dll │ └── steam_api.dll ├── libs-x86_64 ├── OSX-Linux │ ├── Steamworks.NET.dll │ └── libsteam_api.so └── Windows │ ├── Steamworks.NET.dll │ └── steam_api64.dll ├── steam_api.bundle └── Contents │ ├── Info.plist │ └── MacOS │ └── libsteam_api.dylib └── steam_appid.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /Documentation/ConditionalCompilationSymbols.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Documentation/ConditionalCompilationSymbols.JPG -------------------------------------------------------------------------------- /Documentation/ConfigurationManager.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Documentation/ConfigurationManager.JPG -------------------------------------------------------------------------------- /Documentation/MonoGameSteamworksNet_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Documentation/MonoGameSteamworksNet_01.png -------------------------------------------------------------------------------- /Documentation/MonoGameSteamworksNet_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Documentation/MonoGameSteamworksNet_03.jpg -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licenses of: 2 | Steamworks.Net 3 | MonoGame 4 | Portions of MonoGame 5 | Steam Logo 6 | 7 | ------------------------------------------------------------------------------- 8 | 9 | The MIT License (MIT) 10 | 11 | Steamworks.Net Copyright (c) 2013-2018 Riley Labrecque 12 | MonoGame implementation Copyright (c) 2018 Marcel Härtel 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | ------------------------------------------------------------------------------- 33 | 34 | Microsoft Public License (Ms-PL) 35 | MonoGame - Copyright © 2009-2016 The MonoGame Team 36 | 37 | All rights reserved. 38 | 39 | This license governs use of the accompanying software. If you use the software, 40 | you accept this license. If you do not accept the license, do not use the 41 | software. 42 | 43 | 1. Definitions 44 | 45 | The terms "reproduce," "reproduction," "derivative works," and "distribution" 46 | have the same meaning here as under U.S. copyright law. 47 | 48 | A "contribution" is the original software, or any additions or changes to the 49 | software. 50 | 51 | A "contributor" is any person that distributes its contribution under this 52 | license. 53 | 54 | "Licensed patents" are a contributor's patent claims that read directly on its 55 | contribution. 56 | 57 | 2. Grant of Rights 58 | 59 | (A) Copyright Grant- Subject to the terms of this license, including the 60 | license conditions and limitations in section 3, each contributor grants you a 61 | non-exclusive, worldwide, royalty-free copyright license to reproduce its 62 | contribution, prepare derivative works of its contribution, and distribute its 63 | contribution or any derivative works that you create. 64 | 65 | (B) Patent Grant- Subject to the terms of this license, including the license 66 | conditions and limitations in section 3, each contributor grants you a 67 | non-exclusive, worldwide, royalty-free license under its licensed patents to 68 | make, have made, use, sell, offer for sale, import, and/or otherwise dispose of 69 | its contribution in the software or derivative works of the contribution in the 70 | software. 71 | 72 | 3. Conditions and Limitations 73 | 74 | (A) No Trademark License- This license does not grant you rights to use any 75 | contributors' name, logo, or trademarks. 76 | 77 | (B) If you bring a patent claim against any contributor over patents that you 78 | claim are infringed by the software, your patent license from such contributor 79 | to the software ends automatically. 80 | 81 | (C) If you distribute any portion of the software, you must retain all 82 | copyright, patent, trademark, and attribution notices that are present in the 83 | software. 84 | 85 | (D) If you distribute any portion of the software in source code form, you may 86 | do so only under this license by including a complete copy of this license with 87 | your distribution. If you distribute any portion of the software in compiled or 88 | object code form, you may only do so under a license that complies with this 89 | license. 90 | 91 | (E) The software is licensed "as-is." You bear the risk of using it. The 92 | contributors give no express warranties, guarantees or conditions. You may have 93 | additional consumer rights under your local laws which this license cannot 94 | change. To the extent permitted under your local laws, the contributors exclude 95 | the implied warranties of merchantability, fitness for a particular purpose and 96 | non-infringement. 97 | 98 | ------------------------------------------------------------------------------- 99 | 100 | The MIT License (MIT) 101 | Portions of MonoGame Copyright © The Mono.Xna Team 102 | 103 | Permission is hereby granted, free of charge, to any person obtaining a copy 104 | of this software and associated documentation files (the "Software"), to deal 105 | in the Software without restriction, including without limitation the rights 106 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 107 | copies of the Software, and to permit persons to whom the Software is 108 | furnished to do so, subject to the following conditions: 109 | 110 | The above copyright notice and this permission notice shall be included in 111 | all copies or substantial portions of the Software. 112 | 113 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 114 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 115 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 116 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 117 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 118 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 119 | THE SOFTWARE. 120 | 121 | ------------------------------------------------------------------------------- 122 | 123 | Steam Logo Copyright 124 | 125 | © 2018 Valve Corporation. All rights reserved. Valve, the Valve logo, 126 | Half-Life, the Half-Life logo, the Lambda logo, Steam, the Steam logo, 127 | Team Fortress, the Team Fortress logo, Opposing Force, Day of Defeat, 128 | the Day of Defeat logo, Counter-Strike, the Counter-Strike logo, Source, 129 | the Source logo, Counter-Strike: Condition Zero, Portal, the Portal logo, 130 | Dota, the Dota 2 logo, and Defense of the Ancients are trademarks and/or 131 | registered trademarks of Valve Corporation. All other trademarks are 132 | property of their respective owners. 133 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Steamworks.Net MonoGame Integration 2 | This repo is for everyone who is about to integrate the Steamworks.Net.dll into a MonoGame project. It shows some Steamworks.Net features and how easy it is to integrate it into a MonoGame project. 3 | 4 | ![HelloSteamworks](Documentation/MonoGameSteamworksNet_03.jpg) 5 | ![HelloSteamworks](Documentation/MonoGameSteamworksNet_01.png) 6 | 7 | ### Building 8 | 9 | The following is required to successfully compile the solution: 10 | 11 | - MonoGame 3.6 12 | - [Steamworks.Net](https://github.com/rlabrecque/Steamworks.NET) Precompiled .dlls are included in this repo. They are targeting **Steam SDK 1.42** (Steamworks.Net 11.0.0) 13 | 14 | ### How To 15 | 16 | To set up your own MonoGame with Steamworks.Net integration project you need to do the following steps: 17 | 18 | - Add the **Steamworks.Net.dll** as a reference 19 | - Add **steam_api.dll** as a new file to the project and set "copy to output directory" to "copy if newer" 20 | - Add **steam_appid.txt** as a new file to the project and set "copy to output directory" to "copy if newer" 21 | 22 | - Don't forget to add that file as a ```FileExclusion``` to your Steamworks build-script since you don't want that file to be copied to your customer's destination directory, since it's for debugging purposes only (it lets you try all the steam-stuff without actually having that game listed and active on steam and is important for debugging directly from out of Visual Studio). 23 | Your ```depot_build_xxxxxx.vdf``` you're referencing in your ```app_build_xxxxxx.vdf``` should end like this: 24 | 25 | `````` 26 | // but exclude all symbol files 27 | // This can be a full path, or a path relative to ContentRoot 28 | "FileExclusion" "*.pdb" 29 | "FileExclusion" "steam_appid.txt" 30 | } 31 | `````` 32 | 33 | - Add your desired **Steamworks AppID** to the steam_appid.txt file 34 | 35 | - Initialize the API with the method **SteamAPI.Init()** like this: 36 | 37 | ```cs 38 | using Steamworks; 39 | 40 | protected override void Initialize() 41 | { 42 | try 43 | { 44 | if (!SteamAPI.Init()) Console.WriteLine("SteamAPI.Init() failed!"); 45 | else isSteamRunning = true; 46 | } 47 | catch (DllNotFoundException e) 48 | { 49 | Console.WriteLine(e); 50 | } 51 | } 52 | ``` 53 | 54 | - Update callbacks with **SteamAPI.RunCallbacks();** like this: 55 | 56 | ```cs 57 | protected override void Update(GameTime gameTime) 58 | { 59 | if (isSteamRunning == true) SteamAPI.RunCallbacks(); 60 | 61 | base.Update(gameTime); 62 | } 63 | ``` 64 | 65 | - ShutDown the Api with **SteamAPI.Shutdown();** like this: 66 | 67 | ```cs 68 | private void Game1_Exiting(object sender, EventArgs e) 69 | { 70 | SteamAPI.Shutdown(); 71 | } 72 | ``` 73 | 74 | > Add the EventHandler **Exiting += Game1_Exiting** and then the SteamAPI.Shutdown() method. 75 | 76 | You should be able to build and run the project now. 77 | It may be possible that you will receive the following exception: 78 | 79 | ```js 80 | An unhandled exception of type 'System.BadImageFormatException' occurred in SWTEST.exe 81 | 82 | Additional information: Could not load file or assembly 83 | 'Steamworks.NET, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null' 84 | or one of its dependencies. 85 | An attempt was made to load a program with an incorrect format. 86 | ``` 87 | 88 | In this case you need to make sure, that you took the right assemblies for your target platform. 89 | E.g. When you took the assemblies from the repo directory 90 | "Steamworks.Net-MonoGame-Integration/Steamworks.NET/Windows-x86/", then you need to configure 91 | your project to build it for the x86 platform. Use the integrated configuration manager 92 | to create or choose the right platform. It will look like this: 93 | 94 | ![](https://github.com/sqrMin1/Steamworks.Net-MonoGame-Integration/blob/master/Documentation/ConfigurationManager.JPG) 95 | 96 | You should also define the right "conditional compilation symbols": 97 | 98 | ![](https://github.com/sqrMin1/Steamworks.Net-MonoGame-Integration/blob/master/Documentation/ConditionalCompilationSymbols.JPG) 99 | 100 | Type in "WINDOWS", when building for the windows platform and "LINUX", when building for linux. 101 | 102 | Latest now it should build without an exception. 103 | 104 | ## Samples 105 | 106 | - **Hello Steamworks.Net**: Simple sample which sets up bare basics of Steamworks.Net and displaying a welcome message which includes your steam user name. 107 | - **AchievementHunter**: Simple sample which shows you the correct way of implementing achievements and stats as well as storing them on the steam server. It's based upon the Steamworks Example 'SpaceWar' included with the Steamworks SDK. 108 | - **Steamworks.Net MonoGame Integration**: Extendend sample which shows some features of Steamworks.Net like UserStats, PersonaState, LeaderboardData, NumberOfCurrentPlayers, Steam User Avatar and so on. 109 | 110 | > Note: You need to start your steam client before executing the examples. Otherwise you won't receive any data -obviously ;) 111 | 112 | **Have fun!** 113 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/AchievementHunter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8.0.30703 8 | 2.0 9 | {DD842683-2485-407C-945D-DB80167A99F5} 10 | Exe 11 | Properties 12 | AchievementHunter 13 | AchievementHunter 14 | 512 15 | DesktopGL 16 | v4.5 17 | 18 | 19 | true 20 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 21 | DEBUG;TRACE;LINUX 22 | full 23 | AnyCPU 24 | prompt 25 | false 26 | 4 27 | 28 | 29 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 30 | TRACE;LINUX 31 | true 32 | pdbonly 33 | AnyCPU 34 | prompt 35 | false 36 | 4 37 | 38 | 39 | Icon.ico 40 | 41 | 42 | app.manifest 43 | 44 | 45 | true 46 | bin\x86\Debug\ 47 | DEBUG;TRACE;LINUX 48 | full 49 | x86 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | bin\x86\Release\ 55 | TRACE;LINUX 56 | true 57 | pdbonly 58 | x86 59 | prompt 60 | MinimumRecommendedRules.ruleset 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll 74 | 75 | 76 | False 77 | ..\..\Steamworks.Net\libs-x86\Windows\Steamworks.NET.dll 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | x86\SDL2.dll 90 | PreserveNewest 91 | 92 | 93 | x64\SDL2.dll 94 | PreserveNewest 95 | 96 | 97 | x86\soft_oal.dll 98 | PreserveNewest 99 | 100 | 101 | x64\soft_oal.dll 102 | PreserveNewest 103 | 104 | 105 | x86\libSDL2-2.0.so.0 106 | PreserveNewest 107 | 108 | 109 | x64\libSDL2-2.0.so.0 110 | PreserveNewest 111 | 112 | 113 | x86\libopenal.so.1 114 | PreserveNewest 115 | 116 | 117 | x64\libopenal.so.1 118 | PreserveNewest 119 | 120 | 121 | libSDL2-2.0.0.dylib 122 | PreserveNewest 123 | 124 | 125 | libopenal.1.dylib 126 | PreserveNewest 127 | 128 | 129 | MonoGame.Framework.dll.config 130 | PreserveNewest 131 | 132 | 133 | 134 | 135 | 136 | Always 137 | 138 | 139 | Always 140 | 141 | 142 | 143 | 144 | 151 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/AchievementSample.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using Microsoft.Xna.Framework.Input; 4 | using System; 5 | using Steamworks; 6 | using AchievementHunter.Classes; 7 | 8 | namespace AchievementHunter 9 | { 10 | public class AchievementSample : Game 11 | { 12 | // Enum for possible game states on the client 13 | public enum EClientGameState 14 | { 15 | k_EClientGameWinner, 16 | k_EClientGameLoser 17 | }; 18 | 19 | GraphicsDeviceManager graphics; 20 | SpriteBatch spriteBatch; 21 | 22 | Rectangle ShipPosition, WinGamePosition, LoseGamePosition, ResetAllPosition; 23 | Texture2D ShipTexture, Pixel; 24 | 25 | KeyboardState oldKeys; 26 | 27 | // Do not use 'SteamApi.IsSteamRunning()'! It's not reliable and slow 28 | //see: https://github.com/rlabrecque/Steamworks.NET/issues/30 29 | public static bool IsSteamRunning { get; set; } = false; 30 | 31 | //Error Message: Steam Client not running. 32 | private const string STEAM_NOT_RUNNING_ERROR_MESSAGE = "Please start your steam client to receive data!"; 33 | 34 | //Description Message: How to control the ship. 35 | private const string DESCRIPTION_MESSAGE = "Use [W] [A] [S] [D] to control the ship!"; 36 | 37 | // Store screen dimensions. 38 | public static int ScreenWidth, ScreenHeight; 39 | 40 | public static SpriteFont Font { get; private set; } 41 | 42 | private StatsAndAchievements StatsAndAchievements { get; set; } 43 | 44 | public AchievementSample() 45 | { 46 | graphics = new GraphicsDeviceManager(this); 47 | Content.RootDirectory = "Content"; 48 | 49 | // The following lines restart your game through the Steam-client in case someone started it by double-clicking the exe. 50 | try 51 | { 52 | if (SteamAPI.RestartAppIfNecessary((AppId_t)480)) 53 | { 54 | Console.Out.WriteLine("Game wasn't started by Steam-client. Restarting."); 55 | Exit(); 56 | } 57 | } 58 | catch (DllNotFoundException e) 59 | { 60 | // We check this here as it will be the first instance of it. 61 | Console.Out.WriteLine("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib." + 62 | " It's likely not in the correct location. Refer to the README for more details.\n" + 63 | e); 64 | Exit(); 65 | } 66 | } 67 | 68 | protected override void Initialize() 69 | { 70 | try 71 | { 72 | if (!SteamAPI.Init()) 73 | { 74 | Console.WriteLine("SteamAPI.Init() failed!"); 75 | } 76 | else 77 | { 78 | // Set the "IsSteamRunning" flag to true 79 | IsSteamRunning = true; 80 | 81 | // Set overlay position 82 | SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionBottomRight); 83 | 84 | // Create new stats and achievement object 85 | StatsAndAchievements = new StatsAndAchievements(); 86 | 87 | // Add exiting event to close the steamapi on exit 88 | Exiting += Game1_Exiting; 89 | } 90 | } 91 | catch (DllNotFoundException e) 92 | { 93 | // We check this here as it will be the first instance of it 94 | Console.WriteLine(e); 95 | Exit(); 96 | } 97 | 98 | IsFixedTimeStep = true; 99 | graphics.SynchronizeWithVerticalRetrace = true; 100 | 101 | graphics.PreferredBackBufferWidth = 1280; 102 | graphics.PreferredBackBufferHeight = 720; 103 | graphics.ApplyChanges(); 104 | 105 | ScreenWidth = graphics.PreferredBackBufferWidth; 106 | ScreenHeight = graphics.PreferredBackBufferHeight; 107 | 108 | Window.Position = new Point(GraphicsDevice.DisplayMode.Width / 2 - graphics.PreferredBackBufferWidth / 2, 109 | GraphicsDevice.DisplayMode.Height / 2 - graphics.PreferredBackBufferHeight / 2 - 25); 110 | 111 | IsMouseVisible = true; 112 | 113 | base.Initialize(); 114 | } 115 | 116 | /// 117 | /// Replaces characters not supported by your spritefont. 118 | /// 119 | /// The font. 120 | /// The input string. 121 | /// The string to replace illegal characters with. 122 | /// 123 | public static string ReplaceUnsupportedChars(SpriteFont font, string input, string replaceString = "") 124 | { 125 | string result = ""; 126 | if (input == null) 127 | { 128 | return null; 129 | } 130 | 131 | foreach (char c in input) 132 | { 133 | if (font.Characters.Contains(c) || c == '\r' || c == '\n') 134 | { 135 | result += c; 136 | } 137 | else 138 | { 139 | result += replaceString; 140 | } 141 | } 142 | return result; 143 | } 144 | 145 | private void Game1_Exiting(object sender, EventArgs e) 146 | { 147 | SteamAPI.Shutdown(); 148 | } 149 | 150 | protected override void LoadContent() 151 | { 152 | spriteBatch = new SpriteBatch(GraphicsDevice); 153 | 154 | Font = Content.Load(@"Font"); 155 | ShipTexture = Content.Load(@"Ship"); 156 | 157 | ResetShip(true); 158 | 159 | WinGamePosition = new Rectangle(20, ScreenHeight / 2, 150, 150); 160 | LoseGamePosition = new Rectangle(20, (ScreenHeight / 2) + 180, 150, 150); 161 | ResetAllPosition = new Rectangle((ScreenWidth / 2) - 75, 20, 150, 150); 162 | 163 | Pixel = new Texture2D(GraphicsDevice, 1, 1); 164 | Pixel.SetData(new[] { Color.White }); 165 | } 166 | 167 | protected override void UnloadContent() 168 | { 169 | 170 | } 171 | 172 | protected override void Update(GameTime gameTime) 173 | { 174 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) 175 | Exit(); 176 | 177 | if (IsSteamRunning) 178 | { 179 | #region ShipMovement 180 | 181 | if (Keyboard.GetState().IsKeyDown(Keys.W)) 182 | { 183 | ShipPosition.Y = MathHelper.Clamp(ShipPosition.Y - 5, 0, ScreenHeight); 184 | StatsAndAchievements.AddDistanceTraveled(3.0f); 185 | } 186 | if (Keyboard.GetState().IsKeyDown(Keys.A)) 187 | { 188 | ShipPosition.X = MathHelper.Clamp(ShipPosition.X - 5, 0, ScreenWidth); 189 | StatsAndAchievements.AddDistanceTraveled(3.0f); 190 | } 191 | if (Keyboard.GetState().IsKeyDown(Keys.S)) 192 | { 193 | ShipPosition.Y = MathHelper.Clamp(ShipPosition.Y + 5, 0, ScreenHeight - ShipTexture.Height); 194 | StatsAndAchievements.AddDistanceTraveled(3.0f); 195 | } 196 | if (Keyboard.GetState().IsKeyDown(Keys.D)) 197 | { 198 | ShipPosition.X = MathHelper.Clamp(ShipPosition.X + 5, 0, ScreenWidth - ShipTexture.Width); 199 | StatsAndAchievements.AddDistanceTraveled(3.0f); 200 | } 201 | 202 | #endregion 203 | 204 | #region ShipCollisionDetection 205 | 206 | if (ShipPosition.Intersects(ResetAllPosition)) 207 | { 208 | ResetShip(true); 209 | SteamUserStats.ResetAllStats(true); 210 | SteamUserStats.RequestCurrentStats(); 211 | StatsAndAchievements.ResetDistanceTraveled(); 212 | } 213 | 214 | if (ShipPosition.Intersects(WinGamePosition)) 215 | { 216 | ResetShip(false); 217 | StatsAndAchievements.OnGameStateChange(EClientGameState.k_EClientGameWinner); 218 | } 219 | 220 | if (ShipPosition.Intersects(LoseGamePosition)) 221 | { 222 | ResetShip(false); 223 | StatsAndAchievements.OnGameStateChange(EClientGameState.k_EClientGameLoser); 224 | } 225 | 226 | #endregion 227 | 228 | StatsAndAchievements.Update(); 229 | SteamAPI.RunCallbacks(); 230 | } 231 | 232 | oldKeys = Keyboard.GetState(); 233 | base.Update(gameTime); 234 | } 235 | 236 | protected override void Draw(GameTime gameTime) 237 | { 238 | GraphicsDevice.Clear(Color.Black); 239 | 240 | spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearClamp, 241 | DepthStencilState.None, RasterizerState.CullCounterClockwise); 242 | 243 | if (IsSteamRunning) 244 | { 245 | // WinGame Rectangle 246 | spriteBatch.Draw(Pixel, WinGamePosition, Color.Blue); 247 | spriteBatch.DrawString(Font, "Win_Game!", new Vector2( 248 | WinGamePosition.X + (WinGamePosition.Width / 2) - (Font.MeasureString("Win_Game!").X / 2), 249 | WinGamePosition.Y + (WinGamePosition.Height / 2) - (Font.MeasureString("Win_Game!").Y / 2)), Color.White); 250 | 251 | // LoseGame Rectangle 252 | spriteBatch.Draw(Pixel, LoseGamePosition, Color.Red); 253 | spriteBatch.DrawString(Font, "Lose_Game!", new Vector2( 254 | LoseGamePosition.X + (LoseGamePosition.Width / 2) - (Font.MeasureString("Lose_Game!").X / 2), 255 | LoseGamePosition.Y + (LoseGamePosition.Height / 2) - (Font.MeasureString("Lose_Game!").Y / 2)), Color.White); 256 | 257 | // ResetAll Rectangle 258 | spriteBatch.Draw(Pixel, ResetAllPosition, Color.Yellow); 259 | spriteBatch.DrawString(Font, "Reset_ALL!", new Vector2( 260 | ResetAllPosition.X + (ResetAllPosition.Width / 2) - (Font.MeasureString("Reset_ALL!").X / 2), 261 | ResetAllPosition.Y + (ResetAllPosition.Height / 2) - (Font.MeasureString("Reset_ALL!").Y / 2)), Color.Black); 262 | 263 | // Draw the ship (MonoGame logo) 264 | spriteBatch.Draw(ShipTexture, ShipPosition, Color.White); 265 | 266 | // Description 267 | spriteBatch.DrawString(Font, DESCRIPTION_MESSAGE, new Vector2( 268 | ScreenWidth - (Font.MeasureString(DESCRIPTION_MESSAGE).X * 2), 269 | ScreenHeight - Font.MeasureString(DESCRIPTION_MESSAGE).Y - 20), Color.GreenYellow); 270 | 271 | StatsAndAchievements.Draw(spriteBatch); 272 | } 273 | else 274 | { 275 | // Error Message 276 | spriteBatch.DrawString(Font, STEAM_NOT_RUNNING_ERROR_MESSAGE, new Vector2( 277 | (ScreenWidth / 2) - (Font.MeasureString(STEAM_NOT_RUNNING_ERROR_MESSAGE).X / 2), 278 | (ScreenHeight / 2) - (Font.MeasureString(STEAM_NOT_RUNNING_ERROR_MESSAGE).Y / 2)), Color.GreenYellow); 279 | } 280 | 281 | spriteBatch.End(); 282 | 283 | base.Draw(gameTime); 284 | } 285 | 286 | /// 287 | /// Reset the ship to the screen center. 288 | /// 289 | private void ResetShip(bool forceScreenCenter) 290 | { 291 | if (IsSteamRunning && StatsAndAchievements != null) 292 | { 293 | ShipPosition = new Rectangle( 294 | (StatsAndAchievements.m_nTotalGamesPlayed > 7 && !forceScreenCenter ? 295 | 200 : (ScreenWidth / 2) - (ShipTexture.Width / 2)), 296 | (ScreenHeight / 2), ShipTexture.Width, ShipTexture.Height); 297 | } 298 | } 299 | } 300 | } 301 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/Classes/StatsAndAchievements.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using System; 4 | using Steamworks; 5 | 6 | namespace AchievementHunter.Classes 7 | { 8 | // This is a port of StatsAndAchievements.cpp from SpaceWar, the official Steamworks Example. 9 | public class StatsAndAchievements 10 | { 11 | private class Achievement_t 12 | { 13 | public Achievement m_eAchievementID; 14 | public string m_strName; 15 | public string m_strDescription; 16 | public bool m_bAchieved; 17 | 18 | /// 19 | /// Creates an Achievement. You must also mirror the data provided here in https://partner.steamgames.com/apps/achievements/yourappid 20 | /// 21 | /// The "API Name Progress Stat" used to uniquely identify the achievement. 22 | /// The "Display Name" that will be shown to players in game and on the Steam Community. 23 | /// The "Description" that will be shown to players in game and on the Steam Community. 24 | public Achievement_t(Achievement achievementID, string name, string desc) 25 | { 26 | m_eAchievementID = achievementID; 27 | m_strName = name; 28 | m_strDescription = desc; 29 | m_bAchieved = false; 30 | } 31 | } 32 | 33 | public enum Achievement : int 34 | { 35 | ACH_WIN_ONE_GAME, 36 | ACH_WIN_100_GAMES, 37 | ACH_HEAVY_FIRE, 38 | ACH_TRAVEL_FAR_ACCUM, 39 | ACH_TRAVEL_FAR_SINGLE, 40 | }; 41 | 42 | private Achievement_t[] m_Achievements = new Achievement_t[] 43 | { 44 | new Achievement_t(Achievement.ACH_WIN_ONE_GAME, "Winner", ""), 45 | new Achievement_t(Achievement.ACH_WIN_100_GAMES, "Champion", ""), 46 | new Achievement_t(Achievement.ACH_TRAVEL_FAR_ACCUM, "Interstellar", ""), 47 | new Achievement_t(Achievement.ACH_TRAVEL_FAR_SINGLE, "Orbiter", "") 48 | }; 49 | 50 | // Our GameID 51 | private CGameID m_GameID; 52 | 53 | // Did we get the stats from Steam? 54 | private bool m_bRequestedStats; 55 | private bool m_bStatsValid; 56 | 57 | // Should we store stats this frame? 58 | private bool m_bStoreStats; 59 | 60 | // Current Stat details 61 | 62 | /// 63 | /// Accumulate distance traveled. 64 | /// 65 | /// Distance to add. 66 | public void AddDistanceTraveled(float flDistance) 67 | { 68 | m_flGameFeetTraveled += flDistance; 69 | } 70 | private float m_flGameFeetTraveled; 71 | 72 | // Persisted Stat details 73 | public int m_nTotalGamesPlayed; 74 | private int m_nTotalNumWins; 75 | private int m_nTotalNumLosses; 76 | private float m_flTotalFeetTraveled; 77 | private float m_flMaxFeetTraveled; 78 | 79 | protected Callback m_UserStatsReceived; 80 | protected Callback m_UserStatsStored; 81 | protected Callback m_UserAchievementStored; 82 | 83 | /// 84 | /// We have stats data from Steam. It is authoritative, so update our data with those results now. 85 | /// 86 | /// 87 | private void OnUserStatsReceived(UserStatsReceived_t pCallback) 88 | { 89 | if (!AchievementSample.IsSteamRunning) 90 | return; 91 | 92 | // we may get callbacks for other games' stats arriving, ignore them 93 | if ((ulong)m_GameID == pCallback.m_nGameID) 94 | { 95 | if (EResult.k_EResultOK == pCallback.m_eResult) 96 | { 97 | Console.WriteLine("Received stats and achievements from Steam\n"); 98 | 99 | m_bStatsValid = true; 100 | 101 | // load achievements 102 | foreach (Achievement_t ach in m_Achievements) 103 | { 104 | bool ret = SteamUserStats.GetAchievement(ach.m_eAchievementID.ToString(), out ach.m_bAchieved); 105 | if (ret) 106 | { 107 | ach.m_strName = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "name"); 108 | ach.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "desc"); 109 | } 110 | else 111 | { 112 | Console.WriteLine("SteamUserStats.GetAchievement failed for Achievement " + ach.m_eAchievementID + "\nIs it registered in the Steam Partner site?"); 113 | } 114 | } 115 | 116 | // load stats 117 | SteamUserStats.GetStat("NumGames", out m_nTotalGamesPlayed); 118 | SteamUserStats.GetStat("NumWins", out m_nTotalNumWins); 119 | SteamUserStats.GetStat("NumLosses", out m_nTotalNumLosses); 120 | SteamUserStats.GetStat("FeetTraveled", out m_flTotalFeetTraveled); 121 | SteamUserStats.GetStat("MaxFeetTraveled", out m_flMaxFeetTraveled); 122 | } 123 | else 124 | { 125 | Console.WriteLine("RequestStats - failed, " + pCallback.m_eResult); 126 | } 127 | } 128 | } 129 | 130 | /// 131 | /// Our stats data was stored! 132 | /// 133 | /// Our callback. 134 | private void OnUserStatsStored(UserStatsStored_t pCallback) 135 | { 136 | // we may get callbacks for other games' stats arriving, ignore them 137 | if ((ulong)m_GameID == pCallback.m_nGameID) 138 | { 139 | if (EResult.k_EResultOK == pCallback.m_eResult) 140 | { 141 | Console.WriteLine("StoreStats - success"); 142 | } 143 | else if (EResult.k_EResultInvalidParam == pCallback.m_eResult) 144 | { 145 | // One or more stats we set broke a constraint. They've been reverted, 146 | // and we should re-iterate the values now to keep in sync. 147 | Console.WriteLine("StoreStats - some failed to validate"); 148 | // Fake up a callback here so that we re-load the values. 149 | UserStatsReceived_t callback = new UserStatsReceived_t(); 150 | callback.m_eResult = EResult.k_EResultOK; 151 | callback.m_nGameID = (ulong)m_GameID; 152 | OnUserStatsReceived(callback); 153 | } 154 | else 155 | { 156 | Console.WriteLine("StoreStats - failed, " + pCallback.m_eResult); 157 | } 158 | } 159 | } 160 | 161 | /// 162 | /// Unlock this achievement. 163 | /// 164 | /// This achievement get unlocked. 165 | private void UnlockAchievement(Achievement_t achievement) 166 | { 167 | achievement.m_bAchieved = true; 168 | 169 | // the icon may change once it's unlocked 170 | //achievement.m_iIconImage = 0; 171 | 172 | // mark it down 173 | SteamUserStats.SetAchievement(achievement.m_eAchievementID.ToString()); 174 | 175 | // Store stats end of frame 176 | m_bStoreStats = true; 177 | } 178 | 179 | /// 180 | /// An achievement was stored. 181 | /// 182 | /// Our callback 183 | private void OnAchievementStored(UserAchievementStored_t pCallback) 184 | { 185 | // We may get callbacks for other games' stats arriving, ignore them 186 | if ((ulong)m_GameID == pCallback.m_nGameID) 187 | { 188 | if (pCallback.m_nMaxProgress == 0) 189 | { 190 | Console.WriteLine("Achievement '" + pCallback.m_rgchAchievementName + "' unlocked!"); 191 | } 192 | else 193 | { 194 | Console.WriteLine("Achievement '" + pCallback.m_rgchAchievementName + "' progress callback, (" + pCallback.m_nCurProgress + "," + pCallback.m_nMaxProgress + ")"); 195 | } 196 | } 197 | } 198 | 199 | public StatsAndAchievements() 200 | { 201 | // Cache the GameID for use in the Callbacks 202 | m_GameID = new CGameID(SteamUtils.GetAppID()); 203 | 204 | m_UserStatsReceived = Callback.Create(OnUserStatsReceived); 205 | m_UserStatsStored = Callback.Create(OnUserStatsStored); 206 | m_UserAchievementStored = Callback.Create(OnAchievementStored); 207 | 208 | // These need to be reset to get the stats upon an Assembly reload in the Editor. 209 | m_bRequestedStats = false; 210 | m_bStatsValid = false; 211 | } 212 | 213 | public void Update() 214 | { 215 | if (!m_bRequestedStats) 216 | { 217 | // Is Steam Loaded? if no, can't get stats, done 218 | if (!AchievementSample.IsSteamRunning) 219 | { 220 | m_bRequestedStats = true; 221 | return; 222 | } 223 | 224 | // If yes, request our stats 225 | bool bSuccess = SteamUserStats.RequestCurrentStats(); 226 | 227 | // This function should only return false if we weren't logged in, and we already checked that. 228 | // But handle it being false again anyway, just ask again later. 229 | m_bRequestedStats = bSuccess; 230 | } 231 | 232 | if (!m_bStatsValid) 233 | return; 234 | 235 | // Get info from sources 236 | // Evaluate achievements 237 | foreach (Achievement_t achievement in m_Achievements) 238 | { 239 | if (achievement.m_bAchieved) 240 | continue; 241 | 242 | switch (achievement.m_eAchievementID) 243 | { 244 | case Achievement.ACH_WIN_ONE_GAME: 245 | if (m_nTotalNumWins != 0) 246 | { 247 | UnlockAchievement(achievement); 248 | } 249 | break; 250 | case Achievement.ACH_WIN_100_GAMES: 251 | if (m_nTotalNumWins >= 100) 252 | { 253 | UnlockAchievement(achievement); 254 | } 255 | break; 256 | case Achievement.ACH_TRAVEL_FAR_ACCUM: 257 | if (m_flTotalFeetTraveled >= 5280) 258 | { 259 | UnlockAchievement(achievement); 260 | } 261 | break; 262 | case Achievement.ACH_TRAVEL_FAR_SINGLE: 263 | if (m_flGameFeetTraveled >= 500) 264 | { 265 | UnlockAchievement(achievement); 266 | } 267 | break; 268 | } 269 | } 270 | 271 | //Store stats in the Steam database if necessary 272 | if (m_bStoreStats) 273 | { 274 | // already set any achievements in UnlockAchievement 275 | 276 | // set stats 277 | SteamUserStats.SetStat("NumGames", m_nTotalGamesPlayed); 278 | SteamUserStats.SetStat("NumWins", m_nTotalNumWins); 279 | SteamUserStats.SetStat("NumLosses", m_nTotalNumLosses); 280 | SteamUserStats.SetStat("FeetTraveled", m_flTotalFeetTraveled); 281 | SteamUserStats.SetStat("MaxFeetTraveled", m_flMaxFeetTraveled); 282 | 283 | bool bSuccess = SteamUserStats.StoreStats(); 284 | // If this failed, we never sent anything to the server, try 285 | // again later. 286 | m_bStoreStats = !bSuccess; 287 | } 288 | } 289 | 290 | public void Draw(SpriteBatch sB) 291 | { 292 | if (!AchievementSample.IsSteamRunning) 293 | return; 294 | 295 | string stats = $@" 296 | DistanceTraveled: {m_flGameFeetTraveled} 297 | 298 | NumGames: {m_nTotalGamesPlayed} 299 | NumWins: {m_nTotalNumWins} 300 | NumLosses: {m_nTotalNumLosses} 301 | FeetTraveled: {m_flTotalFeetTraveled} 302 | MaxFeetTraveled: {m_flMaxFeetTraveled}"; 303 | 304 | // Draw Stats 305 | sB.DrawString(AchievementSample.Font, 306 | AchievementSample.ReplaceUnsupportedChars(AchievementSample.Font, stats), new Vector2(20, 20), Color.White); 307 | 308 | //Draw Achievements 309 | for (int i = 0; i < m_Achievements.Length; i++) 310 | { 311 | string achievments = $@" 312 | ID: {m_Achievements[i].m_eAchievementID.ToString()} 313 | Name: {m_Achievements[i].m_strName} 314 | Description: {m_Achievements[i].m_strDescription} 315 | Achieved: {m_Achievements[i].m_bAchieved}"; 316 | 317 | string drawString = AchievementSample.ReplaceUnsupportedChars(AchievementSample.Font, achievments); 318 | 319 | sB.DrawString(AchievementSample.Font, drawString, new Vector2(AchievementSample.ScreenWidth - 320 | AchievementSample.Font.MeasureString(drawString).X - 20, 321 | AchievementSample.Font.MeasureString(drawString).Y * i), Color.White); 322 | } 323 | } 324 | 325 | #region DEBUGGING 326 | 327 | //Reset the traveled distance 328 | public void ResetDistanceTraveled() => m_flGameFeetTraveled = 0; 329 | 330 | /// 331 | /// Game state has changed (We use this to reset all achievements so we can test the unlocking of them again). 332 | /// 333 | /// 334 | public void OnGameStateChange(AchievementSample.EClientGameState eNewState) 335 | { 336 | if (!m_bStatsValid) 337 | return; 338 | 339 | if (eNewState == AchievementSample.EClientGameState.k_EClientGameWinner || 340 | eNewState == AchievementSample.EClientGameState.k_EClientGameLoser) 341 | { 342 | if (eNewState == AchievementSample.EClientGameState.k_EClientGameWinner) 343 | { 344 | m_nTotalNumWins++; 345 | } 346 | else 347 | { 348 | m_nTotalNumLosses++; 349 | } 350 | 351 | // Tally games 352 | m_nTotalGamesPlayed++; 353 | 354 | // Accumulate distances 355 | m_flTotalFeetTraveled += m_flGameFeetTraveled; 356 | 357 | // New max? 358 | if (m_flGameFeetTraveled > m_flMaxFeetTraveled) 359 | m_flMaxFeetTraveled = m_flGameFeetTraveled; 360 | 361 | ResetDistanceTraveled(); 362 | 363 | // We want to update stats the next frame. 364 | m_bStoreStats = true; 365 | } 366 | } 367 | 368 | #endregion 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin Font.spritefont 17 | /importer:FontDescriptionImporter 18 | /processor:FontDescriptionProcessor 19 | /processorParam:PremultiplyAlpha=True 20 | /processorParam:TextureFormat=Compressed 21 | /build:Font.spritefont 22 | 23 | #begin Ship.png 24 | /importer:TextureImporter 25 | /processor:TextureProcessor 26 | /processorParam:ColorKeyColor=255,0,255,255 27 | /processorParam:ColorKeyEnabled=True 28 | /processorParam:GenerateMipmaps=False 29 | /processorParam:PremultiplyAlpha=True 30 | /processorParam:ResizeToPowerOfTwo=False 31 | /processorParam:MakeSquare=False 32 | /processorParam:TextureFormat=Color 33 | /build:Ship.png 34 | 35 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/Content/Font.spritefont: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | Arial 15 | 16 | 20 | 14 21 | 22 | 26 | 0 27 | 28 | 32 | true 33 | 34 | 38 | 39 | 40 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | ~ 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/Content/Ship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/AchievementHunter/Content/Ship.png -------------------------------------------------------------------------------- /Samples/AchievementHunter/Icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/AchievementHunter/Icon.bmp -------------------------------------------------------------------------------- /Samples/AchievementHunter/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/AchievementHunter/Icon.ico -------------------------------------------------------------------------------- /Samples/AchievementHunter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AchievementHunter 4 | { 5 | /// 6 | /// The main class. 7 | /// 8 | public static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | using (var game = new AchievementSample()) 17 | game.Run(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AchievementHunter")] 9 | [assembly: AssemblyProduct("AchievementHunter")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d46131ed-f4c8-4ca6-9784-9ed10ae5bb34")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true/pm 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Samples/AchievementHunter/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/AchievementHunter/steam_api.dll -------------------------------------------------------------------------------- /Samples/AchievementHunter/steam_appid.txt: -------------------------------------------------------------------------------- 1 | 480 -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin Font.spritefont 17 | /importer:FontDescriptionImporter 18 | /processor:FontDescriptionProcessor 19 | /processorParam:PremultiplyAlpha=True 20 | /processorParam:TextureFormat=Compressed 21 | /build:Font.spritefont 22 | 23 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Content/Font.spritefont: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | Arial 15 | 16 | 20 | 16 21 | 22 | 26 | 0 27 | 28 | 32 | true 33 | 34 | 38 | 39 | 40 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | ~ 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Hello Steamworks.Net.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | 8.0.30703 8 | 2.0 9 | {E1300152-A874-46AA-948D-86FBABEF1F6F} 10 | WinExe 11 | Properties 12 | Hello_Steamworks.Net 13 | Hello Steamworks.Net 14 | 512 15 | DesktopGL 16 | v4.5 17 | 18 | 19 | true 20 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 21 | TRACE;DEBUG;WINDOWS 22 | full 23 | x86 24 | prompt 25 | false 26 | 4 27 | 28 | 29 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 30 | TRACE;LINUX 31 | true 32 | pdbonly 33 | x86 34 | prompt 35 | false 36 | 4 37 | 38 | 39 | Icon.ico 40 | 41 | 42 | app.manifest 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | ..\..\packages\MonoGame.Framework.DesktopGL.3.6.0.1625\lib\net40\MonoGame.Framework.dll 52 | True 53 | 54 | 55 | False 56 | ..\..\Steamworks.Net\libs-x86\Windows\Steamworks.NET.dll 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | x86\SDL2.dll 69 | PreserveNewest 70 | 71 | 72 | x64\SDL2.dll 73 | PreserveNewest 74 | 75 | 76 | x86\soft_oal.dll 77 | PreserveNewest 78 | 79 | 80 | x64\soft_oal.dll 81 | PreserveNewest 82 | 83 | 84 | x86\libSDL2-2.0.so.0 85 | PreserveNewest 86 | 87 | 88 | x64\libSDL2-2.0.so.0 89 | PreserveNewest 90 | 91 | 92 | x86\libopenal.so.1 93 | PreserveNewest 94 | 95 | 96 | x64\libopenal.so.1 97 | PreserveNewest 98 | 99 | 100 | libSDL2-2.0.0.dylib 101 | PreserveNewest 102 | 103 | 104 | libopenal.1.dylib 105 | PreserveNewest 106 | 107 | 108 | 109 | 110 | 111 | 112 | Always 113 | 114 | 115 | PreserveNewest 116 | 117 | 118 | 119 | 120 | 127 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/HelloSteamworks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using Microsoft.Xna.Framework.Input; 5 | using Steamworks; 6 | 7 | namespace Hello_Steamworks.Net 8 | { 9 | public class HelloSteamworks : Game 10 | { 11 | private readonly GraphicsDeviceManager graphics; 12 | private SpriteBatch spriteBatch; 13 | 14 | public SpriteFont Font { get; private set; } 15 | 16 | public string WelcomeMessage { get; private set; } = 17 | "Error: Please start your Steam Client before you run this example!"; 18 | 19 | public string WelcomeNote { get; } = "- Press [Shift + Tab] to open the Steam Overlay -"; 20 | 21 | // Do not use 'SteamApi.IsSteamRunning()'! It's not reliable and slow 22 | //see: https://github.com/rlabrecque/Steamworks.NET/issues/30 23 | public static bool IsSteamRunning { get; set; } = false; 24 | 25 | public HelloSteamworks() 26 | { 27 | graphics = new GraphicsDeviceManager(this); 28 | Content.RootDirectory = "Content"; 29 | 30 | // The following lines restart your game through the Steam-client in case someone started it by double-clicking the exe. 31 | try 32 | { 33 | if (SteamAPI.RestartAppIfNecessary((AppId_t)480)) 34 | { 35 | Console.Out.WriteLine("Game wasn't started by Steam-client. Restarting."); 36 | Exit(); 37 | } 38 | } 39 | catch (DllNotFoundException e) 40 | { 41 | // We check this here as it will be the first instance of it. 42 | Console.Out.WriteLine("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib." + 43 | " It's likely not in the correct location. Refer to the README for more details.\n" + 44 | e); 45 | Exit(); 46 | } 47 | } 48 | 49 | protected override void Initialize() 50 | { 51 | try 52 | { 53 | if (!SteamAPI.Init()) 54 | { 55 | Console.WriteLine("SteamAPI.Init() failed!"); 56 | } 57 | else 58 | { 59 | IsSteamRunning = true; 60 | 61 | SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionBottomRight); 62 | 63 | Exiting += Game1_Exiting; 64 | } 65 | } 66 | catch (DllNotFoundException e) 67 | { 68 | // We check this here as it will be the first instance of it. 69 | Console.WriteLine(e); 70 | Exit(); 71 | } 72 | 73 | Window.Position = new Point(GraphicsDevice.DisplayMode.Width / 2 - graphics.PreferredBackBufferWidth / 2, 74 | GraphicsDevice.DisplayMode.Height / 2 - graphics.PreferredBackBufferHeight / 2 - 25); 75 | 76 | base.Initialize(); 77 | } 78 | 79 | /// 80 | /// Replaces characters not supported by your spritefont. 81 | /// 82 | /// The font. 83 | /// The input string. 84 | /// The string to replace illegal characters with. 85 | /// 86 | public static string ReplaceUnsupportedChars(SpriteFont font, string input, string replaceString = "") 87 | { 88 | string result = ""; 89 | if (input == null) 90 | { 91 | return null; 92 | } 93 | 94 | foreach (char c in input) 95 | { 96 | if (font.Characters.Contains(c) || c == '\r' || c == '\n') 97 | { 98 | result += c; 99 | } 100 | else 101 | { 102 | result += replaceString; 103 | } 104 | } 105 | return result; 106 | } 107 | 108 | private void Game1_Exiting(object sender, EventArgs e) 109 | { 110 | SteamAPI.Shutdown(); 111 | } 112 | 113 | protected override void LoadContent() 114 | { 115 | // Create a new SpriteBatch, which can be used to draw textures. 116 | spriteBatch = new SpriteBatch(GraphicsDevice); 117 | 118 | Font = Content.Load(@"Font"); 119 | 120 | if (IsSteamRunning) 121 | { 122 | // Get your trimmed Steam User Name. 123 | string steamUserName = SteamFriends.GetPersonaName(); 124 | // Remove unsupported chars like emojis or other stuff our font cannot handle. 125 | steamUserName = ReplaceUnsupportedChars(Font, steamUserName); 126 | var userNameTrimmed = steamUserName.Trim(); 127 | WelcomeMessage = $"Hello {userNameTrimmed}!"; 128 | } 129 | } 130 | 131 | protected override void Update(GameTime gameTime) 132 | { 133 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || 134 | Keyboard.GetState().IsKeyDown(Keys.Escape)) 135 | { 136 | Exit(); 137 | } 138 | 139 | if (IsSteamRunning) SteamAPI.RunCallbacks(); 140 | 141 | base.Update(gameTime); 142 | } 143 | 144 | protected override void Draw(GameTime gameTime) 145 | { 146 | GraphicsDevice.Clear(Color.Black); 147 | spriteBatch.Begin(); 148 | 149 | // Draw WelcomeMessage. 150 | spriteBatch.DrawString(Font, WelcomeMessage, 151 | new Vector2(graphics.PreferredBackBufferWidth / 2f - Font.MeasureString(WelcomeMessage).X / 2f, 152 | graphics.PreferredBackBufferHeight / 2f - Font.MeasureString(WelcomeMessage).Y / 2f - 153 | (IsSteamRunning ? 20 : 0)), Color.GreenYellow); 154 | 155 | if (IsSteamRunning) 156 | { 157 | // Draw WelcomeNote. 158 | spriteBatch.DrawString(Font, WelcomeNote, 159 | new Vector2(graphics.PreferredBackBufferWidth / 2f - Font.MeasureString(WelcomeNote).X / 2f, 160 | graphics.PreferredBackBufferHeight / 2f - Font.MeasureString(WelcomeNote).Y / 2f + 20), 161 | Color.GreenYellow); 162 | } 163 | 164 | spriteBatch.End(); 165 | base.Draw(gameTime); 166 | } 167 | } 168 | } -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Hello Steamworks.Net/Icon.bmp -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Hello Steamworks.Net/Icon.ico -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/MonoGame.Framework.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Hello_Steamworks.Net.DesktopGL 4 | { 5 | /// 6 | /// The main class. 7 | /// 8 | public static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | using (var game = new HelloSteamworks()) 17 | game.Run(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Hello Steamworks.Net.DesktopGL")] 9 | [assembly: AssemblyProduct("Hello Steamworks.Net.DesktopGL")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d5bab696-272d-441b-83a2-b282199937fa")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true/pm 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Hello Steamworks.Net/steam_api.dll -------------------------------------------------------------------------------- /Samples/Hello Steamworks.Net/steam_appid.txt: -------------------------------------------------------------------------------- 1 | 480 -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin Font.spritefont 17 | /importer:FontDescriptionImporter 18 | /processor:FontDescriptionProcessor 19 | /processorParam:PremultiplyAlpha=True 20 | /processorParam:TextureFormat=Compressed 21 | /build:Font.spritefont 22 | 23 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Content/Font.spritefont: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | Arial 15 | 16 | 20 | 14 21 | 22 | 26 | 0 27 | 28 | 32 | true 33 | 34 | 38 | 39 | 40 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | ~ 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Steamworks.Net MonoGame Integration/Icon.bmp -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Steamworks.Net MonoGame Integration/Icon.ico -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/MonoGame.Framework.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Steamworks.Net_MonoGame_Integration.DesktopGL 4 | { 5 | /// 6 | /// The main class. 7 | /// 8 | public static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | using (var game = new SteamworksIntegration()) 17 | game.Run(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Steamworks.Net MonoGame Integration.DesktopGL")] 9 | [assembly: AssemblyProduct("Steamworks.Net MonoGame Integration.DesktopGL")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d8c1a229-a394-4b4c-8092-eaf941b425fc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/Steamworks.Net MonoGame Integration.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | 8.0.30703 8 | 2.0 9 | {63422818-DBA6-4944-9435-13C217F9B763} 10 | WinExe 11 | Properties 12 | Steamworks.Net_MonoGame_Integration 13 | Steamworks.Net MonoGame Integration 14 | 512 15 | DesktopGL 16 | v4.5 17 | 18 | 19 | true 20 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 21 | TRACE;DEBUG;WINDOWS 22 | full 23 | x86 24 | prompt 25 | false 26 | 4 27 | 28 | 29 | bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ 30 | TRACE;LINUX 31 | true 32 | pdbonly 33 | x86 34 | prompt 35 | false 36 | 4 37 | 38 | 39 | Icon.ico 40 | 41 | 42 | app.manifest 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | ..\..\packages\MonoGame.Framework.DesktopGL.3.6.0.1625\lib\net40\MonoGame.Framework.dll 52 | True 53 | 54 | 55 | False 56 | ..\..\Steamworks.Net\libs-x86\Windows\Steamworks.NET.dll 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | x86\SDL2.dll 69 | PreserveNewest 70 | 71 | 72 | x64\SDL2.dll 73 | PreserveNewest 74 | 75 | 76 | x86\soft_oal.dll 77 | PreserveNewest 78 | 79 | 80 | x64\soft_oal.dll 81 | PreserveNewest 82 | 83 | 84 | x86\libSDL2-2.0.so.0 85 | PreserveNewest 86 | 87 | 88 | x64\libSDL2-2.0.so.0 89 | PreserveNewest 90 | 91 | 92 | x86\libopenal.so.1 93 | PreserveNewest 94 | 95 | 96 | x64\libopenal.so.1 97 | PreserveNewest 98 | 99 | 100 | libSDL2-2.0.0.dylib 101 | PreserveNewest 102 | 103 | 104 | libopenal.1.dylib 105 | PreserveNewest 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Always 114 | 115 | 116 | PreserveNewest 117 | 118 | 119 | 120 | 121 | 128 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/SteamworksIntegration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using Microsoft.Xna.Framework.Input; 5 | 6 | namespace Steamworks.Net_MonoGame_Integration 7 | { 8 | public class SteamworksIntegration : Game 9 | { 10 | private readonly GraphicsDeviceManager graphics; 11 | private SpriteBatch spriteBatch; 12 | 13 | // Do not use 'SteamApi.IsSteamRunning()'! It's not reliable and slow 14 | //see: https://github.com/rlabrecque/Steamworks.NET/issues/30 15 | public static bool IsSteamRunning { get; set; } = false; 16 | 17 | public SpriteFont Font { get; private set; } 18 | public int ScreenWidth { get; private set; } 19 | public int ScreenHeight { get; private set; } 20 | private const string STEAM_NOT_RUNNING_ERROR_MESSAGE = "Please start your steam client to receive data!"; 21 | 22 | // Collectible data. 23 | private string SteamUserName { get; set; } = ""; 24 | private string CurrentLanguage { get; set; } = ""; 25 | private string AvailableLanguages { get; set; } = ""; 26 | private string InstallDir { get; set; } = ""; 27 | private Texture2D UserAvatar { get; set; } 28 | 29 | private static bool SteamOverlayActive { get; set; } 30 | private static string UserStats { get; set; } = ""; 31 | private static string PersonaState { get; set; } = ""; 32 | private static string LeaderboardData { get; set; } = ""; 33 | private static string NumberOfCurrentPlayers { get; set; } = ""; 34 | 35 | private uint PlayTimeInSeconds() => SteamUtils.GetSecondsSinceAppActive(); 36 | 37 | /// 38 | /// Get your steam avatar. 39 | /// Important: 40 | /// The returned Texture2D object is NOT loaded using a ContentManager. 41 | /// So it's your responsibility to dispose it at the end by calling . 42 | /// 43 | /// The GraphicsDevice 44 | /// Your Steam Avatar Image as a Texture2D object 45 | private Texture2D GetSteamUserAvatar(GraphicsDevice device) 46 | { 47 | // Get the icon type as a integer. 48 | var icon = SteamFriends.GetMediumFriendAvatar(SteamUser.GetSteamID()); 49 | 50 | // Check if we got an icon type. 51 | if (icon != 0) 52 | { 53 | uint width; 54 | uint height; 55 | var ret = SteamUtils.GetImageSize(icon, out width, out height); 56 | 57 | if (ret && width > 0 && height > 0) 58 | { 59 | var rgba = new byte[width * height * 4]; 60 | ret = SteamUtils.GetImageRGBA(icon, rgba, rgba.Length); 61 | if (ret) 62 | { 63 | var texture = new Texture2D(device, (int)width, (int)height, false, SurfaceFormat.Color); 64 | texture.SetData(rgba, 0, rgba.Length); 65 | return texture; 66 | } 67 | } 68 | } 69 | return null; 70 | } 71 | 72 | /// 73 | /// Replaces characters not supported by your spritefont. 74 | /// 75 | /// The font. 76 | /// The input string. 77 | /// The string to replace illegal characters with. 78 | /// 79 | public static string ReplaceUnsupportedChars(SpriteFont font, string input, string replaceString = "") 80 | { 81 | string result = ""; 82 | if (input == null) 83 | { 84 | return null; 85 | } 86 | 87 | foreach (char c in input) 88 | { 89 | if (font.Characters.Contains(c) || c == '\r' || c == '\n') 90 | { 91 | result += c; 92 | } 93 | else 94 | { 95 | result += replaceString; 96 | } 97 | } 98 | return result; 99 | } 100 | 101 | private static Callback mGameOverlayActivated; 102 | private static CallResult mNumberOfCurrentPlayers; 103 | private static CallResult mCallResultFindLeaderboard; 104 | private static Callback mPersonaStateChange; 105 | private static Callback mUserStatsReceived; 106 | 107 | /// 108 | /// Initialize some Steam Callbacks. 109 | /// 110 | private void InitializeCallbacks() 111 | { 112 | mGameOverlayActivated = Callback.Create(OnGameOverlayActivated); 113 | mNumberOfCurrentPlayers = CallResult.Create(OnNumberOfCurrentPlayers); 114 | mCallResultFindLeaderboard = CallResult.Create(OnFindLeaderboard); 115 | mPersonaStateChange = Callback.Create(OnPersonaStateChange); 116 | mUserStatsReceived = 117 | Callback.Create( 118 | pCallback => 119 | { 120 | UserStats = 121 | $"[{UserStatsReceived_t.k_iCallback} - UserStatsReceived] - {pCallback.m_eResult} -- {pCallback.m_nGameID} -- {pCallback.m_steamIDUser}"; 122 | }); 123 | } 124 | 125 | private static void OnGameOverlayActivated(GameOverlayActivated_t pCallback) 126 | { 127 | if (pCallback.m_bActive == 0) 128 | { 129 | // GameOverlay is not active. 130 | SteamOverlayActive = false; 131 | } 132 | else 133 | { 134 | // GameOverlay is active. 135 | SteamOverlayActive = true; 136 | } 137 | } 138 | 139 | private static void OnNumberOfCurrentPlayers(NumberOfCurrentPlayers_t pCallback, bool bIoFailure) 140 | { 141 | NumberOfCurrentPlayers = 142 | $"[{NumberOfCurrentPlayers_t.k_iCallback} - NumberOfCurrentPlayers] - {pCallback.m_bSuccess} -- {pCallback.m_cPlayers}"; 143 | } 144 | 145 | private static void OnFindLeaderboard(LeaderboardFindResult_t pCallback, bool bIoFailure) 146 | { 147 | LeaderboardData = 148 | $"[{LeaderboardFindResult_t.k_iCallback} - LeaderboardFindResult] - {pCallback.m_bLeaderboardFound} -- {pCallback.m_hSteamLeaderboard}"; 149 | } 150 | 151 | private static void OnPersonaStateChange(PersonaStateChange_t pCallback) 152 | { 153 | PersonaState = 154 | $"[{PersonaStateChange_t.k_iCallback} - PersonaStateChange] - {pCallback.m_ulSteamID} -- {pCallback.m_nChangeFlags}"; 155 | } 156 | 157 | public SteamworksIntegration() 158 | { 159 | graphics = new GraphicsDeviceManager(this); 160 | Content.RootDirectory = "Content"; 161 | 162 | // The following lines restart your game through the Steam-client in case someone started it by double-clicking the exe. 163 | try 164 | { 165 | if (SteamAPI.RestartAppIfNecessary((AppId_t)480)) 166 | { 167 | Console.Out.WriteLine("Game wasn't started by Steam-client. Restarting."); 168 | Exit(); 169 | } 170 | } 171 | catch (DllNotFoundException e) 172 | { 173 | // We check this here as it will be the first instance of it. 174 | Console.Out.WriteLine("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib." + 175 | " It's likely not in the correct location. Refer to the README for more details.\n" + 176 | e); 177 | Exit(); 178 | } 179 | } 180 | 181 | private void Game1_Exiting(object sender, EventArgs e) 182 | { 183 | SteamAPI.Shutdown(); 184 | UserAvatar?.Dispose(); 185 | } 186 | 187 | protected override void Initialize() 188 | { 189 | // TODO: Add your initialization logic here 190 | 191 | IsMouseVisible = true; 192 | 193 | ScreenWidth = graphics.PreferredBackBufferWidth; 194 | ScreenHeight = graphics.PreferredBackBufferHeight; 195 | 196 | Window.Position = new Point(GraphicsDevice.DisplayMode.Width / 2 - graphics.PreferredBackBufferWidth / 2, 197 | GraphicsDevice.DisplayMode.Height / 2 - graphics.PreferredBackBufferHeight / 2 - 25); 198 | 199 | graphics.SynchronizeWithVerticalRetrace = true; 200 | IsFixedTimeStep = false; 201 | base.Initialize(); 202 | } 203 | 204 | protected override void LoadContent() 205 | { 206 | // Create a new SpriteBatch, which can be used to draw textures. 207 | spriteBatch = new SpriteBatch(GraphicsDevice); 208 | 209 | // TODO: use this.Content to load your game content here 210 | 211 | Font = Content.Load(@"Font"); 212 | 213 | if (!SteamAPI.Init()) 214 | { 215 | Console.WriteLine("SteamAPI.Init() failed!"); 216 | } 217 | else 218 | { 219 | // Steam is running 220 | IsSteamRunning = true; 221 | 222 | // It's important that the next call happens AFTER the call to SteamAPI.Init(). 223 | InitializeCallbacks(); 224 | 225 | SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionTopRight); 226 | // Uncomment the next line to adjust the OverlayNotificationPosition. 227 | //SteamUtils.SetOverlayNotificationInset(400, 0); 228 | 229 | // Set collactible data. 230 | CurrentLanguage = $"CurrentGameLanguage: {SteamApps.GetCurrentGameLanguage()}"; 231 | AvailableLanguages = $"Languages: {SteamApps.GetAvailableGameLanguages()}"; 232 | UserStats = $"Reqesting Current Stats - {SteamUserStats.RequestCurrentStats()}"; 233 | mNumberOfCurrentPlayers.Set(SteamUserStats.GetNumberOfCurrentPlayers()); 234 | var hSteamApiCall = SteamUserStats.FindLeaderboard("Quickest Win"); 235 | mCallResultFindLeaderboard.Set(hSteamApiCall); 236 | 237 | string folder; 238 | var length = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out folder, 260); 239 | InstallDir = $"AppInstallDir: {length} {folder}"; 240 | 241 | // Get your Steam Avatar (Image) as a Texture2D. 242 | UserAvatar = GetSteamUserAvatar(GraphicsDevice); 243 | 244 | // Get your trimmed Steam User Name. 245 | var untrimmedUserName = SteamFriends.GetPersonaName(); 246 | // Remove unsupported chars like emojis or other stuff our font cannot handle. 247 | untrimmedUserName = ReplaceUnsupportedChars(Font, untrimmedUserName); 248 | SteamUserName = untrimmedUserName.Trim(); 249 | 250 | Exiting += Game1_Exiting; 251 | } 252 | } 253 | 254 | protected override void Update(GameTime gameTime) 255 | { 256 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || 257 | Keyboard.GetState().IsKeyDown(Keys.Escape)) 258 | { 259 | Exit(); 260 | } 261 | 262 | // TODO: Add your update logic here 263 | 264 | if (IsSteamRunning) SteamAPI.RunCallbacks(); 265 | base.Update(gameTime); 266 | } 267 | 268 | protected override void Draw(GameTime gameTime) 269 | { 270 | GraphicsDevice.Clear(Color.CornflowerBlue); 271 | 272 | // TODO: Add your drawing code here 273 | 274 | spriteBatch.Begin(); 275 | 276 | if (IsSteamRunning) 277 | { 278 | //Draw your Steam Avatar and Steam Name 279 | if (UserAvatar != null) 280 | { 281 | var avatarPosition = new Vector2(ScreenWidth / 2f, 282 | ScreenHeight / 2f + (!SteamOverlayActive ? MoveUpAndDown(gameTime, 2).Y * 25 : 0)); 283 | spriteBatch.Draw(UserAvatar, avatarPosition, null, Color.White, 0f, 284 | new Vector2(UserAvatar.Width / 2f, UserAvatar.Height / 2f), 1f, SpriteEffects.None, 0f); 285 | spriteBatch.DrawString(Font, SteamUserName, 286 | new Vector2(avatarPosition.X - Font.MeasureString(SteamUserName).X / 2f, 287 | avatarPosition.Y - UserAvatar.Height / 2f - Font.MeasureString(SteamUserName).Y * 1.5f), 288 | Color.Yellow); 289 | } 290 | 291 | // Draw data up/left. 292 | spriteBatch.DrawString(Font, 293 | $"{CurrentLanguage}\n{AvailableLanguages}\n{InstallDir}\n\nOverlay Active: {SteamOverlayActive}\nApp PlayTime: {PlayTimeInSeconds()}", 294 | new Vector2(20, 20), Color.White); 295 | 296 | // Draw data down/left. 297 | spriteBatch.DrawString(Font, $"{NumberOfCurrentPlayers}\n{PersonaState}\n{UserStats}\n{LeaderboardData}", 298 | new Vector2(20, 375), Color.White); 299 | } 300 | else 301 | { 302 | spriteBatch.DrawString(Font, STEAM_NOT_RUNNING_ERROR_MESSAGE, 303 | new Vector2(ScreenWidth / 2f - Font.MeasureString(STEAM_NOT_RUNNING_ERROR_MESSAGE).X / 2f, 304 | ScreenHeight / 2f - Font.MeasureString(STEAM_NOT_RUNNING_ERROR_MESSAGE).Y / 2f), Color.White); 305 | } 306 | 307 | spriteBatch.End(); 308 | base.Draw(gameTime); 309 | } 310 | 311 | /// 312 | /// Smooth up/down movement. 313 | /// 314 | private Vector2 MoveUpAndDown(GameTime gameTime, float speed) 315 | { 316 | var time = gameTime.TotalGameTime.TotalSeconds * speed; 317 | return new Vector2(0, (float)Math.Sin(time)); 318 | } 319 | } 320 | } -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true/pm 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Samples/Steamworks.Net MonoGame Integration/steam_api.dll -------------------------------------------------------------------------------- /Samples/Steamworks.Net MonoGame Integration/steam_appid.txt: -------------------------------------------------------------------------------- 1 | 480 -------------------------------------------------------------------------------- /Steamworks.Net MonoGame Integration.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello Steamworks.Net", "Samples\Hello Steamworks.Net\Hello Steamworks.Net.csproj", "{E1300152-A874-46AA-948D-86FBABEF1F6F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steamworks.Net MonoGame Integration", "Samples\Steamworks.Net MonoGame Integration\Steamworks.Net MonoGame Integration.csproj", "{63422818-DBA6-4944-9435-13C217F9B763}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AchievementHunter", "Samples\AchievementHunter\AchievementHunter.csproj", "{DD842683-2485-407C-945D-DB80167A99F5}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | OSX-Linux|Any CPU = OSX-Linux|Any CPU 18 | OSX-Linux|x64 = OSX-Linux|x64 19 | OSX-Linux|x86 = OSX-Linux|x86 20 | Release|Any CPU = Release|Any CPU 21 | Release|x64 = Release|x64 22 | Release|x86 = Release|x86 23 | Windows|Any CPU = Windows|Any CPU 24 | Windows|x64 = Windows|x64 25 | Windows|x86 = Windows|x86 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Debug|Any CPU.ActiveCfg = Debug|x86 29 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Debug|x64.ActiveCfg = Debug|x86 30 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Debug|x86.ActiveCfg = Debug|x86 31 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Debug|x86.Build.0 = Debug|x86 32 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|Any CPU.ActiveCfg = Release|x86 33 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|Any CPU.Build.0 = Release|x86 34 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|x64.ActiveCfg = Release|x86 35 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|x64.Build.0 = Release|x86 36 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|x86.ActiveCfg = Release|x86 37 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.OSX-Linux|x86.Build.0 = Release|x86 38 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Release|Any CPU.ActiveCfg = Release|x86 39 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Release|x64.ActiveCfg = Release|x86 40 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Release|x86.ActiveCfg = Release|x86 41 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Release|x86.Build.0 = Release|x86 42 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|Any CPU.ActiveCfg = Release|x86 43 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|Any CPU.Build.0 = Release|x86 44 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|x64.ActiveCfg = Release|x86 45 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|x64.Build.0 = Release|x86 46 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|x86.ActiveCfg = Release|x86 47 | {E1300152-A874-46AA-948D-86FBABEF1F6F}.Windows|x86.Build.0 = Release|x86 48 | {63422818-DBA6-4944-9435-13C217F9B763}.Debug|Any CPU.ActiveCfg = Debug|x86 49 | {63422818-DBA6-4944-9435-13C217F9B763}.Debug|x64.ActiveCfg = Debug|x86 50 | {63422818-DBA6-4944-9435-13C217F9B763}.Debug|x86.ActiveCfg = Debug|x86 51 | {63422818-DBA6-4944-9435-13C217F9B763}.Debug|x86.Build.0 = Debug|x86 52 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|Any CPU.ActiveCfg = Release|x86 53 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|Any CPU.Build.0 = Release|x86 54 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|x64.ActiveCfg = Release|x86 55 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|x64.Build.0 = Release|x86 56 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|x86.ActiveCfg = Release|x86 57 | {63422818-DBA6-4944-9435-13C217F9B763}.OSX-Linux|x86.Build.0 = Release|x86 58 | {63422818-DBA6-4944-9435-13C217F9B763}.Release|Any CPU.ActiveCfg = Release|x86 59 | {63422818-DBA6-4944-9435-13C217F9B763}.Release|x64.ActiveCfg = Release|x86 60 | {63422818-DBA6-4944-9435-13C217F9B763}.Release|x86.ActiveCfg = Release|x86 61 | {63422818-DBA6-4944-9435-13C217F9B763}.Release|x86.Build.0 = Release|x86 62 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|Any CPU.ActiveCfg = Release|x86 63 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|Any CPU.Build.0 = Release|x86 64 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|x64.ActiveCfg = Release|x86 65 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|x64.Build.0 = Release|x86 66 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|x86.ActiveCfg = Release|x86 67 | {63422818-DBA6-4944-9435-13C217F9B763}.Windows|x86.Build.0 = Release|x86 68 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 69 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|Any CPU.Build.0 = Debug|Any CPU 70 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|x64.ActiveCfg = Debug|Any CPU 71 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|x64.Build.0 = Debug|Any CPU 72 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|x86.ActiveCfg = Debug|x86 73 | {DD842683-2485-407C-945D-DB80167A99F5}.Debug|x86.Build.0 = Debug|x86 74 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|Any CPU.ActiveCfg = Release|Any CPU 75 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|Any CPU.Build.0 = Release|Any CPU 76 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|x64.ActiveCfg = Release|Any CPU 77 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|x64.Build.0 = Release|Any CPU 78 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|x86.ActiveCfg = Release|Any CPU 79 | {DD842683-2485-407C-945D-DB80167A99F5}.OSX-Linux|x86.Build.0 = Release|Any CPU 80 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|Any CPU.ActiveCfg = Release|Any CPU 81 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|Any CPU.Build.0 = Release|Any CPU 82 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|x64.ActiveCfg = Release|Any CPU 83 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|x64.Build.0 = Release|Any CPU 84 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|x86.ActiveCfg = Release|x86 85 | {DD842683-2485-407C-945D-DB80167A99F5}.Release|x86.Build.0 = Release|x86 86 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|Any CPU.ActiveCfg = Release|Any CPU 87 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|Any CPU.Build.0 = Release|Any CPU 88 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|x64.ActiveCfg = Release|Any CPU 89 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|x64.Build.0 = Release|Any CPU 90 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|x86.ActiveCfg = Release|Any CPU 91 | {DD842683-2485-407C-945D-DB80167A99F5}.Windows|x86.Build.0 = Release|Any CPU 92 | EndGlobalSection 93 | GlobalSection(SolutionProperties) = preSolution 94 | HideSolutionNode = FALSE 95 | EndGlobalSection 96 | EndGlobal 97 | -------------------------------------------------------------------------------- /Steamworks.Net MonoGame Integration.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Steamworks.Net/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2018 Riley Labrecque 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Steamworks.Net/README.md: -------------------------------------------------------------------------------- 1 | Steamworks.NET 2 | ======= 3 | 4 | _Steamworks.NET_ is a C# Wrapper for Valve's Steamworks API, it can be used either with Unity or your C# based Application. 5 | 6 | _Steamworks.NET_ was designed to be as close as possible to the original C++ API, as such the documentation provided from Valve largely covers usage of _Steamworks.NET_. 7 | Niceties and C# Idioms can be easily implemented on top of _Steamworks.NET_. 8 | 9 | _Steamworks.NET_ currently fully supports Windows, OSX, and Linux in both 32 and 64bit varieties. Currently building against Steamworks SDK 1.42. 10 | 11 | * Author: [Riley Labrecque](https://github.com/rlabrecque) 12 | * License: [MIT](http://www.opensource.org/licenses/mit-license.php) 13 | * [Documentation](https://steamworks.github.io/) 14 | * [Discussion Thread](http://steamcommunity.com/groups/steamworks/discussions/0/666827974770212954/) 15 | * [Reporting Issues](https://github.com/rlabrecque/Steamworks.NET/issues) 16 | * 1-on-1 support is available by donating $100 USD or greater. 17 | * Support can be obtained via [Email](mailto:support@rileylabrecque.com), [Skype](http://rileylabrecque.com/skype), or [Steam](http://steamcommunity.com/id/rlabrecque) 18 | * I can only help with Steamworks.NET specific issues, general API questions should be asked on the [Steamworks discussion board](http://steamcommunity.com/groups/steamworks/discussions). 19 | 20 | [![Support via Paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YFZZER8VNXKRC) 21 | 22 | 23 | [Installation Instructions](http://steamworks.github.io/installation/) 24 | ----- 25 | 26 | Samples 27 | ----- 28 | Check out these sample projects to get started: 29 | * [Steamworks.NET Example](https://github.com/rlabrecque/Steamworks.NET-Example) 30 | * [Steamworks.NET Test](https://github.com/rlabrecque/Steamworks.NET-Test) 31 | * [Steamworks.NET ChatClient](https://github.com/rlabrecque/Steamworks.NET-ChatClient) 32 | * [Steamworks.NET GameServerTest](https://github.com/rlabrecque/Steamworks.NET-GameServerTest) 33 | -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86/OSX-Linux/Steamworks.NET.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86/OSX-Linux/Steamworks.NET.dll -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86/OSX-Linux/libsteam_api.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86/OSX-Linux/libsteam_api.so -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86/Windows/Steamworks.NET.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86/Windows/Steamworks.NET.dll -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86/Windows/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86/Windows/steam_api.dll -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86_64/OSX-Linux/Steamworks.NET.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86_64/OSX-Linux/Steamworks.NET.dll -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86_64/OSX-Linux/libsteam_api.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86_64/OSX-Linux/libsteam_api.so -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86_64/Windows/Steamworks.NET.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86_64/Windows/Steamworks.NET.dll -------------------------------------------------------------------------------- /Steamworks.Net/libs-x86_64/Windows/steam_api64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/libs-x86_64/Windows/steam_api64.dll -------------------------------------------------------------------------------- /Steamworks.Net/steam_api.bundle/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 11G63 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | libsteam_api.dylib 11 | CFBundleIdentifier 12 | com.rileylabrecque.steam_api 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.42 21 | CSResourcesFileMapped 22 | yes 23 | DTCompiler 24 | 25 | DTPlatformBuild 26 | 4H1503 27 | DTPlatformVersion 28 | GM 29 | DTSDKBuild 30 | 11E52 31 | DTSDKName 32 | macosx10.7 33 | DTXcode 34 | 0463 35 | DTXcodeBuild 36 | 4H1503 37 | 38 | 39 | -------------------------------------------------------------------------------- /Steamworks.Net/steam_api.bundle/Contents/MacOS/libsteam_api.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlizzCrafter/Steamworks.Net-MonoGame-Integration/5b72177e35521f1bf9eac8d079f92dcd01134597/Steamworks.Net/steam_api.bundle/Contents/MacOS/libsteam_api.dylib -------------------------------------------------------------------------------- /Steamworks.Net/steam_appid.txt: -------------------------------------------------------------------------------- 1 | 480 --------------------------------------------------------------------------------