diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 58309e1..63f8c53 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -100,16 +100,21 @@ void Mass::refreshValues() { return; } - auto name_prop = unit_data->at("Name_45_A037C5D54E53456407BDF091344529BB"); + // region MassName + { + auto name_prop = unit_data->at("Name_45_A037C5D54E53456407BDF091344529BB"); - if(!name_prop) { - _name = Containers::NullOpt; - _state = State::Invalid; - return; + if(!name_prop) { + _name = Containers::NullOpt; + _state = State::Invalid; + return; + } + + _name = name_prop->value; } + // endregion - _name = name_prop->value; - + // region FrameData { auto frame_prop = unit_data->at("Frame_3_F92B0F6A44A15088AF7F41B9FF290653"); @@ -154,6 +159,115 @@ void Mass::refreshValues() { _frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a}; } + // endregion + + // region FrameStyles + { + auto frame_styles = unit_data->at("FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA"); + if(!frame_styles) { + _state = State::Invalid; + 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); + } + } + // endregion + + // TODO: armour + + // region ArmourStyles + { + auto armour_styles = unit_data->at("ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E"); + if(!armour_styles) { + _state = State::Invalid; + 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); + } + } + // endregion + + // TODO: weapons + + // region GlobalStyles + { + auto global_styles = unit_data->at("GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B"); + if(!global_styles) { + _state = State::Invalid; + 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); + } + } + // endregion + + // TODO: tuning auto account_prop = _mass->at("Account"); if(!account_prop) { @@ -383,6 +497,48 @@ auto Mass::setEyeFlareColour(Color4 new_colour) -> bool { return _mass->saveToFile(); } +auto Mass::frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> { + return _frame.customStyles; +} + +auto Mass::setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool { + if(index > _frame.customStyles.size()) { + return false; + } + + _frame.customStyles[index] = std::move(style); + + return setCustomStyle(_frame.customStyles[index], index, "FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA"); +} + +auto Mass::armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> { + return _armour.customStyles; +} + +auto Mass::setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool { + if(index > _armour.customStyles.size()) { + return false; + } + + _armour.customStyles[index] = std::move(style); + + return setCustomStyle(_armour.customStyles[index], index, "ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E"); +} + +auto Mass::globalStyles() -> Containers::StaticArrayView<16, CustomStyle> { + return _globalStyles; +} + +auto Mass::setGlobalStyle(CustomStyle style, UnsignedLong index) -> bool { + if(index > _globalStyles.size()) { + return false; + } + + _globalStyles[index] = std::move(style); + + return setCustomStyle(_globalStyles[index], index, "GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B"); +} + auto Mass::updateSteamId(const std::string& steam_id) -> bool { _steamId = steam_id; @@ -402,3 +558,37 @@ auto Mass::updateSteamId(const std::string& steam_id) -> bool { return _mass->saveToFile(); } + +auto Mass::setCustomStyle(const CustomStyle& style, UnsignedLong index, const char* prop_name) -> bool { + auto unit_data = _mass->at("UnitData"); + if(!unit_data) { + _state = State::Invalid; + return false; + } + + auto frame_styles = unit_data->at(prop_name); + if(!frame_styles) { + _state = State::Invalid; + return false; + } + + auto style_prop = frame_styles->at(index); + + style_prop->at("Name_27_1532115A46EF2B2FA283908DF561A86B")->value = style.name; + auto colour_prop = style_prop->at("Color_5_F0D383DF40474C9464AE48A0984A212E"); + colour_prop->r = style.colour.r(); + colour_prop->g = style.colour.g(); + colour_prop->b = style.colour.b(); + colour_prop->a = style.glow ? 1.0f : 0.0f; + style_prop->at("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value = style.metallic; + style_prop->at("Gloss_11_9769599842CC275A401C4282A236E240")->value = style.gloss; + + style_prop->at("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value = style.patternId; + style_prop->at("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value = style.opacity; + style_prop->at("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value = style.offset.x(); + style_prop->at("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value = style.offset.y(); + style_prop->at("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value = style.rotation; + style_prop->at("Scale_26_19DF0708409262183E1247B317137671")->value = style.scale; + + return _mass->saveToFile(); +} diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index 916e1ea..f2cd17c 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -147,9 +147,20 @@ class Mass { auto eyeFlareColour() const -> Color4 const&; auto setEyeFlareColour(Color4 new_colour) -> bool; + auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; + auto setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool; + + auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; + auto setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool; + + auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>; + auto setGlobalStyle(CustomStyle style, UnsignedLong index) -> bool; + auto updateSteamId(const std::string& steam_id) -> bool; private: + auto setCustomStyle(const CustomStyle& style, UnsignedLong index, const char* prop_name) -> bool; + Containers::Optional _mass; static std::string _lastError;