eirexe

Untitled

Jun 30th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. //====== Copyright 2011-2013, EirTeam, All rights reserved. ===================
  2. //
  3. // Purpose: Wrapper for Game Maker to be able to use the Steam Api.
  4. //
  5. //=============================================================================
  6.  
  7. /*
  8. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9. !!!!!DON'T FUCKING CHANGE TABS TO SPACES!!!!!
  10. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  11.  
  12. Game Maker only acepts doubles or strings so I have to fucking work.
  13. */
  14. #include "stdafx.h"
  15. #include "steam/steam_api.h"
  16. #include <string>
  17. #include <sstream>
  18. #define GMEXPORT extern "C" __declspec (dllexport)
  19.  
  20. #include <windows.h>
  21. BOOL WINAPI DllMain(
  22.   HANDLE hinstDLL,
  23.   DWORD dwReason,
  24.   LPVOID lpvReserved
  25. )
  26.  
  27. {
  28.     switch (dwReason)
  29.     {
  30.     case DLL_PROCESS_ATTACH:
  31.         //We want to make sure that steamapi is ready before even the game runs
  32.         //so only by defining it makes steam api run
  33.         SteamAPI_Init();
  34.     case DLL_THREAD_ATTACH:
  35.     case DLL_THREAD_DETACH:
  36.     case DLL_PROCESS_DETACH:
  37.         break;
  38.     }
  39.     return TRUE;
  40. }
  41.  
  42. //string conversion stuff
  43. std::string RetString;
  44.  
  45. template <typename T>
  46. std::string to_string(const T & value) {
  47.     std::stringstream sstr;
  48.     sstr << value;
  49.     return sstr.str();
  50. }
  51.  
  52.  
  53. /*
  54. HowTo: New function
  55.  
  56. Define a new function using
  57. GMEXPORT const char * SteamWorkFuncTionName()
  58. inside it run it, remember that game maker only acepts strings or reals.
  59. So even if yours is a bool you will want to convert it to a char, we will convert it to a string later.
  60. in this case, i'm returning a string
  61.  
  62. GMEXPORT const char * SteamGetPlayerName() {
  63.     //get the player name to a char
  64.     const char * playername = SteamFriends()->GetPersonaName();
  65.     //move it to return string variable, wich makes it a string
  66.     RetString = playername;
  67.     //return string
  68.     return RetString.c_str();
  69. }
  70. */
  71.  
  72.  
  73. /*
  74. == SteamGetPlayerName() ==
  75.  
  76. Purpose: Get the name of the user that is logged in
  77.  
  78. ===========================
  79. */
  80. GMEXPORT const char * SteamGetPlayerName() {
  81.     const char * playername = SteamFriends()->GetPersonaName();
  82.     RetString = playername;
  83.     return RetString.c_str();
  84. }
Advertisement
Add Comment
Please, Sign In to add comment