Reimplementing save/load file
This commit is contained in:
parent
260288a1b0
commit
9913eb6c8e
37 changed files with 437 additions and 350 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "DrawingProgramLayer.hpp"
|
||||
#include "DrawingProgramLayerManager.hpp"
|
||||
#include "../DrawingProgram.hpp"
|
||||
#include "../../World.hpp"
|
||||
#include <Helpers/Parallel.hpp>
|
||||
|
||||
void DrawingProgramLayer::draw(SkCanvas* canvas, const DrawData& drawData) const {
|
||||
|
|
@ -12,8 +13,10 @@ void DrawingProgramLayer::set_component_list_callbacks(DrawingProgramLayerListIt
|
|||
auto insertCallback = [&](const CanvasComponentContainer::ObjInfoIterator& c) {
|
||||
c->obj->objInfo = c;
|
||||
c->obj->parentLayer = &layerListItem;
|
||||
c->obj->commit_update(layerMan.drawP); // Run commit update on insert so that world bounds are calculated
|
||||
layerMan.drawP.drawCache.add_component(&(*c));
|
||||
if(layerMan.commitUpdateOnComponentInsert) {
|
||||
c->obj->commit_update(layerMan.drawP); // Run commit update on insert so that world bounds are calculated
|
||||
layerMan.drawP.drawCache.add_component(&(*c));
|
||||
}
|
||||
if(c->obj->get_comp().get_type() == CanvasComponentType::IMAGE)
|
||||
layerMan.drawP.updateableComponents.emplace(&(*c));
|
||||
};
|
||||
|
|
@ -41,12 +44,6 @@ void DrawingProgramLayer::set_to_erase() {
|
|||
eraseCallback(it);
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::commit_update_dont_invalidate_cache(DrawingProgramLayerManager& layerMan) const {
|
||||
parallel_loop_container(*components, [&layerMan](auto& comp) {
|
||||
comp.obj->commit_update_dont_invalidate_cache(layerMan.drawP);
|
||||
});
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::get_flattened_component_list(std::vector<CanvasComponentContainer::ObjInfo*>& objList) const {
|
||||
for(auto& p : *components)
|
||||
objList.emplace_back(&p);
|
||||
|
|
@ -56,3 +53,20 @@ void DrawingProgramLayer::scale_up(const WorldScalar& scaleUpAmount) {
|
|||
for(auto& p : *components)
|
||||
p.obj->scale_up(scaleUpAmount);
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version, DrawingProgramLayerManager& layerMan) {
|
||||
components = layerMan.drawP.world.netObjMan.make_obj<CanvasComponentContainer::NetList>();
|
||||
uint32_t layerListSize;
|
||||
a(layerListSize);
|
||||
for(uint32_t i = 0; i < layerListSize; i++) {
|
||||
CanvasComponentContainer* item = new CanvasComponentContainer();
|
||||
item->load_file(a, version, layerMan.drawP.world.netObjMan);
|
||||
components->push_back_and_send_create(components, item);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::save_file(cereal::PortableBinaryOutputArchive& a) const {
|
||||
a(components->size());
|
||||
for(auto& comp : *components)
|
||||
comp.obj->save_file(a);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue