editor_settings.cpp 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530
  1. /*************************************************************************/
  2. /* editor_settings.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "editor_settings.h"
  31. #include "core/io/certs_compressed.gen.h"
  32. #include "core/io/compression.h"
  33. #include "core/io/config_file.h"
  34. #include "core/io/file_access_memory.h"
  35. #include "core/io/resource_loader.h"
  36. #include "core/io/resource_saver.h"
  37. #include "core/io/translation_loader_po.h"
  38. #include "core/os/dir_access.h"
  39. #include "core/os/file_access.h"
  40. #include "core/os/keyboard.h"
  41. #include "core/os/os.h"
  42. #include "core/project_settings.h"
  43. #include "core/version.h"
  44. #include "editor/editor_node.h"
  45. #include "editor/translations.gen.h"
  46. #include "scene/main/node.h"
  47. #include "scene/main/scene_tree.h"
  48. #include "scene/main/viewport.h"
  49. // PRIVATE METHODS
  50. Ref<EditorSettings> EditorSettings::singleton = NULL;
  51. // Properties
  52. bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
  53. _THREAD_SAFE_METHOD_
  54. bool changed = _set_only(p_name, p_value);
  55. if (changed) {
  56. emit_signal("settings_changed");
  57. }
  58. return true;
  59. }
  60. bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) {
  61. _THREAD_SAFE_METHOD_
  62. if (p_name.operator String() == "shortcuts") {
  63. Array arr = p_value;
  64. ERR_FAIL_COND_V(arr.size() && arr.size() & 1, true);
  65. for (int i = 0; i < arr.size(); i += 2) {
  66. String name = arr[i];
  67. Ref<InputEvent> shortcut = arr[i + 1];
  68. Ref<ShortCut> sc;
  69. sc.instance();
  70. sc->set_shortcut(shortcut);
  71. add_shortcut(name, sc);
  72. }
  73. return false;
  74. }
  75. bool changed = false;
  76. if (p_value.get_type() == Variant::NIL) {
  77. if (props.has(p_name)) {
  78. props.erase(p_name);
  79. changed = true;
  80. }
  81. } else {
  82. if (props.has(p_name)) {
  83. if (p_value != props[p_name].variant) {
  84. props[p_name].variant = p_value;
  85. changed = true;
  86. }
  87. } else {
  88. props[p_name] = VariantContainer(p_value, last_order++);
  89. changed = true;
  90. }
  91. if (save_changed_setting) {
  92. if (props[p_name].save != true) {
  93. props[p_name].save = true;
  94. changed = true;
  95. }
  96. }
  97. }
  98. return changed;
  99. }
  100. bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
  101. _THREAD_SAFE_METHOD_
  102. if (p_name.operator String() == "shortcuts") {
  103. Array arr;
  104. for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) {
  105. Ref<ShortCut> sc = E->get();
  106. if (optimize_save) {
  107. if (!sc->has_meta("original")) {
  108. continue; //this came from settings but is not any longer used
  109. }
  110. Ref<InputEvent> original = sc->get_meta("original");
  111. if (sc->is_shortcut(original) || (original.is_null() && sc->get_shortcut().is_null()))
  112. continue; //not changed from default, don't save
  113. }
  114. arr.push_back(E->key());
  115. arr.push_back(sc->get_shortcut());
  116. }
  117. r_ret = arr;
  118. return true;
  119. }
  120. const VariantContainer *v = props.getptr(p_name);
  121. if (!v) {
  122. WARN_PRINTS("EditorSettings::_get - Property not found: " + String(p_name));
  123. return false;
  124. }
  125. r_ret = v->variant;
  126. return true;
  127. }
  128. void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_value) {
  129. set(p_name, p_value);
  130. props[p_name].initial = p_value;
  131. props[p_name].has_default_value = true;
  132. }
  133. struct _EVCSort {
  134. String name;
  135. Variant::Type type;
  136. int order;
  137. bool save;
  138. bool restart_if_changed;
  139. bool operator<(const _EVCSort &p_vcs) const { return order < p_vcs.order; }
  140. };
  141. void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
  142. _THREAD_SAFE_METHOD_
  143. const String *k = NULL;
  144. Set<_EVCSort> vclist;
  145. while ((k = props.next(k))) {
  146. const VariantContainer *v = props.getptr(*k);
  147. if (v->hide_from_editor)
  148. continue;
  149. _EVCSort vc;
  150. vc.name = *k;
  151. vc.order = v->order;
  152. vc.type = v->variant.get_type();
  153. vc.save = v->save;
  154. vc.restart_if_changed = v->restart_if_changed;
  155. vclist.insert(vc);
  156. }
  157. for (Set<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) {
  158. int pinfo = 0;
  159. if (E->get().save || !optimize_save) {
  160. pinfo |= PROPERTY_USAGE_STORAGE;
  161. }
  162. if (!E->get().name.begins_with("_") && !E->get().name.begins_with("projects/")) {
  163. pinfo |= PROPERTY_USAGE_EDITOR;
  164. } else {
  165. pinfo |= PROPERTY_USAGE_STORAGE; //hiddens must always be saved
  166. }
  167. PropertyInfo pi(E->get().type, E->get().name);
  168. pi.usage = pinfo;
  169. if (hints.has(E->get().name))
  170. pi = hints[E->get().name];
  171. if (E->get().restart_if_changed) {
  172. pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED;
  173. }
  174. p_list->push_back(pi);
  175. }
  176. p_list->push_back(PropertyInfo(Variant::ARRAY, "shortcuts", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); //do not edit
  177. }
  178. void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
  179. ERR_FAIL_COND(!p_info.has("name"));
  180. ERR_FAIL_COND(!p_info.has("type"));
  181. PropertyInfo pinfo;
  182. pinfo.name = p_info["name"];
  183. ERR_FAIL_COND(!props.has(pinfo.name));
  184. pinfo.type = Variant::Type(p_info["type"].operator int());
  185. ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
  186. if (p_info.has("hint"))
  187. pinfo.hint = PropertyHint(p_info["hint"].operator int());
  188. if (p_info.has("hint_string"))
  189. pinfo.hint_string = p_info["hint_string"];
  190. add_property_hint(pinfo);
  191. }
  192. // Default configs
  193. bool EditorSettings::has_default_value(const String &p_setting) const {
  194. _THREAD_SAFE_METHOD_
  195. if (!props.has(p_setting))
  196. return false;
  197. return props[p_setting].has_default_value;
  198. }
  199. void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
  200. _THREAD_SAFE_METHOD_
  201. /* Languages */
  202. {
  203. String lang_hint = "en";
  204. String host_lang = OS::get_singleton()->get_locale();
  205. host_lang = TranslationServer::standardize_locale(host_lang);
  206. String best;
  207. EditorTranslationList *etl = _editor_translations;
  208. while (etl->data) {
  209. const String &locale = etl->lang;
  210. lang_hint += ",";
  211. lang_hint += locale;
  212. if (host_lang == locale) {
  213. best = locale;
  214. }
  215. if (best == String() && host_lang.begins_with(locale)) {
  216. best = locale;
  217. }
  218. etl++;
  219. }
  220. if (best == String()) {
  221. best = "en";
  222. }
  223. _initial_set("interface/editor/editor_language", best);
  224. set_restart_if_changed("interface/editor/editor_language", true);
  225. hints["interface/editor/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  226. }
  227. /* Interface */
  228. // Editor
  229. _initial_set("interface/editor/display_scale", 0);
  230. hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, "Auto,75%,100%,125%,150%,175%,200%,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  231. _initial_set("interface/editor/custom_display_scale", 1.0f);
  232. hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::REAL, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.75,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  233. _initial_set("interface/editor/main_font_size", 14);
  234. hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  235. _initial_set("interface/editor/code_font_size", 14);
  236. hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT);
  237. _initial_set("interface/editor/main_font_antialiased", true);
  238. _initial_set("interface/editor/code_font_antialiased", true);
  239. _initial_set("interface/editor/main_font_hinting", 2);
  240. hints["interface/editor/main_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/main_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT);
  241. _initial_set("interface/editor/code_font_hinting", 2);
  242. hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT);
  243. _initial_set("interface/editor/main_font", "");
  244. hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
  245. _initial_set("interface/editor/main_font_bold", "");
  246. hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_font_bold", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
  247. _initial_set("interface/editor/code_font", "");
  248. hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
  249. _initial_set("interface/editor/dim_editor_on_dialog_popup", true);
  250. _initial_set("interface/editor/dim_amount", 0.6f);
  251. hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
  252. _initial_set("interface/editor/dim_transition_time", 0.08f);
  253. hints["interface/editor/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/editor/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT);
  254. _initial_set("interface/editor/separate_distraction_mode", false);
  255. _initial_set("interface/editor/save_each_scene_on_quit", true); // Regression
  256. _initial_set("interface/editor/quit_confirmation", true);
  257. // Theme
  258. _initial_set("interface/theme/preset", "Default");
  259. hints["interface/theme/preset"] = PropertyInfo(Variant::STRING, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Alien,Arc,Godot 2,Grey,Light,Solarized (Dark),Solarized (Light),Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  260. _initial_set("interface/theme/icon_and_font_color", 0);
  261. hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  262. _initial_set("interface/theme/base_color", Color::html("#323b4f"));
  263. hints["interface/theme/accent_color"] = PropertyInfo(Variant::COLOR, "interface/theme/accent_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  264. _initial_set("interface/theme/accent_color", Color::html("#699ce8"));
  265. hints["interface/theme/base_color"] = PropertyInfo(Variant::COLOR, "interface/theme/base_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  266. _initial_set("interface/theme/contrast", 0.25);
  267. hints["interface/theme/contrast"] = PropertyInfo(Variant::REAL, "interface/theme/contrast", PROPERTY_HINT_RANGE, "0.01, 1, 0.01");
  268. _initial_set("interface/theme/highlight_tabs", false);
  269. _initial_set("interface/theme/border_size", 1);
  270. _initial_set("interface/theme/use_graph_node_headers", false);
  271. hints["interface/theme/border_size"] = PropertyInfo(Variant::INT, "interface/theme/border_size", PROPERTY_HINT_RANGE, "0,2,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  272. _initial_set("interface/theme/additional_spacing", 0);
  273. hints["interface/theme/additional_spacing"] = PropertyInfo(Variant::REAL, "interface/theme/additional_spacing", PROPERTY_HINT_RANGE, "0,5,0.1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  274. _initial_set("interface/theme/custom_theme", "");
  275. hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  276. // Scene tabs
  277. _initial_set("interface/scene_tabs/show_extension", false);
  278. _initial_set("interface/scene_tabs/show_thumbnail_on_hover", true);
  279. _initial_set("interface/scene_tabs/resize_if_many_tabs", true);
  280. _initial_set("interface/scene_tabs/minimum_width", 50);
  281. hints["interface/scene_tabs/minimum_width"] = PropertyInfo(Variant::INT, "interface/scene_tabs/minimum_width", PROPERTY_HINT_RANGE, "50,500,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  282. _initial_set("interface/scene_tabs/show_script_button", false);
  283. /* Filesystem */
  284. // Directories
  285. _initial_set("filesystem/directories/autoscan_project_path", "");
  286. hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR);
  287. _initial_set("filesystem/directories/default_project_path", OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS));
  288. hints["filesystem/directories/default_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_path", PROPERTY_HINT_GLOBAL_DIR);
  289. // On save
  290. _initial_set("filesystem/on_save/compress_binary_resources", true);
  291. _initial_set("filesystem/on_save/safe_save_on_backup_then_rename", true);
  292. // File dialog
  293. _initial_set("filesystem/file_dialog/show_hidden_files", false);
  294. _initial_set("filesystem/file_dialog/display_mode", 0);
  295. hints["filesystem/file_dialog/display_mode"] = PropertyInfo(Variant::INT, "filesystem/file_dialog/display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
  296. _initial_set("filesystem/file_dialog/thumbnail_size", 64);
  297. hints["filesystem/file_dialog/thumbnail_size"] = PropertyInfo(Variant::INT, "filesystem/file_dialog/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
  298. // Import
  299. _initial_set("filesystem/import/pvrtc_texture_tool", "");
  300. #ifdef WINDOWS_ENABLED
  301. hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "filesystem/import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "*.exe");
  302. #else
  303. hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "filesystem/import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "");
  304. #endif
  305. _initial_set("filesystem/import/pvrtc_fast_conversion", false);
  306. /* Docks */
  307. // SceneTree
  308. _initial_set("docks/scene_tree/start_create_dialog_fully_expanded", false);
  309. _initial_set("docks/scene_tree/draw_relationship_lines", true);
  310. _initial_set("docks/scene_tree/relationship_line_color", Color::html("464646"));
  311. // FileSystem
  312. _initial_set("docks/filesystem/display_mode", 0);
  313. hints["docks/filesystem/display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/display_mode", PROPERTY_HINT_ENUM, "Tree only, Split");
  314. _initial_set("docks/filesystem/thumbnail_size", 64);
  315. hints["docks/filesystem/thumbnail_size"] = PropertyInfo(Variant::INT, "docks/filesystem/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
  316. _initial_set("docks/filesystem/files_display_mode", 0);
  317. hints["docks/filesystem/files_display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/files_display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
  318. _initial_set("docks/filesystem/always_show_folders", true);
  319. // Property editor
  320. _initial_set("docks/property_editor/auto_refresh_interval", 0.3);
  321. /* Text editor */
  322. // Theme
  323. _initial_set("text_editor/theme/color_theme", "Adaptive");
  324. hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default,Custom");
  325. _initial_set("text_editor/theme/line_spacing", 6);
  326. _initial_set("text_editor/theme/selection_color", Color::html("40808080"));
  327. _load_default_text_editor_theme();
  328. // Highlighting
  329. _initial_set("text_editor/highlighting/syntax_highlighting", true);
  330. _initial_set("text_editor/highlighting/highlight_all_occurrences", true);
  331. _initial_set("text_editor/highlighting/highlight_current_line", true);
  332. _initial_set("text_editor/highlighting/highlight_type_safe_lines", true);
  333. // Indent
  334. _initial_set("text_editor/indent/type", 0);
  335. hints["text_editor/indent/type"] = PropertyInfo(Variant::INT, "text_editor/indent/type", PROPERTY_HINT_ENUM, "Tabs,Spaces");
  336. _initial_set("text_editor/indent/size", 4);
  337. hints["text_editor/indent/size"] = PropertyInfo(Variant::INT, "text_editor/indent/size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes.
  338. _initial_set("text_editor/indent/auto_indent", true);
  339. _initial_set("text_editor/indent/convert_indent_on_save", false);
  340. _initial_set("text_editor/indent/draw_tabs", true);
  341. // Line numbers
  342. _initial_set("text_editor/line_numbers/show_line_numbers", true);
  343. _initial_set("text_editor/line_numbers/line_numbers_zero_padded", false);
  344. _initial_set("text_editor/line_numbers/show_breakpoint_gutter", true);
  345. _initial_set("text_editor/line_numbers/code_folding", true);
  346. _initial_set("text_editor/line_numbers/word_wrap", false);
  347. _initial_set("text_editor/line_numbers/show_line_length_guideline", false);
  348. _initial_set("text_editor/line_numbers/line_length_guideline_column", 80);
  349. hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");
  350. // Open scripts
  351. _initial_set("text_editor/open_scripts/smooth_scrolling", true);
  352. _initial_set("text_editor/open_scripts/v_scroll_speed", 80);
  353. _initial_set("text_editor/open_scripts/show_members_overview", true);
  354. // Files
  355. _initial_set("text_editor/files/trim_trailing_whitespace_on_save", false);
  356. _initial_set("text_editor/files/autosave_interval_secs", 0);
  357. _initial_set("text_editor/files/restore_scripts_on_load", true);
  358. // Tools
  359. _initial_set("text_editor/tools/create_signal_callbacks", true);
  360. _initial_set("text_editor/tools/sort_members_outline_alphabetically", false);
  361. // Cursor
  362. _initial_set("text_editor/cursor/scroll_past_end_of_file", false);
  363. _initial_set("text_editor/cursor/block_caret", false);
  364. _initial_set("text_editor/cursor/caret_blink", true);
  365. _initial_set("text_editor/cursor/caret_blink_speed", 0.5);
  366. hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.01");
  367. _initial_set("text_editor/cursor/right_click_moves_caret", true);
  368. // Completion
  369. _initial_set("text_editor/completion/idle_parse_delay", 2);
  370. _initial_set("text_editor/completion/auto_brace_complete", false);
  371. _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true);
  372. _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2());
  373. _initial_set("text_editor/completion/complete_file_paths", true);
  374. _initial_set("text_editor/completion/add_type_hints", false);
  375. // Help
  376. _initial_set("text_editor/help/show_help_index", true);
  377. /* Editors */
  378. // GridMap
  379. _initial_set("editors/grid_map/pick_distance", 5000.0);
  380. // 3D
  381. _initial_set("editors/3d/primary_grid_color", Color::html("909090"));
  382. hints["editors/3d/primary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/primary_grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  383. _initial_set("editors/3d/secondary_grid_color", Color::html("606060"));
  384. hints["editors/3d/secondary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/secondary_grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  385. _initial_set("editors/3d/grid_size", 50);
  386. hints["editors/3d/grid_size"] = PropertyInfo(Variant::INT, "editors/3d/grid_size", PROPERTY_HINT_RANGE, "1,500,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  387. _initial_set("editors/3d/primary_grid_steps", 10);
  388. hints["editors/3d/primary_grid_steps"] = PropertyInfo(Variant::INT, "editors/3d/primary_grid_steps", PROPERTY_HINT_RANGE, "1,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
  389. _initial_set("editors/3d/default_fov", 70.0);
  390. _initial_set("editors/3d/default_z_near", 0.05);
  391. _initial_set("editors/3d/default_z_far", 500.0);
  392. // 3D: Navigation
  393. _initial_set("editors/3d/navigation/navigation_scheme", 0);
  394. _initial_set("editors/3d/navigation/invert_y_axis", false);
  395. hints["editors/3d/navigation/navigation_scheme"] = PropertyInfo(Variant::INT, "editors/3d/navigation/navigation_scheme", PROPERTY_HINT_ENUM, "Godot,Maya,Modo");
  396. _initial_set("editors/3d/navigation/zoom_style", 0);
  397. hints["editors/3d/navigation/zoom_style"] = PropertyInfo(Variant::INT, "editors/3d/navigation/zoom_style", PROPERTY_HINT_ENUM, "Vertical, Horizontal");
  398. _initial_set("editors/3d/navigation/emulate_3_button_mouse", false);
  399. _initial_set("editors/3d/navigation/orbit_modifier", 0);
  400. hints["editors/3d/navigation/orbit_modifier"] = PropertyInfo(Variant::INT, "editors/3d/navigation/orbit_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
  401. _initial_set("editors/3d/navigation/pan_modifier", 1);
  402. hints["editors/3d/navigation/pan_modifier"] = PropertyInfo(Variant::INT, "editors/3d/navigation/pan_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
  403. _initial_set("editors/3d/navigation/zoom_modifier", 4);
  404. hints["editors/3d/navigation/zoom_modifier"] = PropertyInfo(Variant::INT, "editors/3d/navigation/zoom_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
  405. _initial_set("editors/3d/navigation/warped_mouse_panning", true);
  406. // 3D: Navigation feel
  407. _initial_set("editors/3d/navigation_feel/orbit_sensitivity", 0.4);
  408. hints["editors/3d/navigation_feel/orbit_sensitivity"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/orbit_sensitivity", PROPERTY_HINT_RANGE, "0.0, 2, 0.01");
  409. _initial_set("editors/3d/navigation_feel/orbit_inertia", 0.05);
  410. hints["editors/3d/navigation_feel/orbit_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/orbit_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  411. _initial_set("editors/3d/navigation_feel/translation_inertia", 0.15);
  412. hints["editors/3d/navigation_feel/translation_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/translation_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  413. _initial_set("editors/3d/navigation_feel/zoom_inertia", 0.075);
  414. hints["editors/3d/navigation_feel/zoom_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/zoom_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  415. _initial_set("editors/3d/navigation_feel/manipulation_orbit_inertia", 0.075);
  416. hints["editors/3d/navigation_feel/manipulation_orbit_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/manipulation_orbit_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  417. _initial_set("editors/3d/navigation_feel/manipulation_translation_inertia", 0.075);
  418. hints["editors/3d/navigation_feel/manipulation_translation_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/navigation_feel/manipulation_translation_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  419. // 3D: Freelook
  420. _initial_set("editors/3d/freelook/freelook_inertia", 0.1);
  421. hints["editors/3d/freelook/freelook_inertia"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01");
  422. _initial_set("editors/3d/freelook/freelook_base_speed", 5.0);
  423. hints["editors/3d/freelook/freelook_base_speed"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_base_speed", PROPERTY_HINT_RANGE, "0.0, 10, 0.01");
  424. _initial_set("editors/3d/freelook/freelook_activation_modifier", 0);
  425. hints["editors/3d/freelook/freelook_activation_modifier"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_activation_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
  426. _initial_set("editors/3d/freelook/freelook_modifier_speed_factor", 3.0);
  427. hints["editors/3d/freelook/freelook_modifier_speed_factor"] = PropertyInfo(Variant::REAL, "editors/3d/freelook/freelook_modifier_speed_factor", PROPERTY_HINT_RANGE, "0.0, 10.0, 0.1");
  428. _initial_set("editors/3d/freelook/freelook_speed_zoom_link", false);
  429. // 2D
  430. _initial_set("editors/2d/grid_color", Color(1.0, 1.0, 1.0, 0.07));
  431. _initial_set("editors/2d/guides_color", Color(0.6, 0.0, 0.8));
  432. _initial_set("editors/2d/bone_width", 5);
  433. _initial_set("editors/2d/bone_color1", Color(1.0, 1.0, 1.0, 0.9));
  434. _initial_set("editors/2d/bone_color2", Color(0.6, 0.6, 0.6, 0.9));
  435. _initial_set("editors/2d/bone_selected_color", Color(0.9, 0.45, 0.45, 0.9));
  436. _initial_set("editors/2d/bone_ik_color", Color(0.9, 0.9, 0.45, 0.9));
  437. _initial_set("editors/2d/bone_outline_color", Color(0.35, 0.35, 0.35));
  438. _initial_set("editors/2d/bone_outline_size", 2);
  439. _initial_set("editors/2d/keep_margins_when_changing_anchors", false);
  440. _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4));
  441. _initial_set("editors/2d/warped_mouse_panning", true);
  442. _initial_set("editors/2d/simple_spacebar_panning", false);
  443. _initial_set("editors/2d/scroll_to_pan", false);
  444. _initial_set("editors/2d/pan_speed", 20);
  445. // Polygon editor
  446. _initial_set("editors/poly_editor/point_grab_radius", 8);
  447. _initial_set("editors/poly_editor/show_previous_outline", true);
  448. // Animation
  449. _initial_set("editors/animation/autorename_animation_tracks", true);
  450. _initial_set("editors/animation/confirm_insert_track", true);
  451. _initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0));
  452. _initial_set("editors/animation/onion_layers_future_color", Color(0, 1, 0));
  453. /* Run */
  454. // Window placement
  455. _initial_set("run/window_placement/rect", 1);
  456. hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen");
  457. String screen_hints = "Same as Editor,Previous Monitor,Next Monitor";
  458. for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
  459. screen_hints += ",Monitor " + itos(i + 1);
  460. }
  461. _initial_set("run/window_placement/rect_custom_position", Vector2());
  462. _initial_set("run/window_placement/screen", 0);
  463. hints["run/window_placement/screen"] = PropertyInfo(Variant::INT, "run/window_placement/screen", PROPERTY_HINT_ENUM, screen_hints);
  464. // Auto save
  465. _initial_set("run/auto_save/save_before_running", true);
  466. // Output
  467. _initial_set("run/output/always_clear_output_on_play", true);
  468. _initial_set("run/output/always_open_output_on_play", true);
  469. _initial_set("run/output/always_close_output_on_stop", false);
  470. /* Extra config */
  471. _initial_set("project_manager/sorting_order", 0);
  472. hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Last Modified");
  473. if (p_extra_config.is_valid()) {
  474. if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
  475. Vector<String> list = p_extra_config->get_value("init_projects", "list");
  476. for (int i = 0; i < list.size(); i++) {
  477. String name = list[i].replace("/", "::");
  478. set("projects/" + name, list[i]);
  479. };
  480. };
  481. if (p_extra_config->has_section("presets")) {
  482. List<String> keys;
  483. p_extra_config->get_section_keys("presets", &keys);
  484. for (List<String>::Element *E = keys.front(); E; E = E->next()) {
  485. String key = E->get();
  486. Variant val = p_extra_config->get_value("presets", key);
  487. set(key, val);
  488. };
  489. };
  490. };
  491. }
  492. void EditorSettings::_load_default_text_editor_theme() {
  493. bool dark_theme = is_dark_theme();
  494. _initial_set("text_editor/highlighting/symbol_color", Color::html("badfff"));
  495. _initial_set("text_editor/highlighting/keyword_color", Color::html("ffffb3"));
  496. _initial_set("text_editor/highlighting/base_type_color", Color::html("a4ffd4"));
  497. _initial_set("text_editor/highlighting/engine_type_color", Color::html("83d3ff"));
  498. _initial_set("text_editor/highlighting/comment_color", Color::html("676767"));
  499. _initial_set("text_editor/highlighting/string_color", Color::html("ef6ebe"));
  500. _initial_set("text_editor/highlighting/background_color", dark_theme ? Color::html("3b000000") : Color::html("#323b4f"));
  501. _initial_set("text_editor/highlighting/completion_background_color", Color::html("2C2A32"));
  502. _initial_set("text_editor/highlighting/completion_selected_color", Color::html("434244"));
  503. _initial_set("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"));
  504. _initial_set("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"));
  505. _initial_set("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
  506. _initial_set("text_editor/highlighting/text_color", Color::html("aaaaaa"));
  507. _initial_set("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"));
  508. _initial_set("text_editor/highlighting/safe_line_number_color", Color::html("99aac8aa"));
  509. _initial_set("text_editor/highlighting/caret_color", Color::html("aaaaaa"));
  510. _initial_set("text_editor/highlighting/caret_background_color", Color::html("000000"));
  511. _initial_set("text_editor/highlighting/text_selected_color", Color::html("000000"));
  512. _initial_set("text_editor/highlighting/selection_color", Color::html("6ca9c2"));
  513. _initial_set("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2));
  514. _initial_set("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15));
  515. _initial_set("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1));
  516. _initial_set("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
  517. _initial_set("text_editor/highlighting/number_color", Color::html("EB9532"));
  518. _initial_set("text_editor/highlighting/function_color", Color::html("66a2ce"));
  519. _initial_set("text_editor/highlighting/member_variable_color", Color::html("e64e59"));
  520. _initial_set("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
  521. _initial_set("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
  522. _initial_set("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
  523. _initial_set("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
  524. _initial_set("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
  525. }
  526. bool EditorSettings::_save_text_editor_theme(String p_file) {
  527. String theme_section = "color_theme";
  528. Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better?
  529. List<String> keys;
  530. props.get_key_list(&keys);
  531. keys.sort();
  532. for (const List<String>::Element *E = keys.front(); E; E = E->next()) {
  533. String key = E->get();
  534. if (key.begins_with("text_editor/highlighting/") && key.find("color") >= 0) {
  535. cf->set_value(theme_section, key.replace("text_editor/highlighting/", ""), ((Color)props[key].variant).to_html());
  536. }
  537. }
  538. Error err = cf->save(p_file);
  539. if (err == OK) {
  540. return true;
  541. }
  542. return false;
  543. }
  544. static Dictionary _get_builtin_script_templates() {
  545. Dictionary templates;
  546. //No Comments
  547. templates["no_comments.gd"] =
  548. "extends %BASE%\n"
  549. "\n"
  550. "func _ready():\n"
  551. "%TS%pass\n";
  552. //Empty
  553. templates["empty.gd"] =
  554. "extends %BASE%"
  555. "\n"
  556. "\n";
  557. return templates;
  558. }
  559. static void _create_script_templates(const String &p_path) {
  560. Dictionary templates = _get_builtin_script_templates();
  561. List<Variant> keys;
  562. templates.get_key_list(&keys);
  563. FileAccess *file = FileAccess::create(FileAccess::ACCESS_FILESYSTEM);
  564. DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  565. dir->change_dir(p_path);
  566. for (int i = 0; i < keys.size(); i++) {
  567. if (!dir->file_exists(keys[i])) {
  568. Error err = file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE);
  569. ERR_FAIL_COND(err != OK);
  570. file->store_string(templates[keys[i]]);
  571. file->close();
  572. }
  573. }
  574. memdelete(dir);
  575. memdelete(file);
  576. }
  577. // PUBLIC METHODS
  578. EditorSettings *EditorSettings::get_singleton() {
  579. return singleton.ptr();
  580. }
  581. void EditorSettings::create() {
  582. if (singleton.ptr())
  583. return; //pointless
  584. DirAccess *dir = NULL;
  585. String data_path;
  586. String data_dir;
  587. String config_path;
  588. String config_dir;
  589. String cache_path;
  590. String cache_dir;
  591. Ref<ConfigFile> extra_config = memnew(ConfigFile);
  592. String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
  593. DirAccess *d = DirAccess::create_for_path(exe_path);
  594. bool self_contained = false;
  595. if (d->file_exists(exe_path + "/._sc_")) {
  596. self_contained = true;
  597. extra_config->load(exe_path + "/._sc_");
  598. } else if (d->file_exists(exe_path + "/_sc_")) {
  599. self_contained = true;
  600. extra_config->load(exe_path + "/_sc_");
  601. }
  602. memdelete(d);
  603. if (self_contained) {
  604. // editor is self contained, all in same folder
  605. data_path = exe_path;
  606. data_dir = data_path.plus_file("editor_data");
  607. config_path = exe_path;
  608. config_dir = data_dir;
  609. cache_path = exe_path;
  610. cache_dir = data_dir.plus_file("cache");
  611. } else {
  612. // Typically XDG_DATA_HOME or %APPDATA%
  613. data_path = OS::get_singleton()->get_data_path();
  614. data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name());
  615. // Can be different from data_path e.g. on Linux or macOS
  616. config_path = OS::get_singleton()->get_config_path();
  617. config_dir = config_path.plus_file(OS::get_singleton()->get_godot_dir_name());
  618. // Can be different from above paths, otherwise a subfolder of data_dir
  619. cache_path = OS::get_singleton()->get_cache_path();
  620. if (cache_path == data_path) {
  621. cache_dir = data_dir.plus_file("cache");
  622. } else {
  623. cache_dir = cache_path.plus_file(OS::get_singleton()->get_godot_dir_name());
  624. }
  625. }
  626. ClassDB::register_class<EditorSettings>(); //otherwise it can't be unserialized
  627. String config_file_path;
  628. if (data_path != "" && config_path != "" && cache_path != "") {
  629. // Validate/create data dir and subdirectories
  630. dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  631. if (dir->change_dir(data_path) != OK) {
  632. ERR_PRINT("Cannot find path for data directory!");
  633. memdelete(dir);
  634. goto fail;
  635. }
  636. if (dir->change_dir(data_dir) != OK) {
  637. dir->make_dir_recursive(data_dir);
  638. if (dir->change_dir(data_dir) != OK) {
  639. ERR_PRINT("Cannot create data directory!");
  640. memdelete(dir);
  641. goto fail;
  642. }
  643. }
  644. if (dir->change_dir("templates") != OK) {
  645. dir->make_dir("templates");
  646. } else {
  647. dir->change_dir("..");
  648. }
  649. // Validate/create cache dir
  650. if (dir->change_dir(cache_dir) != OK) {
  651. dir->make_dir_recursive(cache_dir);
  652. if (dir->change_dir(cache_dir) != OK) {
  653. ERR_PRINT("Cannot create cache directory!");
  654. memdelete(dir);
  655. goto fail;
  656. }
  657. }
  658. // Validate/create config dir and subdirectories
  659. if (dir->change_dir(config_dir) != OK) {
  660. dir->make_dir_recursive(config_dir);
  661. if (dir->change_dir(config_dir) != OK) {
  662. ERR_PRINT("Cannot create config directory!");
  663. memdelete(dir);
  664. goto fail;
  665. }
  666. }
  667. if (dir->change_dir("text_editor_themes") != OK) {
  668. dir->make_dir("text_editor_themes");
  669. } else {
  670. dir->change_dir("..");
  671. }
  672. if (dir->change_dir("script_templates") != OK) {
  673. dir->make_dir("script_templates");
  674. } else {
  675. dir->change_dir("..");
  676. }
  677. _create_script_templates(dir->get_current_dir().plus_file("script_templates"));
  678. if (dir->change_dir("projects") != OK) {
  679. dir->make_dir("projects");
  680. } else {
  681. dir->change_dir("..");
  682. }
  683. // Validate/create project-specific config dir
  684. dir->change_dir("projects");
  685. String project_config_dir = ProjectSettings::get_singleton()->get_resource_path();
  686. if (project_config_dir.ends_with("/"))
  687. project_config_dir = config_path.substr(0, project_config_dir.size() - 1);
  688. project_config_dir = project_config_dir.get_file() + "-" + project_config_dir.md5_text();
  689. if (dir->change_dir(project_config_dir) != OK) {
  690. dir->make_dir(project_config_dir);
  691. } else {
  692. dir->change_dir("..");
  693. }
  694. dir->change_dir("..");
  695. // Validate editor config file
  696. String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
  697. config_file_path = config_dir.plus_file(config_file_name);
  698. if (!dir->file_exists(config_file_name)) {
  699. goto fail;
  700. }
  701. memdelete(dir);
  702. singleton = ResourceLoader::load(config_file_path, "EditorSettings");
  703. if (singleton.is_null()) {
  704. WARN_PRINT("Could not open config file.");
  705. goto fail;
  706. }
  707. singleton->save_changed_setting = true;
  708. singleton->config_file_path = config_file_path;
  709. singleton->project_config_dir = project_config_dir;
  710. singleton->settings_dir = config_dir;
  711. singleton->data_dir = data_dir;
  712. singleton->cache_dir = cache_dir;
  713. print_verbose("EditorSettings: Load OK!");
  714. singleton->setup_language();
  715. singleton->setup_network();
  716. singleton->load_favorites();
  717. singleton->list_text_editor_themes();
  718. return;
  719. }
  720. fail:
  721. // patch init projects
  722. if (extra_config->has_section("init_projects")) {
  723. Vector<String> list = extra_config->get_value("init_projects", "list");
  724. for (int i = 0; i < list.size(); i++) {
  725. list.write[i] = exe_path + "/" + list[i];
  726. };
  727. extra_config->set_value("init_projects", "list", list);
  728. };
  729. singleton = Ref<EditorSettings>(memnew(EditorSettings));
  730. singleton->save_changed_setting = true;
  731. singleton->config_file_path = config_file_path;
  732. singleton->settings_dir = config_dir;
  733. singleton->data_dir = data_dir;
  734. singleton->cache_dir = cache_dir;
  735. singleton->_load_defaults(extra_config);
  736. singleton->setup_language();
  737. singleton->setup_network();
  738. singleton->list_text_editor_themes();
  739. }
  740. void EditorSettings::setup_language() {
  741. String lang = get("interface/editor/editor_language");
  742. if (lang == "en")
  743. return; //none to do
  744. EditorTranslationList *etl = _editor_translations;
  745. while (etl->data) {
  746. if (etl->lang == lang) {
  747. Vector<uint8_t> data;
  748. data.resize(etl->uncomp_size);
  749. Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
  750. FileAccessMemory *fa = memnew(FileAccessMemory);
  751. fa->open_custom(data.ptr(), data.size());
  752. Ref<Translation> tr = TranslationLoaderPO::load_translation(fa, NULL, "translation_" + String(etl->lang));
  753. if (tr.is_valid()) {
  754. tr->set_locale(etl->lang);
  755. TranslationServer::get_singleton()->set_tool_translation(tr);
  756. break;
  757. }
  758. }
  759. etl++;
  760. }
  761. }
  762. void EditorSettings::setup_network() {
  763. List<IP_Address> local_ip;
  764. IP::get_singleton()->get_local_addresses(&local_ip);
  765. String lip = "127.0.0.1";
  766. String hint;
  767. String current = has_setting("network/debug/remote_host") ? get("network/debug/remote_host") : "";
  768. int port = has_setting("network/debug/remote_port") ? (int)get("network/debug/remote_port") : 6007;
  769. for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
  770. String ip = E->get();
  771. // link-local IPv6 addresses don't work, skipping them
  772. if (ip.begins_with("fe80:0:0:0:")) // fe80::/64
  773. continue;
  774. if (ip == current)
  775. lip = current; //so it saves
  776. if (hint != "")
  777. hint += ",";
  778. hint += ip;
  779. }
  780. _initial_set("network/debug/remote_host", lip);
  781. add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint));
  782. _initial_set("network/debug/remote_port", port);
  783. add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1"));
  784. // Editor SSL certificates override
  785. _initial_set("network/ssl/editor_ssl_certificates", _SYSTEM_CERTS_PATH);
  786. add_property_hint(PropertyInfo(Variant::STRING, "network/ssl/editor_ssl_certificates", PROPERTY_HINT_GLOBAL_FILE, "*.crt,*.pem"));
  787. }
  788. void EditorSettings::save() {
  789. //_THREAD_SAFE_METHOD_
  790. if (!singleton.ptr())
  791. return;
  792. if (singleton->config_file_path == "") {
  793. ERR_PRINT("Cannot save EditorSettings config, no valid path");
  794. return;
  795. }
  796. Error err = ResourceSaver::save(singleton->config_file_path, singleton);
  797. if (err != OK) {
  798. ERR_PRINTS("Error saving editor settings to " + singleton->config_file_path);
  799. } else {
  800. print_verbose("EditorSettings: Save OK!");
  801. }
  802. }
  803. void EditorSettings::destroy() {
  804. if (!singleton.ptr())
  805. return;
  806. save();
  807. singleton = Ref<EditorSettings>();
  808. }
  809. void EditorSettings::set_optimize_save(bool p_optimize) {
  810. optimize_save = p_optimize;
  811. }
  812. // Properties
  813. void EditorSettings::set_setting(const String &p_setting, const Variant &p_value) {
  814. _THREAD_SAFE_METHOD_
  815. set(p_setting, p_value);
  816. }
  817. Variant EditorSettings::get_setting(const String &p_setting) const {
  818. _THREAD_SAFE_METHOD_
  819. return get(p_setting);
  820. }
  821. bool EditorSettings::has_setting(const String &p_setting) const {
  822. _THREAD_SAFE_METHOD_
  823. return props.has(p_setting);
  824. }
  825. void EditorSettings::erase(const String &p_setting) {
  826. _THREAD_SAFE_METHOD_
  827. props.erase(p_setting);
  828. }
  829. void EditorSettings::raise_order(const String &p_setting) {
  830. _THREAD_SAFE_METHOD_
  831. ERR_FAIL_COND(!props.has(p_setting));
  832. props[p_setting].order = ++last_order;
  833. }
  834. void EditorSettings::set_restart_if_changed(const StringName &p_setting, bool p_restart) {
  835. _THREAD_SAFE_METHOD_
  836. if (!props.has(p_setting))
  837. return;
  838. props[p_setting].restart_if_changed = p_restart;
  839. }
  840. void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) {
  841. _THREAD_SAFE_METHOD_
  842. if (!props.has(p_setting))
  843. return;
  844. props[p_setting].initial = p_value;
  845. props[p_setting].has_default_value = true;
  846. if (p_update_current) {
  847. set(p_setting, p_value);
  848. }
  849. }
  850. Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed) {
  851. Variant ret = p_default;
  852. if (EditorSettings::get_singleton()->has_setting(p_setting)) {
  853. ret = EditorSettings::get_singleton()->get(p_setting);
  854. } else {
  855. EditorSettings::get_singleton()->set_manually(p_setting, p_default);
  856. EditorSettings::get_singleton()->set_restart_if_changed(p_setting, p_restart_if_changed);
  857. }
  858. if (!EditorSettings::get_singleton()->has_default_value(p_setting)) {
  859. EditorSettings::get_singleton()->set_initial_value(p_setting, p_default);
  860. }
  861. return ret;
  862. }
  863. Variant _EDITOR_GET(const String &p_setting) {
  864. ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has_setting(p_setting), Variant())
  865. return EditorSettings::get_singleton()->get(p_setting);
  866. }
  867. bool EditorSettings::property_can_revert(const String &p_setting) {
  868. if (!props.has(p_setting))
  869. return false;
  870. if (!props[p_setting].has_default_value)
  871. return false;
  872. return props[p_setting].initial != props[p_setting].variant;
  873. }
  874. Variant EditorSettings::property_get_revert(const String &p_setting) {
  875. if (!props.has(p_setting) || !props[p_setting].has_default_value)
  876. return Variant();
  877. return props[p_setting].initial;
  878. }
  879. void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
  880. _THREAD_SAFE_METHOD_
  881. hints[p_hint.name] = p_hint;
  882. }
  883. // Data directories
  884. String EditorSettings::get_data_dir() const {
  885. return data_dir;
  886. }
  887. String EditorSettings::get_templates_dir() const {
  888. return get_data_dir().plus_file("templates");
  889. }
  890. // Config directories
  891. String EditorSettings::get_settings_dir() const {
  892. return settings_dir;
  893. }
  894. String EditorSettings::get_project_settings_dir() const {
  895. return get_settings_dir().plus_file("projects").plus_file(project_config_dir);
  896. }
  897. String EditorSettings::get_text_editor_themes_dir() const {
  898. return get_settings_dir().plus_file("text_editor_themes");
  899. }
  900. String EditorSettings::get_script_templates_dir() const {
  901. return get_settings_dir().plus_file("script_templates");
  902. }
  903. // Cache directory
  904. String EditorSettings::get_cache_dir() const {
  905. return cache_dir;
  906. }
  907. // Metadata
  908. void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) {
  909. Ref<ConfigFile> cf = memnew(ConfigFile);
  910. String path = get_project_settings_dir().plus_file("project_metadata.cfg");
  911. cf->load(path);
  912. cf->set_value(p_section, p_key, p_data);
  913. cf->save(path);
  914. }
  915. Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const {
  916. Ref<ConfigFile> cf = memnew(ConfigFile);
  917. String path = get_project_settings_dir().plus_file("project_metadata.cfg");
  918. Error err = cf->load(path);
  919. if (err != OK) {
  920. return p_default;
  921. }
  922. return cf->get_value(p_section, p_key, p_default);
  923. }
  924. void EditorSettings::set_favorites(const Vector<String> &p_favorites) {
  925. favorites = p_favorites;
  926. FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::WRITE);
  927. if (f) {
  928. for (int i = 0; i < favorites.size(); i++)
  929. f->store_line(favorites[i]);
  930. memdelete(f);
  931. }
  932. }
  933. Vector<String> EditorSettings::get_favorites() const {
  934. return favorites;
  935. }
  936. void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) {
  937. recent_dirs = p_recent_dirs;
  938. FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::WRITE);
  939. if (f) {
  940. for (int i = 0; i < recent_dirs.size(); i++)
  941. f->store_line(recent_dirs[i]);
  942. memdelete(f);
  943. }
  944. }
  945. Vector<String> EditorSettings::get_recent_dirs() const {
  946. return recent_dirs;
  947. }
  948. void EditorSettings::load_favorites() {
  949. FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::READ);
  950. if (f) {
  951. String line = f->get_line().strip_edges();
  952. while (line != "") {
  953. favorites.push_back(line);
  954. line = f->get_line().strip_edges();
  955. }
  956. memdelete(f);
  957. }
  958. f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::READ);
  959. if (f) {
  960. String line = f->get_line().strip_edges();
  961. while (line != "") {
  962. recent_dirs.push_back(line);
  963. line = f->get_line().strip_edges();
  964. }
  965. memdelete(f);
  966. }
  967. }
  968. bool EditorSettings::is_dark_theme() {
  969. int AUTO_COLOR = 0;
  970. int LIGHT_COLOR = 2;
  971. Color base_color = get("interface/theme/base_color");
  972. int icon_font_color_setting = get("interface/theme/icon_and_font_color");
  973. return (icon_font_color_setting == AUTO_COLOR && ((base_color.r + base_color.g + base_color.b) / 3.0) < 0.5) || icon_font_color_setting == LIGHT_COLOR;
  974. }
  975. void EditorSettings::list_text_editor_themes() {
  976. String themes = "Adaptive,Default,Custom";
  977. DirAccess *d = DirAccess::open(get_text_editor_themes_dir());
  978. if (d) {
  979. List<String> custom_themes;
  980. d->list_dir_begin();
  981. String file = d->get_next();
  982. while (file != String()) {
  983. if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive" && file.get_basename().to_lower() != "custom") {
  984. custom_themes.push_back(file.get_basename());
  985. }
  986. file = d->get_next();
  987. }
  988. d->list_dir_end();
  989. memdelete(d);
  990. custom_themes.sort();
  991. for (List<String>::Element *E = custom_themes.front(); E; E = E->next()) {
  992. themes += "," + E->get();
  993. }
  994. }
  995. add_property_hint(PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, themes));
  996. }
  997. void EditorSettings::load_text_editor_theme() {
  998. if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") {
  999. if (get("text_editor/theme/color_theme") == "Default") {
  1000. _load_default_text_editor_theme();
  1001. }
  1002. return; // sorry for "Settings changed" console spam
  1003. }
  1004. String theme_path = get_text_editor_themes_dir().plus_file((String)get("text_editor/theme/color_theme") + ".tet");
  1005. Ref<ConfigFile> cf = memnew(ConfigFile);
  1006. Error err = cf->load(theme_path);
  1007. if (err != OK) {
  1008. return;
  1009. }
  1010. List<String> keys;
  1011. cf->get_section_keys("color_theme", &keys);
  1012. for (List<String>::Element *E = keys.front(); E; E = E->next()) {
  1013. String key = E->get();
  1014. String val = cf->get_value("color_theme", key);
  1015. // don't load if it's not already there!
  1016. if (has_setting("text_editor/highlighting/" + key)) {
  1017. // make sure it is actually a color
  1018. if (val.is_valid_html_color() && key.find("color") >= 0) {
  1019. props["text_editor/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
  1020. }
  1021. }
  1022. }
  1023. emit_signal("settings_changed");
  1024. // if it doesn't load just use what is currently loaded
  1025. }
  1026. bool EditorSettings::import_text_editor_theme(String p_file) {
  1027. if (!p_file.ends_with(".tet")) {
  1028. return false;
  1029. } else {
  1030. if (p_file.get_file().to_lower() == "default.tet") {
  1031. return false;
  1032. }
  1033. DirAccess *d = DirAccess::open(get_text_editor_themes_dir());
  1034. if (d) {
  1035. d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file()));
  1036. memdelete(d);
  1037. return true;
  1038. }
  1039. }
  1040. return false;
  1041. }
  1042. bool EditorSettings::save_text_editor_theme() {
  1043. String p_file = get("text_editor/theme/color_theme");
  1044. if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive" || p_file.get_file().to_lower() == "custom") {
  1045. return false;
  1046. }
  1047. String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet");
  1048. return _save_text_editor_theme(theme_path);
  1049. }
  1050. bool EditorSettings::save_text_editor_theme_as(String p_file) {
  1051. if (!p_file.ends_with(".tet")) {
  1052. p_file += ".tet";
  1053. }
  1054. 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") {
  1055. return false;
  1056. }
  1057. if (_save_text_editor_theme(p_file)) {
  1058. // switch to theme is saved in the theme directory
  1059. list_text_editor_themes();
  1060. String theme_name = p_file.substr(0, p_file.length() - 4).get_file();
  1061. if (p_file.get_base_dir() == get_text_editor_themes_dir()) {
  1062. _initial_set("text_editor/theme/color_theme", theme_name);
  1063. load_text_editor_theme();
  1064. }
  1065. return true;
  1066. }
  1067. return false;
  1068. }
  1069. Vector<String> EditorSettings::get_script_templates(const String &p_extension) {
  1070. Vector<String> templates;
  1071. DirAccess *d = DirAccess::open(get_script_templates_dir());
  1072. if (d) {
  1073. d->list_dir_begin();
  1074. String file = d->get_next();
  1075. while (file != String()) {
  1076. if (file.get_extension() == p_extension) {
  1077. templates.push_back(file.get_basename());
  1078. }
  1079. file = d->get_next();
  1080. }
  1081. d->list_dir_end();
  1082. memdelete(d);
  1083. }
  1084. return templates;
  1085. }
  1086. String EditorSettings::get_editor_layouts_config() const {
  1087. return get_settings_dir().plus_file("editor_layouts.cfg");
  1088. }
  1089. // Shortcuts
  1090. void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) {
  1091. shortcuts[p_name] = p_shortcut;
  1092. }
  1093. bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const {
  1094. const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name);
  1095. if (!E) {
  1096. ERR_EXPLAIN("Unknown Shortcut: " + p_name);
  1097. ERR_FAIL_V(false);
  1098. }
  1099. return E->get()->is_shortcut(p_event);
  1100. }
  1101. Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const {
  1102. const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name);
  1103. if (!E)
  1104. return Ref<ShortCut>();
  1105. return E->get();
  1106. }
  1107. void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
  1108. for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) {
  1109. r_shortcuts->push_back(E->key());
  1110. }
  1111. }
  1112. Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
  1113. Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
  1114. if (!sc.is_valid()) {
  1115. ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path);
  1116. ERR_FAIL_COND_V(!sc.is_valid(), sc);
  1117. }
  1118. return sc;
  1119. }
  1120. struct ShortCutMapping {
  1121. const char *path;
  1122. uint32_t keycode;
  1123. };
  1124. Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) {
  1125. #ifdef OSX_ENABLED
  1126. // Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
  1127. if (p_keycode == KEY_DELETE) {
  1128. p_keycode = KEY_MASK_CMD | KEY_BACKSPACE;
  1129. }
  1130. #endif
  1131. Ref<InputEventKey> ie;
  1132. if (p_keycode) {
  1133. ie.instance();
  1134. ie->set_unicode(p_keycode & KEY_CODE_MASK);
  1135. ie->set_scancode(p_keycode & KEY_CODE_MASK);
  1136. ie->set_shift(bool(p_keycode & KEY_MASK_SHIFT));
  1137. ie->set_alt(bool(p_keycode & KEY_MASK_ALT));
  1138. ie->set_control(bool(p_keycode & KEY_MASK_CTRL));
  1139. ie->set_metakey(bool(p_keycode & KEY_MASK_META));
  1140. }
  1141. Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
  1142. if (sc.is_valid()) {
  1143. sc->set_name(p_name); //keep name (the ones that come from disk have no name)
  1144. sc->set_meta("original", ie); //to compare against changes
  1145. return sc;
  1146. }
  1147. sc.instance();
  1148. sc->set_name(p_name);
  1149. sc->set_shortcut(ie);
  1150. sc->set_meta("original", ie); //to compare against changes
  1151. EditorSettings::get_singleton()->add_shortcut(p_path, sc);
  1152. return sc;
  1153. }
  1154. void EditorSettings::notify_changes() {
  1155. _THREAD_SAFE_METHOD_
  1156. SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
  1157. if (!sml) {
  1158. return;
  1159. }
  1160. Node *root = sml->get_root()->get_child(0);
  1161. if (!root) {
  1162. return;
  1163. }
  1164. root->propagate_notification(NOTIFICATION_EDITOR_SETTINGS_CHANGED);
  1165. }
  1166. void EditorSettings::_bind_methods() {
  1167. ClassDB::bind_method(D_METHOD("has_setting", "name"), &EditorSettings::has_setting);
  1168. ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &EditorSettings::set_setting);
  1169. ClassDB::bind_method(D_METHOD("get_setting", "name"), &EditorSettings::get_setting);
  1170. ClassDB::bind_method(D_METHOD("erase", "property"), &EditorSettings::erase);
  1171. ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value", "update_current"), &EditorSettings::set_initial_value);
  1172. ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &EditorSettings::property_can_revert);
  1173. ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &EditorSettings::property_get_revert);
  1174. ClassDB::bind_method(D_METHOD("add_property_info", "info"), &EditorSettings::_add_property_info_bind);
  1175. ClassDB::bind_method(D_METHOD("get_settings_dir"), &EditorSettings::get_settings_dir);
  1176. ClassDB::bind_method(D_METHOD("get_project_settings_dir"), &EditorSettings::get_project_settings_dir);
  1177. ClassDB::bind_method(D_METHOD("set_project_metadata", "section", "key", "data"), &EditorSettings::set_project_metadata);
  1178. ClassDB::bind_method(D_METHOD("get_project_metadata", "section", "key", "default"), &EditorSettings::get_project_metadata, DEFVAL(Variant()));
  1179. ClassDB::bind_method(D_METHOD("set_favorites", "dirs"), &EditorSettings::set_favorites);
  1180. ClassDB::bind_method(D_METHOD("get_favorites"), &EditorSettings::get_favorites);
  1181. ClassDB::bind_method(D_METHOD("set_recent_dirs", "dirs"), &EditorSettings::set_recent_dirs);
  1182. ClassDB::bind_method(D_METHOD("get_recent_dirs"), &EditorSettings::get_recent_dirs);
  1183. ADD_SIGNAL(MethodInfo("settings_changed"));
  1184. }
  1185. EditorSettings::EditorSettings() {
  1186. last_order = 0;
  1187. optimize_save = true;
  1188. save_changed_setting = true;
  1189. _load_defaults();
  1190. }
  1191. EditorSettings::~EditorSettings() {
  1192. }