Build viewer/editor #13

Manually merged
williamjcm merged 128 commits from mass-viewer into master 2022-03-02 14:50:10 +01:00
2 changed files with 209 additions and 1 deletions
Showing only changes of commit 80bb85c0d8 - Show all commits

View file

@ -144,7 +144,35 @@ void Mass::refreshValues() {
return; return;
} }
// TODO: weapons getMeleeWeapons();
if(_state == State::Invalid) {
return;
}
getShields();
if(_state == State::Invalid) {
return;
}
getBulletShooters();
if(_state == State::Invalid) {
return;
}
getEnergyShooters();
if(_state == State::Invalid) {
return;
}
getBulletLaunchers();
if(_state == State::Invalid) {
return;
}
getEnergyLaunchers();
if(_state == State::Invalid) {
return;
}
if(!_demo) if(!_demo)
{ {
@ -806,6 +834,54 @@ auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool {
return setCustomStyle(_armour.customStyles[index], index, "ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E"); return setCustomStyle(_armour.customStyles[index], index, "ArmorStyle_42_E2F6AC3647788CB366BD469B3B7E899E");
} }
auto Mass::meleeWeapons() -> Containers::StaticArrayView<8, Weapon> {
return _weapons.melee;
}
void Mass::getMeleeWeapons() {
getWeaponType("WeaponCC_22_0BBEC58C4A0EA1DB9E037B9339EE26A7", _weapons.melee);
}
auto Mass::shields() -> Containers::StaticArrayView<1, Weapon> {
return _weapons.shields;
}
void Mass::getShields() {
getWeaponType("Shield_53_839BFD7945481BAEA3E43A9C5CA8E92E", _weapons.shields);
}
auto Mass::bulletShooters() -> Containers::StaticArrayView<4, Weapon> {
return _weapons.bulletShooters;
}
void Mass::getBulletShooters() {
getWeaponType("WeaponBS_35_6EF6E0104FD7A138DF47F88CB57A83ED", _weapons.bulletShooters);
}
auto Mass::energyShooters() -> Containers::StaticArrayView<4, Weapon> {
return _weapons.energyShooters;
}
void Mass::getEnergyShooters() {
getWeaponType("WeaponES_37_1A295D544528623880A0B1AC2C7DEE99", _weapons.energyShooters);
}
auto Mass::bulletLaunchers() -> Containers::StaticArrayView<4, Weapon> {
return _weapons.bulletLaunchers;
}
void Mass::getBulletLaunchers() {
getWeaponType("WeaponBL_36_5FD7C41E4613A75B44AB0E90B362846E", _weapons.bulletLaunchers);
}
auto Mass::energyLaunchers() -> Containers::StaticArrayView<4, Weapon> {
return _weapons.energyLaunchers;
}
void Mass::getEnergyLaunchers() {
getWeaponType("WeaponEL_38_9D23F3884ACA15902C9E6CA6E4995995", _weapons.energyLaunchers);
}
auto Mass::globalStyles() -> Containers::StaticArrayView<16, CustomStyle> { auto Mass::globalStyles() -> Containers::StaticArrayView<16, CustomStyle> {
return _globalStyles; return _globalStyles;
} }
@ -908,3 +984,108 @@ auto Mass::setCustomStyle(const CustomStyle& style, UnsignedLong index, const ch
return _mass->saveToFile(); return _mass->saveToFile();
} }
void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array) {
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
if(!unit_data) {
_state = State::Invalid;
return;
}
auto prop = unit_data->at<ArrayProperty>(prop_name);
if(!prop) {
_state = State::Invalid;
return;
}
if(prop->items.size() != weapon_array.size()) {
_state = State::Invalid;
return;
}
for(UnsignedInt i = 0; i < weapon_array.size(); i++) {
auto weapon_prop = prop->at<GenericStructProperty>(i);
auto& weapon = weapon_array[i];
weapon.name = weapon_prop->at<StringProperty>("Name_13_7BF0D31F4E50C50C47231BB36A485D92")->value;
weapon.type = weapon_prop->at<ByteProperty>("Type_2_35ABA8C3406F8D9BBF14A89CD6BCE976")->enumValue;
auto parts_prop = weapon_prop->at<ArrayProperty>("Element_6_8E4617CC4B2C1F1490435599784EC6E0");
weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()};
for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) {
auto part_prop = parts_prop->at<GenericStructProperty>(j);
auto& part = weapon.parts[j];
part.id = part_prop->at<IntProperty>("ID_2_A74D75434308158E5926178822DD28EE")->value;
auto part_styles = part_prop->at<ArrayProperty>("Styles_17_994C97C34A90667BE5B716BFD0B97588");
for(UnsignedInt k = 0; k < part_styles->items.size(); k++) {
part.styles[k] = part_styles->at<IntProperty>(k)->value;
}
auto part_decals = part_prop->at<ArrayProperty>("Decals_13_8B81112B453D7230C0CDE982185E14F1");
if(part_decals->items.size() != 8) {
_demo = true;
part.demoDecals = part_decals->items.size();
}
for(UnsignedInt k = 0; k < part_decals->items.size(); k++) {
auto decal_prop = part_decals->at<GenericStructProperty>(k);
auto& decal = part.decals[k];
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;
}
if(!_demo) {
auto part_accs = part_prop->at<ArrayProperty>("Accessories_21_3878DE8B4ED0EA0DB725E98BCDC20E0C");
if(!part_accs) {
_demo = true;
}
if(!_demo) {
if(part_accs->items.size() != 8) {
_state = State::Invalid;
return;
}
for(UnsignedInt k = 0; k < part_accs->items.size(); k++) {
auto acc_prop = part_accs->at<GenericStructProperty>(k);
auto& accessory = part.accessories[k];
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 l = 0; l < acc_styles->items.size(); l++) {
accessory.styles[l] = acc_styles->at<IntProperty>(l)->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};
}
}
}
}
}
}

View file

@ -93,6 +93,7 @@ struct ArmourPart {
struct WeaponPart { struct WeaponPart {
Int id = 0; Int id = 0;
Containers::StaticArray<4, Int> styles{ValueInit}; Containers::StaticArray<4, Int> styles{ValueInit};
UnsignedInt demoDecals = 8;
Containers::StaticArray<8, Decal> decals{ValueInit}; Containers::StaticArray<8, Decal> decals{ValueInit};
Containers::StaticArray<8, Accessory> accessories{ValueInit}; Containers::StaticArray<8, Accessory> accessories{ValueInit};
}; };
@ -165,6 +166,30 @@ class Mass {
void getArmourCustomStyles(); void getArmourCustomStyles();
auto writeArmourCustomStyle(UnsignedLong index) -> bool; auto writeArmourCustomStyle(UnsignedLong index) -> bool;
auto meleeWeapons() -> Containers::StaticArrayView<8, Weapon>;
void getMeleeWeapons();
auto writeMeleeWeapons() -> bool;
auto shields() -> Containers::StaticArrayView<1, Weapon>;
void getShields();
auto writeShields() -> bool;
auto bulletShooters() -> Containers::StaticArrayView<4, Weapon>;
void getBulletShooters();
auto writeBulletShooters() -> bool;
auto energyShooters() -> Containers::StaticArrayView<4, Weapon>;
void getEnergyShooters();
auto writeEnergyShooters() -> bool;
auto bulletLaunchers() -> Containers::StaticArrayView<4, Weapon>;
void getBulletLaunchers();
auto writeBulletLaunchers() -> bool;
auto energyLaunchers() -> Containers::StaticArrayView<4, Weapon>;
void getEnergyLaunchers();
auto writeEnergyLaunchers() -> bool;
auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>; auto globalStyles() -> Containers::StaticArrayView<16, CustomStyle>;
void getGlobalStyles(); void getGlobalStyles();
auto writeGlobalStyle(UnsignedLong index) -> bool; auto writeGlobalStyle(UnsignedLong index) -> bool;
@ -174,6 +199,8 @@ class Mass {
private: private:
auto setCustomStyle(const CustomStyle& style, UnsignedLong index, const char* prop_name) -> bool; auto setCustomStyle(const CustomStyle& style, UnsignedLong index, const char* prop_name) -> bool;
void getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array);
Containers::Optional<UESaveFile> _mass; Containers::Optional<UESaveFile> _mass;
static std::string _lastError; static std::string _lastError;