diff --git a/src/Mass/Locators.h b/src/Mass/Locators.h index 51011c2..2cd1e1a 100644 --- a/src/Mass/Locators.h +++ b/src/Mass/Locators.h @@ -18,3 +18,5 @@ 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 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"; diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 87726ff..7545506 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -25,8 +25,6 @@ #include "Mass.h" -using namespace Corrade; - std::string Mass::_lastError; Mass::Mass(const std::string& path) { @@ -64,6 +62,12 @@ auto Mass::getNameFromFile(const std::string& path) -> std::string { void Mass::refreshValues() { getName(); + + if(_state != State::Valid) { + return; + } + + getFrameStyles(); } auto Mass::filename() -> std::string const&{ @@ -78,6 +82,41 @@ auto Mass::state() -> State { return _state; } +auto Mass::frameStyles() -> Containers::StaticArrayView<4, Int> { + return _frameStyles; +} + +auto Mass::setFrameStyle(Int index, Int style_id) -> bool { + if(index < 0 || index > 3) { + _lastError = "Index is out of range in Mass::setFrameStyle()."; + return false; + } + + std::string path = Utility::Directory::join(_folder, _filename); + + 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(iter) + index) = style_id; + } + else { + _lastError = "Frame styles couldn't be found in " + path; + _state = State::Invalid; + return false; + } + + return true; +} + auto Mass::updateSteamId(const std::string& steam_id) -> bool { std::string path = Utility::Directory::join(_folder, _filename); diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index c008fa1..cf9160f 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -18,8 +18,11 @@ #include +#include + #include +using namespace Corrade; using namespace Magnum; @@ -49,10 +52,14 @@ class Mass { auto state() -> State; + auto frameStyles() -> Containers::StaticArrayView<4, Int>; + auto setFrameStyle(Int index, Int style_id) -> bool; + auto updateSteamId(const std::string& steam_id) -> bool; private: void getName(); + void getFrameStyles(); static std::string _lastError; @@ -60,4 +67,6 @@ class Mass { std::string _filename; std::string _name; State _state = State::Empty; + + Containers::StaticArray<4, Int> _frameStyles; };