started improving the main code a bit

This commit is contained in:
Yannik
2023-10-30 01:50:54 +01:00
parent b24defd292
commit c7a06b6d9a
7 changed files with 422 additions and 264 deletions

View File

@@ -0,0 +1,266 @@
[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"]
[sub_resource type="GDScript" id="GDScript_ak1tp"]
resource_name = "Debug"
script/source = "extends Node
func _ready():
discord_sdk.connect(\"activity_join_request\",_on_activity_join_request)
func _process(_delta):
if(discord_sdk.get_is_discord_working()):
$Panel/TextureRect.self_modulate = Color(\"#3eff8d\")
$Panel/TextureRect/AnimationPlayer.play(\"pulsate\")
debug_text_update()
else:
$Panel/TextureRect.self_modulate = Color(\"#797979\")
$Panel/TextureRect/AnimationPlayer.stop()
debug_text_update()
func debug_text_update():
$Panel/Info.text = \"Application ID : {id}
Details: {details}
State: {state}
Large image key: {lkey}
Large image text: {ltext}
Small image key: {skey}
Small image text: {stext}
Start timestamp: {stimestamp}
End timestamp: {etimestamp}
Party ID: {partyid}
Current party size: {cpartysize}
Max party size: {mpartysize}
Match secret: {msecret}
Join secret: {jsecret}
Spectate secret: {ssecret}
Is party public: {ppublic} (needs to be activated in Discord client settings)
Is instanced: {instanced}
\"
$Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(discord_sdk.is_public_party)).replace(\"{instanced}\",str(discord_sdk.instanced)).replace(\"{ssecret}\",discord_sdk.spectate_secret).replace(\"{jsecret}\",discord_sdk.join_secret).replace(\"{msecret}\",discord_sdk.match_secret).replace(\"{mpartysize}\",str(discord_sdk.max_party_size)).replace(\"{cpartysize}\",str(discord_sdk.current_party_size)).replace(\"{partyid}\",discord_sdk.party_id).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))
var user_request = {};
func _on_activity_join_request(user_requesting):
print(user_requesting)
user_request = user_requesting
func _on_accept_join_request_pressed():
if(!user_request.is_empty()):
discord_sdk.accept_join_request(user_request.id)
func _on_invite_with_user_id_text_submitted(new_text):
discord_sdk.send_invite(int(new_text),true,\"this is a test invite sent from godot\")
func _on_accept_with_user_id_text_submitted(new_text):
discord_sdk.accept_invite(int(new_text))
func _on_print_current_user_on_console_pressed():
print(discord_sdk.get_current_user())
func _on_toggle_sdk_toggled(button_pressed):
if(button_pressed):
discord_sdk.unclear()
else:
discord_sdk.clear(false)
func _on_print_friends_pressed():
print(discord_sdk.get_all_relationships())
"
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8abo6"]
[sub_resource type="Animation" id="Animation_mmtmn"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.4),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.5, 0.5)]
}
[sub_resource type="Animation" id="Animation_5u02v"]
resource_name = "pulsate"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5, 1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(0.5, 0.5), Vector2(0.8, 0.8), Vector2(0.5, 0.5)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_a7ofc"]
_data = {
"RESET": SubResource("Animation_mmtmn"),
"pulsate": SubResource("Animation_5u02v")
}
[node name="DebugNodeGroup" type="Node"]
editor_description = "This is a Debug Node wich will show (only if the project runs) some usefull info and buttons/input"
script = SubResource("GDScript_ak1tp")
[node name="Panel" type="Panel" parent="."]
anchors_preset = -1
anchor_right = 0.373
anchor_bottom = 1.0
offset_left = -5.0
offset_right = 0.303955
grow_horizontal = 2
grow_vertical = 2
[node name="Info" type="RichTextLabel" parent="Panel"]
layout_mode = 0
offset_left = 12.0
offset_top = 21.0
offset_right = 429.0
offset_bottom = 461.0
theme_override_font_sizes/normal_font_size = 14
text = "Application ID : {id}
Details: {details}
State: {state}
Large image key: {lkey}
Large image text: {ltext}
Small image key: {skey}
Small image text: {stext}
Start timestamp: {stimestamp}
End timestamp: {etimestamp}
Party ID: {partyid}
Current party size: {cpartysize}
Max party size: {mpartysize}
Match secret: {msecret}
Join secret: {jsecret}
Spectate secret: {ssecret}
Is party public: {ppublic} (needs to be activated in Discord client settings)
Is instanced: {instanced}
"
fit_content = true
[node name="PrintCurrentUserOnConsole" type="Button" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 12.0
offset_top = 138.375
offset_right = 245.0
offset_bottom = 171.375
grow_vertical = 2
text = "Print current user on console"
[node name="PrintFriends" type="Button" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 12.0
offset_top = 176.5
offset_right = 204.0
offset_bottom = 207.5
grow_vertical = 2
text = "Print friends on console"
[node name="AcceptJoinRequest" type="Button" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 12.0
offset_top = 212.875
offset_right = 154.0
offset_bottom = 243.875
grow_vertical = 2
text = "ACCEPT REQUEST"
[node name="InviteWithUserID" type="LineEdit" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 11.0
offset_top = 250.375
offset_right = 210.0
offset_bottom = 281.375
grow_vertical = 2
size_flags_horizontal = 0
placeholder_text = "Invite with user_id here"
[node name="AcceptWithUserID" type="LineEdit" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 11.0
offset_top = 286.875
offset_right = 260.0
offset_bottom = 317.875
grow_vertical = 2
placeholder_text = "Accept Invite with user_id here"
[node name="ToggleSDK" type="CheckButton" parent="Panel"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 298.0
offset_top = 157.375
offset_right = 1144.0
offset_bottom = 665.375
grow_vertical = 2
scale = Vector2(0.05, 0.05)
theme_override_icons/checked = ExtResource("2_q6tao")
theme_override_icons/unchecked = ExtResource("3_5cyem")
theme_override_styles/focus = SubResource("StyleBoxEmpty_8abo6")
button_pressed = true
[node name="TextureRect" type="TextureRect" parent="Panel"]
self_modulate = Color(0.47451, 0.47451, 0.47451, 1)
layout_mode = 1
anchors_preset = -1
anchor_left = 0.88
anchor_top = 0.762
anchor_right = 0.88
anchor_bottom = 0.762
offset_left = -28.8
offset_top = -28.776
offset_right = 28.0841
offset_bottom = 28.1082
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(0.5, 0.5)
pivot_offset = Vector2(29.0693, 29.0693)
texture = ExtResource("3_goflf")
[node name="AnimationPlayer" type="AnimationPlayer" parent="Panel/TextureRect"]
libraries = {
"": SubResource("AnimationLibrary_a7ofc")
}
[connection signal="pressed" from="Panel/PrintCurrentUserOnConsole" to="." method="_on_print_current_user_on_console_pressed"]
[connection signal="pressed" from="Panel/PrintFriends" to="." method="_on_print_friends_pressed"]
[connection signal="pressed" from="Panel/AcceptJoinRequest" to="." method="_on_accept_join_request_pressed"]
[connection signal="text_submitted" from="Panel/InviteWithUserID" to="." method="_on_invite_with_user_id_text_submitted"]
[connection signal="text_submitted" from="Panel/AcceptWithUserID" to="." method="_on_accept_with_user_id_text_submitted"]
[connection signal="toggled" from="Panel/ToggleSDK" to="." method="_on_toggle_sdk_toggled"]

View File

@@ -69,7 +69,7 @@ func _on_toggle_sdk_toggled(button_pressed):
if(button_pressed): if(button_pressed):
discord_sdk.unclear() discord_sdk.unclear()
else: else:
discord_sdk.clear() discord_sdk.clear(false)
func _on_print_friends_pressed(): func _on_print_friends_pressed():
print(discord_sdk.get_all_relationships()) print(discord_sdk.get_all_relationships())

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dp4u0g6gvyt0a"
path="res://.godot/imported/GodotEditorPresenceBanner.png-5d1b012e64655706e9686e0163b65d30.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GodotEditorPresenceBanner.png"
dest_files=["res://.godot/imported/GodotEditorPresenceBanner.png-5d1b012e64655706e9686e0163b65d30.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://08bj2tfacvhm"
path="res://.godot/imported/GodotEditorPresenceBanner.svg-e0420faa20460520008caa2101993296.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GodotEditorPresenceBanner.svg"
dest_files=["res://.godot/imported/GodotEditorPresenceBanner.svg-e0420faa20460520008caa2101993296.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

@@ -9,7 +9,7 @@ func _ready() -> void:
discord_sdk.connect("updated_relationship", _on_updated_relationship) discord_sdk.connect("updated_relationship", _on_updated_relationship)
func set_activity() -> void: func set_activity() -> void:
discord_sdk.clear() discord_sdk.clear(false)
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"

View File

@@ -5,10 +5,21 @@
#include <godot_cpp/variant/utility_functions.hpp> #include <godot_cpp/variant/utility_functions.hpp>
#include <godot_cpp/classes/time.hpp> #include <godot_cpp/classes/time.hpp>
using namespace godot; #define BIND_METHOD(method, ...) godot::ClassDB::bind_method(D_METHOD(#method, ##__VA_ARGS__), &discord_sdk::method)
#define BIND_SET_GET(property_name, variant_type) \
godot::ClassDB::bind_method(D_METHOD("get_" #property_name), &discord_sdk::get_##property_name); \
godot::ClassDB::bind_method(D_METHOD("set_" #property_name, #variant_type), &discord_sdk::set_##property_name); \
godot::ClassDB::add_property(get_class_static(), PropertyInfo(variant_type, #property_name), "set_" #property_name, "get_" #property_name)
#define BIND_SIGNAL(signal_name, ...) godot::ClassDB::add_signal(get_class_static(), MethodInfo(#signal_name, __VA_ARGS__))
#define SET_GET(variable, setter, ...) /*getter isn't mandatory for this project*/ \
decltype(discord_sdk::variable) discord_sdk::get_##variable() { return variable; } \
void discord_sdk::set_##variable(decltype(discord_sdk::variable) value) \
{ \
variable = value; \
setter; \
}
discord_sdk *discord_sdk::singleton = nullptr; discord_sdk *discord_sdk::singleton = nullptr;
discord::Core *core{}; discord::Core *core{};
discord::Result result; discord::Result result;
discord::Activity activity{}; discord::Activity activity{};
@@ -16,108 +27,65 @@ discord::User user{};
void discord_sdk::_bind_methods() void discord_sdk::_bind_methods()
{ {
ClassDB::bind_method(D_METHOD("debug"), &discord_sdk::debug); BIND_SET_GET(app_id, Variant::INT);
ClassDB::bind_method(D_METHOD("coreupdate"), &discord_sdk::coreupdate); BIND_SET_GET(state, Variant::STRING);
BIND_SET_GET(details, Variant::STRING);
ClassDB::bind_method(D_METHOD("get_app_id"), &discord_sdk::get_app_id); BIND_SET_GET(large_image, Variant::STRING);
ClassDB::bind_method(D_METHOD("set_app_id", "app_id"), &discord_sdk::set_app_id); BIND_SET_GET(large_image_text, Variant::STRING);
ADD_PROPERTY(PropertyInfo(Variant::INT, "app_id"), "set_app_id", "get_app_id"); BIND_SET_GET(small_image, Variant::STRING);
ClassDB::bind_method(D_METHOD("get_state"), &discord_sdk::get_state); BIND_SET_GET(small_image_text, Variant::STRING);
ClassDB::bind_method(D_METHOD("set_state", "state"), &discord_sdk::set_state); BIND_SET_GET(start_timestamp, Variant::INT);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "state"), "set_state", "get_state"); BIND_SET_GET(end_timestamp, Variant::INT);
ClassDB::bind_method(D_METHOD("get_details"), &discord_sdk::get_details); BIND_SET_GET(party_id, Variant::STRING);
ClassDB::bind_method(D_METHOD("set_details", "details"), &discord_sdk::set_details); BIND_SET_GET(current_party_size, Variant::INT);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "details"), "set_details", "get_details"); BIND_SET_GET(max_party_size, Variant::INT);
BIND_SET_GET(match_secret, Variant::STRING);
ClassDB::bind_method(D_METHOD("get_large_image"), &discord_sdk::get_large_image); BIND_SET_GET(join_secret, Variant::STRING);
ClassDB::bind_method(D_METHOD("set_large_image", "large_image"), &discord_sdk::set_large_image); BIND_SET_GET(spectate_secret, Variant::STRING);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "large_image"), "set_large_image", "get_large_image"); BIND_SET_GET(instanced, Variant::BOOL);
ClassDB::bind_method(D_METHOD("get_large_image_text"), &discord_sdk::get_large_image_text); BIND_SET_GET(is_public_party, Variant::BOOL);
ClassDB::bind_method(D_METHOD("set_large_image_text", "large_image_text"), &discord_sdk::set_large_image_text); BIND_SIGNAL(activity_join, PropertyInfo(Variant::STRING, "join_secret"));
ADD_PROPERTY(PropertyInfo(Variant::STRING, "large_image_text"), "set_large_image_text", "get_large_image_text"); BIND_SIGNAL(activity_spectate, PropertyInfo(Variant::STRING, "spectate_secret"));
ClassDB::bind_method(D_METHOD("get_small_image"), &discord_sdk::get_small_image); BIND_SIGNAL(activity_join_request, PropertyInfo(Variant::DICTIONARY, "user_requesting"));
ClassDB::bind_method(D_METHOD("set_small_image", "small_image"), &discord_sdk::set_small_image); BIND_SIGNAL(updated_relationship, PropertyInfo(Variant::DICTIONARY, "relationship"));
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image"), "set_small_image", "get_small_image"); BIND_SIGNAL(overlay_toggle, PropertyInfo(Variant::BOOL, "is_locked"));
ClassDB::bind_method(D_METHOD("get_small_image_text"), &discord_sdk::get_small_image_text); BIND_SIGNAL(relationships_init);
ClassDB::bind_method(D_METHOD("set_small_image_text", "large_small_text"), &discord_sdk::set_small_image_text); BIND_METHOD(debug);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image_text"), "set_small_image_text", "get_small_image_text"); BIND_METHOD(coreupdate);
BIND_METHOD(refresh);
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_timestamp"), "set_end_timestamp", "get_end_timestamp");
ClassDB::bind_method(D_METHOD("get_party_id"), &discord_sdk::get_party_id);
ClassDB::bind_method(D_METHOD("set_party_id", "party_id"), &discord_sdk::set_party_id);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "party_id"), "set_party_id", "get_party_id");
ClassDB::bind_method(D_METHOD("get_current_party_size"), &discord_sdk::get_current_party_size);
ClassDB::bind_method(D_METHOD("set_current_party_size", "current_party_size"), &discord_sdk::set_current_party_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_party_size"), "set_current_party_size", "get_current_party_size");
ClassDB::bind_method(D_METHOD("get_max_party_size"), &discord_sdk::get_max_party_size);
ClassDB::bind_method(D_METHOD("set_max_party_size", "max_party_size"), &discord_sdk::set_max_party_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_party_size"), "set_max_party_size", "get_max_party_size");
ClassDB::bind_method(D_METHOD("get_match_secret"), &discord_sdk::get_match_secret);
ClassDB::bind_method(D_METHOD("set_match_secret", "match_secret"), &discord_sdk::set_match_secret);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "match_secret"), "set_match_secret", "get_match_secret");
ClassDB::bind_method(D_METHOD("get_join_secret"), &discord_sdk::get_join_secret);
ClassDB::bind_method(D_METHOD("set_join_secret", "join_secret"), &discord_sdk::set_join_secret);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "join_secret"), "set_join_secret", "get_join_secret");
ClassDB::bind_method(D_METHOD("get_spectate_secret"), &discord_sdk::get_spectate_secret);
ClassDB::bind_method(D_METHOD("set_spectate_secret", "spectate_secret"), &discord_sdk::set_spectate_secret);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "spectate_secret"), "set_spectate_secret", "get_spectate_secret");
ClassDB::bind_method(D_METHOD("get_instanced"), &discord_sdk::get_instanced);
ClassDB::bind_method(D_METHOD("set_instanced", "instanced"), &discord_sdk::set_instanced);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "instanced"), "set_instanced", "get_instanced");
ClassDB::bind_method(D_METHOD("get_is_public_party"), &discord_sdk::get_is_public_party);
ClassDB::bind_method(D_METHOD("set_is_public_party", "is_public_party"), &discord_sdk::set_is_public_party);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_public_party"), "set_is_public_party", "get_is_public_party");
ADD_SIGNAL(MethodInfo("activity_join", PropertyInfo(Variant::STRING, "join_secret")));
ADD_SIGNAL(MethodInfo("activity_spectate", PropertyInfo(Variant::STRING, "spectate_secret")));
ADD_SIGNAL(MethodInfo("activity_join_request", PropertyInfo(Variant::DICTIONARY, "user_requesting")));
ADD_SIGNAL(MethodInfo("relationships_init"));
ADD_SIGNAL(MethodInfo("updated_relationship", PropertyInfo(Variant::DICTIONARY, "relationship")));
ClassDB::bind_method(D_METHOD("refresh"), &discord_sdk::refresh);
ClassDB::bind_method(D_METHOD("clear", "reset_values"), &discord_sdk::clear, DEFVAL(false)); ClassDB::bind_method(D_METHOD("clear", "reset_values"), &discord_sdk::clear, DEFVAL(false));
ClassDB::bind_method(D_METHOD("unclear"), &discord_sdk::unclear); BIND_METHOD(unclear);
BIND_METHOD(register_command, "command");
ClassDB::bind_method(D_METHOD("register_command", "command"), &discord_sdk::register_command); BIND_METHOD(register_steam, "steam_id");
ClassDB::bind_method(D_METHOD("register_steam", "steam_id"), &discord_sdk::register_steam); BIND_METHOD(accept_join_request, "user_id");
BIND_METHOD(send_invite, "user_id", "is_spectate", "message_content");
ClassDB::bind_method(D_METHOD("accept_join_request", "user_id"), &discord_sdk::accept_join_request); BIND_METHOD(accept_invite, "user_id");
ClassDB::bind_method(D_METHOD("send_invite", "user_id", "is_spectate", "message_content"), &discord_sdk::send_invite); BIND_METHOD(get_current_user);
ClassDB::bind_method(D_METHOD("accept_invite", "user_id"), &discord_sdk::accept_invite); BIND_METHOD(get_all_relationships);
BIND_METHOD(get_is_overlay_enabled);
ClassDB::bind_method(D_METHOD("get_current_user"), &discord_sdk::get_current_user); BIND_METHOD(get_is_overlay_locked);
ClassDB::bind_method(D_METHOD("get_all_relationships"), &discord_sdk::get_all_relationships); BIND_METHOD(open_invite_overlay, "is_spectate");
BIND_METHOD(open_server_invite_overlay, "invite_code");
ClassDB::bind_method(D_METHOD("get_is_overlay_enabled"), &discord_sdk::get_is_overlay_enabled); BIND_METHOD(open_voice_settings);
ClassDB::bind_method(D_METHOD("get_is_overlay_locked"), &discord_sdk::get_is_overlay_locked); BIND_METHOD(get_is_discord_working);
ClassDB::bind_method(D_METHOD("set_is_overlay_locked", "is_overlay_locked"), &discord_sdk::set_is_overlay_locked); BIND_METHOD(get_result_int);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_overlay_locked"), "set_is_overlay_locked", "get_is_overlay_locked");
ClassDB::bind_method(D_METHOD("open_invite_overlay", "is_spectate"), &discord_sdk::open_invite_overlay);
ClassDB::bind_method(D_METHOD("open_server_invite_overlay", "invite_code"), &discord_sdk::open_server_invite_overlay);
ClassDB::bind_method(D_METHOD("open_voice_settings"), &discord_sdk::open_voice_settings);
ADD_SIGNAL(MethodInfo("overlay_toggle", PropertyInfo(Variant::BOOL, "is_locked")));
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()
{
return singleton;
} }
SET_GET(state, activity.SetState(value.utf8().get_data()))
SET_GET(details, activity.SetDetails(value.utf8().get_data()))
SET_GET(large_image, activity.GetAssets().SetLargeImage(value.utf8().get_data()))
SET_GET(large_image_text, activity.GetAssets().SetLargeText(value.utf8().get_data()))
SET_GET(small_image, activity.GetAssets().SetSmallImage(value.utf8().get_data()))
SET_GET(small_image_text, activity.GetAssets().SetSmallText(value.utf8().get_data()))
SET_GET(start_timestamp, activity.GetTimestamps().SetStart(value))
SET_GET(end_timestamp, activity.GetTimestamps().SetEnd(value))
SET_GET(party_id, activity.GetParty().SetId(value.utf8().get_data()))
SET_GET(current_party_size, activity.GetParty().GetSize().SetCurrentSize(value))
SET_GET(max_party_size, activity.GetParty().GetSize().SetMaxSize(value))
SET_GET(match_secret, activity.GetSecrets().SetMatch(value.utf8().get_data()))
SET_GET(join_secret, activity.GetSecrets().SetJoin(value.utf8().get_data()))
SET_GET(spectate_secret, activity.GetSecrets().SetSpectate(value.utf8().get_data()))
SET_GET(instanced, activity.SetInstance(value))
SET_GET(is_public_party, activity.GetParty().SetPrivacy(static_cast<discord::ActivityPartyPrivacy>(value)))
discord_sdk::discord_sdk() discord_sdk::discord_sdk()
{ {
@@ -128,9 +96,15 @@ discord_sdk::discord_sdk()
discord_sdk::~discord_sdk() discord_sdk::~discord_sdk()
{ {
ERR_FAIL_COND(singleton != this); ERR_FAIL_COND(singleton != this);
singleton = nullptr; set_app_id(0);
delete core; delete core;
core = nullptr; core = nullptr;
singleton = nullptr;
}
discord_sdk *discord_sdk::get_singleton()
{
return singleton;
} }
void discord_sdk::coreupdate() void discord_sdk::coreupdate()
@@ -165,7 +139,7 @@ void discord_sdk::set_app_id(int64_t value)
if (result == discord::Result::Ok) if (result == discord::Result::Ok)
{ {
// initialize currentuser stuff // initialize currentuser
core->UserManager().OnCurrentUserUpdate.Connect([]() core->UserManager().OnCurrentUserUpdate.Connect([]()
{discord::User user{}; {discord::User user{};
core->UserManager().GetCurrentUser(&user); }); core->UserManager().GetCurrentUser(&user); });
@@ -179,7 +153,6 @@ void discord_sdk::set_app_id(int64_t value)
core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user) core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user)
{ discord_sdk::get_singleton() { discord_sdk::get_singleton()
->emit_signal("activity_join_request", user2dict(user)); }); ->emit_signal("activity_join_request", user2dict(user)); });
core->OverlayManager().OnToggle.Connect([](bool is_locked) core->OverlayManager().OnToggle.Connect([](bool is_locked)
{ discord_sdk::get_singleton() { discord_sdk::get_singleton()
->emit_signal("overlay_toggle", is_locked); }); ->emit_signal("overlay_toggle", is_locked); });
@@ -199,25 +172,6 @@ int64_t discord_sdk::get_app_id()
return old_app_id; return old_app_id;
} }
void discord_sdk::set_state(String value)
{
state = value;
activity.SetState(value.utf8().get_data());
}
String discord_sdk::get_state()
{
return state;
}
void discord_sdk::set_details(String value)
{
details = value;
activity.SetDetails(value.utf8().get_data());
}
String discord_sdk::get_details()
{
return details;
}
void discord_sdk::refresh() void discord_sdk::refresh()
{ {
if (result == discord::Result::Ok && app_id > 0) if (result == discord::Result::Ok && app_id > 0)
@@ -276,129 +230,6 @@ void discord_sdk::unclear()
UtilityFunctions::push_warning("Discord Activity couldn't be uncleared. Maybe it didn't get cleared before?"); UtilityFunctions::push_warning("Discord Activity couldn't be uncleared. Maybe it didn't get cleared before?");
} }
void discord_sdk::set_large_image(String value)
{
large_image = value;
activity.GetAssets().SetLargeImage(value.utf8().get_data());
}
String discord_sdk::get_large_image()
{
return large_image;
}
void discord_sdk::set_large_image_text(String value)
{
large_image_text = value;
activity.GetAssets().SetLargeText(value.utf8().get_data());
}
String discord_sdk::get_large_image_text()
{
return large_image_text;
}
void discord_sdk::set_small_image(String value)
{
small_image = value;
activity.GetAssets().SetSmallImage(value.utf8().get_data());
}
String discord_sdk::get_small_image()
{
return small_image;
}
void discord_sdk::set_small_image_text(String value)
{
small_image_text = value;
activity.GetAssets().SetSmallText(value.utf8().get_data());
}
String discord_sdk::get_small_image_text()
{
return small_image_text;
}
void discord_sdk::set_start_timestamp(int64_t value)
{
start_timestamp = value;
activity.GetTimestamps().SetStart(value);
}
int64_t discord_sdk::get_start_timestamp()
{
return activity.GetTimestamps().GetStart();
}
void discord_sdk::set_end_timestamp(int64_t value)
{
end_timestamp = value;
activity.GetTimestamps().SetEnd(value);
}
int64_t discord_sdk::get_end_timestamp()
{
return activity.GetTimestamps().GetEnd();
}
void discord_sdk::set_party_id(String value)
{
party_id = value;
activity.GetParty().SetId(value.utf8().get_data());
}
String discord_sdk::get_party_id()
{
return party_id;
}
void discord_sdk::set_current_party_size(int32_t value)
{
current_party_size = value;
activity.GetParty().GetSize().SetCurrentSize(value);
}
int32_t discord_sdk::get_current_party_size()
{
return current_party_size;
}
void discord_sdk::set_max_party_size(int32_t value)
{
max_party_size = value;
activity.GetParty().GetSize().SetMaxSize(value);
}
int32_t discord_sdk::get_max_party_size()
{
return max_party_size;
}
void discord_sdk::set_match_secret(String value)
{
match_secret = value;
activity.GetSecrets().SetMatch(value.utf8().get_data());
}
String discord_sdk::get_match_secret()
{
return match_secret;
}
void discord_sdk::set_join_secret(String value)
{
join_secret = value;
activity.GetSecrets().SetJoin(value.utf8().get_data());
}
String discord_sdk::get_join_secret()
{
return join_secret;
}
void discord_sdk::set_spectate_secret(String value)
{
spectate_secret = value;
activity.GetSecrets().SetSpectate(value.utf8().get_data());
}
String discord_sdk::get_spectate_secret()
{
return spectate_secret;
}
void discord_sdk::set_instanced(bool value)
{
instanced = value;
activity.SetInstance(value);
}
bool discord_sdk::get_instanced()
{
return instanced;
}
bool discord_sdk::get_is_overlay_enabled() bool discord_sdk::get_is_overlay_enabled()
{ {
bool ie; bool ie;
@@ -435,16 +266,6 @@ void discord_sdk::open_voice_settings()
core->OverlayManager().OpenVoiceSettings({}); core->OverlayManager().OpenVoiceSettings({});
} }
void discord_sdk::set_is_public_party(bool value)
{
is_public_party = value;
activity.GetParty().SetPrivacy(static_cast<discord::ActivityPartyPrivacy>(value)); // normaly true
}
bool discord_sdk::get_is_public_party()
{
return is_public_party;
}
void discord_sdk::accept_join_request(int64_t user_id) void discord_sdk::accept_join_request(int64_t user_id)
{ {
if (result == discord::Result::Ok && app_id > 0) if (result == discord::Result::Ok && app_id > 0)
@@ -512,11 +333,6 @@ Array discord_sdk::get_all_relationships()
return all_relationships; return all_relationships;
} }
bool discord_sdk::get_is_discord_working()
{
return result == discord::Result::Ok && app_id > 0;
}
int discord_sdk::get_result_int() int discord_sdk::get_result_int()
{ {
return static_cast<int>(result); return static_cast<int>(result);
@@ -609,3 +425,8 @@ Dictionary discord_sdk::relationship2dict(discord::Relationship relationship)
dict_relationship.make_read_only(); dict_relationship.make_read_only();
return dict_relationship; return dict_relationship;
} }
bool discord_sdk::get_is_discord_working()
{
return result == discord::Result::Ok && app_id > 0;
}