Compare commits

...

5 commits

Author SHA1 Message Date
918b26ab5e SaveTool: add some frame info display. 2021-09-10 16:16:21 +02:00
32bc179120 SaveTool: change an include.
The old one works on my setup, but might not work on others.
2021-09-10 16:15:27 +02:00
c64684b34c StyleNames: add placeholders for custom/global style names. 2021-09-10 16:14:31 +02:00
40840e3128 Mass: add support for reading joint sliders. 2021-09-10 16:13:29 +02:00
c7c379c419 SaveTool: adapt main manager to Mass changes. 2021-08-29 19:39:29 +02:00
7 changed files with 421 additions and 9 deletions

View file

@ -23,6 +23,40 @@
using namespace Magnum; using namespace Magnum;
static const std::map<Int, const char*> style_names { static const std::map<Int, const char*> style_names {
{0, "Custom Style 1"},
{1, "Custom Style 2"},
{2, "Custom Style 3"},
{3, "Custom Style 4"},
{4, "Custom Style 5"},
{5, "Custom Style 6"},
{6, "Custom Style 7"},
{7, "Custom Style 8"},
{8, "Custom Style 9"},
{9, "Custom Style 10"},
{10, "Custom Style 11"},
{11, "Custom Style 12"},
{12, "Custom Style 13"},
{13, "Custom Style 14"},
{14, "Custom Style 15"},
{15, "Custom Style 16"},
{50, "Global Style 1"},
{51, "Global Style 2"},
{52, "Global Style 3"},
{53, "Global Style 4"},
{54, "Global Style 5"},
{55, "Global Style 6"},
{56, "Global Style 7"},
{57, "Global Style 8"},
{58, "Global Style 9"},
{59, "Global Style 10"},
{60, "Global Style 11"},
{61, "Global Style 12"},
{62, "Global Style 13"},
{63, "Global Style 14"},
{64, "Global Style 15"},
{65, "Global Style 16"},
{100, "Iron"}, {100, "Iron"},
{101, "Silver"}, {101, "Silver"},
{102, "Gold"}, {102, "Gold"},

View file

@ -19,4 +19,13 @@
constexpr char mass_name_locator[] = "Name_45_A037C5D54E53456407BDF091344529BB\0\f\0\0\0StrProperty"; 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 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"; 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";

View file

@ -68,6 +68,7 @@ void Mass::refreshValues() {
} }
getFrameStyles(); getFrameStyles();
getJointSliders();
} }
auto Mass::filename() -> std::string const&{ auto Mass::filename() -> std::string const&{
@ -82,6 +83,10 @@ auto Mass::state() -> State {
return _state; return _state;
} }
auto Mass::jointSliders() -> Joints const& {
return _sliders;
}
auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> { auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> {
return _frameStyles; return _frameStyles;
} }
@ -180,6 +185,90 @@ void Mass::getName() {
} }
} }
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() { void Mass::getFrameStyles() {
std::string path = Utility::Directory::join(_folder, _filename); std::string path = Utility::Directory::join(_folder, _filename);

View file

@ -25,6 +25,16 @@
using namespace Corrade; using namespace Corrade;
using namespace Magnum; using namespace Magnum;
struct Joints {
Float neck = 0.0f;
Float body = 0.0f;
Float shoulders = 0.0f;
Float hips = 0.0f;
Float upperArms = 0.0f;
Float lowerArms = 0.0f;
Float upperLegs = 0.0f;
Float lowerLegs = 0.0f;
};
class Mass { class Mass {
public: public:
@ -52,6 +62,8 @@ class Mass {
auto state() -> State; auto state() -> State;
auto jointSliders() -> Joints const&;
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;
@ -59,6 +71,7 @@ class Mass {
private: private:
void getName(); void getName();
void getJointSliders();
void getFrameStyles(); void getFrameStyles();
static std::string _lastError; static std::string _lastError;
@ -68,5 +81,7 @@ class Mass {
std::string _name; std::string _name;
State _state = State::Empty; State _state = State::Empty;
Joints _sliders;
Containers::StaticArray<4, Int> _frameStyles; Containers::StaticArray<4, Int> _frameStyles;
}; };

View file

@ -25,7 +25,7 @@
#include <Magnum/Platform/Sdl2Application.h> #include <Magnum/Platform/Sdl2Application.h>
#include <Magnum/ImGuiIntegration/Context.h> #include <Magnum/ImGuiIntegration/Context.h>
#include <SDL2/SDL.h> #include <SDL.h>
#include <imgui.h> #include <imgui.h>
#include <imgui_internal.h> #include <imgui_internal.h>
@ -104,6 +104,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID; auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
void drawMassViewer(); void drawMassViewer();
void drawFrameInfo();
void drawAbout(); void drawAbout();
void drawGameState(); void drawGameState();

View file

@ -429,7 +429,7 @@ void SaveTool::drawMassManager() {
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Selectable(Utility::formatString("{:.2d}", i + 1).c_str(), ImGui::Selectable(Utility::formatString("{:.2d}", i + 1).c_str(),
false, ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap); false, ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap);
if(_massManager->hangar(i).state() == MassState::Valid && if(_massManager->hangar(i).state() == Mass::State::Valid &&
ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers))
{ {
drag_drop_index = i; drag_drop_index = i;
@ -477,13 +477,13 @@ void SaveTool::drawMassManager() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
switch(_massManager->hangar(i).state()) { switch(_massManager->hangar(i).state()) {
case MassState::Empty: case Mass::State::Empty:
ImGui::TextDisabled("<empty>"); ImGui::TextDisabled("<empty>");
break; break;
case MassState::Invalid: case Mass::State::Invalid:
ImGui::TextDisabled("<invalid>"); ImGui::TextDisabled("<invalid>");
break; break;
case MassState::Valid: case Mass::State::Valid:
ImGui::TextUnformatted(_massManager->hangar(i).name().c_str()); ImGui::TextUnformatted(_massManager->hangar(i).name().c_str());
break; break;
} }
@ -494,10 +494,10 @@ void SaveTool::drawMassManager() {
drawTooltip("This is the currently active frame slot."); drawTooltip("This is the currently active frame slot.");
} }
if(_massManager->hangar(i).state() != MassState::Empty) { if(_massManager->hangar(i).state() != Mass::State::Empty) {
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(i); ImGui::PushID(i);
if(_massManager->hangar(i).state() == MassState::Valid) { if(_massManager->hangar(i).state() == Mass::State::Valid) {
if(ImGui::SmallButton(ICON_FA_SEARCH)) { if(ImGui::SmallButton(ICON_FA_SEARCH)) {
_currentMass = &_massManager->hangar(i); _currentMass = &_massManager->hangar(i);
_uiState = UiState::MassViewer; _uiState = UiState::MassViewer;
@ -595,7 +595,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
return ImGui::GetID("Confirmation##DeleteMassConfirmation"); return ImGui::GetID("Confirmation##DeleteMassConfirmation");
} }
if(_massManager->hangar(mass_index).state() == MassState::Empty) { if(_massManager->hangar(mass_index).state() == Mass::State::Empty) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
ImGui::EndPopup(); ImGui::EndPopup();
return 0; return 0;
@ -608,7 +608,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
} }
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
if(_massManager->hangar(mass_index).state() == MassState::Invalid) { if(_massManager->hangar(mass_index).state() == Mass::State::Invalid) {
ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the invalid M.A.S.S. data in hangar %.2i ? This operation is irreversible.",
mass_index + 1); mass_index + 1);
} }

View file

@ -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 "../Maps/StyleNames.h"
#include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5.h"
#include "SaveTool.h" #include "SaveTool.h"
@ -61,6 +63,7 @@ void SaveTool::drawMassViewer() {
if(ImGui::BeginTabBar("##MassTabBar")) { if(ImGui::BeginTabBar("##MassTabBar")) {
if(ImGui::BeginTabItem("Frame")) { if(ImGui::BeginTabItem("Frame")) {
drawFrameInfo();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
@ -85,3 +88,264 @@ void SaveTool::drawMassViewer() {
ImGui::End(); ImGui::End();
} }
void SaveTool::drawFrameInfo() {
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
return;
}
ImGui::TextUnformatted("Frame type: Skeleton"); // Placeholder for now, replace with actual code once other frames are implemented.
if(ImGui::CollapsingHeader("Joint sliders")) {
static Joints sliders = _currentMass->jointSliders();
static bool edit = false;
static bool dirty = false;
ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game.");
if(ImGui::BeginTable("##JointSliderTable", 2, ImGuiTableFlags_Borders)) {
ImGui::TableSetupColumn("##SliderLabel", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("##Sliders", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Neck");
ImGui::TableSetColumnIndex(1);
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##NeckSlider", &sliders.neck, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().neck));
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Body");
ImGui::TableSetColumnIndex(1);
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##BodySlider", &sliders.body, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().body));
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Shoulders");
ImGui::TableSetColumnIndex(1);
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##ShouldersSlider", &sliders.shoulders, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().shoulders));
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Hips");
ImGui::TableSetColumnIndex(1);
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##HipsSlider", &sliders.hips, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().hips));
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(1);
if(ImGui::BeginTable("##UpperLowerLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("##Upper", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##Lower", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Upper");
ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Lower");
ImGui::EndTable();
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Arms");
ImGui::TableSetColumnIndex(1);
if(ImGui::BeginTable("##UpperLowerArmsLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("##UpperArms", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##LowerArms", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextColumn();
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##UpperArmsSlider", &sliders.upperArms, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperArms));
}
ImGui::TableNextColumn();
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##LowerArmsSlider", &sliders.lowerArms, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().lowerArms));
}
ImGui::EndTable();
}
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Legs");
ImGui::TableSetColumnIndex(1);
if(ImGui::BeginTable("##UpperLowerLegsLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
ImGui::TableSetupColumn("##UpperLegs", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##LowerLegs", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextColumn();
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##UpperLegsSlider", &sliders.upperLegs, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperLegs));
}
ImGui::TableNextColumn();
if(edit) {
ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##LowerLegsSlider", &sliders.lowerLegs, 0.0f, 1.0f)) {
dirty = true;
}
}
else {
ImGui::AlignTextToFramePadding();
ImGui::Text("%.3f", Double(_currentMass->jointSliders().lowerLegs));
}
ImGui::EndTable();
}
ImGui::EndTable();
}
if(edit) {
if(!dirty) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
ImGui::Button(ICON_FA_SAVE " Save changes");
ImGui::SameLine();
ImGui::Button(ICON_FA_UNDO " Reset sliders");
ImGui::PopStyleVar();
ImGui::PopItemFlag();
}
else {
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save changes"); })) {
dirty = false;
}
ImGui::SameLine();
if(ImGui::Button(ICON_FA_UNDO " Reset sliders")) {
sliders = _currentMass->jointSliders();
dirty = false;
}
}
ImGui::SameLine();
if(ImGui::Button(ICON_FA_TIMES " Cancel editing")) {
sliders = _currentMass->jointSliders();
dirty = false;
edit = false;
}
ImGui::TextUnformatted("To input out-of-range values, hold Ctrl and click on a slider.");
}
else {
if(ImGui::Button(ICON_FA_EDIT " Edit sliders")) {
edit = true;
}
}
}
if(ImGui::CollapsingHeader("Paint")) {
ImGui::TextUnformatted("Frame styles:");
for(Int i = 0; i < 4; i++) {
ImGui::AlignTextToFramePadding();
ImGui::Text("Slot %d:", i + 1);
ImGui::SameLine();
ImGui::PushID(i);
GameState game_state = _gameState;
if(!_unsafeMode && game_state != GameState::NotRunning) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
}
if(ImGui::BeginCombo("##Style", style_names.at(_currentMass->frameStyles()[i]))) {
for(const auto& style : style_names) {
if(ImGui::Selectable(style.second, _currentMass->frameStyles()[i] == style.first)) {
if(!_currentMass->setFrameStyle(i, style.first)) {
_queue.addToast(Toast::Type::Error, Mass::lastError());
}
else {
_currentMass->refreshValues();
}
}
}
ImGui::EndCombo();
}
if(!_unsafeMode && game_state != GameState::NotRunning) {
ImGui::PopItemFlag();
ImGui::PopStyleVar();
}
ImGui::PopID();
}
ImGui::Separator();
static const Int hex_literals[] = {0x3DF68F08, 0x3E791C4C, 0x00000000};
static Float colour_components[3];
static bool run_once = true;
if(run_once) {
std::memcpy(colour_components, hex_literals, sizeof(Float) * 3);
run_once = false;
}
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Eye flare colour:");
ImGui::SameLine();
ImGui::SetNextItemWidth(-1.0f);
ImGui::ColorEdit3("##EyeFlarePicker", &colour_components[0]);
ImGui::Separator();
ImGui::TextUnformatted("The frame's custom styles will go here.");
}
}