109 lines
3.2 KiB
C++
109 lines
3.2 KiB
C++
/*
|
|
speciesgen
|
|
Copyright (C) 2022-2023 prisixia
|
|
|
|
This file is part of speciesgen.
|
|
|
|
speciesgen 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.
|
|
|
|
speciesgen 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 speciesgen. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: species.cpp
|
|
// Purpose: Implementation of SpeciesConfig for patching
|
|
// Author: prisixia
|
|
// Created: 2022-10-03
|
|
// Copyright: (C) 2022-2023 prisixia
|
|
// Licence: GNU General Public License version 3
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef SPECIESGEN_STARPOUNDS_SPECIES_H
|
|
#define SPECIESGEN_STARPOUNDS_SPECIES_H
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
|
|
#include "cereal/types/string.hpp"
|
|
|
|
namespace Starpounds {
|
|
class SpeciesConfig {
|
|
public:
|
|
SpeciesConfig(const bool = false);
|
|
SpeciesConfig(std::string, const bool = false);
|
|
SpeciesConfig(std::string, std::string, const bool = false);
|
|
|
|
[[nodiscard]] bool GetFullbright() const;
|
|
[[nodiscard]] std::string GetOverride() const;
|
|
[[nodiscard]] std::string GetOverrideDirectives() const;
|
|
|
|
void SetFullbright(const bool);
|
|
void SetOverride(const std::string &);
|
|
void SetOverrideDirectives(const std::string &);
|
|
|
|
private:
|
|
bool m_fullbright;
|
|
std::string m_override;
|
|
std::string m_overrideDirectives;
|
|
};
|
|
} // namespace Starpounds
|
|
|
|
//----------------------------------------------------------------------
|
|
// Serialisation
|
|
//----------------------------------------------------------------------
|
|
|
|
namespace cereal {
|
|
template <class Archive>
|
|
void Load(Archive &archive, Starpounds::SpeciesConfig &m) {
|
|
bool fullbright;
|
|
std::string _override;
|
|
std::string overrideDirectives;
|
|
|
|
/*
|
|
* It'd throw an exception here eventually, since this
|
|
* patch may not include unnecesseary data, while cereal
|
|
* currently has no option to deserialise with optional
|
|
* values.
|
|
*
|
|
* But since we don't load this and just have this function
|
|
* because we can, we don't have to worry about this for now.
|
|
*/
|
|
archive(CEREAL_NVP(fullbright), CEREAL_NVP_("override", _override),
|
|
CEREAL_NVP(overrideDirectives));
|
|
|
|
m.SetFullbright(fullbright);
|
|
m.SetOverride(_override);
|
|
m.SetOverrideDirectives(overrideDirectives);
|
|
}
|
|
|
|
template <class Archive>
|
|
void Save(Archive &archive, Starpounds::SpeciesConfig const &m) {
|
|
const bool fullbright = m.GetFullbright();
|
|
const std::string _override = m.GetOverride();
|
|
const std::string overrideDirectives = m.GetOverrideDirectives();
|
|
|
|
if (fullbright) {
|
|
archive(CEREAL_NVP(fullbright));
|
|
}
|
|
|
|
if (!_override.empty()) {
|
|
archive(CEREAL_NVP_("override", _override));
|
|
}
|
|
|
|
if (!overrideDirectives.empty()) {
|
|
archive(CEREAL_NVP(overrideDirectives));
|
|
}
|
|
}
|
|
} // namespace cereal
|
|
|
|
#endif // SPECIESGEN_STARPOUNDS_SPECIES_H
|