Compare commits

..

6 commits

Author SHA1 Message Date
a22aa6f7ae Mass: update CustomStyle default values to match game. 2021-10-05 10:10:18 +02:00
d03e75a8e9 Mass: not all parts can have 8 decals in the demo.
For now, at least. Just like the code that treats a lack of global
styles as a demo thing, I'll remove it in due time.
2021-10-05 10:03:52 +02:00
4429e581f3 Mass: reorganise a whole chunk of code. 2021-10-04 18:18:53 +02:00
2d0d5817f2 SaveTool: add a basic guide to the help menu. 2021-10-04 18:18:20 +02:00
bfe9a2c3a8 Profile: fix a crash that happens when restoring a backup. 2021-10-04 18:17:51 +02:00
8c81b7811b Mass: add support for reading armour parts. 2021-10-03 16:32:47 +02:00
4 changed files with 442 additions and 211 deletions

View file

@ -22,11 +22,16 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/ArrayProperty.h"
#include "../UESaveFile/Types/BoolProperty.h"
#include "../UESaveFile/Types/ByteProperty.h"
#include "../UESaveFile/Types/ColourStructProperty.h" #include "../UESaveFile/Types/ColourStructProperty.h"
#include "../UESaveFile/Types/FloatProperty.h" #include "../UESaveFile/Types/FloatProperty.h"
#include "../UESaveFile/Types/GenericStructProperty.h" #include "../UESaveFile/Types/GenericStructProperty.h"
#include "../UESaveFile/Types/IntProperty.h" #include "../UESaveFile/Types/IntProperty.h"
#include "../UESaveFile/Types/RotatorStructProperty.h"
#include "../UESaveFile/Types/StringProperty.h" #include "../UESaveFile/Types/StringProperty.h"
#include "../UESaveFile/Types/VectorStructProperty.h"
#include "../UESaveFile/Types/Vector2DStructProperty.h"
#include "Mass.h" #include "Mass.h"
@ -94,198 +99,57 @@ void Mass::refreshValues() {
} }
auto unit_data = _mass->at<GenericStructProperty>("UnitData"); auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) { if(!unit_data) {
_state = State::Invalid; _state = State::Invalid;
return; return;
} }
// region MassName auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
{
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
if(!name_prop) { if(!name_prop) {
_name = Containers::NullOpt; _name = Containers::NullOpt;
_state = State::Invalid; _state = State::Invalid;
return; return;
}
_name = name_prop->value;
} }
// endregion
// region FrameData _name = name_prop->value;
{
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
if(!frame_prop) { getJointSliders();
_state = State::Invalid; if(_state == State::Invalid) {
return; return;
}
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
_frame.joints.neck = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
_frame.joints.body = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
_frame.joints.shoulders = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
_frame.joints.hips = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
_frame.joints.upperArms = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
_frame.joints.lowerArms = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
_frame.joints.upperLegs = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
_frame.joints.lowerLegs = (length ? length->value : 0.0f);
auto frame_styles = frame_prop->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
if(!frame_styles) {
_state = State::Invalid;
return;
}
if(frame_styles->items.size() != 4) {
_state = State::Invalid;
return;
}
for(UnsignedInt i = 0; i < 4; i++) {
_frame.styles[i] = frame_styles->at<IntProperty>(i)->value;
}
auto eye_flare_prop = frame_prop->at<ColourStructProperty>("EyeFlareColor_36_AF79999C40FCA0E88A2F9A84488A38CA");
if(!eye_flare_prop) {
_state = State::Invalid;
return;
}
_frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a};
} }
// endregion
// region FrameStyles getFrameStyles();
{ if(_state == State::Invalid) {
auto frame_styles = unit_data->at<ArrayProperty>("FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA"); return;
if(!frame_styles) {
_state = State::Invalid;
return;
}
if(frame_styles->items.size() != 16) {
_state = State::Invalid;
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);
}
} }
// endregion
// TODO: armour getEyeFlareColour();
if(_state == State::Invalid) {
// region ArmourStyles return;
{ }
auto armour_styles = unit_data->at<ArrayProperty>("ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
if(!armour_styles) { getFrameCustomStyles();
_state = State::Invalid; if(_state == State::Invalid) {
return; return;
} }
if(armour_styles->items.size() != 16) { getArmourParts();
_state = State::Invalid; if(_state == State::Invalid) {
return; return;
} }
for(UnsignedInt i = 0; i < armour_styles->items.size(); i++) { getArmourCustomStyles();
auto style_prop = armour_styles->at<GenericStructProperty>(i); if(_state == State::Invalid) {
return;
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);
}
} }
// endregion
// TODO: weapons // TODO: weapons
// region GlobalStyles if(!_demo)
{ {
auto global_styles = unit_data->at<ArrayProperty>("GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B"); getGlobalStyles();
if(!global_styles) {
_state = State::Invalid;
return;
}
if(global_styles->items.size() != 16) {
_state = State::Invalid;
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);
}
} }
// endregion
// TODO: tuning // TODO: tuning
@ -334,6 +198,10 @@ auto Mass::state() -> State {
return _state; return _state;
} }
auto Mass::demo() const -> bool {
return _demo;
}
auto Mass::dirty() const -> bool { auto Mass::dirty() const -> bool {
return _dirty; return _dirty;
} }
@ -342,17 +210,47 @@ void Mass::setDirty(bool dirty) {
_dirty = dirty; _dirty = dirty;
} }
auto Mass::jointSliders() const -> Joints const& { auto Mass::jointSliders() -> Joints& {
return _frame.joints; return _frame.joints;
} }
auto Mass::setSliders(Joints joints) -> bool { void Mass::getJointSliders() {
_frame.joints = joints; auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
if(!frame_prop) {
_state = State::Invalid;
return;
}
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
_frame.joints.neck = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
_frame.joints.body = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
_frame.joints.shoulders = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
_frame.joints.hips = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
_frame.joints.upperArms = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
_frame.joints.lowerArms = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
_frame.joints.upperLegs = (length ? length->value : 0.0f);
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
_frame.joints.lowerLegs = (length ? length->value : 0.0f);
}
auto Mass::writeJointSliders() -> bool {
auto unit_data = _mass->at<GenericStructProperty>("UnitData"); auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) { if(!unit_data) {
_state = State::Invalid; _state = State::Invalid;
_lastError = "No unit data in " + _filename;
return false; return false;
} }
@ -360,6 +258,7 @@ auto Mass::setSliders(Joints joints) -> bool {
if(!frame_prop) { if(!frame_prop) {
_state = State::Invalid; _state = State::Invalid;
_lastError = "No frame data in " + _filename;
return false; return false;
} }
@ -451,46 +350,108 @@ auto Mass::setSliders(Joints joints) -> bool {
length->value = _frame.joints.lowerLegs; length->value = _frame.joints.lowerLegs;
} }
return _mass->saveToFile(); if(!_mass->saveToFile()) {
_lastError = "Couldn't write data to " + _filename;
return false;
}
return true;
} }
auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> { auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> {
return _frame.styles; return _frame.styles;
} }
auto Mass::setFrameStyle(Int index, Int style_id) -> bool { void Mass::getFrameStyles() {
_frame.styles[index] = style_id;
auto unit_data = _mass->at<GenericStructProperty>("UnitData"); auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) { if(!unit_data) {
_state = State::Invalid; _state = State::Invalid;
return;
}
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
if(!frame_prop) {
_state = State::Invalid;
return;
}
auto frame_styles = frame_prop->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
if(!frame_styles) {
_state = State::Invalid;
return;
}
if(frame_styles->items.size() != 4) {
_state = State::Invalid;
return;
}
for(UnsignedInt i = 0; i < 4; i++) {
_frame.styles[i] = frame_styles->at<IntProperty>(i)->value;
}
}
auto Mass::writeFrameStyles() -> bool {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
_lastError = "No unit data in " + _filename;
return false; return false;
} }
auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653"); auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
if(!frame) { if(!frame) {
_state = State::Invalid; _state = State::Invalid;
_lastError = "No frame data in " + _filename;
return false; return false;
} }
auto frame_styles = frame->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48"); auto frame_styles = frame->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
if(!frame_styles) { if(!frame_styles) {
_state = State::Invalid; _state = State::Invalid;
_lastError = "No frame styles in " + _filename;
return false; return false;
} }
frame_styles->at<IntProperty>(index)->value = style_id; for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) {
frame_styles->at<IntProperty>(i)->value = _frame.styles[i];
}
return _mass->saveToFile(); if(!_mass->saveToFile()) {
_lastError = "Couldn't write data to " + _filename;
return false;
}
return true;
} }
auto Mass::eyeFlareColour() const -> const Color4& { auto Mass::eyeFlareColour() -> Color4& {
return _frame.eyeFlare; return _frame.eyeFlare;
} }
auto Mass::setEyeFlareColour(Color4 new_colour) -> bool { void Mass::getEyeFlareColour() {
_frame.eyeFlare = new_colour; auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
if(!frame_prop) {
_state = State::Invalid;
return;
}
auto eye_flare_prop = frame_prop->at<ColourStructProperty>("EyeFlareColor_36_AF79999C40FCA0E88A2F9A84488A38CA");
if(!eye_flare_prop) {
_state = State::Invalid;
return;
}
_frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a};
}
auto Mass::writeEyeFlareColour() -> bool {
auto unit_data = _mass->at<GenericStructProperty>("UnitData"); auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) { if(!unit_data) {
_state = State::Invalid; _state = State::Invalid;
@ -509,10 +470,10 @@ auto Mass::setEyeFlareColour(Color4 new_colour) -> bool {
return false; return false;
} }
eye_flare_prop->r = new_colour.r(); eye_flare_prop->r = _frame.eyeFlare.r();
eye_flare_prop->g = new_colour.g(); eye_flare_prop->g = _frame.eyeFlare.g();
eye_flare_prop->b = new_colour.b(); eye_flare_prop->b = _frame.eyeFlare.b();
eye_flare_prop->a = new_colour.a(); eye_flare_prop->a = _frame.eyeFlare.a();
return _mass->saveToFile(); return _mass->saveToFile();
} }
@ -521,27 +482,229 @@ auto Mass::frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> {
return _frame.customStyles; return _frame.customStyles;
} }
auto Mass::setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool { void Mass::getFrameCustomStyles() {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto frame_styles = unit_data->at<ArrayProperty>("FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA");
if(!frame_styles) {
_state = State::Invalid;
return;
}
if(frame_styles->items.size() != 16) {
_state = State::Invalid;
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);
}
}
auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool {
if(index > _frame.customStyles.size()) { if(index > _frame.customStyles.size()) {
return false; return false;
} }
_frame.customStyles[index] = std::move(style);
return setCustomStyle(_frame.customStyles[index], index, "FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA"); return setCustomStyle(_frame.customStyles[index], index, "FrameStyle_44_04A44C9440363CCEC5443D98BFAF22AA");
} }
auto Mass::armourParts() -> Containers::StaticArrayView<38, ArmourPart> {
return _armour.parts;
}
void Mass::getArmourParts() {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto armour_array = unit_data->at<ArrayProperty>("Armor_10_12E266C44116DDAF57E99ABB575A4B3C");
if(!armour_array) {
_state = State::Invalid;
return;
}
if(armour_array->items.size() != 38) {
_state = State::Invalid;
return;
}
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
auto part_prop = armour_array->at<GenericStructProperty>(i);
ArmourPart part;
part.slot = part_prop->at<ByteProperty>("Slot_3_408BA56F4C9605C7E805CF91B642249C")->enumValue;
part.id = part_prop->at<IntProperty>("ID_5_ACD101864D3481DE96EDACACC09BDD25")->value;
auto part_styles = part_prop->at<ArrayProperty>("Styles_47_3E31870441DFD7DB8BEE5C85C26B365B");
if(!part_styles) {
_state = State::Invalid;
return;
}
if(part_styles->items.size() != 4) {
_state = State::Invalid;
return;
}
for(UnsignedInt j = 0; j < part_styles->items.size(); j++) {
part.styles[j] = part_styles->at<IntProperty>(j)->value;
}
auto decals_array = part_prop->at<ArrayProperty>("Decals_42_F358794A4F18497970F56BA9627D3603");
if(!decals_array) {
_state = State::Invalid;
return;
}
if(decals_array->items.size() != 8) {
_demo = true;
}
for(UnsignedInt j = 0; j < decals_array->items.size(); j++) {
auto decal_prop = decals_array->at<GenericStructProperty>(j);
Decal decal;
decal.id = decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value;
auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606");
decal.colour = Color4{colour_prop->r, colour_prop->g, colour_prop->b, colour_prop->a};
auto pos_prop = decal_prop->at<VectorStructProperty>("Position_41_022C8FE84E1AAFE587261E88F2C72250");
decal.position = Vector3{pos_prop->x, pos_prop->y, pos_prop->z};
auto u_prop = decal_prop->at<VectorStructProperty>("UAxis_37_EBEB715F45491AECACCC07A1AE4646D1");
decal.uAxis = Vector3{u_prop->x, u_prop->y, u_prop->z};
auto v_prop = decal_prop->at<VectorStructProperty>("VAxis_39_C31EB2664EE202CAECFBBB84100B5E35");
decal.vAxis = Vector3{v_prop->x, v_prop->y, v_prop->z};
auto offset_prop = decal_prop->at<Vector2DStructProperty>("Offset_29_B02BBBB74FC60F5EDBEBAB8020738020");
decal.offset = Vector2{offset_prop->x, offset_prop->y};
decal.scale = decal_prop->at<FloatProperty>("Scale_32_959D1C2747AFD8D62808468235CBBA40")->value;
decal.rotation = decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value;
decal.flip = decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value;
decal.wrap = decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value;
part.decals[j] = decal;
}
if(!_demo) {
auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3");
if(!accs_array) {
_demo = true;
}
if(accs_array->items.size() != 8) {
_state = State::Invalid;
return;
}
for(UnsignedInt j = 0; j < accs_array->items.size(); j++) {
auto acc_prop = accs_array->at<GenericStructProperty>(j);
Accessory accessory;
accessory.attachIndex = acc_prop->at<IntProperty>("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20")->value;
accessory.id = acc_prop->at<IntProperty>("ID_4_5757B32647BAE263266259B8A7DFFFC1")->value;
auto acc_styles = acc_prop->at<ArrayProperty>("Styles_7_91DEB0F24E24D13FC9472882C11D0DFD");
for(UnsignedInt k = 0; k < acc_styles->items.size(); k++) {
accessory.styles[k] = acc_styles->at<IntProperty>(k)->value;
}
auto rel_pos_prop = acc_prop->at<VectorStructProperty>("RelativePosition_14_BE8FB2A94074F34B3EDA6683B227D3A1");
accessory.relativePosition = Vector3{rel_pos_prop->x, rel_pos_prop->y, rel_pos_prop->z};
auto rel_pos_offset_prop = acc_prop->at<VectorStructProperty>("RelativePositionOffset_15_98FD0CE74E44BBAFC2D46FB4CA4E0ED6");
accessory.relativePositionOffset = Vector3{rel_pos_offset_prop->x, rel_pos_offset_prop->y, rel_pos_offset_prop->z};
auto rel_rot_prop = acc_prop->at<RotatorStructProperty>("RelativeRotation_20_C78C73274E6E78E7878F8C98ECA342C0");
accessory.relativeRotation = Vector3{rel_rot_prop->x, rel_rot_prop->y, rel_rot_prop->z};
auto rel_rot_offset_prop = acc_prop->at<RotatorStructProperty>("RelativeRotationOffset_21_E07FA0EC46728B7BA763C6861249ABAA");
accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z};
auto local_scale_prop = acc_prop->at<VectorStructProperty>("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53");
accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z};
part.accessories[j] = std::move(accessory);
}
}
_armour.parts[i] = std::move(part);
}
}
auto Mass::armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> { auto Mass::armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle> {
return _armour.customStyles; return _armour.customStyles;
} }
auto Mass::setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool { void Mass::getArmourCustomStyles() {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto armour_styles = unit_data->at<ArrayProperty>("ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
if(!armour_styles) {
_state = State::Invalid;
return;
}
if(armour_styles->items.size() != 16) {
_state = State::Invalid;
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);
}
}
auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool {
if(index > _armour.customStyles.size()) { if(index > _armour.customStyles.size()) {
return false; return false;
} }
_armour.customStyles[index] = std::move(style);
return setCustomStyle(_armour.customStyles[index], index, "ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E"); return setCustomStyle(_armour.customStyles[index], index, "ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
} }
@ -549,13 +712,54 @@ auto Mass::globalStyles() -> Containers::StaticArrayView<16, CustomStyle> {
return _globalStyles; return _globalStyles;
} }
auto Mass::setGlobalStyle(CustomStyle style, UnsignedLong index) -> bool { void Mass::getGlobalStyles() {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto global_styles = unit_data->at<ArrayProperty>("GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B");
if(!global_styles) {
_state = State::Invalid;
return;
}
if(global_styles->items.size() != 16) {
_state = State::Invalid;
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);
}
}
auto Mass::writeGlobalStyle(UnsignedLong index) -> bool {
if(index > _globalStyles.size()) { if(index > _globalStyles.size()) {
return false; return false;
} }
_globalStyles[index] = std::move(style);
return setCustomStyle(_globalStyles[index], index, "GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B"); return setCustomStyle(_globalStyles[index], index, "GlobalStyles_57_6A681C114035241F7BDAAE9B43A8BF1B");
} }

View file

@ -46,15 +46,15 @@ struct Joints {
struct CustomStyle { struct CustomStyle {
std::string name; std::string name;
Color4 colour{0.0f}; Color4 colour{0.0f};
Float metallic = 0.0f; Float metallic = 0.5f;
Float gloss = 0.0f; Float gloss = 0.5f;
bool glow = false; bool glow = false;
Int patternId = 0; Int patternId = 0;
Float opacity = 0.5f; Float opacity = 0.5f;
Vector2 offset{0.0f}; Vector2 offset{0.5f};
Float rotation = 0.0f; Float rotation = 0.0f;
Float scale = 1.0f; Float scale = 0.5f;
}; };
struct Decal { struct Decal {
@ -135,26 +135,38 @@ class Mass {
auto state() -> State; auto state() -> State;
auto demo() const -> bool;
auto dirty() const -> bool; auto dirty() const -> bool;
void setDirty(bool dirty = true); void setDirty(bool dirty = true);
auto jointSliders() const -> Joints const&; auto jointSliders() -> Joints&;
auto setSliders(Joints joints) -> bool; void getJointSliders();
auto writeJointSliders() -> bool;
auto frameStyles() -> Containers::StaticArrayView<4, Int>; auto frameStyles() -> Containers::StaticArrayView<4, Int>;
auto setFrameStyle(Int index, Int style_id) -> bool; void getFrameStyles();
auto writeFrameStyles() -> bool;
auto eyeFlareColour() const -> Color4 const&; auto eyeFlareColour() -> Color4&;
auto setEyeFlareColour(Color4 new_colour) -> bool; void getEyeFlareColour();
auto writeEyeFlareColour() -> bool;
auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto frameCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
auto setFrameCustomStyle(CustomStyle style, UnsignedLong index) -> bool; void getFrameCustomStyles();
auto writeFrameCustomStyle(UnsignedLong index) -> bool;
auto armourParts() -> Containers::StaticArrayView<38, ArmourPart>;
void getArmourParts();
auto setArmourPart(UnsignedLong index) -> bool;
auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto armourCustomStyles() -> Containers::StaticArrayView<16, CustomStyle>;
auto setArmourCustomStyle(CustomStyle style, UnsignedLong index) -> bool; void getArmourCustomStyles();
auto writeArmourCustomStyle(UnsignedLong index) -> bool;
auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>;
auto setGlobalStyle(CustomStyle style, UnsignedLong index) -> bool; void getGlobalStyles();
auto writeGlobalStyle(UnsignedLong index) -> bool;
auto updateSteamId(const std::string& steam_id) -> bool; auto updateSteamId(const std::string& steam_id) -> bool;
@ -168,6 +180,7 @@ class Mass {
std::string _folder; std::string _folder;
std::string _filename; std::string _filename;
State _state = State::Empty; State _state = State::Empty;
bool _demo = false;
bool _dirty = false; bool _dirty = false;

View file

@ -355,7 +355,7 @@ auto Profile::getResource(const char* container, Int id) -> Int {
return 0; return 0;
} }
static auto predicate = [&id](UnrealPropertyBase::ptr& prop){ auto predicate = [&id](UnrealPropertyBase::ptr& prop){
auto res_prop = static_cast<ResourceItemValue*>(prop.get()); auto res_prop = static_cast<ResourceItemValue*>(prop.get());
return res_prop->id == id; return res_prop->id == id;
}; };

View file

@ -181,6 +181,20 @@ void SaveTool::drawMainMenu() {
#endif #endif
if(ImGui::BeginMenu("Help")) { if(ImGui::BeginMenu("Help")) {
if(ImGui::BeginMenu(ICON_FA_BOOK " ImGui user guide")) {
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
ImGui::BulletText("While inputing text:\n");
ImGui::Indent();
ImGui::BulletText("CTRL+Left/Right to word jump.");
ImGui::BulletText("CTRL+A or double-click to select all.");
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
ImGui::BulletText("ESCAPE to revert.");
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
ImGui::Unindent();
ImGui::EndMenu();
}
ImGui::MenuItem(ICON_FA_INFO_CIRCLE " About", nullptr, &_aboutPopup); ImGui::MenuItem(ICON_FA_INFO_CIRCLE " About", nullptr, &_aboutPopup);
ImGui::EndMenu(); ImGui::EndMenu();