restarting doesnt crash anymore and disabling plugin works safer, general bug fixes

This commit is contained in:
2023-12-15 15:51:39 +01:00
parent e69c514b44
commit 8de5c65cdc
17 changed files with 134 additions and 73 deletions

View File

@@ -1,10 +1,8 @@
#!python
import os
# Gets the standard flags CC, CCX, etc.
env = SConscript("src/lib/godot-cpp/SConstruct")
# Check our platform specifics
if env["platform"] == "macos":
discord_library = "libdiscord_game_sdk.dylib"
discord_library_second = "libdiscord_game_sdk_aarch64.dylib"
@@ -25,19 +23,16 @@ if env["target"] == "template_debug":
else:
debugsuffix = ""
# make sure our binding library is properly includes
env.Append(LIBPATH=["src/lib/discord_game_sdk/bin/"])
sources = Glob("src/lib/discord_game_sdk/cpp/*.cpp")
env.Append(
CPPPATH=["src/lib/discord_game_sdk/cpp/"]
) # this line for some reason doesn't get understanded by most linux distros
env.Append(CPPPATH=["src/lib/discord_game_sdk/cpp/"])
env.Append(LIBS=["discord_game_sdk"])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
sources += Glob("src/*.cpp")
# The finished exports
env.Append(CPPDEFINES=["HOT_RELOAD_ENABLED"])
library = env.SharedLibrary(
target="project/addons/discord-sdk-gd/bin/"
+ libexportfolder

View File

@@ -0,0 +1,5 @@
PLEASE ACTIVATE THE PLUGIN UNDER Project -> Project Settings... -> Plugins -> DiscordSDK -> Status
IGNORE THE RED ERRORS ON THE FIRST 2 RESTARTS
READ THE TUTORIAL LINKED IN THE WINDOW THAT WILL OPEN ON PLUGIN ENABLE
If nothing works, enable the plugin and delete /addons/discord-sdk-gd/bin/.gdignore

View File

@@ -2,6 +2,7 @@
entry_symbol = "discordsdkgd_library_init"
compatibility_minimum = 4.2
reloadable = true
[libraries]

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csl0e2px0cwc1"
path="res://.godot/imported/logo.png-b59b4861dc0c64616d78af30082b08b5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/discord-sdk-gd/logo.png"
dest_files=["res://.godot/imported/logo.png-b59b4861dc0c64616d78af30082b08b5.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

@@ -1,8 +1,8 @@
[gd_scene load_steps=9 format=3 uid="uid://c1slhdnlsv2qt"]
[ext_resource type="Texture2D" uid="uid://dnfq6kug4x6o2" path="res://addons/discord-sdk-gd/nodes/assets/Checked.svg" id="2_q6tao"]
[ext_resource type="Texture2D" uid="uid://compmm3kviqqe" path="res://addons/discord-sdk-gd/nodes/assets/Unchecked.svg" id="3_5cyem"]
[ext_resource type="Texture2D" uid="uid://dtc6ckladq0td" path="res://addons/discord-sdk-gd/nodes/assets/circle.svg" id="3_goflf"]
[ext_resource type="Texture2D" path="res://addons/discord-sdk-gd/nodes/assets/Checked.svg" id="2_q6tao"]
[ext_resource type="Texture2D" path="res://addons/discord-sdk-gd/nodes/assets/Unchecked.svg" id="3_5cyem"]
[ext_resource type="Texture2D" path="res://addons/discord-sdk-gd/nodes/assets/circle.svg" id="3_goflf"]
[sub_resource type="GDScript" id="GDScript_ak1tp"]
resource_name = "Debug"

View File

@@ -8,9 +8,10 @@
extends Node
class_name DiscordSDKLoaderAutoload
func _process(_delta):
if(ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled") && Engine.is_editor_hint()):
if(discord_sdk.app_id != 1108142249990176808):
func _process(_delta) -> void:
if GDExtensionManager.get_loaded_extensions().has("res://addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension"):
if ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled",false) && Engine.is_editor_hint():
if discord_sdk.app_id != 1108142249990176808:
discord_sdk.app_id = 1108142249990176808
discord_sdk.details = ProjectSettings.get_setting("application/config/name")
discord_sdk.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\""
@@ -18,5 +19,5 @@ func _process(_delta):
discord_sdk.large_image_text = str(Engine.get_version_info().string)
discord_sdk.start_timestamp = int(Time.get_unix_time_from_system())
discord_sdk.refresh()
if(discord_sdk.app_id == 1108142249990176808 || !Engine.is_editor_hint()):
if discord_sdk.app_id == 1108142249990176808 || !Engine.is_editor_hint():
discord_sdk.run_callbacks()

View File

@@ -4,9 +4,7 @@ extends EditorPlugin
const DiscordSDKDebug = preload("res://addons/discord-sdk-gd/nodes/debug.gd")
const DiscordSDKDebug_icon = preload("res://addons/discord-sdk-gd/Debug.svg")
var loaded_DiscordSDKDebug = DiscordSDKDebug.new()
var restart_window: Control = preload("res://addons/discord-sdk-gd/restart_window.tscn").instantiate()
var restart_window: ConfirmationDialog = preload("res://addons/discord-sdk-gd/restart_window.tscn").instantiate()
func _enter_tree() -> void:
add_custom_type("DiscordSDKDebug","Node",DiscordSDKDebug,DiscordSDKDebug_icon)
@@ -15,15 +13,26 @@ func _enter_tree() -> void:
ProjectSettings.set_initial_value("DiscordSDK/EditorPresence/enabled",false)
func _enable_plugin() -> void:
add_autoload_singleton("DiscordSDKAutoload","res://addons/discord-sdk-gd/nodes/discord_autoload.gd")
if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore"):
DirAccess.remove_absolute(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore")
if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/nodes/.gdignore"):
DirAccess.remove_absolute(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/nodes/.gdignore")
add_autoload_singleton("DiscordSDKAutoload","res://addons/discord-sdk-gd/nodes/discord_autoload.gd")
restart_window.connect("confirmed", save_no_restart)
restart_window.connect("canceled", save_and_restart)
EditorInterface.popup_dialog_centered(restart_window)
func _disable_plugin() -> void:
GDExtensionManager.unload_extension("res://addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension")
remove_autoload_singleton("DiscordSDKAutoload")
FileAccess.open("res://addons/discord-sdk-gd/bin/.gdignore",FileAccess.WRITE)
FileAccess.open("res://addons/discord-sdk-gd/nodes/.gdignore",FileAccess.WRITE)
remove_custom_type("DiscordSDKDebug")
ProjectSettings.clear("DiscordSDK/EditorPresence/enabled")
func save_and_restart() -> void:
EditorInterface.save_all_scenes()
EditorInterface.restart_editor(true)
func save_no_restart() -> void:
EditorInterface.restart_editor(false)

View File

@@ -1,15 +1,31 @@
[gd_scene load_steps=8 format=3 uid="uid://byc4c6d5tpomq"]
[gd_scene load_steps=9 format=3 uid="uid://byc4c6d5tpomq"]
[ext_resource type="Texture2D" uid="uid://csl0e2px0cwc1" path="res://addons/discord-sdk-gd/Logo_V2_No_Bg.png" id="1_f828l"]
[ext_resource type="Texture2D" uid="uid://csl0e2px0cwc1" path="res://addons/discord-sdk-gd/Logo_V2_No_Bg.png" id="1_0svbg"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1t7mm"]
[sub_resource type="Theme" id="Theme_swwco"]
Button/styles/focus = SubResource("StyleBoxEmpty_1t7mm")
[sub_resource type="GDScript" id="GDScript_7v43l"]
resource_name = "RestartWindow"
script/source = "extends ConfirmationDialog
func _ready():
canceled.connect(_on_canceled)
confirmed.connect(_on_confirmed)
func _on_canceled():
EditorInterface.restart_editor(false)
func _on_confirmed():
EditorInterface.restart_editor(true)
"
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5vqdt"]
[sub_resource type="Image" id="Image_inmd8"]
[sub_resource type="Image" id="Image_241ci"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 168, 224, 224, 224, 233, 224, 224, 224, 236, 224, 224, 224, 170, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 234, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 239, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 168, 224, 224, 224, 255, 224, 224, 224, 186, 224, 224, 224, 32, 224, 224, 224, 33, 224, 224, 224, 187, 224, 224, 224, 255, 225, 225, 225, 167, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 255, 224, 224, 224, 234, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 229, 229, 229, 38, 224, 224, 224, 255, 224, 224, 224, 229, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 164, 224, 224, 224, 255, 224, 224, 224, 187, 225, 225, 225, 34, 227, 227, 227, 36, 224, 224, 224, 192, 224, 224, 224, 255, 224, 224, 224, 162, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 225, 225, 225, 215, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 229, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 210, 224, 224, 224, 161, 224, 224, 224, 232, 224, 224, 224, 231, 225, 225, 225, 159, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 107, 224, 224, 224, 255, 224, 224, 224, 210, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 105, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 224, 224, 224, 130, 255, 255, 255, 1, 255, 255, 255, 1, 225, 225, 225, 134, 224, 224, 224, 224, 225, 225, 225, 223, 224, 224, 224, 132, 255, 255, 255, 1, 255, 255, 255, 6, 224, 224, 224, 137, 224, 224, 224, 231, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 130, 225, 225, 225, 133, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 129, 224, 224, 224, 137, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 220, 225, 225, 225, 223, 224, 224, 224, 255, 226, 226, 226, 61, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 222, 224, 224, 224, 231, 224, 224, 224, 255, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 222, 224, 224, 224, 255, 227, 227, 227, 63, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 230, 224, 224, 224, 255, 227, 227, 227, 63, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 127, 224, 224, 224, 129, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 126, 225, 225, 225, 135, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 1, 224, 224, 224, 128, 224, 224, 224, 220, 224, 224, 224, 219, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 5, 225, 225, 225, 134, 224, 224, 224, 229, 224, 224, 224, 255, 255, 255, 255, 0),
"format": "RGBA8",
@@ -19,97 +35,94 @@ data = {
}
[sub_resource type="ImageTexture" id="ImageTexture_gdtpn"]
image = SubResource("Image_inmd8")
image = SubResource("Image_241ci")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7v0rg"]
[node name="RestartWindow" type="Control"]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -171.5
offset_right = 200.0
offset_bottom = 171.5
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="."]
[node name="RestartWindow" type="ConfirmationDialog"]
title = "Restart required"
initial_position = 2
size = Vector2i(416, 400)
size = Vector2i(430, 500)
visible = true
transient = false
unresizable = true
theme = SubResource("Theme_swwco")
ok_button_text = "Restart"
cancel_button_text = "Save and restart"
script = SubResource("GDScript_7v43l")
[node name="Panel" type="Panel" parent="ConfirmationDialog"]
[node name="Panel" type="Panel" parent="."]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = 8.0
offset_top = 8.0
offset_right = 408.0
offset_bottom = 351.0
offset_right = 422.0
offset_bottom = 451.0
grow_horizontal = 2
mouse_filter = 1
[node name="VBoxContainer" type="VBoxContainer" parent="ConfirmationDialog/Panel"]
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
custom_minimum_size = Vector2(400, 0)
layout_mode = 0
offset_right = 400.0
offset_bottom = 309.0
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -200.0
offset_right = 200.0
offset_bottom = 389.0
grow_horizontal = 2
[node name="HSeparator" type="HSeparator" parent="ConfirmationDialog/Panel/VBoxContainer"]
[node name="HSeparator" type="HSeparator" parent="Panel/VBoxContainer"]
layout_mode = 2
mouse_filter = 1
theme_override_constants/separation = 15
theme_override_styles/separator = SubResource("StyleBoxEmpty_5vqdt")
[node name="HBoxContainer" type="HBoxContainer" parent="ConfirmationDialog/Panel/VBoxContainer"]
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = 10
[node name="DocsIcon" type="TextureRect" parent="ConfirmationDialog/Panel/VBoxContainer/HBoxContainer"]
[node name="DocsIcon" type="TextureRect" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
texture = SubResource("ImageTexture_gdtpn")
stretch_mode = 2
[node name="LinkButton" type="LinkButton" parent="ConfirmationDialog/Panel/VBoxContainer/HBoxContainer"]
[node name="LinkButton" type="LinkButton" parent="Panel/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8
mouse_default_cursor_shape = 16
text = "Plugin Docs"
theme_override_font_sizes/font_size = 24
text = "HOW TO USE"
uri = "https://github.com/vaporvee/discord-sdk-godot/wiki"
[node name="TextureRect" type="TextureRect" parent="ConfirmationDialog/Panel/VBoxContainer"]
[node name="TextureRect" type="TextureRect" parent="Panel/VBoxContainer"]
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
texture = ExtResource("1_f828l")
texture = ExtResource("1_0svbg")
expand_mode = 1
[node name="RichTextLabel" type="RichTextLabel" parent="ConfirmationDialog/Panel/VBoxContainer"]
custom_minimum_size = Vector2(400, 200)
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"]
custom_minimum_size = Vector2(400, 250)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 1
theme_override_font_sizes/normal_font_size = 16
theme_override_styles/normal = SubResource("StyleBoxEmpty_7v0rg")
bbcode_enabled = true
text = "[center]Thanks for enabling the
[rainbow]Discord Game SDK Plugin[/rainbow]
[rainbow][b]Discord Game SDK Plugin[/b][/rainbow]
made by vaporvee. ❤️
You need to [wave]restart[/wave] the editor to fully enable this plugin!
Do you want to [wave]save[/wave] your project before restarting?
You need to [wave][b]restart[/b][/wave] the editor to fully enable this plugin!
Do you want to [wave][b]save[/b][/wave] your project before restarting?
(Error messages after the first restart are normal. Please ignore them)"

View File

@@ -33,7 +33,7 @@ func set_activity() -> void:
discord_sdk.is_public_party = true
discord_sdk.instanced = true #required for spectate
#discord_sdk.start_timestamp = int(Time.get_unix_time_from_system())
discord_sdk.register_command("C:\\Users\\yanni\\Desktop\\demo\\discord_sdk.exe")
discord_sdk.register_command(r"C:\Users\yanni\Desktop\demo\discord_sdk.exe")
#discord_sdk.register_steam(1389990)
discord_sdk.refresh()

View File

@@ -19,6 +19,10 @@ boot_splash/image="res://assets/Banner_v1.png"
boot_splash/fullsize=false
config/icon="res://assets/Logo_V2.png"
[autoload]
DiscordSDKAutoload="*res://addons/discord-sdk-gd/nodes/discord_autoload.gd"
[display]
window/size/resizable=false

View File

@@ -93,7 +93,7 @@ discord_sdk::discord_sdk()
discord_sdk::~discord_sdk()
{
singleton = nullptr;
delete core;
delete core; // couldn't use destructor because it would not compile on linux
core = nullptr;
}

View File

@@ -3,7 +3,7 @@
#include <stdio.h>
#include "lib/discord_game_sdk/cpp/discord.h"
#include <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/classes/object.hpp>
#include <godot_cpp/core/class_db.hpp>
#define H_SET_GET(variable_type, property_name) \
@@ -13,7 +13,7 @@
using namespace godot;
class discord_sdk : public RefCounted
class discord_sdk : public Object
{
GDCLASS(discord_sdk, Object);

View File

@@ -26,7 +26,6 @@ void uninitialize_discordsdk_module(ModuleInitializationLevel p_level)
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
Engine::get_singleton()->unregister_singleton("discord_sdk");
memdelete(discordsdk);
}
}