added EditorPresence

This commit is contained in:
Yannik
2023-05-16 23:38:51 +02:00
parent 7e8c1cc7bb
commit fd5a59d1eb
6 changed files with 40 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
@tool
extends EditorExportPlugin
func _export_file(_path, _type, features):
func _export_file(_path, _type, features) -> void:
if features[2] == "windows":
if features[4] == "x86_64":
add_shared_object("res://addons/discord-sdk-gd/bin/windows/discord_game_sdk.dll",[],"/")

View File

@@ -1,5 +1,8 @@
## This always needs to run in the background if you want to comunicate with the discord client.
extends Node
@export var is_running: bool =false
func _process(delta) -> void:
discord_sdk.coreupdate()
is_running = true

View File

@@ -1,7 +1,6 @@
## This is a Debug Node wich will show (only if the project runs) some usefull info and buttons/input
extends Node
const DebugNodeGroup = preload("res://addons/discord-sdk-gd/nodes/Debug.tscn")
func _ready():
func _ready() -> void:
const DebugNodeGroup: PackedScene = preload("res://addons/discord-sdk-gd/nodes/Debug.tscn")
add_child(DebugNodeGroup.instantiate())

View File

@@ -14,14 +14,34 @@ const ExportPlugin = preload("res://addons/discord-sdk-gd/export.gd")
var loaded_exportplugin = ExportPlugin.new()
func _enter_tree():
func _enable_plugin() -> void:
print("DiscordSDK Addon got enabled")
add_custom_type("DiscordSDKLoader","Node",DiscordSDKLoader,DiscordSDKLoader_icon)
add_custom_type("DiscordSDKDebug","Node",DiscordSDKDebug,DiscordSDKDebug_icon)
add_autoload_singleton("DiscordSDKLoader", "res://addons/discord-sdk-gd/nodes/DiscordSDKLoader.tscn")
add_autoload_singleton("DiscordSDKLoader", "res://addons/discord-sdk-gd/nodes/core_updater.gd")
add_export_plugin(loaded_exportplugin)
func disable_plugin():
ProjectSettings.set_setting("DiscordSDK/EditorPresence/enabled",false)
ProjectSettings.set_initial_value("DiscordSDK/EditorPresence/enabled",false)
ProjectSettings.set_restart_if_changed("DiscordSDK/EditorPresence/enabled",true)
func _disable_plugin() -> void:
print("DiscordSDK Addon got disabled")
remove_autoload_singleton("DiscordSDKLoader")
remove_custom_type("DiscordSDKLoader")
remove_custom_type("DiscordSDKDebug")
remove_autoload_singleton("DiscordSDKLoader")
remove_export_plugin(loaded_exportplugin)
ProjectSettings.clear("DiscordSDK/EditorPresence/enabled")
func _process(_delta):
if(ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled")&&!get_editor_interface().is_playing_scene()):
if(discord_sdk.app_id != 1108142249990176808):
discord_sdk.app_id = 1108142249990176808
discord_sdk.details = ProjectSettings.get_setting("application/config/name")
discord_sdk.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\""
discord_sdk.large_image = "godot"
discord_sdk.large_image_text = str(Engine.get_version_info())
discord_sdk.start_timestamp = int(Time.get_unix_time_from_system())
discord_sdk.refresh()
if(discord_sdk.app_id == 1108142249990176808):
discord_sdk.coreupdate()