Compare commits
No commits in common. "e11fa34c097e8884b708b981d965508b0dc1cfd5" and "b9fe38782d0df73e101276e33ed4f9a51431421c" have entirely different histories.
e11fa34c09
...
b9fe38782d
10 changed files with 34 additions and 169 deletions
|
@ -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 drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
|
||||
void drawMassManager();
|
||||
void drawDeleteMassPopup(int mass_index);
|
||||
void drawDeleteStagedMassPopup(Containers::StringView filename);
|
||||
auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
|
||||
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID;
|
||||
|
||||
void drawMassViewer();
|
||||
void drawFrameInfo();
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Corrade/Containers/ScopeGuard.h>
|
||||
#include <Corrade/Utility/Format.h>
|
||||
#include <Corrade/Utility/Path.h>
|
||||
|
||||
|
@ -400,6 +399,7 @@ Application::drawMassManager() {
|
|||
}
|
||||
|
||||
static int mass_to_delete = 0;
|
||||
static ImGuiID mass_deletion_popup_ID = drawDeleteMassPopup(mass_to_delete);
|
||||
|
||||
if(ImGui::BeginTable("##HangarsTable", 4,
|
||||
ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg|ImGuiTableFlags_ScrollY,
|
||||
|
@ -509,10 +509,9 @@ Application::drawMassManager() {
|
|||
ImGui::SameLine(0.0f, 2.0f);
|
||||
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
|
||||
mass_to_delete = i;
|
||||
ImGui::OpenPopup("Confirmation##DeleteMassConfirmation");
|
||||
ImGui::OpenPopup(mass_deletion_popup_ID);
|
||||
}
|
||||
drawTooltip("Delete");
|
||||
drawDeleteMassPopup(mass_to_delete);
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
@ -522,6 +521,8 @@ Application::drawMassManager() {
|
|||
|
||||
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;
|
||||
|
||||
if(ImGui::BeginTable("##StagingArea", 2,
|
||||
|
@ -561,10 +562,9 @@ Application::drawMassManager() {
|
|||
ImGui::PushID(pair.first.data());
|
||||
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
|
||||
staged_mass_to_delete = pair.first;
|
||||
ImGui::OpenPopup("Confirmation##DeleteStagedMassConfirmation");
|
||||
ImGui::OpenPopup(staged_mass_deletion_popup_ID);
|
||||
}
|
||||
drawTooltip("Delete");
|
||||
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
|
@ -592,24 +592,24 @@ Application::drawMassManager() {
|
|||
drawDeleteStagedMassPopup(staged_mass_to_delete);
|
||||
}
|
||||
|
||||
void
|
||||
ImGuiID
|
||||
Application::drawDeleteMassPopup(int mass_index) {
|
||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr,
|
||||
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) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
return;
|
||||
ImGui::EndPopup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(_gameState != GameState::NotRunning) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
return;
|
||||
ImGui::EndPopup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
||||
|
@ -643,14 +643,18 @@ Application::drawDeleteMassPopup(int mass_index) {
|
|||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ImGuiID
|
||||
Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
||||
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
return;
|
||||
return ImGui::GetID("Confirmation##DeleteStagedMassConfirmation");
|
||||
}
|
||||
|
||||
ImGui::PushTextWrapPos(float(windowSize().x()) * 0.40f);
|
||||
|
@ -680,6 +684,8 @@ Application::drawDeleteStagedMassPopup(Containers::StringView filename) {
|
|||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -199,8 +199,6 @@ add_executable(MassBuilderSaveTool
|
|||
Managers/MassManager.cpp
|
||||
Managers/ProfileManager.h
|
||||
Managers/ProfileManager.cpp
|
||||
Managers/Vfs/VirtualFileSystem.h
|
||||
Managers/Vfs/VfsDirectory.h
|
||||
Maps/ArmourSlots.hpp
|
||||
Maps/BulletLauncherAttachmentStyles.hpp
|
||||
Maps/BulletLauncherSockets.hpp
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <chrono>
|
||||
|
||||
#include <Corrade/Containers/GrowableArray.h>
|
||||
#include <Corrade/Containers/Pair.h>
|
||||
#include <Corrade/Containers/ScopeGuard.h>
|
||||
#include <Corrade/Utility/Path.h>
|
||||
#include <Corrade/Utility/String.h>
|
||||
|
@ -226,12 +225,10 @@ void
|
|||
BackupManager::scanSubdir(Containers::StringView subdir) {
|
||||
static std::uint8_t depth = 0;
|
||||
|
||||
auto full_subdir = Utility::Path::join(conf().directories().backups, subdir);
|
||||
|
||||
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) {
|
||||
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{
|
||||
|
@ -246,9 +243,7 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
|
|||
Backup backup;
|
||||
backup.filename = Utility::Path::join(subdir, file);
|
||||
|
||||
auto full_path = Utility::Path::join(full_subdir, file);
|
||||
|
||||
zip = zip_open(full_path.cbegin(), ZIP_RDONLY, &error_code);
|
||||
zip = zip_open(Utility::Path::join(conf().directories().backups, file).data(), ZIP_RDONLY, &error_code);
|
||||
if(zip == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
@ -306,13 +301,14 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
|
|||
arrayAppend(_backups, Utility::move(backup));
|
||||
}
|
||||
|
||||
if(depth == 5) {
|
||||
return;
|
||||
auto subdirs = Utility::Path::list(conf().directories().backups,
|
||||
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(!subdirs) {
|
||||
LOG_ERROR_FORMAT("Couldn't list contents of {}.", full_subdir);
|
||||
if(depth == 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
depth++;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace mbst { namespace Managers {
|
|||
|
||||
class BackupManager {
|
||||
public:
|
||||
explicit BackupManager();
|
||||
BackupManager();
|
||||
|
||||
auto lastError() -> Containers::StringView;
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}}}
|
|
@ -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
2
third-party/corrade
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f966f918bd7dec95002921227b6bd68ccbdda113
|
||||
Subproject commit 295bbba1f49887da060465f88b8501965f6acd7d
|
2
third-party/imgui
vendored
2
third-party/imgui
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a8e96ae21a4ec10e5f02b19dd865dfffe8a98e67
|
||||
Subproject commit 4f9ba19e520bea478f5cb654d37ef45e6404bd52
|
2
third-party/magnum
vendored
2
third-party/magnum
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a40020f3fff91dc9c59148f52adb0d48203799eb
|
||||
Subproject commit 8538610fa27e1db37070eaabe34f1e4e41648bab
|
Loading…
Reference in a new issue