Compare commits
No commits in common. "c1ad757f80ebaf39735859ee2a0bc6e5bd215d69" and "b8584f26bbf5323a46215bab3b0a7565167fb6a1" have entirely different histories.
c1ad757f80
...
b8584f26bb
6 changed files with 66 additions and 44 deletions
|
@ -199,7 +199,8 @@ add_executable(MassBuilderSaveTool
|
|||
Managers/MassManager.cpp
|
||||
Managers/ProfileManager.h
|
||||
Managers/ProfileManager.cpp
|
||||
Managers/Vfs/Directory.h
|
||||
Managers/Vfs/VirtualFileSystem.h
|
||||
Managers/Vfs/VfsDirectory.h
|
||||
Maps/ArmourSlots.hpp
|
||||
Maps/BulletLauncherAttachmentStyles.hpp
|
||||
Maps/BulletLauncherSockets.hpp
|
||||
|
@ -238,10 +239,6 @@ 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,10 +92,6 @@ 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():
|
||||
_root{""}
|
||||
_vfs()
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ BackupManager::refresh() {
|
|||
|
||||
scanSubdir(""_s);
|
||||
|
||||
_root.clear();
|
||||
_root.build(_backups);
|
||||
_vfs.build(_backups);
|
||||
}
|
||||
|
||||
Containers::ArrayView<const Backup>
|
||||
|
@ -61,10 +60,10 @@ BackupManager::backups() const {
|
|||
return _backups;
|
||||
}
|
||||
|
||||
const Vfs::Directory<Backup>&
|
||||
const Vfs::VirtualFileSystem<Backup>&
|
||||
BackupManager::vfs() const
|
||||
{
|
||||
return _root;
|
||||
return _vfs;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "Backup.h"
|
||||
#include "../GameObjects/Profile.h"
|
||||
#include "Vfs/Directory.h"
|
||||
#include "Vfs/VirtualFileSystem.h"
|
||||
|
||||
using namespace Corrade;
|
||||
|
||||
|
@ -41,13 +41,10 @@ class BackupManager {
|
|||
|
||||
auto backups() const -> Containers::ArrayView<const Backup>;
|
||||
|
||||
auto vfs() const -> const Vfs::Directory<Backup>&;
|
||||
auto vfs() const -> const Vfs::VirtualFileSystem<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:
|
||||
|
@ -57,7 +54,7 @@ class BackupManager {
|
|||
|
||||
Containers::Array<Backup> _backups;
|
||||
|
||||
Vfs::Directory<Backup> _root;
|
||||
Vfs::VirtualFileSystem<Backup> _vfs;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -27,22 +27,22 @@ namespace mbst { namespace Managers { namespace Vfs {
|
|||
CORRADE_HAS_TYPE(HasFilename, decltype(T::filename));
|
||||
|
||||
template<typename FileType>
|
||||
class Directory {
|
||||
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 = Directory<FileType>;
|
||||
using DirType = VfsDirectory<FileType>;
|
||||
|
||||
explicit Directory(Containers::StringView name): _name{name} {
|
||||
explicit VfsDirectory(Containers::StringView name): _name{name} {
|
||||
// ctor
|
||||
}
|
||||
|
||||
Directory(const Directory<FileType>& other) = delete;
|
||||
Directory& operator=(const Directory<FileType>& other) = delete;
|
||||
VfsDirectory(const VfsDirectory<FileType>& other) = delete;
|
||||
VfsDirectory& operator=(const VfsDirectory<FileType>& other) = delete;
|
||||
|
||||
Directory(Directory<FileType>&& other) = default;
|
||||
Directory& operator=(Directory<FileType>&& other) = default;
|
||||
VfsDirectory(VfsDirectory<FileType>&& other) = default;
|
||||
VfsDirectory& operator=(VfsDirectory<FileType>&& other) = default;
|
||||
|
||||
auto name() const -> Containers::StringView {
|
||||
return _name;
|
||||
|
@ -52,26 +52,12 @@ class Directory {
|
|||
return _subdirs;
|
||||
}
|
||||
|
||||
auto files() const -> Containers::ArrayView<FileType* const> {
|
||||
auto files() const -> Containers::ArrayView<const FileType*> {
|
||||
return _files;
|
||||
}
|
||||
|
||||
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,
|
||||
protected:
|
||||
void buildNestedPath(VfsDirectory<FileType>& root, Containers::ArrayView<const Containers::MutableStringView> components,
|
||||
FileType& file)
|
||||
{
|
||||
if(components.size() > 1) {
|
47
src/Managers/Vfs/VirtualFileSystem.h
Normal file
47
src/Managers/Vfs/VirtualFileSystem.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#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