2021-06-11 19:24:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2021-06-11 19:24:52 +02:00
|
|
|
//
|
|
|
|
// 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/>.
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
#include <string>
|
2021-09-23 19:01:42 +02:00
|
|
|
|
|
|
|
#include <Corrade/Containers/Array.h>
|
2022-03-04 21:18:55 +01:00
|
|
|
#include <Corrade/Containers/String.h>
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2024-03-28 13:15:47 +01:00
|
|
|
#include "../GameObjects/Profile.h"
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2021-09-23 19:01:42 +02:00
|
|
|
using namespace Corrade;
|
|
|
|
|
2024-03-28 13:32:34 +01:00
|
|
|
namespace mbst { namespace Managers {
|
2023-11-29 12:33:26 +01:00
|
|
|
|
2021-06-11 19:24:52 +02:00
|
|
|
struct Backup {
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::String filename;
|
|
|
|
Containers::String company;
|
2023-11-29 12:33:26 +01:00
|
|
|
bool demo;
|
2021-06-11 19:24:52 +02:00
|
|
|
struct {
|
2022-12-05 11:32:18 +01:00
|
|
|
std::int32_t year;
|
|
|
|
std::int32_t month;
|
|
|
|
std::int32_t day;
|
|
|
|
std::int32_t hour;
|
|
|
|
std::int32_t minute;
|
|
|
|
std::int32_t second;
|
2021-06-11 19:24:52 +02:00
|
|
|
} timestamp;
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::Array<Containers::String> includedFiles;
|
2021-06-11 19:24:52 +02:00
|
|
|
};
|
|
|
|
|
2024-03-28 13:32:34 +01:00
|
|
|
class Profile {
|
2021-06-11 19:24:52 +02:00
|
|
|
public:
|
2024-03-28 13:32:34 +01:00
|
|
|
explicit Profile(Containers::StringView save_dir, Containers::StringView backup_dir);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
auto ready() const -> bool;
|
2023-11-29 12:33:26 +01:00
|
|
|
auto lastError() -> Containers::StringView;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto profiles() -> Containers::ArrayView<GameObjects::Profile>;
|
2022-12-03 16:49:39 +01:00
|
|
|
bool refreshProfiles();
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto getProfile(std::size_t index) -> GameObjects::Profile*;
|
2022-12-03 16:49:39 +01:00
|
|
|
bool deleteProfile(std::size_t index, bool delete_builds);
|
|
|
|
bool backupProfile(std::size_t index, bool backup_builds);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
auto backups() -> Containers::ArrayView<Backup>;
|
2021-06-11 19:24:52 +02:00
|
|
|
void refreshBackups();
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
bool deleteBackup(std::size_t index);
|
|
|
|
bool restoreBackup(std::size_t index);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool _ready = false;
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::String _lastError;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
Containers::StringView _saveDirectory;
|
|
|
|
Containers::StringView _backupsDirectory;
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
Containers::Array<GameObjects::Profile> _profiles;
|
2021-09-23 19:01:42 +02:00
|
|
|
Containers::Array<Backup> _backups;
|
2021-06-11 19:24:52 +02:00
|
|
|
};
|
2023-11-29 12:33:26 +01:00
|
|
|
|
2024-03-28 13:32:34 +01:00
|
|
|
}}
|