performance and code structure improvements
This commit is contained in:
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -1,3 +1,4 @@
|
|||||||
[submodule "src/lib/godot-cpp"]
|
[submodule "src/lib/godot-cpp"]
|
||||||
path = src/lib/godot-cpp
|
path = src/lib/godot-cpp
|
||||||
url = https://github.com/godotengine/godot-cpp
|
url = https://github.com/godotengine/godot-cpp
|
||||||
|
branch = 4.2
|
||||||
|
19
build.py
19
build.py
@@ -1,23 +1,28 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
yes = {'yes', 'y', 'ye', ''}
|
yes = {"yes", "y", "ye", ""}
|
||||||
no = {'no', 'n'}
|
no = {"no", "n"}
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
choice = sys.argv[1].removeprefix("-")
|
choice = sys.argv[1].removeprefix("-")
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
"Do you want to open only the built project instead of the Godot Editor after building? ([y]es/[n]o): ")
|
"Do you want to open only the built project instead of the Godot Editor after building? ([y]es/[n]o): "
|
||||||
|
)
|
||||||
choice = input().lower()
|
choice = input().lower()
|
||||||
if choice in yes:
|
if choice in yes:
|
||||||
os.system("python -m SCons && python -m SCons target=template_release && cd project && godot")
|
os.system(
|
||||||
|
"python -m SCons && python -m SCons target=template_release && cd project && godot"
|
||||||
|
)
|
||||||
elif choice in no:
|
elif choice in no:
|
||||||
if os.name == 'nt':
|
if os.name == "nt":
|
||||||
os.system(
|
os.system(
|
||||||
"python -m SCons && python -m SCons target=template_release && godot project\project.godot")
|
"python -m SCons && python -m SCons target=template_release && godot project\project.godot"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
os.system(
|
os.system(
|
||||||
"python -m SCons && python -m SCons target=template_release && godot project/project.godot")
|
"python -m SCons && python -m SCons target=template_release && godot project/project.godot"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
sys.stdout.write("Please respond with 'yes' or 'no'")
|
sys.stdout.write("Please respond with 'yes' or 'no'")
|
||||||
|
BIN
project/Node
BIN
project/Node
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,5 +3,5 @@
|
|||||||
name="DiscordSDK"
|
name="DiscordSDK"
|
||||||
description="Discord Game SDK support for GDScript in Godot"
|
description="Discord Game SDK support for GDScript in Godot"
|
||||||
author="vaporvee"
|
author="vaporvee"
|
||||||
version="3.2"
|
version="3.3"
|
||||||
script="plugin.gd"
|
script="plugin.gd"
|
||||||
|
@@ -13,7 +13,6 @@ func _enter_tree() -> void:
|
|||||||
ProjectSettings.set_setting("DiscordSDK/EditorPresence/enabled",false)
|
ProjectSettings.set_setting("DiscordSDK/EditorPresence/enabled",false)
|
||||||
ProjectSettings.set_as_basic("DiscordSDK/EditorPresence/enabled",true)
|
ProjectSettings.set_as_basic("DiscordSDK/EditorPresence/enabled",true)
|
||||||
ProjectSettings.set_initial_value("DiscordSDK/EditorPresence/enabled",false)
|
ProjectSettings.set_initial_value("DiscordSDK/EditorPresence/enabled",false)
|
||||||
ProjectSettings.set_restart_if_changed("DiscordSDK/EditorPresence/enabled",true)
|
|
||||||
|
|
||||||
func _enable_plugin() -> void:
|
func _enable_plugin() -> void:
|
||||||
if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore"):
|
if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore"):
|
||||||
|
@@ -13,7 +13,7 @@ config_version=5
|
|||||||
config/name="GDExtension DiscordSDK Test Project"
|
config/name="GDExtension DiscordSDK Test Project"
|
||||||
config/tags=PackedStringArray("vaporvee")
|
config/tags=PackedStringArray("vaporvee")
|
||||||
run/main_scene="res://main.tscn"
|
run/main_scene="res://main.tscn"
|
||||||
config/features=PackedStringArray("4.1")
|
config/features=PackedStringArray("4.2")
|
||||||
boot_splash/bg_color=Color(0.25098, 0.305882, 0.929412, 1)
|
boot_splash/bg_color=Color(0.25098, 0.305882, 0.929412, 1)
|
||||||
boot_splash/image="res://assets/Banner_v1.png"
|
boot_splash/image="res://assets/Banner_v1.png"
|
||||||
boot_splash/fullsize=false
|
boot_splash/fullsize=false
|
||||||
|
6
setup.py
6
setup.py
@@ -8,8 +8,8 @@ with zipfile.ZipFile("src/lib/discord_game_sdk.zip", "r") as zip_ref:
|
|||||||
|
|
||||||
# Patch the SDK to actually build, since it's missing an include
|
# Patch the SDK to actually build, since it's missing an include
|
||||||
with open("src/lib/discord_game_sdk/cpp/types.h", "r+") as f:
|
with open("src/lib/discord_game_sdk/cpp/types.h", "r+") as f:
|
||||||
s = f.read();
|
s = f.read()
|
||||||
f.seek(0);
|
f.seek(0)
|
||||||
f.write("#include <cstdint>\n" + s)
|
f.write("#include <cstdint>\n" + s)
|
||||||
|
|
||||||
copy_tree("src/lib/discord_game_sdk/lib/", "src/lib/discord_game_sdk/bin/")
|
copy_tree("src/lib/discord_game_sdk/lib/", "src/lib/discord_game_sdk/bin/")
|
||||||
@@ -47,4 +47,4 @@ shutil.rmtree("src/lib/discord_game_sdk/bin/x86/", ignore_errors=True)
|
|||||||
shutil.rmtree("src/lib/discord_game_sdk/bin/x86_64/", ignore_errors=True)
|
shutil.rmtree("src/lib/discord_game_sdk/bin/x86_64/", ignore_errors=True)
|
||||||
os.remove("src/lib/discord_game_sdk/README.md")
|
os.remove("src/lib/discord_game_sdk/README.md")
|
||||||
|
|
||||||
os.system("git submodule update --init")
|
os.system("git submodule update --init --remote")
|
||||||
|
@@ -89,16 +89,17 @@ SET_GET(is_public_party, activity.GetParty().SetPrivacy(static_cast<discord::Act
|
|||||||
|
|
||||||
discord_sdk::discord_sdk()
|
discord_sdk::discord_sdk()
|
||||||
{
|
{
|
||||||
ERR_FAIL_COND(singleton != nullptr);
|
|
||||||
singleton = this;
|
singleton = this;
|
||||||
|
app_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
discord_sdk::~discord_sdk()
|
discord_sdk::~discord_sdk()
|
||||||
{
|
{
|
||||||
ERR_FAIL_COND(singleton != this);
|
if (app_id != 0)
|
||||||
set_app_id(0);
|
{
|
||||||
delete core;
|
set_app_id(0);
|
||||||
core = nullptr;
|
core->~Core();
|
||||||
|
}
|
||||||
singleton = nullptr;
|
singleton = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,11 @@
|
|||||||
#include <godot_cpp/classes/ref_counted.hpp>
|
#include <godot_cpp/classes/ref_counted.hpp>
|
||||||
#include <godot_cpp/core/class_db.hpp>
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
|
|
||||||
|
#define H_SET_GET(variable_type, property_name) \
|
||||||
|
variable_type property_name; \
|
||||||
|
variable_type get_##property_name(); \
|
||||||
|
void set_##property_name(variable_type value);
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
class discord_sdk : public RefCounted
|
class discord_sdk : public RefCounted
|
||||||
@@ -29,98 +34,42 @@ public:
|
|||||||
Dictionary relationship2dict(discord::Relationship relationship);
|
Dictionary relationship2dict(discord::Relationship relationship);
|
||||||
Dictionary user2dict(discord::User user);
|
Dictionary user2dict(discord::User user);
|
||||||
///
|
///
|
||||||
|
H_SET_GET(int64_t, app_id)
|
||||||
int64_t app_id = 0;
|
H_SET_GET(String, state)
|
||||||
|
H_SET_GET(String, details)
|
||||||
String state;
|
H_SET_GET(String, large_image)
|
||||||
String details;
|
H_SET_GET(String, large_image_text)
|
||||||
|
H_SET_GET(String, small_image)
|
||||||
String large_image;
|
H_SET_GET(String, small_image_text)
|
||||||
String large_image_text;
|
H_SET_GET(int64_t, start_timestamp)
|
||||||
String small_image;
|
H_SET_GET(int64_t, end_timestamp)
|
||||||
String small_image_text;
|
H_SET_GET(String, party_id)
|
||||||
|
H_SET_GET(int32_t, current_party_size)
|
||||||
int64_t start_timestamp;
|
H_SET_GET(int32_t, max_party_size)
|
||||||
int64_t end_timestamp;
|
H_SET_GET(String, match_secret)
|
||||||
|
H_SET_GET(String, join_secret)
|
||||||
String party_id;
|
H_SET_GET(String, spectate_secret)
|
||||||
int32_t current_party_size;
|
H_SET_GET(bool, is_public_party)
|
||||||
int32_t max_party_size;
|
H_SET_GET(bool, instanced)
|
||||||
String match_secret;
|
H_SET_GET(bool, is_overlay_locked)
|
||||||
String join_secret;
|
|
||||||
String spectate_secret;
|
|
||||||
|
|
||||||
bool is_public_party;
|
|
||||||
|
|
||||||
bool instanced;
|
|
||||||
|
|
||||||
bool is_overlay_locked;
|
|
||||||
|
|
||||||
void debug();
|
void debug();
|
||||||
void coreupdate();
|
void coreupdate();
|
||||||
void refresh();
|
void refresh();
|
||||||
void clear(bool reset_values);
|
void clear(bool reset_values);
|
||||||
|
|
||||||
void unclear();
|
void unclear();
|
||||||
int64_t get_app_id();
|
|
||||||
void set_app_id(int64_t value);
|
|
||||||
String get_state();
|
|
||||||
void set_state(String value);
|
|
||||||
String get_details();
|
|
||||||
void set_details(String value);
|
|
||||||
|
|
||||||
String get_large_image();
|
|
||||||
void set_large_image(String value);
|
|
||||||
String get_large_image_text();
|
|
||||||
void set_large_image_text(String value);
|
|
||||||
String get_small_image();
|
|
||||||
void set_small_image(String value);
|
|
||||||
String get_small_image_text();
|
|
||||||
void set_small_image_text(String value);
|
|
||||||
|
|
||||||
int64_t get_start_timestamp();
|
|
||||||
void set_start_timestamp(int64_t value);
|
|
||||||
int64_t get_end_timestamp();
|
|
||||||
void set_end_timestamp(int64_t value);
|
|
||||||
|
|
||||||
String get_party_id();
|
|
||||||
void set_party_id(String value);
|
|
||||||
|
|
||||||
int32_t get_current_party_size();
|
|
||||||
void set_current_party_size(int32_t value);
|
|
||||||
int32_t get_max_party_size();
|
|
||||||
void set_max_party_size(int32_t value);
|
|
||||||
String get_match_secret();
|
|
||||||
void set_match_secret(String value);
|
|
||||||
String get_join_secret();
|
|
||||||
void set_join_secret(String value);
|
|
||||||
String get_spectate_secret();
|
|
||||||
void set_spectate_secret(String value);
|
|
||||||
|
|
||||||
bool get_is_public_party();
|
|
||||||
void set_is_public_party(bool value);
|
|
||||||
|
|
||||||
bool get_instanced();
|
|
||||||
void set_instanced(bool value);
|
|
||||||
|
|
||||||
bool get_is_overlay_enabled();
|
bool get_is_overlay_enabled();
|
||||||
bool get_is_overlay_locked();
|
|
||||||
void set_is_overlay_locked(bool value);
|
|
||||||
void open_invite_overlay(bool is_spectate);
|
void open_invite_overlay(bool is_spectate);
|
||||||
void open_server_invite_overlay(String invite_code);
|
void open_server_invite_overlay(String invite_code);
|
||||||
void open_voice_settings();
|
void open_voice_settings();
|
||||||
|
|
||||||
void accept_join_request(int64_t user_id);
|
void accept_join_request(int64_t user_id);
|
||||||
void send_invite(int64_t user_id, bool is_spectate, String message_content);
|
void send_invite(int64_t user_id, bool is_spectate, String message_content);
|
||||||
void accept_invite(int64_t user_id);
|
void accept_invite(int64_t user_id);
|
||||||
|
|
||||||
void register_command(String value);
|
void register_command(String value);
|
||||||
void register_steam(int32_t value);
|
void register_steam(int32_t value);
|
||||||
|
|
||||||
Dictionary get_current_user();
|
Dictionary get_current_user();
|
||||||
Dictionary get_relationship(int64_t user_id);
|
Dictionary get_relationship(int64_t user_id);
|
||||||
Array get_all_relationships();
|
Array get_all_relationships();
|
||||||
|
|
||||||
bool get_is_discord_working();
|
bool get_is_discord_working();
|
||||||
int get_result_int();
|
int get_result_int();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user