From d38606b57405a3330d9fa466ccb19be6c32446df Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 5 Oct 2020 00:55:08 +0200 Subject: [PATCH] Add two more values. --- GUI/EvtMainFrame.cpp | 20 ++++ GUI/MainFrame.cpp | 26 ++++- GUI/MainFrame.fbp | 246 ++++++++++++++++++++++++++++++++++++++++++- GUI/MainFrame.h | 4 + Profile/Profile.cpp | 43 ++++++++ Profile/Profile.h | 10 ++ 6 files changed, 347 insertions(+), 2 deletions(-) diff --git a/GUI/EvtMainFrame.cpp b/GUI/EvtMainFrame.cpp index 6a2568a..0b197c2 100644 --- a/GUI/EvtMainFrame.cpp +++ b/GUI/EvtMainFrame.cpp @@ -36,6 +36,24 @@ #include "EvtMainFrame.h" +static const std::map mission_id_map {{ + {25600, "Mission 1 - Training"}, + {25856, "Mission 2 - Patrol Operation"}, + {26112, "Mission 3 - Fusion Cells in the Snow"}, + {26368, "Mission 4 - Earning Changes"}, + {26624, "Mission 5 - Unexpected Coordination"}, + {26880, "Mission 6 - Empowering Void"}, + {27136, "Mission 7 - Logisitics Obstacles"}, + {27392, "Mission 8 - Wrath of the Wastelands"}, + {27648, "Mission 9 - Suspicious Originator"}, + {27904, "Mission 10 - Researchers Data Recovery"}, + {28160, "Mission 11 - Tempestuous Sector"}, + {28416, "Mission 12 - Clashes of Metal"}, + {51200, "Hunting Ground 1 - Desert Pathway Safety"}, + {51456, "Hunting Ground 2 - Snowfield Custodian"}, + {51712, "Hunting Ground 3 - Abandoned Valley Raid"}, +}}; + EvtMainFrame::EvtMainFrame(wxWindow* parent): MainFrame(parent), _profileManager{_mbManager.saveDirectory()} @@ -519,6 +537,8 @@ void EvtMainFrame::updateProfileStats() { Profile* current_profile = _profileManager.currentProfile(); _companyName->SetLabel(current_profile->companyName()); _credits->SetLabel(wxString::Format("%i", current_profile->getCredits())); + _storyProgress->SetLabel(wxString::Format("%i", current_profile->getStoryProgress())); + _lastMissionId->SetLabel(wxString::Format("%s", mission_id_map.find(current_profile->getLastMissionId()) != mission_id_map.end() ? mission_id_map.at(current_profile->lastMissionId()) : std::to_string(current_profile->lastMissionId()))); } void EvtMainFrame::initialiseListView() { diff --git a/GUI/MainFrame.cpp b/GUI/MainFrame.cpp index 2acc39d..5fae8c0 100644 --- a/GUI/MainFrame.cpp +++ b/GUI/MainFrame.cpp @@ -43,7 +43,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _managerNotebook = new wxNotebook( _mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); _profilePanel = new wxPanel( _managerNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerProfilePanel; - bSizerProfilePanel = new wxBoxSizer( wxHORIZONTAL ); + bSizerProfilePanel = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbSizerGeneralInfo; sbSizerGeneralInfo = new wxStaticBoxSizer( new wxStaticBox( _profilePanel, wxID_ANY, wxT("General information") ), wxVERTICAL ); @@ -70,6 +70,30 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _credits->Wrap( -1 ); fgSizerGeneralStats->Add( _credits, 0, wxALL|wxEXPAND, 5 ); + _storyProgressLabel = new wxStaticText( sbSizerGeneralInfo->GetStaticBox(), wxID_ANY, wxT("Story progress:"), wxDefaultPosition, wxDefaultSize, 0 ); + _storyProgressLabel->Wrap( -1 ); + _storyProgressLabel->SetToolTip( wxT("What this value does or corresponds to is unknown at this point in time. It is only listed here for the sake of completion.") ); + + fgSizerGeneralStats->Add( _storyProgressLabel, 0, wxALL, 5 ); + + _storyProgress = new wxStaticText( sbSizerGeneralInfo->GetStaticBox(), wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 ); + _storyProgress->Wrap( -1 ); + _storyProgress->SetToolTip( wxT("What this value does or corresponds to is unknown at this point in time. It is only listed here for the sake of completion.") ); + + fgSizerGeneralStats->Add( _storyProgress, 0, wxALL, 5 ); + + _lastMissionIdLabel = new wxStaticText( sbSizerGeneralInfo->GetStaticBox(), wxID_ANY, wxT("Last mission ID:"), wxDefaultPosition, wxDefaultSize, 0 ); + _lastMissionIdLabel->Wrap( -1 ); + _lastMissionIdLabel->SetToolTip( wxT("This corresponds to the last mission menu selection, not the last mission played.\nIf you see just a number instead of the mission name, please report it to the creator of this application.") ); + + fgSizerGeneralStats->Add( _lastMissionIdLabel, 0, wxALL, 5 ); + + _lastMissionId = new wxStaticText( sbSizerGeneralInfo->GetStaticBox(), wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 ); + _lastMissionId->Wrap( -1 ); + _lastMissionId->SetToolTip( wxT("This corresponds to the last mission menu selection, not the last mission played.\nIf you see just a number instead of the mission name, please report it to the creator of this application.") ); + + fgSizerGeneralStats->Add( _lastMissionId, 0, wxALL, 5 ); + sbSizerGeneralInfo->Add( fgSizerGeneralStats, 1, wxEXPAND, 5 ); diff --git a/GUI/MainFrame.fbp b/GUI/MainFrame.fbp index a86bd88..54e1a87 100644 --- a/GUI/MainFrame.fbp +++ b/GUI/MainFrame.fbp @@ -445,7 +445,7 @@ bSizerProfilePanel - wxHORIZONTAL + wxVERTICAL none 5 @@ -719,6 +719,250 @@ -1 + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Story progress: + 0 + + 0 + + + 0 + + 1 + _storyProgressLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + What this value does or corresponds to is unknown at this point in time. It is only listed here for the sake of completion. + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + + 1 + _storyProgress + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + What this value does or corresponds to is unknown at this point in time. It is only listed here for the sake of completion. + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Last mission ID: + 0 + + 0 + + + 0 + + 1 + _lastMissionIdLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This corresponds to the last mission menu selection, not the last mission played. If you see just a number instead of the mission name, please report it to the creator of this application. + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + + 1 + _lastMissionId + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This corresponds to the last mission menu selection, not the last mission played. If you see just a number instead of the mission name, please report it to the creator of this application. + + + + -1 + + diff --git a/GUI/MainFrame.h b/GUI/MainFrame.h index 5cf6c7f..c7d5d81 100644 --- a/GUI/MainFrame.h +++ b/GUI/MainFrame.h @@ -52,6 +52,10 @@ class MainFrame : public wxFrame wxStaticText* _companyName; wxStaticText* _creditsLabel; wxStaticText* _credits; + wxStaticText* _storyProgressLabel; + wxStaticText* _storyProgress; + wxStaticText* _lastMissionIdLabel; + wxStaticText* _lastMissionId; wxPanel* _massPanel; wxListView* _installedListView; wxButton* _moveButton; diff --git a/Profile/Profile.cpp b/Profile/Profile.cpp index 1420fda..86daecc 100644 --- a/Profile/Profile.cpp +++ b/Profile/Profile.cpp @@ -35,6 +35,8 @@ constexpr char company_name_locator[] = "CompanyName\0\x0c\0\0\0StrProperty"; constexpr char active_slot_locator[] = "ActiveFrameSlot\0\x0c\0\0\0IntProperty"; constexpr char credits_locator[] = "Credit\0\x0c\0\0\0IntProperty"; +constexpr char story_progress_locator[] = "StoryProgress\0\x0c\0\0\0IntProperty"; +constexpr char last_mission_id_locator[] = "LastMissionID\0\x0c\0\0\0IntProperty"; using namespace Corrade; @@ -132,12 +134,53 @@ auto Profile::getCredits() -> std::int32_t { _credits = *reinterpret_cast(iter + 0x20); } else{ + _lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file."; _credits = -1; } return _credits; } +auto Profile::storyProgress() -> std::int32_t { + return _storyProgress; +} + +auto Profile::getStoryProgress() -> std::int32_t { + auto mmap = Utility::Directory::mapRead(Utility::Directory::join(_profileDirectory, _filename)); + + auto iter = std::search(mmap.begin(), mmap.end(), &story_progress_locator[0], &story_progress_locator[29]); + + if(iter != mmap.end()) { + _storyProgress = *reinterpret_cast(iter + 0x26); + } + else{ + _lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file."; + _storyProgress = -1; + } + + return _storyProgress; +} + +auto Profile::lastMissionId() -> std::int32_t { + return _lastMissionId; +} + +auto Profile::getLastMissionId() -> std::int32_t { + auto mmap = Utility::Directory::mapRead(Utility::Directory::join(_profileDirectory, _filename)); + + auto iter = std::search(mmap.begin(), mmap.end(), &last_mission_id_locator[0], &last_mission_id_locator[29]); + + if(iter != mmap.end()) { + _lastMissionId = *reinterpret_cast(iter + 0x26); + } + else{ + _lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file."; + _lastMissionId = -1; + } + + return _lastMissionId; +} + auto Profile::backup(const std::string& filename) -> bool { if(filename.empty() || (filename.length() < 5 && !Utility::String::endsWith(filename, ".zip"))) { _lastError = "Invalid filename " + filename + " in Profile::backup()"; diff --git a/Profile/Profile.h b/Profile/Profile.h index 0387fcf..33611c6 100644 --- a/Profile/Profile.h +++ b/Profile/Profile.h @@ -32,6 +32,12 @@ class Profile { auto credits() const -> std::int32_t; auto getCredits() -> std::int32_t; + auto storyProgress() -> std::int32_t; + auto getStoryProgress() -> std::int32_t; + + auto lastMissionId() -> std::int32_t; + auto getLastMissionId() -> std::int32_t; + auto backup(const std::string& filename) -> bool; private: @@ -50,6 +56,10 @@ class Profile { std::int8_t _activeFrameSlot = 0; std::int32_t _credits; + + std::int32_t _storyProgress; + + std::int32_t _lastMissionId; }; #endif //PROFILE_H