Compare commits
5 commits
b8584f26bb
...
c1ad757f80
Author | SHA1 | Date | |
---|---|---|---|
c1ad757f80 | |||
c0bf16144f | |||
90a67f30d9 | |||
e9a356fa21 | |||
03cbb7f8ae |
6 changed files with 44 additions and 66 deletions
|
@ -199,8 +199,7 @@ add_executable(MassBuilderSaveTool
|
|||
Managers/MassManager.cpp
|
||||
Managers/ProfileManager.h
|
||||
Managers/ProfileManager.cpp
|
||||
Managers/Vfs/VirtualFileSystem.h
|
||||
Managers/Vfs/VfsDirectory.h
|
||||
Managers/Vfs/Directory.h
|
||||
Maps/ArmourSlots.hpp
|
||||
Maps/BulletLauncherAttachmentStyles.hpp
|
||||
Maps/BulletLauncherSockets.hpp
|
||||
|
@ -239,6 +238,10 @@ target_compile_definitions(MassBuilderSaveTool PRIVATE
|
|||
SAVETOOL_SUPPORTED_GAME_VERSION="0.10.x"
|
||||
)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
target_compile_definitions(MassBuilderSaveTool PRIVATE SAVETOOL_DEBUG_BUILD)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
set_target_properties(MassBuilderSaveTool PROPERTIES OUTPUT_NAME MassBuilderSaveTool-${SAVETOOL_PROJECT_VERSION})
|
||||
endif()
|
||||
|
|
|
@ -92,6 +92,10 @@ Logger::log(EntryType type, StringView location, StringView message) {
|
|||
}
|
||||
|
||||
d << ((message.back() == '\n') ? message.exceptSuffix(1) : message);
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
_logFile.flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
namespace mbst { namespace Managers {
|
||||
|
||||
BackupManager::BackupManager():
|
||||
_vfs()
|
||||
_root{""}
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ BackupManager::refresh() {
|
|||
|
||||
scanSubdir(""_s);
|
||||
|
||||
_vfs.build(_backups);
|
||||
_root.clear();
|
||||
_root.build(_backups);
|
||||
}
|
||||
|
||||
Containers::ArrayView<const Backup>
|
||||
|
@ -60,10 +61,10 @@ BackupManager::backups() const {
|
|||
return _backups;
|
||||
}
|
||||
|
||||
const Vfs::VirtualFileSystem<Backup>&
|
||||
const Vfs::Directory<Backup>&
|
||||
BackupManager::vfs() const
|
||||
{
|
||||
return _vfs;
|
||||
return _root;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "Backup.h"
|
||||
#include "../GameObjects/Profile.h"
|
||||
#include "Vfs/VirtualFileSystem.h"
|
||||
#include "Vfs/Directory.h"
|
||||
|
||||
using namespace Corrade;
|
||||
|
||||
|
@ -41,10 +41,13 @@ class BackupManager {
|
|||
|
||||
auto backups() const -> Containers::ArrayView<const Backup>;
|
||||
|
||||
auto vfs() const -> const Vfs::VirtualFileSystem<Backup>&;
|
||||
auto vfs() const -> const Vfs::Directory<Backup>&;
|
||||
|
||||
bool create(const GameObjects::Profile& profile);
|
||||
|
||||
bool remove(std::size_t index);
|
||||
bool remove(Containers::StringView filename);
|
||||
|
||||
bool restore(std::size_t index);
|
||||
|
||||
private:
|
||||
|
@ -54,7 +57,7 @@ class BackupManager {
|
|||
|
||||
Containers::Array<Backup> _backups;
|
||||
|
||||
Vfs::VirtualFileSystem<Backup> _vfs;
|
||||
Vfs::Directory<Backup> _root;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -27,22 +27,22 @@ namespace mbst { namespace Managers { namespace Vfs {
|
|||
CORRADE_HAS_TYPE(HasFilename, decltype(T::filename));
|
||||
|
||||
template<typename FileType>
|
||||
class VfsDirectory {
|
||||
class Directory {
|
||||
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>;
|
||||
using DirType = Directory<FileType>;
|
||||
|
||||
explicit VfsDirectory(Containers::StringView name): _name{name} {
|
||||
explicit Directory(Containers::StringView name): _name{name} {
|
||||
// ctor
|
||||
}
|
||||
|
||||
VfsDirectory(const VfsDirectory<FileType>& other) = delete;
|
||||
VfsDirectory& operator=(const VfsDirectory<FileType>& other) = delete;
|
||||
Directory(const Directory<FileType>& other) = delete;
|
||||
Directory& operator=(const Directory<FileType>& other) = delete;
|
||||
|
||||
VfsDirectory(VfsDirectory<FileType>&& other) = default;
|
||||
VfsDirectory& operator=(VfsDirectory<FileType>&& other) = default;
|
||||
Directory(Directory<FileType>&& other) = default;
|
||||
Directory& operator=(Directory<FileType>&& other) = default;
|
||||
|
||||
auto name() const -> Containers::StringView {
|
||||
return _name;
|
||||
|
@ -52,12 +52,26 @@ class VfsDirectory {
|
|||
return _subdirs;
|
||||
}
|
||||
|
||||
auto files() const -> Containers::ArrayView<const FileType*> {
|
||||
auto files() const -> Containers::ArrayView<FileType* const> {
|
||||
return _files;
|
||||
}
|
||||
|
||||
protected:
|
||||
void buildNestedPath(VfsDirectory<FileType>& root, Containers::ArrayView<const Containers::MutableStringView> components,
|
||||
void clear() {
|
||||
_subdirs = Containers::Array<DirType>{};
|
||||
_files = Containers::Array<FileType*>{};
|
||||
}
|
||||
|
||||
void build(Containers::ArrayView<FileType> files) {
|
||||
for(auto& file : files) {
|
||||
auto components = file.filename.split('/');
|
||||
CORRADE_INTERNAL_ASSERT(components.size() != 0);
|
||||
|
||||
buildNestedPath(*this, components, file);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void buildNestedPath(Directory<FileType>& root, Containers::ArrayView<const Containers::MutableStringView> components,
|
||||
FileType& file)
|
||||
{
|
||||
if(components.size() > 1) {
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
Loading…
Reference in a new issue