diff options
Diffstat (limited to 'src/lib/film.cc')
| -rw-r--r-- | src/lib/film.cc | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index d9ab6e2a3..d747efb0e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -114,6 +114,7 @@ using namespace dcpomatic; static constexpr char metadata_file[] = "metadata.xml"; +static constexpr char ui_state_file[] = "ui.xml"; /* 5 -> 6 @@ -416,7 +417,7 @@ Film::metadata (bool with_content_paths) const root->add_child("UserExplicitVideoFrameRate")->add_child_text(_user_explicit_video_frame_rate ? "1" : "0"); for (auto const& marker: _markers) { auto m = root->add_child("Marker"); - m->set_attribute("Type", dcp::marker_to_string(marker.first)); + m->set_attribute("type", dcp::marker_to_string(marker.first)); m->add_child_text(raw_convert<string>(marker.second.get())); } for (auto i: _ratings) { @@ -603,7 +604,11 @@ Film::read_metadata (optional<boost::filesystem::path> path) _user_explicit_video_frame_rate = f.optional_bool_child("UserExplicitVideoFrameRate").get_value_or(false); for (auto i: f.node_children("Marker")) { - _markers[dcp::marker_from_string(i->string_attribute("Type"))] = DCPTime(dcp::raw_convert<DCPTime::Type>(i->content())); + auto type = i->optional_string_attribute("Type"); + if (!type) { + type = i->string_attribute("type"); + } + _markers[dcp::marker_from_string(*type)] = DCPTime(dcp::raw_convert<DCPTime::Type>(i->content())); } for (auto i: f.node_children("Rating")) { @@ -2230,3 +2235,53 @@ Film::set_territory_type(TerritoryType type) _territory_type = type; } + +void +Film::set_ui_state(string key, string value) +{ + _ui_state[key] = value; + write_ui_state(); +} + + +boost::optional<std::string> +Film::ui_state(string key) const +{ + auto iter = _ui_state.find(key); + if (iter == _ui_state.end()) { + return {}; + } + + return iter->second; +} + + +void +Film::write_ui_state() const +{ + auto doc = make_shared<xmlpp::Document>(); + auto root = doc->create_root_node("UI"); + + for (auto state: _ui_state) { + root->add_child(state.first)->add_child_text(state.second); + } + + try { + doc->write_to_file_formatted(dcp::filesystem::fix_long_path(file(ui_state_file)).string()); + } catch (...) {} +} + + +void +Film::read_ui_state() +{ + try { + cxml::Document xml("UI"); + xml.read_file(dcp::filesystem::fix_long_path(file(ui_state_file))); + for (auto node: xml.node_children()) { + if (!node->is_text()) { + _ui_state[node->name()] = node->content(); + } + } + } catch (...) {} +} |
