+ optional<string> const e = optional_string_attribute (node, "Effect");
+ if (e) {
+ ps.effect = string_to_effect (e.get ());
+ }
+ c = optional_string_attribute (node, "EffectColor");
+ if (c) {
+ ps.effect_colour = Colour (c.get ());
+ }
+
+ return ps;
+}
+
+SubtitleAsset::ParseState
+SubtitleAsset::text_node_state (xmlpp::Element const * node) const
+{
+ ParseState ps;
+
+ optional<float> hp = optional_number_attribute<float> (node, "HPosition");
+ if (!hp) {
+ hp = optional_number_attribute<float> (node, "Hposition");
+ }
+ if (hp) {
+ ps.h_position = hp.get () / 100;
+ }
+
+ optional<string> ha = optional_string_attribute (node, "HAlign");
+ if (!ha) {
+ ha = optional_string_attribute (node, "Halign");
+ }
+ if (ha) {
+ ps.h_align = string_to_halign (ha.get ());
+ }
+
+ optional<float> vp = optional_number_attribute<float> (node, "VPosition");
+ if (!vp) {
+ vp = optional_number_attribute<float> (node, "Vposition");
+ }
+ if (vp) {
+ ps.v_position = vp.get () / 100;
+ }
+
+ optional<string> va = optional_string_attribute (node, "VAlign");
+ if (!va) {
+ va = optional_string_attribute (node, "Valign");
+ }
+ if (va) {
+ ps.v_align = string_to_valign (va.get ());
+ }
+
+ optional<string> d = optional_string_attribute (node, "Direction");
+ if (d) {
+ ps.direction = string_to_direction (d.get ());
+ }
+
+ return ps;
+}
+
+SubtitleAsset::ParseState
+SubtitleAsset::subtitle_node_state (xmlpp::Element const * node, optional<int> tcr) const
+{
+ ParseState ps;
+ ps.in = Time (string_attribute(node, "TimeIn"), tcr);
+ ps.out = Time (string_attribute(node, "TimeOut"), tcr);
+ ps.fade_up_time = fade_time (node, "FadeUpTime", tcr);
+ ps.fade_down_time = fade_time (node, "FadeDownTime", tcr);
+ return ps;
+}
+
+Time
+SubtitleAsset::fade_time (xmlpp::Element const * node, string name, optional<int> tcr) const
+{
+ string const u = optional_string_attribute(node, name).get_value_or ("");
+ Time t;
+
+ if (u.empty ()) {
+ t = Time (0, 0, 0, 20, 250);
+ } else if (u.find (":") != string::npos) {
+ t = Time (u, tcr);
+ } else {
+ t = Time (0, 0, 0, lexical_cast<int> (u), tcr.get_value_or(250));
+ }
+
+ if (t > Time (0, 0, 8, 0, 250)) {
+ t = Time (0, 0, 8, 0, 250);
+ }
+
+ return t;