Compare commits
No commits in common. "028d991b74fb75547ea3f37ebdd7c5423c786724" and "fbfcce1d86252b66c44e9ac3cdff9a431ac1e61d" have entirely different histories.
028d991b74
...
fbfcce1d86
9 changed files with 43 additions and 47 deletions
|
@ -30,12 +30,12 @@ cmake_dependent_option(SAVETOOL_USE_SYSTEM_LIBZIP "Use a system-wide version of
|
||||||
cmake_dependent_option(SAVETOOL_USE_SYSTEM_EFSW "Use a system-wide version of EFSW." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_EFSW "Use a system-wide version of EFSW." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
cmake_dependent_option(SAVETOOL_USE_SYSTEM_LIBCURL "Use a system-wide version of libcurl." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
cmake_dependent_option(SAVETOOL_USE_SYSTEM_LIBCURL "Use a system-wide version of libcurl." ON "SAVETOOL_USE_SYSTEM_LIBS" OFF)
|
||||||
|
|
||||||
if(NOT SAVETOOL_USE_SYSTEM_LIBS OR NOT (SAVETOOL_USE_SYSTEM_CORRADE_MAGNUM AND SAVETOOL_USE_SYSTEM_SDL2 AND SAVETOOL_USE_SYSTEM_LIBZIP AND SAVETOOL_USE_SYSTEM_EFSW AND SAVETOOL_USE_SYSTEM_LIBCURL))
|
if(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
# Generic variables shared by multiple libs that don't provide their own.
|
# Generic variables shared by multiple libs that don't provide their own.
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
||||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||||
endif()
|
endif(NOT SAVETOOL_USE_SYSTEM_LIBS)
|
||||||
|
|
||||||
if(NOT SAVETOOL_USE_SYSTEM_SDL2)
|
if(NOT SAVETOOL_USE_SYSTEM_SDL2)
|
||||||
set(DIRECTX OFF CACHE BOOL "" FORCE) # We use OpenGL.
|
set(DIRECTX OFF CACHE BOOL "" FORCE) # We use OpenGL.
|
||||||
|
|
|
@ -174,7 +174,7 @@ void
|
||||||
Application::viewportEvent(ViewportEvent& event) {
|
Application::viewportEvent(ViewportEvent& event) {
|
||||||
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
|
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
|
||||||
|
|
||||||
const auto size = Vector2{windowSize()}/dpiScaling();
|
const Vector2 size = Vector2{windowSize()}/dpiScaling();
|
||||||
_imgui.relayout(size, windowSize(), framebufferSize());
|
_imgui.relayout(size, windowSize(), framebufferSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,11 @@
|
||||||
namespace mbst {
|
namespace mbst {
|
||||||
|
|
||||||
void
|
void
|
||||||
Application::handleFileAction(efsw::WatchID watch_id, const std::string&, const std::string& filename,
|
Application::handleFileAction(efsw::WatchID watch_id,
|
||||||
efsw::Action action, std::string old_filename)
|
const std::string&,
|
||||||
|
const std::string& filename,
|
||||||
|
efsw::Action action,
|
||||||
|
std::string old_filename)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_zero(event);
|
SDL_zero(event);
|
||||||
|
|
|
@ -58,7 +58,8 @@ Application::initialiseGui() {
|
||||||
LOG_INFO("Initialising Dear ImGui.");
|
LOG_INFO("Initialising Dear ImGui.");
|
||||||
|
|
||||||
auto ctx = ImGui::CreateContext();
|
auto ctx = ImGui::CreateContext();
|
||||||
auto& io = ImGui::GetIO();
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
const auto size = Vector2{windowSize()}/dpiScaling();
|
const auto size = Vector2{windowSize()}/dpiScaling();
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ Application::initialiseGui() {
|
||||||
|
|
||||||
io.IniFilename = nullptr;
|
io.IniFilename = nullptr;
|
||||||
|
|
||||||
auto& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
|
||||||
style.WindowTitleAlign = {0.5f, 0.5f};
|
style.WindowTitleAlign = {0.5f, 0.5f};
|
||||||
style.FrameRounding = 3.2f;
|
style.FrameRounding = 3.2f;
|
||||||
|
@ -124,7 +125,8 @@ Application::initialiseManager() {
|
||||||
void
|
void
|
||||||
Application::initialiseMassManager() {
|
Application::initialiseMassManager() {
|
||||||
LOG_INFO("Initialising the M.A.S.S. manager.");
|
LOG_INFO("Initialising the M.A.S.S. manager.");
|
||||||
_massManager.emplace(_currentProfile->account(), _currentProfile->isDemo());
|
_massManager.emplace(conf().directories().gameSaves, _currentProfile->account(), _currentProfile->isDemo(),
|
||||||
|
conf().directories().staging);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -521,7 +521,6 @@ Application::drawMassManager() {
|
||||||
|
|
||||||
drawDeleteMassPopup(mass_to_delete);
|
drawDeleteMassPopup(mass_to_delete);
|
||||||
|
|
||||||
// TODO: fix this shit, like with the profile manager.
|
|
||||||
static ImGuiID staged_mass_deletion_popup_ID = drawDeleteStagedMassPopup("");
|
static ImGuiID staged_mass_deletion_popup_ID = drawDeleteStagedMassPopup("");
|
||||||
static Containers::StringView staged_mass_to_delete;
|
static Containers::StringView staged_mass_to_delete;
|
||||||
|
|
||||||
|
|
|
@ -333,18 +333,6 @@ Application::drawCustomStyle(GameObjects::CustomStyle& style) {
|
||||||
style.name = name_buf.data();
|
style.name = name_buf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::SmallButton(ICON_FA_FILE_EXPORT " Export")) {
|
|
||||||
if(!ImportExport::exportStyle(_currentMass->name(), style)) {
|
|
||||||
_queue.addToast(Toast::Type::Error, ImportExport::lastExportError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_queue.addToast(Toast::Type::Success, "Style exported successfully.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_FILE_IMPORT " Import")) {
|
|
||||||
// TODO: implement once the style manager is ready.
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <Corrade/Utility/Format.h>
|
#include <Corrade/Utility/Format.h>
|
||||||
#include <Corrade/Utility/Path.h>
|
#include <Corrade/Utility/Path.h>
|
||||||
|
|
||||||
#include "../Configuration/Configuration.h"
|
|
||||||
#include "../Logger/Logger.h"
|
#include "../Logger/Logger.h"
|
||||||
|
|
||||||
#include "MassManager.h"
|
#include "MassManager.h"
|
||||||
|
@ -28,12 +27,13 @@ using namespace Containers::Literals;
|
||||||
|
|
||||||
namespace mbst { namespace Managers {
|
namespace mbst { namespace Managers {
|
||||||
|
|
||||||
MassManager::MassManager(Containers::StringView account, bool demo):
|
MassManager::MassManager(Containers::StringView save_path, Containers::StringView account, bool demo,
|
||||||
_account{account}, _demo{demo}
|
Containers::StringView staging_dir):
|
||||||
|
_saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir}
|
||||||
{
|
{
|
||||||
Containers::String mass_filename = "";
|
Containers::String mass_filename = "";
|
||||||
for(std::uint32_t i = 0; i < _hangars.size(); i++) {
|
for(std::uint32_t i = 0; i < _hangars.size(); i++) {
|
||||||
mass_filename = Utility::Path::join(conf().directories().gameSaves,
|
mass_filename = Utility::Path::join(_saveDirectory,
|
||||||
Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account));
|
Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account));
|
||||||
new(&_hangars[i]) GameObjects::Mass{mass_filename};
|
new(&_hangars[i]) GameObjects::Mass{mass_filename};
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ MassManager::refreshHangar(std::int32_t hangar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers::String mass_filename =
|
Containers::String mass_filename =
|
||||||
Utility::Path::join(conf().directories().gameSaves,
|
Utility::Path::join(_saveDirectory,
|
||||||
Utility::format("{}Unit{:.2d}{}.sav", _demo ? "Demo" : "", hangar, _account));
|
Utility::format("{}Unit{:.2d}{}.sav", _demo ? "Demo" : "", hangar, _account));
|
||||||
_hangars[hangar] = GameObjects::Mass{mass_filename};
|
_hangars[hangar] = GameObjects::Mass{mass_filename};
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers::String source = Utility::Path::join(conf().directories().staging, staged_fn);
|
Containers::String source = Utility::Path::join(_stagingAreaDirectory, staged_fn);
|
||||||
Utility::Path::copy(source, source + ".tmp"_s);
|
Utility::Path::copy(source, source + ".tmp"_s);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers::String dest = Utility::Path::join(conf().directories().gameSaves, _hangars[hangar].filename());
|
Containers::String dest = Utility::Path::join(_saveDirectory, _hangars[hangar].filename());
|
||||||
|
|
||||||
if(Utility::Path::exists(dest)) {
|
if(Utility::Path::exists(dest)) {
|
||||||
Utility::Path::remove(dest);
|
Utility::Path::remove(dest);
|
||||||
|
@ -122,8 +122,8 @@ MassManager::exportMass(std::int32_t hangar) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers::String source = Utility::Path::join(conf().directories().gameSaves, _hangars[hangar].filename());
|
Containers::String source = Utility::Path::join(_saveDirectory, _hangars[hangar].filename());
|
||||||
Containers::String dest = Utility::Path::join(conf().directories().staging,
|
Containers::String dest = Utility::Path::join(_stagingAreaDirectory,
|
||||||
Utility::format("{}_{}.sav", _hangars[hangar].name(), _account));
|
Utility::format("{}_{}.sav", _hangars[hangar].name(), _account));
|
||||||
|
|
||||||
if(!Utility::Path::copy(source, dest)) {
|
if(!Utility::Path::copy(source, dest)) {
|
||||||
|
@ -149,10 +149,8 @@ MassManager::moveMass(std::int32_t source, std::int32_t destination) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Containers::String source_file = Utility::Path::join(conf().directories().gameSaves,
|
Containers::String source_file = Utility::Path::join(_saveDirectory, _hangars[source].filename());
|
||||||
_hangars[source].filename());
|
Containers::String dest_file = Utility::Path::join(_saveDirectory, _hangars[destination].filename());
|
||||||
Containers::String dest_file = Utility::Path::join(conf().directories().gameSaves,
|
|
||||||
_hangars[destination].filename());
|
|
||||||
GameObjects::Mass::State dest_state = _hangars[destination].state();
|
GameObjects::Mass::State dest_state = _hangars[destination].state();
|
||||||
|
|
||||||
switch(dest_state) {
|
switch(dest_state) {
|
||||||
|
@ -183,7 +181,7 @@ MassManager::deleteMass(std::int32_t hangar) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Path::remove(Utility::Path::join(conf().directories().gameSaves, _hangars[hangar].filename()))) {
|
if(!Utility::Path::remove(Utility::Path::join(_saveDirectory, _hangars[hangar].filename()))) {
|
||||||
_lastError = Utility::format("Deletion failed: {}", std::strerror(errno));
|
_lastError = Utility::format("Deletion failed: {}", std::strerror(errno));
|
||||||
LOG_ERROR(_lastError);
|
LOG_ERROR(_lastError);
|
||||||
return false;
|
return false;
|
||||||
|
@ -202,11 +200,11 @@ MassManager::refreshStagedMasses() {
|
||||||
_stagedMasses.clear();
|
_stagedMasses.clear();
|
||||||
|
|
||||||
using Utility::Path::ListFlag;
|
using Utility::Path::ListFlag;
|
||||||
auto file_list = Utility::Path::list(conf().directories().staging,
|
auto file_list = Utility::Path::list(_stagingAreaDirectory,
|
||||||
ListFlag::SkipSpecial|ListFlag::SkipDirectories|ListFlag::SkipDotAndDotDot);
|
ListFlag::SkipSpecial|ListFlag::SkipDirectories|ListFlag::SkipDotAndDotDot);
|
||||||
|
|
||||||
if(!file_list) {
|
if(!file_list) {
|
||||||
LOG_ERROR_FORMAT("{} couldn't be opened.", conf().directories().staging);
|
LOG_ERROR_FORMAT("{} couldn't be opened.", _stagingAreaDirectory);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +216,7 @@ MassManager::refreshStagedMasses() {
|
||||||
|
|
||||||
LOG_INFO("Scanning for staged M.A.S.S.es...");
|
LOG_INFO("Scanning for staged M.A.S.S.es...");
|
||||||
for(Containers::StringView file : list_view) {
|
for(Containers::StringView file : list_view) {
|
||||||
auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(conf().directories().staging, file));
|
auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, file));
|
||||||
|
|
||||||
if(name) {
|
if(name) {
|
||||||
LOG_INFO_FORMAT("Found staged M.A.S.S.: {}", *name);
|
LOG_INFO_FORMAT("Found staged M.A.S.S.: {}", *name);
|
||||||
|
@ -234,11 +232,11 @@ void
|
||||||
MassManager::refreshStagedMass(Containers::StringView filename) {
|
MassManager::refreshStagedMass(Containers::StringView filename) {
|
||||||
LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename);
|
LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename);
|
||||||
|
|
||||||
bool file_exists = Utility::Path::exists(Utility::Path::join(conf().directories().staging, filename));
|
bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename));
|
||||||
auto it = _stagedMasses.find(filename);
|
auto it = _stagedMasses.find(filename);
|
||||||
|
|
||||||
if(file_exists) {
|
if(file_exists) {
|
||||||
auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(conf().directories().staging, filename));
|
auto name = GameObjects::Mass::getNameFromFile(Utility::Path::join(_stagingAreaDirectory, filename));
|
||||||
if(name) {
|
if(name) {
|
||||||
_stagedMasses[filename] = *name;
|
_stagedMasses[filename] = *name;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +257,7 @@ MassManager::deleteStagedMass(Containers::StringView filename) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Path::remove(Utility::Path::join(conf().directories().staging, filename))) {
|
if(!Utility::Path::remove(Utility::Path::join(_stagingAreaDirectory, filename))) {
|
||||||
_lastError = filename + " couldn't be deleted: " + std::strerror(errno);
|
_lastError = filename + " couldn't be deleted: " + std::strerror(errno);
|
||||||
LOG_ERROR(_lastError);
|
LOG_ERROR(_lastError);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mbst { namespace Managers {
|
||||||
|
|
||||||
class MassManager {
|
class MassManager {
|
||||||
public:
|
public:
|
||||||
MassManager(Containers::StringView account, bool demo);
|
MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir);
|
||||||
|
|
||||||
auto lastError() -> Containers::StringView;
|
auto lastError() -> Containers::StringView;
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ class MassManager {
|
||||||
bool deleteStagedMass(Containers::StringView filename);
|
bool deleteStagedMass(Containers::StringView filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Containers::StringView _saveDirectory;
|
||||||
Containers::StringView _account;
|
Containers::StringView _account;
|
||||||
bool _demo;
|
bool _demo;
|
||||||
|
|
||||||
|
@ -57,6 +58,8 @@ class MassManager {
|
||||||
|
|
||||||
Containers::StaticArray<32, GameObjects::Mass> _hangars{NoInit};
|
Containers::StaticArray<32, GameObjects::Mass> _hangars{NoInit};
|
||||||
|
|
||||||
|
Containers::StringView _stagingAreaDirectory;
|
||||||
|
|
||||||
std::map<Containers::String, Containers::String> _stagedMasses;
|
std::map<Containers::String, Containers::String> _stagedMasses;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
// 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 <cstdio>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <Corrade/Containers/ScopeGuard.h>
|
#include <Corrade/Containers/ScopeGuard.h>
|
||||||
#include <Corrade/Containers/StaticArray.h>
|
#include <Corrade/Containers/StaticArray.h>
|
||||||
|
@ -22,6 +25,8 @@
|
||||||
#include <Corrade/Utility/Path.h>
|
#include <Corrade/Utility/Path.h>
|
||||||
#include <Corrade/Utility/String.h>
|
#include <Corrade/Utility/String.h>
|
||||||
|
|
||||||
|
#include <zip.h>
|
||||||
|
|
||||||
#include "../Configuration/Configuration.h"
|
#include "../Configuration/Configuration.h"
|
||||||
#include "../Logger/Logger.h"
|
#include "../Logger/Logger.h"
|
||||||
|
|
||||||
|
@ -98,8 +103,6 @@ ProfileManager::getProfile(std::size_t index) {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
|
ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
|
||||||
CORRADE_INTERNAL_ASSERT(index < _profiles.size());
|
|
||||||
|
|
||||||
if(!Utility::Path::remove(Utility::Path::join(conf().directories().gameSaves, _profiles[index].filename()))) {
|
if(!Utility::Path::remove(Utility::Path::join(conf().directories().gameSaves, _profiles[index].filename()))) {
|
||||||
_lastError = Utility::format("Couldn't delete {} (filename: {}).",
|
_lastError = Utility::format("Couldn't delete {} (filename: {}).",
|
||||||
_profiles[index].companyName(),
|
_profiles[index].companyName(),
|
||||||
|
|
Loading…
Reference in a new issue