| 320 | } |
| 321 | |
| 322 | void gdre::get_strings_from_variant(const Variant &p_var, Vector<String> &r_strings, const String &engine_version) { |
| 323 | // resource_paths are handled seperately, resource_scene_unique_id is generated by Godot and not useful for translation |
| 324 | static const HashSet<String> skip_properties = { "resource_path", "resource_scene_unique_id" }; |
| 325 | if (p_var.get_type() == Variant::STRING || p_var.get_type() == Variant::STRING_NAME) { |
| 326 | r_strings.push_back(p_var); |
| 327 | } else if (p_var.get_type() == Variant::PACKED_STRING_ARRAY) { |
| 328 | Vector<String> p_strings = p_var; |
| 329 | for (auto &E : p_strings) { |
| 330 | r_strings.push_back(E); |
| 331 | } |
| 332 | } else if (p_var.get_type() == Variant::ARRAY) { |
| 333 | Array arr = p_var; |
| 334 | for (int i = 0; i < arr.size(); i++) { |
| 335 | get_strings_from_variant(arr[i], r_strings, engine_version); |
| 336 | } |
| 337 | } else if (p_var.get_type() == Variant::DICTIONARY) { |
| 338 | Dictionary d = p_var; |
| 339 | Array keys = d.keys(); |
| 340 | for (int i = 0; i < keys.size(); i++) { |
| 341 | get_strings_from_variant(keys[i], r_strings, engine_version); |
| 342 | get_strings_from_variant(d[keys[i]], r_strings, engine_version); |
| 343 | } |
| 344 | } else if (p_var.get_type() == Variant::OBJECT) { |
| 345 | Object *obj = Object::cast_to<Object>(p_var); |
| 346 | if (obj) { |
| 347 | List<PropertyInfo> p_list; |
| 348 | obj->get_property_list(&p_list); |
| 349 | for (List<PropertyInfo>::Element *E = p_list.front(); E; E = E->next()) { |
| 350 | auto &p = E->get(); |
| 351 | if (!skip_properties.has(p.name)) { |
| 352 | get_strings_from_variant(obj->get(p.name), r_strings, engine_version); |
| 353 | } |
| 354 | } |
| 355 | List<StringName> m_list; |
| 356 | obj->get_meta_list(&m_list); |
| 357 | for (auto &name : m_list) { |
| 358 | get_strings_from_variant(obj->get_meta(name), r_strings, engine_version); |
| 359 | } |
| 360 | if (!engine_version.is_empty()) { |
| 361 | if (obj->get_save_class() == "GDScript") { |
| 362 | String code = obj->get("script/source"); |
| 363 | if (!code.is_empty()) { |
| 364 | auto decomp = GDScriptDecomp::create_decomp_for_version(engine_version, true); |
| 365 | if (!decomp.is_null()) { |
| 366 | auto buf = decomp->compile_code_string(code); |
| 367 | if (!buf.is_empty()) { |
| 368 | decomp->get_script_strings_from_buf(buf, r_strings, true); |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | String gdre::remove_url_query_params(const String &p_url) { |
| 379 | String base = p_url.get_base_dir(); |
nothing calls this directly
no test coverage detected