Fix module compilation
This commit is contained in:
parent
ac3da5ab90
commit
0e37d3dfa3
2
SCsub
2
SCsub
|
@ -5,6 +5,8 @@ Import("env_modules")
|
||||||
|
|
||||||
module_env = env.Clone()
|
module_env = env.Clone()
|
||||||
|
|
||||||
|
module_env.Append(CPPDEFINES = ['LIMBOAI_MODULE'])
|
||||||
|
|
||||||
module_env.add_source_files(env.modules_sources, "*.cpp")
|
module_env.add_source_files(env.modules_sources, "*.cpp")
|
||||||
module_env.add_source_files(env.modules_sources, "blackboard/*.cpp")
|
module_env.add_source_files(env.modules_sources, "blackboard/*.cpp")
|
||||||
module_env.add_source_files(env.modules_sources, "blackboard/bb_param/*.cpp")
|
module_env.add_source_files(env.modules_sources, "blackboard/bb_param/*.cpp")
|
||||||
|
|
|
@ -111,7 +111,6 @@ void BBParam::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_variable"), &BBParam::get_variable);
|
ClassDB::bind_method(D_METHOD("get_variable"), &BBParam::get_variable);
|
||||||
ClassDB::bind_method(D_METHOD("get_type"), &BBParam::get_type);
|
ClassDB::bind_method(D_METHOD("get_type"), &BBParam::get_type);
|
||||||
ClassDB::bind_method(D_METHOD("get_value", "p_agent", "p_blackboard", "p_default"), &BBParam::get_value, Variant());
|
ClassDB::bind_method(D_METHOD("get_value", "p_agent", "p_blackboard", "p_default"), &BBParam::get_value, Variant());
|
||||||
ClassDB::bind_method(D_METHOD("_to_string"), &BBParam::_to_string);
|
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "value_source", PROPERTY_HINT_ENUM, "Saved Value,Blackboard Var"), "set_value_source", "get_value_source");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "value_source", PROPERTY_HINT_ENUM, "Saved Value,Blackboard Var"), "set_value_source", "get_value_source");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable", PROPERTY_HINT_NONE, "", 0), "set_variable", "get_variable");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "variable", PROPERTY_HINT_NONE, "", 0), "set_variable", "get_variable");
|
||||||
|
|
|
@ -31,7 +31,7 @@ Ref<BehaviorTree> BehaviorTree::clone() const {
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorTree::copy_from(const Ref<BehaviorTree> &p_other) {
|
void BehaviorTree::copy_other(const Ref<BehaviorTree> &p_other) {
|
||||||
ERR_FAIL_COND(p_other.is_null());
|
ERR_FAIL_COND(p_other.is_null());
|
||||||
description = p_other->get_description();
|
description = p_other->get_description();
|
||||||
root_task = p_other->get_root_task();
|
root_task = p_other->get_root_task();
|
||||||
|
@ -50,7 +50,7 @@ void BehaviorTree::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_root_task", "p_value"), &BehaviorTree::set_root_task);
|
ClassDB::bind_method(D_METHOD("set_root_task", "p_value"), &BehaviorTree::set_root_task);
|
||||||
ClassDB::bind_method(D_METHOD("get_root_task"), &BehaviorTree::get_root_task);
|
ClassDB::bind_method(D_METHOD("get_root_task"), &BehaviorTree::get_root_task);
|
||||||
ClassDB::bind_method(D_METHOD("clone"), &BehaviorTree::clone);
|
ClassDB::bind_method(D_METHOD("clone"), &BehaviorTree::clone);
|
||||||
ClassDB::bind_method(D_METHOD("copy_from", "p_other"), &BehaviorTree::copy_from);
|
ClassDB::bind_method(D_METHOD("copy_other", "p_other"), &BehaviorTree::copy_other);
|
||||||
ClassDB::bind_method(D_METHOD("instantiate", "p_agent", "p_blackboard"), &BehaviorTree::instantiate);
|
ClassDB::bind_method(D_METHOD("instantiate", "p_agent", "p_blackboard"), &BehaviorTree::instantiate);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "description", PROPERTY_HINT_MULTILINE_TEXT), "set_description", "get_description");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "description", PROPERTY_HINT_MULTILINE_TEXT), "set_description", "get_description");
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
Ref<BTTask> get_root_task() const { return root_task; }
|
Ref<BTTask> get_root_task() const { return root_task; }
|
||||||
|
|
||||||
Ref<BehaviorTree> clone() const;
|
Ref<BehaviorTree> clone() const;
|
||||||
void copy_from(const Ref<BehaviorTree> &p_other);
|
void copy_other(const Ref<BehaviorTree> &p_other);
|
||||||
Ref<BTTask> instantiate(Node *p_agent, const Ref<Blackboard> &p_blackboard) const;
|
Ref<BTTask> instantiate(Node *p_agent, const Ref<Blackboard> &p_blackboard) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "bt_player.h"
|
#include "bt_player.h"
|
||||||
|
|
||||||
#include "../editor/debugger/limbo_debugger.h"
|
#include "../editor/debugger/limbo_debugger.h"
|
||||||
|
#include "../util/limbo_compat.h"
|
||||||
#include "../util/limbo_string_names.h"
|
#include "../util/limbo_string_names.h"
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
|
@ -130,7 +131,7 @@ void BTPlayer::_set_monitor_performance(bool p_monitor_performance) {
|
||||||
String(itos(get_instance_id())).md5_text().substr(0, 4));
|
String(itos(get_instance_id())).md5_text().substr(0, 4));
|
||||||
}
|
}
|
||||||
if (!perf->has_custom_monitor(monitor_id)) {
|
if (!perf->has_custom_monitor(monitor_id)) {
|
||||||
perf->add_custom_monitor(monitor_id, callable_mp(this, &BTPlayer::_get_mean_update_time_msec));
|
PERFORMANCE_ADD_CUSTOM_MONITOR(monitor_id, callable_mp(this, &BTPlayer::_get_mean_update_time_msec));
|
||||||
}
|
}
|
||||||
} else if (monitor_id != StringName() && perf->has_custom_monitor(monitor_id)) {
|
} else if (monitor_id != StringName() && perf->has_custom_monitor(monitor_id)) {
|
||||||
perf->remove_custom_monitor(monitor_id);
|
perf->remove_custom_monitor(monitor_id);
|
||||||
|
|
|
@ -12,11 +12,12 @@
|
||||||
#ifndef BTTASK_H
|
#ifndef BTTASK_H
|
||||||
#define BTTASK_H
|
#define BTTASK_H
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#include "../../blackboard/blackboard.h"
|
||||||
#include "modules/limboai/blackboard/blackboard.h"
|
#include "../../util/limbo_compat.h"
|
||||||
#include "modules/limboai/util/limbo_string_names.h"
|
#include "../../util/limbo_string_names.h"
|
||||||
#include "modules/limboai/util/limbo_task_db.h"
|
#include "../../util/limbo_task_db.h"
|
||||||
|
|
||||||
|
#ifdef LIMBOAI_MODULE
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/error/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "core/io/resource.h"
|
#include "core/io/resource.h"
|
||||||
|
@ -31,21 +32,16 @@
|
||||||
#include "core/variant/binder_common.h"
|
#include "core/variant/binder_common.h"
|
||||||
#include "core/variant/dictionary.h"
|
#include "core/variant/dictionary.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // ! LIMBOAI_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
#include "blackboard/blackboard.h"
|
|
||||||
#include "util/limbo_compat.h"
|
|
||||||
#include "util/limbo_string_names.h"
|
|
||||||
#include "util/limbo_task_db.h"
|
|
||||||
|
|
||||||
#include <godot_cpp/classes/engine.hpp>
|
#include <godot_cpp/classes/engine.hpp>
|
||||||
#include <godot_cpp/classes/resource.hpp>
|
#include <godot_cpp/classes/resource.hpp>
|
||||||
#include <godot_cpp/core/object.hpp>
|
#include <godot_cpp/core/object.hpp>
|
||||||
#include <godot_cpp/templates/vector.hpp>
|
#include <godot_cpp/templates/vector.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for BTTask.
|
* Base class for BTTask.
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bt_probability_selector.h"
|
#include "bt_probability_selector.h"
|
||||||
#include "godot_cpp/variant/utility_functions.hpp"
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
|
|
||||||
double BTProbabilitySelector::get_weight(int p_index) const {
|
double BTProbabilitySelector::get_weight(int p_index) const {
|
||||||
ERR_FAIL_INDEX_V(p_index, get_child_count(), 0.0);
|
ERR_FAIL_INDEX_V(p_index, get_child_count(), 0.0);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef BT_PROBABILITY_SELECTOR_H
|
#ifndef BT_PROBABILITY_SELECTOR_H
|
||||||
#define BT_PROBABILITY_SELECTOR_H
|
#define BT_PROBABILITY_SELECTOR_H
|
||||||
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
#include "../bt_comment.h"
|
#include "../bt_comment.h"
|
||||||
#include "../bt_composite.h"
|
#include "../bt_composite.h"
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "bt_probability.h"
|
#include "bt_probability.h"
|
||||||
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
|
|
||||||
void BTProbability::set_run_chance(float p_value) {
|
void BTProbability::set_run_chance(float p_value) {
|
||||||
run_chance = p_value;
|
run_chance = p_value;
|
||||||
emit_changed();
|
emit_changed();
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bt_repeat.h"
|
#include "bt_repeat.h"
|
||||||
#include "util/limbo_string_names.h"
|
|
||||||
|
#include "../../../util/limbo_string_names.h"
|
||||||
|
|
||||||
String BTRepeat::_generate_name() {
|
String BTRepeat::_generate_name() {
|
||||||
if (forever) {
|
if (forever) {
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "bt_call_method.h"
|
#include "bt_call_method.h"
|
||||||
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
|
|
||||||
//**** Setters / Getters
|
//**** Setters / Getters
|
||||||
|
|
||||||
void BTCallMethod::set_method(StringName p_method_name) {
|
void BTCallMethod::set_method(StringName p_method_name) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "../bt_action.h"
|
#include "../bt_action.h"
|
||||||
|
|
||||||
#include "../../limboai/blackboard/bb_param/bb_node.h"
|
#include "../../../limboai/blackboard/bb_param/bb_node.h"
|
||||||
|
|
||||||
class BTCallMethod : public BTAction {
|
class BTCallMethod : public BTAction {
|
||||||
GDCLASS(BTCallMethod, BTAction);
|
GDCLASS(BTCallMethod, BTAction);
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "bt_console_print.h"
|
#include "bt_console_print.h"
|
||||||
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
|
|
||||||
String BTConsolePrint::_generate_name() {
|
String BTConsolePrint::_generate_name() {
|
||||||
String tx = text;
|
String tx = text;
|
||||||
if (text.length() > 30) {
|
if (text.length() > 30) {
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "bt_random_wait.h"
|
#include "bt_random_wait.h"
|
||||||
|
|
||||||
|
#include "../../../util/limbo_compat.h"
|
||||||
|
|
||||||
String BTRandomWait::_generate_name() {
|
String BTRandomWait::_generate_name() {
|
||||||
return vformat("Wait %s to %s sec",
|
return vformat("Wait %s to %s sec",
|
||||||
Math::snapped(min_duration, 0.001),
|
Math::snapped(min_duration, 0.001),
|
||||||
|
|
|
@ -11,16 +11,15 @@
|
||||||
|
|
||||||
#include "action_banner.h"
|
#include "action_banner.h"
|
||||||
|
|
||||||
|
#include "../util/limbo_compat.h"
|
||||||
|
#include "../util/limbo_string_names.h"
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
#include "../util/limbo_compat.h"
|
|
||||||
#include "../util/limbo_string_names.h"
|
|
||||||
|
|
||||||
#include <godot_cpp/classes/button.hpp>
|
#include <godot_cpp/classes/button.hpp>
|
||||||
|
|
||||||
#endif // ! LIMBOAI_GDEXTENSION
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
void ActionBanner::set_text(const String &p_text) {
|
void ActionBanner::set_text(const String &p_text) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "limbo_debugger.h"
|
#include "limbo_debugger.h"
|
||||||
|
|
||||||
#include "../../bt/tasks/bt_task.h"
|
#include "../../bt/tasks/bt_task.h"
|
||||||
|
#include "../../util/limbo_compat.h"
|
||||||
#include "behavior_tree_data.h"
|
#include "behavior_tree_data.h"
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
|
@ -88,11 +89,13 @@ Error LimboDebugger::parse_message(void *p_user, const String &p_msg, const Arra
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
bool LimboDebugger::parse_message_gdext(const String &p_msg, const Array &p_args) {
|
bool LimboDebugger::parse_message_gdext(const String &p_msg, const Array &p_args) {
|
||||||
bool r_captured;
|
bool r_captured;
|
||||||
LimboDebugger::parse_message(nullptr, p_msg, p_args, r_captured);
|
LimboDebugger::parse_message(nullptr, p_msg, p_args, r_captured);
|
||||||
return r_captured;
|
return r_captured;
|
||||||
}
|
}
|
||||||
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
void LimboDebugger::register_bt_instance(Ref<BTTask> p_instance, NodePath p_player_path) {
|
void LimboDebugger::register_bt_instance(Ref<BTTask> p_instance, NodePath p_player_path) {
|
||||||
ERR_FAIL_COND(p_instance.is_null());
|
ERR_FAIL_COND(p_instance.is_null());
|
||||||
|
|
|
@ -191,7 +191,11 @@ void LimboAIEditor::_new_bt() {
|
||||||
void LimboAIEditor::_save_bt(String p_path) {
|
void LimboAIEditor::_save_bt(String p_path) {
|
||||||
ERR_FAIL_COND_MSG(p_path.is_empty(), "Empty p_path");
|
ERR_FAIL_COND_MSG(p_path.is_empty(), "Empty p_path");
|
||||||
ERR_FAIL_COND_MSG(task_tree->get_bt().is_null(), "Behavior Tree is null.");
|
ERR_FAIL_COND_MSG(task_tree->get_bt().is_null(), "Behavior Tree is null.");
|
||||||
|
#ifdef LIMBOAI_MODULE
|
||||||
|
task_tree->get_bt()->set_path(p_path, true);
|
||||||
|
#else // LIMBOAI_GDEXTENSION
|
||||||
task_tree->get_bt()->take_over_path(p_path);
|
task_tree->get_bt()->take_over_path(p_path);
|
||||||
|
#endif // LIMBOAI_MODULE
|
||||||
RESOURCE_SAVE(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH);
|
RESOURCE_SAVE(task_tree->get_bt(), p_path, ResourceSaver::FLAG_CHANGE_PATH);
|
||||||
_update_header();
|
_update_header();
|
||||||
_mark_as_dirty(false);
|
_mark_as_dirty(false);
|
||||||
|
@ -760,7 +764,7 @@ void LimboAIEditor::_on_resources_reload(const PackedStringArray &p_resources) {
|
||||||
disk_changed_files.insert(res_path);
|
disk_changed_files.insert(res_path);
|
||||||
} else {
|
} else {
|
||||||
Ref<BehaviorTree> reloaded = RESOURCE_LOAD_NO_CACHE(res_path, "BehaviorTree");
|
Ref<BehaviorTree> reloaded = RESOURCE_LOAD_NO_CACHE(res_path, "BehaviorTree");
|
||||||
res->copy_from(reloaded);
|
res->copy_other(reloaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,7 +853,7 @@ void LimboAIEditor::_reload_modified() {
|
||||||
Ref<BehaviorTree> res = RESOURCE_LOAD(res_path, "BehaviorTree");
|
Ref<BehaviorTree> res = RESOURCE_LOAD(res_path, "BehaviorTree");
|
||||||
if (res.is_valid()) {
|
if (res.is_valid()) {
|
||||||
Ref<BehaviorTree> reloaded = RESOURCE_LOAD_NO_CACHE(res_path, "BehaviorTree");
|
Ref<BehaviorTree> reloaded = RESOURCE_LOAD_NO_CACHE(res_path, "BehaviorTree");
|
||||||
res->copy_from(reloaded);
|
res->copy_other(reloaded);
|
||||||
if (idx_history >= 0 && history.get(idx_history) == res) {
|
if (idx_history >= 0 && history.get(idx_history) == res) {
|
||||||
edit_bt(res, true);
|
edit_bt(res, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef MODE_SWITCH_BUTTON
|
#ifndef MODE_SWITCH_BUTTON
|
||||||
#define MODE_SWITCH_BUTTON
|
#define MODE_SWITCH_BUTTON
|
||||||
|
|
||||||
|
#include "../util/limbo_compat.h"
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
|
|
||||||
|
@ -28,8 +30,6 @@
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
#define SET_BUTTON_ICON(m_tex) set_button_icon(m_tex)
|
|
||||||
|
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
class ModeSwitchButton : public Button {
|
class ModeSwitchButton : public Button {
|
||||||
|
@ -47,7 +47,7 @@ private:
|
||||||
|
|
||||||
_FORCE_INLINE_ void _set_mode_by_index(int p_index) {
|
_FORCE_INLINE_ void _set_mode_by_index(int p_index) {
|
||||||
current_mode_index = p_index;
|
current_mode_index = p_index;
|
||||||
SET_BUTTON_ICON(modes[current_mode_index].icon);
|
BUTTON_SET_ICON(this, modes[current_mode_index].icon);
|
||||||
if (!modes[current_mode_index].tooltip.is_empty()) {
|
if (!modes[current_mode_index].tooltip.is_empty()) {
|
||||||
set_tooltip_text(modes[current_mode_index].tooltip);
|
set_tooltip_text(modes[current_mode_index].tooltip);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "../util/limbo_task_db.h"
|
#include "../util/limbo_task_db.h"
|
||||||
#include "../util/limbo_utility.h"
|
#include "../util/limbo_utility.h"
|
||||||
|
|
||||||
#ifdef LIMBO_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/error/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "editor/editor_help.h"
|
#include "editor/editor_help.h"
|
||||||
|
@ -29,7 +29,6 @@
|
||||||
#endif // LIMBO_MODULE
|
#endif // LIMBO_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
#include "godot_cpp/core/error_macros.hpp"
|
|
||||||
#include <godot_cpp/classes/button_group.hpp>
|
#include <godot_cpp/classes/button_group.hpp>
|
||||||
#include <godot_cpp/classes/check_box.hpp>
|
#include <godot_cpp/classes/check_box.hpp>
|
||||||
#include <godot_cpp/classes/config_file.hpp>
|
#include <godot_cpp/classes/config_file.hpp>
|
||||||
|
@ -48,6 +47,7 @@
|
||||||
#include <godot_cpp/classes/script_editor.hpp>
|
#include <godot_cpp/classes/script_editor.hpp>
|
||||||
#include <godot_cpp/classes/script_editor_base.hpp>
|
#include <godot_cpp/classes/script_editor_base.hpp>
|
||||||
#include <godot_cpp/classes/style_box.hpp>
|
#include <godot_cpp/classes/style_box.hpp>
|
||||||
|
#include <godot_cpp/core/error_macros.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
|
|
@ -30,13 +30,22 @@
|
||||||
|
|
||||||
// * This is a port of a WindowWrapper from the Godot Engine to use with godot-cpp.
|
// * This is a port of a WindowWrapper from the Godot Engine to use with godot-cpp.
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
|
||||||
|
|
||||||
#ifndef COMPAT_WINDOW_WRAPPER_H
|
#ifndef COMPAT_WINDOW_WRAPPER_H
|
||||||
#define COMPAT_WINDOW_WRAPPER_H
|
#define COMPAT_WINDOW_WRAPPER_H
|
||||||
|
|
||||||
|
#ifdef LIMBOAI_MODULE
|
||||||
|
#include "editor/window_wrapper.h"
|
||||||
|
|
||||||
|
#define CompatWindowWrapper WindowWrapper
|
||||||
|
#define CompatShortcutBin ShortcutBin
|
||||||
|
#define CompatScreenSelect ScreenSelect
|
||||||
|
|
||||||
|
#endif // ! LIMBOAI_MODULE
|
||||||
|
|
||||||
// TODO: Need to compile this as module too!!!
|
// TODO: Need to compile this as module too!!!
|
||||||
|
|
||||||
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
#include <godot_cpp/classes/h_box_container.hpp>
|
#include <godot_cpp/classes/h_box_container.hpp>
|
||||||
#include <godot_cpp/classes/input_event.hpp>
|
#include <godot_cpp/classes/input_event.hpp>
|
||||||
#include <godot_cpp/classes/label.hpp>
|
#include <godot_cpp/classes/label.hpp>
|
||||||
|
@ -133,6 +142,6 @@ public:
|
||||||
CompatScreenSelect();
|
CompatScreenSelect();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ! COMPAT_WINDOW_WRAPPER_H
|
|
||||||
|
|
||||||
#endif // ! LIMBOAI_GDEXTENSION
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
|
#endif // ! COMPAT_WINDOW_WRAPPER_H
|
||||||
|
|
|
@ -279,5 +279,5 @@ GDExtensionBool GDE_EXPORT limboai_init(GDExtensionInterfaceGetProcAddress p_get
|
||||||
|
|
||||||
return init_obj.init();
|
return init_obj.init();
|
||||||
}
|
}
|
||||||
#endif // ! LIMBOAI_GDEXTENSION
|
|
||||||
}
|
}
|
||||||
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
|
|
|
@ -13,13 +13,11 @@
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
|
|
||||||
void EDIT_SCRIPT(const String &p_path) {
|
#include "core/io/resource.h"
|
||||||
Ref<Resource> res = ScriptEditor::get_singleton()->open_file(p_path);
|
#include "editor/editor_node.h"
|
||||||
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
EditorNode::get_singleton()->edit_resource(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // ! LIMBOAI_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
|
@ -51,10 +49,6 @@ String TTR(const String &p_text, const String &p_context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDIT_SCRIPT(const String &p_path) {
|
void EDIT_SCRIPT(const String &p_path) {
|
||||||
Ref<Script> res = RESOURCE_LOAD(p_path, "Script");
|
|
||||||
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
|
|
||||||
EditorInterface::get_singleton()->edit_script(res);
|
|
||||||
EditorInterface::get_singleton()->set_main_screen_editor("Script");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs, bool p_basic, bool p_internal) {
|
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs, bool p_basic, bool p_internal) {
|
||||||
|
@ -88,9 +82,13 @@ Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
|
// **** Shared
|
||||||
|
|
||||||
void SHOW_DOC(const String &p_topic) {
|
void SHOW_DOC(const String &p_topic) {
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
ScriptEditor::get_singleton()->goto_help(m_doc);
|
ScriptEditor::get_singleton()->goto_help(p_topic);
|
||||||
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
||||||
#else // LIMBOAI_GDEXTENSION
|
#else // LIMBOAI_GDEXTENSION
|
||||||
TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors();
|
TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors();
|
||||||
|
@ -98,7 +96,20 @@ void SHOW_DOC(const String &p_topic) {
|
||||||
ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(open_editors.front());
|
ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(open_editors.front());
|
||||||
ERR_FAIL_NULL(seb);
|
ERR_FAIL_NULL(seb);
|
||||||
seb->emit_signal("go_to_help", p_topic);
|
seb->emit_signal("go_to_help", p_topic);
|
||||||
#endif // ! LIMBOAI_MODULE
|
#endif // ! LIMBOAI_GDEXTENSION
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ! LIMBOAI_GDEXTENSION
|
void EDIT_SCRIPT(const String &p_path) {
|
||||||
|
#ifdef LIMBOAI_MODULE
|
||||||
|
Ref<Resource> res = ScriptEditor::get_singleton()->open_file(p_path);
|
||||||
|
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
|
||||||
|
EditorNode::get_singleton()->edit_resource(res);
|
||||||
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
|
Ref<Script> res = RESOURCE_LOAD(p_path, "Script");
|
||||||
|
ERR_FAIL_COND_MSG(res.is_null(), "Failed to load script: " + p_path);
|
||||||
|
EditorInterface::get_singleton()->edit_script(res);
|
||||||
|
EditorInterface::get_singleton()->set_main_screen_editor("Script");
|
||||||
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
|
|
||||||
|
#include "core/object/ref_counted.h"
|
||||||
#include "core/string/print_string.h"
|
#include "core/string/print_string.h"
|
||||||
|
|
||||||
// * API abstractions: Module edition
|
// * API abstractions: Module edition
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
|
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
|
||||||
#define EDITOR_SETTINGS() (EditorSettings::get_singleton())
|
#define EDITOR_SETTINGS() (EditorSettings::get_singleton())
|
||||||
#define BASE_CONTROL() (EditorNode::get_singleton()->get_gui_base())
|
#define BASE_CONTROL() (EditorNode::get_singleton()->get_gui_base())
|
||||||
#define MAIN_SCREEN_CONTROL(EditorNode::get_singleton()->get_main_screen_control())
|
#define MAIN_SCREEN_CONTROL() (EditorNode::get_singleton()->get_main_screen_control())
|
||||||
#define SCENE_TREE() (SceneTree::get_singleton())
|
#define SCENE_TREE() (SceneTree::get_singleton())
|
||||||
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
|
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
|
||||||
#define FS_DOCK_SELECT_FILE(m_path) FileSystemDock::get_singleton()->select_file(m_path)
|
#define FS_DOCK_SELECT_FILE(m_path) FileSystemDock::get_singleton()->select_file(m_path)
|
||||||
|
@ -36,11 +37,11 @@
|
||||||
#define IS_CLASS(m_obj, m_class) (m_obj->is_class_ptr(m_class::get_class_ptr_static()))
|
#define IS_CLASS(m_obj, m_class) (m_obj->is_class_ptr(m_class::get_class_ptr_static()))
|
||||||
#define RAND_RANGE(m_from, m_to) (Math::random(m_from, m_to))
|
#define RAND_RANGE(m_from, m_to) (Math::random(m_from, m_to))
|
||||||
#define RANDF() (Math::randf())
|
#define RANDF() (Math::randf())
|
||||||
#define VCALL(m_method) (GDVIRTUAL_CALL(method))
|
#define VCALL(m_name, ...) (GDVIRTUAL_CALL(m_name, __VA_ARGS__))
|
||||||
#define VCALL_ARGS(method, ...) (call(LW_NAME(method), __VA_ARGS__))
|
#define VCALL_ARGS(method, ...) (call(LW_NAME(method), __VA_ARGS__))
|
||||||
#define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_icon(m_icon)
|
#define BUTTON_SET_ICON(m_btn, m_icon) m_btn->set_icon(m_icon)
|
||||||
#define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::load(m_path, m_hint)
|
#define RESOURCE_LOAD(m_path, m_hint) ResourceLoader::load(m_path, m_hint)
|
||||||
#define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::load(m_path, m_hint, ResourceLoader::CACHE_MODE_IGNORE)
|
#define RESOURCE_LOAD_NO_CACHE(m_path, m_hint) ResourceLoader::load(m_path, m_hint, ResourceFormatLoader::CACHE_MODE_IGNORE)
|
||||||
#define RESOURCE_SAVE(m_res, m_path, m_flags) ResourceSaver::save(m_res, m_path, m_flags)
|
#define RESOURCE_SAVE(m_res, m_path, m_flags) ResourceSaver::save(m_res, m_path, m_flags)
|
||||||
#define RESOURCE_IS_CACHED(m_path) (ResourceCache::has(m_path))
|
#define RESOURCE_IS_CACHED(m_path) (ResourceCache::has(m_path))
|
||||||
#define RESOURCE_GET_TYPE(m_path) (ResourceLoader::get_resource_type(m_path))
|
#define RESOURCE_GET_TYPE(m_path) (ResourceLoader::get_resource_type(m_path))
|
||||||
|
@ -51,13 +52,14 @@
|
||||||
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorNode::get_singleton()->select_editor_by_name(m_name))
|
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorNode::get_singleton()->select_editor_by_name(m_name))
|
||||||
#define FILE_EXISTS(m_path) FileAccess::exists(m_path)
|
#define FILE_EXISTS(m_path) FileAccess::exists(m_path)
|
||||||
#define DIR_ACCESS_CREATE() DirAccess::create(DirAccess::ACCESS_RESOURCES)
|
#define DIR_ACCESS_CREATE() DirAccess::create(DirAccess::ACCESS_RESOURCES)
|
||||||
|
#define PERFORMANCE_ADD_CUSTOM_MONITOR(m_id, m_callable) (Performance::get_singleton()->add_custom_monitor(m_id, m_callable, Variant()))
|
||||||
|
|
||||||
#define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) r_ret = Variant::evaluate(m_op, m_lvalue, m_rvalue)
|
#define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) r_ret = Variant::evaluate(m_op, m_lvalue, m_rvalue)
|
||||||
|
|
||||||
// * Enum
|
// * Enum
|
||||||
|
|
||||||
#define LW_KEY(key) (Key::key)
|
#define LW_KEY(key) (Key::key)
|
||||||
#define LW_KEY_MASK(mask) (KeyModifierMask::##mask)
|
#define LW_KEY_MASK(mask) (KeyModifierMask::mask)
|
||||||
#define LW_MBTN(key) (MouseButton::key)
|
#define LW_MBTN(key) (MouseButton::key)
|
||||||
|
|
||||||
#endif // ! LIMBOAI_MODULE
|
#endif // ! LIMBOAI_MODULE
|
||||||
|
@ -98,11 +100,11 @@ using namespace godot;
|
||||||
#define RESOURCE_EXISTS(m_path, m_type_hint) (ResourceLoader::get_singleton()->exists(m_path, m_type_hint))
|
#define RESOURCE_EXISTS(m_path, m_type_hint) (ResourceLoader::get_singleton()->exists(m_path, m_type_hint))
|
||||||
#define GET_PROJECT_SETTINGS_DIR() EditorInterface::get_singleton()->get_editor_paths()->get_project_settings_dir()
|
#define GET_PROJECT_SETTINGS_DIR() EditorInterface::get_singleton()->get_editor_paths()->get_project_settings_dir()
|
||||||
#define EDIT_RESOURCE(m_res) EditorInterface::get_singleton()->edit_resource(m_res)
|
#define EDIT_RESOURCE(m_res) EditorInterface::get_singleton()->edit_resource(m_res)
|
||||||
void EDIT_SCRIPT(const String &p_path); // TODO: need a module version!
|
|
||||||
#define INSPECTOR_GET_EDITED_OBJECT() (EditorInterface::get_singleton()->get_inspector()->get_edited_object())
|
#define INSPECTOR_GET_EDITED_OBJECT() (EditorInterface::get_singleton()->get_inspector()->get_edited_object())
|
||||||
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorInterface::get_singleton()->set_main_screen_editor(m_name))
|
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorInterface::get_singleton()->set_main_screen_editor(m_name))
|
||||||
#define FILE_EXISTS(m_path) FileAccess::file_exists(m_path)
|
#define FILE_EXISTS(m_path) FileAccess::file_exists(m_path)
|
||||||
#define DIR_ACCESS_CREATE() DirAccess::open("res://")
|
#define DIR_ACCESS_CREATE() DirAccess::open("res://")
|
||||||
|
#define PERFORMANCE_ADD_CUSTOM_MONITOR(m_id, m_callable) (Performance::get_singleton()->add_custom_monitor(m_id, m_callable))
|
||||||
|
|
||||||
#define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) \
|
#define VARIANT_EVALUATE(m_op, m_lvalue, m_rvalue, r_ret) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -151,5 +153,6 @@ inline void VARIANT_DELETE_IF_OBJECT(Variant m_variant) {
|
||||||
#define IS_RESOURCE_FILE(m_path) (m_path.begins_with("res://") && m_path.find("::") == -1)
|
#define IS_RESOURCE_FILE(m_path) (m_path.begins_with("res://") && m_path.find("::") == -1)
|
||||||
|
|
||||||
void SHOW_DOC(const String &p_topic);
|
void SHOW_DOC(const String &p_topic);
|
||||||
|
void EDIT_SCRIPT(const String &p_path);
|
||||||
|
|
||||||
#endif // LIMBO_COMPAT_H
|
#endif // LIMBO_COMPAT_H
|
||||||
|
|
Loading…
Reference in New Issue