forked from FoxCouncil/Steamworks.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteamAppList.cs
116 lines (84 loc) · 3.94 KB
/
SteamAppList.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// !! // Steamworks.Core - SteamAppList.cs
// *.-". // Created: 2016-10-22 [2:36 PM]
// | | // Copyright 2016 // MIT License // The Fox Council
// Modified by: Fox Diller on 2016-10-22 @ 3:03 PM
#region Usings
using System;
using System.Runtime.InteropServices;
using System.Text;
#endregion
namespace Steamworks.Core
{
public class SteamAppList : ISteamAppList
{
private readonly IntPtr m_instancePtr;
public SteamAppList(IntPtr c_instancePtr)
{
m_instancePtr = c_instancePtr;
}
private void CheckIfUsable()
{
if (m_instancePtr == IntPtr.Zero)
{
throw new InvalidOperationException("Steam App List Not Initialized!");
}
}
#region Native Method
[DllImport(SteamApi.STEAMWORKS_MODULE_NAME, EntryPoint = "SteamAPI_ISteamAppList_GetNumInstalledApps")]
private static extern uint SteamAPI_ISteamAppList_GetNumInstalledApps(IntPtr c_instancePtr);
[DllImport(SteamApi.STEAMWORKS_MODULE_NAME, EntryPoint = "SteamAPI_ISteamAppList_GetInstalledApps")]
private static extern uint SteamAPI_ISteamAppList_GetInstalledApps(IntPtr c_instancePtr, ref uint c_pvecAppId, uint c_unMaxAppIDs);
[DllImport(SteamApi.STEAMWORKS_MODULE_NAME, EntryPoint = "SteamAPI_ISteamAppList_GetAppName")]
private static extern int SteamAPI_ISteamAppList_GetAppName(IntPtr c_instancePtr, uint c_nAppId, StringBuilder c_pchName, int c_cchNameMax);
[DllImport(SteamApi.STEAMWORKS_MODULE_NAME, EntryPoint = "SteamAPI_ISteamAppList_GetAppInstallDir")]
private static extern int SteamAPI_ISteamAppList_GetAppInstallDir(IntPtr c_instancePtr, uint c_nAppId, SafeUtf8String c_pchDirectory, int c_cchNameMax);
[DllImport(SteamApi.STEAMWORKS_MODULE_NAME, EntryPoint = "SteamAPI_ISteamAppList_GetAppBuildId")]
private static extern int SteamAPI_ISteamAppList_GetAppBuildId(IntPtr c_instancePtr, uint c_nAppId);
#endregion
#region Overrides of ISteamAppList
public override IntPtr GetIntPtr()
{
return m_instancePtr;
}
public override uint GetNumInstalledApps()
{
CheckIfUsable();
var a_result = SteamAPI_ISteamAppList_GetNumInstalledApps(m_instancePtr);
return a_result;
}
public override uint GetInstalledApps(ref uint c_pvecAppId, uint c_unMaxAppIDs)
{
CheckIfUsable();
var a_result = SteamAPI_ISteamAppList_GetInstalledApps(m_instancePtr, ref c_pvecAppId, c_unMaxAppIDs);
return a_result;
}
public override int GetAppName(uint c_nAppId, StringBuilder c_pchName, int c_cchNameMax)
{
CheckIfUsable();
var a_result = SteamAPI_ISteamAppList_GetAppName(m_instancePtr, c_nAppId, c_pchName, c_cchNameMax);
return a_result;
}
public override int GetAppInstallDir(uint c_nAppId, string c_pchDirectory, int c_cchNameMax)
{
CheckIfUsable();
var a_result = SteamAPI_ISteamAppList_GetAppInstallDir(m_instancePtr, c_nAppId, new SafeUtf8String(c_pchDirectory), c_cchNameMax);
return a_result;
}
public override int GetAppBuildId(uint c_nAppId)
{
CheckIfUsable();
var a_result = SteamAPI_ISteamAppList_GetAppBuildId(m_instancePtr, c_nAppId);
return a_result;
}
#endregion
}
public abstract class ISteamAppList
{
public abstract IntPtr GetIntPtr();
public abstract uint GetNumInstalledApps();
public abstract uint GetInstalledApps(ref uint c_pvecAppId, uint c_unMaxAppIDs);
public abstract int GetAppName(uint c_nAppId, StringBuilder c_pchName, int c_cchNameMax);
public abstract int GetAppInstallDir(uint c_nAppId, string c_pchDirectory, int c_cchNameMax);
public abstract int GetAppBuildId(uint c_nAppId);
}
}