From e461d5a505d1d15db715827b64fb1ce373de6dd7 Mon Sep 17 00:00:00 2001 From: William JCM Date: Sun, 17 Oct 2021 15:28:54 +0200 Subject: [PATCH] Mass: add getCustomStyles(); --- src/Mass/Mass.cpp | 95 +++++++++++++---------------------------------- src/Mass/Mass.h | 1 + 2 files changed, 27 insertions(+), 69 deletions(-) diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 0e181d4..00df6a0 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -528,29 +528,7 @@ void Mass::getFrameCustomStyles() { return; } - for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) { - auto style_prop = frame_styles->at(i); - - CustomStyle style; - - style.name = style_prop->at("Name_27_1532115A46EF2B2FA283908DF561A86B")->value; - auto colour_prop = style_prop->at("Color_5_F0D383DF40474C9464AE48A0984A212E"); - style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; - style.metallic = style_prop->at("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value; - style.gloss = style_prop->at("Gloss_11_9769599842CC275A401C4282A236E240")->value; - style.glow = colour_prop->a == 0.0f ? false : true; - - style.patternId = style_prop->at("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value; - style.opacity = style_prop->at("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value; - style.offset = Vector2{ - style_prop->at("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value, - style_prop->at("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value - }; - style.rotation = style_prop->at("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value; - style.scale = style_prop->at("Scale_26_19DF0708409262183E1247B317137671")->value; - - _frame.customStyles[i] = std::move(style); - } + getCustomStyles(_frame.customStyles, frame_styles); } auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool { @@ -805,29 +783,7 @@ void Mass::getArmourCustomStyles() { return; } - for(UnsignedInt i = 0; i < armour_styles->items.size(); i++) { - auto style_prop = armour_styles->at(i); - - CustomStyle style; - - style.name = style_prop->at("Name_27_1532115A46EF2B2FA283908DF561A86B")->value; - auto colour_prop = style_prop->at("Color_5_F0D383DF40474C9464AE48A0984A212E"); - style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; - style.metallic = style_prop->at("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value; - style.gloss = style_prop->at("Gloss_11_9769599842CC275A401C4282A236E240")->value; - style.glow = colour_prop->a == 0.0f ? false : true; - - style.patternId = style_prop->at("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value; - style.opacity = style_prop->at("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value; - style.offset = Vector2{ - style_prop->at("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value, - style_prop->at("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value - }; - style.rotation = style_prop->at("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value; - style.scale = style_prop->at("Scale_26_19DF0708409262183E1247B317137671")->value; - - _armour.customStyles[i] = std::move(style); - } + getCustomStyles(_armour.customStyles, armour_styles); } auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool { @@ -920,29 +876,7 @@ void Mass::getGlobalStyles() { return; } - for(UnsignedInt i = 0; i < global_styles->items.size(); i++) { - auto style_prop = global_styles->at(i); - - CustomStyle style; - - style.name = style_prop->at("Name_27_1532115A46EF2B2FA283908DF561A86B")->value; - auto colour_prop = style_prop->at("Color_5_F0D383DF40474C9464AE48A0984A212E"); - style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; - style.metallic = style_prop->at("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value; - style.gloss = style_prop->at("Gloss_11_9769599842CC275A401C4282A236E240")->value; - style.glow = colour_prop->a == 0.0f ? false : true; - - style.patternId = style_prop->at("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value; - style.opacity = style_prop->at("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value; - style.offset = Vector2{ - style_prop->at("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value, - style_prop->at("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value - }; - style.rotation = style_prop->at("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value; - style.scale = style_prop->at("Scale_26_19DF0708409262183E1247B317137671")->value; - - _globalStyles[i] = std::move(style); - } + getCustomStyles(_globalStyles, global_styles); } auto Mass::writeGlobalStyle(UnsignedLong index) -> bool { @@ -979,6 +913,29 @@ auto Mass::updateSteamId(const std::string& steam_id) -> bool { return _mass->saveToFile(); } +void Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array) { + for(UnsignedInt i = 0; i < style_array->items.size(); i++) { + auto style_prop = style_array->at(i); + auto& style = styles[i]; + + style.name = style_prop->at("Name_27_1532115A46EF2B2FA283908DF561A86B")->value; + auto colour_prop = style_prop->at("Color_5_F0D383DF40474C9464AE48A0984A212E"); + style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a}; + style.metallic = style_prop->at("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value; + style.gloss = style_prop->at("Gloss_11_9769599842CC275A401C4282A236E240")->value; + style.glow = colour_prop->a == 0.0f ? false : true; + + style.patternId = style_prop->at("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value; + style.opacity = style_prop->at("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value; + style.offset = Vector2{ + style_prop->at("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value, + style_prop->at("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value + }; + style.rotation = style_prop->at("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value; + style.scale = style_prop->at("Scale_26_19DF0708409262183E1247B317137671")->value; + } +} + auto Mass::setCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool { if(!style_array) { return false; diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index 57a289e..793f620 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -199,6 +199,7 @@ class Mass { auto updateSteamId(const std::string& steam_id) -> bool; private: + void getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array); auto setCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool; void getWeaponType(const char* prop_name, Containers::ArrayView weapon_array);