1.5: Fuckin' UE5... #38

Manually merged
williamjcm merged 126 commits from one-point-five into master 2024-07-22 11:06:13 +02:00
5 changed files with 38 additions and 66 deletions
Showing only changes of commit c1ad757f80 - Show all commits

View file

@ -199,8 +199,7 @@ 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/Directory.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

@ -35,7 +35,9 @@
namespace mbst { namespace Managers { namespace mbst { namespace Managers {
BackupManager::BackupManager() { BackupManager::BackupManager():
_root{""}
{
refresh(); refresh();
} }
@ -50,7 +52,8 @@ BackupManager::refresh() {
scanSubdir(""_s); scanSubdir(""_s);
_vfs.build(_backups); _root.clear();
_root.build(_backups);
} }
Containers::ArrayView<const Backup> Containers::ArrayView<const Backup>
@ -58,10 +61,10 @@ BackupManager::backups() const {
return _backups; return _backups;
} }
const Vfs::VirtualFileSystem<Backup>& const Vfs::Directory<Backup>&
BackupManager::vfs() const BackupManager::vfs() const
{ {
return _vfs; return _root;
} }
bool bool

View file

@ -25,7 +25,7 @@
#include "Backup.h" #include "Backup.h"
#include "../GameObjects/Profile.h" #include "../GameObjects/Profile.h"
#include "Vfs/VirtualFileSystem.h" #include "Vfs/Directory.h"
using namespace Corrade; using namespace Corrade;
@ -41,10 +41,13 @@ class BackupManager {
auto backups() const -> Containers::ArrayView<const Backup>; 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 create(const GameObjects::Profile& profile);
bool remove(std::size_t index); bool remove(std::size_t index);
bool remove(Containers::StringView filename);
bool restore(std::size_t index); bool restore(std::size_t index);
private: private:
@ -54,7 +57,7 @@ class BackupManager {
Containers::Array<Backup> _backups; Containers::Array<Backup> _backups;
Vfs::VirtualFileSystem<Backup> _vfs; Vfs::Directory<Backup> _root;
}; };
}} }}

View file

@ -27,22 +27,22 @@ namespace mbst { namespace Managers { namespace Vfs {
CORRADE_HAS_TYPE(HasFilename, decltype(T::filename)); CORRADE_HAS_TYPE(HasFilename, decltype(T::filename));
template<typename FileType> template<typename FileType>
class VfsDirectory { class Directory {
public: public:
static_assert(HasFilename<FileType>::value && (std::is_same<decltype(FileType::filename), Containers::String>::value || std::is_same<decltype(FileType::filename), Containers::StringView>::value), 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."); "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 // ctor
} }
VfsDirectory(const VfsDirectory<FileType>& other) = delete; Directory(const Directory<FileType>& other) = delete;
VfsDirectory& operator=(const VfsDirectory<FileType>& other) = delete; Directory& operator=(const Directory<FileType>& other) = delete;
VfsDirectory(VfsDirectory<FileType>&& other) = default; Directory(Directory<FileType>&& other) = default;
VfsDirectory& operator=(VfsDirectory<FileType>&& other) = default; Directory& operator=(Directory<FileType>&& other) = default;
auto name() const -> Containers::StringView { auto name() const -> Containers::StringView {
return _name; return _name;
@ -52,12 +52,26 @@ class VfsDirectory {
return _subdirs; return _subdirs;
} }
auto files() const -> Containers::ArrayView<const FileType*> { auto files() const -> Containers::ArrayView<FileType* const> {
return _files; return _files;
} }
protected: void clear() {
void buildNestedPath(VfsDirectory<FileType>& root, Containers::ArrayView<const Containers::MutableStringView> components, _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) FileType& file)
{ {
if(components.size() > 1) { if(components.size() > 1) {

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);
}
}
};
}}}