virtualx-engine/core/project_settings.h

162 lines
6.4 KiB
C++
Raw Normal View History

2014-02-10 02:10:30 +01:00
/*************************************************************************/
2017-09-01 16:07:55 +02:00
/* project_settings.h */
2014-02-10 02:10:30 +01:00
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
2014-02-10 02:10:30 +01:00
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
2014-02-10 02:10:30 +01:00
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
2014-02-10 02:10:30 +01:00
#include "core/object.h"
#include "core/os/thread_safe.h"
#include "core/set.h"
class ProjectSettings : public Object {
GDCLASS(ProjectSettings, Object);
2014-02-10 02:10:30 +01:00
_THREAD_SAFE_CLASS_
public:
typedef Map<String, Variant> CustomMap;
2014-02-10 02:10:30 +01:00
enum {
//properties that are not for built in values begin from this value, so builtin ones are displayed first
NO_BUILTIN_ORDER_BASE = 1 << 16
};
protected:
2014-02-10 02:10:30 +01:00
struct VariantContainer {
int order = 0;
bool persist = false;
2014-02-10 02:10:30 +01:00
Variant variant;
Variant initial;
bool hide_from_editor = false;
bool overridden = false;
bool restart_if_changed = false;
VariantContainer() {}
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) :
order(p_order),
persist(p_persist),
variant(p_variant) {
}
2014-02-10 02:10:30 +01:00
};
bool registering_order = true;
int last_order = 0;
int last_builtin_order = NO_BUILTIN_ORDER_BASE;
Map<StringName, VariantContainer> props;
2014-02-10 02:10:30 +01:00
String resource_path;
Map<StringName, PropertyInfo> custom_prop_info;
bool disable_feature_overrides = false;
bool using_datapack = false;
2015-12-14 22:36:53 +01:00
List<String> input_presets;
2014-02-10 02:10:30 +01:00
Set<String> custom_features;
Map<StringName, StringName> feature_overrides;
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
2014-02-10 02:10:30 +01:00
void _get_property_list(List<PropertyInfo> *p_list) const;
2016-03-09 00:00:52 +01:00
static ProjectSettings *singleton;
2016-03-09 00:00:52 +01:00
2019-07-10 11:54:12 +02:00
Error _load_settings_text(const String &p_path);
Error _load_settings_binary(const String &p_path);
Error _load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path);
2014-02-10 02:10:30 +01:00
Error _save_settings_text(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
2014-02-10 02:10:30 +01:00
Error _save_custom_bnd(const String &p_file);
2014-02-10 02:10:30 +01:00
void _convert_to_last_version(int p_from_version);
bool _load_resource_pack(const String &p_pack, bool p_replace_files = true, int p_offset = 0);
2014-02-10 02:10:30 +01:00
void _add_property_info_bind(const Dictionary &p_info);
Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
2014-02-10 02:10:30 +01:00
protected:
static void _bind_methods();
2016-03-09 00:00:52 +01:00
public:
static const int CONFIG_VERSION = 4;
void set_setting(const String &p_setting, const Variant &p_value);
Variant get_setting(const String &p_setting) const;
bool has_setting(String p_var) const;
String localize_path(const String &p_path) const;
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);
2014-02-10 02:10:30 +01:00
String get_resource_path() const;
2016-03-09 00:00:52 +01:00
static ProjectSettings *get_singleton();
2014-02-10 02:10:30 +01:00
void clear(const String &p_name);
int get_order(const String &p_name) const;
void set_order(const String &p_name, int p_order);
void set_builtin_order(const String &p_name);
2016-03-09 00:00:52 +01:00
2017-10-10 14:45:54 +02:00
Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
2014-02-10 02:10:30 +01:00
Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
2014-02-10 02:10:30 +01:00
Error save();
void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
const Map<StringName, PropertyInfo> &get_custom_property_info() const;
2014-02-10 02:10:30 +01:00
Vector<String> get_optimizer_presets() const;
2015-12-14 22:36:53 +01:00
List<String> get_input_presets() const { return input_presets; }
void set_disable_feature_overrides(bool p_disable);
2014-02-10 02:10:30 +01:00
bool is_using_datapack() const;
void set_registering_order(bool p_enable);
bool has_custom_feature(const String &p_feature) const;
ProjectSettings();
~ProjectSettings();
2014-02-10 02:10:30 +01:00
};
//not a macro any longer
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 // PROJECT_SETTINGS_H