Fixes to filter popup and task palette
This commit is contained in:
parent
a601d44517
commit
8341396640
|
@ -496,7 +496,7 @@ void LimboAIEditor::_on_tree_task_double_clicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimboAIEditor::_on_visibility_changed() {
|
void LimboAIEditor::_on_visibility_changed() {
|
||||||
if (task_tree->is_visible()) {
|
if (task_tree->is_visible_in_tree()) {
|
||||||
Ref<BTTask> sel = task_tree->get_selected();
|
Ref<BTTask> sel = task_tree->get_selected();
|
||||||
if (sel.is_valid()) {
|
if (sel.is_valid()) {
|
||||||
EditorNode::get_singleton()->edit_resource(sel);
|
EditorNode::get_singleton()->edit_resource(sel);
|
||||||
|
|
|
@ -199,19 +199,6 @@ void TaskPalette::_apply_filter(const String &p_text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPalette::_show_filter_popup() {
|
|
||||||
_update_filter_popup();
|
|
||||||
|
|
||||||
category_list->reset_size();
|
|
||||||
category_scroll->set_custom_minimum_size(category_list->get_size() + Size2(8, 8));
|
|
||||||
|
|
||||||
Rect2i rect = tool_filters->get_screen_rect();
|
|
||||||
rect.position.y += rect.size.height;
|
|
||||||
rect.size.height = 0;
|
|
||||||
filter_popup->reset_size();
|
|
||||||
filter_popup->popup(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskPalette::_update_filter_popup() {
|
void TaskPalette::_update_filter_popup() {
|
||||||
switch (filter_settings.type_filter) {
|
switch (filter_settings.type_filter) {
|
||||||
case FilterSettings::TypeFilter::TYPE_ALL: {
|
case FilterSettings::TypeFilter::TYPE_ALL: {
|
||||||
|
@ -237,12 +224,15 @@ void TaskPalette::_update_filter_popup() {
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < category_list->get_child_count(); i++) {
|
while (category_list->get_child_count() > 0) {
|
||||||
category_list->get_child(i)->queue_free();
|
Node *item = category_list->get_child(0);
|
||||||
|
category_list->remove_child(item);
|
||||||
|
item->queue_free();
|
||||||
}
|
}
|
||||||
for (String &cat : LimboTaskDB::get_categories()) {
|
for (String &cat : LimboTaskDB::get_categories()) {
|
||||||
CheckBox *category_item = memnew(CheckBox);
|
CheckBox *category_item = memnew(CheckBox);
|
||||||
category_item->set_text(cat);
|
category_item->set_text(cat);
|
||||||
|
category_item->set_focus_mode(FocusMode::FOCUS_NONE);
|
||||||
category_item->set_pressed_no_signal(LOGICAL_XOR(
|
category_item->set_pressed_no_signal(LOGICAL_XOR(
|
||||||
filter_settings.excluded_categories.has(cat),
|
filter_settings.excluded_categories.has(cat),
|
||||||
filter_settings.category_filter == FilterSettings::CategoryFilter::CATEGORY_INCLUDE));
|
filter_settings.category_filter == FilterSettings::CategoryFilter::CATEGORY_INCLUDE));
|
||||||
|
@ -250,9 +240,25 @@ void TaskPalette::_update_filter_popup() {
|
||||||
category_list->add_child(category_item);
|
category_list->add_child(category_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
category_list->reset_size();
|
||||||
|
Size2 size = category_list->get_size() + Size2(8, 8);
|
||||||
|
size.width = MIN(size.width, 400 * EDSCALE);
|
||||||
|
size.height = MIN(size.height, 600 * EDSCALE);
|
||||||
|
category_scroll->set_custom_minimum_size(size);
|
||||||
|
|
||||||
category_choice->set_visible(filter_settings.category_filter != FilterSettings::CATEGORY_ALL);
|
category_choice->set_visible(filter_settings.category_filter != FilterSettings::CATEGORY_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskPalette::_show_filter_popup() {
|
||||||
|
_update_filter_popup();
|
||||||
|
|
||||||
|
Rect2i rect = tool_filters->get_screen_rect();
|
||||||
|
rect.position.y += rect.size.height;
|
||||||
|
rect.size.height = 0;
|
||||||
|
filter_popup->reset_size();
|
||||||
|
filter_popup->popup(rect);
|
||||||
|
}
|
||||||
|
|
||||||
void TaskPalette::_category_filter_changed() {
|
void TaskPalette::_category_filter_changed() {
|
||||||
if (category_all->is_pressed()) {
|
if (category_all->is_pressed()) {
|
||||||
filter_settings.category_filter = FilterSettings::CategoryFilter::CATEGORY_ALL;
|
filter_settings.category_filter = FilterSettings::CategoryFilter::CATEGORY_ALL;
|
||||||
|
@ -305,7 +311,7 @@ void TaskPalette::_filter_data_changed() {
|
||||||
call_deferred(SNAME("refresh"));
|
call_deferred(SNAME("refresh"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskPalette::_draw_category_choice_background() {
|
void TaskPalette::_draw_filter_popup_background() {
|
||||||
category_choice_background->draw(category_choice->get_canvas_item(), Rect2(Point2(), category_choice->get_size()));
|
category_choice_background->draw(category_choice->get_canvas_item(), Rect2(Point2(), category_choice->get_size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +577,7 @@ TaskPalette::TaskPalette() {
|
||||||
category_filter->add_child(category_exclude);
|
category_filter->add_child(category_exclude);
|
||||||
|
|
||||||
category_choice = memnew(VBoxContainer);
|
category_choice = memnew(VBoxContainer);
|
||||||
category_choice->connect("draw", callable_mp(this, &TaskPalette::_draw_category_choice_background));
|
category_choice->connect("draw", callable_mp(this, &TaskPalette::_draw_filter_popup_background));
|
||||||
vbox->add_child(category_choice);
|
vbox->add_child(category_choice);
|
||||||
|
|
||||||
HBoxContainer *selection_controls = memnew(HBoxContainer);
|
HBoxContainer *selection_controls = memnew(HBoxContainer);
|
||||||
|
|
|
@ -109,14 +109,14 @@ private:
|
||||||
void _on_task_button_pressed(const String &p_task);
|
void _on_task_button_pressed(const String &p_task);
|
||||||
void _on_task_button_rmb(const String &p_task);
|
void _on_task_button_rmb(const String &p_task);
|
||||||
void _apply_filter(const String &p_text);
|
void _apply_filter(const String &p_text);
|
||||||
void _show_filter_popup();
|
|
||||||
void _update_filter_popup();
|
void _update_filter_popup();
|
||||||
|
void _show_filter_popup();
|
||||||
void _type_filter_changed();
|
void _type_filter_changed();
|
||||||
void _category_filter_changed();
|
void _category_filter_changed();
|
||||||
void _set_all_filter_categories(bool p_selected);
|
void _set_all_filter_categories(bool p_selected);
|
||||||
void _category_item_toggled(bool p_pressed, const String &p_category);
|
void _category_item_toggled(bool p_pressed, const String &p_category);
|
||||||
void _filter_data_changed();
|
void _filter_data_changed();
|
||||||
void _draw_category_choice_background();
|
void _draw_filter_popup_background();
|
||||||
|
|
||||||
_FORCE_INLINE_ void _set_category_excluded(const String &p_category, bool p_excluded) {
|
_FORCE_INLINE_ void _set_category_excluded(const String &p_category, bool p_excluded) {
|
||||||
if (p_excluded) {
|
if (p_excluded) {
|
||||||
|
|
Loading…
Reference in New Issue