@@ -1,6 +1,6 @@
|
|||||||
<img src="https://github.com/vaporvee/discord-sdk-godot/blob/main/project/assets/Banner_v1.png?raw=true">
|
<img src="https://github.com/vaporvee/discord-sdk-godot/blob/main/project/assets/Banner_v1.png?raw=true">
|
||||||
|
|
||||||
### This is version 1.0! In future versions there will be lobbies, invites, linux builds etc. very soon!
|
### This is an early version! In future versions there will be lobbies, invites, linux builds etc. very soon!
|
||||||
Don't forget to run the following command **if you clone this project** or the godot-cpp folder will be empty
|
Don't forget to run the following command **if you clone this project** or the godot-cpp folder will be empty
|
||||||
```sh
|
```sh
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
@@ -11,13 +11,12 @@ git submodule update --init
|
|||||||
3. Enable the addon in your Project Settings under "Plugins" and "DiscordSDK". (if it doesn't show up reopen the project)
|
3. Enable the addon in your Project Settings under "Plugins" and "DiscordSDK". (if it doesn't show up reopen the project)
|
||||||
4. Create an Application under https://discord.com/developers/applications and get the Application ID
|
4. Create an Application under https://discord.com/developers/applications and get the Application ID
|
||||||
5. (optional) Set images under "Rich Presence" and "Art Assets" and remember the keys
|
5. (optional) Set images under "Rich Presence" and "Art Assets" and remember the keys
|
||||||
6. Exporting: You need to copy the `discord_game_sdk.dll` or on linux `discord_game_sdk.so` from `res://addons/discord-sdk-gd/bin/PLATFORM/discord_game_sdk.[dll/.so]` to your exported project in the same directory as `discord_game_sdk_binding_debug.[dll/.so]`
|
|
||||||
**Known issue:** on some PCs the project will crash when Discord isn't running. This will be fixed asap!
|
|
||||||
```gdscript
|
```gdscript
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Discord_Activity.app_id = 1099618430065324082 # Application ID
|
Discord_Activity.app_id = 1099618430065324082 # Application ID
|
||||||
|
print("Discord working: " + str(Discord_Activity.get_is_discord_working())) # A boolean if everything worked
|
||||||
Discord_Activity.details = "A demo activity by vaporvee#1231"
|
Discord_Activity.details = "A demo activity by vaporvee#1231"
|
||||||
Discord_Activity.state = "Checkpoint 23/23"
|
Discord_Activity.state = "Checkpoint 23/23"
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ func _ready():
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Extra Info
|
## Extra Info
|
||||||
- "Step 2" (enabling the addon) is needed to add `Discord_Activity.coreupdate()` to a `_process()` function with a singleton. This function is needed by pretty everything but you can it also just add it yourself.
|
|
||||||
- The Discord SDK itself doesn't build under Linux for some reason (I don't have a Mac so i don't even know if it's builds under OSX) its not well documented but I try as hard as i can to get it working crossplatform but at the time its only working under Windows... (But feel free to make pull requests btw)
|
- The Discord SDK itself doesn't build under Linux for some reason (I don't have a Mac so i don't even know if it's builds under OSX) its not well documented but I try as hard as i can to get it working crossplatform but at the time its only working under Windows... (But feel free to make pull requests btw)
|
||||||
- Its an early release some features aren't implemented only because i need a small amount of time not because it's not possible
|
- Its an early release some features aren't implemented only because i need a small amount of time not because it's not possible
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
10
project/addons/discord-sdk-gd/export.gd
Normal file
10
project/addons/discord-sdk-gd/export.gd
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
@tool
|
||||||
|
extends EditorExportPlugin
|
||||||
|
|
||||||
|
func _export_file(path, type, features):
|
||||||
|
if path[2] == "windows":
|
||||||
|
add_shared_object("res://addons/discord-sdk-gd/bin/windows/discord_game_sdk.dll",[],"/")
|
||||||
|
elif path[2] == "linux":
|
||||||
|
add_shared_object("res://addons/discord-sdk-gd/bin/linux/discord_game_sdk.so",[],"/")
|
||||||
|
elif path[2] == "macos":
|
||||||
|
add_shared_object("res://addons/discord-sdk-gd/bin/macos/discord_game_sdk.dylib",[],"/")
|
@@ -3,5 +3,5 @@
|
|||||||
name="DiscordSDK"
|
name="DiscordSDK"
|
||||||
description="Discord Game SDK support for GDScript in Godot"
|
description="Discord Game SDK support for GDScript in Godot"
|
||||||
author="vaporvee"
|
author="vaporvee"
|
||||||
version="1.0"
|
version="1.1"
|
||||||
script="plugin.gd"
|
script="plugin.gd"
|
||||||
|
@@ -1,9 +1,15 @@
|
|||||||
@tool
|
@tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
|
const ExportPlugin = preload("res://addons/discord-sdk-gd/export.gd")
|
||||||
|
var loaded_exportplugin = ExportPlugin.new()
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
add_autoload_singleton("discord_coreupdater", "res://addons/discord-sdk-gd/discord_coreupdater.gd")
|
add_autoload_singleton("discord_coreupdater", "res://addons/discord-sdk-gd/discord_coreupdater.gd")
|
||||||
|
add_export_plugin(loaded_exportplugin)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func disable_plugin():
|
func disable_plugin():
|
||||||
remove_autoload_singleton("discord_coreupdater")
|
remove_autoload_singleton("discord_coreupdater")
|
||||||
|
remove_export_plugin(loaded_exportplugin)
|
||||||
|
@@ -8,7 +8,7 @@ custom_features=""
|
|||||||
export_filter="all_resources"
|
export_filter="all_resources"
|
||||||
include_filter=""
|
include_filter=""
|
||||||
exclude_filter=""
|
exclude_filter=""
|
||||||
export_path="../../Demo/Discord_Activity.exe"
|
export_path="../../demo/Discord_Activity.exe"
|
||||||
encryption_include_filters=""
|
encryption_include_filters=""
|
||||||
encryption_exclude_filters=""
|
encryption_exclude_filters=""
|
||||||
encrypt_pck=false
|
encrypt_pck=false
|
||||||
@@ -35,7 +35,7 @@ codesign/timestamp_server_url=""
|
|||||||
codesign/digest_algorithm=1
|
codesign/digest_algorithm=1
|
||||||
codesign/description=""
|
codesign/description=""
|
||||||
codesign/custom_options=PackedStringArray()
|
codesign/custom_options=PackedStringArray()
|
||||||
application/modify_resources=true
|
application/modify_resources=false
|
||||||
application/icon=""
|
application/icon=""
|
||||||
application/console_wrapper_icon=""
|
application/console_wrapper_icon=""
|
||||||
application/icon_interpolation=4
|
application/icon_interpolation=4
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
#Discord_Activity.debug()
|
|
||||||
Discord_Activity.app_id = 1099618430065324082
|
Discord_Activity.app_id = 1099618430065324082
|
||||||
Discord_Activity.details = "A demo activity by vaporvee#1231"
|
Discord_Activity.details = "A demo activity by vaporvee#1231"
|
||||||
Discord_Activity.state = "Checkpoint 23/23"
|
Discord_Activity.state = "Checkpoint 23/23"
|
||||||
@@ -12,7 +11,8 @@ func _ready():
|
|||||||
Discord_Activity.small_image_text = "Fighting the end boss! D:"
|
Discord_Activity.small_image_text = "Fighting the end boss! D:"
|
||||||
|
|
||||||
Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system())
|
Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system())
|
||||||
#Discord_Activity.end_timestamp = 2492978400 #31. 12. 2048 in unix time
|
# Discord_Activity.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
|
||||||
|
|
||||||
Discord_Activity.refresh()
|
Discord_Activity.refresh()
|
||||||
$Info.text = $Info.text.replace("{id}",str(Discord_Activity.app_id)).replace("{details}",Discord_Activity.details).replace("{state}",Discord_Activity.state).replace("{lkey}",Discord_Activity.large_image).replace("{ltext}",Discord_Activity.large_image_text).replace("{skey}",Discord_Activity.small_image).replace("{stext}",Discord_Activity.small_image_text).replace("{stimestamp}",str(Discord_Activity.start_timestamp)).replace("{etimestamp}",str(Discord_Activity.end_timestamp))
|
|
||||||
|
$Info.text = $Info.text.replace("{isdiscordworking}",str(Discord_Activity.get_is_discord_working())).replace("{id}",str(Discord_Activity.app_id)).replace("{details}",Discord_Activity.details).replace("{state}",Discord_Activity.state).replace("{lkey}",Discord_Activity.large_image).replace("{ltext}",Discord_Activity.large_image_text).replace("{skey}",Discord_Activity.small_image).replace("{stext}",Discord_Activity.small_image_text).replace("{stimestamp}",str(Discord_Activity.start_timestamp)).replace("{etimestamp}",str(Discord_Activity.end_timestamp))
|
||||||
|
@@ -46,7 +46,9 @@ offset_left = 7.0
|
|||||||
offset_top = 6.0
|
offset_top = 6.0
|
||||||
offset_right = 514.0
|
offset_right = 514.0
|
||||||
offset_bottom = 722.0
|
offset_bottom = 722.0
|
||||||
text = "Application ID : {id}
|
text = "Is Discord working: {isdiscordworking}
|
||||||
|
|
||||||
|
Application ID : {id}
|
||||||
Details: {details}
|
Details: {details}
|
||||||
State: {state}
|
State: {state}
|
||||||
|
|
||||||
|
@@ -49,6 +49,8 @@ void Discord_Activity::_bind_methods()
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_timestamp"), "set_end_timestamp", "get_end_timestamp");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_timestamp"), "set_end_timestamp", "get_end_timestamp");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("refresh"), &Discord_Activity::refresh);
|
ClassDB::bind_method(D_METHOD("refresh"), &Discord_Activity::refresh);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_is_discord_working"), &Discord_Activity::get_is_discord_working);
|
||||||
}
|
}
|
||||||
|
|
||||||
Discord_Activity *Discord_Activity::get_singleton()
|
Discord_Activity *Discord_Activity::get_singleton()
|
||||||
@@ -70,21 +72,26 @@ Discord_Activity::~Discord_Activity()
|
|||||||
|
|
||||||
void Discord_Activity::debug()
|
void Discord_Activity::debug()
|
||||||
{
|
{
|
||||||
auto debugresult = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
|
result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
|
||||||
discord::Activity debugactivity{};
|
activity.SetState("Test from Godot!");
|
||||||
debugactivity.SetState("Test from Godot!");
|
activity.SetDetails("I worked months on this");
|
||||||
debugactivity.SetDetails("I worked months on this");
|
activity.GetAssets().SetLargeImage("test1");
|
||||||
debugactivity.GetAssets().SetLargeImage("test1");
|
activity.GetAssets().SetLargeText("wow test text for large image");
|
||||||
debugactivity.GetAssets().SetLargeText("wow test text for large image");
|
activity.GetAssets().SetSmallImage("godot");
|
||||||
debugactivity.GetAssets().SetSmallImage("godot");
|
activity.GetAssets().SetSmallText("wow test text for small image");
|
||||||
debugactivity.GetAssets().SetSmallText("wow test text for small image");
|
activity.GetTimestamps().SetStart(1682242800);
|
||||||
debugactivity.GetTimestamps().SetStart(1682242800);
|
if (result == discord::Result::Ok)
|
||||||
core->ActivityManager().UpdateActivity(debugactivity, [](discord::Result debugresult) {});
|
{
|
||||||
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord_Activity::coreupdate()
|
void Discord_Activity::coreupdate()
|
||||||
{
|
{
|
||||||
::core->RunCallbacks();
|
if (result == discord::Result::Ok)
|
||||||
|
::core->RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord_Activity::set_app_id(const int64_t &value)
|
void Discord_Activity::set_app_id(const int64_t &value)
|
||||||
@@ -118,7 +125,10 @@ String Discord_Activity::get_details() const
|
|||||||
|
|
||||||
void Discord_Activity::refresh()
|
void Discord_Activity::refresh()
|
||||||
{
|
{
|
||||||
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
if (result == discord::Result::Ok)
|
||||||
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
|
else
|
||||||
|
UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord_Activity::set_large_image(const String &value)
|
void Discord_Activity::set_large_image(const String &value)
|
||||||
@@ -175,4 +185,9 @@ void Discord_Activity::set_end_timestamp(const int64_t &value)
|
|||||||
int64_t Discord_Activity::get_end_timestamp() const
|
int64_t Discord_Activity::get_end_timestamp() const
|
||||||
{
|
{
|
||||||
return activity.GetTimestamps().GetEnd();
|
return activity.GetTimestamps().GetEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Discord_Activity::get_is_discord_working() const
|
||||||
|
{
|
||||||
|
return result == discord::Result::Ok;
|
||||||
}
|
}
|
@@ -61,6 +61,8 @@ public:
|
|||||||
void set_start_timestamp(const int64_t &value);
|
void set_start_timestamp(const int64_t &value);
|
||||||
int64_t get_end_timestamp() const;
|
int64_t get_end_timestamp() const;
|
||||||
void set_end_timestamp(const int64_t &value);
|
void set_end_timestamp(const int64_t &value);
|
||||||
|
|
||||||
|
bool get_is_discord_working() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@@ -16,7 +16,6 @@ void gdextension_initialize(ModuleInitializationLevel p_level)
|
|||||||
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
|
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
|
||||||
{
|
{
|
||||||
ClassDB::register_class<Discord_Activity>();
|
ClassDB::register_class<Discord_Activity>();
|
||||||
|
|
||||||
discordactivity = memnew(Discord_Activity);
|
discordactivity = memnew(Discord_Activity);
|
||||||
Engine::get_singleton()->register_singleton("Discord_Activity", Discord_Activity::get_singleton());
|
Engine::get_singleton()->register_singleton("Discord_Activity", Discord_Activity::get_singleton());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user