-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use property constructors without PropertyTag, cleanup property value…
… interface
- Loading branch information
Showing
10 changed files
with
47 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 4 additions & 16 deletions
20
libsave/include/SatisfactorySave/GameTypes/Properties/ByteProperty.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
#include <vector> | ||
|
||
#include "Base/Property.h" | ||
#include "Base/PropertyImpl.h" | ||
|
||
namespace SatisfactorySave { | ||
|
||
class SATISFACTORYSAVE_API ByteProperty : public Property { | ||
class SATISFACTORYSAVE_API ByteProperty : public PropertyImplBase<ByteProperty, std::variant<FName, int8_t>> { | ||
public: | ||
static constexpr std::string_view TypeName = "ByteProperty"; | ||
|
||
using Property::Property; | ||
using PropertyImplBase<ByteProperty, std::variant<FName, int8_t>>::PropertyImplBase; | ||
|
||
void serialize(Archive& ar) override; | ||
|
||
void accept(PropertyVisitor& v) override; | ||
|
||
[[nodiscard]] inline FName& enumName() { | ||
return tag_.EnumName; | ||
} | ||
|
||
[[nodiscard]] const FName& valueName() const { | ||
return value_name_; | ||
} | ||
|
||
[[nodiscard]] int8_t valueByte() const { | ||
return value_byte_; | ||
} | ||
|
||
protected: | ||
FName value_name_; | ||
int8_t value_byte_ = 0; | ||
}; | ||
} // namespace SatisfactorySave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#include "GameTypes/Properties/ByteProperty.h" | ||
|
||
#include "GameTypes/Properties/Base/PropertyVisitor.h" | ||
|
||
void SatisfactorySave::ByteProperty::serialize(Archive& ar) { | ||
if (ar.isIArchive()) { | ||
if (enumName() == "None") { | ||
Value = static_cast<int8_t>(0); | ||
} else { | ||
Value = FName(); | ||
} | ||
} | ||
if (enumName() == "None") { | ||
ar << value_byte_; | ||
ar << std::get<int8_t>(Value); | ||
} else { | ||
ar << value_name_; | ||
ar << std::get<FName>(Value); | ||
} | ||
} | ||
|
||
void SatisfactorySave::ByteProperty::accept(SatisfactorySave::PropertyVisitor& v) { | ||
v.visit(*this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters