diff --git a/project/discord_connector.gd b/project/discord_connector.gd index 33c3fb6..3459b9a 100644 --- a/project/discord_connector.gd +++ b/project/discord_connector.gd @@ -3,6 +3,12 @@ extends DiscordConnector func _on_user_connected(access_token: String, refresh_token: String, expires_in: int) -> void: print_debug("Access token: %s \nRefresh Token: %s \nExpires in: %s" % [access_token, refresh_token, expires_in]) +func _on_user_updated() -> void: + print_debug("USER UPDATED") + await get_tree().create_timer(2).timeout + print("oop") + $DiscordLobby.create_or_join_lobby("beanis") + func _on_user_connection_failed(error: String) -> void: push_error("User connection failed! Error: " + error) diff --git a/project/discord_lobby.gd b/project/discord_lobby.gd new file mode 100644 index 0000000..b7fc3b2 --- /dev/null +++ b/project/discord_lobby.gd @@ -0,0 +1 @@ +extends DiscordLobby diff --git a/project/discord_lobby.gd.uid b/project/discord_lobby.gd.uid new file mode 100644 index 0000000..511671d --- /dev/null +++ b/project/discord_lobby.gd.uid @@ -0,0 +1 @@ +uid://del0aaf7txxn6 diff --git a/project/main.tscn b/project/main.tscn index 1daf306..4f9956a 100644 --- a/project/main.tscn +++ b/project/main.tscn @@ -2,6 +2,7 @@ [ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"] [ext_resource type="Script" uid="uid://kmubk5a6i385" path="res://discord_connector.gd" id="3_h2yge"] +[ext_resource type="Script" uid="uid://del0aaf7txxn6" path="res://discord_lobby.gd" id="4_1bvp3"] [ext_resource type="Script" uid="uid://46tue7u6crd6" path="res://addons/discord-rpc-gd/nodes/debug.gd" id="6_ujijw"] [node name="Node" type="Node"] @@ -51,6 +52,10 @@ script = ExtResource("3_h2yge") [node name="DiscordActivity" type="DiscordActivity" parent="DiscordConnector"] root_connector = NodePath("..") +[node name="DiscordLobby" type="DiscordLobby" parent="DiscordConnector"] +root_connector = NodePath("..") +script = ExtResource("4_1bvp3") + [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] position = Vector2(789, 330.5) scale = Vector2(0.408203, 0.408203) diff --git a/src/gen/doc_data.gen.cpp b/src/gen/doc_data.gen.cpp index 48763b8..76afba8 100644 --- a/src/gen/doc_data.gen.cpp +++ b/src/gen/doc_data.gen.cpp @@ -2,7 +2,7 @@ #include -static const char *_doc_data_hash = "8311200392454987859"; +static const char *_doc_data_hash = "8781033133787346433"; static const int _doc_data_uncompressed_size = 4148; static const int _doc_data_compressed_size = 684; static const unsigned char _doc_data_compressed[] = { diff --git a/src/nodes/discord_connector.cpp b/src/nodes/discord_connector.cpp index 6979d1c..5dd3e7a 100644 --- a/src/nodes/discord_connector.cpp +++ b/src/nodes/discord_connector.cpp @@ -81,7 +81,7 @@ void DiscordConnector::_ready() void DiscordConnector::_process(double delta) { - if (!Engine::get_singleton()->is_editor_hint() && !editor_process) + if (!Engine::get_singleton()->is_editor_hint() && !editor_process && client) { discordpp::RunCallbacks(); } diff --git a/src/nodes/discord_linked_channel.cpp b/src/nodes/discord_linked_channel.cpp new file mode 100644 index 0000000..9236a6f --- /dev/null +++ b/src/nodes/discord_linked_channel.cpp @@ -0,0 +1,16 @@ +#include "discord_linked_channel.h" + +void DiscordLinkedChannel ::_bind_methods() +{ + +} + +DiscordLinkedChannel::DiscordLinkedChannel () +{ + +} + +DiscordLinkedChannel::~DiscordLinkedChannel() +{ + +} \ No newline at end of file diff --git a/src/nodes/discord_linked_channel.h b/src/nodes/discord_linked_channel.h new file mode 100644 index 0000000..bf7c052 --- /dev/null +++ b/src/nodes/discord_linked_channel.h @@ -0,0 +1,20 @@ +#ifndef DISCORD_LINKED_CHANNEL_H +#define DISCORD_LINKED_CHANNEL_H + +#include "discord_connected.h" + +using namespace godot; + +class DiscordLinkedChannel : public DiscordConnected +{ + GDCLASS(DiscordLinkedChannel, DiscordConnected); + +protected: + static void _bind_methods(); + +public: + DiscordLinkedChannel(); + ~DiscordLinkedChannel(); +}; + +#endif \ No newline at end of file diff --git a/src/nodes/discord_lobby.cpp b/src/nodes/discord_lobby.cpp new file mode 100644 index 0000000..a9f9c8d --- /dev/null +++ b/src/nodes/discord_lobby.cpp @@ -0,0 +1,31 @@ +#include "discord_lobby.h" + +void DiscordLobby ::_bind_methods() +{ + BIND_METHOD(DiscordLobby, create_or_join_lobby, "secret"); +} + +void DiscordLobby::create_or_join_lobby(String secret) { + if (connector) { + auto current_client = connector->client; + + current_client->CreateOrJoinLobby(secret.utf8().get_data(),[current_client](discordpp::ClientResult result, uint64_t lobbyId) { + if(result.Successful()) { + std::cout << "Lobby created or joined successfully! Lobby Id: " << lobbyId << std::endl; + } else { + std::cout << "Lobby creation/join failed\n" << result.Error().c_str(); + } + }); + } +} + +DiscordLobby::DiscordLobby() +{ + +} + +DiscordLobby::~DiscordLobby() +{ + +} + diff --git a/src/nodes/discord_lobby.h b/src/nodes/discord_lobby.h new file mode 100644 index 0000000..1387e24 --- /dev/null +++ b/src/nodes/discord_lobby.h @@ -0,0 +1,21 @@ +#ifndef DISCORD_LOBBY_H +#define DISCORD_LOBBY_H + +#include "discord_connected.h" + +using namespace godot; + +class DiscordLobby : public DiscordConnected +{ + GDCLASS(DiscordLobby, DiscordConnected); + +protected: + static void _bind_methods(); + +public: + void create_or_join_lobby(String secret); + DiscordLobby(); + ~DiscordLobby(); +}; + +#endif \ No newline at end of file diff --git a/src/register_types.cpp b/src/register_types.cpp index 3a00227..8c4d763 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -15,6 +15,8 @@ void initialize_DiscordUtil_module(ModuleInitializationLevel p_level) ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_abstract_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); } diff --git a/src/register_types.h b/src/register_types.h index fc75432..0c81c2c 100644 --- a/src/register_types.h +++ b/src/register_types.h @@ -17,6 +17,8 @@ void uninitialize_DiscordUtil_module(); #include "nodes/editor_presence.h" #include "nodes/discord_connector.h" #include "nodes/discord_connected.h" +#include "nodes/discord_lobby.h" +#include "nodes/discord_linked_channel.h" #include "nodes/discord_activity.h" #include "resources/activity.h"