-Project/Editor settings now use new inspector

-Project/Editor settings now show tooltips properly
-Settings thar require restart now will show a restart warning
-Video driver is now visible all the time, can be changed easily
-Added function to request current video driver
This commit is contained in:
Juan Linietsky
2018-07-19 18:58:15 -03:00
parent 76bfe14e00
commit c69de2ba46
47 changed files with 1055 additions and 81 deletions
+1 -1
View File
@@ -342,7 +342,7 @@ MessageQueue::MessageQueue() {
buffer_end = 0;
buffer_max_used = 0;
buffer_size = GLOBAL_DEF("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB);
buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB);
buffer_size *= 1024;
buffer = memnew_arr(uint8_t, buffer_size);
}
+12
View File
@@ -659,6 +659,18 @@ const char *OS::get_audio_driver_name(int p_driver) const {
return AudioDriverManager::get_driver(p_driver)->get_name();
}
void OS::set_restart_on_exit(bool p_restart, const List<String> &p_restart_arguments) {
restart_on_exit = p_restart;
restart_commandline = p_restart_arguments;
}
bool OS::is_restart_on_exit_set() const {
return restart_on_exit;
}
List<String> OS::get_restart_on_exit_argumens() const {
return restart_commandline;
}
OS::OS() {
void *volatile stack_bottom;
+9 -1
View File
@@ -74,6 +74,9 @@ class OS {
CompositeLogger *_logger;
bool restart_on_exit;
List<String> restart_commandline;
protected:
void _set_logger(CompositeLogger *p_logger);
@@ -182,7 +185,7 @@ public:
virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) const;
virtual int get_current_video_driver() const = 0;
virtual int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const;
@@ -496,6 +499,11 @@ public:
bool is_layered_allowed() const { return _allow_layered; }
bool is_hidpi_allowed() const { return _allow_hidpi; }
void set_restart_on_exit(bool p_restart, const List<String> &p_restart_arguments);
bool is_restart_on_exit_set() const;
List<String> get_restart_on_exit_argumens() const;
OS();
virtual ~OS();
};
+10 -2
View File
@@ -105,6 +105,11 @@ void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_v
ERR_FAIL_COND(!props.has(p_name));
props[p_name].initial = p_value;
}
void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
ERR_FAIL_COND(!props.has(p_name));
props[p_name].restart_if_changed = p_restart;
}
String ProjectSettings::globalize_path(const String &p_path) const {
@@ -225,6 +230,9 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
else
vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
if (v->restart_if_changed) {
vc.flags |= PROPERTY_USAGE_RESTART_IF_CHANGED;
}
vclist.insert(vc);
}
@@ -817,7 +825,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
return OK;
}
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) {
Variant ret;
if (!ProjectSettings::get_singleton()->has_setting(p_var)) {
@@ -827,6 +835,7 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
ProjectSettings::get_singleton()->set_builtin_order(p_var);
ProjectSettings::get_singleton()->set_restart_if_changed(p_var, p_restart_if_changed);
return ret;
}
@@ -1080,7 +1089,6 @@ ProjectSettings::ProjectSettings() {
custom_prop_info["rendering/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics/2d/thread_model"] = PropertyInfo(Variant::INT, "physics/2d/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["rendering/quality/intended_usage/framebuffer_allocation"] = PropertyInfo(Variant::INT, "rendering/quality/intended_usage/framebuffer_allocation", PROPERTY_HINT_ENUM, "2D,2D Without Sampling,3D,3D Without Effects");
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2);
GLOBAL_DEF("debug/settings/profiler/max_functions", 16384);
+6 -1
View File
@@ -59,11 +59,13 @@ protected:
Variant initial;
bool hide_from_editor;
bool overridden;
bool restart_if_changed;
VariantContainer() :
order(0),
persist(false),
hide_from_editor(false),
overridden(false) {
restart_if_changed = false;
}
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) :
order(p_order),
@@ -71,6 +73,7 @@ protected:
variant(p_variant),
hide_from_editor(false),
overridden(false) {
restart_if_changed = false;
}
};
@@ -120,6 +123,7 @@ public:
String globalize_path(const String &p_path) const;
void set_initial_value(const String &p_name, const Variant &p_value);
void set_restart_if_changed(const String &p_name, bool p_restart);
bool property_can_revert(const String &p_name);
Variant property_get_revert(const String &p_name);
@@ -158,8 +162,9 @@ public:
};
//not a macro any longer
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default);
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
#define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true)
#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)
#endif
+1 -1
View File
@@ -191,7 +191,7 @@ void register_core_types() {
void register_core_settings() {
//since in register core types, globals may not e present
GLOBAL_DEF("network/limits/packet_peer_stream/max_buffer_po2", (16));
GLOBAL_DEF_RST("network/limits/packet_peer_stream/max_buffer_po2", (16));
}
void register_core_singletons() {
+2 -2
View File
@@ -102,7 +102,7 @@ Error AudioDriverCoreAudio::init() {
break;
}
mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
zeromem(&strdesc, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
@@ -117,7 +117,7 @@ Error AudioDriverCoreAudio::init() {
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc));
ERR_FAIL_COND_V(result != noErr, FAILED);
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
// Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels)
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
+2 -2
View File
@@ -1895,7 +1895,7 @@ void RasterizerCanvasGLES3::initialize() {
}
{
uint32_t poly_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128);
uint32_t poly_size = GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128);
poly_size *= 1024; //kb
poly_size = MAX(poly_size, (2 + 2 + 4) * 4 * sizeof(float));
glGenBuffers(1, &data.polygon_buffer);
@@ -1942,7 +1942,7 @@ void RasterizerCanvasGLES3::initialize() {
glGenVertexArrays(1, &data.polygon_buffer_pointer_array);
uint32_t index_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128);
uint32_t index_size = GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128);
index_size *= 1024; //kb
glGenBuffers(1, &data.polygon_index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
+1 -1
View File
@@ -4866,7 +4866,7 @@ void RasterizerSceneGLES3::initialize() {
glBufferData(GL_UNIFORM_BUFFER, sizeof(State::EnvironmentRadianceUBO), &state.env_radiance_ubo, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
render_list.max_elements = GLOBAL_DEF("rendering/limits/rendering/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS);
render_list.max_elements = GLOBAL_DEF_RST("rendering/limits/rendering/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS);
if (render_list.max_elements > 1000000)
render_list.max_elements = 1000000;
if (render_list.max_elements < 1024)
+1 -1
View File
@@ -7463,7 +7463,7 @@ void RasterizerStorageGLES3::initialize() {
{
//transform feedback buffers
uint32_t xf_feedback_size = GLOBAL_DEF("rendering/limits/buffers/blend_shape_max_buffer_size_kb", 4096);
uint32_t xf_feedback_size = GLOBAL_DEF_RST("rendering/limits/buffers/blend_shape_max_buffer_size_kb", 4096);
for (int i = 0; i < 2; i++) {
glGenBuffers(1, &resources.transform_feedback_buffers[i]);
@@ -155,7 +155,7 @@ Error AudioDriverPulseAudio::init_device() {
break;
}
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
pa_buffer_size = buffer_frames * pa_map.channels;
@@ -204,7 +204,7 @@ Error AudioDriverPulseAudio::init() {
thread_exited = false;
exit_thread = false;
mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
pa_ml = pa_mainloop_new();
ERR_FAIL_COND_V(pa_ml == NULL, ERR_CANT_OPEN);
+2 -2
View File
@@ -88,7 +88,7 @@ Error AudioDriverRtAudio::init() {
// FIXME: Adapt to the OutputFormat -> SpeakerMode change
/*
String channels = GLOBAL_DEF("audio/output","stereo");
String channels = GLOBAL_DEF_RST("audio/output","stereo");
if (channels=="5.1")
output_format=OUTPUT_5_1;
@@ -108,7 +108,7 @@ Error AudioDriverRtAudio::init() {
options.numberOfBuffers = 4;
parameters.firstChannel = 0;
mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
unsigned int buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
+1 -1
View File
@@ -318,7 +318,7 @@ Error AudioDriverWASAPI::finish_device() {
Error AudioDriverWASAPI::init() {
mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
Error err = init_device();
if (err != OK) {
+1 -1
View File
@@ -50,7 +50,7 @@ Error AudioDriverXAudio2::init() {
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
int latency = GLOBAL_DEF_RST("audio/output_latency", 25);
buffer_size = closest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
+38 -3
View File
@@ -1507,12 +1507,19 @@ void EditorInspector::update_tree() {
checked = p.usage & PROPERTY_USAGE_CHECKED;
}
if (p.usage & PROPERTY_USAGE_RESTART_IF_CHANGED) {
restart_request_props.insert(p.name);
}
String doc_hint;
if (use_doc_hints) {
StringName classname = object->get_class_name();
StringName propname = p.name;
if (object_class != String()) {
classname = object_class;
}
StringName propname = property_prefix + p.name;
String descr;
bool found = false;
@@ -1580,9 +1587,9 @@ void EditorInspector::update_tree() {
ep->connect("resource_selected", this, "_resource_selected", varray(), CONNECT_DEFERRED);
ep->connect("object_id_selected", this, "_object_id_selected", varray(), CONNECT_DEFERRED);
if (doc_hint != String()) {
ep->set_tooltip(TTR("Property: ") + p.name + "\n\n" + doc_hint);
ep->set_tooltip(TTR("Property: ") + property_prefix + p.name + "\n\n" + doc_hint);
} else {
ep->set_tooltip(TTR("Property: ") + p.name);
ep->set_tooltip(TTR("Property: ") + property_prefix + p.name);
}
ep->set_draw_red(draw_red);
ep->set_use_folding(use_folding);
@@ -1659,6 +1666,7 @@ void EditorInspector::_clear() {
editor_property_map.clear();
sections.clear();
pending.clear();
restart_request_props.clear();
}
void EditorInspector::refresh() {
@@ -1902,6 +1910,10 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
if (changing)
this->changing--;
if (restart_request_props.has(p_path)) {
emit_signal("restart_requested");
}
}
void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) {
@@ -1921,6 +1933,9 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array
undo_redo->create_action(TTR("Set Multiple:") + " " + names, UndoRedo::MERGE_ENDS);
for (int i = 0; i < p_paths.size(); i++) {
_edit_set(p_paths[i], p_values[i], false, "");
if (restart_request_props.has(p_paths[i])) {
emit_signal("restart_requested");
}
}
changing++;
undo_redo->commit_action();
@@ -1993,6 +2008,8 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable)
E->get()->deselect();
}
}
emit_signal("property_selected", p_path);
}
void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) {
@@ -2090,6 +2107,21 @@ void EditorInspector::_vscroll_changed(double p_offset) {
scroll_cache[object->get_instance_id()] = p_offset;
}
}
void EditorInspector::set_property_prefix(const String &p_prefix) {
property_prefix = p_prefix;
}
String EditorInspector::get_property_prefix() const {
return property_prefix;
}
void EditorInspector::set_object_class(const String &p_class) {
object_class = p_class;
}
String EditorInspector::get_object_class() const {
return object_class;
}
void EditorInspector::_bind_methods() {
@@ -2110,9 +2142,12 @@ void EditorInspector::_bind_methods() {
ClassDB::bind_method("refresh", &EditorInspector::refresh);
ADD_SIGNAL(MethodInfo("property_selected", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("restart_requested"));
}
EditorInspector::EditorInspector() {
+10
View File
@@ -267,9 +267,13 @@ class EditorInspector : public ScrollContainer {
Map<StringName, Map<StringName, String> > descr_cache;
Map<StringName, String> class_descr_cache;
Set<StringName> restart_request_props;
Map<ObjectID, int> scroll_cache;
String property_prefix; //used for sectioned inspector
String object_class;
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
void _property_changed(const String &p_path, const Variant &p_value, bool changing = false);
@@ -343,6 +347,12 @@ public:
void set_scroll_offset(int p_offset);
int get_scroll_offset() const;
void set_property_prefix(const String &p_prefix);
String get_property_prefix() const;
void set_object_class(const String &p_class);
String get_object_class() const;
void set_use_sub_inspector_bg(bool p_enable);
EditorInspector();
+89 -8
View File
@@ -1068,6 +1068,32 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
}
void EditorNode::save_all_scenes_and_restart() {
_menu_option_confirm(RUN_STOP, true);
exiting = true;
_save_all_scenes();
String to_reopen;
if (get_tree()->get_edited_scene_root()) {
to_reopen = get_tree()->get_edited_scene_root()->get_filename();
}
get_tree()->quit();
String exec = OS::get_singleton()->get_executable_path();
List<String> args;
args.push_back("--path");
args.push_back(ProjectSettings::get_singleton()->get_resource_path());
args.push_back("-e");
if (to_reopen != String()) {
args.push_back(to_reopen);
}
OS::get_singleton()->set_restart_on_exit(true, args);
}
void EditorNode::_save_all_scenes() {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
@@ -2204,6 +2230,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
about->popup_centered_minsize(Size2(780, 500) * EDSCALE);
} break;
case SET_VIDEO_DRIVER_SAVE_AND_RESTART: {
ProjectSettings::get_singleton()->set("rendering/quality/driver/driver_name", video_driver_request);
ProjectSettings::get_singleton()->save();
save_all_scenes_and_restart();
} break;
default: {
if (p_option >= IMPORT_PLUGIN_BASE) {
}
@@ -4390,6 +4423,21 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
}
}
void EditorNode::_video_driver_selected(int p_which) {
String driver = video_driver->get_item_metadata(p_which);
String current = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
if (driver == current) {
return;
}
video_driver_request = driver;
video_restart_dialog->popup_centered_minsize();
video_driver->select(video_driver_current);
}
void EditorNode::_bind_methods() {
ClassDB::bind_method("_menu_option", &EditorNode::_menu_option);
@@ -4460,6 +4508,8 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported);
ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled);
ClassDB::bind_method(D_METHOD("_video_driver_selected"), &EditorNode::_video_driver_selected);
ADD_SIGNAL(MethodInfo("play_pressed"));
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
@@ -4656,19 +4706,19 @@ EditorNode::EditorNode() {
ClassDB::set_class_enabled("RootMotionView", true);
//defs here, use EDITOR_GET in logic
EDITOR_DEF("interface/scene_tabs/always_show_close_button", false);
EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true);
EDITOR_DEF("interface/scene_tabs/minimum_width", 50);
EDITOR_DEF_RST("interface/scene_tabs/always_show_close_button", false);
EDITOR_DEF_RST("interface/scene_tabs/resize_if_many_tabs", true);
EDITOR_DEF_RST("interface/scene_tabs/minimum_width", 50);
EDITOR_DEF("run/output/always_clear_output_on_play", true);
EDITOR_DEF("run/output/always_open_output_on_play", true);
EDITOR_DEF("run/output/always_close_output_on_stop", true);
EDITOR_DEF("run/auto_save/save_before_running", true);
EDITOR_DEF("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF("interface/editor/quit_confirmation", true);
EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false);
EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true);
EDITOR_DEF("interface/inspector/capitalize_properties", true);
EDITOR_DEF("interface/inspector/disable_folding", false);
EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", false);
EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true);
EDITOR_DEF_RST("interface/inspector/capitalize_properties", true);
EDITOR_DEF_RST("interface/inspector/disable_folding", false);
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
EDITOR_DEF("interface/inspector/resources_types_to_open_in_new_inspector", "SpatialMaterial");
EDITOR_DEF("run/auto_save/save_before_running", true);
@@ -5191,6 +5241,37 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
#endif
video_driver = memnew(OptionButton);
video_driver->set_flat(true);
video_driver->set_focus_mode(Control::FOCUS_NONE);
video_driver->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string;
String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
menu_hb->add_child(video_driver);
video_driver_current = 0;
for (int i = 0; i < video_drivers.get_slice_count(","); i++) {
String driver = video_drivers.get_slice(",", i);
if (gui_base->has_icon(driver, "EditorIcons")) {
video_driver->add_icon_item(gui_base->get_icon(driver, "EditorIcons"), "");
} else {
video_driver->add_item(driver);
}
video_driver->set_item_metadata(i, driver);
if (current_video_driver == driver) {
video_driver->select(i);
video_driver_current = i;
}
}
video_driver->connect("item_selected", this, "_video_driver_selected");
video_restart_dialog = memnew(ConfirmationDialog);
video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor."));
video_restart_dialog->get_ok()->set_text(TTR("Save & Restart"));
video_restart_dialog->connect("confirmed", this, "_menu_option", varray(SET_VIDEO_DRIVER_SAVE_AND_RESTART));
add_child(video_restart_dialog);
progress_hb = memnew(BackgroundProgress);
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
+11
View File
@@ -182,6 +182,8 @@ private:
HELP_COMMUNITY,
HELP_ABOUT,
SET_VIDEO_DRIVER_SAVE_AND_RESTART,
IMPORT_PLUGIN_BASE = 100,
TOOL_MENU_BASE = 1000
@@ -194,6 +196,13 @@ private:
Control *gui_base;
VBoxContainer *main_vbox;
PanelContainer *play_button_panel;
OptionButton *video_driver;
ConfirmationDialog *video_restart_dialog;
int video_driver_current;
String video_driver_request;
void _video_driver_selected(int);
//split
@@ -745,6 +754,8 @@ public:
void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
void remove_tool_menu_item(const String &p_name);
void save_all_scenes_and_restart();
void dim_editor(bool p_dimming);
void edit_current() { _edit_current(); };
+306
View File
@@ -0,0 +1,306 @@
#include "editor_sectioned_inspector.h"
#include "editor_scale.h"
class SectionedInspectorFilter : public Object {
GDCLASS(SectionedInspectorFilter, Object);
Object *edited;
String section;
bool allow_sub;
bool _set(const StringName &p_name, const Variant &p_value) {
if (!edited)
return false;
String name = p_name;
if (section != "") {
name = section + "/" + name;
}
bool valid;
edited->set(name, p_value, &valid);
return valid;
}
bool _get(const StringName &p_name, Variant &r_ret) const {
if (!edited)
return false;
String name = p_name;
if (section != "") {
name = section + "/" + name;
}
bool valid = false;
r_ret = edited->get(name, &valid);
return valid;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
if (!edited)
return;
List<PropertyInfo> pinfo;
edited->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
int sp = pi.name.find("/");
if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff
continue;
if (sp == -1) {
pi.name = "global/" + pi.name;
}
if (pi.name.begins_with(section + "/")) {
pi.name = pi.name.replace_first(section + "/", "");
if (!allow_sub && pi.name.find("/") != -1)
continue;
p_list->push_back(pi);
}
}
}
bool property_can_revert(const String &p_name) {
return edited->call("property_can_revert", section + "/" + p_name);
}
Variant property_get_revert(const String &p_name) {
return edited->call("property_get_revert", section + "/" + p_name);
}
protected:
static void _bind_methods() {
ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert);
ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert);
}
public:
void set_section(const String &p_section, bool p_allow_sub) {
section = p_section;
allow_sub = p_allow_sub;
_change_notify();
}
void set_edited(Object *p_edited) {
edited = p_edited;
_change_notify();
}
SectionedInspectorFilter() {
edited = NULL;
}
};
void SectionedInspector::_bind_methods() {
ClassDB::bind_method("_section_selected", &SectionedInspector::_section_selected);
ClassDB::bind_method("_search_changed", &SectionedInspector::_search_changed);
ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list);
}
void SectionedInspector::_section_selected() {
if (!sections->get_selected())
return;
filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL);
inspector->set_property_prefix(String(sections->get_selected()->get_metadata(0)) + "/");
}
void SectionedInspector::set_current_section(const String &p_section) {
if (section_map.has(p_section)) {
section_map[p_section]->select(0);
}
}
String SectionedInspector::get_current_section() const {
if (sections->get_selected())
return sections->get_selected()->get_metadata(0);
else
return "";
}
String SectionedInspector::get_full_item_path(const String &p_item) {
String base = get_current_section();
if (base != "")
return base + "/" + p_item;
else
return p_item;
}
void SectionedInspector::edit(Object *p_object) {
if (!p_object) {
obj = -1;
sections->clear();
filter->set_edited(NULL);
inspector->edit(NULL);
return;
}
ObjectID id = p_object->get_instance_id();
inspector->set_object_class(p_object->get_class());
if (obj != id) {
obj = id;
update_category_list();
filter->set_edited(p_object);
inspector->edit(filter);
if (sections->get_root()->get_children()) {
sections->get_root()->get_children()->select(0);
}
} else {
update_category_list();
}
}
void SectionedInspector::update_category_list() {
String selected_category = get_current_section();
sections->clear();
Object *o = ObjectDB::get_instance(obj);
if (!o)
return;
List<PropertyInfo> pinfo;
o->get_property_list(&pinfo);
section_map.clear();
TreeItem *root = sections->create_item();
section_map[""] = root;
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
if (pi.usage & PROPERTY_USAGE_CATEGORY)
continue;
else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
continue;
if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene")
continue;
if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1)
continue;
int sp = pi.name.find("/");
if (sp == -1)
pi.name = "Global/" + pi.name;
Vector<String> sectionarr = pi.name.split("/");
String metasection;
int sc = MIN(2, sectionarr.size() - 1);
for (int i = 0; i < sc; i++) {
TreeItem *parent = section_map[metasection];
parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
if (i > 0) {
metasection += "/" + sectionarr[i];
} else {
metasection = sectionarr[i];
}
if (!section_map.has(metasection)) {
TreeItem *ms = sections->create_item(parent);
section_map[metasection] = ms;
ms->set_text(0, sectionarr[i].capitalize());
ms->set_metadata(0, metasection);
ms->set_selectable(0, false);
}
if (i == sc - 1) {
//if it has children, make selectable
section_map[metasection]->set_selectable(0, true);
}
}
}
if (section_map.has(selected_category)) {
section_map[selected_category]->select(0);
}
inspector->update_tree();
}
void SectionedInspector::register_search_box(LineEdit *p_box) {
search_box = p_box;
inspector->register_text_enter(p_box);
search_box->connect("text_changed", this, "_search_changed");
}
void SectionedInspector::_search_changed(const String &p_what) {
update_category_list();
}
EditorInspector *SectionedInspector::get_inspector() {
return inspector;
}
SectionedInspector::SectionedInspector() {
obj = -1;
search_box = NULL;
add_constant_override("autohide", 1); // Fixes the dragger always showing up
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE);
add_child(left_vb);
sections = memnew(Tree);
sections->set_v_size_flags(SIZE_EXPAND_FILL);
sections->set_hide_root(true);
left_vb->add_child(sections, true);
VBoxContainer *right_vb = memnew(VBoxContainer);
right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
right_vb->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(right_vb);
filter = memnew(SectionedInspectorFilter);
inspector = memnew(EditorInspector);
inspector->set_v_size_flags(SIZE_EXPAND_FILL);
right_vb->add_child(inspector, true);
inspector->set_use_doc_hints(true);
sections->connect("cell_selected", this, "_section_selected");
}
SectionedInspector::~SectionedInspector() {
memdelete(filter);
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef EDITOR_SECTIONED_INSPECTOR_H
#define EDITOR_SECTIONED_INSPECTOR_H
#include "editor/editor_inspector.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tree.h"
class SectionedInspectorFilter;
class SectionedInspector : public HSplitContainer {
GDCLASS(SectionedInspector, HSplitContainer);
ObjectID obj;
Tree *sections;
SectionedInspectorFilter *filter;
Map<String, TreeItem *> section_map;
EditorInspector *inspector;
LineEdit *search_box;
static void _bind_methods();
void _section_selected();
void _search_changed(const String &p_what);
public:
void register_search_box(LineEdit *p_box);
EditorInspector *get_inspector();
void edit(Object *p_object);
String get_full_item_path(const String &p_item);
void set_current_section(const String &p_section);
String get_current_section() const;
void update_category_list();
SectionedInspector();
~SectionedInspector();
};
#endif // EDITOR_SECTIONED_INSPECTOR_H

Some files were not shown because too many files have changed in this diff Show More