Compare commits

..

No commits in common. "e11fa34c097e8884b708b981d965508b0dc1cfd5" and "b9fe38782d0df73e101276e33ed4f9a51431421c" have entirely different histories.

10 changed files with 34 additions and 169 deletions

View file

@ -127,8 +127,8 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
void drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id); void drawMaterialRow(Containers::StringView name, std::int32_t tier, GameData::MaterialID id);
void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier); void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager(); void drawMassManager();
void drawDeleteMassPopup(int mass_index); auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
void drawDeleteStagedMassPopup(Containers::StringView filename); auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
void drawMassViewer(); void drawMassViewer();
void drawFrameInfo(); void drawFrameInfo();

View file

@ -16,7 +16,6 @@
#include <algorithm> #include <algorithm>
#include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
@ -400,6 +399,7 @@ Application::drawMassManager() {
} }
static int mass_to_delete = 0; static int mass_to_delete = 0;
static ImGuiID mass_deletion_popup_ID = drawDeleteMassPopup(mass_to_delete);
if(ImGui::BeginTable("##HangarsTable", 4, if(ImGui::BeginTable("##HangarsTable", 4,
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY, ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY,
@ -509,10 +509,9 @@ Application::drawMassManager() {
ImGui::SameLine(0.0f, 2.0f); ImGui::SameLine(0.0f, 2.0f);
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) { if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
mass_to_delete = i; mass_to_delete = i;
ImGui::OpenPopup("Confirmation##DeleteMassConfirmation"); ImGui::OpenPopup(mass_deletion_popup_ID);
} }
drawTooltip("Delete"); drawTooltip("Delete");
drawDeleteMassPopup(mass_to_delete);
ImGui::PopID(); ImGui::PopID();
} }
} }
@ -522,6 +521,8 @@ 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 Containers::StringView staged_mass_to_delete; static Containers::StringView staged_mass_to_delete;
if(ImGui::BeginTable("##StagingArea", 2, if(ImGui::BeginTable("##StagingArea", 2,
@ -561,10 +562,9 @@ Application::drawMassManager() {
ImGui::PushID(pair.first.data()); ImGui::PushID(pair.first.data());
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) { if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
staged_mass_to_delete = pair.first; staged_mass_to_delete = pair.first;
ImGui::OpenPopup("Confirmation##DeleteStagedMassConfirmation"); ImGui::OpenPopup(staged_mass_deletion_popup_ID);
} }
drawTooltip("Delete"); drawTooltip("Delete");
drawDeleteStagedMassPopup(staged_mass_to_delete);
ImGui::PopID(); ImGui::PopID();
} }
@ -592,24 +592,24 @@ Application::drawMassManager() {
drawDeleteStagedMassPopup(staged_mass_to_delete); drawDeleteStagedMassPopup(staged_mass_to_delete);
} }
void ImGuiID
Application::drawDeleteMassPopup(int mass_index) { Application::drawDeleteMassPopup(int mass_index) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr, if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {
return; return ImGui::GetID("Confirmation##DeleteMassConfirmation");
} }
Containers::ScopeGuard guard{ImGui::EndPopup};
if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) { if(_massManager->hangar(mass_index).state() == GameObjects::Mass::State::Empty) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
return; ImGui::EndPopup();
return 0;
} }
if(_gameState != GameState::NotRunning) { if(_gameState != GameState::NotRunning) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
return; ImGui::EndPopup();
return 0;
} }
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
@ -643,14 +643,18 @@ Application::drawDeleteMassPopup(int mass_index) {
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::EndPopup();
return 0;
} }
void ImGuiID
Application::drawDeleteStagedMassPopup(Containers::StringView filename) { Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr, if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {
return; return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation");
} }
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f); ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
@ -680,6 +684,8 @@ Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
} }
ImGui::EndPopup(); ImGui::EndPopup();
return 0;
} }
} }

View file

@ -199,8 +199,6 @@ add_executable(MassBuilderSaveTool
Managers/MassManager.cpp Managers/MassManager.cpp
Managers/ProfileManager.h Managers/ProfileManager.h
Managers/ProfileManager.cpp Managers/ProfileManager.cpp
Managers/Vfs/VirtualFileSystem.h
Managers/Vfs/VfsDirectory.h
Maps/ArmourSlots.hpp Maps/ArmourSlots.hpp
Maps/BulletLauncherAttachmentStyles.hpp Maps/BulletLauncherAttachmentStyles.hpp
Maps/BulletLauncherSockets.hpp Maps/BulletLauncherSockets.hpp

View file

@ -20,7 +20,6 @@
#include <chrono> #include <chrono>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
@ -226,12 +225,10 @@ void
BackupManager::scanSubdir(Containers::StringView subdir) { BackupManager::scanSubdir(Containers::StringView subdir) {
static std::uint8_t depth = 0; static std::uint8_t depth = 0;
auto full_subdir = Utility::Path::join(conf().directories().backups, subdir);
using Flag = Utility::Path::ListFlag; using Flag = Utility::Path::ListFlag;
auto files = Utility::Path::list(full_subdir, Flag::SkipDirectories|Flag::SkipSpecial); auto files = Utility::Path::list(conf().directories().backups, Flag::SkipDirectories|Flag::SkipSpecial);
if(!files) { if(!files) {
LOG_ERROR_FORMAT("Couldn't list contents of {}.", full_subdir); LOG_ERROR_FORMAT("Couldn't list contents of {}.", conf().directories().backups);
} }
auto predicate = [](Containers::StringView file)->bool{ auto predicate = [](Containers::StringView file)->bool{
@ -246,9 +243,7 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
Backup backup; Backup backup;
backup.filename = Utility::Path::join(subdir, file); backup.filename = Utility::Path::join(subdir, file);
auto full_path = Utility::Path::join(full_subdir, file); zip = zip_open(Utility::Path::join(conf().directories().backups, file).data(), ZIP_RDONLY, &error_code);
zip = zip_open(full_path.cbegin(), ZIP_RDONLY, &error_code);
if(zip == nullptr) { if(zip == nullptr) {
continue; continue;
} }
@ -306,13 +301,14 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
arrayAppend(_backups, Utility::move(backup)); arrayAppend(_backups, Utility::move(backup));
} }
if(depth == 5) { auto subdirs = Utility::Path::list(conf().directories().backups,
return; Flag::SkipFiles|Flag::SkipSpecial|Flag::SkipDotAndDotDot);
if(!subdirs) {
LOG_ERROR_FORMAT("Couldn't list contents of {}.", conf().directories().backups);
} }
auto subdirs = Utility::Path::list(full_subdir, Flag::SkipFiles|Flag::SkipSpecial|Flag::SkipDotAndDotDot); if(depth == 5) {
if(!subdirs) { return;
LOG_ERROR_FORMAT("Couldn't list contents of {}.", full_subdir);
} }
depth++; depth++;

View file

@ -32,7 +32,7 @@ namespace mbst { namespace Managers {
class BackupManager { class BackupManager {
public: public:
explicit BackupManager(); BackupManager();
auto lastError() -> Containers::StringView; auto lastError() -> Containers::StringView;

View file

@ -1,88 +0,0 @@
#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021-2024 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/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
using namespace Corrade;
namespace mbst { namespace Managers { namespace Vfs {
CORRADE_HAS_TYPE(HasFilename, decltype(T::filename));
template<typename FileType>
class VfsDirectory {
public:
static_assert(HasFilename<FileType>::value && (std::is_same<decltype(FileType::filename), Containers::String>::value || std::is_same<decltype(FileType::filename), Containers::StringView>::value),
"FileType has no string-like member named filename.");
using DirType = VfsDirectory<FileType>;
explicit VfsDirectory(Containers::StringView name): _name{name} {
// ctor
}
VfsDirectory(const VfsDirectory<FileType>& other) = delete;
VfsDirectory& operator=(const VfsDirectory<FileType>& other) = delete;
VfsDirectory(VfsDirectory<FileType>&& other) = default;
VfsDirectory& operator=(VfsDirectory<FileType>&& other) = default;
auto name() const -> Containers::StringView {
return _name;
}
auto subdirs() const -> Containers::ArrayView<const DirType> {
return _subdirs;
}
auto files() const -> Containers::ArrayView<const FileType*> {
return _files;
}
protected:
void buildNestedPath(VfsDirectory<FileType>& root, Containers::ArrayView<const Containers::MutableStringView> components,
FileType& file)
{
if(components.size() > 1) {
bool found = false;
for(auto& subdir : root._subdirs) {
if(subdir._name == components[0]) {
found = true;
buildNestedPath(subdir, components.exceptPrefix(1), file);
break;
}
}
if(!found) {
arrayAppend(root._subdirs, InPlaceInit, components[0]);
buildNestedPath(root._subdirs.back(), components.exceptPrefix(1), file);
}
}
else if(components.size() == 1) {
arrayAppend(root._files, &file);
}
}
Containers::String _name;
Containers::Array<DirType> _subdirs;
Containers::Array<FileType*> _files;
};
}}}

View file

@ -1,47 +0,0 @@
#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021-2024 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 "VfsDirectory.h"
namespace mbst { namespace Managers { namespace Vfs {
template<typename FileType>
class VirtualFileSystem: public VfsDirectory<FileType> {
public:
explicit VirtualFileSystem():
VfsDirectory<FileType>("")
{
// ctor
}
explicit VirtualFileSystem(Containers::ArrayView<FileType> files):
VfsDirectory<FileType>("")
{
build(files);
}
void build(Containers::ArrayView<FileType> files) {
for(auto& file : files) {
auto components = file.filename.split('/');
CORRADE_INTERNAL_ASSERT(components.size() == 0);
VfsDirectory<FileType>::buildNestedPath(*this, components, file);
}
}
};
}}}

2
third-party/corrade vendored

@ -1 +1 @@
Subproject commit f966f918bd7dec95002921227b6bd68ccbdda113 Subproject commit 295bbba1f49887da060465f88b8501965f6acd7d

2
third-party/imgui vendored

@ -1 +1 @@
Subproject commit a8e96ae21a4ec10e5f02b19dd865dfffe8a98e67 Subproject commit 4f9ba19e520bea478f5cb654d37ef45e6404bd52

2
third-party/magnum vendored

@ -1 +1 @@
Subproject commit a40020f3fff91dc9c59148f52adb0d48203799eb Subproject commit 8538610fa27e1db37070eaabe34f1e4e41648bab