2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_settings.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2018-01-01 13:40:08 +00:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00: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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef EDITOR_SETTINGS_H
|
|
|
|
#define EDITOR_SETTINGS_H
|
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
|
2016-02-21 23:15:47 +00:00
|
|
|
#include "core/io/config_file.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "os/thread_safe.h"
|
|
|
|
#include "resource.h"
|
2017-08-27 19:07:15 +00:00
|
|
|
#include "scene/gui/shortcut.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "translation.h"
|
2016-06-05 00:31:29 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class EditorPlugin;
|
|
|
|
|
|
|
|
class EditorSettings : public Resource {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(EditorSettings, Resource);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
private:
|
|
|
|
_THREAD_SAFE_CLASS_
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct Plugin {
|
|
|
|
|
|
|
|
EditorPlugin *instance;
|
|
|
|
String path;
|
|
|
|
String name;
|
|
|
|
String author;
|
|
|
|
String version;
|
|
|
|
String description;
|
|
|
|
bool installs;
|
|
|
|
String script;
|
|
|
|
Vector<String> install_files;
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
private:
|
2014-02-10 01:10:30 +00:00
|
|
|
struct VariantContainer {
|
|
|
|
int order;
|
|
|
|
Variant variant;
|
2017-09-25 03:26:41 +00:00
|
|
|
Variant initial;
|
2017-11-20 17:34:13 +00:00
|
|
|
bool has_default_value;
|
2014-02-10 01:10:30 +00:00
|
|
|
bool hide_from_editor;
|
2016-06-12 00:16:14 +00:00
|
|
|
bool save;
|
2017-03-05 15:44:50 +00:00
|
|
|
VariantContainer() {
|
2017-11-30 03:11:53 +00:00
|
|
|
variant = Variant();
|
|
|
|
initial = Variant();
|
2017-03-05 15:44:50 +00:00
|
|
|
order = 0;
|
|
|
|
hide_from_editor = false;
|
2017-11-20 17:34:13 +00:00
|
|
|
has_default_value = false;
|
2017-03-05 15:44:50 +00:00
|
|
|
save = false;
|
|
|
|
}
|
|
|
|
VariantContainer(const Variant &p_variant, int p_order) {
|
|
|
|
variant = p_variant;
|
2017-11-30 03:11:53 +00:00
|
|
|
initial = Variant();
|
2017-03-05 15:44:50 +00:00
|
|
|
order = p_order;
|
|
|
|
hide_from_editor = false;
|
2017-11-30 03:11:53 +00:00
|
|
|
has_default_value = false;
|
|
|
|
save = false;
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
static Ref<EditorSettings> singleton;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
HashMap<String, PropertyInfo> hints;
|
|
|
|
HashMap<String, VariantContainer> props;
|
2017-10-28 13:40:55 +00:00
|
|
|
int last_order;
|
2017-09-25 03:26:41 +00:00
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
Ref<Resource> clipboard;
|
|
|
|
Map<String, Ref<ShortCut> > shortcuts;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
String resource_path;
|
Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html
(latest as of this commit).
Three virtual methods are added to OS for the various XDG paths we will use:
- OS::get_data_path gives XDG_DATA_HOME, or if missing:
~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_config_path gives XDG_CONFIG_HOME, or if missing:
~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_cache_path gives XDG_CACHE_HOME, or if missing:
~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows
So for Windows there are no changes, for Linux we follow the full split spec
and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot.
Support for system-wide installation of templates on Unix was removed for now,
as it's a bit hackish and I don't think anyone uses it.
user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by
default, but when using the application/config/use_shared_user_dir option
it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame.
For now everything still goes in EditorSettings::get_settings_dir(), but
this will be changed in a later commit to make use of the new splitting
where relevant.
Part of #3513.
2017-11-17 16:11:41 +00:00
|
|
|
String settings_dir;
|
|
|
|
String data_dir;
|
|
|
|
String cache_dir;
|
2014-02-10 01:10:30 +00:00
|
|
|
String config_file_path;
|
Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html
(latest as of this commit).
Three virtual methods are added to OS for the various XDG paths we will use:
- OS::get_data_path gives XDG_DATA_HOME, or if missing:
~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_config_path gives XDG_CONFIG_HOME, or if missing:
~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_cache_path gives XDG_CACHE_HOME, or if missing:
~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows
So for Windows there are no changes, for Linux we follow the full split spec
and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot.
Support for system-wide installation of templates on Unix was removed for now,
as it's a bit hackish and I don't think anyone uses it.
user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by
default, but when using the application/config/use_shared_user_dir option
it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame.
For now everything still goes in EditorSettings::get_settings_dir(), but
this will be changed in a later commit to make use of the new splitting
where relevant.
Part of #3513.
2017-11-17 16:11:41 +00:00
|
|
|
String project_config_dir;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
Vector<String> favorite_dirs;
|
|
|
|
Vector<String> recent_dirs;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-06-12 00:16:14 +00:00
|
|
|
bool save_changed_setting;
|
2016-07-03 22:13:45 +00:00
|
|
|
bool optimize_save; //do not save stuff that came from config but was not set from engine
|
2016-06-12 00:16:14 +00:00
|
|
|
|
2018-01-06 11:40:43 +00:00
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _set_only(const StringName &p_name, const Variant &p_value);
|
2017-10-28 13:40:55 +00:00
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _initial_set(const StringName &p_name, const Variant &p_value);
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
|
|
|
void _add_property_info_bind(const Dictionary &p_info);
|
|
|
|
|
2016-02-21 23:15:47 +00:00
|
|
|
void _load_defaults(Ref<ConfigFile> p_extra_config = NULL);
|
2016-04-12 14:45:31 +00:00
|
|
|
void _load_default_text_editor_theme();
|
|
|
|
bool _save_text_editor_theme(String p_file);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
enum {
|
2017-03-05 15:44:50 +00:00
|
|
|
NOTIFICATION_EDITOR_SETTINGS_CHANGED = 10000
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static EditorSettings *get_singleton();
|
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
static void create();
|
2016-05-27 22:58:28 +00:00
|
|
|
void setup_language();
|
2015-08-06 05:37:40 +00:00
|
|
|
void setup_network();
|
2014-02-10 01:10:30 +00:00
|
|
|
static void save();
|
|
|
|
static void destroy();
|
2017-10-28 13:40:55 +00:00
|
|
|
void set_optimize_save(bool p_optimize);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-28 21:25:28 +00:00
|
|
|
bool has_default_value(const String &p_setting) const;
|
2017-10-28 13:40:55 +00:00
|
|
|
void set_setting(const String &p_setting, const Variant &p_value);
|
|
|
|
Variant get_setting(const String &p_setting) const;
|
2017-10-31 14:24:35 +00:00
|
|
|
bool has_setting(const String &p_setting) const;
|
|
|
|
void erase(const String &p_setting);
|
|
|
|
void raise_order(const String &p_setting);
|
2018-02-01 08:57:10 +00:00
|
|
|
void set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current = false);
|
2017-10-31 14:24:35 +00:00
|
|
|
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
|
2018-01-06 11:40:43 +00:00
|
|
|
if (p_emit_signal)
|
|
|
|
_set(p_setting, p_value);
|
|
|
|
else
|
|
|
|
_set_only(p_setting, p_value);
|
2017-10-28 13:40:55 +00:00
|
|
|
}
|
2017-10-31 14:24:35 +00:00
|
|
|
bool property_can_revert(const String &p_setting);
|
|
|
|
Variant property_get_revert(const String &p_setting);
|
2017-10-28 13:40:55 +00:00
|
|
|
void add_property_hint(const PropertyInfo &p_hint);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; }
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Resource> get_resource_clipboard() const { return clipboard; }
|
|
|
|
|
Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html
(latest as of this commit).
Three virtual methods are added to OS for the various XDG paths we will use:
- OS::get_data_path gives XDG_DATA_HOME, or if missing:
~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_config_path gives XDG_CONFIG_HOME, or if missing:
~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_cache_path gives XDG_CACHE_HOME, or if missing:
~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows
So for Windows there are no changes, for Linux we follow the full split spec
and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot.
Support for system-wide installation of templates on Unix was removed for now,
as it's a bit hackish and I don't think anyone uses it.
user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by
default, but when using the application/config/use_shared_user_dir option
it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame.
For now everything still goes in EditorSettings::get_settings_dir(), but
this will be changed in a later commit to make use of the new splitting
where relevant.
Part of #3513.
2017-11-17 16:11:41 +00:00
|
|
|
String get_data_dir() const;
|
|
|
|
String get_templates_dir() const;
|
2017-11-17 14:50:18 +00:00
|
|
|
String get_settings_dir() const;
|
|
|
|
String get_project_settings_dir() const;
|
Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html
(latest as of this commit).
Three virtual methods are added to OS for the various XDG paths we will use:
- OS::get_data_path gives XDG_DATA_HOME, or if missing:
~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_config_path gives XDG_CONFIG_HOME, or if missing:
~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows
- OS::get_cache_path gives XDG_CACHE_HOME, or if missing:
~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows
So for Windows there are no changes, for Linux we follow the full split spec
and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot.
Support for system-wide installation of templates on Unix was removed for now,
as it's a bit hackish and I don't think anyone uses it.
user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by
default, but when using the application/config/use_shared_user_dir option
it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame.
For now everything still goes in EditorSettings::get_settings_dir(), but
this will be changed in a later commit to make use of the new splitting
where relevant.
Part of #3513.
2017-11-17 16:11:41 +00:00
|
|
|
String get_text_editor_themes_dir() const;
|
|
|
|
String get_script_templates_dir() const;
|
|
|
|
String get_cache_dir() const;
|
2017-10-28 13:40:55 +00:00
|
|
|
|
|
|
|
void set_project_metadata(const String &p_section, const String &p_key, Variant p_data);
|
2018-05-16 15:23:20 +00:00
|
|
|
Variant get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-12 16:52:50 +00:00
|
|
|
void set_favorite_dirs(const Vector<String> &p_favorites_dirs);
|
2015-06-06 12:44:38 +00:00
|
|
|
Vector<String> get_favorite_dirs() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_recent_dirs(const Vector<String> &p_recent_dirs);
|
2015-06-06 12:44:38 +00:00
|
|
|
Vector<String> get_recent_dirs() const;
|
|
|
|
void load_favorites();
|
|
|
|
|
2016-04-12 14:45:31 +00:00
|
|
|
void list_text_editor_themes();
|
|
|
|
void load_text_editor_theme();
|
|
|
|
bool import_text_editor_theme(String p_file);
|
|
|
|
bool save_text_editor_theme();
|
|
|
|
bool save_text_editor_theme_as(String p_file);
|
|
|
|
|
2017-06-13 20:03:08 +00:00
|
|
|
Vector<String> get_script_templates(const String &p_extension);
|
2017-11-17 20:48:24 +00:00
|
|
|
String get_editor_layouts_config() const;
|
2017-06-13 20:03:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut);
|
2017-05-20 15:38:03 +00:00
|
|
|
bool is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const;
|
2017-03-05 15:44:50 +00:00
|
|
|
Ref<ShortCut> get_shortcut(const String &p_name) const;
|
2016-06-05 00:31:29 +00:00
|
|
|
void get_shortcut_list(List<String> *r_shortcuts);
|
|
|
|
|
2017-10-28 13:40:55 +00:00
|
|
|
void notify_changes();
|
2017-09-25 03:26:41 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
EditorSettings();
|
|
|
|
~EditorSettings();
|
|
|
|
};
|
|
|
|
|
|
|
|
//not a macro any longer
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
#define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val))
|
2017-10-31 14:24:35 +00:00
|
|
|
Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-26 03:40:45 +00:00
|
|
|
#define EDITOR_GET(m_var) _EDITOR_GET(m_var)
|
2017-10-31 14:24:35 +00:00
|
|
|
Variant _EDITOR_GET(const String &p_setting);
|
2017-08-26 03:40:45 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
#define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev))
|
|
|
|
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
|
|
|
|
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path);
|
2016-06-05 00:31:29 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#endif // EDITOR_SETTINGS_H
|