| 30 | using namespace tinyxml2; |
| 31 | namespace exporter { |
| 32 | static void ReadCommonConfig(XMLElement* commonElement, ConfigParam* configParam) { |
| 33 | if (!commonElement) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | if (XMLElement* tagLevelElement = commonElement->FirstChildElement("tag-level")) { |
| 38 | if (const auto tagModeText = GetChildElementText(tagLevelElement, "mode")) { |
| 39 | if (SafeStringEqual(tagModeText, "beta")) { |
| 40 | configParam->tagMode = TagMode::Beta; |
| 41 | } else if (SafeStringEqual(tagModeText, "custom")) { |
| 42 | configParam->tagMode = TagMode::Custom; |
| 43 | } else { |
| 44 | configParam->tagMode = TagMode::Stable; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | if (const auto customLevelText = GetChildElementText(tagLevelElement, "custom-level")) { |
| 49 | configParam->exportTagLevel = SafeStringToInt<uint16_t>(customLevelText, 1023); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if (const auto imageQualityText = GetChildElementText(commonElement, "image-quality")) { |
| 54 | configParam->imageQuality = SafeStringToInt(imageQualityText, 80); |
| 55 | } |
| 56 | |
| 57 | if (const auto imagePixelRatioText = GetChildElementText(commonElement, "image-pixel-ratio")) { |
| 58 | configParam->imagePixelRatio = SafeStringToFloat(imagePixelRatioText, 2.0f); |
| 59 | } |
| 60 | |
| 61 | if (const auto enableLayerNameText = GetChildElementText(commonElement, "enable-layer-name")) { |
| 62 | configParam->exportLayerName = SafeStringToInt(enableLayerNameText, 1) != 0; |
| 63 | } |
| 64 | |
| 65 | if (const auto enableFontFileText = GetChildElementText(commonElement, "enable-font-file")) { |
| 66 | configParam->exportFontFile = SafeStringToInt(enableFontFileText, 0) != 0; |
| 67 | } |
| 68 | |
| 69 | if (const auto exportScenseText = GetChildElementText(commonElement, "export-scense")) { |
| 70 | configParam->scenes = static_cast<ExportScenes>(SafeStringToInt(exportScenseText, 0)); |
| 71 | } |
| 72 | |
| 73 | if (const auto exportLanguageText = GetChildElementText(commonElement, "export-language")) { |
| 74 | configParam->language = static_cast<Language>(SafeStringToInt(exportLanguageText, 0)); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | static void ReadBitmapConfig(XMLElement* bitmapElement, ConfigParam* configParam) { |
| 79 | if (!bitmapElement) { |
no test coverage detected