You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Support custom features in project settings dialog
This commit is contained in:
@@ -42,8 +42,6 @@
|
|||||||
#include "scene/gui/check_button.h"
|
#include "scene/gui/check_button.h"
|
||||||
#include "servers/movie_writer/movie_writer.h"
|
#include "servers/movie_writer/movie_writer.h"
|
||||||
|
|
||||||
ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr;
|
|
||||||
|
|
||||||
void ProjectSettingsEditor::connect_filesystem_dock_signals(FileSystemDock *p_fs_dock) {
|
void ProjectSettingsEditor::connect_filesystem_dock_signals(FileSystemDock *p_fs_dock) {
|
||||||
localization_editor->connect_filesystem_dock_signals(p_fs_dock);
|
localization_editor->connect_filesystem_dock_signals(p_fs_dock);
|
||||||
group_settings->connect_filesystem_dock_signals(p_fs_dock);
|
group_settings->connect_filesystem_dock_signals(p_fs_dock);
|
||||||
@@ -179,35 +177,45 @@ void ProjectSettingsEditor::_property_box_changed(const String &p_text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::_feature_selected(int p_index) {
|
void ProjectSettingsEditor::_feature_selected(int p_index) {
|
||||||
Vector<String> t = property_box->get_text().strip_edges().split(".", true, 1);
|
const String property = property_box->get_text().strip_edges().get_slicec('.', 0);
|
||||||
const String feature = p_index ? "." + feature_box->get_item_text(p_index) : "";
|
if (p_index == FEATURE_ALL) {
|
||||||
property_box->set_text(t[0] + feature);
|
property_box->set_text(property);
|
||||||
|
} else if (p_index == FEATURE_CUSTOM) {
|
||||||
|
property_box->set_text(property + ".custom");
|
||||||
|
const int len = property.length() + 1;
|
||||||
|
property_box->select(len);
|
||||||
|
property_box->set_caret_column(len);
|
||||||
|
property_box->grab_focus();
|
||||||
|
} else {
|
||||||
|
property_box->set_text(property + "." + feature_box->get_item_text(p_index));
|
||||||
|
};
|
||||||
_update_property_box();
|
_update_property_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::_update_property_box() {
|
void ProjectSettingsEditor::_update_property_box() {
|
||||||
const String setting = _get_setting_name();
|
const String setting = _get_setting_name();
|
||||||
const Vector<String> t = setting.split(".", true, 1);
|
int slices = setting.get_slice_count(".");
|
||||||
const String &name = t[0];
|
const String name = setting.get_slicec('.', 0);
|
||||||
const String feature = (t.size() == 2) ? t[1] : "";
|
const String feature = setting.get_slicec('.', 1);
|
||||||
bool feature_invalid = (t.size() == 2) && (t[1].is_empty());
|
bool feature_invalid = slices > 2 || (slices == 2 && feature.is_empty());
|
||||||
|
|
||||||
add_button->set_disabled(true);
|
add_button->set_disabled(true);
|
||||||
del_button->set_disabled(true);
|
del_button->set_disabled(true);
|
||||||
|
|
||||||
if (!feature.is_empty()) {
|
if (feature.is_empty() || feature_invalid) {
|
||||||
feature_invalid = true;
|
feature_box->select(FEATURE_ALL);
|
||||||
for (int i = 1; i < feature_box->get_item_count(); i++) {
|
} else {
|
||||||
|
bool is_custom = true;
|
||||||
|
for (int i = FEATURE_FIRST; i < feature_box->get_item_count(); i++) {
|
||||||
if (feature == feature_box->get_item_text(i)) {
|
if (feature == feature_box->get_item_text(i)) {
|
||||||
feature_invalid = false;
|
is_custom = false;
|
||||||
feature_box->select(i);
|
feature_box->select(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (is_custom) {
|
||||||
|
feature_box->select(FEATURE_CUSTOM);
|
||||||
if (feature.is_empty() || feature_invalid) {
|
}
|
||||||
feature_box->select(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_box->get_text().is_empty()) {
|
if (property_box->get_text().is_empty()) {
|
||||||
@@ -330,8 +338,11 @@ void ProjectSettingsEditor::_add_feature_overrides() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
feature_box->clear();
|
feature_box->clear();
|
||||||
feature_box->add_item(TTR("(All)"), 0); // So it is always on top.
|
feature_box->add_item(TTR("(All)"), FEATURE_ALL); // So it is always on top.
|
||||||
int id = 1;
|
feature_box->add_item(TTR("Custom"), FEATURE_CUSTOM);
|
||||||
|
feature_box->add_separator();
|
||||||
|
|
||||||
|
int id = FEATURE_FIRST;
|
||||||
for (const String &E : presets) {
|
for (const String &E : presets) {
|
||||||
feature_box->add_item(E, id++);
|
feature_box->add_item(E, id++);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,14 @@ class FileSystemDock;
|
|||||||
class ProjectSettingsEditor : public AcceptDialog {
|
class ProjectSettingsEditor : public AcceptDialog {
|
||||||
GDCLASS(ProjectSettingsEditor, AcceptDialog);
|
GDCLASS(ProjectSettingsEditor, AcceptDialog);
|
||||||
|
|
||||||
static ProjectSettingsEditor *singleton;
|
inline static ProjectSettingsEditor *singleton = nullptr;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FEATURE_ALL,
|
||||||
|
FEATURE_CUSTOM,
|
||||||
|
FEATURE_FIRST,
|
||||||
|
};
|
||||||
|
|
||||||
ProjectSettings *ps = nullptr;
|
ProjectSettings *ps = nullptr;
|
||||||
Timer *timer = nullptr;
|
Timer *timer = nullptr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user