crash fix for missing party invite resources
This commit is contained in:
@@ -1,22 +1,17 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://dyc3kseph4el7"]
|
[gd_scene load_steps=5 format=3 uid="uid://dyc3kseph4el7"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"]
|
[ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"]
|
||||||
[ext_resource type="Script" uid="uid://kmubk5a6i385" path="res://discord_connector.gd" id="3_h2yge"]
|
[ext_resource type="Script" uid="uid://kmubk5a6i385" path="res://discord_connector.gd" id="3_h2yge"]
|
||||||
[ext_resource type="Script" uid="uid://46tue7u6crd6" path="res://addons/discord-rpc-gd/nodes/debug.gd" id="6_ujijw"]
|
[ext_resource type="Script" uid="uid://46tue7u6crd6" path="res://addons/discord-rpc-gd/nodes/debug.gd" id="6_ujijw"]
|
||||||
|
|
||||||
[sub_resource type="RichPresence" id="RichPresence_h2yge"]
|
[sub_resource type="RichPresence" id="RichPresence_h2yge"]
|
||||||
state = "Inside a Node"
|
|
||||||
details = "Godot -> Discord Social SDK"
|
details = "Godot -> Discord Social SDK"
|
||||||
|
state = "Inside a Node"
|
||||||
large_image = "example_game"
|
large_image = "example_game"
|
||||||
large_text = "Example"
|
large_text = "Example"
|
||||||
small_image = "boss"
|
small_image = "boss"
|
||||||
small_text = "Fighting the boss D:"
|
small_text = "Fighting the boss D:"
|
||||||
|
|
||||||
[sub_resource type="PartyInvite" id="PartyInvite_h2yge"]
|
|
||||||
id = "test"
|
|
||||||
join_secret = "test2"
|
|
||||||
is_public_party = true
|
|
||||||
|
|
||||||
[node name="Node" type="Node"]
|
[node name="Node" type="Node"]
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="."]
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
@@ -62,7 +57,6 @@ script = ExtResource("3_h2yge")
|
|||||||
|
|
||||||
[node name="DiscordActivity" type="DiscordActivity" parent="DiscordConnector"]
|
[node name="DiscordActivity" type="DiscordActivity" parent="DiscordConnector"]
|
||||||
rich_presence = SubResource("RichPresence_h2yge")
|
rich_presence = SubResource("RichPresence_h2yge")
|
||||||
party_invite = SubResource("PartyInvite_h2yge")
|
|
||||||
root_connector = NodePath("..")
|
root_connector = NodePath("..")
|
||||||
|
|
||||||
[node name="DiscordLobby" type="DiscordLobby" parent="DiscordConnector"]
|
[node name="DiscordLobby" type="DiscordLobby" parent="DiscordConnector"]
|
||||||
|
@@ -35,8 +35,9 @@ void DiscordActivity::set_party_invite(Ref<PartyInvite> value)
|
|||||||
|
|
||||||
void DiscordActivity::update()
|
void DiscordActivity::update()
|
||||||
{
|
{
|
||||||
if(rich_presence.is_valid()){
|
|
||||||
discordpp::Activity activity;
|
discordpp::Activity activity;
|
||||||
|
if (rich_presence.is_valid())
|
||||||
|
{
|
||||||
activity.SetState(rich_presence->get_state().utf8().get_data());
|
activity.SetState(rich_presence->get_state().utf8().get_data());
|
||||||
activity.SetDetails(rich_presence->get_details().utf8().get_data());
|
activity.SetDetails(rich_presence->get_details().utf8().get_data());
|
||||||
discordpp::ActivityAssets assets;
|
discordpp::ActivityAssets assets;
|
||||||
@@ -49,7 +50,9 @@ void DiscordActivity::update()
|
|||||||
timestamps.SetStart(rich_presence->get_timestamps_start());
|
timestamps.SetStart(rich_presence->get_timestamps_start());
|
||||||
timestamps.SetEnd(rich_presence->get_timestamps_end());
|
timestamps.SetEnd(rich_presence->get_timestamps_end());
|
||||||
activity.SetTimestamps(timestamps);
|
activity.SetTimestamps(timestamps);
|
||||||
|
}
|
||||||
|
if (party_invite.is_valid())
|
||||||
|
{
|
||||||
discordpp::ActivityParty party;
|
discordpp::ActivityParty party;
|
||||||
party.SetCurrentSize(party_invite->get_current_size());
|
party.SetCurrentSize(party_invite->get_current_size());
|
||||||
party.SetMaxSize(party_invite->get_max_size());
|
party.SetMaxSize(party_invite->get_max_size());
|
||||||
@@ -61,6 +64,7 @@ void DiscordActivity::update()
|
|||||||
activity.SetParty(party);
|
activity.SetParty(party);
|
||||||
// TODO: Supported platforms
|
// TODO: Supported platforms
|
||||||
// activity.SetSupportedPlatforms();
|
// activity.SetSupportedPlatforms();
|
||||||
|
// TODO: Error on invalid values inside getters
|
||||||
|
}
|
||||||
connector->client->UpdateRichPresence(activity, [](discordpp::ClientResult result) {});
|
connector->client->UpdateRichPresence(activity, [](discordpp::ClientResult result) {});
|
||||||
}
|
}
|
||||||
}
|
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
void RichPresence::_bind_methods()
|
void RichPresence::_bind_methods()
|
||||||
{
|
{
|
||||||
BIND_SET_GET(RichPresence, state, Variant::STRING);
|
|
||||||
BIND_SET_GET(RichPresence, details, Variant::STRING);
|
BIND_SET_GET(RichPresence, details, Variant::STRING);
|
||||||
|
BIND_SET_GET(RichPresence, state, Variant::STRING);
|
||||||
ADD_GROUP("Large Image", "large_");
|
ADD_GROUP("Large Image", "large_");
|
||||||
BIND_SET_GET(RichPresence, large_image, Variant::STRING);
|
BIND_SET_GET(RichPresence, large_image, Variant::STRING);
|
||||||
BIND_SET_GET(RichPresence, large_text, Variant::STRING);
|
BIND_SET_GET(RichPresence, large_text, Variant::STRING);
|
||||||
@@ -14,16 +14,6 @@ void RichPresence::_bind_methods()
|
|||||||
|
|
||||||
RichPresence::RichPresence() {}
|
RichPresence::RichPresence() {}
|
||||||
|
|
||||||
void RichPresence::set_state(String value)
|
|
||||||
{
|
|
||||||
state = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
String RichPresence::get_state()
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RichPresence::set_details(String value)
|
void RichPresence::set_details(String value)
|
||||||
{
|
{
|
||||||
details = value;
|
details = value;
|
||||||
@@ -34,6 +24,16 @@ String RichPresence::get_details()
|
|||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RichPresence::set_state(String value)
|
||||||
|
{
|
||||||
|
state = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RichPresence::get_state()
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
void RichPresence::set_large_image(String value)
|
void RichPresence::set_large_image(String value)
|
||||||
{
|
{
|
||||||
large_image = value;
|
large_image = value;
|
||||||
|
@@ -9,16 +9,16 @@
|
|||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
class RichPresence : public Resource {
|
class RichPresence : public Resource
|
||||||
|
{
|
||||||
GDCLASS(RichPresence, Resource);
|
GDCLASS(RichPresence, Resource);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
H_SET_GET(state, "")
|
|
||||||
H_SET_GET(details, "")
|
H_SET_GET(details, "")
|
||||||
|
H_SET_GET(state, "")
|
||||||
H_SET_GET(large_image, "")
|
H_SET_GET(large_image, "")
|
||||||
H_SET_GET(large_text, "")
|
H_SET_GET(large_text, "")
|
||||||
H_SET_GET(small_image, "")
|
H_SET_GET(small_image, "")
|
||||||
|
Reference in New Issue
Block a user