mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 05:39:58 +00:00
Merge pull request #113615 from bruvzg/ed_bit_url
[EditorHelpBit] Open online documentation if script editor is not available.
This commit is contained in:
commit
0156b2bcd6
2 changed files with 57 additions and 2 deletions
|
|
@ -4218,9 +4218,63 @@ void EditorHelpBit::_update_labels() {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorHelpBit::_go_to_url(const String &p_what) {
|
||||
Vector<String> parts;
|
||||
{
|
||||
int from = 0;
|
||||
int buffer_start = 0;
|
||||
while (true) {
|
||||
const int pos = p_what.find_char(':', from);
|
||||
if (pos < 0) {
|
||||
parts.push_back(p_what.substr(buffer_start));
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos + 1 < p_what.length() && p_what[pos + 1] == ':') {
|
||||
// `::` used in built-in scripts.
|
||||
from = pos + 2;
|
||||
} else {
|
||||
parts.push_back(p_what.substr(buffer_start, pos - buffer_start));
|
||||
from = pos + 1;
|
||||
buffer_start = from;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const String what = parts[0]; // `parts` is always non-empty.
|
||||
const String clss = (parts.size() > 1) ? parts[1].to_lower() : String();
|
||||
const String name = (parts.size() > 2) ? parts[2].to_lower().replace_chars("/_", '-') : String();
|
||||
|
||||
String section = "";
|
||||
if (what == "class_desc") {
|
||||
section = "#description";
|
||||
} else if (what == "class_signal") {
|
||||
section = vformat("#class-%s-signal-%s", clss, name);
|
||||
} else if (what == "class_method" || what == "class_method_desc") {
|
||||
section = vformat("#class-%s-method-%s", clss, name);
|
||||
} else if (what == "class_property") {
|
||||
section = vformat("#class-%s-property-%s", clss, name);
|
||||
} else if (what == "class_enum") {
|
||||
section = vformat("#enum-%s-%s", clss, name);
|
||||
} else if (what == "class_theme_item") {
|
||||
section = vformat("#class-%s-theme-%s", clss, name);
|
||||
} else if (what == "class_constant") {
|
||||
section = vformat("#class-%s-constant-%s", clss, name);
|
||||
} else if (what == "class_annotation") {
|
||||
section = vformat("#%s", clss);
|
||||
}
|
||||
|
||||
String doc_url = clss.is_empty() ? String(GODOT_VERSION_DOCS_URL "/") : vformat(GODOT_VERSION_DOCS_URL "/classes/class_%s.html%s", clss, section);
|
||||
OS::get_singleton()->shell_open(doc_url);
|
||||
}
|
||||
|
||||
void EditorHelpBit::_go_to_help(const String &p_what) {
|
||||
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
|
||||
ScriptEditor::get_singleton()->goto_help(p_what);
|
||||
if (ScriptEditor::get_singleton()) {
|
||||
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
|
||||
ScriptEditor::get_singleton()->goto_help(p_what);
|
||||
} else {
|
||||
_go_to_url(p_what);
|
||||
}
|
||||
emit_signal(SNAME("request_hide"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ class EditorHelpBit : public VBoxContainer {
|
|||
void _add_type_to_title(const DocType &p_doc_type);
|
||||
void _update_labels();
|
||||
void _go_to_help(const String &p_what);
|
||||
void _go_to_url(const String &p_what);
|
||||
void _meta_clicked(const String &p_select);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue