/* === G L O B A L S ======================================================= */
-FileVersion save_canvas_version;
+ReleaseVersion save_canvas_version = ReleaseVersion(RELEASE_VERSION_END-1);
+int valuenode_too_new_count;
/* === P R O C E D U R E S ================================================= */
xmlpp::Element* encode_linkable_value_node(xmlpp::Element* root,LinkableValueNode::ConstHandle value_node,Canvas::ConstHandle canvas=0)
{
assert(value_node);
- root->set_name(value_node->get_name());
+
+ String name(value_node->get_name());
+ ReleaseVersion saving_version(get_file_version());
+ ReleaseVersion feature_version(LinkableValueNode::book()[name].release_version);
+
+ if (saving_version < feature_version)
+ {
+ valuenode_too_new_count++;
+ warning("can't save <%s> valuenodes in this old file format version", name.c_str());
+
+ ValueBase value((*value_node)(0));
+ encode_value(root,value,canvas);
+
+ // ValueNode_Const::ConstHandle const_value(ValueNode_Const::create((*value_node)(0)));
+ // encode_value_node(root,const_value,canvas);
+
+ return root;
+ }
+
+ root->set_name(name);
root->set_attribute("type",ValueBase::type_name(value_node->get_type()));
return root;
}
+xmlpp::Element* encode_canvas_toplevel(xmlpp::Element* root,Canvas::ConstHandle canvas)
+{
+ valuenode_too_new_count = 0;
+
+ xmlpp::Element* ret = encode_canvas(root, canvas);
+
+ if (valuenode_too_new_count)
+ warning("saved %d valuenodes as constant values in old file format\n", valuenode_too_new_count);
+
+ return ret;
+}
+
bool
synfig::save_canvas(const String &filename, Canvas::ConstHandle canvas)
{
assert(canvas);
xmlpp::Document document;
- encode_canvas(document.create_root_node("canvas"),canvas);
+ encode_canvas_toplevel(document.create_root_node("canvas"),canvas);
document.write_to_file_formatted(tmp_filename);
}
xmlpp::Document document;
- encode_canvas(document.create_root_node("canvas"),canvas);
+ encode_canvas_toplevel(document.create_root_node("canvas"),canvas);
return document.write_to_string_formatted();
}
void
-synfig::set_file_version(FileVersion version)
+synfig::set_file_version(ReleaseVersion version)
{
save_canvas_version = version;
}
-FileVersion
+ReleaseVersion
synfig::get_file_version()
{
return save_canvas_version;
#include "general.h"
#include "canvas.h"
#include "paramdesc.h"
+#include "releases.h"
#include "valuenode_const.h"
#include "valuenode_linear.h"
{
book_=new LinkableValueNode::Book();
-#define ADD_VALUENODE(class,name,local) \
+#define ADD_VALUENODE(class,name,local,version) \
(*book_)[name].factory=reinterpret_cast<LinkableValueNode::Factory>(&class::create); \
(*book_)[name].check_type=&class::check_type; \
- (*book_)[name].local_name=local
+ (*book_)[name].local_name=local; \
+ (*book_)[name].release_version=version
-#define ADD_VALUENODE2(class,name,local) \
+#define ADD_VALUENODE2(class,name,local,version) \
(*book_)[name].factory=reinterpret_cast<LinkableValueNode::Factory>(&class::create_from); \
(*book_)[name].check_type=&class::check_type; \
- (*book_)[name].local_name=local
-
- ADD_VALUENODE(ValueNode_Linear, "linear", _("Linear") );
- ADD_VALUENODE(ValueNode_Composite, "composite", _("Composite") );
- ADD_VALUENODE(ValueNode_RadialComposite,"radial_composite", _("Radial Composite") );
- ADD_VALUENODE(ValueNode_Reference, "reference", _("Reference") );
- ADD_VALUENODE(ValueNode_Repeat_Gradient,"repeat_gradient", _("Repeat Gradient") );
- ADD_VALUENODE(ValueNode_Scale, "scale", _("Scale") );
- ADD_VALUENODE(ValueNode_BLineCalcTangent,"blinecalctangent",_("BLine Tangent") );
- ADD_VALUENODE(ValueNode_BLineCalcVertex,"blinecalcvertex", _("BLine Vertex") );
- ADD_VALUENODE(ValueNode_BLineRevTangent,"blinerevtangent", _("Reverse Tangent") );
- ADD_VALUENODE(ValueNode_SegCalcTangent, "segcalctangent", _("Segment Tangent") );
- ADD_VALUENODE(ValueNode_SegCalcVertex, "segcalcvertex", _("Segment Vertex") );
- ADD_VALUENODE(ValueNode_Stripes, "stripes", _("Stripes") );
- ADD_VALUENODE(ValueNode_Range, "range", _("Range") );
- ADD_VALUENODE(ValueNode_Add, "add", _("Add") );
- ADD_VALUENODE(ValueNode_Subtract, "subtract", _("Subtract") );
- ADD_VALUENODE(ValueNode_TimedSwap, "timed_swap", _("Timed Swap") );
- ADD_VALUENODE(ValueNode_TwoTone, "twotone", _("Two-Tone") );
- ADD_VALUENODE(ValueNode_BLine, "bline", _("BLine") );
- ADD_VALUENODE2(ValueNode_DynamicList, "dynamic_list", _("Dynamic List") );
- ADD_VALUENODE(ValueNode_GradientRotate, "gradient_rotate", _("Gradient Rotate") );
- ADD_VALUENODE(ValueNode_Sine, "sine", _("Sine") );
- ADD_VALUENODE(ValueNode_Cos, "cos", _("Cos") );
- ADD_VALUENODE(ValueNode_Atan2, "atan2", _("aTan2") );
- ADD_VALUENODE(ValueNode_Exp, "exp", _("Exponential") );
- ADD_VALUENODE(ValueNode_Switch, "switch", _("Switch") );
- ADD_VALUENODE(ValueNode_TimeLoop, "timeloop", _("Time Loop") );
- ADD_VALUENODE(ValueNode_Reciprocal, "reciprocal", _("Reciprocal") );
- ADD_VALUENODE(ValueNode_Duplicate, "duplicate", _("Duplicate") );
- ADD_VALUENODE(ValueNode_Integer, "fromint", _("From Integer") );
+ (*book_)[name].local_name=local; \
+ (*book_)[name].release_version=version
+
+ ADD_VALUENODE(ValueNode_Linear, "linear", _("Linear") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Composite, "composite", _("Composite") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_RadialComposite,"radial_composite", _("Radial Composite"),RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Reference, "reference", _("Reference") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Scale, "scale", _("Scale") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_SegCalcTangent, "segcalctangent", _("Segment Tangent") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_SegCalcVertex, "segcalcvertex", _("Segment Vertex") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Stripes, "stripes", _("Stripes") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Subtract, "subtract", _("Subtract") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_TwoTone, "twotone", _("Two-Tone") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_BLine, "bline", _("BLine") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE2(ValueNode_DynamicList, "dynamic_list", _("Dynamic List") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_GradientRotate, "gradient_rotate", _("Gradient Rotate") ,RELEASE_VERSION_0_61_06);
+ ADD_VALUENODE(ValueNode_Sine, "sine", _("Sine") ,RELEASE_VERSION_0_61_06);
+
+ ADD_VALUENODE(ValueNode_TimedSwap, "timed_swap", _("Timed Swap") ,RELEASE_VERSION_0_61_07); // SVN r610
+ ADD_VALUENODE(ValueNode_Repeat_Gradient,"repeat_gradient", _("Repeat Gradient") ,RELEASE_VERSION_0_61_07); // SVN r666
+ ADD_VALUENODE(ValueNode_Exp, "exp", _("Exponential") ,RELEASE_VERSION_0_61_07); // SVN r739
+ ADD_VALUENODE(ValueNode_Add, "add", _("Add") ,RELEASE_VERSION_0_61_07); // SVN r742
+ ADD_VALUENODE(ValueNode_BLineCalcTangent,"blinecalctangent",_("BLine Tangent") ,RELEASE_VERSION_0_61_07); // SVN r744
+ ADD_VALUENODE(ValueNode_BLineCalcVertex,"blinecalcvertex", _("BLine Vertex") ,RELEASE_VERSION_0_61_07); // SVN r744
+ ADD_VALUENODE(ValueNode_Range, "range", _("Range") ,RELEASE_VERSION_0_61_07); // SVN r776
+
+ ADD_VALUENODE(ValueNode_Switch, "switch", _("Switch") ,RELEASE_VERSION_0_61_08); // SVN r923
+ ADD_VALUENODE(ValueNode_Cos, "cos", _("Cos") ,RELEASE_VERSION_0_61_08); // SVN r1111
+ ADD_VALUENODE(ValueNode_Atan2, "atan2", _("aTan2") ,RELEASE_VERSION_0_61_08); // SVN r1132
+ ADD_VALUENODE(ValueNode_BLineRevTangent,"blinerevtangent", _("Reverse Tangent") ,RELEASE_VERSION_0_61_08); // SVN r1162
+ ADD_VALUENODE(ValueNode_TimeLoop, "timeloop", _("Time Loop") ,RELEASE_VERSION_0_61_08); // SVN r1226
+ ADD_VALUENODE(ValueNode_Reciprocal, "reciprocal", _("Reciprocal") ,RELEASE_VERSION_0_61_08); // SVN r1238
+ ADD_VALUENODE(ValueNode_Duplicate, "duplicate", _("Duplicate") ,RELEASE_VERSION_0_61_08); // SVN r1267
+ ADD_VALUENODE(ValueNode_Integer, "fromint", _("From Integer") ,RELEASE_VERSION_0_61_08); // SVN r1267
#undef ADD_VALUENODE
#undef ADD_VALUENODE2