Serialization works in new version
This commit is contained in:
parent
6b3ce01e94
commit
79f7135746
23 changed files with 186 additions and 56 deletions
|
|
@ -23,6 +23,14 @@ void DrawBrushStroke::load(cereal::PortableBinaryInputArchive& a) {
|
|||
a(d->points, d->color, d->hasRoundCaps);
|
||||
}
|
||||
|
||||
void DrawBrushStroke::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(d->points, d->color, d->hasRoundCaps);
|
||||
}
|
||||
|
||||
void DrawBrushStroke::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
|
||||
a(d->points, d->color, d->hasRoundCaps);
|
||||
}
|
||||
|
||||
DrawComponentType DrawBrushStroke::get_type() const {
|
||||
return DRAWCOMPONENT_BRUSHSTROKE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class DrawBrushStroke : public DrawComponent {
|
|||
virtual DrawComponentType get_type() const override;
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
||||
|
||||
struct Data {
|
||||
std::vector<DrawBrushStrokePoint> points;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "../CoordSpaceHelper.hpp"
|
||||
#include "../Server/MainServer.hpp"
|
||||
#include "../CollabList.hpp"
|
||||
#include <Helpers/VersionNumber.hpp>
|
||||
|
||||
#ifndef IS_SERVER
|
||||
#include "../DrawData.hpp"
|
||||
|
|
@ -43,6 +44,8 @@ class DrawComponent {
|
|||
static std::shared_ptr<DrawComponent> allocate_comp_type(DrawComponentType type);
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const = 0;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) = 0;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const = 0;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) = 0;
|
||||
virtual DrawComponentType get_type() const = 0;
|
||||
virtual void get_used_resources(std::unordered_set<ServerClientID>& v) const;
|
||||
virtual void remap_resource_ids(std::unordered_map<ServerClientID, ServerClientID>& newIDs);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ void DrawEllipse::load(cereal::PortableBinaryInputArchive& a) {
|
|||
a(d.strokeColor, d.fillColor, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
void DrawEllipse::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(d.strokeColor, d.fillColor, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
void DrawEllipse::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
|
||||
a(d.strokeColor, d.fillColor, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawEllipse::copy() const {
|
||||
auto a = std::make_shared<DrawEllipse>();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class DrawEllipse : public DrawComponent {
|
|||
public:
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
||||
virtual DrawComponentType get_type() const override;
|
||||
|
||||
// User input data
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ void DrawImage::load(cereal::PortableBinaryInputArchive& a) {
|
|||
a(d.p1, d.p2, d.imageID);
|
||||
}
|
||||
|
||||
void DrawImage::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(d.p1, d.p2, d.imageID);
|
||||
}
|
||||
|
||||
void DrawImage::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
|
||||
a(d.p1, d.p2, d.imageID);
|
||||
}
|
||||
|
||||
void DrawImage::get_used_resources(std::unordered_set<ServerClientID>& v) const {
|
||||
v.emplace(d.imageID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class DrawImage : public DrawComponent {
|
|||
public:
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
||||
virtual DrawComponentType get_type() const override;
|
||||
virtual void get_used_resources(std::unordered_set<ServerClientID>& v) const override;
|
||||
virtual void remap_resource_ids(std::unordered_map<ServerClientID, ServerClientID>& newIDs) override;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,14 @@ void DrawRectangle::load(cereal::PortableBinaryInputArchive& a) {
|
|||
a(d.strokeColor, d.fillColor, d.cornerRadius, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
void DrawRectangle::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(d.strokeColor, d.fillColor, d.cornerRadius, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
void DrawRectangle::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
|
||||
a(d.strokeColor, d.fillColor, d.cornerRadius, d.strokeWidth, d.p1, d.p2, d.fillStrokeMode);
|
||||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawRectangle::copy() const {
|
||||
auto a = std::make_shared<DrawRectangle>();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class DrawRectangle : public DrawComponent {
|
|||
public:
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
||||
virtual DrawComponentType get_type() const override;
|
||||
|
||||
// User input data
|
||||
|
|
|
|||
|
|
@ -37,6 +37,29 @@ void DrawTextBox::load(cereal::PortableBinaryInputArchive& a) {
|
|||
textBox->set_rich_text_data(richText);
|
||||
}
|
||||
|
||||
void DrawTextBox::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(d.p1, d.p2, textBox->get_rich_text_data());
|
||||
}
|
||||
|
||||
void DrawTextBox::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
|
||||
if(version < VersionNumber(0, 3, 0)) {
|
||||
bool editing; // Unused
|
||||
Vector4f textColor;
|
||||
float textSize;
|
||||
RichText::TextBox::Cursor cursor; // Unused, Equivalent to old cursor structure, just paragraph index and text index flipped
|
||||
std::string currentText;
|
||||
a(editing, d.p1, d.p2, textColor, textSize, cursor, currentText);
|
||||
textBox->insert({0, 0}, currentText);
|
||||
textBox->set_text_style_modifier_between({0, 0}, textBox->move(RichText::TextBox::Movement::END, {0, 0}), std::make_shared<ColorTextStyleModifier>(textColor));
|
||||
textBox->set_text_style_modifier_between({0, 0}, textBox->move(RichText::TextBox::Movement::END, {0, 0}), std::make_shared<SizeTextStyleModifier>(textSize));
|
||||
}
|
||||
else {
|
||||
TextData richText;
|
||||
a(d.p1, d.p2, richText);
|
||||
textBox->set_rich_text_data(richText);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawTextBox::copy() const {
|
||||
auto a = std::make_shared<DrawTextBox>();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class DrawTextBox : public DrawComponent {
|
|||
virtual DrawComponentType get_type() const override;
|
||||
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
||||
virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override;
|
||||
virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override;
|
||||
|
||||
// User input data
|
||||
struct Data {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue