Update v1.3

This commit is contained in:
Yannik
2023-05-12 12:03:48 +02:00
parent 28a61a539b
commit 4992948be5
21 changed files with 511 additions and 112 deletions

View File

@@ -9,17 +9,17 @@ extends Node
#SELECT THE TEXT WITH YOUR MOUSE AND CTR + K TO UNCOMMENT THE FOLLOWING
#func _ready():
# Discord_SDK.app_id = 1099618430065324082 # Application ID
# print("Discord working: " + str(Discord_SDK.get_is_discord_working())) # A boolean if everything worked
# Discord_SDK.details = "A demo activity by vaporvee#1231"
# Discord_SDK.state = "Checkpoint 23/23"
# Discord_Activity.app_id = 1099618430065324082 # Application ID
# print("Discord working: " + str(Discord_Activity.get_is_discord_working())) # A boolean if everything worked
# Discord_Activity.details = "A demo activity by vaporvee#1231"
# Discord_Activity.state = "Checkpoint 23/23"
#
# Discord_SDK.large_image = "game" # Image key from "Art Assets"
# Discord_SDK.large_image_text = "Try it now!"
# Discord_SDK.small_image = "boss" # Image key from "Art Assets"
# Discord_SDK.small_image_text = "Fighting the end boss! D:"
# Discord_Activity.large_image = "game" # Image key from "Art Assets"
# Discord_Activity.large_image_text = "Try it now!"
# Discord_Activity.small_image = "boss" # Image key from "Art Assets"
# Discord_Activity.small_image_text = "Fighting the end boss! D:"
#
# Discord_SDK.start_timestamp = int(Time.get_unix_time_from_system()) # "02:41 elapsed"
# Discord_SDK.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
# Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system()) # "02:41 elapsed"
# Discord_Activity.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
#
# Discord_SDK.refresh() # Always refresh after changing the values!
# Discord_Activity.refresh() # Always refresh after changing the values!

View File

@@ -3,5 +3,5 @@
name="DiscordSDK"
description="Discord Game SDK support for GDScript in Godot"
author="vaporvee"
version="1.2"
version="1.3"
script="plugin.gd"

View File

@@ -1,4 +1,4 @@
extends Node
func _process(delta):
Discord_SDK.coreupdate()
Discord_Activity.coreupdate()

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5mfg305pk1y7"
path="res://.godot/imported/ActivityPreview.png-8a573f700e18e7e09dfaf28c363f25d1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ActivityPreview.png"
dest_files=["res://.godot/imported/ActivityPreview.png-8a573f700e18e7e09dfaf28c363f25d1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bs8uoff7oxe48"
path="res://.godot/imported/ActivityPreview.svg-43b6e6182000294801ecf97db1b7fbe3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ActivityPreview.svg"
dest_files=["res://.godot/imported/ActivityPreview.svg-43b6e6182000294801ecf97db1b7fbe3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c0i5gy8pvdnwt"
path="res://.godot/imported/Banner.svg-5bd63979daa8dcc3afce0089ffa91a12.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Banner.svg"
dest_files=["res://.godot/imported/Banner.svg-5bd63979daa8dcc3afce0089ffa91a12.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cm3gqnd84wbvu"
path="res://.godot/imported/Core Updater.png-3bb461d6b6e9b42b926c572ac9a4a10f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Core Updater.png"
dest_files=["res://.godot/imported/Core Updater.png-3bb461d6b6e9b42b926c572ac9a4a10f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://2no2ced378ds"
path="res://.godot/imported/Core Updater.svg-75aabb825d7cf085efdd2bf5760ba312.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Core Updater.svg"
dest_files=["res://.godot/imported/Core Updater.svg-75aabb825d7cf085efdd2bf5760ba312.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b5dn3rnp5eqqp"
path="res://.godot/imported/Debug.png-81b23c4a8a55e89d458626f08de3d2fb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Debug.png"
dest_files=["res://.godot/imported/Debug.png-81b23c4a8a55e89d458626f08de3d2fb.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d1dntlgjiapde"
path="res://.godot/imported/Debug.svg-dbd0299514a2ed7480404c509868c103.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Debug.svg"
dest_files=["res://.godot/imported/Debug.svg-dbd0299514a2ed7480404c509868c103.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://q0le45i0mob0"
path="res://.godot/imported/Example Game.png-0d03ed995c4a02b250411186f1dc9df5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Example Game.png"
dest_files=["res://.godot/imported/Example Game.png-0d03ed995c4a02b250411186f1dc9df5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cbobhuss7g04u"
path="res://.godot/imported/Example Game.svg-48231b262244db99fc03d3d54beb3b09.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Example Game.svg"
dest_files=["res://.godot/imported/Example Game.svg-48231b262244db99fc03d3d54beb3b09.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5mpc1x4iv28l"
path="res://.godot/imported/Small Icon.png-bf79f6b34f46f1f950ca33961ec983c7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Small Icon.png"
dest_files=["res://.godot/imported/Small Icon.png-bf79f6b34f46f1f950ca33961ec983c7.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d2ibjcs3l5tlr"
path="res://.godot/imported/Small Icon.svg-123c32942cd065d21fbcd757387305e5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Small Icon.svg"
dest_files=["res://.godot/imported/Small Icon.svg-123c32942cd065d21fbcd757387305e5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -8,7 +8,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../demo/Discord_SDK.exe"
export_path="../../demo/Discord_Activity.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false

View File

@@ -1,20 +1,20 @@
extends Node
func _ready():
Discord_SDK.app_id = 1099618430065324082
Discord_SDK.debug()
# Discord_SDK.app_id = 1099618430065324082
# Discord_SDK.details = "A demo activity by vaporvee#1231"
# Discord_SDK.state = "Checkpoint 23/23"
# Discord_Activity.app_id = 1099618430065324082
# Discord_Activity.debug()
# Discord_Activity.app_id = 1099618430065324082
# Discord_Activity.details = "A demo activity by vaporvee#1231"
# Discord_Activity.state = "Checkpoint 23/23"
#
# Discord_SDK.large_image = "game"
# Discord_SDK.large_image_text = "Try it now!"
# Discord_SDK.small_image = "boss"
# Discord_SDK.small_image_text = "Fighting the end boss! D:"
# Discord_Activity.large_image = "game"
# Discord_Activity.large_image_text = "Try it now!"
# Discord_Activity.small_image = "boss"
# Discord_Activity.small_image_text = "Fighting the end boss! D:"
#
# #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_Activity.start_timestamp = int(Time.get_unix_time_from_system())
# Discord_Activity.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
#
# Discord_SDK.refresh()
# Discord_Activity.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_Activity.get_is_discord_working())).replace("{id}",str(Discord_Activity.app_id)).replace("{details}",Discord_Activity.details).replace("{state}",Discord_Activity.state).replace("{lkey}",Discord_Activity.large_image).replace("{ltext}",Discord_Activity.large_image_text).replace("{skey}",Discord_Activity.small_image).replace("{stext}",Discord_Activity.small_image_text).replace("{stimestamp}",str(Discord_Activity.start_timestamp)).replace("{etimestamp}",str(Discord_Activity.end_timestamp))

View File

@@ -7,80 +7,84 @@
using namespace godot;
Discord_SDK *Discord_SDK::singleton = nullptr;
Discord_Activity *Discord_Activity::singleton = nullptr;
discord::Core *core{};
discord::Result result;
discord::Activity activity{};
discord::User user{};
void Discord_SDK::_bind_methods()
void Discord_Activity::_bind_methods()
{
ClassDB::bind_method(D_METHOD("debug"), &Discord_SDK::debug);
ClassDB::bind_method(D_METHOD("coreupdate"), &Discord_SDK::coreupdate);
ClassDB::bind_method(D_METHOD("debug"), &Discord_Activity::debug);
ClassDB::bind_method(D_METHOD("coreupdate"), &Discord_Activity::coreupdate);
ClassDB::bind_method(D_METHOD("get_app_id"), &Discord_SDK::get_app_id);
ClassDB::bind_method(D_METHOD("set_app_id", "app_id"), &Discord_SDK::set_app_id);
ClassDB::bind_method(D_METHOD("get_app_id"), &Discord_Activity::get_app_id);
ClassDB::bind_method(D_METHOD("set_app_id", "app_id"), &Discord_Activity::set_app_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "app_id"), "set_app_id", "get_app_id");
ClassDB::bind_method(D_METHOD("get_state"), &Discord_SDK::get_state);
ClassDB::bind_method(D_METHOD("set_state", "state"), &Discord_SDK::set_state);
ClassDB::bind_method(D_METHOD("get_state"), &Discord_Activity::get_state);
ClassDB::bind_method(D_METHOD("set_state", "state"), &Discord_Activity::set_state);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "state"), "set_state", "get_state");
ClassDB::bind_method(D_METHOD("get_details"), &Discord_SDK::get_details);
ClassDB::bind_method(D_METHOD("set_details", "details"), &Discord_SDK::set_details);
ClassDB::bind_method(D_METHOD("get_details"), &Discord_Activity::get_details);
ClassDB::bind_method(D_METHOD("set_details", "details"), &Discord_Activity::set_details);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "details"), "set_details", "get_details");
ClassDB::bind_method(D_METHOD("get_large_image"), &Discord_SDK::get_large_image);
ClassDB::bind_method(D_METHOD("set_large_image", "large_image"), &Discord_SDK::set_large_image);
ClassDB::bind_method(D_METHOD("get_large_image"), &Discord_Activity::get_large_image);
ClassDB::bind_method(D_METHOD("set_large_image", "large_image"), &Discord_Activity::set_large_image);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "large_image"), "set_large_image", "get_large_image");
ClassDB::bind_method(D_METHOD("get_large_image_text"), &Discord_SDK::get_large_image_text);
ClassDB::bind_method(D_METHOD("set_large_image_text", "large_image_text"), &Discord_SDK::set_large_image_text);
ClassDB::bind_method(D_METHOD("get_large_image_text"), &Discord_Activity::get_large_image_text);
ClassDB::bind_method(D_METHOD("set_large_image_text", "large_image_text"), &Discord_Activity::set_large_image_text);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "large_image_text"), "set_large_image_text", "get_large_image_text");
ClassDB::bind_method(D_METHOD("get_small_image"), &Discord_SDK::get_small_image);
ClassDB::bind_method(D_METHOD("set_small_image", "small_image"), &Discord_SDK::set_small_image);
ClassDB::bind_method(D_METHOD("get_small_image"), &Discord_Activity::get_small_image);
ClassDB::bind_method(D_METHOD("set_small_image", "small_image"), &Discord_Activity::set_small_image);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image"), "set_small_image", "get_small_image");
ClassDB::bind_method(D_METHOD("get_small_image_text"), &Discord_SDK::get_small_image_text);
ClassDB::bind_method(D_METHOD("set_small_image_text", "large_small_text"), &Discord_SDK::set_small_image_text);
ClassDB::bind_method(D_METHOD("get_small_image_text"), &Discord_Activity::get_small_image_text);
ClassDB::bind_method(D_METHOD("set_small_image_text", "large_small_text"), &Discord_Activity::set_small_image_text);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image_text"), "set_small_image_text", "get_small_image_text");
ClassDB::bind_method(D_METHOD("get_start_timestamp"), &Discord_SDK::get_start_timestamp);
ClassDB::bind_method(D_METHOD("set_start_timestamp", "start_timestamp"), &Discord_SDK::set_start_timestamp);
ClassDB::bind_method(D_METHOD("get_start_timestamp"), &Discord_Activity::get_start_timestamp);
ClassDB::bind_method(D_METHOD("set_start_timestamp", "start_timestamp"), &Discord_Activity::set_start_timestamp);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_timestamp"), "set_start_timestamp", "get_start_timestamp");
ClassDB::bind_method(D_METHOD("get_end_timestamp"), &Discord_SDK::get_end_timestamp);
ClassDB::bind_method(D_METHOD("set_end_timestamp", "end_timestamp"), &Discord_SDK::set_end_timestamp);
ClassDB::bind_method(D_METHOD("get_end_timestamp"), &Discord_Activity::get_end_timestamp);
ClassDB::bind_method(D_METHOD("set_end_timestamp", "end_timestamp"), &Discord_Activity::set_end_timestamp);
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_timestamp"), "set_end_timestamp", "get_end_timestamp");
ClassDB::bind_method(D_METHOD("refresh"), &Discord_SDK::refresh);
ClassDB::bind_method(D_METHOD("refresh"), &Discord_Activity::refresh);
ClassDB::bind_method(D_METHOD("get_is_discord_working"), &Discord_SDK::get_is_discord_working);
ClassDB::bind_method(D_METHOD("get_is_discord_working"), &Discord_Activity::get_is_discord_working);
ClassDB::bind_method(D_METHOD("get_result_int"), &Discord_SDK::get_result_int);
ClassDB::bind_method(D_METHOD("get_result_int"), &Discord_Activity::get_result_int);
}
Discord_SDK *Discord_SDK::get_singleton()
Discord_Activity *Discord_Activity::get_singleton()
{
return singleton;
}
Discord_SDK::Discord_SDK()
Discord_Activity::Discord_Activity()
{
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
// intitalize core with discord's dummy application ID to make "is_discord_working" work anytime
app_id = 461618159171141643;
result = discord::Core::Create(app_id, DiscordCreateFlags_NoRequireDiscord, &core);
}
Discord_SDK::~Discord_SDK()
Discord_Activity::~Discord_Activity()
{
ERR_FAIL_COND(singleton != this);
singleton = nullptr;
}
void Discord_SDK::coreupdate()
void Discord_Activity::coreupdate()
{
if (result == discord::Result::Ok && app_id > 0)
if (result == discord::Result::Ok && app_id > 0 && app_id != 461618159171141643)
{
::core->RunCallbacks();
}
}
void Discord_SDK::debug()
void Discord_Activity::debug()
{
result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
activity.SetState("Test from Godot!");
@@ -100,38 +104,41 @@ void Discord_SDK::debug()
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
}
void Discord_SDK::set_app_id(const int64_t &value)
void Discord_Activity::set_app_id(int64_t value)
{
app_id = value;
result = discord::Core::Create(value, DiscordCreateFlags_NoRequireDiscord, &core);
}
int64_t Discord_SDK::get_app_id() const
int64_t Discord_Activity::get_app_id()
{
if (app_id = 461618159171141643)
return NULL;
else
return app_id;
}
void Discord_SDK::set_state(const String &value)
void Discord_Activity::set_state(String value)
{
state = value;
activity.SetState(value.utf8().get_data());
}
String Discord_SDK::get_state() const
String Discord_Activity::get_state()
{
return state;
}
void Discord_SDK::set_details(const String &value)
void Discord_Activity::set_details(String value)
{
details = value;
activity.SetDetails(value.utf8().get_data());
}
String Discord_SDK::get_details() const
String Discord_Activity::get_details()
{
return details;
}
void Discord_SDK::refresh()
void Discord_Activity::refresh()
{
if (result == discord::Result::Ok && app_id > 0)
if (result == discord::Result::Ok && app_id > 0 && app_id != 461618159171141643)
{
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
core->UserManager().OnCurrentUserUpdate.Connect([]()
@@ -141,68 +148,68 @@ void Discord_SDK::refresh()
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_Activity::set_large_image(String value)
{
large_image = value;
activity.GetAssets().SetLargeImage(value.utf8().get_data());
}
String Discord_SDK::get_large_image() const
String Discord_Activity::get_large_image()
{
return large_image;
}
void Discord_SDK::set_large_image_text(const String &value)
void Discord_Activity::set_large_image_text(String value)
{
large_image_text = value;
activity.GetAssets().SetLargeText(value.utf8().get_data());
}
String Discord_SDK::get_large_image_text() const
String Discord_Activity::get_large_image_text()
{
return large_image_text;
}
void Discord_SDK::set_small_image(const String &value)
void Discord_Activity::set_small_image(String value)
{
small_image = value;
activity.GetAssets().SetSmallImage(value.utf8().get_data());
}
String Discord_SDK::get_small_image() const
String Discord_Activity::get_small_image()
{
return small_image;
}
void Discord_SDK::set_small_image_text(const String &value)
void Discord_Activity::set_small_image_text(String value)
{
small_image_text = value;
activity.GetAssets().SetSmallText(value.utf8().get_data());
}
String Discord_SDK::get_small_image_text() const
String Discord_Activity::get_small_image_text()
{
return small_image_text;
}
void Discord_SDK::set_start_timestamp(const int64_t &value)
void Discord_Activity::set_start_timestamp(int64_t value)
{
start_timestamp = value;
activity.GetTimestamps().SetStart(value);
}
int64_t Discord_SDK::get_start_timestamp() const
int64_t Discord_Activity::get_start_timestamp()
{
return activity.GetTimestamps().GetStart();
}
void Discord_SDK::set_end_timestamp(const int64_t &value)
void Discord_Activity::set_end_timestamp(int64_t value)
{
end_timestamp = value;
activity.GetTimestamps().SetEnd(value);
}
int64_t Discord_SDK::get_end_timestamp() const
int64_t Discord_Activity::get_end_timestamp()
{
return activity.GetTimestamps().GetEnd();
}
bool Discord_SDK::get_is_discord_working() const
bool Discord_Activity::get_is_discord_working()
{
return result == discord::Result::Ok && app_id > 0;
}
int Discord_SDK::get_result_int() const
int Discord_Activity::get_result_int()
{
return static_cast<int>(result);
}

View File

@@ -8,11 +8,11 @@
using namespace godot;
class Discord_SDK : public Object
class Discord_Activity : public Object
{
GDCLASS(Discord_SDK, Object);
GDCLASS(Discord_Activity, Object);
static Discord_SDK *singleton;
static Discord_Activity *singleton;
protected:
static void _bind_methods();
@@ -32,39 +32,39 @@ private:
int64_t end_timestamp;
public:
static Discord_SDK *get_singleton();
static Discord_Activity *get_singleton();
Discord_SDK();
~Discord_SDK();
Discord_Activity();
~Discord_Activity();
void debug();
void coreupdate();
void refresh();
int64_t get_app_id() const;
int64_t get_app_id();
void set_app_id(const int64_t &value);
String get_state() const;
void set_state(const String &value);
String get_details() const;
void set_details(const String &value);
void set_app_id(int64_t value);
String get_state();
void set_state(String value);
String get_details();
void set_details(String value);
String get_large_image() const;
void set_large_image(const String &value);
String get_large_image_text() const;
void set_large_image_text(const String &value);
String get_small_image() const;
void set_small_image(const String &value);
String get_small_image_text() const;
void set_small_image_text(const String &value);
String get_large_image();
void set_large_image(String value);
String get_large_image_text();
void set_large_image_text(String value);
String get_small_image();
void set_small_image(String value);
String get_small_image_text();
void set_small_image_text(String value);
int64_t get_start_timestamp() const;
void set_start_timestamp(const int64_t &value);
int64_t get_end_timestamp() const;
void set_end_timestamp(const int64_t &value);
int64_t get_start_timestamp();
void set_start_timestamp(int64_t value);
int64_t get_end_timestamp();
void set_end_timestamp(int64_t value);
bool get_is_discord_working() const;
int get_result_int() const;
bool get_is_discord_working();
int get_result_int();
};
#endif

View File

@@ -9,15 +9,15 @@
#include "discordgodot.h"
using namespace godot;
static Discord_SDK *discordsdk;
static Discord_Activity *discordsdk;
void gdextension_initialize(ModuleInitializationLevel p_level)
{
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
ClassDB::register_class<Discord_SDK>();
discordsdk = memnew(Discord_SDK);
Engine::get_singleton()->register_singleton("Discord_SDK", Discord_SDK::get_singleton());
ClassDB::register_class<Discord_Activity>();
discordsdk = memnew(Discord_Activity);
Engine::get_singleton()->register_singleton("Discord_Activity", Discord_Activity::get_singleton());
}
}
@@ -25,7 +25,7 @@ void gdextension_terminate(ModuleInitializationLevel p_level)
{
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
Engine::get_singleton()->unregister_singleton("Discord_SDK");
Engine::get_singleton()->unregister_singleton("Discord_Activity");
memdelete(discordsdk);
}
}