diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2017-03-24 13:47:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 13:47:19 +0300 |
commit | 329ceb1e6eebb9707c0a17431729fcf89755b0fc (patch) | |
tree | a2169f35500d066ec299db8198351555434625c3 /indexer | |
parent | 778f13e23b4b3dd635835ec2e74d4f542f2edcda (diff) | |
parent | 3bcb803b554991ce886642ce73d83f5797ef6fa0 (diff) |
Merge pull request #5682 from rokuz/styles-override
Added styles overrides
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/map_style_reader.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/indexer/map_style_reader.cpp b/indexer/map_style_reader.cpp index fbf8d2f6d6..68f38a7213 100644 --- a/indexer/map_style_reader.cpp +++ b/indexer/map_style_reader.cpp @@ -6,15 +6,17 @@ #include "platform/platform.hpp" -#include "std/string.hpp" +#include <string> namespace { -const char * const kSuffixDark = "_dark"; -const char * const kSuffixClear = "_clear"; -const char * const kSuffixVehicleDark = "_vehicle_dark"; -const char * const kSuffixVehicleClear = "_vehicle_clear"; +std::string const kSuffixDark = "_dark"; +std::string const kSuffixClear = "_clear"; +std::string const kSuffixVehicleDark = "_vehicle_dark"; +std::string const kSuffixVehicleClear = "_vehicle_clear"; + +std::string const kStylesOverrideDir = "styles"; string GetStyleRulesSuffix(MapStyle mapStyle) { @@ -79,14 +81,25 @@ MapStyle StyleReader::GetCurrentStyle() ReaderPtr<Reader> StyleReader::GetDrawingRulesReader() { - string const rulesFile = string("drules_proto") + GetStyleRulesSuffix(GetCurrentStyle()) + ".bin"; + string rulesFile = string("drules_proto") + GetStyleRulesSuffix(GetCurrentStyle()) + ".bin"; + + auto overriddenRulesFile = my::JoinFoldersToPath({GetPlatform().WritableDir(), kStylesOverrideDir}, rulesFile); + if (GetPlatform().IsFileExistsByFullPath(overriddenRulesFile)) + rulesFile = overriddenRulesFile; + return GetPlatform().GetReader(rulesFile); } ReaderPtr<Reader> StyleReader::GetResourceReader(string const & file, string const & density) { string const resourceDir = string("resources-") + density + GetStyleResourcesSuffix(GetCurrentStyle()); - return GetPlatform().GetReader(my::JoinFoldersToPath(resourceDir, file)); + string resFile = my::JoinFoldersToPath(resourceDir, file); + + auto overriddenResFile = my::JoinFoldersToPath({GetPlatform().WritableDir(), kStylesOverrideDir}, resFile); + if (GetPlatform().IsFileExistsByFullPath(overriddenResFile)) + resFile = overriddenResFile; + + return GetPlatform().GetReader(resFile); } StyleReader & GetStyleReader() |