Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //====== Copyright 2011-2013, EirTeam, All rights reserved. ===================
- //
- // Purpose: Wrapper for Game Maker to be able to use the Steam Api.
- //
- //=============================================================================
- /*
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !!!!!DON'T FUCKING CHANGE TABS TO SPACES!!!!!
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- Game Maker only acepts doubles or strings so I have to fucking work.
- */
- #include "stdafx.h"
- #include "steam/steam_api.h"
- #include <string>
- #include <sstream>
- #define GMEXPORT extern "C" __declspec (dllexport)
- #include <windows.h>
- BOOL WINAPI DllMain(
- HANDLE hinstDLL,
- DWORD dwReason,
- LPVOID lpvReserved
- )
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- //We want to make sure that steamapi is ready before even the game runs
- //so only by defining it makes steam api run
- SteamAPI_Init();
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- //string conversion stuff
- std::string RetString;
- template <typename T>
- std::string to_string(const T & value) {
- std::stringstream sstr;
- sstr << value;
- return sstr.str();
- }
- /*
- HowTo: New function
- Define a new function using
- GMEXPORT const char * SteamWorkFuncTionName()
- inside it run it, remember that game maker only acepts strings or reals.
- So even if yours is a bool you will want to convert it to a char, we will convert it to a string later.
- in this case, i'm returning a string
- GMEXPORT const char * SteamGetPlayerName() {
- //get the player name to a char
- const char * playername = SteamFriends()->GetPersonaName();
- //move it to return string variable, wich makes it a string
- RetString = playername;
- //return string
- return RetString.c_str();
- }
- */
- /*
- == SteamGetPlayerName() ==
- Purpose: Get the name of the user that is logged in
- ===========================
- */
- GMEXPORT const char * SteamGetPlayerName() {
- const char * playername = SteamFriends()->GetPersonaName();
- RetString = playername;
- return RetString.c_str();
- }
Advertisement
Add Comment
Please, Sign In to add comment