using System; using System.Runtime.InteropServices; namespace Steamworks { public static class SteamGameServerUtils { public static uint GetSecondsSinceAppActive() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetSecondsSinceAppActive(CSteamGameServerAPIContext.GetSteamUtils()); } public static uint GetSecondsSinceComputerActive() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetSecondsSinceComputerActive(CSteamGameServerAPIContext.GetSteamUtils()); } public static EUniverse GetConnectedUniverse() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetConnectedUniverse(CSteamGameServerAPIContext.GetSteamUtils()); } public static uint GetServerRealTime() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetServerRealTime(CSteamGameServerAPIContext.GetSteamUtils()); } public static string GetIPCountry() { InteropHelp.TestIfAvailableGameServer(); return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamUtils_GetIPCountry(CSteamGameServerAPIContext.GetSteamUtils())); } public static bool GetImageSize(int iImage, out uint pnWidth, out uint pnHeight) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetImageSize(CSteamGameServerAPIContext.GetSteamUtils(), iImage, out pnWidth, out pnHeight); } public static bool GetImageRGBA(int iImage, byte[] pubDest, int nDestBufferSize) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetImageRGBA(CSteamGameServerAPIContext.GetSteamUtils(), iImage, pubDest, nDestBufferSize); } public static bool GetCSERIPPort(out uint unIP, out ushort usPort) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetCSERIPPort(CSteamGameServerAPIContext.GetSteamUtils(), out unIP, out usPort); } public static byte GetCurrentBatteryPower() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetCurrentBatteryPower(CSteamGameServerAPIContext.GetSteamUtils()); } public static AppId_t GetAppID() { InteropHelp.TestIfAvailableGameServer(); return (AppId_t)NativeMethods.ISteamUtils_GetAppID(CSteamGameServerAPIContext.GetSteamUtils()); } public static void SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition) { InteropHelp.TestIfAvailableGameServer(); NativeMethods.ISteamUtils_SetOverlayNotificationPosition(CSteamGameServerAPIContext.GetSteamUtils(), eNotificationPosition); } public static bool IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_IsAPICallCompleted(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall, out pbFailed); } public static ESteamAPICallFailure GetAPICallFailureReason(SteamAPICall_t hSteamAPICall) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetAPICallFailureReason(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall); } public static bool GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetAPICallResult(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall, pCallback, cubCallback, iCallbackExpected, out pbFailed); } public static uint GetIPCCallCount() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetIPCCallCount(CSteamGameServerAPIContext.GetSteamUtils()); } public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction) { InteropHelp.TestIfAvailableGameServer(); NativeMethods.ISteamUtils_SetWarningMessageHook(CSteamGameServerAPIContext.GetSteamUtils(), pFunction); } public static bool IsOverlayEnabled() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_IsOverlayEnabled(CSteamGameServerAPIContext.GetSteamUtils()); } public static bool BOverlayNeedsPresent() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_BOverlayNeedsPresent(CSteamGameServerAPIContext.GetSteamUtils()); } public static SteamAPICall_t CheckFileSignature(string szFileName) { InteropHelp.TestIfAvailableGameServer(); using (InteropHelp.UTF8StringHandle szFileName2 = new InteropHelp.UTF8StringHandle(szFileName)) { return (SteamAPICall_t)NativeMethods.ISteamUtils_CheckFileSignature(CSteamGameServerAPIContext.GetSteamUtils(), szFileName2); } } public static bool ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, string pchDescription, uint unCharMax, string pchExistingText) { InteropHelp.TestIfAvailableGameServer(); using (InteropHelp.UTF8StringHandle pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) { using (InteropHelp.UTF8StringHandle pchExistingText2 = new InteropHelp.UTF8StringHandle(pchExistingText)) { return NativeMethods.ISteamUtils_ShowGamepadTextInput(CSteamGameServerAPIContext.GetSteamUtils(), eInputMode, eLineInputMode, pchDescription2, unCharMax, pchExistingText2); } } } public static uint GetEnteredGamepadTextLength() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_GetEnteredGamepadTextLength(CSteamGameServerAPIContext.GetSteamUtils()); } public static bool GetEnteredGamepadTextInput(out string pchText, uint cchText) { InteropHelp.TestIfAvailableGameServer(); IntPtr intPtr = Marshal.AllocHGlobal((int)cchText); bool flag = NativeMethods.ISteamUtils_GetEnteredGamepadTextInput(CSteamGameServerAPIContext.GetSteamUtils(), intPtr, cchText); pchText = ((!flag) ? null : InteropHelp.PtrToStringUTF8(intPtr)); Marshal.FreeHGlobal(intPtr); return flag; } public static string GetSteamUILanguage() { InteropHelp.TestIfAvailableGameServer(); return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamUtils_GetSteamUILanguage(CSteamGameServerAPIContext.GetSteamUtils())); } public static bool IsSteamRunningInVR() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_IsSteamRunningInVR(CSteamGameServerAPIContext.GetSteamUtils()); } public static void SetOverlayNotificationInset(int nHorizontalInset, int nVerticalInset) { InteropHelp.TestIfAvailableGameServer(); NativeMethods.ISteamUtils_SetOverlayNotificationInset(CSteamGameServerAPIContext.GetSteamUtils(), nHorizontalInset, nVerticalInset); } public static bool IsSteamInBigPictureMode() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_IsSteamInBigPictureMode(CSteamGameServerAPIContext.GetSteamUtils()); } public static void StartVRDashboard() { InteropHelp.TestIfAvailableGameServer(); NativeMethods.ISteamUtils_StartVRDashboard(CSteamGameServerAPIContext.GetSteamUtils()); } public static bool IsVRHeadsetStreamingEnabled() { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamUtils_IsVRHeadsetStreamingEnabled(CSteamGameServerAPIContext.GetSteamUtils()); } public static void SetVRHeadsetStreamingEnabled(bool bEnabled) { InteropHelp.TestIfAvailableGameServer(); NativeMethods.ISteamUtils_SetVRHeadsetStreamingEnabled(CSteamGameServerAPIContext.GetSteamUtils(), bEnabled); } } }