Build viewer/editor #13
3 changed files with 52 additions and 2 deletions
|
@ -18,3 +18,5 @@
|
||||||
|
|
||||||
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 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";
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
#include "Mass.h"
|
#include "Mass.h"
|
||||||
|
|
||||||
using namespace Corrade;
|
|
||||||
|
|
||||||
std::string Mass::_lastError;
|
std::string Mass::_lastError;
|
||||||
|
|
||||||
Mass::Mass(const std::string& path) {
|
Mass::Mass(const std::string& path) {
|
||||||
|
@ -64,6 +62,12 @@ auto Mass::getNameFromFile(const std::string& path) -> std::string {
|
||||||
|
|
||||||
void Mass::refreshValues() {
|
void Mass::refreshValues() {
|
||||||
getName();
|
getName();
|
||||||
|
|
||||||
|
if(_state != State::Valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getFrameStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mass::filename() -> std::string const&{
|
auto Mass::filename() -> std::string const&{
|
||||||
|
@ -78,6 +82,41 @@ auto Mass::state() -> State {
|
||||||
return _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<Int*>(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 {
|
auto Mass::updateSteamId(const std::string& steam_id) -> bool {
|
||||||
std::string path = Utility::Directory::join(_folder, _filename);
|
std::string path = Utility::Directory::join(_folder, _filename);
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,11 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <Corrade/Containers/StaticArray.h>
|
||||||
|
|
||||||
#include <Magnum/Magnum.h>
|
#include <Magnum/Magnum.h>
|
||||||
|
|
||||||
|
using namespace Corrade;
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,10 +52,14 @@ class Mass {
|
||||||
|
|
||||||
auto state() -> State;
|
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;
|
auto updateSteamId(const std::string& steam_id) -> bool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getName();
|
void getName();
|
||||||
|
void getFrameStyles();
|
||||||
|
|
||||||
static std::string _lastError;
|
static std::string _lastError;
|
||||||
|
|
||||||
|
@ -60,4 +67,6 @@ class Mass {
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
State _state = State::Empty;
|
State _state = State::Empty;
|
||||||
|
|
||||||
|
Containers::StaticArray<4, Int> _frameStyles;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue