mirror of
https://ceregatti.org/git/daniel/dayzdockerserver.git
synced 2025-05-06 14:21:18 +00:00
Add a Steam API client. WIP.
This commit is contained in:
parent
8a87edf798
commit
176c06fd48
8 changed files with 137 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@
|
|||
*.iml
|
||||
.env*
|
||||
node_modules/
|
||||
web/client/bin
|
||||
web/client/obj
|
||||
|
|
BIN
files/bin/steam_api64.dll
Normal file
BIN
files/bin/steam_api64.dll
Normal file
Binary file not shown.
|
@ -70,6 +70,9 @@ installxml(){
|
|||
xmlstarlet ed -L -r "events" -v "eventposdef" /tmp/x
|
||||
fi
|
||||
fi
|
||||
# Some mod authors ship invalid XML files. This fixes comments before the <?xml> declaration.
|
||||
xmlstarlet ed -d '//comment()' /tmp/x > /tmp/y && mv /tmp/y /tmp/x
|
||||
# Check for the required root node and add it if it's missing
|
||||
if ! grep -q '<'${CHECK}'>' /tmp/x
|
||||
then
|
||||
echo " - has no root node <${CHECK}>. fixing..."
|
||||
|
|
|
@ -8,6 +8,7 @@ then
|
|||
alias ls='ls --color'
|
||||
export PS1="${debian_chroot:+($debian_chroot)}\u@dz-web:\w\$ "
|
||||
unset DEVELOPMENT
|
||||
export PATH=${PATH}:/usr/local/dotnet
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
|
111
web/client/Program.cs
Normal file
111
web/client/Program.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using Steamworks;
|
||||
|
||||
namespace SteamworksNET_StandaloneTest {
|
||||
class Program {
|
||||
static CallResult<NumberOfCurrentPlayers_t> m_NumberOfCurrentPlayers;
|
||||
static CallResult<LeaderboardFindResult_t> m_callResultFindLeaderboard;
|
||||
static Callback<PersonaStateChange_t> m_PersonaStateChange;
|
||||
static Callback<UserStatsReceived_t> m_UserStatsReceived;
|
||||
|
||||
static void InitializeCallbacks() {
|
||||
m_NumberOfCurrentPlayers = CallResult<NumberOfCurrentPlayers_t>.Create(OnNumberOfCurrentPlayers);
|
||||
m_callResultFindLeaderboard = CallResult<LeaderboardFindResult_t>.Create(OnFindLeaderboard);
|
||||
m_PersonaStateChange = Callback<PersonaStateChange_t>.Create(OnPersonaStateChange);
|
||||
m_UserStatsReceived = Callback<UserStatsReceived_t>.Create(
|
||||
(pCallback) => {
|
||||
Console.WriteLine("[" + UserStatsReceived_t.k_iCallback + " - UserStatsReceived] - " + pCallback.m_eResult + " -- " + pCallback.m_nGameID + " -- " + pCallback.m_steamIDUser);
|
||||
});
|
||||
}
|
||||
|
||||
static void Main(string[] args) {
|
||||
try {
|
||||
if (!SteamAPI.Init()) {
|
||||
Console.WriteLine("SteamAPI.Init() failed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (DllNotFoundException e) { // We check this here as it will be the first instance of it.
|
||||
Console.WriteLine(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Packsize.Test()) {
|
||||
Console.WriteLine("You're using the wrong Steamworks.NET Assembly for this platform!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DllCheck.Test()) {
|
||||
Console.WriteLine("You're using the wrong dlls for this platform!");
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeCallbacks(); // We do this after SteamAPI.Init() has occurred
|
||||
|
||||
|
||||
Console.WriteLine("Requesting Current Stats - " + SteamUserStats.RequestCurrentStats());
|
||||
|
||||
Console.WriteLine("CurrentGameLanguage: " + SteamApps.GetCurrentGameLanguage());
|
||||
Console.WriteLine("PersonaName: " + SteamFriends.GetPersonaName());
|
||||
|
||||
{
|
||||
string folder;
|
||||
uint length = SteamApps.GetAppInstallDir(SteamUtils.GetAppID(), out folder, 260);
|
||||
Console.WriteLine("AppInstallDir: " + length + " " + folder);
|
||||
}
|
||||
|
||||
|
||||
m_NumberOfCurrentPlayers.Set(SteamUserStats.GetNumberOfCurrentPlayers());
|
||||
Console.WriteLine("Requesting Number of Current Players");
|
||||
|
||||
{
|
||||
SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard("Quickest Win");
|
||||
m_callResultFindLeaderboard.Set(hSteamAPICall);
|
||||
Console.WriteLine("Requesting Leaderboard");
|
||||
}
|
||||
|
||||
while (true) {
|
||||
// Must be called from the primary thread.
|
||||
SteamAPI.RunCallbacks();
|
||||
|
||||
if (Console.KeyAvailable) {
|
||||
ConsoleKeyInfo info = Console.ReadKey(true);
|
||||
|
||||
if (info.Key == ConsoleKey.Escape) {
|
||||
break;
|
||||
}
|
||||
else if (info.Key == ConsoleKey.Spacebar) {
|
||||
SteamUserStats.RequestCurrentStats();
|
||||
Console.WriteLine("Requesting Current Stats");
|
||||
}
|
||||
else if (info.Key == ConsoleKey.D1) {
|
||||
SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard("Quickest Win");
|
||||
m_callResultFindLeaderboard.Set(hSteamAPICall);
|
||||
Console.WriteLine("FindLeaderboard() - " + hSteamAPICall);
|
||||
}
|
||||
else if (info.Key == ConsoleKey.D2) {
|
||||
SteamAPICall_t hSteamAPICall = SteamUserStats.GetNumberOfCurrentPlayers();
|
||||
m_NumberOfCurrentPlayers.Set(hSteamAPICall);
|
||||
Console.WriteLine("GetNumberOfCurrentPlayers() - " + hSteamAPICall);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
SteamAPI.Shutdown();
|
||||
}
|
||||
|
||||
static void OnNumberOfCurrentPlayers(NumberOfCurrentPlayers_t pCallback, bool bIOFailure) {
|
||||
Console.WriteLine("[" + NumberOfCurrentPlayers_t.k_iCallback + " - NumberOfCurrentPlayers] - " + pCallback.m_bSuccess + " -- " + pCallback.m_cPlayers);
|
||||
}
|
||||
|
||||
static void OnFindLeaderboard(LeaderboardFindResult_t pCallback, bool bIOFailure) {
|
||||
Console.WriteLine("[" + LeaderboardFindResult_t.k_iCallback + " - LeaderboardFindResult] - " + pCallback.m_bLeaderboardFound + " -- " + pCallback.m_hSteamLeaderboard);
|
||||
}
|
||||
|
||||
static void OnPersonaStateChange(PersonaStateChange_t pCallback) {
|
||||
Console.WriteLine("[" + PersonaStateChange_t.k_iCallback + " - PersonaStateChange] - " + pCallback.m_ulSteamID + " -- " + pCallback.m_nChangeFlags);
|
||||
}
|
||||
}
|
||||
}
|
3
web/client/README.md
Normal file
3
web/client/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Steamworks client
|
||||
|
||||
WIP
|
16
web/client/proj.csproj
Normal file
16
web/client/proj.csproj
Normal file
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Steamworks.NET">
|
||||
<HintPath>\usr\local\steamworks.net\OSX-Linux-x64\Steamworks.NET.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
1
web/client/steam_appid.txt
Normal file
1
web/client/steam_appid.txt
Normal file
|
@ -0,0 +1 @@
|
|||
223350
|
Loading…
Add table
Reference in a new issue