From 115cf4c8c0676d2e5de62c46ba5a3ae93300f363 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sat, 22 Mar 2025 00:13:17 +0100 Subject: [PATCH] fixed import errors --- .gitignore | 2 + .vscode/c_cpp_properties.json | 3 +- SConstruct | 10 ++-- .../bin/discord-rpc-gd.gdextension | 10 +--- .../addons/discord-rpc-gd/nodes/Debug.tscn | 4 +- project/main.gd | 50 +++++++++---------- setup.py | 24 +++++++-- src/discordgodot.cpp | 12 +---- src/discordgodot.h | 4 +- src/editor_presence.cpp | 2 +- src/editor_presence.h | 2 +- src/register_types.cpp | 2 +- 12 files changed, 59 insertions(+), 66 deletions(-) diff --git a/.gitignore b/.gitignore index 4d6fe3e..03dc3a6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,8 @@ build/ #Clean files from setup.py src/lib/discord_social_sdk/* src/lib/godot-cpp/* +discordpp.h +cdiscord.h *.zip *.so *.dll diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 89a2e8c..7784361 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,8 +7,7 @@ "${workspaceFolder}/src/lib/godot-cpp/gen/include", "${workspaceFolder}/src/lib/godot-cpp/include", "${workspaceFolder}/src/lib/godot-cpp/gdextension", - "${workspaceFolder}/src/lib/godot-cpp/gen/include", - "${workspaceFolder}/src/lib/discord_social_sdk/include" + "${workspaceFolder}/src/lib/godot-cpp/gen/include" ], "defines": [ "_DEBUG", diff --git a/SConstruct b/SConstruct index 57bfe42..93f1d78 100644 --- a/SConstruct +++ b/SConstruct @@ -20,14 +20,10 @@ elif env["platform"] == "windows": if env["target"] == "template_debug": debugsuffix = "_debug" - folder = "debug/" - discord_library_target = discord_library.replace(".", f"{debugsuffix}.") else: debugsuffix = "" - folder = "release/" - discord_library_target = discord_library -env.Append(LIBPATH=["src/lib/discord_social_sdk/lib/" + folder]) +env.Append(LIBPATH=["src/lib/discord_social_sdk/lib/release/"]) env.Append(LIBS=["discord_partner_sdk"]) env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"]) @@ -42,8 +38,8 @@ library = env.SharedLibrary( env.Depends( library, Command( - "project/addons/discord-rpc-gd/bin/" + libexportfolder + discord_library_target, - "src/lib/discord_social_sdk/lib/" + folder + discord_library, + "project/addons/discord-rpc-gd/bin/" + libexportfolder + discord_library, + "src/lib/discord_social_sdk/lib/release/" + discord_library, Copy("$TARGET", "$SOURCE"), ), ) diff --git a/project/addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension b/project/addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension index 541c550..ddcb34d 100644 --- a/project/addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension +++ b/project/addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension @@ -19,11 +19,5 @@ linux.release.rv64 = "linux/libdiscord_partner_sdk_binding.so" [dependencies] macos = { "macos/libdiscord_partner_sdk.dylib": "" } -windows.debug.x86_64 = { "windows/discord_partner_sdk_debug.dll": "" } -windows.release.x86_64 = { "windows/discord_partner_sdk.dll": "" } -linux.debug.x86_64 = { "linux/libdiscord_partner_sdk_debug.so": "" } -linux.release.x86_64 = { "linux/libdiscord_partner_sdk.so": "" } -linux.debug.arm64 = { "linux/libdiscord_partner_sdk_debug.so": "" } -linux.release.arm64 = { "linux/libdiscord_partner_sdk.so": "" } -linux.debug.rv64 = { "linux/libdiscord_partner_sdk_debug.so": "" } -linux.release.rv64 = { "linux/libdiscord_partner_sdk.so": "" } +windows.x86_64 = { "windows/discord_partner_sdk.dll": "" } +linux = { "linux/libdiscord_partner_sdk.so": "" } diff --git a/project/addons/discord-rpc-gd/nodes/Debug.tscn b/project/addons/discord-rpc-gd/nodes/Debug.tscn index 7a4f9c9..7d4d2ec 100644 --- a/project/addons/discord-rpc-gd/nodes/Debug.tscn +++ b/project/addons/discord-rpc-gd/nodes/Debug.tscn @@ -48,7 +48,7 @@ Is party public: {ppublic} (needs to be activated in Discord client settings) Is instanced: {instanced} \" - $Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(DiscordRPC.is_public_party)).replace(\"{instanced}\",str(DiscordRPC.instanced)).replace(\"{ssecret}\",DiscordRPC.spectate_secret).replace(\"{jsecret}\",DiscordRPC.join_secret).replace(\"{msecret}\",DiscordRPC.match_secret).replace(\"{mpartysize}\",str(DiscordRPC.max_party_size)).replace(\"{cpartysize}\",str(DiscordRPC.current_party_size)).replace(\"{partyid}\",DiscordRPC.party_id).replace(\"{id}\",str(DiscordRPC.app_id)).replace(\"{details}\",DiscordRPC.details).replace(\"{state}\",DiscordRPC.state).replace(\"{lkey}\",DiscordRPC.large_image).replace(\"{ltext}\",DiscordRPC.large_image_text).replace(\"{skey}\",DiscordRPC.small_image).replace(\"{stext}\",DiscordRPC.small_image_text).replace(\"{stimestamp}\",str(DiscordRPC.start_timestamp)).replace(\"{etimestamp}\",str(DiscordRPC.end_timestamp)) + #$Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(DiscordRPC.is_public_party)).replace(\"{instanced}\",str(DiscordRPC.instanced)).replace(\"{ssecret}\",DiscordRPC.spectate_secret).replace(\"{jsecret}\",DiscordRPC.join_secret).replace(\"{msecret}\",DiscordRPC.match_secret).replace(\"{mpartysize}\",str(DiscordRPC.max_party_size)).replace(\"{cpartysize}\",str(DiscordRPC.current_party_size)).replace(\"{partyid}\",DiscordRPC.party_id).replace(\"{id}\",str(DiscordRPC.app_id)).replace(\"{details}\",DiscordRPC.details).replace(\"{state}\",DiscordRPC.state).replace(\"{lkey}\",DiscordRPC.large_image).replace(\"{ltext}\",DiscordRPC.large_image_text).replace(\"{skey}\",DiscordRPC.small_image).replace(\"{stext}\",DiscordRPC.small_image_text).replace(\"{stimestamp}\",str(DiscordRPC.start_timestamp)).replace(\"{etimestamp}\",str(DiscordRPC.end_timestamp)) var user_request: Dictionary = {}; @@ -260,7 +260,7 @@ texture = ExtResource("3_goflf") [node name="AnimationPlayer" type="AnimationPlayer" parent="Panel/TextureRect"] libraries = { -"": SubResource("AnimationLibrary_a7ofc") +&"": SubResource("AnimationLibrary_a7ofc") } [connection signal="pressed" from="Panel/PrintCurrentUserOnConsole" to="." method="_on_print_current_user_on_console_pressed"] diff --git a/project/main.gd b/project/main.gd index 04d2d6e..5e96d88 100644 --- a/project/main.gd +++ b/project/main.gd @@ -4,7 +4,7 @@ func _ready() -> void: if GDExtensionManager.is_extension_loaded("res://addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension"): set_activity() DiscordRPC.connect("activity_join_request",_on_activity_join_request) - DiscordRPC.connect("activity_join",_on_activity_join) + #DiscordRPC.connect("activity_join",_on_activity_join) DiscordRPC.connect("activity_spectate",_on_activity_spectate) DiscordRPC.connect("relationships_init",_on_relationship_init) DiscordRPC.connect("updated_relationship", _on_updated_relationship) @@ -12,27 +12,27 @@ func _ready() -> void: func set_activity() -> void: DiscordRPC.clear(false) DiscordRPC.app_id = 1099618430065324082 - DiscordRPC.details = "A demo activity by vaporvee#1231" - DiscordRPC.state = "Checkpoint 23/23" - - DiscordRPC.large_image = "example_game" - DiscordRPC.large_image_text = "Try it now!" - DiscordRPC.small_image = "boss" - DiscordRPC.small_image_text = "Fighting the end boss! D:" - DiscordRPC.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time + #DiscordRPC.details = "A demo activity by vaporvee#1231" + #DiscordRPC.state = "Checkpoint 23/23" + # + #DiscordRPC.large_image = "example_game" + #DiscordRPC.large_image_text = "Try it now!" + #DiscordRPC.small_image = "boss" + #DiscordRPC.small_image_text = "Fighting the end boss! D:" + #DiscordRPC.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time # It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server understands and # returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others. var my_secret: String = str(randi_range(0,999999)) - DiscordRPC.party_id = "mylobbycanbeeverything_" + my_secret - DiscordRPC.current_party_size = 1 - DiscordRPC.max_party_size = 4 - DiscordRPC.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars - DiscordRPC.join_secret = "j_" + my_secret - DiscordRPC.spectate_secret = "s_" + my_secret - DiscordRPC.is_public_party = true - DiscordRPC.instanced = true #required for spectate + #DiscordRPC.party_id = "mylobbycanbeeverything_" + my_secret + #DiscordRPC.current_party_size = 1 + #DiscordRPC.max_party_size = 4 + #DiscordRPC.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars + #DiscordRPC.join_secret = "j_" + my_secret + #DiscordRPC.spectate_secret = "s_" + my_secret + #DiscordRPC.is_public_party = true + #DiscordRPC.instanced = true #required for spectate #DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system()) DiscordRPC.register_command("C:\\Users\\yanni\\Desktop\\demo\\DiscordRPC.exe") #DiscordRPC.register_steam(1389990) @@ -44,14 +44,14 @@ func _on_activity_join_request(user_requesting: Dictionary) -> void: print(user_requesting) user_request = user_requesting -func _on_activity_join(secret: String) -> void: - if(DiscordRPC.join_secret != secret): - DiscordRPC.current_party_size = clamp(int(secret) + 1, 0, DiscordRPC.max_party_size) - DiscordRPC.party_id = secret.replace("j_","mylobbycanbeeverything_") - DiscordRPC.match_secret = secret.replace("j_","m_") - DiscordRPC.join_secret = secret - DiscordRPC.spectate_secret = secret.replace("j_","s_") - DiscordRPC.refresh() +#func _on_activity_join(secret: String) -> void: + #if(DiscordRPC.join_secret != secret): + #DiscordRPC.current_party_size = clamp(int(secret) + 1, 0, DiscordRPC.max_party_size) + #DiscordRPC.party_id = secret.replace("j_","mylobbycanbeeverything_") + #DiscordRPC.match_secret = secret.replace("j_","m_") + #DiscordRPC.join_secret = secret + #DiscordRPC.spectate_secret = secret.replace("j_","s_") + #DiscordRPC.refresh() func _on_activity_spectate(secret: String) -> void: print(secret) diff --git a/setup.py b/setup.py index 8754043..b354e8a 100644 --- a/setup.py +++ b/setup.py @@ -2,35 +2,49 @@ import zipfile import os import re import shutil +import sys +import glob EXPECTED_VERSION = "1.0.7445" -# Extract the version from the zip filename -zip_path = "src/lib/DiscordSocialSdk-1.0.7445.zip" +zip_files = glob.glob("src/lib/DiscordSocialSdk-*.zip") +if not zip_files: + print("Error: No zip file matching 'DiscordSocialSdk-*.zip' found.") + sys.exit(1) + +zip_path = zip_files[0] # Use the first matching file match = re.search(r"DiscordSocialSdk-(\d+\.\d+\.\d+)\.zip", zip_path) if match: extracted_version = match.group(1) if extracted_version != EXPECTED_VERSION: print(f"Warning: Last tested version {EXPECTED_VERSION}, but found {extracted_version} in the zip file.") +print(f"Extracting {zip_path}...") # Extract the zip file ignoring the version in the filename with zipfile.ZipFile(zip_path, "r") as zip_ref: zip_ref.extractall("src/lib/") -# Copy the release DLL to the lib directory release_dll_src = "src/lib/discord_social_sdk/bin/release/discord_partner_sdk.dll" release_dll_dest = "src/lib/discord_social_sdk/lib/release/" os.makedirs(release_dll_dest, exist_ok=True) shutil.copy(release_dll_src, release_dll_dest) -# Copy the debug DLL to the lib/debug directory debug_dll_src = "src/lib/discord_social_sdk/bin/debug/discord_partner_sdk.dll" debug_dll_dest = "src/lib/discord_social_sdk/lib/debug/" os.makedirs(debug_dll_dest, exist_ok=True) shutil.copy(debug_dll_src, debug_dll_dest) -# Delete the bin folder +include_folder_src = "src/lib/discord_social_sdk/include" +include_folder_dest = "src" +shutil.copytree(include_folder_src, include_folder_dest, dirs_exist_ok=True) + +shutil.rmtree(include_folder_src, ignore_errors=True) + bin_folder = "src/lib/discord_social_sdk/bin" shutil.rmtree(bin_folder, ignore_errors=True) +print(f"Extracted and copied Discord Social SDK version: {extracted_version}") + +print("Getting submodules...") os.system("git submodule update --init --remote") +print("Finished setup!") diff --git a/src/discordgodot.cpp b/src/discordgodot.cpp index b6119e6..4ea5612 100644 --- a/src/discordgodot.cpp +++ b/src/discordgodot.cpp @@ -1,4 +1,4 @@ -#include "lib/discord_social_sdk/include/discordpp.h" +#include "discordpp.h" #include "discordgodot.h" #include #include @@ -18,14 +18,10 @@ } DiscordRPC *DiscordRPC::singleton = nullptr; -std::shared_ptr client; -discordpp::Activity activity; void DiscordRPC::_bind_methods() { BIND_SET_GET(app_id, Variant::INT); - BIND_SET_GET(state, Variant::STRING); - BIND_SET_GET(details, Variant::STRING); BIND_SIGNAL(activity_join, PropertyInfo(Variant::STRING, "join_secret")); BIND_SIGNAL(activity_spectate, PropertyInfo(Variant::STRING, "spectate_secret")); BIND_SIGNAL(activity_join_request, PropertyInfo(Variant::DICTIONARY, "user_requesting")); @@ -51,8 +47,6 @@ void DiscordRPC::_bind_methods() BIND_METHOD(open_voice_settings); BIND_METHOD(get_is_discord_working); } -SET_GET(state, activity.SetState(value.utf8().get_data())) -SET_GET(details, activity.SetDetails(value.utf8().get_data())) DiscordRPC::DiscordRPC() { @@ -63,8 +57,6 @@ DiscordRPC::DiscordRPC() DiscordRPC::~DiscordRPC() { app_id = 0; - client->~Client(); - client = nullptr; ERR_FAIL_COND(singleton != this); singleton = nullptr; } @@ -146,8 +138,6 @@ void DiscordRPC::clear(bool reset_values = false) if (reset_values) { old_app_id = 0; - set_state(""); - set_details(""); set_is_overlay_locked(false); // core->ActivityManager().ClearActivity([](discordpp::Result result) {}); } diff --git a/src/discordgodot.h b/src/discordgodot.h index ec8395a..05947ec 100644 --- a/src/discordgodot.h +++ b/src/discordgodot.h @@ -2,7 +2,7 @@ #define DISCORDGODOT_H #include -#include "lib/discord_social_sdk/include/discordpp.h" +#include "discordpp.h" #include #include @@ -37,8 +37,6 @@ public: void set_app_id(uint64_t value); uint64_t get_app_id(); uint64_t app_id = 0; // needs to be directly set to 0 or it will crash randomly - H_SET_GET(String, state) - H_SET_GET(String, details) H_SET_GET(bool, is_overlay_locked) void debug(); diff --git a/src/editor_presence.cpp b/src/editor_presence.cpp index 1f6e5d2..562cdb2 100644 --- a/src/editor_presence.cpp +++ b/src/editor_presence.cpp @@ -1,5 +1,5 @@ #include "editor_presence.h" -#include "lib/discord_social_sdk/include/discordpp.h" +#include "discordpp.h" #include #include #include diff --git a/src/editor_presence.h b/src/editor_presence.h index d554d5c..4e4f915 100644 --- a/src/editor_presence.h +++ b/src/editor_presence.h @@ -2,7 +2,7 @@ #define EDITOR_PRESENCE_H #include -#include "lib/discord_social_sdk/include/discordpp.h" +#include "discordpp.h" #include #include #include diff --git a/src/register_types.cpp b/src/register_types.cpp index ed65edd..b62b518 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -6,7 +6,7 @@ #include #include -#include "lib/discord_social_sdk/include/discordpp.h" +#include "discordpp.h" #include "discordgodot.h" #include "editor_presence.h" using namespace godot;