3 Commits

Author SHA1 Message Date
Yannik Ain
249fe68abd Update README.md 2025-08-28 00:58:37 +00:00
Yannik
852e3b09ea Merge pull request #81 from SmiterG/crash_fix
Fix: Editor crash when creating new scene
2025-07-10 12:21:01 +01:00
SmiterG
0d25a45a57 Fix: Editor crash when creating new scene 2025-06-09 17:01:01 -03:00
2 changed files with 39 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
<img src="/project/assets/discordgodot_banner.png" alt="Project Banner" />
<img src="/project/assets/discordgodot_banner.png" alt="Project Banner">
Discord recently released its new SDK. This plugin will get a huge overhaul and new docs as soon as possible.
<a href="https://discord.com/blog/announcing-discord-social-sdk-to-power-game-comms" target="_blank">Discord's anouncement</a>
@@ -7,10 +7,10 @@ Discord recently released its new SDK. This plugin will get a huge overhaul and
### This is for the Discord Game SDK NOT the Embedded App SDK
**Discord RPC Plugin for GDScript with an easy-to-use code pattern in Godot Engine 4.1+, with optional Editor Rich Presence! (Compatible with Linux, Windows, & MacOS)**<br><br>
<br />
<br>
### [My Discord Server](https://discord.gg/3gqUrtbaur)
# [Quick start :rocket: (click here)](https://docs.vaporvee.com/discord-rpc-godot#quick-start)
<br />
<br>
**A small donation with the sponsor button would be nice if you sell your project with this addon but is of course not mandatory!**
@@ -21,14 +21,15 @@ Discord recently released its new SDK. This plugin will get a huge overhaul and
- User information
- Relationship Manager (Get friendlist and its updates)
- Overlay management
- Editor Presence (optional)
- Editor Presence (optional) <br>
<br>
<img width="600px" src="https://raw.githubusercontent.com/vaporvee/discord-sdk-godot/main/project/assets/GodotEditorPresenceBanner.png">
<br />
<br>
<br />
<br>
### Credit
[@Pukimaa](https://github.com/pukimaa) - Designer<br>
<br />
<br>
*This project is not endorsed or affiliated with Discord Inc. or the Godot Foundation.*

View File

@@ -43,13 +43,39 @@ void EditorPresence::_ready()
void EditorPresence::_process(double delta)
{
if (state_string.utf8() != activity.GetState())
godot::Node *edited_scene_root = get_tree()->get_edited_scene_root();
if (edited_scene_root != nullptr)
{
godot::Node *edited_scene_root = get_tree()->get_edited_scene_root();
activity.SetState(String("Editing: \"" + edited_scene_root->get_scene_file_path() + "\"").replace("res://", "").utf8());
if (result == discord::Result::Ok)
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
godot::String scene_path = edited_scene_root->get_scene_file_path();
if (scene_path.is_empty())
{
state_string = "Editing: (not saved scene)";
}
else
{
state_string = "Editing: \"" + scene_path.replace("res://", "") + "\"";
}
if (state_string.utf8() != activity.GetState())
{
activity.SetState(state_string.utf8());
if (result == discord::Result::Ok)
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
}
}
else
{
godot::String default_state = "No Scene Loaded";
if (default_state.utf8() != activity.GetState())
{
activity.SetState(default_state.utf8());
if (result == discord::Result::Ok)
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
}
}
if (result == discord::Result::Ok)
core->RunCallbacks();
}