Skip to content

Commit

Permalink
-Project/Editor settings now use new inspector
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
reduz committed Jul 19, 2018
1 parent 76bfe14 commit c69de2b
Show file tree
Hide file tree
Showing 47 changed files with 1,055 additions and 81 deletions.
2 changes: 1 addition & 1 deletion core/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 9 additions & 1 deletion core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class OS {

CompositeLogger *_logger;

bool restart_on_exit;
List<String> restart_commandline;

protected:
void _set_logger(CompositeLogger *p_logger);

Expand Down Expand Up @@ -182,7 +185,7 @@ class OS {

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;

Expand Down Expand Up @@ -496,6 +499,11 @@ class OS {

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();
};
Expand Down
12 changes: 10 additions & 2 deletions core/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion core/project_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,21 @@ class ProjectSettings : public Object {
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),
persist(p_persist),
variant(p_variant),
hide_from_editor(false),
overridden(false) {
restart_if_changed = false;
}
};

Expand Down Expand Up @@ -120,6 +123,7 @@ class ProjectSettings : public Object {
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);

Expand Down Expand Up @@ -158,8 +162,9 @@ class ProjectSettings : public Object {
};

//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
2 changes: 1 addition & 1 deletion core/register_core_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions drivers/coreaudio/audio_driver_coreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_storage_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions drivers/pulseaudio/audio_driver_pulseaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions drivers/rtaudio/audio_driver_rtaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/wasapi/audio_driver_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/xaudio2/audio_driver_xaudio2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 38 additions & 3 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1659,6 +1666,7 @@ void EditorInspector::_clear() {
editor_property_map.clear();
sections.clear();
pending.clear();
restart_request_props.clear();
}

void EditorInspector::refresh() {
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {

Expand All @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -343,6 +347,12 @@ class EditorInspector : public ScrollContainer {
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();
Expand Down
Loading

0 comments on commit c69de2b

Please sign in to comment.