Implement steam overlay.

This commit is contained in:
momo5502 2016-01-07 16:55:10 +01:00
parent b58085810a
commit f8a8edde21
5 changed files with 32 additions and 4 deletions

4
.gitmodules vendored
View File

@ -1,7 +1,3 @@
[submodule "tools/premake/github-package"]
path = tools/premake/github-package
url = https://github.com/mversluys/premake-github-package.git
branch = master
[submodule "deps/zlib"]
path = deps/zlib
url = https://github.com/madler/zlib.git

View File

@ -54,6 +54,11 @@ namespace Steam
void Utils::SetOverlayNotificationPosition(int eNotificationPosition)
{
if (Steam::Overlay)
{
FARPROC setPosition = GetProcAddress(Steam::Overlay, "SetNotificationPosition");
::Utils::Hook::Call<void(int)>(setPosition)(eNotificationPosition);
}
}
bool Utils::IsAPICallCompleted(unsigned __int64 hSteamAPICall, bool *pbFailed)

View File

@ -3,6 +3,8 @@
namespace Steam
{
HMODULE Overlay = 0;
uint64_t Callbacks::CallID = 0;
std::map<uint64_t, bool> Callbacks::Calls;
std::map<uint64_t, Callbacks::Base*> Callbacks::ResultHandlers;
@ -70,6 +72,24 @@ namespace Steam
{
bool SteamAPI_Init()
{
Overlay = GetModuleHandleA("gameoverlayrenderer.dll");
if (!Overlay)
{
HKEY hRegKey;
char steamPath[MAX_PATH] = { 0 };
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
{
DWORD dwLength = sizeof(steamPath);
RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, (BYTE*)steamPath, &dwLength);
RegCloseKey(hRegKey);
SetDllDirectory(steamPath);
}
Overlay = LoadLibraryA(::Utils::VA("%s\\%s", steamPath, "gameoverlayrenderer.dll"));
}
return true;
}

View File

@ -88,4 +88,6 @@ namespace Steam
STEAM_EXPORT Steam::RemoteStorage* SteamRemoteStorage();
STEAM_EXPORT Steam::User* SteamUser();
STEAM_EXPORT Steam::Utils* SteamUtils();
extern HMODULE Overlay;
}

View File

@ -28,6 +28,11 @@ namespace Utils
return std::function<T>((T*)function);
}
template <typename T> static std::function<T> Call(FARPROC function)
{
return Call<T>((DWORD)function);
}
static void SetString(void* place, const char* string, size_t length);
static void SetString(DWORD place, const char* string, size_t length);