Editor: Links to "Creating custom tasks" doc page in the editor

This commit is contained in:
Serhii Snitsaruk 2024-01-17 15:51:24 +01:00
parent 27d3ec7555
commit c5be3a725f
6 changed files with 28 additions and 6 deletions

View File

@ -17,11 +17,13 @@
#include "../util/limbo_string_names.h"
#ifdef LIMBOAI_MODULE
#include "editor/editor_scale.h"
#include "scene/gui/button.h"
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/button.hpp>
#include <godot_cpp/classes/editor_interface.hpp>
#endif // LIMBOAI_GDEXTENSION
void ActionBanner::set_text(const String &p_text) {
@ -43,6 +45,12 @@ void ActionBanner::add_action(const String &p_name, const Callable &p_action, bo
hbox->add_child(action_btn);
}
void ActionBanner::add_spacer() {
Control *spacer = memnew(Control);
spacer->set_custom_minimum_size(Vector2(8.0 * EDSCALE, 0.0));
hbox->add_child(spacer);
}
void ActionBanner::_execute_action(const Callable &p_action, bool p_auto_close) {
#ifdef LIMBOAI_MODULE
Callable::CallError ce;

View File

@ -50,6 +50,7 @@ public:
String get_text() const;
void add_action(const String &p_name, const Callable &p_action, bool p_auto_close = false);
void add_spacer();
void close();

View File

@ -594,12 +594,15 @@ void LimboAIEditor::_probability_popup_closed() {
void LimboAIEditor::_misc_option_selected(int p_id) {
switch (p_id) {
case MISC_INTRODUCTION: {
LimboUtility::get_singleton()->open_doc_introduction();
} break;
case MISC_ONLINE_DOCUMENTATION: {
LimboUtility::get_singleton()->open_doc_online();
} break;
case MISC_DOC_INTRODUCTION: {
LimboUtility::get_singleton()->open_doc_introduction();
} break;
case MISC_DOC_CUSTOM_TASKS: {
LimboUtility::get_singleton()->open_doc_custom_tasks();
} break;
case MISC_OPEN_DEBUGGER: {
ERR_FAIL_COND(LimboDebuggerPlugin::get_singleton() == nullptr);
if (LimboDebuggerPlugin::get_singleton()->get_session_tab()->get_window_enabled()) {
@ -951,8 +954,9 @@ void LimboAIEditor::_update_misc_menu() {
misc_menu->clear();
misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Introduction"), MISC_INTRODUCTION);
misc_menu->add_icon_item(theme_cache.doc_icon, TTR("Online Documentation"), MISC_ONLINE_DOCUMENTATION);
misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Introduction"), MISC_DOC_INTRODUCTION);
misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Creating custom tasks in GDScript"), MISC_DOC_CUSTOM_TASKS);
misc_menu->add_separator();
#ifdef LIMBOAI_MODULE
@ -981,6 +985,8 @@ void LimboAIEditor::_update_banners() {
banner->set_text(vformat(TTR("Task folder not found: %s"), task_dir));
banner->add_action(TTR("Create"), callable_mp(this, &LimboAIEditor::_create_user_task_dir), true);
banner->add_action(TTR("Edit Path..."), callable_mp(this, &LimboAIEditor::_edit_project_settings));
banner->add_spacer();
banner->add_action(TTR("Help..."), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_custom_tasks));
banner->set_meta(LW_NAME(managed), Variant(true));
banners->call_deferred(LW_NAME(add_child), banner);
}
@ -1004,7 +1010,7 @@ void LimboAIEditor::_update_banners() {
if (!limitations_banner_shown && GLOBAL_GET("debug/gdscript/warnings/native_method_override") == Variant(2)) {
ActionBanner *banner = memnew(ActionBanner);
banner->set_text(vformat(TTR("In Project Settings, \"debug/gdscript/warnings/native_method_override\" is set to \"Error\"")));
banner->add_action(TTR("Instructions"), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_gdextension_limitations));
banner->add_action(TTR("Instructions..."), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_gdextension_limitations));
banner->add_action(TTR("Dismiss"), callable_mp(banner, &ActionBanner::close));
banners->call_deferred(LW_NAME(add_child), banner);
limitations_banner_shown = true;

View File

@ -85,8 +85,9 @@ private:
};
enum MiscMenu {
MISC_INTRODUCTION,
MISC_ONLINE_DOCUMENTATION,
MISC_DOC_INTRODUCTION,
MISC_DOC_CUSTOM_TASKS,
MISC_OPEN_DEBUGGER,
MISC_PROJECT_SETTINGS,
MISC_CREATE_SCRIPT_TEMPLATE,

View File

@ -348,6 +348,11 @@ void LimboUtility::open_doc_gdextension_limitations() {
LIMBO_DOC_VERSION));
}
void LimboUtility::open_doc_custom_tasks() {
OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/getting-started/custom-tasks.html",
LIMBO_DOC_VERSION));
}
void LimboUtility::open_doc_class(const String &p_class_name) {
if (p_class_name.begins_with("res://")) {
SHOW_DOC(vformat("class_name:\"%s\"", p_class_name));

View File

@ -96,6 +96,7 @@ public:
void open_doc_introduction();
void open_doc_online();
void open_doc_gdextension_limitations();
void open_doc_custom_tasks();
void open_doc_class(const String &p_class_name);
#endif // TOOLS_ENABLED