diff --git a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll index eb6518b..3e94347 100644 Binary files a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll and b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll differ diff --git a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll index 20b2ad8..1435998 100644 Binary files a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll and b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll differ diff --git a/project/addons/discord-sdk-gd/discord_coreupdater.gd b/project/addons/discord-sdk-gd/discord_coreupdater.gd deleted file mode 100644 index 719b20d..0000000 --- a/project/addons/discord-sdk-gd/discord_coreupdater.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Node - -func _process(delta): - Discord_SDK.coreupdate() diff --git a/project/addons/discord-sdk-gd/plugin.gd b/project/addons/discord-sdk-gd/plugin.gd index c9fbd5f..38c927e 100644 --- a/project/addons/discord-sdk-gd/plugin.gd +++ b/project/addons/discord-sdk-gd/plugin.gd @@ -5,9 +5,9 @@ const ExportPlugin = preload("res://addons/discord-sdk-gd/export.gd") var loaded_exportplugin = ExportPlugin.new() func _enter_tree(): - add_autoload_singleton("discord_coreupdater", "res://addons/discord-sdk-gd/discord_coreupdater.gd") + add_autoload_singleton("DiscordSDK", "res://addons/discord-sdk-gd/sdk_utility.gd") add_export_plugin(loaded_exportplugin) func disable_plugin(): - remove_autoload_singleton("discord_coreupdater") + remove_autoload_singleton("DiscordSDK") remove_export_plugin(loaded_exportplugin) diff --git a/project/addons/discord-sdk-gd/sdk_utility.gd b/project/addons/discord-sdk-gd/sdk_utility.gd new file mode 100644 index 0000000..734dadd --- /dev/null +++ b/project/addons/discord-sdk-gd/sdk_utility.gd @@ -0,0 +1,55 @@ +extends Node + +const result: Array[String] = [ + "Ok", + "ServiceUnavailable", + "InvalidVersion", + "LockFailed", + "InternalError", + "InvalidPayload", + "InvalidCommand", + "InvalidPermissions", + "NotFetched", + "NotFound", + "Conflict", + "InvalidSecret", + "InvalidJoinSecret", + "NoEligibleActivity", + "InvalidInvite", + "NotAuthenticated", + "InvalidAccessToken", + "ApplicationMismatch", + "InvalidDataUrl", + "InvalidBase64", + "NotFiltered", + "LobbyFull", + "InvalidLobbySecret", + "InvalidFilename", + "InvalidFileSize", + "InvalidEntitlement", + "NotInstalled", + "NotRunning", + "InsufficientBuffer", + "PurchaseCanceled", + "InvalidGuild", + "InvalidEvent", + "InvalidChannel", + "InvalidOrigin", + "RateLimited", + "OAuth2Error", + "SelectChannelTimeout", + "GetGuildTimeout", + "SelectVoiceForceRequired", + "CaptureShortcutAlreadyListening", + "UnauthorizedForAchievement", + "InvalidGiftCode", + "PurchaseError", + "TransactionAborted", + "DrawingInitFailed" +] + +func _process(delta): + Discord_SDK.coreupdate() + +func get_sdk_info(): + return result[Discord_SDK.get_result_int()] diff --git a/project/main.gd b/project/main.gd index 7950ae5..80c713a 100644 --- a/project/main.gd +++ b/project/main.gd @@ -1,19 +1,19 @@ extends Node func _ready(): - Discord_SDK.debug() - #Discord_SDK.app_id = 1099618430065324082 - #Discord_SDK.details = "A demo activity by vaporvee#1231" - #Discord_SDK.state = "Checkpoint 23/23" + #Discord_SDK.debug() + Discord_SDK.app_id = 1099618430065324082 + Discord_SDK.details = "A demo activity by vaporvee#1231" + Discord_SDK.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_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_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("{isdiscordworking}",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}",DiscordSDK.get_sdk_info()).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)) diff --git a/project/main.tscn b/project/main.tscn index 9eb5c86..546b2d2 100644 --- a/project/main.tscn +++ b/project/main.tscn @@ -46,7 +46,7 @@ offset_left = 7.0 offset_top = 6.0 offset_right = 514.0 offset_bottom = 722.0 -text = "Is Discord working: {isdiscordworking} +text = "Discord info: {discordinfo} Application ID : {id} Details: {details} diff --git a/project/project.godot b/project/project.godot index 1751636..013594e 100644 --- a/project/project.godot +++ b/project/project.godot @@ -20,7 +20,7 @@ config/icon="res://assets/Logo_V2.png" [autoload] -discord_coreupdater="*res://addons/discord-sdk-gd/discord_coreupdater.gd" +DiscordSDK="*res://addons/discord-sdk-gd/sdk_utility.gd" [dotnet] diff --git a/src/discordgodot.cpp b/src/discordgodot.cpp index 11df734..db626be 100644 --- a/src/discordgodot.cpp +++ b/src/discordgodot.cpp @@ -51,7 +51,7 @@ void Discord_SDK::_bind_methods() ClassDB::bind_method(D_METHOD("refresh"), &Discord_SDK::refresh); - ClassDB::bind_method(D_METHOD("get_is_discord_working"), &Discord_SDK::get_is_discord_working); + ClassDB::bind_method(D_METHOD("get_result_int"), &Discord_SDK::get_result_int); } Discord_SDK *Discord_SDK::get_singleton() @@ -192,7 +192,7 @@ int64_t Discord_SDK::get_end_timestamp() const return activity.GetTimestamps().GetEnd(); } -bool Discord_SDK::get_is_discord_working() const +int Discord_SDK::get_result_int() const { - return result == discord::Result::Ok; + return static_cast(result); } \ No newline at end of file diff --git a/src/discordgodot.h b/src/discordgodot.h index b06a872..42d2889 100644 --- a/src/discordgodot.h +++ b/src/discordgodot.h @@ -2,6 +2,7 @@ #define DISCORDGODOT_H #include +#include "discord-game-sdk-cpp/discord.h" #include #include @@ -62,7 +63,7 @@ public: int64_t get_end_timestamp() const; void set_end_timestamp(const int64_t &value); - bool get_is_discord_working() const; + int get_result_int() const; }; #endif \ No newline at end of file