| 1253 | } |
| 1254 | |
| 1255 | Variant EditorSettings::get_setting_directly(const String &p_setting, const Variant &p_default) { |
| 1256 | if (!EditorPaths::get_singleton() || !EditorPaths::get_singleton()->are_paths_valid()) { |
| 1257 | return p_default; |
| 1258 | } |
| 1259 | |
| 1260 | String config_file_path = get_existing_settings_path(); |
| 1261 | if (config_file_path.is_empty() || !FileAccess::exists(config_file_path)) { |
| 1262 | return p_default; |
| 1263 | } |
| 1264 | |
| 1265 | Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ); |
| 1266 | if (f.is_null()) { |
| 1267 | return p_default; |
| 1268 | } |
| 1269 | |
| 1270 | VariantParser::StreamFile stream; |
| 1271 | stream.f = f; |
| 1272 | String assign; |
| 1273 | Variant value; |
| 1274 | VariantParser::Tag next_tag; |
| 1275 | int lines = 0; |
| 1276 | String error_text; |
| 1277 | VariantParser::ResourceParser rp_new; |
| 1278 | rp_new.ext_func = _parse_direct_resource_dummy; |
| 1279 | rp_new.sub_func = _parse_direct_resource_dummy; |
| 1280 | |
| 1281 | while (true) { |
| 1282 | assign = Variant(); |
| 1283 | next_tag.fields.clear(); |
| 1284 | next_tag.name = String(); |
| 1285 | Error err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new, true, true); |
| 1286 | if (err == ERR_FILE_EOF) { |
| 1287 | break; |
| 1288 | } |
| 1289 | if (err == OK && !assign.is_empty() && assign == p_setting) { |
| 1290 | return value; |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | return p_default; |
| 1295 | } |
| 1296 | |
| 1297 | Color EditorSettings::get_default_base_color() { |
| 1298 | return Color(0.06, 0.09, 0.14); |