Merge pull request #90952 from Gaktan/add_online_doc_link
Add option to open online doc for selected class in script editor
This commit is contained in:
commit
096fb3ad7c
2 changed files with 41 additions and 3 deletions
|
@ -731,6 +731,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
|
|||
_update_members_overview();
|
||||
_update_help_overview();
|
||||
_update_selected_editor_menu();
|
||||
_update_online_doc();
|
||||
_update_members_overview_visibility();
|
||||
_update_help_overview_visibility();
|
||||
}
|
||||
|
@ -903,6 +904,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
|
|||
_go_to_tab(idx);
|
||||
} else {
|
||||
_update_selected_editor_menu();
|
||||
_update_online_doc();
|
||||
}
|
||||
|
||||
_update_history_arrows();
|
||||
|
@ -1350,7 +1352,21 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||
help_search_dialog->popup_dialog();
|
||||
} break;
|
||||
case SEARCH_WEBSITE: {
|
||||
OS::get_singleton()->shell_open(VERSION_DOCS_URL "/");
|
||||
Control *tab = tab_container->get_current_tab_control();
|
||||
|
||||
EditorHelp *eh = Object::cast_to<EditorHelp>(tab);
|
||||
bool native_class_doc = false;
|
||||
if (eh) {
|
||||
const HashMap<String, DocData::ClassDoc>::ConstIterator E = EditorHelp::get_doc_data()->class_list.find(eh->get_class());
|
||||
native_class_doc = E && !E->value.is_script_doc;
|
||||
}
|
||||
if (native_class_doc) {
|
||||
String name = eh->get_class().to_lower();
|
||||
String doc_url = vformat(VERSION_DOCS_URL "/classes/class_%s.html", name);
|
||||
OS::get_singleton()->shell_open(doc_url);
|
||||
} else {
|
||||
OS::get_singleton()->shell_open(VERSION_DOCS_URL "/");
|
||||
}
|
||||
} break;
|
||||
case WINDOW_NEXT: {
|
||||
_history_forward();
|
||||
|
@ -2029,6 +2045,26 @@ void ScriptEditor::_update_help_overview() {
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::_update_online_doc() {
|
||||
Node *current = tab_container->get_tab_control(tab_container->get_current_tab());
|
||||
|
||||
EditorHelp *eh = Object::cast_to<EditorHelp>(current);
|
||||
bool native_class_doc = false;
|
||||
if (eh) {
|
||||
const HashMap<String, DocData::ClassDoc>::ConstIterator E = EditorHelp::get_doc_data()->class_list.find(eh->get_class());
|
||||
native_class_doc = E && !E->value.is_script_doc;
|
||||
}
|
||||
if (native_class_doc) {
|
||||
String name = eh->get_class();
|
||||
String tooltip = vformat(TTR("Open '%s' in Godot online documentation."), name);
|
||||
site_search->set_text(TTR("Open in Online Docs"));
|
||||
site_search->set_tooltip_text(tooltip);
|
||||
} else {
|
||||
site_search->set_text(TTR("Online Docs"));
|
||||
site_search->set_tooltip_text(TTR("Open Godot online documentation."));
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::_update_script_colors() {
|
||||
bool script_temperature_enabled = EDITOR_GET("text_editor/script_list/script_temperature_enabled");
|
||||
|
||||
|
@ -4147,10 +4183,8 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
|
||||
site_search = memnew(Button);
|
||||
site_search->set_flat(true);
|
||||
site_search->set_text(TTR("Online Docs"));
|
||||
site_search->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditor::_menu_option).bind(SEARCH_WEBSITE));
|
||||
menu_hb->add_child(site_search);
|
||||
site_search->set_tooltip_text(TTR("Open Godot online documentation."));
|
||||
|
||||
help_search = memnew(Button);
|
||||
help_search->set_flat(true);
|
||||
|
@ -4271,6 +4305,8 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
|||
Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter;
|
||||
json_syntax_highlighter.instantiate();
|
||||
register_syntax_highlighter(json_syntax_highlighter);
|
||||
|
||||
_update_online_doc();
|
||||
}
|
||||
|
||||
ScriptEditor::~ScriptEditor() {
|
||||
|
|
|
@ -450,6 +450,8 @@ class ScriptEditor : public PanelContainer {
|
|||
void _update_help_overview();
|
||||
void _help_overview_selected(int p_idx);
|
||||
|
||||
void _update_online_doc();
|
||||
|
||||
void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used);
|
||||
|
||||
void _tree_changed();
|
||||
|
|
Loading…
Reference in a new issue