35 Commits
1.0 ... 1.2

Author SHA1 Message Date
Yannik
c663977ccb Update README.md 2023-04-28 23:53:23 +02:00
Yannik
966da0d522 Merge branch 'fix-build-system' 2023-04-28 23:51:01 +02:00
Yannik
5f682cc9aa bumped to version 1.2 2023-04-28 23:50:06 +02:00
Yannik
8f46244a65 added version.txt to distinguish builds 2023-04-28 23:49:03 +02:00
Yannik
b2b712f24d added example.gd 2023-04-28 23:48:05 +02:00
Yannik
572debfc24 added macos build 2023-04-28 23:46:49 +02:00
Yannik
e85c671522 Update README.md 2023-04-28 18:00:45 +02:00
Yannik
d5edb10eb1 Update README.md 2023-04-28 18:00:24 +02:00
Yannik
b2fb432a21 linux builded 2023-04-27 19:23:54 +02:00
Yannik
f2f1092b2a should fix crosscompiling 2023-04-27 18:31:30 +02:00
Yannik
3006747b44 Update README.md 2023-04-27 12:38:25 +02:00
Yannik
2642a49a49 Update README.md 2023-04-27 09:07:15 +02:00
Yannik
7a029105f6 didnt merge the readme correctly 2023-04-25 22:33:49 +02:00
Yannik
921329f837 removed whitespace 2023-04-25 22:28:19 +02:00
Yannik
0ea5de351e Update README.md 2023-04-25 22:26:23 +02:00
Yannik
2fcb6d2d38 fixed wrong array name 2023-04-25 19:56:50 +02:00
Yannik
90d6d9dd86 Merge pull request #1 from vaporvee/dev
Version 1.1
2023-04-25 19:45:44 +02:00
Yannik
a6a0347dbe Merge branch 'main' into dev 2023-04-25 19:45:26 +02:00
Yannik
92915897db bump version to 1.1 2023-04-25 19:41:17 +02:00
Yannik
e95d703c7a Updated Readme.md 2023-04-25 19:40:45 +02:00
Yannik
ebf5d677e8 better end_timestamp example 2023-04-25 19:37:39 +02:00
Yannik
af1a7de970 fixed crashing when discord is not open 2023-04-25 19:35:59 +02:00
Yannik
fd72715976 again uuid updating 2023-04-25 17:59:58 +02:00
Yannik
84eb884b83 Added an known issue 2023-04-25 14:02:16 +02:00
a62ae85545 added automatic discord game sdk lib exporting 2023-04-25 13:43:18 +02:00
6bc04c045b added abillity for export scripts 2023-04-25 11:50:52 +02:00
bd125cb7d3 just rebuilt on another platform 2023-04-25 10:44:53 +02:00
bac857b984 oops there was a bracket missing 2023-04-25 10:37:23 +02:00
Yannik
5c43b68aed removed a comment 2023-04-25 10:03:03 +02:00
Yannik
d68088a7e1 Merge branch 'main' of https://github.com/vaporvee/discord-sdk-godot 2023-04-24 17:33:22 +02:00
Yannik
d4df61f263 small project changes 2023-04-24 17:33:21 +02:00
Yannik
d5a9dbf91f Update README.md 2023-04-24 08:18:06 +02:00
Pukima
7b9ae7d24a Update Banner 2023-04-23 13:49:52 +02:00
Yannik
ae3feb9d8e improved download links 2023-04-23 13:39:38 +02:00
Yannik
84db87503e Updated Readme.md added links 2023-04-23 13:36:49 +02:00
27 changed files with 173 additions and 55 deletions

7
.gitignore vendored
View File

@@ -14,7 +14,6 @@
build/
#Cleanup unused build files
*obj
*obj
*exp
*lib
*.obj
*.exp
*.lib

View File

@@ -1,21 +1,23 @@
<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 invites, user info etc. very soon!
Don't forget to run the following command **if you clone this project** or the godot-cpp folder will be empty
```sh
git submodule update --init
```
# Addon Usage :rocket:
1. Put the `discord-sdk-gd/` folder in a `addons/` folder in your Godot project
2. Enable the addon in your Project Settings under "Plugins" and "DiscordSDK". (if it doesn't show up reopen the project)
3. Create an Application under https://discord.com/developers/applications and get the Application ID
4. (optional) Set images under "Rich Presence" and "Art Assets" and remember the keys
5. 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]`
1. [Download the addon](https://github.com/vaporvee/discord-sdk-godot/releases/latest/download/ADDON-Discord-SDK-Godot.zip/)
2. Put the `addons/` folder in your Godot project
3. Enable the addon in your Project Settings under "Plugins" and "DiscordSDK". (if it doesn't show up restart your project and try again)
4. Restart your project
5. Create an Application under https://discord.com/developers/applications and get the Application ID
6. (optional) Set images under "Rich Presence" and "Art Assets" and remember the keys
```gdscript
extends Node
func _ready():
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.state = "Checkpoint 23/23"
@@ -25,7 +27,7 @@ func _ready():
Discord_Activity.small_image_text = "Fighting the end boss! D:"
Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system()) # "02:41 elapsed"
#Discord_Activity.end_timestamp = 2492978400 # "15:41 left" (but currently 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() # Always refresh after changing the values!
@@ -33,10 +35,8 @@ func _ready():
#### Then it should look like this:
<img src="https://cdn.discordapp.com/attachments/825019604207927326/1099642861256970311/activity.webp">
## 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)
- Its an early release some features aren't implemented only because i need a small amount of time not because it's not possible
### [Try a built demo](https://github.com/vaporvee/discord-sdk-godot/releases/latest/download/Demo-Export.zip)
:incoming_envelope: Still questions? write an [issue](https://github.com/vaporvee/discord-sdk-godot/issues)! I'll answer very fast :)
<br />
<br />

View File

@@ -6,11 +6,11 @@ env = SConscript("godot-cpp/SConstruct")
# Check our platform specifics
if env['platform'] == "macos":
discord_library = 'discord_game_sdk.dylib'
discord_library = 'libdiscord_game_sdk.dylib'
libexportfolder = "/macos/"
elif env['platform'] in ('linuxbsd', 'linux'):
discord_library = 'discord_game_sdk.so'
discord_library = 'libdiscord_game_sdk.so'
libexportfolder = "/linux/"
elif env['platform'] == "windows":
@@ -27,7 +27,7 @@ else:
env.Append(LIBPATH=["lib/discord-game-sdk/"])
sources = Glob('src/discord-game-sdk-cpp/*.cpp')
env.Append(CPPPATH=['src/discord-game-sdk-cpp'])
env.Append(LIBS=[discord_library.replace(".dll", "")])
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/'])

View File

@@ -0,0 +1,4 @@
Version: 1.2
Windows: build-1
Linux: build-1
MacOS: build-1

View File

@@ -4,26 +4,26 @@ entry_symbol = "discordsdkgd_library_init"
[libraries]
macos.debug = "bin/macos/discord_game_sdk_binding_debug.framework"
macos.release = "bin/macos/discord_game_sdk_binding.framework"
macos.debug = "bin/macos/libdiscord_game_sdk_binding_debug.dylib"
macos.release = "bin/macos/libdiscord_game_sdk_binding.dylib"
windows.debug.x86_64 = "bin/windows/discord_game_sdk_binding_debug.dll"
windows.release.x86_64 = "bin/windows/discord_game_sdk_binding.dll"
linux.debug.x86_64 = "bin/linux/discord_game_sdk_binding_debug.so"
linux.release.x86_64 = "bin/linux/discord_game_sdk_binding.so"
linux.debug.arm64 = "bin/linux/discord_game_sdk_binding_debug.so"
linux.release.arm64 = "bin/linux/discord_game_sdk_binding.so"
linux.debug.rv64 = "bin/linux/discord_game_sdk_binding_debug.so"
linux.release.rv64 = "bin/linux/discord_game_sdk_binding.so"
linux.debug.x86_64 = "bin/linux/libdiscord_game_sdk_binding_debug.so"
linux.release.x86_64 = "bin/linux/libdiscord_game_sdk_binding.so"
linux.debug.arm64 = "bin/linux/libdiscord_game_sdk_binding_debug.so"
linux.release.arm64 = "bin/linux/libdiscord_game_sdk_binding.so"
linux.debug.rv64 = "bin/linux/libdiscord_game_sdk_binding_debug.so"
linux.release.rv64 = "bin/linux/libdiscord_game_sdk_binding.so"
[dependencies]
macos.debug = "bin/macos/discord_game_sdk.framework"
macos.release = "bin/macos/discord_game_sdk.framework"
macos.debug = "bin/macos/libdiscord_game_sdk.dylib"
macos.release = "bin/macos/libdiscord_game_sdk.dylib"
windows.debug.x86_64 = "bin/windows/discord_game_sdk.dll"
windows.release.x86_64 = "bin/windows/discord_game_sdk.dll"
linux.debug.x86_64 = "bin/linux/discord_game_sdk.so"
linux.release.x86_64 = "bin/linux/discord_game_sdk.so"
linux.debug.arm64 = "bin/linux/discord_game_sdk.so"
linux.release.arm64 = "bin/linux/discord_game_sdk.so"
linux.debug.rv64 = "bin/linux/ldiscord_game_sdk.so"
linux.release.rv64 = "bin/linux/discord_game_sdk.so"
linux.debug.x86_64 = "bin/linux/libdiscord_game_sdk.so"
linux.release.x86_64 = "bin/linux/libdiscord_game_sdk.so"
linux.debug.arm64 = "bin/linux/libdiscord_game_sdk.so"
linux.release.arm64 = "bin/linux/libdiscord_game_sdk.so"
linux.debug.rv64 = "bin/linux/libdiscord_game_sdk.so"
linux.release.rv64 = "bin/linux/libdiscord_game_sdk.so"

View File

@@ -0,0 +1,17 @@
extends Node
func _ready():
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.state = "Checkpoint 23/23"
Discord_Activity.large_image = "game" # Image key from "Art Assets"
Discord_Activity.large_image_text = "Try it now!"
Discord_Activity.small_image = "boss" # Image key from "Art Assets"
Discord_Activity.small_image_text = "Fighting the end boss! D:"
Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system()) # "02:41 elapsed"
# Discord_Activity.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
Discord_Activity.refresh() # Always refresh after changing the values!

View File

@@ -0,0 +1,10 @@
@tool
extends EditorExportPlugin
func _export_file(path, type, features):
if features[2] == "windows":
add_shared_object("res://addons/discord-sdk-gd/bin/windows/discord_game_sdk.dll",[],"/")
elif features[2] == "linux":
add_shared_object("res://addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk.so",[],"/")
elif features[2] == "macos":
add_shared_object("res://addons/discord-sdk-gd/bin/macos/libdiscord_game_sdk.dylib",[],"/")

View File

@@ -3,5 +3,5 @@
name="DiscordSDK"
description="Discord Game SDK support for GDScript in Godot"
author="vaporvee"
version="1.0"
version="1.2"
script="plugin.gd"

View File

@@ -1,9 +1,13 @@
@tool
extends EditorPlugin
const ExportPlugin = preload("res://addons/discord-sdk-gd/export.gd")
var loaded_exportplugin = ExportPlugin.new()
func _enter_tree():
add_autoload_singleton("discord_coreupdater", "res://addons/discord-sdk-gd/discord_coreupdater.gd")
add_export_plugin(loaded_exportplugin)
func disable_plugin():
remove_autoload_singleton("discord_coreupdater")
remove_export_plugin(loaded_exportplugin)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

@@ -0,0 +1,65 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../demo/Discord_Activity.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_script=1
binary_format/embed_pck=true
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=false
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"

View File

@@ -1,7 +1,6 @@
extends Node
func _ready():
#Discord_Activity.debug()
Discord_Activity.app_id = 1099618430065324082
Discord_Activity.details = "A demo activity by vaporvee#1231"
Discord_Activity.state = "Checkpoint 23/23"
@@ -12,7 +11,8 @@ func _ready():
Discord_Activity.small_image_text = "Fighting the end boss! D:"
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()
$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))

View File

@@ -45,8 +45,10 @@ text = "[center][font s=60][rainbow]DiscordSDK Test[/rainbow][/font]"
offset_left = 7.0
offset_top = 6.0
offset_right = 514.0
offset_bottom = 399.0
text = "Application ID : {id}
offset_bottom = 722.0
text = "Is Discord working: {isdiscordworking}
Application ID : {id}
Details: {details}
State: {state}
@@ -57,3 +59,4 @@ Small image text: {stext}
Start timestamp: {stimestamp}
End timestamp: {etimestamp}"
scroll_active = false

View File

@@ -49,6 +49,8 @@ void Discord_Activity::_bind_methods()
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("get_is_discord_working"), &Discord_Activity::get_is_discord_working);
}
Discord_Activity *Discord_Activity::get_singleton()
@@ -70,21 +72,26 @@ Discord_Activity::~Discord_Activity()
void Discord_Activity::debug()
{
auto debugresult = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
discord::Activity debugactivity{};
debugactivity.SetState("Test from Godot!");
debugactivity.SetDetails("I worked months on this");
debugactivity.GetAssets().SetLargeImage("test1");
debugactivity.GetAssets().SetLargeText("wow test text for large image");
debugactivity.GetAssets().SetSmallImage("godot");
debugactivity.GetAssets().SetSmallText("wow test text for small image");
debugactivity.GetTimestamps().SetStart(1682242800);
core->ActivityManager().UpdateActivity(debugactivity, [](discord::Result debugresult) {});
result = discord::Core::Create(1080224638845591692, DiscordCreateFlags_NoRequireDiscord, &core);
activity.SetState("Test from Godot!");
activity.SetDetails("I worked months on this");
activity.GetAssets().SetLargeImage("test1");
activity.GetAssets().SetLargeText("wow test text for large image");
activity.GetAssets().SetSmallImage("godot");
activity.GetAssets().SetSmallText("wow test text for small image");
activity.GetTimestamps().SetStart(1682242800);
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::coreupdate()
{
::core->RunCallbacks();
if (result == discord::Result::Ok)
::core->RunCallbacks();
}
void Discord_Activity::set_app_id(const int64_t &value)
@@ -118,7 +125,10 @@ String Discord_Activity::get_details() const
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)
@@ -176,3 +186,8 @@ int64_t Discord_Activity::get_end_timestamp() const
{
return activity.GetTimestamps().GetEnd();
}
bool Discord_Activity::get_is_discord_working() const
{
return result == discord::Result::Ok;
}

View File

@@ -61,6 +61,8 @@ public:
void set_start_timestamp(const int64_t &value);
int64_t get_end_timestamp() const;
void set_end_timestamp(const int64_t &value);
bool get_is_discord_working() const;
};
#endif

View File

@@ -16,9 +16,8 @@ void gdextension_initialize(ModuleInitializationLevel p_level)
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
ClassDB::register_class<Discord_Activity>();
discordactivity = memnew(Discord_Activity);
Engine::get_singleton()->register_singleton("Discord_Activity", Discord_Activity::get_singleton()); // Cant change the class name in the cpp files for some reason
Engine::get_singleton()->register_singleton("Discord_Activity", Discord_Activity::get_singleton());
}
}