Can load files from previous versions

This commit is contained in:
Yousef Khadadeh 2026-01-02 09:22:52 +03:00
parent b5877ff3ca
commit eb12cdfa7c
5 changed files with 75 additions and 25 deletions

View file

@ -63,10 +63,20 @@ void CanvasComponentContainer::save_file(cereal::PortableBinaryOutputArchive& a)
}
void CanvasComponentContainer::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version, NetObjManager& objMan) {
a(coords);
compAllocator = objMan.make_obj_direct<CanvasComponentAllocator>();
compAllocator->load_file(a, version);
compAllocator->comp->compContainer = this;
if(version >= VersionNumber(0, 4, 0)) {
a(coords);
compAllocator = objMan.make_obj_direct<CanvasComponentAllocator>();
compAllocator->load_file(a, version);
compAllocator->comp->compContainer = this;
}
else {
CanvasComponentType t;
NetworkingObjects::NetObjID uselessID;
a(t, uselessID, coords);
compAllocator = objMan.make_obj_direct<CanvasComponentAllocator>(t);
compAllocator->comp->load_file(a, version);
compAllocator->comp->compContainer = this;
}
}
void CanvasComponentContainer::draw(SkCanvas* canvas, const DrawData& drawData) const {

View file

@ -40,7 +40,12 @@ void TextBoxCanvasComponent::save_file(cereal::PortableBinaryOutputArchive& a) c
}
void TextBoxCanvasComponent::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) {
if(version < VersionNumber(0, 3, 0)) {
if(version >= VersionNumber(0, 3, 0)) {
TextData richText;
a(d.p1, d.p2, richText);
textBox->set_rich_text_data(richText);
}
else {
bool loadedEditing; // Unused
Vector4f textColor;
float textSize;
@ -51,11 +56,6 @@ void TextBoxCanvasComponent::load_file(cereal::PortableBinaryInputArchive& a, Ve
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);
}
}
std::unique_ptr<CanvasComponent> TextBoxCanvasComponent::get_data_copy() const {