Revert"gone back to discord-rpc repo" wrong branch
This reverts commit 41ac291f6b
.
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
|||||||
[submodule "src/lib/godot-cpp"]
|
[submodule "src/lib/godot-cpp"]
|
||||||
path = src/lib/godot-cpp
|
path = src/lib/godot-cpp
|
||||||
url = https://github.com/godotengine/godot-cpp
|
url = https://github.com/godotengine/godot-cpp
|
||||||
[submodule "src/lib/discord-rpc"]
|
|
||||||
path = src/lib/discord-rpc
|
|
||||||
url = https://github.com/vaporvee/discord-rpc
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -1,20 +1,20 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Discord_SDK.app_id = 1099618430065324082
|
Discord_SDK.app_id = 1099618430065324082
|
||||||
Discord_SDK.debug()
|
Discord_SDK.debug()
|
||||||
# Discord_SDK.app_id = 1099618430065324082
|
# Discord_SDK.app_id = 1099618430065324082
|
||||||
# Discord_SDK.details = "A demo activity by vaporvee#1231"
|
# Discord_SDK.details = "A demo activity by vaporvee#1231"
|
||||||
# Discord_SDK.state = "Checkpoint 23/23"
|
# Discord_SDK.state = "Checkpoint 23/23"
|
||||||
|
#
|
||||||
# Discord_SDK.large_image = "game"
|
# Discord_SDK.large_image = "game"
|
||||||
# Discord_SDK.large_image_text = "Try it now!"
|
# Discord_SDK.large_image_text = "Try it now!"
|
||||||
# Discord_SDK.small_image = "boss"
|
# Discord_SDK.small_image = "boss"
|
||||||
# Discord_SDK.small_image_text = "Fighting the end boss! D:"
|
# Discord_SDK.small_image_text = "Fighting the end boss! D:"
|
||||||
|
#
|
||||||
#Discord_SDK.start_timestamp = int(Time.get_unix_time_from_system())
|
# #Discord_SDK.start_timestamp = int(Time.get_unix_time_from_system())
|
||||||
# Discord_SDK.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
|
# Discord_SDK.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
|
||||||
|
#
|
||||||
# Discord_SDK.refresh()
|
# Discord_SDK.refresh()
|
||||||
|
#
|
||||||
# $Info.text = $Info.text.replace("{discordinfo}",str(Discord_SDK.get_is_discord_working())).replace("{id}",str(Discord_SDK.app_id)).replace("{details}",Discord_SDK.details).replace("{state}",Discord_SDK.state).replace("{lkey}",Discord_SDK.large_image).replace("{ltext}",Discord_SDK.large_image_text).replace("{skey}",Discord_SDK.small_image).replace("{stext}",Discord_SDK.small_image_text).replace("{stimestamp}",str(Discord_SDK.start_timestamp)).replace("{etimestamp}",str(Discord_SDK.end_timestamp))
|
# $Info.text = $Info.text.replace("{discordinfo}",str(Discord_SDK.get_is_discord_working())).replace("{id}",str(Discord_SDK.app_id)).replace("{details}",Discord_SDK.details).replace("{state}",Discord_SDK.state).replace("{lkey}",Discord_SDK.large_image).replace("{ltext}",Discord_SDK.large_image_text).replace("{skey}",Discord_SDK.small_image).replace("{stext}",Discord_SDK.small_image_text).replace("{stimestamp}",str(Discord_SDK.start_timestamp)).replace("{etimestamp}",str(Discord_SDK.end_timestamp))
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "discordgodot.h"
|
#include "discordgodot.h"
|
||||||
#include "lib/discord-rpc/include/discord_rpc.h"
|
#include "lib/discord_game_sdk/cpp/discord.h"
|
||||||
#include <godot_cpp/core/class_db.hpp>
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
#include <godot_cpp/classes/editor_plugin.hpp>
|
#include <godot_cpp/classes/editor_plugin.hpp>
|
||||||
#include <godot_cpp/variant/utility_functions.hpp>
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
@@ -9,7 +9,10 @@ using namespace godot;
|
|||||||
|
|
||||||
Discord_SDK *Discord_SDK::singleton = nullptr;
|
Discord_SDK *Discord_SDK::singleton = nullptr;
|
||||||
|
|
||||||
DiscordRichPresence discordPresence;
|
discord::Core *core{};
|
||||||
|
discord::Result result;
|
||||||
|
discord::Activity activity{};
|
||||||
|
discord::User user{};
|
||||||
|
|
||||||
void Discord_SDK::_bind_methods()
|
void Discord_SDK::_bind_methods()
|
||||||
{
|
{
|
||||||
@@ -72,36 +75,35 @@ Discord_SDK::~Discord_SDK()
|
|||||||
|
|
||||||
void Discord_SDK::coreupdate()
|
void Discord_SDK::coreupdate()
|
||||||
{
|
{
|
||||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
if (result == discord::Result::Ok && app_id > 0)
|
||||||
Discord_UpdateConnection();
|
{
|
||||||
#endif
|
::core->RunCallbacks();
|
||||||
Discord_RunCallbacks();
|
}
|
||||||
}
|
}
|
||||||
void Discord_SDK::debug()
|
void Discord_SDK::debug()
|
||||||
{
|
{
|
||||||
DiscordEventHandlers handlers;
|
result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
|
||||||
Discord_Initialize("1099618430065324082", &handlers, 1, NULL);
|
activity.SetState("Test from Godot!");
|
||||||
memset(&discordPresence, 0, sizeof(discordPresence));
|
activity.SetDetails("I worked months on this");
|
||||||
discordPresence.state = "\"new\" discord rpc lib for godot";
|
activity.GetAssets().SetLargeImage("test1");
|
||||||
discordPresence.details = "Teeest";
|
activity.GetAssets().SetLargeText("wow test text for large image");
|
||||||
discordPresence.startTimestamp = 0;
|
activity.GetAssets().SetSmallImage("godot");
|
||||||
discordPresence.endTimestamp = time(0) + 5 * 60;
|
activity.GetAssets().SetSmallText("wow test text for small image");
|
||||||
discordPresence.largeImageKey = "example_game";
|
activity.GetTimestamps().SetStart(1682242800);
|
||||||
discordPresence.smallImageKey = "fighting";
|
if (result == discord::Result::Ok)
|
||||||
discordPresence.partyId = "party1234";
|
{
|
||||||
discordPresence.partySize = 1;
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
discordPresence.partyMax = 6;
|
core->UserManager().OnCurrentUserUpdate.Connect([]()
|
||||||
discordPresence.partyPrivacy = DISCORD_PARTY_PUBLIC;
|
{ core->UserManager().GetCurrentUser(&user); });
|
||||||
discordPresence.matchSecret = "xyzzy";
|
}
|
||||||
discordPresence.joinSecret = "join";
|
else
|
||||||
discordPresence.spectateSecret = "look";
|
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
|
||||||
discordPresence.instance = 0;
|
|
||||||
Discord_UpdatePresence(&discordPresence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord_SDK::set_app_id(const int64_t &value)
|
void Discord_SDK::set_app_id(const int64_t &value)
|
||||||
{
|
{
|
||||||
app_id = value;
|
app_id = value;
|
||||||
|
result = discord::Core::Create(value, DiscordCreateFlags_NoRequireDiscord, &core);
|
||||||
}
|
}
|
||||||
int64_t Discord_SDK::get_app_id() const
|
int64_t Discord_SDK::get_app_id() const
|
||||||
{
|
{
|
||||||
@@ -111,6 +113,7 @@ int64_t Discord_SDK::get_app_id() const
|
|||||||
void Discord_SDK::set_state(const String &value)
|
void Discord_SDK::set_state(const String &value)
|
||||||
{
|
{
|
||||||
state = value;
|
state = value;
|
||||||
|
activity.SetState(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_state() const
|
String Discord_SDK::get_state() const
|
||||||
{
|
{
|
||||||
@@ -119,6 +122,7 @@ String Discord_SDK::get_state() const
|
|||||||
void Discord_SDK::set_details(const String &value)
|
void Discord_SDK::set_details(const String &value)
|
||||||
{
|
{
|
||||||
details = value;
|
details = value;
|
||||||
|
activity.SetDetails(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_details() const
|
String Discord_SDK::get_details() const
|
||||||
{
|
{
|
||||||
@@ -127,11 +131,20 @@ String Discord_SDK::get_details() const
|
|||||||
|
|
||||||
void Discord_SDK::refresh()
|
void Discord_SDK::refresh()
|
||||||
{
|
{
|
||||||
|
if (result == discord::Result::Ok && app_id > 0)
|
||||||
|
{
|
||||||
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
|
core->UserManager().OnCurrentUserUpdate.Connect([]()
|
||||||
|
{ core->UserManager().GetCurrentUser(&user); });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord_SDK::set_large_image(const String &value)
|
void Discord_SDK::set_large_image(const String &value)
|
||||||
{
|
{
|
||||||
large_image = value;
|
large_image = value;
|
||||||
|
activity.GetAssets().SetLargeImage(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_large_image() const
|
String Discord_SDK::get_large_image() const
|
||||||
{
|
{
|
||||||
@@ -140,6 +153,7 @@ String Discord_SDK::get_large_image() const
|
|||||||
void Discord_SDK::set_large_image_text(const String &value)
|
void Discord_SDK::set_large_image_text(const String &value)
|
||||||
{
|
{
|
||||||
large_image_text = value;
|
large_image_text = value;
|
||||||
|
activity.GetAssets().SetLargeText(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_large_image_text() const
|
String Discord_SDK::get_large_image_text() const
|
||||||
{
|
{
|
||||||
@@ -148,6 +162,7 @@ String Discord_SDK::get_large_image_text() const
|
|||||||
void Discord_SDK::set_small_image(const String &value)
|
void Discord_SDK::set_small_image(const String &value)
|
||||||
{
|
{
|
||||||
small_image = value;
|
small_image = value;
|
||||||
|
activity.GetAssets().SetSmallImage(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_small_image() const
|
String Discord_SDK::get_small_image() const
|
||||||
{
|
{
|
||||||
@@ -156,6 +171,7 @@ String Discord_SDK::get_small_image() const
|
|||||||
void Discord_SDK::set_small_image_text(const String &value)
|
void Discord_SDK::set_small_image_text(const String &value)
|
||||||
{
|
{
|
||||||
small_image_text = value;
|
small_image_text = value;
|
||||||
|
activity.GetAssets().SetSmallText(value.utf8().get_data());
|
||||||
}
|
}
|
||||||
String Discord_SDK::get_small_image_text() const
|
String Discord_SDK::get_small_image_text() const
|
||||||
{
|
{
|
||||||
@@ -165,26 +181,28 @@ String Discord_SDK::get_small_image_text() const
|
|||||||
void Discord_SDK::set_start_timestamp(const int64_t &value)
|
void Discord_SDK::set_start_timestamp(const int64_t &value)
|
||||||
{
|
{
|
||||||
start_timestamp = value;
|
start_timestamp = value;
|
||||||
|
activity.GetTimestamps().SetStart(value);
|
||||||
}
|
}
|
||||||
int64_t Discord_SDK::get_start_timestamp() const
|
int64_t Discord_SDK::get_start_timestamp() const
|
||||||
{
|
{
|
||||||
return 0;
|
return activity.GetTimestamps().GetStart();
|
||||||
}
|
}
|
||||||
void Discord_SDK::set_end_timestamp(const int64_t &value)
|
void Discord_SDK::set_end_timestamp(const int64_t &value)
|
||||||
{
|
{
|
||||||
end_timestamp = value;
|
end_timestamp = value;
|
||||||
|
activity.GetTimestamps().SetEnd(value);
|
||||||
}
|
}
|
||||||
int64_t Discord_SDK::get_end_timestamp() const
|
int64_t Discord_SDK::get_end_timestamp() const
|
||||||
{
|
{
|
||||||
return 0;
|
return activity.GetTimestamps().GetEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Discord_SDK::get_is_discord_working() const
|
bool Discord_SDK::get_is_discord_working() const
|
||||||
{
|
{
|
||||||
return 0;
|
return result == discord::Result::Ok && app_id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Discord_SDK::get_result_int() const
|
int Discord_SDK::get_result_int() const
|
||||||
{
|
{
|
||||||
return 0;
|
return static_cast<int>(result);
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,15 @@
|
|||||||
#define DISCORDGODOT_H
|
#define DISCORDGODOT_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <godot_cpp/classes/ref_counted.hpp>
|
#include "lib/discord_game_sdk/cpp/discord.h"
|
||||||
|
#include <godot_cpp/classes/object.hpp>
|
||||||
#include <godot_cpp/core/class_db.hpp>
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
class Discord_SDK : public RefCounted
|
class Discord_SDK : public Object
|
||||||
{
|
{
|
||||||
GDCLASS(Discord_SDK, RefCounted);
|
GDCLASS(Discord_SDK, Object);
|
||||||
|
|
||||||
static Discord_SDK *singleton;
|
static Discord_SDK *singleton;
|
||||||
|
|
||||||
|
Submodule src/lib/discord-rpc deleted from 3eea5821c5
BIN
src/lib/discord_game_sdk.zip
Normal file
BIN
src/lib/discord_game_sdk.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user