Merge pull request #67060 from timothyqiu/named-layers
Only show named layers in layer menu
This commit is contained in:
commit
f7c374272f
|
@ -37,6 +37,7 @@
|
|||
#include "editor/editor_resource_preview.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/filesystem_dock.h"
|
||||
#include "editor/project_settings_editor.h"
|
||||
#include "scene/2d/gpu_particles_2d.h"
|
||||
#include "scene/3d/fog_volume.h"
|
||||
#include "scene/3d/gpu_particles_3d.h"
|
||||
|
@ -1252,26 +1253,41 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) {
|
|||
}
|
||||
|
||||
void EditorPropertyLayers::set_layer_name(int p_index, const String &p_name) {
|
||||
if (ProjectSettings::get_singleton()->has_setting(basename + vformat("/layer_%d", p_index + 1))) {
|
||||
ProjectSettings::get_singleton()->set(basename + vformat("/layer_%d", p_index + 1), p_name);
|
||||
const String property_name = basename + vformat("/layer_%d", p_index + 1);
|
||||
if (ProjectSettings::get_singleton()->has_setting(property_name)) {
|
||||
ProjectSettings::get_singleton()->set(property_name, p_name);
|
||||
ProjectSettings::get_singleton()->save();
|
||||
}
|
||||
}
|
||||
|
||||
String EditorPropertyLayers::get_layer_name(int p_index) const {
|
||||
const String property_name = basename + vformat("/layer_%d", p_index + 1);
|
||||
if (ProjectSettings::get_singleton()->has_setting(property_name)) {
|
||||
return ProjectSettings::get_singleton()->get(property_name);
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
void EditorPropertyLayers::_button_pressed() {
|
||||
int layer_count = grid->layer_count;
|
||||
int layer_group_size = grid->layer_group_size;
|
||||
|
||||
layers->clear();
|
||||
for (int i = 0; i < layer_count; i++) {
|
||||
if ((i != 0) && ((i % layer_group_size) == 0)) {
|
||||
layers->add_separator();
|
||||
const String name = get_layer_name(i);
|
||||
if (name.is_empty()) {
|
||||
continue;
|
||||
}
|
||||
layers->add_check_item(grid->names[i], i);
|
||||
layers->add_check_item(name, i);
|
||||
int idx = layers->get_item_index(i);
|
||||
layers->set_item_checked(idx, grid->value & (1 << i));
|
||||
}
|
||||
|
||||
if (layers->get_item_count() == 0) {
|
||||
layers->add_item(TTR("No Named Layers"));
|
||||
layers->set_item_disabled(0, true);
|
||||
}
|
||||
layers->add_separator();
|
||||
layers->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit Layer Names"), grid->layer_count);
|
||||
|
||||
Rect2 gp = button->get_screen_rect();
|
||||
layers->reset_size();
|
||||
Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0);
|
||||
|
@ -1280,14 +1296,19 @@ void EditorPropertyLayers::_button_pressed() {
|
|||
}
|
||||
|
||||
void EditorPropertyLayers::_menu_pressed(int p_menu) {
|
||||
if (grid->value & (1 << p_menu)) {
|
||||
grid->value &= ~(1 << p_menu);
|
||||
if (p_menu == grid->layer_count) {
|
||||
ProjectSettingsEditor::get_singleton()->popup_project_settings();
|
||||
ProjectSettingsEditor::get_singleton()->set_general_page(basename);
|
||||
} else {
|
||||
grid->value |= (1 << p_menu);
|
||||
if (grid->value & (1 << p_menu)) {
|
||||
grid->value &= ~(1 << p_menu);
|
||||
} else {
|
||||
grid->value |= (1 << p_menu);
|
||||
}
|
||||
grid->queue_redraw();
|
||||
layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu));
|
||||
_grid_changed(grid->value);
|
||||
}
|
||||
grid->queue_redraw();
|
||||
layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu));
|
||||
_grid_changed(grid->value);
|
||||
}
|
||||
|
||||
void EditorPropertyLayers::_refresh_names() {
|
||||
|
|
|
@ -357,6 +357,7 @@ protected:
|
|||
public:
|
||||
void setup(LayerType p_layer_type);
|
||||
void set_layer_name(int p_index, const String &p_name);
|
||||
String get_layer_name(int p_index) const;
|
||||
virtual void update_property() override;
|
||||
EditorPropertyLayers();
|
||||
};
|
||||
|
|
|
@ -151,7 +151,9 @@ void SectionedInspector::_section_selected() {
|
|||
|
||||
void SectionedInspector::set_current_section(const String &p_section) {
|
||||
if (section_map.has(p_section)) {
|
||||
section_map[p_section]->select(0);
|
||||
TreeItem *item = section_map[p_section];
|
||||
item->select(0);
|
||||
sections->scroll_to_item(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,11 @@ void ProjectSettingsEditor::set_plugins_page() {
|
|||
tab_container->set_current_tab(tab_container->get_tab_idx_from_control(plugin_settings));
|
||||
}
|
||||
|
||||
void ProjectSettingsEditor::set_general_page(const String &p_category) {
|
||||
tab_container->set_current_tab(tab_container->get_tab_idx_from_control(general_editor));
|
||||
general_settings_inspector->set_current_section(p_category);
|
||||
}
|
||||
|
||||
void ProjectSettingsEditor::update_plugins() {
|
||||
plugin_settings->update_plugins();
|
||||
}
|
||||
|
@ -576,7 +581,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
|||
tab_container->set_theme_type_variation("TabContainerOdd");
|
||||
add_child(tab_container);
|
||||
|
||||
VBoxContainer *general_editor = memnew(VBoxContainer);
|
||||
general_editor = memnew(VBoxContainer);
|
||||
general_editor->set_name(TTR("General"));
|
||||
general_editor->set_alignment(BoxContainer::ALIGNMENT_BEGIN);
|
||||
general_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
|
|
@ -53,6 +53,7 @@ class ProjectSettingsEditor : public AcceptDialog {
|
|||
Timer *timer = nullptr;
|
||||
|
||||
TabContainer *tab_container = nullptr;
|
||||
VBoxContainer *general_editor = nullptr;
|
||||
SectionedInspector *general_settings_inspector = nullptr;
|
||||
ActionMapEditor *action_map_editor = nullptr;
|
||||
LocalizationEditor *localization_editor = nullptr;
|
||||
|
@ -116,6 +117,7 @@ public:
|
|||
static ProjectSettingsEditor *get_singleton() { return singleton; }
|
||||
void popup_project_settings();
|
||||
void set_plugins_page();
|
||||
void set_general_page(const String &p_category);
|
||||
void update_plugins();
|
||||
|
||||
EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
|
||||
|
|
Loading…
Reference in New Issue