diff options
author | Hop311 <hop3114@gmail.com> | 2023-04-05 18:14:32 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-04-05 18:14:32 +0200 |
commit | 29b334995b084e5d6944c45b7950c88f370941cc (patch) | |
tree | 72b25ee452c934980c5c7e5e3ce7e6e1c5276ac0 /extension/src/MapSingleton.cpp | |
parent | d3c7e9b27ba60550b23efb9e37cc66b91de0c795 (diff) |
Input and province selection cleanup
Diffstat (limited to 'extension/src/MapSingleton.cpp')
-rw-r--r-- | extension/src/MapSingleton.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/extension/src/MapSingleton.cpp b/extension/src/MapSingleton.cpp index 9f76508..9d13496 100644 --- a/extension/src/MapSingleton.cpp +++ b/extension/src/MapSingleton.cpp @@ -13,7 +13,7 @@ void MapSingleton::_bind_methods() { ClassDB::bind_method(D_METHOD("load_province_identifier_file", "file_path"), &MapSingleton::load_province_identifier_file); ClassDB::bind_method(D_METHOD("load_province_shape_file", "file_path"), &MapSingleton::load_province_shape_file); ClassDB::bind_method(D_METHOD("get_province_shape_image"), &MapSingleton::get_province_shape_image); - ClassDB::bind_method(D_METHOD("get_province_id"), &MapSingleton::get_province_id); + ClassDB::bind_method(D_METHOD("get_province_identifier_from_colour", "colour"), &MapSingleton::get_province_identifier_from_colour); } MapSingleton* MapSingleton::get_singleton() { @@ -64,9 +64,9 @@ Error MapSingleton::load_province_identifier_file(String const& file_path) { err = FAILED; continue; } - // static const String prov_prefix = "prov_"; - // if (!identifier.begins_with(prov_prefix)) - // UtilityFunctions::push_warning("Province identifier missing prefix: ", identifier); + static const String prov_prefix = "prov_"; + if (!identifier.begins_with(prov_prefix)) + UtilityFunctions::push_warning("Province identifier missing prefix: ", identifier); type = colour_var.get_type(); Province::colour_t colour = Province::NULL_COLOUR; if (type == Variant::ARRAY) { @@ -115,12 +115,10 @@ Error MapSingleton::load_province_identifier_file(String const& file_path) { return err; } -godot::String MapSingleton::get_province_id(godot::String const& hex_str) { - UtilityFunctions::print(hex_str); - int64_t colour_string = hex_str.hex_to_int(); - godot::String province_id = map.get_province(colour_string).identifier.c_str(); - UtilityFunctions::print("Returning: ",map.get_province(colour_string).to_string().c_str()); - return province_id; +String MapSingleton::get_province_identifier_from_colour(Province::colour_t colour) { + const Province* province = map.get_province_by_colour(colour); + if (province) return province->get_identifier().c_str(); + else return String{}; } Error MapSingleton::load_province_shape_file(String const& file_path) { |