rdiscord_sdk 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +13 -0
- data/.vscode/c_cpp_properties.json +24 -0
- data/.vscode/settings.json +102 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +46 -0
- data/INTERNALS.md +0 -0
- data/LICENSE +674 -0
- data/README.md +187 -0
- data/Rakefile +17 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/rdiscord_sdk/activity.cpp +297 -0
- data/ext/rdiscord_sdk/activity.h +17 -0
- data/ext/rdiscord_sdk/common.cpp +65 -0
- data/ext/rdiscord_sdk/common.h +88 -0
- data/ext/rdiscord_sdk/extconf.rb +54 -0
- data/ext/rdiscord_sdk/gem_activity_manager.cpp +273 -0
- data/ext/rdiscord_sdk/gem_activity_manager.h +8 -0
- data/ext/rdiscord_sdk/gem_user_manager.cpp +114 -0
- data/ext/rdiscord_sdk/gem_user_manager.h +8 -0
- data/ext/rdiscord_sdk/rdiscord_sdk.cpp +77 -0
- data/ext/rdiscord_sdk/rdiscord_sdk.h +17 -0
- data/ext/rdiscord_sdk/user.cpp +98 -0
- data/ext/rdiscord_sdk/user.h +19 -0
- data/lib/rdiscord_sdk/enums.rb +162 -0
- data/lib/rdiscord_sdk/rdiscord_sdk.so +0 -0
- data/lib/rdiscord_sdk/version.rb +16 -0
- data/lib/rdiscord_sdk.rb +3 -0
- data/rdiscord_sdk.gemspec +34 -0
- data/third-party/include/achievement_manager.cpp +98 -0
- data/third-party/include/achievement_manager.h +34 -0
- data/third-party/include/activity_manager.cpp +177 -0
- data/third-party/include/activity_manager.h +42 -0
- data/third-party/include/application_manager.cpp +78 -0
- data/third-party/include/application_manager.h +30 -0
- data/third-party/include/core.cpp +182 -0
- data/third-party/include/core.h +64 -0
- data/third-party/include/discord.h +16 -0
- data/third-party/include/event.h +59 -0
- data/third-party/include/ffi.h +942 -0
- data/third-party/include/image_manager.cpp +57 -0
- data/third-party/include/image_manager.h +28 -0
- data/third-party/include/lobby_manager.cpp +547 -0
- data/third-party/include/lobby_manager.h +88 -0
- data/third-party/include/network_manager.cpp +103 -0
- data/third-party/include/network_manager.h +63 -0
- data/third-party/include/overlay_manager.cpp +112 -0
- data/third-party/include/overlay_manager.h +33 -0
- data/third-party/include/relationship_manager.cpp +90 -0
- data/third-party/include/relationship_manager.h +32 -0
- data/third-party/include/storage_manager.cpp +158 -0
- data/third-party/include/storage_manager.h +46 -0
- data/third-party/include/store_manager.cpp +160 -0
- data/third-party/include/store_manager.h +38 -0
- data/third-party/include/types.cpp +769 -0
- data/third-party/include/types.h +492 -0
- data/third-party/include/user_manager.cpp +80 -0
- data/third-party/include/user_manager.h +31 -0
- data/third-party/include/voice_manager.cpp +124 -0
- data/third-party/include/voice_manager.h +37 -0
- data/third-party/lib/x86/discord_game_sdk.dll +0 -0
- data/third-party/lib/x86/discord_game_sdk.dll.lib +0 -0
- data/third-party/lib/x86_64/discord_game_sdk.bundle +0 -0
- data/third-party/lib/x86_64/discord_game_sdk.dll +0 -0
- data/third-party/lib/x86_64/discord_game_sdk.dll.lib +0 -0
- data/third-party/lib/x86_64/discord_game_sdk.dylib +0 -0
- data/third-party/lib/x86_64/discord_game_sdk.so +0 -0
- metadata +114 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "types.h"
|
4
|
+
|
5
|
+
namespace discord {
|
6
|
+
|
7
|
+
class StorageManager final {
|
8
|
+
public:
|
9
|
+
~StorageManager() = default;
|
10
|
+
|
11
|
+
Result Read(char const* name,
|
12
|
+
std::uint8_t* data,
|
13
|
+
std::uint32_t dataLength,
|
14
|
+
std::uint32_t* read);
|
15
|
+
void ReadAsync(char const* name,
|
16
|
+
std::function<void(Result, std::uint8_t*, std::uint32_t)> callback);
|
17
|
+
void ReadAsyncPartial(char const* name,
|
18
|
+
std::uint64_t offset,
|
19
|
+
std::uint64_t length,
|
20
|
+
std::function<void(Result, std::uint8_t*, std::uint32_t)> callback);
|
21
|
+
Result Write(char const* name, std::uint8_t* data, std::uint32_t dataLength);
|
22
|
+
void WriteAsync(char const* name,
|
23
|
+
std::uint8_t* data,
|
24
|
+
std::uint32_t dataLength,
|
25
|
+
std::function<void(Result)> callback);
|
26
|
+
Result Delete(char const* name);
|
27
|
+
Result Exists(char const* name, bool* exists);
|
28
|
+
void Count(std::int32_t* count);
|
29
|
+
Result Stat(char const* name, FileStat* stat);
|
30
|
+
Result StatAt(std::int32_t index, FileStat* stat);
|
31
|
+
Result GetPath(char path[4096]);
|
32
|
+
|
33
|
+
private:
|
34
|
+
friend class Core;
|
35
|
+
|
36
|
+
StorageManager() = default;
|
37
|
+
StorageManager(StorageManager const& rhs) = delete;
|
38
|
+
StorageManager& operator=(StorageManager const& rhs) = delete;
|
39
|
+
StorageManager(StorageManager&& rhs) = delete;
|
40
|
+
StorageManager& operator=(StorageManager&& rhs) = delete;
|
41
|
+
|
42
|
+
IDiscordStorageManager* internal_;
|
43
|
+
static IDiscordStorageEvents events_;
|
44
|
+
};
|
45
|
+
|
46
|
+
} // namespace discord
|
@@ -0,0 +1,160 @@
|
|
1
|
+
#if !defined(_CRT_SECURE_NO_WARNINGS)
|
2
|
+
#define _CRT_SECURE_NO_WARNINGS
|
3
|
+
#endif
|
4
|
+
|
5
|
+
#include "store_manager.h"
|
6
|
+
|
7
|
+
#include "core.h"
|
8
|
+
|
9
|
+
#include <cstring>
|
10
|
+
#include <memory>
|
11
|
+
|
12
|
+
namespace discord {
|
13
|
+
|
14
|
+
class StoreEvents final {
|
15
|
+
public:
|
16
|
+
static void OnEntitlementCreate(void* callbackData, DiscordEntitlement* entitlement)
|
17
|
+
{
|
18
|
+
auto* core = reinterpret_cast<Core*>(callbackData);
|
19
|
+
if (!core) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
|
23
|
+
auto& module = core->StoreManager();
|
24
|
+
module.OnEntitlementCreate(*reinterpret_cast<Entitlement const*>(entitlement));
|
25
|
+
}
|
26
|
+
|
27
|
+
static void OnEntitlementDelete(void* callbackData, DiscordEntitlement* entitlement)
|
28
|
+
{
|
29
|
+
auto* core = reinterpret_cast<Core*>(callbackData);
|
30
|
+
if (!core) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
|
34
|
+
auto& module = core->StoreManager();
|
35
|
+
module.OnEntitlementDelete(*reinterpret_cast<Entitlement const*>(entitlement));
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
IDiscordStoreEvents StoreManager::events_{
|
40
|
+
&StoreEvents::OnEntitlementCreate,
|
41
|
+
&StoreEvents::OnEntitlementDelete,
|
42
|
+
};
|
43
|
+
|
44
|
+
void StoreManager::FetchSkus(std::function<void(Result)> callback)
|
45
|
+
{
|
46
|
+
static auto wrapper = [](void* callbackData, EDiscordResult result) -> void {
|
47
|
+
std::unique_ptr<std::function<void(Result)>> cb(
|
48
|
+
reinterpret_cast<std::function<void(Result)>*>(callbackData));
|
49
|
+
if (!cb || !(*cb)) {
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
(*cb)(static_cast<Result>(result));
|
53
|
+
};
|
54
|
+
std::unique_ptr<std::function<void(Result)>> cb{};
|
55
|
+
cb.reset(new std::function<void(Result)>(std::move(callback)));
|
56
|
+
internal_->fetch_skus(internal_, cb.release(), wrapper);
|
57
|
+
}
|
58
|
+
|
59
|
+
void StoreManager::CountSkus(std::int32_t* count)
|
60
|
+
{
|
61
|
+
if (!count) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
|
65
|
+
internal_->count_skus(internal_, reinterpret_cast<int32_t*>(count));
|
66
|
+
}
|
67
|
+
|
68
|
+
Result StoreManager::GetSku(Snowflake skuId, Sku* sku)
|
69
|
+
{
|
70
|
+
if (!sku) {
|
71
|
+
return Result::InternalError;
|
72
|
+
}
|
73
|
+
|
74
|
+
auto result = internal_->get_sku(internal_, skuId, reinterpret_cast<DiscordSku*>(sku));
|
75
|
+
return static_cast<Result>(result);
|
76
|
+
}
|
77
|
+
|
78
|
+
Result StoreManager::GetSkuAt(std::int32_t index, Sku* sku)
|
79
|
+
{
|
80
|
+
if (!sku) {
|
81
|
+
return Result::InternalError;
|
82
|
+
}
|
83
|
+
|
84
|
+
auto result = internal_->get_sku_at(internal_, index, reinterpret_cast<DiscordSku*>(sku));
|
85
|
+
return static_cast<Result>(result);
|
86
|
+
}
|
87
|
+
|
88
|
+
void StoreManager::FetchEntitlements(std::function<void(Result)> callback)
|
89
|
+
{
|
90
|
+
static auto wrapper = [](void* callbackData, EDiscordResult result) -> void {
|
91
|
+
std::unique_ptr<std::function<void(Result)>> cb(
|
92
|
+
reinterpret_cast<std::function<void(Result)>*>(callbackData));
|
93
|
+
if (!cb || !(*cb)) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
(*cb)(static_cast<Result>(result));
|
97
|
+
};
|
98
|
+
std::unique_ptr<std::function<void(Result)>> cb{};
|
99
|
+
cb.reset(new std::function<void(Result)>(std::move(callback)));
|
100
|
+
internal_->fetch_entitlements(internal_, cb.release(), wrapper);
|
101
|
+
}
|
102
|
+
|
103
|
+
void StoreManager::CountEntitlements(std::int32_t* count)
|
104
|
+
{
|
105
|
+
if (!count) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
internal_->count_entitlements(internal_, reinterpret_cast<int32_t*>(count));
|
110
|
+
}
|
111
|
+
|
112
|
+
Result StoreManager::GetEntitlement(Snowflake entitlementId, Entitlement* entitlement)
|
113
|
+
{
|
114
|
+
if (!entitlement) {
|
115
|
+
return Result::InternalError;
|
116
|
+
}
|
117
|
+
|
118
|
+
auto result = internal_->get_entitlement(
|
119
|
+
internal_, entitlementId, reinterpret_cast<DiscordEntitlement*>(entitlement));
|
120
|
+
return static_cast<Result>(result);
|
121
|
+
}
|
122
|
+
|
123
|
+
Result StoreManager::GetEntitlementAt(std::int32_t index, Entitlement* entitlement)
|
124
|
+
{
|
125
|
+
if (!entitlement) {
|
126
|
+
return Result::InternalError;
|
127
|
+
}
|
128
|
+
|
129
|
+
auto result = internal_->get_entitlement_at(
|
130
|
+
internal_, index, reinterpret_cast<DiscordEntitlement*>(entitlement));
|
131
|
+
return static_cast<Result>(result);
|
132
|
+
}
|
133
|
+
|
134
|
+
Result StoreManager::HasSkuEntitlement(Snowflake skuId, bool* hasEntitlement)
|
135
|
+
{
|
136
|
+
if (!hasEntitlement) {
|
137
|
+
return Result::InternalError;
|
138
|
+
}
|
139
|
+
|
140
|
+
auto result =
|
141
|
+
internal_->has_sku_entitlement(internal_, skuId, reinterpret_cast<bool*>(hasEntitlement));
|
142
|
+
return static_cast<Result>(result);
|
143
|
+
}
|
144
|
+
|
145
|
+
void StoreManager::StartPurchase(Snowflake skuId, std::function<void(Result)> callback)
|
146
|
+
{
|
147
|
+
static auto wrapper = [](void* callbackData, EDiscordResult result) -> void {
|
148
|
+
std::unique_ptr<std::function<void(Result)>> cb(
|
149
|
+
reinterpret_cast<std::function<void(Result)>*>(callbackData));
|
150
|
+
if (!cb || !(*cb)) {
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
(*cb)(static_cast<Result>(result));
|
154
|
+
};
|
155
|
+
std::unique_ptr<std::function<void(Result)>> cb{};
|
156
|
+
cb.reset(new std::function<void(Result)>(std::move(callback)));
|
157
|
+
internal_->start_purchase(internal_, skuId, cb.release(), wrapper);
|
158
|
+
}
|
159
|
+
|
160
|
+
} // namespace discord
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "types.h"
|
4
|
+
|
5
|
+
namespace discord {
|
6
|
+
|
7
|
+
class StoreManager final {
|
8
|
+
public:
|
9
|
+
~StoreManager() = default;
|
10
|
+
|
11
|
+
void FetchSkus(std::function<void(Result)> callback);
|
12
|
+
void CountSkus(std::int32_t* count);
|
13
|
+
Result GetSku(Snowflake skuId, Sku* sku);
|
14
|
+
Result GetSkuAt(std::int32_t index, Sku* sku);
|
15
|
+
void FetchEntitlements(std::function<void(Result)> callback);
|
16
|
+
void CountEntitlements(std::int32_t* count);
|
17
|
+
Result GetEntitlement(Snowflake entitlementId, Entitlement* entitlement);
|
18
|
+
Result GetEntitlementAt(std::int32_t index, Entitlement* entitlement);
|
19
|
+
Result HasSkuEntitlement(Snowflake skuId, bool* hasEntitlement);
|
20
|
+
void StartPurchase(Snowflake skuId, std::function<void(Result)> callback);
|
21
|
+
|
22
|
+
Event<Entitlement const&> OnEntitlementCreate;
|
23
|
+
Event<Entitlement const&> OnEntitlementDelete;
|
24
|
+
|
25
|
+
private:
|
26
|
+
friend class Core;
|
27
|
+
|
28
|
+
StoreManager() = default;
|
29
|
+
StoreManager(StoreManager const& rhs) = delete;
|
30
|
+
StoreManager& operator=(StoreManager const& rhs) = delete;
|
31
|
+
StoreManager(StoreManager&& rhs) = delete;
|
32
|
+
StoreManager& operator=(StoreManager&& rhs) = delete;
|
33
|
+
|
34
|
+
IDiscordStoreManager* internal_;
|
35
|
+
static IDiscordStoreEvents events_;
|
36
|
+
};
|
37
|
+
|
38
|
+
} // namespace discord
|