a lot of social sdk progress

This commit is contained in:
2025-03-23 22:36:54 +01:00
parent 80bcfbd98d
commit e9a48bba97
29 changed files with 370 additions and 255 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csl0e2px0cwc1"
path="res://.godot/imported/Logo_V2_No_Bg.png-ed667fb599fe1e17ebcfc361ff7c9c93.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/discord-rpc-gd/Logo_V2_No_Bg.png"
dest_files=["res://.godot/imported/Logo_V2_No_Bg.png-ed667fb599fe1e17ebcfc361ff7c9c93.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,6 +1,6 @@
MINIMUM GODOT VERSION: 4.2
PLEASE ACTIVATE THE PLUGIN UNDER Project -> Project Settings... -> Plugins -> DiscordRPC -> Status
PLEASE ACTIVATE THE PLUGIN UNDER Project -> Project Settings... -> Plugins -> DiscordUtil -> Status
IGNORE THE RED ERRORS ON THE FIRST 2 RESTARTS
READ THE TUTORIAL LINKED IN THE WINDOW THAT WILL OPEN ON PLUGIN ENABLE

View File

@@ -1,6 +1,6 @@
[configuration]
entry_symbol = "discordrpcgd_library_init"
entry_symbol = "DiscordUtilgd_library_init"
compatibility_minimum = 4.1
[libraries]

View File

@@ -1,8 +1,8 @@
class_name DiscordRPCTutorial
class_name DiscordUtilTutorial
extends Node
## 1. Put the addons/ folder in your Godot project[br]
## 2. Enable the addon in your Project Settings under "Plugins" and "DiscordRPC". [br](if it doesn't show up restart your project and try again)[br]
## 2. Enable the addon in your Project Settings under "Plugins" and "DiscordUtil". [br](if it doesn't show up restart your project and try again)[br]
## 3. Restart your project[br]
## 4. Create an Application under https://discord.com/developers/applications and get the Application ID br]
## 5. (optional) Set images under "Rich Presence" and "Art Assets" and remember the keys[br]
@@ -11,27 +11,27 @@ extends Node
## [codeblock]
## func _ready():
## # Application ID
## DiscordRPC.app_id = 1099618430065324082
## DiscordUtil.app_id = 1099618430065324082
## # this is boolean if everything worked
## print("Discord working: " + str(DiscordRPC.get_is_discord_working()))
## print("Discord working: " + str(DiscordUtil.get_is_discord_working()))
## # Set the first custom text row of the activity here
## DiscordRPC.details = "A demo activity by vaporvee#1231"
## DiscordUtil.details = "A demo activity by vaporvee#1231"
## # Set the second custom text row of the activity here
## DiscordRPC.state = "Checkpoint 23/23"
## DiscordUtil.state = "Checkpoint 23/23"
## # Image key for small image from "Art Assets" from the Discord Developer website
## DiscordRPC.large_image = "game"
## DiscordUtil.large_image = "game"
## # Tooltip text for the large image
## DiscordRPC.large_image_text = "Try it now!"
## DiscordUtil.large_image_text = "Try it now!"
## # Image key for large image from "Art Assets" from the Discord Developer website
## DiscordRPC.small_image = "boss"
## DiscordUtil.small_image = "boss"
## # Tooltip text for the small image
## DiscordRPC.small_image_text = "Fighting the end boss! D:"
## DiscordUtil.small_image_text = "Fighting the end boss! D:"
## # "02:41 elapsed" timestamp for the activity
## DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
## DiscordUtil.start_timestamp = int(Time.get_unix_time_from_system())
## # "59:59 remaining" timestamp for the activity
## DiscordRPC.end_timestamp = int(Time.get_unix_time_from_system()) + 3600
## DiscordUtil.end_timestamp = int(Time.get_unix_time_from_system()) + 3600
## # Always refresh after changing the values!
## DiscordRPC.refresh()
## DiscordUtil.refresh()
## [/codeblock]
##
## @tutorial(More information here): https://github.com/vaporvee/discord-rpc-godot/wiki/Quick-start

View File

@@ -11,10 +11,10 @@ script/source = "extends Node
@onready var animation_player: AnimationPlayer = $Panel/TextureRect/AnimationPlayer
func _ready():
DiscordRPC.connect(\"activity_join_request\",_on_activity_join_request)
DiscordUtil.connect(\"activity_join_request\",_on_activity_join_request)
func _process(_delta) -> void:
if(DiscordRPC.get_is_discord_working()):
if(DiscordUtil.get_is_discord_working()):
$Panel/TextureRect.self_modulate = Color(\"#3eff8d\")
if !animation_player.is_playing():
animation_player.play(\"pulsate\")
@@ -48,7 +48,7 @@ Is party public: {ppublic} (needs to be activated in Discord client settings)
Is instanced: {instanced}
\"
#$Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(DiscordRPC.is_public_party)).replace(\"{instanced}\",str(DiscordRPC.instanced)).replace(\"{ssecret}\",DiscordRPC.spectate_secret).replace(\"{jsecret}\",DiscordRPC.join_secret).replace(\"{msecret}\",DiscordRPC.match_secret).replace(\"{mpartysize}\",str(DiscordRPC.max_party_size)).replace(\"{cpartysize}\",str(DiscordRPC.current_party_size)).replace(\"{partyid}\",DiscordRPC.party_id).replace(\"{id}\",str(DiscordRPC.app_id)).replace(\"{details}\",DiscordRPC.details).replace(\"{state}\",DiscordRPC.state).replace(\"{lkey}\",DiscordRPC.large_image).replace(\"{ltext}\",DiscordRPC.large_image_text).replace(\"{skey}\",DiscordRPC.small_image).replace(\"{stext}\",DiscordRPC.small_image_text).replace(\"{stimestamp}\",str(DiscordRPC.start_timestamp)).replace(\"{etimestamp}\",str(DiscordRPC.end_timestamp))
#$Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(DiscordUtil.is_public_party)).replace(\"{instanced}\",str(DiscordUtil.instanced)).replace(\"{ssecret}\",DiscordUtil.spectate_secret).replace(\"{jsecret}\",DiscordUtil.join_secret).replace(\"{msecret}\",DiscordUtil.match_secret).replace(\"{mpartysize}\",str(DiscordUtil.max_party_size)).replace(\"{cpartysize}\",str(DiscordUtil.current_party_size)).replace(\"{partyid}\",DiscordUtil.party_id).replace(\"{id}\",str(DiscordUtil.app_id)).replace(\"{details}\",DiscordUtil.details).replace(\"{state}\",DiscordUtil.state).replace(\"{lkey}\",DiscordUtil.large_image).replace(\"{ltext}\",DiscordUtil.large_image_text).replace(\"{skey}\",DiscordUtil.small_image).replace(\"{stext}\",DiscordUtil.small_image_text).replace(\"{stimestamp}\",str(DiscordUtil.start_timestamp)).replace(\"{etimestamp}\",str(DiscordUtil.end_timestamp))
var user_request: Dictionary = {};
@@ -58,25 +58,25 @@ func _on_activity_join_request(user_requesting: Dictionary) -> void:
func _on_accept_join_request_pressed() -> void:
if(!user_request.is_empty()):
DiscordRPC.accept_join_request(user_request.id)
DiscordUtil.accept_join_request(user_request.id)
func _on_invite_with_user_id_text_submitted(new_text: String) -> void:
DiscordRPC.send_invite(int(new_text),true,\"this is a test invite sent from godot\")
DiscordUtil.send_invite(int(new_text),true,\"this is a test invite sent from godot\")
func _on_accept_with_user_id_text_submitted(new_text: String) -> void:
DiscordRPC.accept_invite(int(new_text))
DiscordUtil.accept_invite(int(new_text))
func _on_print_current_user_on_console_pressed() -> void:
print(DiscordRPC.get_current_user())
print(DiscordUtil.get_current_user())
func _on_toggle_sdk_toggled(button_pressed: bool) -> void:
if(button_pressed):
DiscordRPC.unclear()
DiscordUtil.unclear()
else:
DiscordRPC.clear(false)
DiscordUtil.clear(false)
func _on_print_friends_pressed() -> void:
print(DiscordRPC.get_all_relationships())
print(DiscordUtil.get_all_relationships())
"
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8abo6"]

View File

@@ -1,6 +1,6 @@
## This is a Debug Node wich will show some usefull info and buttons/input
##
## The DiscordRPC Debug Node will show info about the current values of its variables and some buttons to change them.
## The DiscordUtil Debug Node will show info about the current values of its variables and some buttons to change them.
##
## @tutorial: https://github.com/vaporvee/discord-rpc-godot/wiki
@tool

View File

@@ -1,7 +1,7 @@
## This is a GDscript Node wich gets automatically added as Autoload while installing the addon.
##
## It can run in the background to comunicate with Discord.
## You don't need to use it. If you remove it make sure to run [code]DiscordRPC.run_callbacks()[/code] in a [code]_process[/code] function.
## You don't need to use it. If you remove it make sure to run [code]DiscordUtil.run_callbacks()[/code] in a [code]_process[/code] function.
##
## @tutorial: https://github.com/vaporvee/discord-rpc-godot/wiki
extends Node
@@ -10,4 +10,4 @@ func _ready() -> void:
pass
func _process(_delta) -> void:
DiscordRPC.run_callbacks()
DiscordUtil.run_callbacks()

View File

@@ -1 +1 @@
uid://d1ohgxo4k3cdf
uid://dc5abjov0ebdr

View File

@@ -1,7 +1,7 @@
[plugin]
name="DiscordRPC"
description="Discord RPC Plugin for GDScript in Godot"
name="Discord Social SDK"
description="Discord Social SDK Plugin for GDScript in Godot"
author="vaporvee"
version="1.3.2"
script="plugin.gd"

View File

@@ -1,42 +1,43 @@
@tool
extends EditorPlugin
const DiscordRPCDebug: GDScript = preload("res://addons/discord-rpc-gd/nodes/debug.gd")
const DiscordRPCDebug_icon: Texture2D = preload("res://addons/discord-rpc-gd/Debug.svg")
var loaded_DiscordRPCDebug: DiscordRPCDebug = DiscordRPCDebug.new()
const DiscordSocialSDKDebug: GDScript = preload("res://addons/discord-rpc-gd/nodes/debug.gd")
const DiscordSocialSDKDebug_icon: Texture2D = preload("res://addons/discord-rpc-gd/Debug.svg")
var loaded_DiscordSocialSDKDebug: DiscordSocialSDKDebug = DiscordSocialSDKDebug.new()
var restart_window: ConfirmationDialog = preload("res://addons/discord-rpc-gd/restart_window.tscn").instantiate()
var plugin_cfg: ConfigFile = ConfigFile.new()
const plugin_data_filename: String = "/plugin_data.cfg"
func _enter_tree() -> void:
add_custom_type("DiscordRPCDebug","Node",DiscordRPCDebug,DiscordRPCDebug_icon)
get_editor_interface().get_editor_settings().settings_changed.connect(_on_editor_settings_changed)
func _ready() -> void:
await get_tree().create_timer(0.5).timeout
plugin_cfg.load(get_editor_interface().get_editor_paths().get_data_dir() + plugin_data_filename)
if !get_editor_interface().get_editor_settings().has_setting("DiscordRPC/EditorPresence/enabled"):
get_editor_interface().get_editor_settings().set_setting("DiscordRPC/EditorPresence/enabled",plugin_cfg.get_value("Discord","editor_presence",false))
if !get_editor_interface().get_editor_settings().has_setting("DiscordSocialSDK/EditorPresence/enabled"):
get_editor_interface().get_editor_settings().set_setting("DiscordSocialSDK/EditorPresence/enabled",plugin_cfg.get_value("Discord","editor_presence",false))
func _enter_tree() -> void:
add_custom_type("DiscordSocialSDKDebug","Node",DiscordSocialSDKDebug,DiscordSocialSDKDebug_icon)
get_editor_interface().get_editor_settings().settings_changed.connect(_on_editor_settings_changed)
func _exit_tree() -> void:
if get_editor_interface().get_editor_settings().has_setting("DiscordRPC/EditorPresence/enabled"):
get_editor_interface().get_editor_settings().erase("DiscordRPC/EditorPresence/enabled")
if get_editor_interface().get_editor_settings().has_setting("DiscordSocialSDK/EditorPresence/enabled"):
get_editor_interface().get_editor_settings().erase("DiscordSocialSDK/EditorPresence/enabled")
func _enable_plugin() -> void:
add_custom_type("DiscordSocialSDKDebug","Node",DiscordSocialSDKDebug,DiscordSocialSDKDebug_icon)
get_editor_interface().get_editor_settings().settings_changed.connect(_on_editor_settings_changed)
if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-rpc-gd/bin/.gdignore"):
DirAccess.remove_absolute(ProjectSettings.globalize_path("res://") + "addons/discord-rpc-gd/bin/.gdignore")
add_autoload_singleton("DiscordRPCLoader","res://addons/discord-rpc-gd/nodes/discord_autoload.gd")
restart_window.connect("confirmed", save_no_restart)
restart_window.connect("canceled", save_and_restart)
get_editor_interface().popup_dialog_centered(restart_window)
print("IGNORE RED ERROR MESSAGES BEFORE THE SECOND RESTART!")
func _disable_plugin() -> void:
remove_autoload_singleton("DiscordRPCLoader")
remove_autoload_singleton("DiscordUtilLoader")
FileAccess.open("res://addons/discord-rpc-gd/bin/.gdignore",FileAccess.WRITE)
remove_custom_type("DiscordRPCDebug")
get_editor_interface().get_editor_settings().erase("DiscordRPC/EditorPresence/enabled")
push_warning("Please restart the editor to fully disable the DiscordRPC plugin")
remove_custom_type("DiscordSocialSDKDebug")
get_editor_interface().get_editor_settings().erase("DiscordSocialSDK/EditorPresence/enabled")
push_warning("Please restart the editor to fully disable the DiscordUtil plugin")
func save_and_restart() -> void:
get_editor_interface().restart_editor(true)
@@ -46,11 +47,11 @@ func save_no_restart() -> void:
var editor_presence: Node
func _on_editor_settings_changed() -> void:
plugin_cfg.set_value("Discord","editor_presence",get_editor_interface().get_editor_settings().get_setting("DiscordRPC/EditorPresence/enabled"))
plugin_cfg.set_value("Discord","editor_presence",get_editor_interface().get_editor_settings().get_setting("DiscordSocialSDK/EditorPresence/enabled"))
plugin_cfg.save(get_editor_interface().get_editor_paths().get_data_dir() + plugin_data_filename)
if ClassDB.class_exists("EditorPresence") && editor_presence == null:
editor_presence = ClassDB.instantiate("EditorPresence")
if get_editor_interface().get_editor_settings().has_setting("DiscordRPC/EditorPresence/enabled") && get_editor_interface().get_editor_settings().get_setting("DiscordRPC/EditorPresence/enabled"):
if get_editor_interface().get_editor_settings().has_setting("DiscordSocialSDK/EditorPresence/enabled") && get_editor_interface().get_editor_settings().get_setting("DiscordSocialSDK/EditorPresence/enabled"):
add_child(editor_presence)
else:
editor_presence.queue_free()

View File

@@ -40,7 +40,7 @@ application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description="Discord RPC Godot Test"
application/file_description="Discord Social SDK Godot Test"
application/copyright=""
application/trademarks=""
application/export_angle=0

View File

@@ -3,41 +3,41 @@ extends Node
func _ready() -> void:
if GDExtensionManager.is_extension_loaded("res://addons/discord-rpc-gd/bin/discord-rpc-gd.gdextension"):
set_activity()
DiscordRPC.connect("activity_join_request",_on_activity_join_request)
#DiscordRPC.connect("activity_join",_on_activity_join)
DiscordRPC.connect("activity_spectate",_on_activity_spectate)
DiscordRPC.connect("relationships_init",_on_relationship_init)
DiscordRPC.connect("updated_relationship", _on_updated_relationship)
DiscordUtil.connect("activity_join_request",_on_activity_join_request)
#DiscordUtil.connect("activity_join",_on_activity_join)
DiscordUtil.connect("activity_spectate",_on_activity_spectate)
DiscordUtil.connect("relationships_init",_on_relationship_init)
DiscordUtil.connect("updated_relationship", _on_updated_relationship)
func set_activity() -> void:
#DiscordRPC.clear(false)
DiscordRPC.app_id = 1099618430065324082
DiscordRPC.debug()
#DiscordRPC.details = "A demo activity by vaporvee#1231"
#DiscordRPC.state = "Checkpoint 23/23"
#DiscordUtil.clear(false)
DiscordUtil.app_id = 1099618430065324082
DiscordUtil.debug()
#DiscordUtil.details = "A demo activity by vaporvee#1231"
#DiscordUtil.state = "Checkpoint 23/23"
#
#DiscordRPC.large_image = "example_game"
#DiscordRPC.large_image_text = "Try it now!"
#DiscordRPC.small_image = "boss"
#DiscordRPC.small_image_text = "Fighting the end boss! D:"
#DiscordRPC.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
#DiscordUtil.large_image = "example_game"
#DiscordUtil.large_image_text = "Try it now!"
#DiscordUtil.small_image = "boss"
#DiscordUtil.small_image_text = "Fighting the end boss! D:"
#DiscordUtil.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time
# It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server understands and
# returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others.
var my_secret: String = str(randi_range(0,999999))
#var my_secret: String = str(randi_range(0,999999))
#DiscordRPC.party_id = "mylobbycanbeeverything_" + my_secret
#DiscordRPC.current_party_size = 1
#DiscordRPC.max_party_size = 4
#DiscordRPC.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars
#DiscordRPC.join_secret = "j_" + my_secret
#DiscordRPC.spectate_secret = "s_" + my_secret
#DiscordRPC.is_public_party = true
#DiscordRPC.instanced = true #required for spectate
#DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
DiscordRPC.register_command("C:\\Users\\yanni\\Desktop\\demo\\DiscordRPC.exe")
#DiscordRPC.register_steam(1389990)
DiscordRPC.refresh()
#DiscordUtil.party_id = "mylobbycanbeeverything_" + my_secret
#DiscordUtil.current_party_size = 1
#DiscordUtil.max_party_size = 4
#DiscordUtil.match_secret = "m_" + my_secret #better use seeds with 1 to 1 range instead of just chars
#DiscordUtil.join_secret = "j_" + my_secret
#DiscordUtil.spectate_secret = "s_" + my_secret
#DiscordUtil.is_public_party = true
#DiscordUtil.instanced = true #required for spectate
#DiscordUtil.start_timestamp = int(Time.get_unix_time_from_system())
DiscordUtil.register_command("C:\\Users\\yanni\\Desktop\\demo\\DiscordUtil.exe")
#DiscordUtil.register_steam(1389990)
DiscordUtil.refresh()
var user_request: Dictionary;
@@ -46,13 +46,13 @@ func _on_activity_join_request(user_requesting: Dictionary) -> void:
user_request = user_requesting
#func _on_activity_join(secret: String) -> void:
#if(DiscordRPC.join_secret != secret):
#DiscordRPC.current_party_size = clamp(int(secret) + 1, 0, DiscordRPC.max_party_size)
#DiscordRPC.party_id = secret.replace("j_","mylobbycanbeeverything_")
#DiscordRPC.match_secret = secret.replace("j_","m_")
#DiscordRPC.join_secret = secret
#DiscordRPC.spectate_secret = secret.replace("j_","s_")
#DiscordRPC.refresh()
#if(DiscordUtil.join_secret != secret):
#DiscordUtil.current_party_size = clamp(int(secret) + 1, 0, DiscordUtil.max_party_size)
#DiscordUtil.party_id = secret.replace("j_","mylobbycanbeeverything_")
#DiscordUtil.match_secret = secret.replace("j_","m_")
#DiscordUtil.join_secret = secret
#DiscordUtil.spectate_secret = secret.replace("j_","s_")
#DiscordUtil.refresh()
func _on_activity_spectate(secret: String) -> void:
print(secret)

View File

@@ -23,7 +23,7 @@ position = Vector2(789, 330.5)
scale = Vector2(0.408203, 0.408203)
texture = ExtResource("2_gd222")
[node name="DiscordRPC Test" type="RichTextLabel" parent="."]
[node name="DiscordUtil Test" type="RichTextLabel" parent="."]
anchors_preset = -1
anchor_left = 0.293
anchor_top = 0.59
@@ -38,7 +38,10 @@ grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
bbcode_enabled = true
text = "[center][font s=60]DiscordRPC Test"
text = "[center][font s=60]DiscordUtil Test"
[node name="DiscordRPCDebug" type="Node" parent="."]
[node name="DiscordSocialSDKDebug" type="Node" parent="."]
script = ExtResource("6_ujijw")
[node name="DiscordConnector" type="DiscordConnector" parent="."]
process_mode = 4

View File

@@ -10,7 +10,7 @@ config_version=5
[application]
config/name="GDExtension DiscordRPC Test Project"
config/name="GDExtension DiscordUtil Test Project"
config/tags=PackedStringArray("vaporvee")
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.4")
@@ -22,7 +22,6 @@ config/icon="res://assets/Logo_V2.png"
[autoload]
PluginManager="*res://plugin_manager.gd"
DiscordRPCLoader="*res://addons/discord-rpc-gd/nodes/discord_autoload.gd"
[debug]
@@ -36,6 +35,7 @@ gdscript/warnings/unsafe_call_argument=1
[display]
window/size/resizable=false
display_server/driver.linuxbsd="wayland"
[dotnet]