Add EditorStringNames singleton

This commit is contained in:
kobewi 2023-08-13 02:33:39 +02:00
parent fa3428ff25
commit 6de34fde27
176 changed files with 2549 additions and 2325 deletions

View file

@ -46,6 +46,7 @@
#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
@ -93,9 +94,9 @@ void ScriptEditorDebugger::debug_copy() {
void ScriptEditorDebugger::debug_skip_breakpoints() {
skip_breakpoints_value = !skip_breakpoints_value;
if (skip_breakpoints_value) {
skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOn"), SNAME("EditorIcons")));
skip_breakpoints->set_icon(get_editor_theme_icon(SNAME("DebugSkipBreakpointsOn")));
} else {
skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons")));
skip_breakpoints->set_icon(get_editor_theme_icon(SNAME("DebugSkipBreakpointsOff")));
}
Array msg;
@ -143,11 +144,11 @@ void ScriptEditorDebugger::update_tabs() {
} else {
errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")");
if (error_count >= 1 && warning_count >= 1) {
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("ErrorWarning")));
} else if (error_count >= 1) {
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("Error")));
} else {
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_editor_theme_icon(SNAME("Warning")));
}
}
}
@ -420,8 +421,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
it->set_text(3, String::humanize_size(bytes));
total += bytes;
if (has_theme_icon(type, SNAME("EditorIcons"))) {
it->set_icon(0, get_theme_icon(type, SNAME("EditorIcons")));
if (has_theme_icon(type, EditorStringName(EditorIcons))) {
it->set_icon(0, get_editor_theme_icon(type));
}
}
@ -560,11 +561,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
}
error->set_collapsed(true);
error->set_icon(0, get_theme_icon(oe.warning ? SNAME("Warning") : SNAME("Error"), SNAME("EditorIcons")));
error->set_icon(0, get_editor_theme_icon(oe.warning ? SNAME("Warning") : SNAME("Error")));
error->set_text(0, time);
error->set_text_alignment(0, HORIZONTAL_ALIGNMENT_LEFT);
const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), SNAME("Editor"));
const Color color = get_theme_color(oe.warning ? SNAME("warning_color") : SNAME("error_color"), EditorStringName(Editor));
error->set_custom_color(0, color);
error->set_custom_color(1, color);
@ -821,13 +822,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) {
switch (p_type) {
case MESSAGE_ERROR:
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
break;
case MESSAGE_WARNING:
reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
break;
default:
reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), EditorStringName(Editor)));
}
reason->set_text(p_reason);
@ -853,32 +854,32 @@ void ScriptEditorDebugger::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles)));
skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons")));
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons")));
next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons")));
dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons")));
docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons")));
vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
skip_breakpoints->set_icon(get_editor_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff")));
copy->set_icon(get_editor_theme_icon(SNAME("ActionCopy")));
step->set_icon(get_editor_theme_icon(SNAME("DebugStep")));
next->set_icon(get_editor_theme_icon(SNAME("DebugNext")));
dobreak->set_icon(get_editor_theme_icon(SNAME("Pause")));
docontinue->set_icon(get_editor_theme_icon(SNAME("DebugContinue")));
vmem_refresh->set_icon(get_editor_theme_icon(SNAME("Reload")));
vmem_export->set_icon(get_editor_theme_icon(SNAME("Save")));
search->set_right_icon(get_editor_theme_icon(SNAME("Search")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
TreeItem *error_root = error_tree->get_root();
if (error_root) {
TreeItem *error = error_root->get_first_child();
while (error) {
if (error->has_meta("_is_warning")) {
error->set_icon(0, get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
error->set_custom_color(0, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
error->set_custom_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor")));
error->set_icon(0, get_editor_theme_icon(SNAME("Warning")));
error->set_custom_color(0, get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
error->set_custom_color(1, get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
} else if (error->has_meta("_is_error")) {
error->set_icon(0, get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
error->set_custom_color(0, get_theme_color(SNAME("error_color"), SNAME("Editor")));
error->set_custom_color(1, get_theme_color(SNAME("error_color"), SNAME("Editor")));
error->set_icon(0, get_editor_theme_icon(SNAME("Error")));
error->set_custom_color(0, get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
error->set_custom_color(1, get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
}
error = error->get_next();
@ -1598,11 +1599,11 @@ void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos,
const TreeItem *selected = breakpoints_tree->get_selected();
String file = selected->get_text(0);
if (selected->has_meta("line")) {
breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT);
breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT);
file = selected->get_parent()->get_text(0);
}
breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints in:") + " " + file, ACTION_DELETE_BREAKPOINTS_IN_FILE);
breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS);
breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete All Breakpoints in:") + " " + file, ACTION_DELETE_BREAKPOINTS_IN_FILE);
breakpoints_menu->add_icon_item(get_editor_theme_icon(SNAME("Remove")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS);
breakpoints_menu->set_position(breakpoints_tree->get_global_position() + p_pos);
breakpoints_menu->popup();
@ -1618,8 +1619,8 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos, M
item_menu->reset_size();
if (error_tree->is_anything_selected()) {
item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR);
item_menu->add_icon_item(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE);
item_menu->add_icon_item(get_editor_theme_icon(SNAME("ActionCopy")), TTR("Copy Error"), ACTION_COPY_ERROR);
item_menu->add_icon_item(get_editor_theme_icon(SNAME("ExternalLink")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE);
}
if (item_menu->get_item_count() > 0) {