Compare commits
13 commits
9bc4aaf66b
...
e77cce5b42
Author | SHA1 | Date | |
---|---|---|---|
e77cce5b42 | |||
18aa7f659e | |||
1612e4372b | |||
b377e0de6c | |||
0a438a4d72 | |||
e839d1c19b | |||
5689ec6c1a | |||
c2d0fbd941 | |||
2b2320ae0a | |||
10368e09db | |||
bd255ef8d5 | |||
911e18fc0a | |||
0c257bcfa6 |
13 changed files with 795 additions and 492 deletions
|
@ -124,7 +124,6 @@ add_executable(MassBuilderSaveTool WIN32
|
||||||
Profile/ResourceIDs.h
|
Profile/ResourceIDs.h
|
||||||
MassManager/MassManager.h
|
MassManager/MassManager.h
|
||||||
MassManager/MassManager.cpp
|
MassManager/MassManager.cpp
|
||||||
Mass/Locators.h
|
|
||||||
Mass/Mass.h
|
Mass/Mass.h
|
||||||
Mass/Mass.cpp
|
Mass/Mass.cpp
|
||||||
Maps/LastMissionId.h
|
Maps/LastMissionId.h
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// MassBuilderSaveTool
|
|
||||||
// Copyright (C) 2021 Guillaume Jacquemin
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
constexpr char mass_name_locator[] = "Name_45_A037C5D54E53456407BDF091344529BB\0\f\0\0\0StrProperty";
|
|
||||||
constexpr char steamid_locator[] = "Account\0\f\0\0\0StrProperty";
|
|
||||||
|
|
||||||
constexpr char neck_slider_locator[] = "NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char body_slider_locator[] = "BodyLength_7_C16287754CBA96C93BAE36A5C154996A\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char shoulders_slider_locator[] = "ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char hips_slider_locator[] = "HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char uarms_slider_locator[] = "ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char larms_slider_locator[] = "ArmLowerLength_12_ACD0F02745C28882619376926292FB36\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char ulegs_slider_locator[] = "LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61\0\x0e\0\0\0FloatProperty";
|
|
||||||
constexpr char llegs_slider_locator[] = "LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F\0\x0e\0\0\0FloatProperty";
|
|
||||||
|
|
||||||
constexpr char frame_styles_locator[] = "Styles_32_00A3B3284B37F1E7819458844A20EB48\0\x0e\0\0\0ArrayProperty\0\x14\0\0\0\0\0\0\0\f\0\0\0IntProperty\0\0\x04\0\0\0";
|
|
|
@ -21,7 +21,12 @@
|
||||||
#include <Corrade/Containers/Array.h>
|
#include <Corrade/Containers/Array.h>
|
||||||
#include <Corrade/Utility/Directory.h>
|
#include <Corrade/Utility/Directory.h>
|
||||||
|
|
||||||
#include "Locators.h"
|
#include "../UESaveFile/Types/ArrayProperty.h"
|
||||||
|
#include "../UESaveFile/Types/ColourStructProperty.h"
|
||||||
|
#include "../UESaveFile/Types/FloatProperty.h"
|
||||||
|
#include "../UESaveFile/Types/GenericStructProperty.h"
|
||||||
|
#include "../UESaveFile/Types/IntProperty.h"
|
||||||
|
#include "../UESaveFile/Types/StringProperty.h"
|
||||||
|
|
||||||
#include "Mass.h"
|
#include "Mass.h"
|
||||||
|
|
||||||
|
@ -38,256 +43,362 @@ auto Mass::lastError() -> std::string const& {
|
||||||
return _lastError;
|
return _lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::getNameFromFile(const std::string& path) -> std::string {
|
auto Mass::getNameFromFile(const std::string& path) -> Containers::Optional<std::string> {
|
||||||
if(!Utility::Directory::exists(path)) {
|
if(!Utility::Directory::exists(path)) {
|
||||||
_lastError = path + " couldn't be found.";
|
_lastError = path + " couldn't be found.";
|
||||||
return "";
|
return Containers::NullOpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
UESaveFile mass{path};
|
||||||
|
|
||||||
auto mmap = Utility::Directory::mapRead(path);
|
if(!mass.valid()) {
|
||||||
|
_lastError = "The unit file seems to be corrupt.";
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &mass_name_locator[0], &mass_name_locator[56]);
|
return Containers::NullOpt;
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
name = std::string{iter + 70};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_lastError = "The name couldn't be found in " + path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
auto unit_data = mass.at<GenericStructProperty>("UnitData");
|
||||||
|
|
||||||
|
if(!unit_data) {
|
||||||
|
_lastError = "Couldn't find unit data in the file.";
|
||||||
|
return Containers::NullOpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
||||||
|
|
||||||
|
if(!name_prop) {
|
||||||
|
_lastError = "Couldn't find the name in the file.";
|
||||||
|
return Containers::NullOpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name_prop->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mass::refreshValues() {
|
void Mass::refreshValues() {
|
||||||
getName();
|
if(!Utility::Directory::exists(Utility::Directory::join(_folder, _filename))) {
|
||||||
|
_state = State::Empty;
|
||||||
if(_state != State::Valid) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFrameStyles();
|
if(!_mass) {
|
||||||
getJointSliders();
|
_mass.emplace(Utility::Directory::join(_folder, _filename));
|
||||||
|
if(!_mass->valid()) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!_mass->reloadData()) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
|
|
||||||
|
if(!unit_data) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
||||||
|
|
||||||
|
if(!name_prop) {
|
||||||
|
_name = Containers::NullOpt;
|
||||||
|
_state = State::Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_name = name_prop->value;
|
||||||
|
|
||||||
|
{
|
||||||
|
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 frame_styles = frame_prop->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
|
||||||
|
|
||||||
|
if(!frame_styles) {
|
||||||
|
_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};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto account_prop = _mass->at<StringProperty>("Account");
|
||||||
|
if(!account_prop) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steamId = account_prop->value;
|
||||||
|
|
||||||
|
_state = State::Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::filename() -> std::string const&{
|
auto Mass::filename() -> std::string const&{
|
||||||
return _filename;
|
return _filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::name() -> std::string const&{
|
auto Mass::name() -> Containers::Optional<std::string> const& {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Mass::setName(std::string new_name) -> bool {
|
||||||
|
_name = new_name;
|
||||||
|
|
||||||
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
|
|
||||||
|
if(!unit_data) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto name_prop = unit_data->at<StringProperty>("Name_45_A037C5D54E53456407BDF091344529BB");
|
||||||
|
|
||||||
|
if(!name_prop) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_prop->value = std::move(new_name);
|
||||||
|
|
||||||
|
return _mass->saveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
auto Mass::state() -> State {
|
auto Mass::state() -> State {
|
||||||
return _state;
|
return _state;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::jointSliders() -> Joints const& {
|
auto Mass::dirty() const -> bool {
|
||||||
return _sliders;
|
return _dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mass::setDirty(bool dirty) {
|
||||||
|
_dirty = dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Mass::jointSliders() const -> Joints const& {
|
||||||
|
return _frame.joints;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Mass::setSliders(Joints joints) -> bool {
|
||||||
|
_frame.joints = joints;
|
||||||
|
|
||||||
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
|
|
||||||
|
if(!unit_data) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto frame_prop = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
||||||
|
|
||||||
|
if(!frame_prop) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto length = frame_prop->at<FloatProperty>("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
|
||||||
|
if(!length && _frame.joints.neck != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("NeckLength_6_ED6AF79849C27CD1A9D523A09E2BFE58");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.neck;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
|
||||||
|
if(!length && _frame.joints.body != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("BodyLength_7_C16287754CBA96C93BAE36A5C154996A");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
|
||||||
|
if(!length && _frame.joints.shoulders != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("ShoulderLength_8_220EDF304F1C1226F0D8D39117FB3883");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.shoulders;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
|
||||||
|
if(!length && _frame.joints.hips != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("HipLength_14_02AEEEAC4376087B9C51F0AA7CC92818");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.hips;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
|
||||||
|
if(!length && _frame.joints.upperArms != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("ArmUpperLength_10_249FDA3E4F3B399E7B9E5C9B7C765EAE");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.upperArms;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
|
||||||
|
if(!length && _frame.joints.lowerArms != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("ArmLowerLength_12_ACD0F02745C28882619376926292FB36");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.lowerArms;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
|
||||||
|
if(!length && _frame.joints.upperLegs != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("LegUpperLength_16_A7C4C71249A3776F7A543D96819C0C61");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.upperLegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = frame_prop->at<FloatProperty>("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
|
||||||
|
if(!length && _frame.joints.lowerLegs != 0.0f) {
|
||||||
|
length = new FloatProperty;
|
||||||
|
auto length_prop = FloatProperty::ptr{length};
|
||||||
|
length_prop->name.emplace("LegLowerLength_18_D2DF39964EA0F2A2129D0491B08A032F");
|
||||||
|
arrayAppend(frame_prop->properties, std::move(length_prop));
|
||||||
|
}
|
||||||
|
if(length) {
|
||||||
|
length->value = _frame.joints.lowerLegs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _mass->saveToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> {
|
auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> {
|
||||||
return _frameStyles;
|
return _frame.styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::setFrameStyle(Int index, Int style_id) -> bool {
|
auto Mass::setFrameStyle(Int index, Int style_id) -> bool {
|
||||||
if(index < 0 || index > 3) {
|
_frame.styles[index] = style_id;
|
||||||
_lastError = "Index is out of range in Mass::setFrameStyle().";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
|
if(!unit_data) {
|
||||||
if(!Utility::Directory::exists(path)) {
|
|
||||||
_lastError = path + " couldn't be found.";
|
|
||||||
_state = State::Empty;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mmap = Utility::Directory::map(path);
|
|
||||||
|
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &frame_styles_locator[0], &frame_styles_locator[90]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
iter += 0x5A;
|
|
||||||
*(reinterpret_cast<Int*>(iter) + index) = style_id;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_lastError = "Frame styles couldn't be found in " + path;
|
|
||||||
_state = State::Invalid;
|
_state = State::Invalid;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
||||||
|
if(!frame) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto frame_styles = frame->at<ArrayProperty>("Styles_32_00A3B3284B37F1E7819458844A20EB48");
|
||||||
|
if(!frame_styles) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_styles->at<IntProperty>(index)->value = style_id;
|
||||||
|
|
||||||
|
return _mass->saveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Mass::eyeFlareColour() const -> const Color4& {
|
||||||
|
return _frame.eyeFlare;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Mass::setEyeFlareColour(Color4 new_colour) -> bool {
|
||||||
|
_frame.eyeFlare = new_colour;
|
||||||
|
|
||||||
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
|
if(!unit_data) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto frame = unit_data->at<GenericStructProperty>("Frame_3_F92B0F6A44A15088AF7F41B9FF290653");
|
||||||
|
if(!frame) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto eye_flare_prop = frame->at<ColourStructProperty>("EyeFlareColor_36_AF79999C40FCA0E88A2F9A84488A38CA");
|
||||||
|
if(!eye_flare_prop) {
|
||||||
|
_state = State::Invalid;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
eye_flare_prop->r = new_colour.r();
|
||||||
|
eye_flare_prop->g = new_colour.g();
|
||||||
|
eye_flare_prop->b = new_colour.b();
|
||||||
|
eye_flare_prop->a = new_colour.a();
|
||||||
|
|
||||||
|
return _mass->saveToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::updateSteamId(const std::string& steam_id) -> bool {
|
auto Mass::updateSteamId(const std::string& steam_id) -> bool {
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
_steamId = steam_id;
|
||||||
|
|
||||||
if(!Utility::Directory::exists(path)) {
|
auto unit_data = _mass->at<GenericStructProperty>("UnitData");
|
||||||
_lastError = path + " couldn't be found.";
|
if(!unit_data) {
|
||||||
_state = State::Empty;
|
_state = State::Invalid;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility::Directory::copy(path, path + ".tmp");
|
auto account_prop = unit_data->at<StringProperty>("Account");
|
||||||
|
if(!account_prop) {
|
||||||
{
|
_state = State::Invalid;
|
||||||
auto mmap = Utility::Directory::map(path + ".tmp");
|
|
||||||
|
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &steamid_locator[0], &steamid_locator[23]);
|
|
||||||
|
|
||||||
if(iter == mmap.end()) {
|
|
||||||
_lastError = "The M.A.S.S. file at " + path + " seems to be corrupt.";
|
|
||||||
Utility::Directory::rm(path + ".tmp");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iter += 37;
|
account_prop->value = steam_id;
|
||||||
|
|
||||||
if(std::strncmp(iter, steam_id.c_str(), steam_id.length()) != 0) {
|
return _mass->saveToFile();
|
||||||
for(int i = 0; i < 17; ++i) {
|
|
||||||
*(iter + i) = steam_id[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Utility::Directory::exists(path)) {
|
|
||||||
Utility::Directory::rm(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::Directory::move(path + ".tmp", path);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mass::getName() {
|
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
|
||||||
|
|
||||||
if(!Utility::Directory::exists(path)) {
|
|
||||||
_lastError = path + " couldn't be found.";
|
|
||||||
_state = State::Empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mmap = Utility::Directory::mapRead(path);
|
|
||||||
|
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &mass_name_locator[0], &mass_name_locator[56]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_name = std::string{iter + 70};
|
|
||||||
_state = State::Valid;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_lastError = "The name couldn't be found in " + _filename;
|
|
||||||
_state = State::Invalid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mass::getJointSliders() {
|
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
|
||||||
|
|
||||||
if(!Utility::Directory::exists(path)) {
|
|
||||||
_lastError = path + " couldn't be found.";
|
|
||||||
_state = State::Empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mmap = Utility::Directory::mapRead(path);
|
|
||||||
|
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &neck_slider_locator[0], &neck_slider_locator[63]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.neck = *reinterpret_cast<const Float*>(iter + 0x49);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.neck = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &body_slider_locator[0], &body_slider_locator[63]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.body = *reinterpret_cast<const Float*>(iter + 0x49);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.body = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &shoulders_slider_locator[0], &shoulders_slider_locator[67]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.shoulders = *reinterpret_cast<const Float*>(iter + 0x4D);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.shoulders = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &hips_slider_locator[0], &hips_slider_locator[63]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.hips = *reinterpret_cast<const Float*>(iter + 0x49);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.hips = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &uarms_slider_locator[0], &uarms_slider_locator[68]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.upperArms = *reinterpret_cast<const Float*>(iter + 0x4E);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.upperArms = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &larms_slider_locator[0], &larms_slider_locator[68]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.lowerArms = *reinterpret_cast<const Float*>(iter + 0x4E);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.lowerArms = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &ulegs_slider_locator[0], &ulegs_slider_locator[68]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.upperLegs = *reinterpret_cast<const Float*>(iter + 0x4E);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.upperLegs = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = std::search(mmap.begin(), mmap.end(), &llegs_slider_locator[0], &llegs_slider_locator[68]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
_sliders.lowerLegs = *reinterpret_cast<const Float*>(iter + 0x4E);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_sliders.lowerLegs = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mass::getFrameStyles() {
|
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
|
||||||
|
|
||||||
if(!Utility::Directory::exists(path)) {
|
|
||||||
_lastError = path + " couldn't be found.";
|
|
||||||
_state = State::Empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mmap = Utility::Directory::mapRead(path);
|
|
||||||
|
|
||||||
auto iter = std::search(mmap.begin(), mmap.end(), &frame_styles_locator[0], &frame_styles_locator[90]);
|
|
||||||
|
|
||||||
if(iter != mmap.end()) {
|
|
||||||
iter += 0x5A;
|
|
||||||
std::copy(reinterpret_cast<const Int*>(iter), reinterpret_cast<const Int*>(iter) + 4, _frameStyles.data());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_lastError = "Frame styles couldn't be found in " + path;
|
|
||||||
_state = State::Invalid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
136
src/Mass/Mass.h
136
src/Mass/Mass.h
|
@ -18,9 +18,16 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <Corrade/Containers/Optional.h>
|
||||||
|
#include <Corrade/Containers/Pointer.h>
|
||||||
#include <Corrade/Containers/StaticArray.h>
|
#include <Corrade/Containers/StaticArray.h>
|
||||||
|
|
||||||
#include <Magnum/Magnum.h>
|
#include <Magnum/Magnum.h>
|
||||||
|
#include <Magnum/Math/Color.h>
|
||||||
|
#include <Magnum/Math/Vector2.h>
|
||||||
|
#include <Magnum/Math/Vector3.h>
|
||||||
|
|
||||||
|
#include "../UESaveFile/UESaveFile.h"
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
@ -36,6 +43,72 @@ struct Joints {
|
||||||
Float lowerLegs = 0.0f;
|
Float lowerLegs = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CustomStyle {
|
||||||
|
std::string name;
|
||||||
|
Color4 colour{0.0f};
|
||||||
|
Float metallic = 0.0f;
|
||||||
|
Float gloss = 0.0f;
|
||||||
|
bool glow = false;
|
||||||
|
|
||||||
|
Int patternId = 0;
|
||||||
|
Float opacity = 0.0f;
|
||||||
|
Float offsetX = 0.0f;
|
||||||
|
Float offsetY = 0.0f;
|
||||||
|
Float rotation = 0.0f;
|
||||||
|
Float scale = 0.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Decal {
|
||||||
|
Int id = -1;
|
||||||
|
Color4 colour{0.0f};
|
||||||
|
Vector3 position{0.0f};
|
||||||
|
Vector3 uAxis{0.0f};
|
||||||
|
Vector3 vAxis{0.0f};
|
||||||
|
Vector2 offset{0.5f};
|
||||||
|
Float scale = 0.5f;
|
||||||
|
Float rotation = 0.0f;
|
||||||
|
bool flip = false;
|
||||||
|
bool wrap = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Accessory {
|
||||||
|
Int attachIndex = -1;
|
||||||
|
Int id = -1;
|
||||||
|
Containers::StaticArray<2, Int> styles{ValueInit};
|
||||||
|
Vector3 relativePosition{0.0f};
|
||||||
|
Vector3 relativePositionOffset{0.0f};
|
||||||
|
Vector3 relativeRotation{0.0f};
|
||||||
|
Vector3 relativeRotationOffset{0.0f};
|
||||||
|
Vector3 localScale{1.0f};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Armour {
|
||||||
|
std::string slot;
|
||||||
|
Int id = 0;
|
||||||
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
||||||
|
Containers::StaticArray<8, Decal> decals{ValueInit};
|
||||||
|
Containers::StaticArray<8, Accessory> accessories{ValueInit};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WeaponPart {
|
||||||
|
Int id = 0;
|
||||||
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
||||||
|
Containers::StaticArray<8, Decal> decals{ValueInit};
|
||||||
|
Containers::StaticArray<8, Accessory> accessories{ValueInit};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Weapon {
|
||||||
|
std::string name;
|
||||||
|
std::string type;
|
||||||
|
Containers::Array<WeaponPart> parts;
|
||||||
|
Containers::StaticArray<16, CustomStyle> customStyles{ValueInit};
|
||||||
|
bool attached = false;
|
||||||
|
std::string damageType;
|
||||||
|
bool dualWield = false;
|
||||||
|
std::string effectColourMode;
|
||||||
|
Color4 effectColour{0.0f};
|
||||||
|
};
|
||||||
|
|
||||||
class Mass {
|
class Mass {
|
||||||
public:
|
public:
|
||||||
enum class State : UnsignedByte {
|
enum class State : UnsignedByte {
|
||||||
|
@ -52,36 +125,81 @@ class Mass {
|
||||||
|
|
||||||
static auto lastError() -> std::string const&;
|
static auto lastError() -> std::string const&;
|
||||||
|
|
||||||
static auto getNameFromFile(const std::string& path) -> std::string;
|
static auto getNameFromFile(const std::string& path) -> Containers::Optional<std::string>;
|
||||||
|
|
||||||
void refreshValues();
|
void refreshValues();
|
||||||
|
|
||||||
auto filename() -> std::string const&;
|
auto filename() -> std::string const&;
|
||||||
|
|
||||||
auto name() -> std::string const&;
|
auto name() -> Containers::Optional<std::string> const&;
|
||||||
|
auto setName(std::string new_name) -> bool;
|
||||||
|
|
||||||
auto state() -> State;
|
auto state() -> State;
|
||||||
|
|
||||||
auto jointSliders() -> Joints const&;
|
auto dirty() const -> bool;
|
||||||
|
void setDirty(bool dirty = true);
|
||||||
|
|
||||||
|
auto jointSliders() const -> Joints const&;
|
||||||
|
auto setSliders(Joints joints) -> bool;
|
||||||
|
|
||||||
auto frameStyles() -> Containers::StaticArrayView<4, Int>;
|
auto frameStyles() -> Containers::StaticArrayView<4, Int>;
|
||||||
auto setFrameStyle(Int index, Int style_id) -> bool;
|
auto setFrameStyle(Int index, Int style_id) -> bool;
|
||||||
|
|
||||||
|
auto eyeFlareColour() const -> Color4 const&;
|
||||||
|
auto setEyeFlareColour(Color4 new_colour) -> bool;
|
||||||
|
|
||||||
auto updateSteamId(const std::string& steam_id) -> bool;
|
auto updateSteamId(const std::string& steam_id) -> bool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getName();
|
Containers::Optional<UESaveFile> _mass;
|
||||||
void getJointSliders();
|
|
||||||
void getFrameStyles();
|
|
||||||
|
|
||||||
static std::string _lastError;
|
static std::string _lastError;
|
||||||
|
|
||||||
std::string _folder;
|
std::string _folder;
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
std::string _name;
|
|
||||||
State _state = State::Empty;
|
State _state = State::Empty;
|
||||||
|
|
||||||
Joints _sliders;
|
bool _dirty = false;
|
||||||
|
|
||||||
Containers::StaticArray<4, Int> _frameStyles;
|
Containers::Optional<std::string> _name = Containers::NullOpt;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Joints joints{};
|
||||||
|
|
||||||
|
Containers::StaticArray<4, Int> styles{ValueInit};
|
||||||
|
|
||||||
|
Color4 eyeFlare{0.0f};
|
||||||
|
|
||||||
|
Containers::StaticArray<16, CustomStyle> frameCustomStyles;
|
||||||
|
} _frame;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Containers::StaticArray<38, Armour> parts;
|
||||||
|
|
||||||
|
Containers::StaticArray<16, CustomStyle> armourCustomStyles;
|
||||||
|
} _armour;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Containers::StaticArray<8, Weapon> meleeWeapons;
|
||||||
|
Containers::StaticArray<1, Weapon> shields;
|
||||||
|
Containers::StaticArray<4, Weapon> bulletShooters;
|
||||||
|
Containers::StaticArray<4, Weapon> energyShooters;
|
||||||
|
Containers::StaticArray<4, Weapon> bulletLaunchers;
|
||||||
|
Containers::StaticArray<4, Weapon> energyLaunchers;
|
||||||
|
} _weapons;
|
||||||
|
|
||||||
|
Containers::StaticArray<16, CustomStyle> _globalStyles;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Int engineId;
|
||||||
|
Containers::StaticArray<7, Int> gearIds;
|
||||||
|
|
||||||
|
Int osId;
|
||||||
|
Containers::StaticArray<7, Int> moduleIds;
|
||||||
|
|
||||||
|
Int archId;
|
||||||
|
Containers::StaticArray<7, Int> techIds;
|
||||||
|
} _tuning;
|
||||||
|
|
||||||
|
std::string _steamId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -111,7 +111,7 @@ auto MassManager::exportMass(int hangar) -> bool {
|
||||||
|
|
||||||
std::string source = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename());
|
std::string source = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename());
|
||||||
std::string dest = Utility::Directory::join(_stagingAreaDirectory,
|
std::string dest = Utility::Directory::join(_stagingAreaDirectory,
|
||||||
Utility::formatString("{}_{}.sav", _hangars[hangar].name(), _steamId));
|
Utility::formatString("{}_{}.sav", *_hangars[hangar].name(), _steamId));
|
||||||
|
|
||||||
if(!Utility::Directory::copy(source, dest)) {
|
if(!Utility::Directory::copy(source, dest)) {
|
||||||
_lastError = Utility::formatString("Couldn't export data from hangar {:.2d} to {}", hangar, dest);
|
_lastError = Utility::formatString("Couldn't export data from hangar {:.2d} to {}", hangar, dest);
|
||||||
|
@ -187,7 +187,7 @@ void MassManager::refreshStagedMasses() {
|
||||||
file_list.erase(iter, file_list.end());
|
file_list.erase(iter, file_list.end());
|
||||||
|
|
||||||
for(const std::string& file : file_list) {
|
for(const std::string& file : file_list) {
|
||||||
std::string name = Mass::getNameFromFile(Utility::Directory::join(_stagingAreaDirectory, file));
|
std::string name = *Mass::getNameFromFile(Utility::Directory::join(_stagingAreaDirectory, file));
|
||||||
|
|
||||||
if(!name.empty()) {
|
if(!name.empty()) {
|
||||||
_stagedMasses[file] = name;
|
_stagedMasses[file] = name;
|
||||||
|
|
|
@ -48,6 +48,8 @@ Profile::Profile(const std::string& path):
|
||||||
|
|
||||||
_steamId = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"});
|
_steamId = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"});
|
||||||
|
|
||||||
|
refreshValues();
|
||||||
|
|
||||||
_valid = _profile.valid();
|
_valid = _profile.valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@ auto Profile::steamId() const -> std::string const& {
|
||||||
void Profile::refreshValues() {
|
void Profile::refreshValues() {
|
||||||
if(!_profile.reloadData()) {
|
if(!_profile.reloadData()) {
|
||||||
_lastError = _profile.lastError();
|
_lastError = _profile.lastError();
|
||||||
|
_valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,10 +130,10 @@ class Profile {
|
||||||
UESaveFile _profile;
|
UESaveFile _profile;
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
Int _activeFrameSlot;
|
Int _activeFrameSlot = 0;
|
||||||
Int _credits;
|
Int _credits = 0;
|
||||||
Int _storyProgress;
|
Int _storyProgress = 0;
|
||||||
Int _lastMissionId;
|
Int _lastMissionId = 0;
|
||||||
|
|
||||||
Int _verseSteel = 0;
|
Int _verseSteel = 0;
|
||||||
Int _undinium = 0;
|
Int _undinium = 0;
|
||||||
|
|
|
@ -49,9 +49,6 @@
|
||||||
extern const ImVec2 center_pivot = {0.5f, 0.5f};
|
extern const ImVec2 center_pivot = {0.5f, 0.5f};
|
||||||
|
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
#include <Corrade/Utility/Tweakable.h>
|
|
||||||
|
|
||||||
#define tw CORRADE_TWEAKABLE
|
|
||||||
Utility::Tweakable tweak;
|
Utility::Tweakable tweak;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -206,14 +203,21 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_moved_after_save = false;
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case efsw::Actions::Add:
|
case efsw::Actions::Add:
|
||||||
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
if(!_currentMass || _currentMass != &(_massManager->hangar(index))) {
|
||||||
_massManager->refreshHangar(index);
|
_massManager->refreshHangar(index);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
_currentMass->setDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case efsw::Actions::Delete:
|
case efsw::Actions::Delete:
|
||||||
|
@ -221,9 +225,11 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
if(!_currentMass || _currentMass != &(_massManager->hangar(index))) {
|
||||||
_massManager->refreshHangar(index);
|
_massManager->refreshHangar(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case efsw::Actions::Modified:
|
case efsw::Actions::Modified:
|
||||||
if(filename == _currentProfile->filename()) {
|
if(filename == _currentProfile->filename()) {
|
||||||
|
@ -233,16 +239,33 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
|
||||||
|
if(!_currentMass || _currentMass != &(_massManager->hangar(index))) {
|
||||||
_massManager->refreshHangar(index);
|
_massManager->refreshHangar(index);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if(!is_moved_after_save) {
|
||||||
|
is_moved_after_save = false;
|
||||||
|
_currentMass->setDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case efsw::Actions::Moved:
|
case efsw::Actions::Moved:
|
||||||
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::endsWith(old_filename, ".tmp")) {
|
||||||
|
is_moved_after_save = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : "")) &&
|
||||||
|
Utility::String::endsWith(old_filename, ".sav"))
|
||||||
|
{
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
_massManager->refreshHangar(index);
|
_massManager->refreshHangar(index);
|
||||||
|
|
||||||
int old_index = ((old_filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int old_index = ((old_filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(old_filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(old_filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
_massManager->refreshHangar(old_index);
|
_massManager->refreshHangar(old_index);
|
||||||
|
@ -526,8 +549,6 @@ auto SaveTool::findGameDataDirectory() -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseMassManager() {
|
void SaveTool::initialiseMassManager() {
|
||||||
_currentProfile->refreshValues();
|
|
||||||
|
|
||||||
_massManager.emplace(_saveDir,
|
_massManager.emplace(_saveDir,
|
||||||
_currentProfile->steamId(),
|
_currentProfile->steamId(),
|
||||||
_currentProfile->type() == ProfileType::Demo,
|
_currentProfile->type() == ProfileType::Demo,
|
||||||
|
|
|
@ -36,6 +36,12 @@
|
||||||
#include "../MassManager/MassManager.h"
|
#include "../MassManager/MassManager.h"
|
||||||
#include "../ToastQueue/ToastQueue.h"
|
#include "../ToastQueue/ToastQueue.h"
|
||||||
|
|
||||||
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
|
#include <Corrade/Utility/Tweakable.h>
|
||||||
|
|
||||||
|
#define tw CORRADE_TWEAKABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
|
@ -105,6 +111,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
void drawMassViewer();
|
void drawMassViewer();
|
||||||
void drawFrameInfo();
|
void drawFrameInfo();
|
||||||
|
void drawJointSliders();
|
||||||
|
void drawFramePaint();
|
||||||
|
void drawCustomStyles(Containers::ArrayView<CustomStyle> styles);
|
||||||
|
|
||||||
void drawAbout();
|
void drawAbout();
|
||||||
void drawGameState();
|
void drawGameState();
|
||||||
|
|
|
@ -359,7 +359,7 @@ void SaveTool::drawResearchInventory() {
|
||||||
matRow("Nuflalt", 2, nuflalt, nuflalt, Nuflalt)
|
matRow("Nuflalt", 2, nuflalt, nuflalt, Nuflalt)
|
||||||
matRow("Aurelene", 3, aurelene, aurelene, Aurelene)
|
matRow("Aurelene", 3, aurelene, aurelene, Aurelene)
|
||||||
matRow("Soldus", 4, soldus, soldus, Soldus)
|
matRow("Soldus", 4, soldus, soldus, Soldus)
|
||||||
matRow("Synthesized N", 5, synthesized_n, synthesizedN, SynthesizedN)
|
matRow("Synthesized N", 5, synthesised_n, synthesisedN, SynthesisedN)
|
||||||
unavRow("Nanoc", 6)
|
unavRow("Nanoc", 6)
|
||||||
unavRow("Abyssillite", 7)
|
unavRow("Abyssillite", 7)
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ void SaveTool::drawResearchInventory() {
|
||||||
matRow("Void residue", 2, void_residue, voidResidue, VoidResidue)
|
matRow("Void residue", 2, void_residue, voidResidue, VoidResidue)
|
||||||
matRow("Muscular construction", 3, muscular_construction, muscularConstruction, MuscularConstruction)
|
matRow("Muscular construction", 3, muscular_construction, muscularConstruction, MuscularConstruction)
|
||||||
matRow("Mineral exoskeletology", 4, mineral_exoskeletology, mineralExoskeletology, MineralExoskeletology)
|
matRow("Mineral exoskeletology", 4, mineral_exoskeletology, mineralExoskeletology, MineralExoskeletology)
|
||||||
matRow("Carbonized skin", 5, carbonized_skin, carbonizedSkin, CarbonizedSkin)
|
matRow("Carbonized skin", 5, carbonised_skin, carbonisedSkin, CarbonisedSkin)
|
||||||
unavRow("Isolated void particle", 6)
|
unavRow("Isolated void particle", 6)
|
||||||
unavRow("Weaponised physiology", 7)
|
unavRow("Weaponised physiology", 7)
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ void SaveTool::drawMassManager() {
|
||||||
drag_drop_index = i;
|
drag_drop_index = i;
|
||||||
ImGui::SetDragDropPayload("Mass", &drag_drop_index, sizeof(int));
|
ImGui::SetDragDropPayload("Mass", &drag_drop_index, sizeof(int));
|
||||||
|
|
||||||
ImGui::Text("%s - Hangar %.2d", _massManager->hangar(i).name().c_str(), i + 1);
|
ImGui::Text("%s - Hangar %.2d", (*_massManager->hangar(i).name()).c_str(), i + 1);
|
||||||
|
|
||||||
ImGui::EndDragDropSource();
|
ImGui::EndDragDropSource();
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ void SaveTool::drawMassManager() {
|
||||||
ImGui::TextDisabled("<invalid>");
|
ImGui::TextDisabled("<invalid>");
|
||||||
break;
|
break;
|
||||||
case Mass::State::Valid:
|
case Mass::State::Valid:
|
||||||
ImGui::TextUnformatted(_massManager->hangar(i).name().c_str());
|
ImGui::TextUnformatted((*_massManager->hangar(i).name()).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImGui::Text("Are you sure you want to delete the M.A.S.S. named %s in hangar %.2i ? This operation is irreversible.",
|
ImGui::Text("Are you sure you want to delete the M.A.S.S. named %s in hangar %.2i ? This operation is irreversible.",
|
||||||
_massManager->hangar(mass_index).name().c_str(), mass_index + 1);
|
(*_massManager->hangar(mass_index).name()).c_str(), mass_index + 1);
|
||||||
}
|
}
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <Magnum/ImGuiIntegration/Integration.h>
|
||||||
|
|
||||||
#include "../Maps/StyleNames.h"
|
#include "../Maps/StyleNames.h"
|
||||||
|
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
|
@ -24,6 +26,7 @@ void SaveTool::drawMassViewer() {
|
||||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||||
_currentMass = nullptr;
|
_currentMass = nullptr;
|
||||||
_uiState = UiState::MainManager;
|
_uiState = UiState::MainManager;
|
||||||
|
_queue.addToast(Toast::Type::Error, "The selected M.A.S.S. isn't valid anymore.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +41,11 @@ void SaveTool::drawMassViewer() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::AlignTextToFramePadding();
|
|
||||||
ImGui::Text("Current M.A.S.S.: %s (%s)",
|
ImGui::Text("Current M.A.S.S.: %s (%s)",
|
||||||
_currentMass->name().c_str(),
|
(*_currentMass->name()).c_str(),
|
||||||
_currentMass->filename().c_str());
|
_currentMass->filename().c_str());
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button(ICON_FA_ARROW_LEFT " Back to main manager")) {
|
if(ImGui::SmallButton(ICON_FA_ARROW_LEFT " Back to main manager")) {
|
||||||
_currentMass = nullptr;
|
_currentMass = nullptr;
|
||||||
_uiState = UiState::MainManager;
|
_uiState = UiState::MainManager;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +54,17 @@ void SaveTool::drawMassViewer() {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextWrapped("WARNING: Colours in this app may look different from in-game colours, due to unavoidable differences in the rendering pipeline.");
|
ImGui::TextWrapped("WARNING: Colours in this app may look different from in-game colours, due to unavoidable differences in the rendering pipeline.");
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(255, 255, 0), ICON_FA_EXCLAMATION_TRIANGLE);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextWrapped("Real-time updates are disabled while on this screen. %s", _currentMass->dirty() ? "The save file has been changed." : "");
|
||||||
|
if(_currentMass->dirty()) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
if(ImGui::SmallButton(ICON_FA_SYNC_ALT " Refresh")) {
|
||||||
|
_currentMass->refreshValues();
|
||||||
|
_currentMass->setDirty(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ImGui::BeginChild("##MassInfo",
|
if(ImGui::BeginChild("##MassInfo",
|
||||||
{ImGui::GetContentRegionAvailWidth() * 0.60f, 0.0f},
|
{ImGui::GetContentRegionAvailWidth() * 0.60f, 0.0f},
|
||||||
true, ImGuiWindowFlags_MenuBar))
|
true, ImGuiWindowFlags_MenuBar))
|
||||||
|
@ -96,10 +109,19 @@ void SaveTool::drawFrameInfo() {
|
||||||
|
|
||||||
ImGui::TextUnformatted("Frame type: Skeleton"); // Placeholder for now, replace with actual code once other frames are implemented.
|
ImGui::TextUnformatted("Frame type: Skeleton"); // Placeholder for now, replace with actual code once other frames are implemented.
|
||||||
|
|
||||||
if(ImGui::CollapsingHeader("Joint sliders")) {
|
drawJointSliders();
|
||||||
|
|
||||||
|
drawFramePaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveTool::drawJointSliders() {
|
||||||
|
if(!ImGui::CollapsingHeader("Joint sliders")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static Joints sliders = _currentMass->jointSliders();
|
static Joints sliders = _currentMass->jointSliders();
|
||||||
static bool edit = false;
|
static bool joints_edit = false;
|
||||||
static bool dirty = false;
|
static bool joints_dirty = false;
|
||||||
|
|
||||||
ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game.");
|
ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game.");
|
||||||
|
|
||||||
|
@ -112,10 +134,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TextUnformatted("Neck");
|
ImGui::TextUnformatted("Neck");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##NeckSlider", &sliders.neck, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##NeckSlider", &sliders.neck, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -128,10 +150,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TextUnformatted("Body");
|
ImGui::TextUnformatted("Body");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##BodySlider", &sliders.body, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##BodySlider", &sliders.body, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -144,10 +166,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TextUnformatted("Shoulders");
|
ImGui::TextUnformatted("Shoulders");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##ShouldersSlider", &sliders.shoulders, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##ShouldersSlider", &sliders.shoulders, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -160,10 +182,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TextUnformatted("Hips");
|
ImGui::TextUnformatted("Hips");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##HipsSlider", &sliders.hips, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##HipsSlider", &sliders.hips, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -197,10 +219,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::TableSetupColumn("##LowerArms", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("##LowerArms", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##UpperArmsSlider", &sliders.upperArms, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##UpperArmsSlider", &sliders.upperArms, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -208,10 +230,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperArms));
|
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperArms));
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##LowerArmsSlider", &sliders.lowerArms, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##LowerArmsSlider", &sliders.lowerArms, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -232,10 +254,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::TableSetupColumn("##LowerLegs", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("##LowerLegs", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##UpperLegsSlider", &sliders.upperLegs, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##UpperLegsSlider", &sliders.upperLegs, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -243,10 +265,10 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperLegs));
|
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperLegs));
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
if(ImGui::SliderFloat("##LowerLegsSlider", &sliders.lowerLegs, 0.0f, 1.0f)) {
|
if(ImGui::SliderFloat("##LowerLegsSlider", &sliders.lowerLegs, 0.0f, 1.0f)) {
|
||||||
dirty = true;
|
joints_dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -260,43 +282,50 @@ void SaveTool::drawFrameInfo() {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(edit) {
|
if(joints_edit) {
|
||||||
if(!dirty) {
|
if(!joints_dirty) {
|
||||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
ImGui::BeginDisabled();
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
|
||||||
ImGui::Button(ICON_FA_SAVE " Save changes");
|
ImGui::Button(ICON_FA_SAVE " Save changes");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Button(ICON_FA_UNDO " Reset sliders");
|
ImGui::Button(ICON_FA_UNDO " Reset sliders");
|
||||||
ImGui::PopStyleVar();
|
ImGui::EndDisabled();
|
||||||
ImGui::PopItemFlag();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save changes"); })) {
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save changes"); })) {
|
||||||
dirty = false;
|
if(!_currentMass->setSliders(sliders)) {
|
||||||
|
_queue.addToast(Toast::Type::Error, "Error writing the joint sliders.");
|
||||||
|
}
|
||||||
|
joints_dirty = false;
|
||||||
|
joints_edit = false;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button(ICON_FA_UNDO " Reset sliders")) {
|
if(ImGui::Button(ICON_FA_UNDO " Reset sliders")) {
|
||||||
sliders = _currentMass->jointSliders();
|
sliders = _currentMass->jointSliders();
|
||||||
dirty = false;
|
joints_dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button(ICON_FA_TIMES " Cancel editing")) {
|
if(ImGui::Button(ICON_FA_TIMES " Cancel editing")) {
|
||||||
sliders = _currentMass->jointSliders();
|
sliders = _currentMass->jointSliders();
|
||||||
dirty = false;
|
joints_dirty = false;
|
||||||
edit = false;
|
joints_edit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TextUnformatted("To input out-of-range values, hold Ctrl and click on a slider.");
|
ImGui::TextUnformatted("To input out-of-range values, hold Ctrl and click on a slider.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(ImGui::Button(ICON_FA_EDIT " Edit sliders")) {
|
if(ImGui::Button(ICON_FA_EDIT " Edit sliders")) {
|
||||||
edit = true;
|
sliders = _currentMass->jointSliders();
|
||||||
|
joints_edit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveTool::drawFramePaint() {
|
||||||
|
if(!ImGui::CollapsingHeader("Paint")) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::CollapsingHeader("Paint")) {
|
|
||||||
ImGui::TextUnformatted("Frame styles:");
|
ImGui::TextUnformatted("Frame styles:");
|
||||||
for(Int i = 0; i < 4; i++) {
|
for(Int i = 0; i < 4; i++) {
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
|
@ -331,21 +360,64 @@ void SaveTool::drawFrameInfo() {
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
static const Int hex_literals[] = {0x3DF68F08, 0x3E791C4C, 0x00000000};
|
static bool eye_flare_edit = false;
|
||||||
static Float colour_components[3];
|
static bool eye_flare_dirty = false;
|
||||||
static bool run_once = true;
|
|
||||||
if(run_once) {
|
static Color4 eye_flare = _currentMass->eyeFlareColour();
|
||||||
std::memcpy(colour_components, hex_literals, sizeof(Float) * 3);
|
|
||||||
run_once = false;
|
|
||||||
}
|
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TextUnformatted("Eye flare colour:");
|
ImGui::TextUnformatted("Eye flare colour:");
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(-1.0f);
|
|
||||||
ImGui::ColorEdit3("##EyeFlarePicker", &colour_components[0]);
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::BeginGroup();
|
||||||
|
if(eye_flare_edit) {
|
||||||
ImGui::TextUnformatted("The frame's custom styles will go here.");
|
if(ImGui::ColorEdit3("##EyeFlarePicker", &eye_flare.x())) {
|
||||||
|
eye_flare_dirty = true;
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
drawHelpMarker("Right-click for more option, click the coloured square for the full picker.", 250.0f);
|
||||||
|
|
||||||
|
if(!eye_flare_dirty) {
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
ImGui::Button(ICON_FA_SAVE " Save");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Button(ICON_FA_UNDO " Reset");
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||||
|
if(!_currentMass->setEyeFlareColour(eye_flare)) {
|
||||||
|
_queue.addToast(Toast::Type::Error, "Error writing the eye flare colour.");
|
||||||
|
}
|
||||||
|
eye_flare_dirty = false;
|
||||||
|
eye_flare_edit = false;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if(ImGui::Button(ICON_FA_UNDO " Reset")) {
|
||||||
|
eye_flare = _currentMass->eyeFlareColour();
|
||||||
|
eye_flare_dirty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if(ImGui::Button(ICON_FA_TIMES " Cancel")) {
|
||||||
|
eye_flare = _currentMass->eyeFlareColour();
|
||||||
|
eye_flare_dirty = false;
|
||||||
|
eye_flare_edit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
ImColor colour{_currentMass->eyeFlareColour()};
|
||||||
|
ImGui::ColorEdit3("##EyeFlarePicker", &colour.Value.x);
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
if(ImGui::Button(ICON_FA_EDIT " Edit")) {
|
||||||
|
eye_flare = _currentMass->eyeFlareColour();
|
||||||
|
eye_flare_edit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndGroup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,5 @@ struct GenericStructProperty : public StructProperty {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
Containers::Array<UnrealPropertyBase::ptr> properties;
|
Containers::Array<UnrealPropertyBase::ptr> properties;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,9 +40,11 @@ auto UESaveFile::lastError() const -> const std::string& {
|
||||||
|
|
||||||
auto UESaveFile::reloadData() -> bool {
|
auto UESaveFile::reloadData() -> bool {
|
||||||
if(_noReloadAfterSave) {
|
if(_noReloadAfterSave) {
|
||||||
|
_noReloadAfterSave = false;
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_properties = Containers::Array<UnrealPropertyBase::ptr>{};
|
||||||
loadData();
|
loadData();
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
@ -211,8 +213,11 @@ void UESaveFile::loadData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_properties.back()->name != "None" && _properties.back()->propertyType != "NoneProperty") {
|
if(_properties.back()->name != "None" && _properties.back()->propertyType != "NoneProperty") {
|
||||||
|
_lastError = "Couldn't find a final NoneProperty.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reader.closeFile();
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue