Mass: add getCustomStyles();

This commit is contained in:
Guillaume Jacquemin 2021-10-17 15:28:54 +02:00
parent d79debe69f
commit e461d5a505
2 changed files with 27 additions and 69 deletions

View File

@ -528,29 +528,7 @@ void Mass::getFrameCustomStyles() {
return;
}
for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
auto style_prop = frame_styles->at<GenericStructProperty>(i);
CustomStyle style;
style.name = style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value;
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
style.metallic = style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value;
style.gloss = style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value;
style.glow = colour_prop->a == 0.0f ? false : true;
style.patternId = style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value;
style.opacity = style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value;
style.offset = Vector2{
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value,
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value
};
style.rotation = style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value;
style.scale = style_prop->at<FloatProperty>("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<GenericStructProperty>(i);
CustomStyle style;
style.name = style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value;
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
style.metallic = style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value;
style.gloss = style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value;
style.glow = colour_prop->a == 0.0f ? false : true;
style.patternId = style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value;
style.opacity = style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value;
style.offset = Vector2{
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value,
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value
};
style.rotation = style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value;
style.scale = style_prop->at<FloatProperty>("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<GenericStructProperty>(i);
CustomStyle style;
style.name = style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value;
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
style.metallic = style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value;
style.gloss = style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value;
style.glow = colour_prop->a == 0.0f ? false : true;
style.patternId = style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value;
style.opacity = style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value;
style.offset = Vector2{
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value,
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value
};
style.rotation = style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value;
style.scale = style_prop->at<FloatProperty>("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<CustomStyle> styles, ArrayProperty* style_array) {
for(UnsignedInt i = 0; i < style_array->items.size(); i++) {
auto style_prop = style_array->at<GenericStructProperty>(i);
auto& style = styles[i];
style.name = style_prop->at<StringProperty>("Name_27_1532115A46EF2B2FA283908DF561A86B")->value;
auto colour_prop = style_prop->at<ColourStructProperty>("Color_5_F0D383DF40474C9464AE48A0984A212E");
style.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
style.metallic = style_prop->at<FloatProperty>("Metallic_10_0A4CD1E4482CBF41CA61D0A856DE90B9")->value;
style.gloss = style_prop->at<FloatProperty>("Gloss_11_9769599842CC275A401C4282A236E240")->value;
style.glow = colour_prop->a == 0.0f ? false : true;
style.patternId = style_prop->at<IntProperty>("PatternID_14_516DB85641DAF8ECFD2920BE2BDF1311")->value;
style.opacity = style_prop->at<FloatProperty>("Opacity_30_53BD060B4DFCA1C92302D6A0F7831131")->value;
style.offset = Vector2{
style_prop->at<FloatProperty>("OffsetX_23_70FC2E814C64BBB82452748D2AF9CD48")->value,
style_prop->at<FloatProperty>("OffsetY_24_5E1F866C4C054D9B2EE337ADC180C17F")->value
};
style.rotation = style_prop->at<FloatProperty>("Rotation_25_EC2DFAD84AD0A6BD3FA841ACD52EDD6D")->value;
style.scale = style_prop->at<FloatProperty>("Scale_26_19DF0708409262183E1247B317137671")->value;
}
}
auto Mass::setCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool {
if(!style_array) {
return false;

View File

@ -199,6 +199,7 @@ class Mass {
auto updateSteamId(const std::string& steam_id) -> bool;
private:
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array);
auto setCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool;
void getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array);