Compare commits

...

22 commits

Author SHA1 Message Date
4883b617fd Change project structure and update copyright years. 2021-05-20 22:46:59 +02:00
e98a5e9d26 Add the FindCorrade module to modules directory. 2021-05-14 19:51:07 +02:00
768bcd1e5f Update the CMakeLists. 2021-05-14 19:50:31 +02:00
896c48290d Update Corrade to latest version. 2021-05-14 19:39:34 +02:00
34cba84362 MainFrame: reduce proportion of the general info. 2021-05-13 22:49:01 +02:00
3cb897ccda EvtMainFrame: Add some extra safety, just in case. 2021-05-12 20:39:48 +02:00
0ce8046728 Bump version number. 2021-05-12 20:27:03 +02:00
13b2614af0 Add a way to edit credits. 2021-05-12 20:21:35 +02:00
171fee333f EvtMainFrame: fix a function signature. 2021-05-12 15:11:05 +02:00
1d7c08b3ca Add a viewer/editor for the research inventory. 2021-05-12 13:53:51 +02:00
32c193a53b MainFrame: change size constraints. 2021-05-11 19:29:25 +02:00
ae2a613879 Profile: move locators to their own header. 2021-05-11 19:28:26 +02:00
a310669839 Bump version number. 2021-05-11 14:54:42 +02:00
f532803d56 Add a way to change the story progression state. 2021-05-11 14:54:33 +02:00
9ebd418ed2 MainFrame: fix the rename event. 2021-05-11 14:53:41 +02:00
3c8e82da96 EvtMainFrame: make the PMC rename button safer. 2021-05-11 14:52:52 +02:00
640f378357 EvtMainFrame: remove an extra line. 2021-05-11 14:51:54 +02:00
3c64f59a8c Expose the company renaming feature. 2021-05-11 14:51:33 +02:00
0ccc232afa Remove the screenshot management feature.
I really wasn't satisfied with it, to be honest.
2021-05-10 21:20:19 +02:00
5256b11a46 Add support for the very first progress state. 2021-05-10 20:33:44 +02:00
bb283b0603 Bump version up. 2021-05-10 19:58:02 +02:00
7eceaf329e Fix values for StoryProgress and LastMissionId.
They aren't bad per se, they're just off.
2021-05-10 19:54:46 +02:00
37 changed files with 3078 additions and 1745 deletions

View file

@ -1,5 +1,5 @@
# wxMASSManager
# Copyright (C) 2020 Guillaume Jacquemin
# Copyright (C) 2020-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
@ -18,84 +18,23 @@ cmake_minimum_required(VERSION 3.5)
project(wxMASSManager LANGUAGES CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(USE_CORRADE_SUBMODULE "Use Corrade from the Git submodule. If set to OFF, make sure you have Corrade 2020.06 or later installed to a path CMake can search in." ON)
if(USE_CORRADE_SUBMODULE)
set(BUILD_STATIC ON CACHE BOOL "" FORCE)
set(BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
set(BUILD_STATIC_UNIQUE_GLOBALS OFF CACHE BOOL "" FORCE)
set(WITH_INTERCONNECT OFF CACHE BOOL "" FORCE)
set(WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
set(WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
add_subdirectory(corrade EXCLUDE_FROM_ALL)
endif()
find_package(Corrade REQUIRED Containers Utility)
include_directories(SYSTEM "C:/msys64/mingw64/lib/wx/include/msw-unicode-static-3.0")
include_directories(SYSTEM "C:/msys64/mingw64/include/wx-3.0")
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
add_executable(wxMASSManager WIN32
main.cpp
GUI/MainFrame.fbp
GUI/MainFrame.h
GUI/MainFrame.cpp
GUI/EvtMainFrame.h
GUI/EvtMainFrame.cpp
GUI/NameChangeDialog.fbp
GUI/NameChangeDialog.h
GUI/NameChangeDialog.cpp
GUI/EvtNameChangeDialog.h
GUI/EvtNameChangeDialog.cpp
Maps/LastMissionId.h
Maps/StoryProgress.h
Mass/Mass.h
Mass/Mass.cpp
MassBuilderManager/MassBuilderManager.h
MassBuilderManager/MassBuilderManager.cpp
MassManager/MassManager.h
MassManager/MassManager.cpp
Profile/Profile.h
Profile/Profile.cpp
ProfileManager/ProfileManager.h
ProfileManager/ProfileManager.cpp
ScreenshotManager/ScreenshotManager.h
ScreenshotManager/ScreenshotManager.cpp
resource.rc)
target_compile_options(wxMASSManager PRIVATE -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -fpermissive)
target_link_options(wxMASSManager PRIVATE -static -static-libgcc -static-libstdc++ -pipe -Wl,--subsystem,windows -mwindows)
target_link_libraries(wxMASSManager PRIVATE
Corrade::Containers
Corrade::Utility
wx_mswu_adv-3.0
wx_mswu_core-3.0
wx_baseu-3.0
wxregexu-3.0
wxexpat-3.0
wxtiff-3.0
wxjpeg-3.0
wxpng-3.0
wxzlib-3.0
rpcrt4
oleaut32
ole32
uuid
lzma
jbig
winspool
winmm
shell32
comctl32
comdlg32
advapi32
wsock32
gdi32
oleacc
wtsapi32)
add_subdirectory(src)

View file

@ -1,49 +0,0 @@
// wxMASSManager
// Copyright (C) 2020 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/>.
#pragma once
#include <cstdint>
#include <map>
static const std::map<std::int32_t, const char*> mission_id_map {{
// Story missions
{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"},
{28672, "Mission 13 - The Sandstorm Glutton"},
// Hunting grounds
{51200, "Hunt 1 - Desert Pathway Safety"},
{51456, "Hunt 2 - Snowfield Custodian"},
{51712, "Hunt 3 - Abandoned Valley Raid"},
{51968, "Hunt 4 - Depths of the Machineries"},
// Challenges
{76800, "Challenge 1 - Redline Battlefront"},
{81920, "Challenge 2 - Void Convergence"},
{102400, "Challenge 3 - Gates of Ascension"}
}};

View file

@ -1,95 +0,0 @@
// wxMASSManager
// Copyright (C) 2020 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/>.
#pragma once
#include <cstdint>
#include <map>
static const std::map<std::int32_t, const char*> story_progress_map {{
{25600, "Chapter 1 start"},
{25856, "Chapter 1 - After 1st meeting with Quin in mission section"},
{26112, "Chapter 1 - After training, talking with Reina and Quin in hangar"},
{26368, "Chapter 1 - After training, returned to hangar"},
{26624, "Chapter 1 - After training, talked with Quin in development section"},
{26880, "Chapter 1 - After training, talked with Waltz in armour section"},
{51200, "Chapter 1 - After training, talked with Kael in tuning section"},
{51456, "Chapter 1 - After training, got mission 2 briefing"},
{76800, "Chapter 1 - After mission 2, talking with Reina"},
{77056, "Chapter 1 - After mission 2, returned to hangar"},
{77312, "Chapter 1 - After mission 2, talked with Kael in tuning section"},
{77568, "Chapter 1 - After mission 2, talked with Reina in hangar"},
{77824, "Chapter 1 - After mission 2, got mission 3 briefing"},
{102400, "Chapter 1 - After mission 3, talking with Reina"},
{102656, "Chapter 1 - After mission 3, returned to hangar"},
{102912, "Chapter 1 - After mission 3, talked with Waltz in armour section"},
{103168, "Chapter 1 - After mission 3, got mission 4 briefing"},
{128000, "Chapter 1 - After mission 4, talking with Reina"},
{128256, "Chapter 1 - After mission 4, returned to hangar"},
{128512, "Chapter 1 - After mission 4, talked with Waltz in armour section"},
{128768, "Chapter 1 - After mission 4, talked with Reina in hangar"},
{129024, "Chapter 1 - After mission 4, got mission 5 and hunt 1 briefing"},
{153600, "Chapter 1 - After mission 5, meeting Neon and Aine"},
{153856, "Chapter 1 - After mission 5, returned to hangar"},
{154112, "Chapter 1 - After mission 5, got mission 6 briefing"},
{179200, "Chapter 1 - After mission 6, talking with Reina"},
{179456, "Chapter 1 - After mission 6, returned to hangar"},
{179712, "Chapter 1 - After mission 6, got hunt 2 briefing"},
{179968, "Chapter 1 - After mission 6, met Ellenier"},
{180224, "Chapter 1 - After mission 6, got mission 7 briefing"},
{204800, "Chapter 1 - After mission 7, talking with Nier"},
{205056, "Chapter 1 - After mission 7, returned to hangar"},
{205312, "Chapter 1 - After mission 7, talked with Quin, Reina, and Nier in development section"},
{205568, "Chapter 1 - After mission 7, got mission 8 briefing"},
{230400, "Chapter 1 - After mission 8, talking with crew in hangar"},
{230656, "Chapter 1 - After mission 8, returned to hangar"},
{230912, "Chapter 1 - After mission 8, got hunt 3 briefing"},
{231168, "Chapter 1 - After mission 8, talked with Reina, Nier, and Quin in development section"},
{231424, "Chapter 2 start"},
{231680, "Chapter 2 - Got mission 9 briefing"},
{256000, "Chapter 2 - After mission 9, talking with Reina in hangar"},
{256256, "Chapter 2 - After mission 9, returned to hangar"},
{256512, "Chapter 2 - After mission 9, talked with crew in armour section"},
{256768, "Chapter 2 - After mission 9, got mission 10 briefing"},
{281600, "Chapter 2 - After mission 10, talking with Reina in hangar"},
{281856, "Chapter 2 - After mission 10, returned to hangar"},
{282112, "Chapter 2 - After mission 10, got mission 11 briefing"},
{307200, "Chapter 2 - After mission 11, talking with Reina and Nier in hangar"},
{307456, "Chapter 2 - After mission 11, returned to hangar"},
{307712, "Chapter 2 - After mission 11, got mission 12 briefing"},
{332800, "Chapter 2 - After mission 12, talking with Reina and Waltz in hangar"},
{333056, "Chapter 2 - After mission 12, returned to hangar"},
{333312, "Chapter 2 - After mission 12, got hunt 4 and mission 13 briefing"},
{358400, "Chapter 2 - After mission 13, talking with Reina in hangar"},
{358656, "Chapter 2 - After mission 13, returned to hangar"},
{358912, "Chapter 2 - After mission 13, talked with Reina in development section"},
{359168, "Chapter 2 - After mission 13, got briefing for challenges 1, 2, and 3"},
}};

View file

@ -1,265 +0,0 @@
// wxMASSManager
// Copyright (C) 2020 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/>.
#include <Corrade/version.h>
#if !(CORRADE_VERSION_YEAR * 100 + CORRADE_VERSION_MONTH >= 202006)
#error This application requires Corrade 2020.06 or later to build.
#endif
#include <algorithm>
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/String.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include "Profile.h"
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;
Profile::Profile(const std::string& path) {
auto map = Utility::Directory::mapRead(path);
if(!map) {
_lastError = "Couldn't memory-map " + Utility::Directory::filename(path);
return;
}
_profileDirectory = Utility::Directory::path(path);
_filename = Utility::Directory::filename(path);
if(Utility::String::beginsWith(_filename, "Demo")) {
_type = ProfileType::Demo;
}
else {
_type = ProfileType::FullGame;
}
_steamId = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"});
auto it = std::search(map.begin(), map.end(), &company_name_locator[0], &company_name_locator[27]);
if(it == map.end()) {
_lastError = "Couldn't find a company name in " + _filename;
return;
}
_companyName = std::string{it + 41};
_valid = true;
}
auto Profile::valid() const -> bool {
return _valid;
}
auto Profile::lastError() const -> std::string const& {
return _lastError;
}
auto Profile::filename() const -> std::string const& {
return _filename;
}
auto Profile::type() const -> ProfileType {
return _type;
}
auto Profile::steamId() const -> std::string const& {
return _steamId;
}
auto Profile::companyName() const -> std::string const& {
return _companyName;
}
auto Profile::getCompanyName() -> std::string const& {
auto mmap = Utility::Directory::mapRead(Utility::Directory::join(_profileDirectory, _filename));
auto it = std::search(mmap.begin(), mmap.end(), &company_name_locator[0], &company_name_locator[27]);
if(it == mmap.end()) {
_lastError = "Couldn't find a company name in " + _filename;
_companyName = "";
}
else {
_companyName = std::string{it + 41};
}
return _companyName;
}
auto Profile::renameCompany(const std::string& new_name) -> bool {
char length_difference = static_cast<char>(_companyName.length() - new_name.length());
std::string profile_data = Utility::Directory::readString(Utility::Directory::join(_profileDirectory, _filename));
auto iter = std::search(profile_data.begin(), profile_data.end(), &company_name_locator[0], &company_name_locator[27]);
if(iter != profile_data.end()) {
*(iter + 0x1C) = *(iter + 0x1C) - length_difference;
*(iter + 0x25) = *(iter + 0x25) - length_difference;
while(*(iter + 0x29) != '\0') {
profile_data.erase(iter + 0x29);
}
profile_data.insert(iter + 0x29, new_name.cbegin(), new_name.cend());
if(!Utility::Directory::writeString(Utility::Directory::join(_profileDirectory, _filename), profile_data)) {
_lastError = "The file" + _filename + " couldn't be written to.";
return false;
}
_companyName = new_name;
return true;
}
else {
_lastError = "Couldn't find the company name in " + _filename;
return false;
}
}
auto Profile::activeFrameSlot() const -> std::int8_t {
return _activeFrameSlot;
}
auto Profile::getActiveFrameSlot() -> std::int8_t {
auto mmap = Utility::Directory::mapRead(Utility::Directory::join(_profileDirectory, _filename));
auto iter = std::search(mmap.begin(), mmap.end(), &active_slot_locator[0], &active_slot_locator[31]);
if(iter == mmap.end()) {
if(std::search(mmap.begin(), mmap.end(), &credits_locator[0], &credits_locator[22]) != mmap.end()) {
_activeFrameSlot = 0;
}
else {
_lastError = "The profile save seems to be corrupted or the game didn't release the handle on the file.";
_activeFrameSlot = -1;
}
}
else {
_activeFrameSlot = *(iter + 41);
}
return _activeFrameSlot;
}
auto Profile::credits() const -> std::int32_t {
return _credits;
}
auto Profile::getCredits() -> std::int32_t {
auto mmap = Utility::Directory::mapRead(Utility::Directory::join(_profileDirectory, _filename));
auto iter = std::search(mmap.begin(), mmap.end(), &credits_locator[0], &credits_locator[22]);
if(iter != mmap.end()) {
_credits = *reinterpret_cast<const std::int32_t*>(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() const -> 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<const std::int32_t*>(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() const -> 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<const std::int32_t*>(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()";
return false;
}
if(Utility::Directory::exists(filename)) {
if(!Utility::Directory::rm(filename)) {
_lastError = "Couldn't overwrite " + filename + " in Profile::backup()";
}
}
wxFFileOutputStream out{filename};
wxZipOutputStream zip{out};
{
zip.PutNextEntry(_filename);
wxFFileInputStream profile_stream{Utility::Directory::toNativeSeparators(Utility::Directory::join(_profileDirectory, _filename)), "rb"};
zip.Write(profile_stream);
}
for(int i = 0; i < 32; ++i) {
std::string unit_file = Utility::Directory::join(_profileDirectory, Utility::formatString("{}Unit{:.2d}{}.sav", _type == ProfileType::Demo ? "Demo" : "", i, _steamId));
if(Utility::Directory::exists(unit_file)) {
zip.PutNextEntry(Utility::Directory::filename(unit_file));
wxFFileInputStream unit_stream{Utility::Directory::toNativeSeparators(unit_file)};
zip.Write(unit_stream);
}
}
return true;
}

View file

@ -1,67 +0,0 @@
#ifndef PROFILE_H
#define PROFILE_H
#include <cstdint>
#include <string>
enum class ProfileType : std::uint8_t {
Demo,
FullGame
};
class Profile {
public:
explicit Profile(const std::string& path);
auto valid() const -> bool;
auto lastError() const -> std::string const&;
auto filename() const -> std::string const&;
auto type() const -> ProfileType;
auto steamId() const -> std::string const&;
auto companyName() const -> std::string const&;
auto getCompanyName() -> std::string const&;
auto renameCompany(const std::string& new_name) -> bool;
auto activeFrameSlot() const -> std::int8_t;
auto getActiveFrameSlot() -> std::int8_t;
auto credits() const -> std::int32_t;
auto getCredits() -> std::int32_t;
auto storyProgress() const -> std::int32_t;
auto getStoryProgress() -> std::int32_t;
auto lastMissionId() const -> std::int32_t;
auto getLastMissionId() -> std::int32_t;
auto backup(const std::string& filename) -> bool;
private:
std::string _profileDirectory;
std::string _filename;
ProfileType _type;
std::string _steamId;
bool _valid = false;
std::string _lastError = "";
std::string _companyName;
std::int8_t _activeFrameSlot = 0;
std::int32_t _credits;
std::int32_t _storyProgress;
std::int32_t _lastMissionId;
};
#endif //PROFILE_H

View file

@ -1,151 +0,0 @@
// wxMASSManager
// Copyright (C) 2020 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/>.
#include <Corrade/version.h>
#if !(CORRADE_VERSION_YEAR * 100 + CORRADE_VERSION_MONTH >= 202006)
#error This application requires Corrade 2020.06 or later to build.
#endif
#include <algorithm>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/String.h>
#include <wx/filename.h>
#include "ScreenshotManager.h"
using namespace Corrade;
ScreenshotManager::ScreenshotManager(const std::string& base_path) {
_screenshotDirectory = Utility::Directory::join(base_path, "Saved/Screenshots/WindowsNoEditor");
if(!Utility::Directory::exists(_screenshotDirectory)) {
Utility::Directory::mkpath(_screenshotDirectory);
}
using Utility::Directory::Flag;
std::vector<std::string> file_list = Utility::Directory::list(_screenshotDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
auto iter = std::remove_if(file_list.begin(), file_list.end(), [](std::string& file){
return !Utility::String::endsWith(file, ".png");
});
file_list.erase(iter, file_list.end());
_screenshots.reserve(file_list.size());
for(const std::string& file : file_list) {
addScreenshot(file);
}
}
auto ScreenshotManager::screenshotDirectory() -> std::string const& {
return _screenshotDirectory;
}
auto ScreenshotManager::screenshots() -> std::vector<Screenshot> const& {
return _screenshots;
}
void ScreenshotManager::sortScreenshots(SortType type) {
_sortType = type;
sortScreenshots();
}
void ScreenshotManager::sortScreenshots(SortOrder order) {
_sortOrder = order;
sortScreenshots();
}
void ScreenshotManager::sortScreenshots() {
auto predicate = [this](const Screenshot& item_1, const Screenshot& item_2)->bool{
switch(_sortType) {
case SortType::Filename:
return wxString::FromUTF8(item_1._filename.c_str()).CmpNoCase(wxString::FromUTF8(item_2._filename.c_str())) < 0;
case SortType::CreationDate:
return item_1._creationDate.IsEarlierThan(item_2._creationDate);
}
return true;
};
switch(_sortOrder) {
case SortOrder::Ascending:
std::stable_sort(_screenshots.begin(), _screenshots.end(), predicate);
break;
case SortOrder::Descending:
std::stable_sort(_screenshots.rbegin(), _screenshots.rend(), predicate);
break;
}
}
auto ScreenshotManager::updateScreenshot(const std::string& filename) -> int {
addScreenshot(filename);
sortScreenshots();
int index = 0;
for(const Screenshot& s : _screenshots) {
if(s._filename == filename) {
return index;
}
}
return -1;
}
void ScreenshotManager::removeScreenshot(int index) {
if(static_cast<size_t>(index + 1) > _screenshots.size()) {
return;
}
auto it = _screenshots.begin() + index;
_screenshots.erase(it);
}
void ScreenshotManager::deleteScreenshot(int index) {
if(static_cast<size_t>(index + 1) > _screenshots.size()) {
return;
}
Utility::Directory::rm(Utility::Directory::join(_screenshotDirectory, _screenshots[index]._filename));
}
void ScreenshotManager::addScreenshot(const std::string& filename) {
std::string screenshot_path = Utility::Directory::toNativeSeparators(Utility::Directory::join(_screenshotDirectory, filename));
wxFileName screenshot_meta(screenshot_path);
wxDateTime creation_date;
screenshot_meta.GetTimes(nullptr, nullptr, &creation_date);
wxImage thumb{screenshot_path, wxBITMAP_TYPE_PNG};
wxSize size = thumb.GetSize();
if(size.GetWidth() > size.GetHeight()) {
size.Set(160, (size.GetHeight() * 160) / size.GetWidth());
}
else if(size.GetHeight() > size.GetWidth()) {
size.Set((size.GetWidth() * 160) / size.GetHeight(), 160);
}
else {
size.Set(160, 160);
}
thumb.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH)
.Resize(wxSize{160, 160}, wxPoint{(160 - size.GetWidth()) / 2, (160 - size.GetHeight()) / 2});
_screenshots.push_back(Screenshot{filename, creation_date, thumb});
}

View file

@ -1,67 +0,0 @@
#ifndef SCREENSHOTMANAGER_H
#define SCREENSHOTMANAGER_H
// wxMASSManager
// Copyright (C) 2020 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/>.
#include <string>
#include <vector>
#include <wx/datetime.h>
#include <wx/image.h>
enum class SortType : uint8_t {
Filename, CreationDate
};
enum class SortOrder: uint8_t {
Ascending, Descending
};
struct Screenshot {
std::string _filename;
wxDateTime _creationDate;
wxImage _thumbnail;
};
class ScreenshotManager {
public:
ScreenshotManager(const std::string& base_path);
auto screenshotDirectory() -> std::string const&;
auto screenshots() -> std::vector<Screenshot> const&;
void sortScreenshots(SortType type);
void sortScreenshots(SortOrder order);
void sortScreenshots();
auto updateScreenshot(const std::string& filename) -> int;
void removeScreenshot(int index);
void deleteScreenshot(int index);
private:
void addScreenshot(const std::string& filename);
std::string _screenshotDirectory = "";
std::vector<Screenshot> _screenshots;
SortType _sortType = SortType::Filename;
SortOrder _sortOrder = SortOrder::Ascending;
};
#endif //SCREENSHOTMANAGER_H

@ -1 +1 @@
Subproject commit 61d1b58cbcb159837bca506b5336a810da67f0a7
Subproject commit cc8824e8d2c00d739adba2263217dc7ae1c30dc5

623
modules/FindCorrade.cmake Normal file
View file

@ -0,0 +1,623 @@
#.rst:
# Find Corrade
# ------------
#
# Finds the Corrade library. Basic usage::
#
# find_package(Corrade REQUIRED)
#
# This module tries to find the base Corrade library and then defines the
# following:
#
# Corrade_FOUND - Whether the base library was found
# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module
#
# This command will try to find only the base library, not the optional
# components, which are:
#
# Containers - Containers library
# PluginManager - PluginManager library
# TestSuite - TestSuite library
# Utility - Utility library
# rc - corrade-rc executable
#
# Example usage with specifying additional components is::
#
# find_package(Corrade REQUIRED Utility TestSuite)
#
# For each component is then defined:
#
# Corrade_*_FOUND - Whether the component was found
# Corrade::* - Component imported target
#
# The package is found if either debug or release version of each library is
# found. If both debug and release libraries are found, proper version is
# chosen based on actual build configuration of the project (i.e. Debug build
# is linked to debug libraries, Release build to release libraries).
#
# Corrade conditionally defines ``CORRADE_IS_DEBUG_BUILD`` preprocessor
# variable in case build configuration is ``Debug`` (not Corrade itself, but
# build configuration of the project using it). Useful e.g. for selecting
# proper plugin directory.
#
# Corrade defines the following custom target properties:
#
# CORRADE_CXX_STANDARD - C++ standard to require when compiling given
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
# particular standard setting flag or if given target contains
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
# INTERFACE_CORRADE_CXX_STANDARD - C++ standard to require when using given
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
# particular standard setting flag or if given target contains
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
# CORRADE_USE_PEDANTIC_FLAGS - Enable additional compiler/linker flags.
# Boolean.
#
# These properties are inherited from directory properties, meaning that if you
# set them on directories, they get implicitly set on all targets in given
# directory (with a possibility to do target-specific overrides). All Corrade
# libraries have the :prop_tgt:`INTERFACE_CORRADE_CXX_STANDARD` property set to
# 11, meaning that you will always have at least C++11 enabled once you link to
# any Corrade library.
#
# Features of found Corrade library are exposed in these variables:
#
# CORRADE_MSVC2019_COMPATIBILITY - Defined if compiled with compatibility
# mode for MSVC 2019
# CORRADE_MSVC2017_COMPATIBILITY - Defined if compiled with compatibility
# mode for MSVC 2017
# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility
# mode for MSVC 2015
# CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs
# included
# CORRADE_BUILD_STATIC - Defined if compiled as static libraries.
# Default are shared libraries.
# CORRADE_BUILD_STATIC_UNIQUE_GLOBALS - Defined if static libraries keep their
# globals unique even across different shared libraries. Enabled by default
# for static builds.
# CORRADE_BUILD_MULTITHREADED - Defined if compiled in a way that makes it
# possible to safely use certain Corrade features simultaneously in multiple
# threads
# CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor
# (Linux, BSD, macOS)
# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms
# CORRADE_TARGET_IOS - Defined if compiled for iOS (device or
# simulator)
# CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator
# CORRADE_TARGET_WINDOWS - Defined if compiled for Windows
# CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT
# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten
# CORRADE_TARGET_ANDROID - Defined if compiled for Android
# CORRADE_TARGET_GCC - Defined if compiling with GCC or GCC-
# compatible Clang
# CORRADE_TARGET_CLANG - Defined if compiling with Clang or any of its
# variants
# CORRADE_TARGET_APPLE_CLANG - Defined if compiling with Apple's Clang
# CORRADE_TARGET_CLANG_CL - Defined if compiling with Clang-CL (Clang
# with a MSVC frontend)
# CORRADE_TARGET_MSVC - Defined if compiling with MSVC or Clang with
# a MSVC frontend
# CORRADE_TARGET_MINGW - Defined if compiling under MinGW
# CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT - Defined if PluginManager
# doesn't support dynamic plugin loading due to platform limitations
# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targetting Xcode
# XCTest
# CORRADE_UTILITY_USE_ANSI_COLORS - Defined if ANSI escape sequences are used
# for colored output with Utility::Debug on Windows
#
# Additionally these variables are defined for internal usage:
#
# CORRADE_INCLUDE_DIR - Root include dir
# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found
# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if found
# CORRADE_*_EXECUTABLE - Location of given executable, if found
# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included
# automatically)
# CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file
# CORRADE_TESTSUITE_ADB_RUNNER - Path to AdbRunner.sh file
# CORRADE_PEDANTIC_COMPILER_OPTIONS - List of pedantic compiler options used
# for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` enabled
# CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler
# definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS`
# enabled
# CORRADE_CXX{11,14,17,20}_STANDARD_FLAG - Compiler flag to use for targeting
# C++11, 14, 17 or 20 in cases where it's not possible to use
# :prop_tgt:`CORRADE_CXX_STANDARD`. Not defined if a standard switch is
# already present in :variable:`CMAKE_CXX_FLAGS`.
#
# Corrade provides these macros and functions:
#
# .. command:: corrade_add_test
#
# Add unit test using Corrade's TestSuite::
#
# corrade_add_test(<test name>
# <sources>...
# [LIBRARIES <libraries>...]
# [FILES <files>...]
# [ARGUMENTS <arguments>...])
#
# Test name is also executable name. You can use ``LIBRARIES`` to specify
# libraries to link with instead of using :command:`target_link_libraries()`.
# The ``Corrade::TestSuite`` target is linked automatically to each test. Note
# that the :command:`enable_testing()` function must be called explicitly.
# Arguments passed after ``ARGUMENTS`` will be appended to the test
# command line. ``ARGUMENTS`` are supported everywhere except when
# ``CORRADE_TESTSUITE_TARGET_XCTEST`` is enabled.
#
# You can list files needed by the test in the ``FILES`` section. If given
# filename is relative, it is treated relatively to `CMAKE_CURRENT_SOURCE_DIR`.
# The files are added to the :prop_test:`REQUIRED_FILES` target property. On
# Emscripten they are bundled to the executable and available in the virtual
# filesystem root. On Android they are copied along the executable to the
# target. In case of Emscripten and Android, if the file is absolute or
# contains ``..``, only the leaf name is used. Alternatively you can have a
# filename formatted as ``<input>@<output>``, in which case the ``<input>`` is
# treated as local filesystem location and ``<output>`` as remote/virtual
# filesystem location. The remote location can't be absolute or contain ``..``
# / ``@`` characters.
#
# Unless :variable:`CORRADE_TESTSUITE_TARGET_XCTEST` is set, test cases on iOS
# targets are created as bundles with bundle identifier set to CMake project
# name by default. Use the cache variable :variable:`CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX`
# to change it to something else.
#
# .. command:: corrade_add_resource
#
# Compile data resources into application binary::
#
# corrade_add_resource(<name> <resources.conf>)
#
# Depends on ``Corrade::rc``, which is part of Corrade utilities. This command
# generates resource data using given configuration file in current build
# directory. Argument name is name under which the resources can be explicitly
# loaded. Variable ``<name>`` contains compiled resource filename, which is
# then used for compiling library / executable. On CMake >= 3.1 the
# `resources.conf` file can contain UTF-8-encoded filenames. Example usage::
#
# corrade_add_resource(app_resources resources.conf)
# add_executable(app source1 source2 ... ${app_resources})
#
# .. command:: corrade_add_plugin
#
# Add dynamic plugin::
#
# corrade_add_plugin(<plugin name>
# "<debug binary install dir>;<debug library install dir>"
# "<release binary install dir>;<release library install dir>"
# <metadata file>
# <sources>...)
#
# The macro adds a preprocessor directive ``CORRADE_DYNAMIC_PLUGIN`` when
# compiling ``<sources>``. Additional libraries can be linked in via
# :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
# On DLL platforms, the plugin DLLs and metadata files are put into
# ``<debug binary install dir>`` / ``<release binary install dir>`` and the
# ``*.lib`` files into ``<debug library install dir>`` /
# ``<release library install dir>``. On non-DLL platforms everything is put
# into ``<debug library install dir>`` / ``<release library install dir>``.
#
# If the plugin interface disables plugin metadata files, the
# ``<metadata file>`` can be set to ``""``, in which case no metadata file is
# copied anywhere. Otherwise the metadata file is copied and renamed to
# ``<plugin name>``, retaining its original extension.
#
# corrade_add_plugin(<plugin name>
# <debug install dir>
# <release install dir>
# <metadata file>
# <sources>...)
#
# Unline the above version this puts everything into ``<debug install dir>`` on
# both DLL and non-DLL platforms. If ``<debug install dir>`` is set to
# :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for testing purposes), the files
# are copied directly, without the need to perform install step. Note that the
# files are actually put into configuration-based subdirectory, i.e.
# ``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}``. See documentation of
# :variable:`CMAKE_CFG_INTDIR` variable for more information.
#
# .. command:: corrade_add_static_plugin
#
# Add static plugin::
#
# corrade_add_static_plugin(<plugin name>
# "<binary install dir>;<library install dir>"
# <metadata file>
# <sources>...)
#
# The macro adds a preprocessor directive ``CORRADE_STATIC_PLUGIN`` when
# compiling ``<sources>``. Additional libraries can be linked in via
# :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
# The ``<binary install dir>`` is ignored and included just for compatibility
# with the :command:`corrade_add_plugin` command, everything is installed into