added addon as plugin to simplefy gdscript user code
This commit is contained in:
3
build.py
Normal file
3
build.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
os.system("scons && cd project && godot project.godot")#ask if editor or game should be opened
|
Binary file not shown.
11
project/addons/discord-rpc-gd/loadaddon.gd
Normal file
11
project/addons/discord-rpc-gd/loadaddon.gd
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
DiscordSDK.update()
|
7
project/addons/discord-rpc-gd/plugin.cfg
Normal file
7
project/addons/discord-rpc-gd/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[plugin]
|
||||||
|
|
||||||
|
name="DiscordRPC"
|
||||||
|
description="Takes the activity manager part from the discord-game-sdk and adds GDscript functionality."
|
||||||
|
author="vaporvee"
|
||||||
|
version="0.1"
|
||||||
|
script="plugin.gd"
|
8
project/addons/discord-rpc-gd/plugin.gd
Normal file
8
project/addons/discord-rpc-gd/plugin.gd
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
@tool
|
||||||
|
extends EditorPlugin
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
add_autoload_singleton("Discord", "res://addons/discord-rpc-gd/loadaddon.gd")
|
||||||
|
|
||||||
|
func disable_plugin():
|
||||||
|
remove_autoload_singleton("Discord")
|
@@ -4,6 +4,3 @@ extends Node
|
|||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
DiscordSDK.debug()
|
DiscordSDK.debug()
|
||||||
|
|
||||||
func _process(_delta):
|
|
||||||
DiscordSDK.updatedebug()
|
|
||||||
|
@@ -17,10 +17,18 @@ boot_splash/bg_color=Color(0.341176, 0.415686, 0.929412, 1)
|
|||||||
boot_splash/image="res://assets/Logo_V2.png"
|
boot_splash/image="res://assets/Logo_V2.png"
|
||||||
config/icon="res://assets/Logo_V2.png"
|
config/icon="res://assets/Logo_V2.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Discord="*res://addons/discord-rpc-gd/loadaddon.gd"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="GDExtension Test Project"
|
project/assembly_name="GDExtension Test Project"
|
||||||
|
|
||||||
|
[editor_plugins]
|
||||||
|
|
||||||
|
enabled=PackedStringArray("res://addons/discord-rpc-gd/plugin.cfg")
|
||||||
|
|
||||||
[native_extensions]
|
[native_extensions]
|
||||||
|
|
||||||
paths=["res://example.gdextension"]
|
paths=["res://example.gdextension"]
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "./discord-game-sdk-cpp/discord.h"
|
#include "./discord-game-sdk-cpp/discord.h"
|
||||||
#include <godot_cpp/core/class_db.hpp>
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
#include <godot_cpp/classes/editor_plugin.hpp>
|
||||||
#include <godot_cpp/variant/utility_functions.hpp>
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
@@ -11,7 +12,7 @@ discord::Core *core{};
|
|||||||
void DiscordSDK::_bind_methods()
|
void DiscordSDK::_bind_methods()
|
||||||
{
|
{
|
||||||
ClassDB::bind_method(D_METHOD("debug"), &DiscordSDK::debug);
|
ClassDB::bind_method(D_METHOD("debug"), &DiscordSDK::debug);
|
||||||
ClassDB::bind_method(D_METHOD("updatedebug"), &DiscordSDK::updatedebug);
|
ClassDB::bind_method(D_METHOD("update"), &DiscordSDK::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscordSDK *DiscordSDK::get_singleton()
|
DiscordSDK *DiscordSDK::get_singleton()
|
||||||
@@ -42,7 +43,7 @@ void DiscordSDK::debug()
|
|||||||
assets.SetSmallImage("godot");
|
assets.SetSmallImage("godot");
|
||||||
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
}
|
}
|
||||||
void DiscordSDK::updatedebug()
|
void DiscordSDK::update()
|
||||||
{
|
{
|
||||||
::core->RunCallbacks();
|
::core->RunCallbacks();
|
||||||
}
|
}
|
@@ -22,7 +22,7 @@ public:
|
|||||||
~DiscordSDK();
|
~DiscordSDK();
|
||||||
|
|
||||||
void debug();
|
void debug();
|
||||||
void updatedebug();
|
void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user