A few improvements to the overlay merge request.

NO_OVERLAY define becomes EMU_OVERLAY which enables the overlay instead of disabling it.

disable_overlay.txt moved to steam_settings.
merge-requests/28/head
Mr_Goldberg 2020-01-19 12:55:14 -05:00
parent ffdaf72597
commit db2a803cf7
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
42 changed files with 857 additions and 1107 deletions

View File

@ -59,8 +59,7 @@ build_windows:
image: fedora:29 image: fedora:29
script: script:
- dnf -y install wine wget p7zip sed dos2unix unzip - dnf -y install wine wget p7zip sed dos2unix
- ./download_glew.sh
- unix2dos *.txt - unix2dos *.txt
- unix2dos files_example/*.txt files_example/*/*.txt - unix2dos files_example/*.txt files_example/*/*.txt
- sed -i 's/..\\vcpkg\\packages\\/.\\/g' build_set_protobuf_directories.bat - sed -i 's/..\\vcpkg\\packages\\/.\\/g' build_set_protobuf_directories.bat
@ -104,7 +103,7 @@ build_cmake_linux:
script: script:
- mkdir cmake-builds && cd cmake-builds - mkdir cmake-builds && cd cmake-builds
- mkdir x64-release && cd x64-release - mkdir x64-release && cd x64-release
- cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DNO_OVERLAY=ON && ninja - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" && ninja
- cd .. - cd ..
# - mkdir x64-experimental-release && cd x64-experimental-release # - mkdir x64-experimental-release && cd x64-experimental-release
# - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD:BOOL=ON && ninja # - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD:BOOL=ON && ninja
@ -127,7 +126,6 @@ build_cmake_windows:
- 7za x cmake-3.15.0-rc1-win64-x64.zip - 7za x cmake-3.15.0-rc1-win64-x64.zip
- wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/0119304e030098b4821d73170fe52084/protobuf_x64-windows-static.7z' - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/0119304e030098b4821d73170fe52084/protobuf_x64-windows-static.7z'
- 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static - 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static
- ./download_glew.sh
script: script:
- export WINEDEBUG=-all - export WINEDEBUG=-all
@ -135,13 +133,13 @@ build_cmake_windows:
- mkdir cmake-builds && cd cmake-builds - mkdir cmake-builds && cd cmake-builds
- mkdir x64-release && cd x64-release - mkdir x64-release && cd x64-release
- echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat - echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat
- echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DNO_OVERLAY=ON -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat - echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat
- echo nmake.exe >> cmake-build.bat - echo nmake.exe >> cmake-build.bat
- wine cmd /c cmake-build.bat - wine cmd /c cmake-build.bat
- cd .. - cd ..
- mkdir x64-experimental-release && cd x64-experimental-release - mkdir x64-experimental-release && cd x64-experimental-release
- echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat - echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat
- echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD=ON -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat - echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD=ON -DEMU_OVERLAY=ON -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat
- echo nmake.exe >> cmake-build.bat - echo nmake.exe >> cmake-build.bat
- wine cmd /c cmake-build.bat - wine cmd /c cmake-build.bat
- cd .. - cd ..

View File

@ -105,7 +105,7 @@ endif()
add_library(${LIB_STEAM_API} add_library(${LIB_STEAM_API}
SHARED SHARED
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}>
$<$<AND:$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<NOT:$<BOOL:${NO_OVERLAY}>>>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}> $<$<AND:$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}>
${DLL_SRC_SHARED} ${DLL_SRC_SHARED}
${PROTO_SRCS} ${PROTO_SRCS}
${PROTO_HDRS} ${PROTO_HDRS}
@ -126,9 +126,9 @@ target_link_libraries(${LIB_STEAM_API}
protobuf::libprotobuf protobuf::libprotobuf
$<$<BOOL:${WIN32}>:ws2_32> $<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi> $<$<BOOL:${WIN32}>:iphlpapi>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<NOT:$<BOOL:${NO_OVERLAY}>>>:glew32s.lib> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:glew32s.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<NOT:$<BOOL:${NO_OVERLAY}>>>:opengl32.lib> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<NOT:$<BOOL:${NO_OVERLAY}>>>:Winmm.lib> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:Winmm.lib>
) )
# Add target compile definitions # Add target compile definitions
@ -139,8 +139,8 @@ target_compile_definitions(${LIB_STEAM_API}
$<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD> $<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD>
$<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD> $<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD>
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
$<$<BOOL:${NO_OVERLAY}>:NO_OVERLAY> $<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<NOT:$<BOOL:${NO_OVERLAY}>>>:GLEW_STATIC> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:GLEW_STATIC>
) )
# Install the target # Install the target
@ -265,7 +265,6 @@ target_link_libraries(${BIN_LOBBY_CONNECT}
target_compile_definitions(${BIN_LOBBY_CONNECT} target_compile_definitions(${BIN_LOBBY_CONNECT}
PRIVATE PRIVATE
NO_DISK_WRITES NO_DISK_WRITES
NO_OVERLAY
LOBBY_CONNECT LOBBY_CONNECT
$<$<CONFIG:>:EMU_RELEASE_BUILD> $<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD> $<$<CONFIG:Release>:EMU_RELEASE_BUILD>

View File

@ -102,8 +102,10 @@ You must all be on the same LAN for it to work.
IMPORTANT: IMPORTANT:
Do not run more than one steam game with the same appid at the same time on the same computer with my emu or there might be network issues (dedicated servers should be fine though). Do not run more than one steam game with the same appid at the same time on the same computer with my emu or there might be network issues (dedicated servers should be fine though).
Overlay (Note: at the moment this feature is only enabled in the windows experimental builds):
The overlay can be disabled by putting a file named disable_overlay.txt in the steam_settings folder. This is for games that depend on the steam overlay to let people join multiplayer games.
Controller (Note: at the moment this feature is only enabled in the windows experimental builds): Controller (Note: at the moment this feature is only enabled in the windows experimental builds and the linux builds):
SteamController/SteamInput support is limited to XInput controllers. If your controller is not XInput, there are many tools (at least for windows) that you can use to make it emulate an XInput one. SteamController/SteamInput support is limited to XInput controllers. If your controller is not XInput, there are many tools (at least for windows) that you can use to make it emulate an XInput one.
Steam uses things called action sets for controller configuration. An action set is a group of action names. Action names are bound to buttons, triggers or joysticks. Steam uses things called action sets for controller configuration. An action set is a group of action names. Action names are bound to buttons, triggers or joysticks.
The emulator needs to know for each action set, which button is linked to which action name. Create a ACTION_SET_NAME.txt file in the steam_settings\controller folder for every action set the game uses. The emulator needs to know for each action set, which button is linked to which action name. Create a ACTION_SET_NAME.txt file in the steam_settings\controller folder for every action set the game uses.

12
build_steamos.sh Executable file → Normal file
View File

@ -7,10 +7,10 @@ mkdir -p linux/tools
cp scripts/find_interfaces.sh linux/tools/ cp scripts/find_interfaces.sh linux/tools/
cp scripts/steamclient_loader.sh linux/tools/ cp scripts/steamclient_loader.sh linux/tools/
../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32 g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32_steamclient g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect32
g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect32 g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32_steamclient
../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64 g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64_steamclient g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect64
g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DNO_OVERLAY -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect64 g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64_steamclient

View File

@ -4,13 +4,13 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\lib\Release\Win32\glew32s.lib opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api.dll cl /LD /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api.dll
cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient.dll cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient.dll
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\lib\Release\x64\glew32s.lib opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api64.dll cl /LD /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api64.dll
cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient64.dll cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient64.dll
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll

View File

@ -6,7 +6,7 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /DNO_OVERLAY /DNO_DISK_WRITES /DLOBBY_CONNECT /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe cl /DNO_DISK_WRITES /DLOBBY_CONNECT /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe
del /Q /S release\lobby_connect\*.lib del /Q /S release\lobby_connect\*.lib
del /Q /S release\lobby_connect\*.exp del /Q /S release\lobby_connect\*.exp
copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt

View File

@ -10,12 +10,12 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DNO_OVERLAY /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api.dll cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DNO_OVERLAY /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api64.dll cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api64.dll
copy Readme_release.txt release\Readme.txt copy Readme_release.txt release\Readme.txt
xcopy /s files_example\* release\ xcopy /s files_example\* release\
call build_win_release_experimental.bat call build_win_release_experimental.bat

View File

@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\lib\Release\Win32\glew32s.lib opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api.dll
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\lib\Release\x64\glew32s.lib opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api64.dll
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient64.dll
copy Readme_experimental.txt release\experimental\Readme.txt copy Readme_experimental.txt release\experimental\Readme.txt

View File

@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\ copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient64.dll
copy Readme_experimental_steamclient.txt release\experimental_steamclient\Readme.txt copy Readme_experimental_steamclient.txt release\experimental_steamclient\Readme.txt

View File

@ -221,14 +221,9 @@ STEAMAPI_API bool S_CALLTYPE SteamAPI_Init()
crack_SteamAPI_Init(); crack_SteamAPI_Init();
#endif #endif
load_old_interface_versions(); load_old_interface_versions();
user_steam_pipe = get_steam_client()->CreateSteamPipe();
get_steam_client()->ConnectToGlobalUser(user_steam_pipe);
Steam_Client* client = get_steam_client(); Steam_Client* client = get_steam_client();
#ifndef NO_OVERLAY user_steam_pipe = client->CreateSteamPipe();
if( client->enable_overlay ) client->ConnectToGlobalUser(user_steam_pipe);
client->steam_overlay->SetupOverlay();
#endif
return true; return true;
} }

View File

@ -139,6 +139,9 @@ public:
//networking //networking
bool disable_networking = false; bool disable_networking = false;
//overlay
bool disable_overlay = false;
}; };
#endif #endif

View File

@ -250,6 +250,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
bool steam_offline_mode = false; bool steam_offline_mode = false;
bool disable_networking = false; bool disable_networking = false;
bool disable_overlay = false;
{ {
std::string steam_settings_path = Local_Storage::get_game_settings_path(); std::string steam_settings_path = Local_Storage::get_game_settings_path();
@ -260,6 +261,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
steam_offline_mode = true; steam_offline_mode = true;
} else if (p == "disable_networking.txt") { } else if (p == "disable_networking.txt") {
disable_networking = true; disable_networking = true;
} else if (p == "disable_overlay.txt") {
disable_overlay = true;
} }
} }
} }
@ -272,6 +275,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
settings_server->custom_broadcasts = custom_broadcasts; settings_server->custom_broadcasts = custom_broadcasts;
settings_client->disable_networking = disable_networking; settings_client->disable_networking = disable_networking;
settings_server->disable_networking = disable_networking; settings_server->disable_networking = disable_networking;
settings_client->disable_overlay = disable_overlay;
settings_server->disable_overlay = disable_overlay;
{ {
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt"; std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";

View File

@ -48,11 +48,6 @@ Steam_Client::Steam_Client()
{ {
uint32 appid = create_localstorage_settings(&settings_client, &settings_server, &local_storage); uint32 appid = create_localstorage_settings(&settings_client, &settings_server, &local_storage);
{
std::ifstream chk_ovlay(Local_Storage::get_program_path() + PATH_SEPARATOR + "disable_overlay.txt", std::ios::in);
if (chk_ovlay)
enable_overlay = false;
}
network = new Networking(settings_server->get_local_steam_id(), appid, settings_server->get_port(), &(settings_server->custom_broadcasts), settings_server->disable_networking); network = new Networking(settings_server->get_local_steam_id(), appid, settings_server->get_port(), &(settings_server->custom_broadcasts), settings_server->disable_networking);
callback_results_client = new SteamCallResults(); callback_results_client = new SteamCallResults();
@ -71,7 +66,7 @@ Steam_Client::Steam_Client()
steam_matchmaking = new Steam_Matchmaking(settings_client, network, callback_results_client, callbacks_client, run_every_runcb); steam_matchmaking = new Steam_Matchmaking(settings_client, network, callback_results_client, callbacks_client, run_every_runcb);
steam_matchmaking_servers = new Steam_Matchmaking_Servers(settings_client, network); steam_matchmaking_servers = new Steam_Matchmaking_Servers(settings_client, network);
steam_user_stats = new Steam_User_Stats(settings_client, local_storage, callback_results_client, callbacks_client); steam_user_stats = new Steam_User_Stats(settings_client, local_storage, callback_results_client, callbacks_client, steam_overlay);
steam_apps = new Steam_Apps(settings_client, callback_results_client); steam_apps = new Steam_Apps(settings_client, callback_results_client);
steam_networking = new Steam_Networking(settings_client, network, callbacks_client, run_every_runcb); steam_networking = new Steam_Networking(settings_client, network, callbacks_client, run_every_runcb);
steam_remote_storage = new Steam_Remote_Storage(settings_client, local_storage, callback_results_client); steam_remote_storage = new Steam_Remote_Storage(settings_client, local_storage, callback_results_client);
@ -197,6 +192,10 @@ HSteamUser Steam_Client::ConnectToGlobalUser( HSteamPipe hSteamPipe )
} }
userLogIn(); userLogIn();
#ifdef EMU_OVERLAY
if(!settings_client->disable_overlay)
steam_overlay->SetupOverlay();
#endif
steam_pipes[hSteamPipe] = Steam_Pipe::CLIENT; steam_pipes[hSteamPipe] = Steam_Pipe::CLIENT;
return CLIENT_HSTEAMUSER; return CLIENT_HSTEAMUSER;
} }
@ -711,7 +710,7 @@ ISteamScreenshots *Steam_Client::GetISteamScreenshots( HSteamUser hSteamuser, HS
// Deprecated. Applications should use SteamAPI_RunCallbacks() or SteamGameServer_RunCallbacks() instead. // Deprecated. Applications should use SteamAPI_RunCallbacks() or SteamGameServer_RunCallbacks() instead.
void Steam_Client::RunFrame() void Steam_Client::RunFrame()
{ {
PRINT_DEBUG("RunFrame\n"); PRINT_DEBUG("Steam_Client::RunFrame\n");
} }
// returns the number of IPC calls made since the last time this function was called // returns the number of IPC calls made since the last time this function was called

View File

@ -131,7 +131,6 @@ public:
Steam_Overlay* steam_overlay; Steam_Overlay* steam_overlay;
bool enable_overlay = true;
bool user_logged_in = false; bool user_logged_in = false;
bool server_init = false; bool server_init = false;
std::thread background_keepalive; std::thread background_keepalive;

View File

@ -1,829 +0,0 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
#include "steam_user_stats.h"
#include "dll.h"
unsigned int Steam_User_Stats::find_leaderboard(std::string name)
{
unsigned index = 1;
for (auto& leaderboard : leaderboards) {
if (leaderboard.name == name) return index;
++index;
}
return 0;
}
void Steam_User_Stats::load_achievements_db()
{
std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file;
local_storage->load_json(file_path, defined_achievements);
}
void Steam_User_Stats::load_achievements()
{
local_storage->load_json_file("", achievements_user_file, user_achievements);
}
void Steam_User_Stats::save_achievements()
{
local_storage->write_json_file("", achievements_user_file, user_achievements);
}
Steam_User_Stats::Steam_User_Stats(Settings *settings, Local_Storage *local_storage, class SteamCallResults *callback_results, class SteamCallBacks *callbacks):
settings(settings),
local_storage(local_storage),
callback_results(callback_results),
callbacks(callbacks),
defined_achievements(nlohmann::json::object()),
user_achievements(nlohmann::json::object())
{
load_achievements_db(); // achievements db
load_achievements(); // achievements per user
}
nlohmann::json const& Steam_User_Stats::GetAchievementsDb() const
{
return defined_achievements;
}
// Ask the server to send down this user's data and achievements for this game
STEAM_CALL_BACK(UserStatsReceived_t)
bool Steam_User_Stats::RequestCurrentStats()
{
PRINT_DEBUG("Steam_User_Stats::RequestCurrentStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
UserStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = settings->get_local_steam_id();
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return true;
}
// Data accessors
bool Steam_User_Stats::GetStat(const char* pchName, int32* pData)
{
PRINT_DEBUG("GetStat int32 %s\n", pchName);
if (!pchName || !pData) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto stats_config = settings->getStats();
auto stats_data = stats_config.find(pchName);
if (stats_data != stats_config.end()) {
if (stats_data->second.type != Stat_Type::STAT_TYPE_INT) return false;
}
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char*)pData, sizeof(*pData));
if (read_data == sizeof(int32))
return true;
if (stats_data != stats_config.end()) {
*pData = stats_data->second.default_value_int;
return true;
}
return false;
}
bool Steam_User_Stats::GetStat(const char* pchName, float* pData)
{
PRINT_DEBUG("GetStat float %s\n", pchName);
if (!pchName || !pData) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto stats_config = settings->getStats();
auto stats_data = stats_config.find(pchName);
if (stats_data != stats_config.end()) {
if (stats_data->second.type == Stat_Type::STAT_TYPE_INT) return false;
}
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char*)pData, sizeof(*pData));
if (read_data == sizeof(float))
return true;
if (stats_data != stats_config.end()) {
*pData = stats_data->second.default_value_float;
return true;
}
return false;
}
// Set / update data
bool Steam_User_Stats::SetStat(const char* pchName, int32 nData)
{
PRINT_DEBUG("SetStat int32 %s\n", pchName);
if (!pchName) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, (char*)&nData, sizeof(nData)) == sizeof(nData);
}
bool Steam_User_Stats::SetStat(const char* pchName, float fData)
{
PRINT_DEBUG("SetStat float %s\n", pchName);
if (!pchName) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, (char*)&fData, sizeof(fData)) == sizeof(fData);
}
bool Steam_User_Stats::UpdateAvgRateStat(const char* pchName, float flCountThisSession, double dSessionLength)
{
PRINT_DEBUG("UpdateAvgRateStat %s\n", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
char data[sizeof(float) + sizeof(float) + sizeof(double)];
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char*)data, sizeof(*data));
float oldcount = 0;
double oldsessionlength = 0;
if (read_data == sizeof(data)) {
memcpy(&oldcount, data + sizeof(float), sizeof(oldcount));
memcpy(&oldsessionlength, data + sizeof(float) + sizeof(double), sizeof(oldsessionlength));
}
oldcount += flCountThisSession;
oldsessionlength += dSessionLength;
float average = oldcount / oldsessionlength;
memcpy(data, &average, sizeof(average));
memcpy(data + sizeof(float), &oldcount, sizeof(oldcount));
memcpy(data + sizeof(float) * 2, &oldsessionlength, sizeof(oldsessionlength));
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, data, sizeof(data)) == sizeof(data);
}
// Achievement flag accessors
bool Steam_User_Stats::GetAchievement(const char* pchName, bool* pbAchieved)
{
PRINT_DEBUG("GetAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return item["name"].get<std::string>() == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end() && ach != user_achievements.end()) {
if (pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
return true;
}
}
catch (...) {}
if (pbAchieved != nullptr)*pbAchieved = false;
return false;
}
bool Steam_User_Stats::SetAchievement(const char* pchName)
{
PRINT_DEBUG("SetAchievement %s\n", pchName);
if (pchName == nullptr) return false;
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return item["name"].get<std::string>() == pchName;
});
if (it != defined_achievements.end()) {
if (user_achievements.find(pchName) == user_achievements.end() || user_achievements[pchName].value("earned", false) == false) {
user_achievements[pchName]["earned"] = true;
user_achievements[pchName]["earned_time"] = std::chrono::duration_cast<std::chrono::duration<uint32>>(std::chrono::system_clock::now().time_since_epoch()).count();
#ifndef NO_OVERLAY
get_steam_client()->steam_overlay->AddAchievementNotification(it.value());
#endif
}
return true;
}
}
catch (...) {}
return false;
}
bool Steam_User_Stats::ClearAchievement(const char* pchName)
{
PRINT_DEBUG("ClearAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
user_achievements[pchName]["earned"] = false;
user_achievements[pchName]["earned_time"] = static_cast<uint32>(0);
return true;
}
}
catch (...) {}
return false;
}
// Get the achievement status, and the time it was unlocked if unlocked.
// If the return value is true, but the unlock time is zero, that means it was unlocked before Steam
// began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970.
bool Steam_User_Stats::GetAchievementAndUnlockTime(const char* pchName, bool* pbAchieved, uint32* punUnlockTime)
{
PRINT_DEBUG("GetAchievementAndUnlockTime\n");
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end() && ach != user_achievements.end()) {
if (pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
if (punUnlockTime != nullptr) *punUnlockTime = (*ach)["earned_time"];
return true;
}
}
catch (...) {}
if (pbAchieved != nullptr) *pbAchieved = false;
if (punUnlockTime != nullptr) *punUnlockTime = 0;
return true;
}
// Store the current data on the server, will get a callback when set
// And one callback for every new achievement
//
// If the callback has a result of k_EResultInvalidParam, one or more stats
// uploaded has been rejected, either because they broke constraints
// or were out of date. In this case the server sends back updated values.
// The stats should be re-iterated to keep in sync.
bool Steam_User_Stats::StoreStats()
{
PRINT_DEBUG("StoreStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
save_achievements();
UserStatsStored_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return true;
}
// Achievement / GroupAchievement metadata
// Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set.
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback
// which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the
// specified achievement.
int Steam_User_Stats::GetAchievementIcon(const char* pchName)
{
PRINT_DEBUG("GetAchievementIcon\n");
if (pchName == nullptr) return 0;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return 0;
}
// Get general attributes for an achievement. Accepts the following keys:
// - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8)
// - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden)
const char* Steam_User_Stats::GetAchievementDisplayAttribute(const char* pchName, const char* pchKey)
{
PRINT_DEBUG("GetAchievementDisplayAttribute %s %s\n", pchName, pchKey);
if (pchName == nullptr) return "";
if (pchKey == nullptr) return "";
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (strcmp (pchKey, "name") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["displayName"].get_ptr<std::string*>()->c_str();
}
}
catch (...) {}
}
if (strcmp(pchKey, "desc") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["description"].get_ptr<std::string*>()->c_str();
}
}
catch (...) {}
}
if (strcmp(pchKey, "hidden") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["hidden"].get_ptr<std::string*>()->c_str();
}
}
catch (...) {}
}
return "";
}
// Achievement progress - triggers an AchievementProgress callback, that is all.
// Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.
bool Steam_User_Stats::IndicateAchievementProgress(const char* pchName, uint32 nCurProgress, uint32 nMaxProgress)
{
PRINT_DEBUG("IndicateAchievementProgress\n");
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end()) {
bool achieved = false;
if (ach != user_achievements.end()) {
bool achieved = ach->value("earned", false);
}
UserAchievementStored_t data = {};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false;
strncpy(data.m_rgchAchievementName, pchName, k_cchStatNameMax);
if (achieved) {
data.m_nCurProgress = 0;
data.m_nMaxProgress = 0;
}
else {
user_achievements[pchName]["progress"] = nCurProgress;
user_achievements[pchName]["max_progress"] = nMaxProgress;
data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress;
}
save_achievements();
callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
return true;
}
}
catch (...) {}
return false;
}
// Used for iterating achievements. In general games should not need these functions because they should have a
// list of existing achievements compiled into them
uint32 Steam_User_Stats::GetNumAchievements()
{
PRINT_DEBUG("GetNumAchievements\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return defined_achievements.size();
}
// Get achievement name iAchievement in [0,GetNumAchievements)
const char* Steam_User_Stats::GetAchievementName(uint32 iAchievement)
{
PRINT_DEBUG("GetAchievementName\n");
try {
static std::string achievement_name;
achievement_name = defined_achievements[iAchievement]["name"].get<std::string>();
return achievement_name.c_str();
}
catch (...) {}
return "";
}
// Friends stats & achievements
// downloads stats for the user
// returns a UserStatsReceived_t received when completed
// if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail
// these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data
STEAM_CALL_RESULT(UserStatsReceived_t)
SteamAPICall_t Steam_User_Stats::RequestUserStats(CSteamID steamIDUser)
{
PRINT_DEBUG("Steam_User_Stats::RequestUserStats %llu\n", steamIDUser.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
// Enable this to allow hot reload achievements status
//if (steamIDUser == settings->get_local_steam_id()) {
// load_achievements();
//}
UserStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = steamIDUser;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
}
// requests stat information for a user, usable after a successful call to RequestUserStats()
bool Steam_User_Stats::GetUserStat(CSteamID steamIDUser, const char* pchName, int32* pData)
{
PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64());
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
}
else {
*pData = 0;
}
return true;
}
bool Steam_User_Stats::GetUserStat(CSteamID steamIDUser, const char* pchName, float* pData)
{
PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64());
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
}
else {
*pData = 0;
}
return true;
}
bool Steam_User_Stats::GetUserAchievement(CSteamID steamIDUser, const char* pchName, bool* pbAchieved)
{
PRINT_DEBUG("GetUserAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievement(pchName, pbAchieved);
}
return false;
}
// See notes for GetAchievementAndUnlockTime above
bool Steam_User_Stats::GetUserAchievementAndUnlockTime(CSteamID steamIDUser, const char* pchName, bool* pbAchieved, uint32* punUnlockTime)
{
PRINT_DEBUG("GetUserAchievementAndUnlockTime %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievementAndUnlockTime(pchName, pbAchieved, punUnlockTime);
}
return false;
}
// Reset stats
bool Steam_User_Stats::ResetAllStats(bool bAchievementsToo)
{
PRINT_DEBUG("ResetAllStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
//TODO
if (bAchievementsToo) {
std::for_each(user_achievements.begin(), user_achievements.end(), [](nlohmann::json& v) {
v["earned"] = false;
v["earned_time"] = 0;
});
}
return true;
}
// Leaderboard functions
// asks the Steam back-end for a leaderboard by name, and will create it if it's not yet
// This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT(LeaderboardFindResult_t)
SteamAPICall_t Steam_User_Stats::FindOrCreateLeaderboard(const char* pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType)
{
PRINT_DEBUG("FindOrCreateLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
unsigned int leader = find_leaderboard(pchLeaderboardName);
if (!leader) {
struct Steam_Leaderboard leaderboard;
leaderboard.name = std::string(pchLeaderboardName);
leaderboard.sort_method = eLeaderboardSortMethod;
leaderboard.display_type = eLeaderboardDisplayType;
leaderboards.push_back(leaderboard);
leader = leaderboards.size();
}
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = leader;
data.m_bLeaderboardFound = 1;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// as above, but won't create the leaderboard if it's not found
// This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT(LeaderboardFindResult_t)
SteamAPICall_t Steam_User_Stats::FindLeaderboard(const char* pchLeaderboardName)
{
PRINT_DEBUG("FindLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto settings_Leaderboards = settings->getLeaderboards();
if (settings_Leaderboards.count(pchLeaderboardName)) {
auto config = settings_Leaderboards[pchLeaderboardName];
return FindOrCreateLeaderboard(pchLeaderboardName, config.sort_method, config.display_type);
}
else if (settings->createUnknownLeaderboards()) {
return FindOrCreateLeaderboard(pchLeaderboardName, k_ELeaderboardSortMethodDescending, k_ELeaderboardDisplayTypeNumeric);
}
else {
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = find_leaderboard(pchLeaderboardName);;
data.m_bLeaderboardFound = !!data.m_hSteamLeaderboard;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
}
// returns the name of a leaderboard
const char* Steam_User_Stats::GetLeaderboardName(SteamLeaderboard_t hSteamLeaderboard)
{
PRINT_DEBUG("GetLeaderboardName\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return "";
return leaderboards[hSteamLeaderboard - 1].name.c_str();
}
// returns the total number of entries in a leaderboard, as of the last request
int Steam_User_Stats::GetLeaderboardEntryCount(SteamLeaderboard_t hSteamLeaderboard)
{
PRINT_DEBUG("GetLeaderboardEntryCount\n");
return 0;
}
// returns the sort method of the leaderboard
ELeaderboardSortMethod Steam_User_Stats::GetLeaderboardSortMethod(SteamLeaderboard_t hSteamLeaderboard)
{
PRINT_DEBUG("GetLeaderboardSortMethod\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardSortMethodNone;
return leaderboards[hSteamLeaderboard - 1].sort_method;
}
// returns the display type of the leaderboard
ELeaderboardDisplayType Steam_User_Stats::GetLeaderboardDisplayType(SteamLeaderboard_t hSteamLeaderboard)
{
PRINT_DEBUG("GetLeaderboardDisplayType\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardDisplayTypeNone;
return leaderboards[hSteamLeaderboard - 1].display_type;
}
// Asks the Steam back-end for a set of rows in the leaderboard.
// This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t
// LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below)
// You can ask for more entries than exist, and it will return as many as do exist.
// k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries]
// k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate
// e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after
// k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user
STEAM_CALL_RESULT(LeaderboardScoresDownloaded_t)
SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntries(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd)
{
PRINT_DEBUG("DownloadLeaderboardEntries %llu %i %i %i\n", hSteamLeaderboard, eLeaderboardDataRequest, nRangeStart, nRangeEnd);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoresDownloaded_t data;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = 123;
data.m_cEntryCount = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers
// if a user doesn't have a leaderboard entry, they won't be included in the result
// a max of 100 users can be downloaded at a time, with only one outstanding call at a time
STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers)
STEAM_CALL_RESULT(LeaderboardScoresDownloaded_t)
SteamAPICall_t Steam_User_Stats::DownloadLeaderboardEntriesForUsers(SteamLeaderboard_t hSteamLeaderboard,
STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID * prgUsers, int cUsers)
{
PRINT_DEBUG("DownloadLeaderboardEntriesForUsers %i %llu\n", cUsers, cUsers > 0 ? prgUsers[0].ConvertToUint64() : 0);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoresDownloaded_t data;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = 123;
data.m_cEntryCount = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Returns data about a single leaderboard entry
// use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries
// e.g.
// void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded )
// {
// for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ )
// {
// LeaderboardEntry_t leaderboardEntry;
// int32 details[3]; // we know this is how many we've stored previously
// GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 );
// assert( leaderboardEntry.m_cDetails == 3 );
// ...
// }
// once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid
bool Steam_User_Stats::GetDownloadedLeaderboardEntry(SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t * pLeaderboardEntry, int32 * pDetails, int cDetailsMax)
{
PRINT_DEBUG("GetDownloadedLeaderboardEntry\n");
return false;
}
// Uploads a user score to the Steam back-end.
// This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t
// Details are extra game-defined information regarding how the user got that score
// pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list
STEAM_CALL_RESULT(LeaderboardScoreUploaded_t)
SteamAPICall_t Steam_User_Stats::UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32 * pScoreDetails, int cScoreDetailsCount)
{
PRINT_DEBUG("UploadLeaderboardScore\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoreUploaded_t data;
data.m_bSuccess = 1; //needs to be success or DOA6 freezes when uploading score.
//data.m_bSuccess = 0;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_nScore = nScore;
//data.m_bScoreChanged = 1;
data.m_bScoreChanged = 0;
//data.m_nGlobalRankNew = 1;
data.m_nGlobalRankNew = 0;
data.m_nGlobalRankPrevious = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
SteamAPICall_t Steam_User_Stats::UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, int32 nScore, int32 * pScoreDetails, int cScoreDetailsCount)
{
PRINT_DEBUG("UploadLeaderboardScore old\n");
return UploadLeaderboardScore(hSteamLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, pScoreDetails, cScoreDetailsCount);
}
// Attaches a piece of user generated content the user's entry on a leaderboard.
// hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare().
// This call is asynchronous, with the result returned in LeaderboardUGCSet_t.
STEAM_CALL_RESULT(LeaderboardUGCSet_t)
SteamAPICall_t Steam_User_Stats::AttachLeaderboardUGC(SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC)
{
PRINT_DEBUG("AttachLeaderboardUGC\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardUGCSet_t data = {};
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) {
data.m_eResult = k_EResultFail;
}
else {
data.m_eResult = k_EResultOK;
}
data.m_hSteamLeaderboard = hSteamLeaderboard;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Retrieves the number of players currently playing your game (online + offline)
// This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t
STEAM_CALL_RESULT(NumberOfCurrentPlayers_t)
SteamAPICall_t Steam_User_Stats::GetNumberOfCurrentPlayers()
{
PRINT_DEBUG("GetNumberOfCurrentPlayers\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
NumberOfCurrentPlayers_t data;
data.m_bSuccess = 1;
data.m_cPlayers = 69;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Requests that Steam fetch data on the percentage of players who have received each achievement
// for the game globally.
// This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t.
STEAM_CALL_RESULT(GlobalAchievementPercentagesReady_t)
SteamAPICall_t Steam_User_Stats::RequestGlobalAchievementPercentages()
{
PRINT_DEBUG("RequestGlobalAchievementPercentages\n");
}
// Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch
// the next most achieved afterwards. Will return -1 if there is no data on achievement
// percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback).
int Steam_User_Stats::GetMostAchievedAchievementInfo(char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved)
{
PRINT_DEBUG("GetMostAchievedAchievementInfo\n");
}
// Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another
// GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last
// achievement has been iterated.
int Steam_User_Stats::GetNextMostAchievedAchievementInfo(int iIteratorPrevious, char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved)
{
PRINT_DEBUG("GetNextMostAchievedAchievementInfo\n");
}
// Returns the percentage of users who have achieved the specified achievement.
bool Steam_User_Stats::GetAchievementAchievedPercent(const char* pchName, float* pflPercent)
{
PRINT_DEBUG("GetAchievementAchievedPercent\n");
}
// Requests global stats data, which is available for stats marked as "aggregated".
// This call is asynchronous, with the results returned in GlobalStatsReceived_t.
// nHistoryDays specifies how many days of day-by-day history to retrieve in addition
// to the overall totals. The limit is 60.
STEAM_CALL_RESULT(GlobalStatsReceived_t)
SteamAPICall_t Steam_User_Stats::RequestGlobalStats(int nHistoryDays)
{
PRINT_DEBUG("RequestGlobalStats %i\n", nHistoryDays);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
GlobalStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Gets the lifetime totals for an aggregated stat
bool Steam_User_Stats::GetGlobalStat(const char* pchStatName, int64 * pData)
{
PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
return false;
}
bool Steam_User_Stats::GetGlobalStat(const char* pchStatName, double* pData)
{
PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
return false;
}
// Gets history for an aggregated stat. pData will be filled with daily values, starting with today.
// So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago,
// etc. cubData is the size in bytes of the pubData buffer. Returns the number of
// elements actually set.
int32 Steam_User_Stats::GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) int64 * pData, uint32 cubData)
{
PRINT_DEBUG("GetGlobalStatHistory int64 %s\n", pchStatName);
return 0;
}
int32 Steam_User_Stats::GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) double* pData, uint32 cubData)
{
PRINT_DEBUG("GetGlobalStatHistory double %s\n", pchStatName);
return 0;
}

View File

@ -19,6 +19,7 @@
#define __INCLUDED_STEAM_USER_STATS_H__ #define __INCLUDED_STEAM_USER_STATS_H__
#include "base.h" #include "base.h"
#include "../overlay_experimental/steam_overlay.h"
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
@ -50,45 +51,261 @@ private:
Settings *settings; Settings *settings;
SteamCallResults *callback_results; SteamCallResults *callback_results;
class SteamCallBacks *callbacks; class SteamCallBacks *callbacks;
class Steam_Overlay* overlay;
std::vector<struct Steam_Leaderboard> leaderboards; std::vector<struct Steam_Leaderboard> leaderboards;
nlohmann::json defined_achievements; nlohmann::json defined_achievements;
nlohmann::json user_achievements; nlohmann::json user_achievements;
unsigned int find_leaderboard(std::string name); unsigned int find_leaderboard(std::string name)
{
unsigned index = 1;
for (auto &leaderboard : leaderboards) {
if (leaderboard.name == name) return index;
++index;
}
void load_achievements_db(); return 0;
void load_achievements(); }
void save_achievements();
void load_achievements_db()
{
std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file;
local_storage->load_json(file_path, defined_achievements);
}
void load_achievements()
{
local_storage->load_json_file("", achievements_user_file, user_achievements);
}
void save_achievements()
{
local_storage->write_json_file("", achievements_user_file, user_achievements);
}
public: public:
Steam_User_Stats(Settings* settings, Local_Storage* local_storage, class SteamCallResults* callback_results, class SteamCallBacks* callbacks); Steam_User_Stats(Settings *settings, Local_Storage *local_storage, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, Steam_Overlay* overlay):
settings(settings),
nlohmann::json const& GetAchievementsDb() const; local_storage(local_storage),
callback_results(callback_results),
callbacks(callbacks),
defined_achievements(nlohmann::json::object()),
user_achievements(nlohmann::json::object()),
overlay(overlay)
{
load_achievements_db(); // achievements db
load_achievements(); // achievements per user
}
// Ask the server to send down this user's data and achievements for this game // Ask the server to send down this user's data and achievements for this game
STEAM_CALL_BACK( UserStatsReceived_t ) STEAM_CALL_BACK( UserStatsReceived_t )
bool RequestCurrentStats(); bool RequestCurrentStats()
{
PRINT_DEBUG("Steam_User_Stats::RequestCurrentStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
UserStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = settings->get_local_steam_id();
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
return true;
}
// Data accessors // Data accessors
bool GetStat(const char* pchName, int32* pData); bool GetStat( const char *pchName, int32 *pData )
bool GetStat(const char* pchName, float* pData); {
PRINT_DEBUG("GetStat int32 %s\n", pchName);
if (!pchName || !pData) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto stats_config = settings->getStats();
auto stats_data = stats_config.find(pchName);
if (stats_data != stats_config.end()) {
if (stats_data->second.type != Stat_Type::STAT_TYPE_INT) return false;
}
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char* )pData, sizeof(*pData));
if (read_data == sizeof(int32))
return true;
if (stats_data != stats_config.end()) {
*pData = stats_data->second.default_value_int;
return true;
}
return false;
}
bool GetStat( const char *pchName, float *pData )
{
PRINT_DEBUG("GetStat float %s\n", pchName);
if (!pchName || !pData) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto stats_config = settings->getStats();
auto stats_data = stats_config.find(pchName);
if (stats_data != stats_config.end()) {
if (stats_data->second.type == Stat_Type::STAT_TYPE_INT) return false;
}
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char* )pData, sizeof(*pData));
if (read_data == sizeof(float))
return true;
if (stats_data != stats_config.end()) {
*pData = stats_data->second.default_value_float;
return true;
}
return false;
}
// Set / update data // Set / update data
bool SetStat(const char* pchName, int32 nData); bool SetStat( const char *pchName, int32 nData )
bool SetStat(const char* pchName, float fData); {
bool UpdateAvgRateStat(const char* pchName, float flCountThisSession, double dSessionLength); PRINT_DEBUG("SetStat int32 %s\n", pchName);
if (!pchName) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, (char* )&nData, sizeof(nData)) == sizeof(nData);
}
bool SetStat( const char *pchName, float fData )
{
PRINT_DEBUG("SetStat float %s\n", pchName);
if (!pchName) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, (char* )&fData, sizeof(fData)) == sizeof(fData);
}
bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength )
{
PRINT_DEBUG("UpdateAvgRateStat %s\n", pchName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
char data[sizeof(float) + sizeof(float) + sizeof(double)];
int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, pchName, (char* )data, sizeof(*data));
float oldcount = 0;
double oldsessionlength = 0;
if (read_data == sizeof(data)) {
memcpy(&oldcount, data + sizeof(float), sizeof(oldcount));
memcpy(&oldsessionlength, data + sizeof(float) + sizeof(double), sizeof(oldsessionlength));
}
oldcount += flCountThisSession;
oldsessionlength += dSessionLength;
float average = oldcount / oldsessionlength;
memcpy(data, &average, sizeof(average));
memcpy(data + sizeof(float), &oldcount, sizeof(oldcount));
memcpy(data + sizeof(float) * 2, &oldsessionlength, sizeof(oldsessionlength));
return local_storage->store_data(Local_Storage::stats_storage_folder, pchName, data, sizeof(data)) == sizeof(data);
}
// Achievement flag accessors // Achievement flag accessors
bool GetAchievement(const char* pchName, bool* pbAchieved); bool GetAchievement( const char *pchName, bool *pbAchieved )
bool SetAchievement(const char* pchName); {
bool ClearAchievement(const char* pchName); PRINT_DEBUG("GetAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName]( nlohmann::json &item ) {
return item["name"].get<std::string>() == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end() && ach != user_achievements.end()) {
if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
return true;
}
} catch (...) {}
if (pbAchieved != nullptr)* pbAchieved = false;
return false;
}
bool SetAchievement( const char *pchName )
{
PRINT_DEBUG("SetAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return item["name"].get<std::string>() == pchName;
});
if (it != defined_achievements.end()) {
if (user_achievements.find(pchName) == user_achievements.end() || user_achievements[pchName].value("earned", false) == false) {
user_achievements[pchName]["earned"] = true;
user_achievements[pchName]["earned_time"] = std::chrono::duration_cast<std::chrono::duration<uint32>>(std::chrono::system_clock::now().time_since_epoch()).count();
#ifdef EMU_OVERLAY
overlay->AddAchievementNotification(it.value());
#endif
save_achievements();
}
return true;
}
} catch (...) {}
return false;
}
bool ClearAchievement( const char *pchName )
{
PRINT_DEBUG("ClearAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
user_achievements[pchName]["earned"] = false;
user_achievements[pchName]["earned_time"] = static_cast<uint32>(0);
save_achievements();
return true;
}
} catch (...) {}
return false;
}
// Get the achievement status, and the time it was unlocked if unlocked. // Get the achievement status, and the time it was unlocked if unlocked.
// If the return value is true, but the unlock time is zero, that means it was unlocked before Steam // If the return value is true, but the unlock time is zero, that means it was unlocked before Steam
// began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970. // began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970.
bool GetAchievementAndUnlockTime(const char* pchName, bool* pbAchieved, uint32* punUnlockTime); bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32 *punUnlockTime )
{
PRINT_DEBUG("GetAchievementAndUnlockTime\n");
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end() && ach != user_achievements.end()) {
if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
if(punUnlockTime != nullptr) *punUnlockTime = (*ach)["earned_time"];
return true;
}
} catch (...) {}
if(pbAchieved != nullptr) *pbAchieved = false;
if(punUnlockTime != nullptr) *punUnlockTime = 0;
return true;
}
// Store the current data on the server, will get a callback when set // Store the current data on the server, will get a callback when set
// And one callback for every new achievement // And one callback for every new achievement
@ -97,7 +314,18 @@ public:
// uploaded has been rejected, either because they broke constraints // uploaded has been rejected, either because they broke constraints
// or were out of date. In this case the server sends back updated values. // or were out of date. In this case the server sends back updated values.
// The stats should be re-iterated to keep in sync. // The stats should be re-iterated to keep in sync.
bool StoreStats(); bool StoreStats()
{
PRINT_DEBUG("StoreStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
UserStatsStored_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return true;
}
// Achievement / GroupAchievement metadata // Achievement / GroupAchievement metadata
@ -105,24 +333,129 @@ public:
// A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback // A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback
// which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the // which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the
// specified achievement. // specified achievement.
int GetAchievementIcon(const char* pchName); int GetAchievementIcon( const char *pchName )
{
PRINT_DEBUG("GetAchievementIcon\n");
if (pchName == nullptr) return 0;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return 0;
}
// Get general attributes for an achievement. Accepts the following keys: // Get general attributes for an achievement. Accepts the following keys:
// - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8) // - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8)
// - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden) // - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden)
const char* GetAchievementDisplayAttribute(const char* pchName, const char* pchKey); const char * GetAchievementDisplayAttribute( const char *pchName, const char *pchKey )
{
PRINT_DEBUG("GetAchievementDisplayAttribute %s %s\n", pchName, pchKey);
if (pchName == nullptr) return "";
if (pchKey == nullptr) return "";
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (strcmp (pchKey, "name") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["displayName"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}
if (strcmp (pchKey, "desc") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["description"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}
if (strcmp (pchKey, "hidden") == 0) {
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
return it.value()["hidden"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}
return "";
}
// Achievement progress - triggers an AchievementProgress callback, that is all. // Achievement progress - triggers an AchievementProgress callback, that is all.
// Calling this w/ N out of N progress will NOT set the achievement, the game must still do that. // Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.
bool IndicateAchievementProgress(const char* pchName, uint32 nCurProgress, uint32 nMaxProgress); bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress )
{
PRINT_DEBUG("IndicateAchievementProgress\n");
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
try {
auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
auto ach = user_achievements.find(pchName);
if (it != defined_achievements.end()) {
bool achieved = false;
if ( ach != user_achievements.end()) {
bool achieved = ach->value("earned", false);
}
UserAchievementStored_t data = {};
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false;
strncpy(data.m_rgchAchievementName, pchName, k_cchStatNameMax);
if (achieved) {
data.m_nCurProgress = 0;
data.m_nMaxProgress = 0;
} else {
user_achievements[pchName]["progress"] = nCurProgress;
user_achievements[pchName]["max_progress"] = nMaxProgress;
data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress;
}
save_achievements();
callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
return true;
}
} catch (...) {}
return false;
}
// Used for iterating achievements. In general games should not need these functions because they should have a // Used for iterating achievements. In general games should not need these functions because they should have a
// list of existing achievements compiled into them // list of existing achievements compiled into them
uint32 GetNumAchievements(); uint32 GetNumAchievements()
{
PRINT_DEBUG("GetNumAchievements\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return defined_achievements.size();
}
// Get achievement name iAchievement in [0,GetNumAchievements) // Get achievement name iAchievement in [0,GetNumAchievements)
const char* GetAchievementName(uint32 iAchievement); const char * GetAchievementName( uint32 iAchievement )
{
PRINT_DEBUG("GetAchievementName\n");
try {
static std::string achievement_name;
achievement_name = defined_achievements[iAchievement]["name"].get<std::string>();
return achievement_name.c_str();
} catch (...) {}
return "";
}
// Friends stats & achievements // Friends stats & achievements
@ -131,44 +464,190 @@ public:
// if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail // if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail
// these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data // these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data
STEAM_CALL_RESULT( UserStatsReceived_t ) STEAM_CALL_RESULT( UserStatsReceived_t )
SteamAPICall_t RequestUserStats(CSteamID steamIDUser); SteamAPICall_t RequestUserStats( CSteamID steamIDUser )
{
PRINT_DEBUG("Steam_User_Stats::RequestUserStats %llu\n", steamIDUser.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
// Enable this to allow hot reload achievements status
//if (steamIDUser == settings->get_local_steam_id()) {
// load_achievements();
//}
UserStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
data.m_steamIDUser = steamIDUser;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
}
// requests stat information for a user, usable after a successful call to RequestUserStats() // requests stat information for a user, usable after a successful call to RequestUserStats()
bool GetUserStat(CSteamID steamIDUser, const char* pchName, int32* pData); bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData )
bool GetUserStat(CSteamID steamIDUser, const char* pchName, float* pData); {
PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64());
if (pchName == nullptr) return false;
bool GetUserAchievement(CSteamID steamIDUser, const char* pchName, bool* pbAchieved); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
} else {
*pData = 0;
}
return true;
}
bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData )
{
PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64());
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
GetStat(pchName, pData);
} else {
*pData = 0;
}
return true;
}
bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved )
{
PRINT_DEBUG("GetUserAchievement %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievement(pchName, pbAchieved);
}
return false;
}
// See notes for GetAchievementAndUnlockTime above // See notes for GetAchievementAndUnlockTime above
bool GetUserAchievementAndUnlockTime(CSteamID steamIDUser, const char* pchName, bool* pbAchieved, uint32* punUnlockTime); bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser, const char *pchName, bool *pbAchieved, uint32 *punUnlockTime )
{
PRINT_DEBUG("GetUserAchievementAndUnlockTime %s\n", pchName);
if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (steamIDUser == settings->get_local_steam_id()) {
return GetAchievementAndUnlockTime(pchName, pbAchieved, punUnlockTime);
}
return false;
}
// Reset stats // Reset stats
bool ResetAllStats(bool bAchievementsToo); bool ResetAllStats( bool bAchievementsToo )
{
PRINT_DEBUG("ResetAllStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
//TODO
if (bAchievementsToo) {
std::for_each(user_achievements.begin(), user_achievements.end(), [](nlohmann::json& v) {
v["earned"] = false;
v["earned_time"] = 0;
});
}
return true;
}
// Leaderboard functions // Leaderboard functions
// asks the Steam back-end for a leaderboard by name, and will create it if it's not yet // asks the Steam back-end for a leaderboard by name, and will create it if it's not yet
// This call is asynchronous, with the result returned in LeaderboardFindResult_t // This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT(LeaderboardFindResult_t) STEAM_CALL_RESULT(LeaderboardFindResult_t)
SteamAPICall_t FindOrCreateLeaderboard(const char* pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType); SteamAPICall_t FindOrCreateLeaderboard( const char *pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType )
{
PRINT_DEBUG("FindOrCreateLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
unsigned int leader = find_leaderboard(pchLeaderboardName);
if (!leader) {
struct Steam_Leaderboard leaderboard;
leaderboard.name = std::string(pchLeaderboardName);
leaderboard.sort_method = eLeaderboardSortMethod;
leaderboard.display_type = eLeaderboardDisplayType;
leaderboards.push_back(leaderboard);
leader = leaderboards.size();
}
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = leader;
data.m_bLeaderboardFound = 1;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// as above, but won't create the leaderboard if it's not found // as above, but won't create the leaderboard if it's not found
// This call is asynchronous, with the result returned in LeaderboardFindResult_t // This call is asynchronous, with the result returned in LeaderboardFindResult_t
STEAM_CALL_RESULT( LeaderboardFindResult_t ) STEAM_CALL_RESULT( LeaderboardFindResult_t )
SteamAPICall_t FindLeaderboard(const char* pchLeaderboardName); SteamAPICall_t FindLeaderboard( const char *pchLeaderboardName )
{
PRINT_DEBUG("FindLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto settings_Leaderboards = settings->getLeaderboards();
if (settings_Leaderboards.count(pchLeaderboardName)) {
auto config = settings_Leaderboards[pchLeaderboardName];
return FindOrCreateLeaderboard(pchLeaderboardName, config.sort_method, config.display_type);
} else if (settings->createUnknownLeaderboards()) {
return FindOrCreateLeaderboard(pchLeaderboardName, k_ELeaderboardSortMethodDescending, k_ELeaderboardDisplayTypeNumeric);
} else {
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = find_leaderboard(pchLeaderboardName);;
data.m_bLeaderboardFound = !!data.m_hSteamLeaderboard;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
}
// returns the name of a leaderboard // returns the name of a leaderboard
const char* GetLeaderboardName(SteamLeaderboard_t hSteamLeaderboard); const char * GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("GetLeaderboardName\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return "";
return leaderboards[hSteamLeaderboard - 1].name.c_str();
}
// returns the total number of entries in a leaderboard, as of the last request // returns the total number of entries in a leaderboard, as of the last request
int GetLeaderboardEntryCount(SteamLeaderboard_t hSteamLeaderboard); int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("GetLeaderboardEntryCount\n");
return 0;
}
// returns the sort method of the leaderboard // returns the sort method of the leaderboard
ELeaderboardSortMethod GetLeaderboardSortMethod(SteamLeaderboard_t hSteamLeaderboard); ELeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("GetLeaderboardSortMethod\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardSortMethodNone;
return leaderboards[hSteamLeaderboard - 1].sort_method;
}
// returns the display type of the leaderboard // returns the display type of the leaderboard
ELeaderboardDisplayType GetLeaderboardDisplayType(SteamLeaderboard_t hSteamLeaderboard); ELeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard )
{
PRINT_DEBUG("GetLeaderboardDisplayType\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) return k_ELeaderboardDisplayTypeNone;
return leaderboards[hSteamLeaderboard - 1].display_type;
}
// Asks the Steam back-end for a set of rows in the leaderboard. // Asks the Steam back-end for a set of rows in the leaderboard.
// This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t // This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t
@ -179,7 +658,16 @@ public:
// e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after // e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after
// k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user // k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t )
SteamAPICall_t DownloadLeaderboardEntries(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd); SteamAPICall_t DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd )
{
PRINT_DEBUG("DownloadLeaderboardEntries %llu %i %i %i\n", hSteamLeaderboard, eLeaderboardDataRequest, nRangeStart, nRangeEnd);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoresDownloaded_t data;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = 123;
data.m_cEntryCount = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers // as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers
// if a user doesn't have a leaderboard entry, they won't be included in the result // if a user doesn't have a leaderboard entry, they won't be included in the result
@ -187,7 +675,17 @@ public:
STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers) STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers)
STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t )
SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard, SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard,
STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID* prgUsers, int cUsers); STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID *prgUsers, int cUsers )
{
PRINT_DEBUG("DownloadLeaderboardEntriesForUsers %i %llu\n", cUsers, cUsers > 0 ? prgUsers[0].ConvertToUint64() : 0);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoresDownloaded_t data;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_hSteamLeaderboardEntries = 123;
data.m_cEntryCount = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Returns data about a single leaderboard entry // Returns data about a single leaderboard entry
// use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries // use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries
@ -203,64 +701,156 @@ public:
// ... // ...
// } // }
// once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid // once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid
bool GetDownloadedLeaderboardEntry(SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t* pLeaderboardEntry, int32* pDetails, int cDetailsMax); bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t *pLeaderboardEntry, int32 *pDetails, int cDetailsMax )
{
PRINT_DEBUG("GetDownloadedLeaderboardEntry\n");
return false;
}
// Uploads a user score to the Steam back-end. // Uploads a user score to the Steam back-end.
// This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t // This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t
// Details are extra game-defined information regarding how the user got that score // Details are extra game-defined information regarding how the user got that score
// pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list // pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list
STEAM_CALL_RESULT( LeaderboardScoreUploaded_t ) STEAM_CALL_RESULT( LeaderboardScoreUploaded_t )
SteamAPICall_t UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32* pScoreDetails, int cScoreDetailsCount); SteamAPICall_t UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32 *pScoreDetails, int cScoreDetailsCount )
{
PRINT_DEBUG("UploadLeaderboardScore\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardScoreUploaded_t data;
data.m_bSuccess = 1; //needs to be success or DOA6 freezes when uploading score.
//data.m_bSuccess = 0;
data.m_hSteamLeaderboard = hSteamLeaderboard;
data.m_nScore = nScore;
//data.m_bScoreChanged = 1;
data.m_bScoreChanged = 0;
//data.m_nGlobalRankNew = 1;
data.m_nGlobalRankNew = 0;
data.m_nGlobalRankPrevious = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
SteamAPICall_t UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, int32 nScore, int32 *pScoreDetails, int cScoreDetailsCount )
{
PRINT_DEBUG("UploadLeaderboardScore old\n");
return UploadLeaderboardScore(hSteamLeaderboard, k_ELeaderboardUploadScoreMethodKeepBest, nScore, pScoreDetails, cScoreDetailsCount);
}
SteamAPICall_t UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, int32 nScore, int32* pScoreDetails, int cScoreDetailsCount);
// Attaches a piece of user generated content the user's entry on a leaderboard. // Attaches a piece of user generated content the user's entry on a leaderboard.
// hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare(). // hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare().
// This call is asynchronous, with the result returned in LeaderboardUGCSet_t. // This call is asynchronous, with the result returned in LeaderboardUGCSet_t.
STEAM_CALL_RESULT( LeaderboardUGCSet_t ) STEAM_CALL_RESULT( LeaderboardUGCSet_t )
SteamAPICall_t AttachLeaderboardUGC(SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC); SteamAPICall_t AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC )
{
PRINT_DEBUG("AttachLeaderboardUGC\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
LeaderboardUGCSet_t data = {};
if (hSteamLeaderboard > leaderboards.size() || hSteamLeaderboard <= 0) {
data.m_eResult = k_EResultFail;
} else {
data.m_eResult = k_EResultOK;
}
data.m_hSteamLeaderboard = hSteamLeaderboard;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Retrieves the number of players currently playing your game (online + offline) // Retrieves the number of players currently playing your game (online + offline)
// This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t // This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t
STEAM_CALL_RESULT( NumberOfCurrentPlayers_t ) STEAM_CALL_RESULT( NumberOfCurrentPlayers_t )
SteamAPICall_t GetNumberOfCurrentPlayers(); SteamAPICall_t GetNumberOfCurrentPlayers()
{
PRINT_DEBUG("GetNumberOfCurrentPlayers\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
NumberOfCurrentPlayers_t data;
data.m_bSuccess = 1;
data.m_cPlayers = 69;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Requests that Steam fetch data on the percentage of players who have received each achievement // Requests that Steam fetch data on the percentage of players who have received each achievement
// for the game globally. // for the game globally.
// This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t. // This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t.
STEAM_CALL_RESULT( GlobalAchievementPercentagesReady_t ) STEAM_CALL_RESULT( GlobalAchievementPercentagesReady_t )
SteamAPICall_t RequestGlobalAchievementPercentages(); SteamAPICall_t RequestGlobalAchievementPercentages()
{
PRINT_DEBUG("RequestGlobalAchievementPercentages\n");
}
// Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch // Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch
// the next most achieved afterwards. Will return -1 if there is no data on achievement // the next most achieved afterwards. Will return -1 if there is no data on achievement
// percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback). // percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback).
int GetMostAchievedAchievementInfo(char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved); int GetMostAchievedAchievementInfo( char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved )
{
PRINT_DEBUG("GetMostAchievedAchievementInfo\n");
}
// Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another // Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another
// GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last // GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last
// achievement has been iterated. // achievement has been iterated.
int GetNextMostAchievedAchievementInfo(int iIteratorPrevious, char* pchName, uint32 unNameBufLen, float* pflPercent, bool* pbAchieved); int GetNextMostAchievedAchievementInfo( int iIteratorPrevious, char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved )
{
PRINT_DEBUG("GetNextMostAchievedAchievementInfo\n");
}
// Returns the percentage of users who have achieved the specified achievement. // Returns the percentage of users who have achieved the specified achievement.
bool GetAchievementAchievedPercent(const char* pchName, float* pflPercent); bool GetAchievementAchievedPercent( const char *pchName, float *pflPercent )
{
PRINT_DEBUG("GetAchievementAchievedPercent\n");
}
// Requests global stats data, which is available for stats marked as "aggregated". // Requests global stats data, which is available for stats marked as "aggregated".
// This call is asynchronous, with the results returned in GlobalStatsReceived_t. // This call is asynchronous, with the results returned in GlobalStatsReceived_t.
// nHistoryDays specifies how many days of day-by-day history to retrieve in addition // nHistoryDays specifies how many days of day-by-day history to retrieve in addition
// to the overall totals. The limit is 60. // to the overall totals. The limit is 60.
STEAM_CALL_RESULT( GlobalStatsReceived_t ) STEAM_CALL_RESULT( GlobalStatsReceived_t )
SteamAPICall_t RequestGlobalStats(int nHistoryDays); SteamAPICall_t RequestGlobalStats( int nHistoryDays )
{
PRINT_DEBUG("RequestGlobalStats %i\n", nHistoryDays);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
GlobalStatsReceived_t data;
data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_eResult = k_EResultOK;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
// Gets the lifetime totals for an aggregated stat // Gets the lifetime totals for an aggregated stat
bool GetGlobalStat(const char* pchStatName, int64* pData); bool GetGlobalStat( const char *pchStatName, int64 *pData )
bool GetGlobalStat(const char* pchStatName, double* pData); {
PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
return false;
}
bool GetGlobalStat( const char *pchStatName, double *pData )
{
PRINT_DEBUG("GetGlobalStat %s\n", pchStatName);
return false;
}
// Gets history for an aggregated stat. pData will be filled with daily values, starting with today. // Gets history for an aggregated stat. pData will be filled with daily values, starting with today.
// So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago, // So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago,
// etc. cubData is the size in bytes of the pubData buffer. Returns the number of // etc. cubData is the size in bytes of the pubData buffer. Returns the number of
// elements actually set. // elements actually set.
int32 GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) int64* pData, uint32 cubData); int32 GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) int64 *pData, uint32 cubData )
int32 GetGlobalStatHistory(const char* pchStatName, STEAM_ARRAY_COUNT(cubData) double* pData, uint32 cubData); {
PRINT_DEBUG("GetGlobalStatHistory int64 %s\n", pchStatName);
return 0;
}
int32 GetGlobalStatHistory( const char *pchStatName, STEAM_ARRAY_COUNT(cubData) double *pData, uint32 cubData )
{
PRINT_DEBUG("GetGlobalStatHistory double %s\n", pchStatName);
return 0;
}
}; };
#endif//__INCLUDED_STEAM_USER_STATS_H__ #endif//__INCLUDED_STEAM_USER_STATS_H__

View File

@ -1,12 +0,0 @@
#!/bin/bash
rm -rf glew*
URL="https://downloads.sourceforge.net/project/glew/glew/2.1.0/glew-2.1.0-win32.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fglew%2Ffiles%2Fglew%2F2.1.0%2Fglew-2.1.0-win32.zip%2Fdownload&ts=1565791827"
wget "$URL" -O glew.zip
unzip glew.zip
rm glew.zip
mv glew-* glew
# Fix libraries name
sed -i "s/LIBCMT/libcmt/;s/OLDNAMES/oldnames/" glew/lib/Release/*/glew32s.lib

View File

@ -0,0 +1 @@
Rename this to: disable_overlay.EXAMPLE.txt to disable the overlay.

View File

@ -3,7 +3,7 @@
#include <algorithm> #include <algorithm>
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#ifdef STEAM_WIN32 #ifdef STEAM_WIN32
#include "../detours/detours.h" #include "../detours/detours.h"
@ -85,4 +85,4 @@ void Base_Hook::UnhookAll()
#endif #endif
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -1,7 +1,7 @@
#ifndef __INCLUDED_BASE_HOOK_H__ #ifndef __INCLUDED_BASE_HOOK_H__
#define __INCLUDED_BASE_HOOK_H__ #define __INCLUDED_BASE_HOOK_H__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <vector> #include <vector>
#include <utility> #include <utility>
@ -45,6 +45,6 @@ public:
} }
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_BASE_HOOK_H__ #endif//__INCLUDED_BASE_HOOK_H__

View File

@ -1,7 +1,7 @@
#include "../dll/dll.h" #include "../dll/dll.h"
#include "Hook_Manager.h" #include "Hook_Manager.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
Hook_Manager::Hook_Manager() Hook_Manager::Hook_Manager()
{} {}
@ -33,4 +33,4 @@ void Hook_Manager::RemoveHook(Base_Hook* hook)
} }
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -3,7 +3,7 @@
#include "Base_Hook.h" #include "Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <set> #include <set>
@ -24,6 +24,6 @@ public:
void RemoveHook(Base_Hook* hook); void RemoveHook(Base_Hook* hook);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_HOOK_BASE_H__ #endif//__INCLUDED_HOOK_BASE_H__

View File

@ -4,7 +4,7 @@
#include "Base_Hook.h" #include "Base_Hook.h"
#include <thread> #include <thread>
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#ifdef __WINDOWS__ #ifdef __WINDOWS__
struct IDXGISwapChain; struct IDXGISwapChain;
@ -101,5 +101,5 @@ public:
}; };
#endif//__WINDOWS__ #endif//__WINDOWS__
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_RENDERER_DETECTOR_H__ #endif//__INCLUDED_RENDERER_DETECTOR_H__

View File

@ -4,7 +4,7 @@
#include "../dll/dll.h" #include "../dll/dll.h"
#ifdef __LINUX__ #ifdef __LINUX__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/imgui_impl_opengl3.h> #include <impls/imgui_impl_opengl3.h>
@ -171,5 +171,5 @@ void OpenGLX_Hook::loadFunctions(decltype(glXSwapBuffers)* pfnglXSwapBuffers)
_glXSwapBuffers = pfnglXSwapBuffers; _glXSwapBuffers = pfnglXSwapBuffers;
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__LINUX__ #endif//__LINUX__

View File

@ -4,7 +4,7 @@
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifdef __LINUX__ #ifdef __LINUX__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/glx.h> #include <GL/glx.h>
@ -44,6 +44,6 @@ public:
void loadFunctions(decltype(glXSwapBuffers)* pfnglXSwapBuffers); void loadFunctions(decltype(glXSwapBuffers)* pfnglXSwapBuffers);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__LINUX__ #endif//__LINUX__
#endif//__INCLUDED_OPENGLX_HOOK_H__ #endif//__INCLUDED_OPENGLX_HOOK_H__

View File

@ -3,7 +3,7 @@
#include "../dll/dll.h" #include "../dll/dll.h"
#ifdef __LINUX__ #ifdef __LINUX__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/linux/imgui_impl_x11.h> #include <impls/linux/imgui_impl_x11.h>
@ -201,5 +201,5 @@ const char* X11_Hook::get_lib_name() const
return DLL_NAME; return DLL_NAME;
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//#__LINUX__ #endif//#__LINUX__

View File

@ -4,7 +4,7 @@
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifdef __LINUX__ #ifdef __LINUX__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <X11/X.h> // XEvent types #include <X11/X.h> // XEvent types
#include <X11/Xlib.h> // XEvent structure #include <X11/Xlib.h> // XEvent structure
@ -58,6 +58,6 @@ public:
virtual const char* get_lib_name() const; virtual const char* get_lib_name() const;
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__LINUX__ #endif//__LINUX__
#endif//__INCLUDED_X11_HOOK_H__ #endif//__INCLUDED_X11_HOOK_H__

View File

@ -1,6 +1,6 @@
#include "steam_overlay.h" #include "steam_overlay.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <thread> #include <thread>
#include <string> #include <string>

View File

@ -68,7 +68,7 @@ struct Notification
std::pair<const Friend, friend_window_state>* frd; std::pair<const Friend, friend_window_state>* frd;
}; };
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
class Steam_Overlay class Steam_Overlay
{ {

View File

@ -3,7 +3,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/windows/imgui_impl_dx10.h> #include <impls/windows/imgui_impl_dx10.h>
@ -169,4 +169,4 @@ void DX10_Hook::loadFunctions(IDXGISwapChain *pSwapChain)
#undef LOAD_FUNC #undef LOAD_FUNC
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -2,7 +2,7 @@
#define __INCLUDED_DX10_HOOK_H__ #define __INCLUDED_DX10_HOOK_H__
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <d3d10.h> #include <d3d10.h>
#include "DirectX_VTables.h" #include "DirectX_VTables.h"
@ -46,6 +46,6 @@ public:
void loadFunctions(IDXGISwapChain *pSwapChain); void loadFunctions(IDXGISwapChain *pSwapChain);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_DX10_HOOK_H__ #endif//__INCLUDED_DX10_HOOK_H__

View File

@ -3,7 +3,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/windows/imgui_impl_dx11.h> #include <impls/windows/imgui_impl_dx11.h>
@ -183,4 +183,4 @@ void DX11_Hook::loadFunctions(IDXGISwapChain *pSwapChain)
#undef LOAD_FUNC #undef LOAD_FUNC
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -2,7 +2,7 @@
#define __INCLUDED_DX11_HOOK_H__ #define __INCLUDED_DX11_HOOK_H__
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <d3d11.h> #include <d3d11.h>
#include "DirectX_VTables.h" #include "DirectX_VTables.h"
@ -46,6 +46,6 @@ public:
void loadFunctions(IDXGISwapChain *pSwapChain); void loadFunctions(IDXGISwapChain *pSwapChain);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_DX11_HOOK_H__ #endif//__INCLUDED_DX11_HOOK_H__

View File

@ -3,7 +3,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/windows/imgui_impl_dx12.h> #include <impls/windows/imgui_impl_dx12.h>
@ -316,4 +316,4 @@ void DX12_Hook::loadFunctions(ID3D12CommandQueue* pCommandQueue, IDXGISwapChain
#undef LOAD_FUNC #undef LOAD_FUNC
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -2,7 +2,7 @@
#define __INCLUDED_DX12_HOOK_H__ #define __INCLUDED_DX12_HOOK_H__
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <d3d12.h> #include <d3d12.h>
#include <dxgi1_4.h> #include <dxgi1_4.h>
@ -56,5 +56,5 @@ public:
void loadFunctions(ID3D12CommandQueue* pCommandQueue, IDXGISwapChain* pSwapChain); void loadFunctions(ID3D12CommandQueue* pCommandQueue, IDXGISwapChain* pSwapChain);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_DX12_HOOK_H__ #endif//__INCLUDED_DX12_HOOK_H__

View File

@ -3,7 +3,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/windows/imgui_impl_dx9.h> #include <impls/windows/imgui_impl_dx9.h>
@ -169,4 +169,4 @@ void DX9_Hook::loadFunctions(IDirect3DDevice9* pDevice, bool ex)
#undef LOAD_FUNC #undef LOAD_FUNC
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -2,7 +2,7 @@
#define __INCLUDED_DX9_HOOK_H__ #define __INCLUDED_DX9_HOOK_H__
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <d3d9.h> #include <d3d9.h>
#include "DirectX_VTables.h" #include "DirectX_VTables.h"
@ -47,6 +47,6 @@ public:
void loadFunctions(IDirect3DDevice9 *pDevice, bool ex); void loadFunctions(IDirect3DDevice9 *pDevice, bool ex);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_DX9_HOOK_H__ #endif//__INCLUDED_DX9_HOOK_H__

View File

@ -3,7 +3,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/imgui_impl_opengl3.h> #include <impls/imgui_impl_opengl3.h>
@ -144,4 +144,4 @@ void OpenGL_Hook::loadFunctions(wglSwapBuffers_t pfnwglSwapBuffers)
wglSwapBuffers = pfnwglSwapBuffers; wglSwapBuffers = pfnwglSwapBuffers;
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -2,7 +2,7 @@
#define __INCLUDED_OPENGL_HOOK_H__ #define __INCLUDED_OPENGL_HOOK_H__
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
class OpenGL_Hook : public Base_Hook class OpenGL_Hook : public Base_Hook
{ {
@ -38,5 +38,5 @@ public:
void loadFunctions(wglSwapBuffers_t pfnwglSwapBuffers); void loadFunctions(wglSwapBuffers_t pfnwglSwapBuffers);
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__INCLUDED_OPENGL_HOOK_H__ #endif//__INCLUDED_OPENGL_HOOK_H__

View File

@ -2,7 +2,7 @@
#include "../Renderer_Detector.h" #include "../Renderer_Detector.h"
#include "../../dll/dll.h" #include "../../dll/dll.h"
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
#include <imgui.h> #include <imgui.h>
#include <impls/windows/imgui_impl_win32.h> #include <impls/windows/imgui_impl_win32.h>
@ -206,4 +206,4 @@ const char* Windows_Hook::get_lib_name() const
return DLL_NAME; return DLL_NAME;
} }
#endif//NO_OVERLAY #endif//EMU_OVERLAY

View File

@ -4,7 +4,7 @@
#include "../Base_Hook.h" #include "../Base_Hook.h"
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#ifndef NO_OVERLAY #ifdef EMU_OVERLAY
class Windows_Hook : public Base_Hook class Windows_Hook : public Base_Hook
{ {
@ -45,6 +45,6 @@ public:
virtual const char* get_lib_name() const; virtual const char* get_lib_name() const;
}; };
#endif//NO_OVERLAY #endif//EMU_OVERLAY
#endif//__WINDOWS__ #endif//__WINDOWS__
#endif//__INCLUDED_WINDOWS_HOOK_H__ #endif//__INCLUDED_WINDOWS_HOOK_H__