mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Allow to override editor settings per project
This commit is contained in:
parent
64b09905c7
commit
b41d6ecf8c
22 changed files with 306 additions and 21 deletions
|
|
@ -482,6 +482,18 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
pi.name = base.name;
|
||||
pi.usage = base.flags;
|
||||
p_list->push_back(pi);
|
||||
#ifdef TOOLS_ENABLED
|
||||
} else if (base.name.begins_with(EDITOR_SETTING_OVERRIDE_PREFIX)) {
|
||||
PropertyInfo info(base.type, base.name, PROPERTY_HINT_NONE, "", base.flags);
|
||||
|
||||
const PropertyInfo *pi = editor_settings_info.getptr(base.name.trim_prefix(EDITOR_SETTING_OVERRIDE_PREFIX));
|
||||
if (pi) {
|
||||
info.usage = pi->usage;
|
||||
info.hint = pi->hint;
|
||||
info.hint_string = pi->hint_string;
|
||||
}
|
||||
p_list->push_back(info);
|
||||
#endif
|
||||
} else {
|
||||
p_list->push_back(PropertyInfo(base.type, base.name, PROPERTY_HINT_NONE, "", base.flags));
|
||||
}
|
||||
|
|
@ -1263,7 +1275,7 @@ bool ProjectSettings::is_project_loaded() const {
|
|||
}
|
||||
|
||||
bool ProjectSettings::_property_can_revert(const StringName &p_name) const {
|
||||
return props.has(p_name);
|
||||
return props.has(p_name) && !String(p_name).begins_with(EDITOR_SETTING_OVERRIDE_PREFIX);
|
||||
}
|
||||
|
||||
bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_property) const {
|
||||
|
|
@ -1449,6 +1461,18 @@ void ProjectSettings::get_argument_options(const StringName &p_function, int p_i
|
|||
}
|
||||
#endif
|
||||
|
||||
void ProjectSettings::set_editor_setting_override(const String &p_setting, const Variant &p_value) {
|
||||
set_setting(EDITOR_SETTING_OVERRIDE_PREFIX + p_setting, p_value);
|
||||
}
|
||||
|
||||
bool ProjectSettings::has_editor_setting_override(const String &p_setting) const {
|
||||
return has_setting(EDITOR_SETTING_OVERRIDE_PREFIX + p_setting);
|
||||
}
|
||||
|
||||
Variant ProjectSettings::get_editor_setting_override(const String &p_setting) const {
|
||||
return get_setting(EDITOR_SETTING_OVERRIDE_PREFIX + p_setting);
|
||||
}
|
||||
|
||||
void ProjectSettings::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("has_setting", "name"), &ProjectSettings::has_setting);
|
||||
ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class ProjectSettings : public Object {
|
|||
public:
|
||||
typedef HashMap<String, Variant> CustomMap;
|
||||
static inline const String PROJECT_DATA_DIR_NAME_SUFFIX = "godot";
|
||||
static inline const String EDITOR_SETTING_OVERRIDE_PREFIX = "editor_overrides/";
|
||||
|
||||
// Properties that are not for built in values begin from this value, so builtin ones are displayed first.
|
||||
constexpr static const int32_t NO_BUILTIN_ORDER_BASE = 1 << 16;
|
||||
|
|
@ -153,6 +154,10 @@ protected:
|
|||
public:
|
||||
static const int CONFIG_VERSION = 5;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
HashMap<String, PropertyInfo> editor_settings_info;
|
||||
#endif
|
||||
|
||||
void set_setting(const String &p_setting, const Variant &p_value);
|
||||
Variant get_setting(const String &p_setting, const Variant &p_default_value = Variant()) const;
|
||||
TypedArray<Dictionary> get_global_class_list();
|
||||
|
|
@ -229,6 +234,10 @@ public:
|
|||
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
||||
#endif
|
||||
|
||||
void set_editor_setting_override(const String &p_setting, const Variant &p_value);
|
||||
bool has_editor_setting_override(const String &p_setting) const;
|
||||
Variant get_editor_setting_override(const String &p_setting) const;
|
||||
|
||||
ProjectSettings();
|
||||
ProjectSettings(const String &p_path);
|
||||
~ProjectSettings();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue