diff options
Diffstat (limited to 'editor/editor_settings.cpp')
-rw-r--r-- | editor/editor_settings.cpp | 84 |
1 files changed, 67 insertions, 17 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index d199b27b83..a5001cb1ac 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* http:/www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -75,20 +75,33 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool return true; } + bool changed = false; + if (p_value.get_type() == Variant::NIL) { - props.erase(p_name); + if (props.has(p_name)) { + props.erase(p_name); + changed = true; + } } else { - if (props.has(p_name)) - props[p_name].variant = p_value; - else + if (props.has(p_name)) { + if (p_value != props[p_name].variant) { + props[p_name].variant = p_value; + changed = true; + } + } else { props[p_name] = VariantContainer(p_value, last_order++); + changed = true; + } if (save_changed_setting) { - props[p_name].save = true; + if (props[p_name].save != true) { + props[p_name].save = true; + changed = true; + } } } - if (p_emit_signal) { + if (changed && p_emit_signal) { emit_signal("settings_changed"); } return true; @@ -258,13 +271,13 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/hidpi_mode", 0); hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/show_script_in_scene_tabs", false); + _initial_set("interface/scene_tabs/show_script_button", false); _initial_set("interface/editor/font_size", 14); hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/source_font_size", 14); hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/custom_font", ""); - hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); _initial_set("interface/editor/dim_amount", 0.6f); hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); @@ -307,10 +320,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["filesystem/directories/default_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_path", PROPERTY_HINT_GLOBAL_DIR); _initial_set("filesystem/directories/default_project_export_path", ""); hints["filesystem/directories/default_project_export_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_export_path", PROPERTY_HINT_GLOBAL_DIR); - _initial_set("interface/editor/show_script_in_scene_tabs", false); + _initial_set("interface/scene_tabs/show_script_button", false); _initial_set("text_editor/theme/color_theme", "Adaptive"); - hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default"); + hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default,Custom"); _initial_set("text_editor/theme/line_spacing", 4); @@ -351,6 +364,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/cursor/caret_blink", true); _initial_set("text_editor/cursor/caret_blink_speed", 0.65); hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1"); + _initial_set("text_editor/cursor/right_click_moves_caret", true); _initial_set("text_editor/theme/font", ""); hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res"); @@ -1140,13 +1154,13 @@ void EditorSettings::load_favorites() { } void EditorSettings::list_text_editor_themes() { - String themes = "Adaptive,Default"; + String themes = "Adaptive,Default,Custom"; DirAccess *d = DirAccess::open(get_text_editor_themes_dir()); if (d) { d->list_dir_begin(); String file = d->get_next(); while (file != String()) { - if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive") { + if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive" && file.get_basename().to_lower() != "custom") { themes += "," + file.get_basename(); } file = d->get_next(); @@ -1158,7 +1172,7 @@ void EditorSettings::list_text_editor_themes() { } void EditorSettings::load_text_editor_theme() { - if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive") { + if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") { _load_default_text_editor_theme(); // sorry for "Settings changed" console spam return; } @@ -1215,7 +1229,7 @@ bool EditorSettings::save_text_editor_theme() { String p_file = get("text_editor/theme/color_theme"); - if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive") { + if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive" || p_file.get_file().to_lower() == "custom") { return false; } String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet"); @@ -1227,7 +1241,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { p_file += ".tet"; } - if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet") { + if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet" || p_file.get_file().to_lower() == "custom.tet") { return false; } if (_save_text_editor_theme(p_file)) { @@ -1315,8 +1329,44 @@ Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) { return sc; } +struct ShortCutMapping { + const char *path; + uint32_t keycode; +}; + Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) { +#ifdef OSX_ENABLED + static const ShortCutMapping macos_mappings[] = { + { "editor/play", KEY_MASK_CMD | KEY_B }, + { "editor/play_scene", KEY_MASK_CMD | KEY_R }, + { "editor/pause_scene", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_Y }, + { "editor/stop", KEY_MASK_CMD | KEY_PERIOD }, + { "editor/play_custom_scene", KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_R }, + { "editor/editor_2d", KEY_MASK_ALT | KEY_1 }, + { "editor/editor_3d", KEY_MASK_ALT | KEY_2 }, + { "editor/editor_script", KEY_MASK_ALT | KEY_3 }, + { "editor/editor_help", KEY_MASK_ALT | KEY_SPACE }, + { "editor/fullscreen_mode", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F }, + { "editor/distraction_free_mode", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_D }, + { "script_text_editor/contextual_help", KEY_MASK_ALT | KEY_MASK_SHIFT | KEY_SPACE }, + { "script_text_editor/find_next", KEY_MASK_CMD | KEY_G }, + { "script_text_editor/find_previous", KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_G }, + { "script_text_editor/toggle_breakpoint", KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B } + }; + + if (p_keycode == KEY_DELETE) { + p_keycode = KEY_MASK_CMD | KEY_BACKSPACE; + } else { + for (int i = 0; i < sizeof(macos_mappings) / sizeof(ShortCutMapping); i++) { + if (p_path == macos_mappings[i].path) { + p_keycode = macos_mappings[i].keycode; + break; + } + } + } +#endif + Ref<InputEventKey> ie; if (p_keycode) { ie.instance(); |