From e46cbe66b2219fff219db90a7449bc4a4a62c2b8 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 22 Jun 2007 23:12:41 +0000 Subject: [PATCH] Cleaned up Set::Styling/Card::Styling by spliting that functionality into a 'DelayedIndexMaps' class; Added 'right' and 'bottom' properties to style as an alternative way of specifying width/height; Added content_width, content_height and content_lines properties that give feedback on text rendering; Always show warnings when showing errors and vice-versa, this prevents script errors from appearing before the reader/parse error that caused them; Finally some preliminairy work on export templates git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@428 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/card.cpp | 50 +++---------------- src/data/card.hpp | 3 +- src/data/export_template.cpp | 4 ++ src/data/export_template.hpp | 15 ++++-- src/data/field.cpp | 52 ++++++++++++++++++-- src/data/field.hpp | 16 ++++++ src/data/field/text.cpp | 20 ++++++++ src/data/field/text.hpp | 5 ++ src/data/set.cpp | 36 +------------- src/data/set.hpp | 3 +- src/gui/control/native_look_editor.hpp | 15 ++++++ src/gui/html_export_window.cpp | 32 +++++++++++- src/gui/html_export_window.hpp | 3 ++ src/gui/new_window.cpp | 10 ++-- src/mse.vcproj | 7 ++- src/render/card/viewer.cpp | 16 ++++-- src/render/text/viewer.cpp | 17 ++++++- src/render/text/viewer.hpp | 4 +- src/render/value/text.cpp | 7 ++- src/render/value/text.hpp | 1 + src/render/value/viewer.hpp | 5 +- src/script/dependency.hpp | 3 ++ src/script/functions/basic.cpp | 12 +++++ src/script/script_manager.cpp | 5 ++ src/script/scriptable.hpp | 12 +++-- src/script/to_value.hpp | 2 +- src/util/delayed_index_maps.hpp | 68 ++++++++++++++++++++++++++ src/util/error.cpp | 43 ++++++++++------ src/util/index_map.hpp | 31 ++++++++++++ src/util/io/get_member.hpp | 4 ++ src/util/io/reader.hpp | 10 ++-- src/util/io/writer.hpp | 10 ++-- src/util/window_id.hpp | 1 + 33 files changed, 384 insertions(+), 138 deletions(-) create mode 100644 src/util/delayed_index_maps.hpp diff --git a/src/data/card.cpp b/src/data/card.cpp index 26aebb9d..331fb717 100644 --- a/src/data/card.cpp +++ b/src/data/card.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include DECLARE_TYPEOF_COLLECTION(FieldP); DECLARE_TYPEOF_NO_REV(IndexMap); @@ -45,6 +45,10 @@ String Card::identification() const { } } +IndexMap& Card::extraDataFor(const StyleSheet& stylesheet) { + return extra_data.get(stylesheet.name(), stylesheet.extra_card_fields); +} + void mark_dependency_member(const Card& card, const String& name, const Dependency& dep) { mark_dependency_member(card.data, name, dep); } @@ -52,48 +56,6 @@ void mark_dependency_member(const Card& card, const String& name, const Dependen IMPLEMENT_REFLECTION(Card) { REFLECT(stylesheet); REFLECT(notes); - REFLECT_NO_SCRIPT(extra_data); + REFLECT_NO_SCRIPT(extra_data); // don't allow scripts to depend on style specific data REFLECT_NAMELESS(data); } - -// ----------------------------------------------------------------------------- : Styling - -// TODO : this is practically the same as Set::Styling, maybe somehow abstract it - -// Extra card data, for a specific stylesheet -/* The data is not read immediatly, because we do not know the stylesheet */ -class Card::Styling : public IntrusivePtrBase { - public: - /// The values on the extra card fields of the card. - /** The indices should correspond to the extra_card_fields in the StyleSheet */ - IndexMap extra_data; - /// Unparsed extra_data - String unread_data; - DECLARE_REFLECTION(); -}; - -IndexMap& Card::extraDataFor(const StyleSheet& stylesheet) { - StylingP& styling = extra_data[stylesheet.name()]; - if (!styling) { - styling = new_intrusive(); - styling->extra_data.init(stylesheet.extra_card_fields); - } else if (!styling->unread_data.empty() || (styling->extra_data.empty()) && !stylesheet.extra_card_fields.empty()) { - // we delayed the reading of the data, read it now - styling->extra_data.init(stylesheet.extra_card_fields); - Reader reader(new_shared1(styling->unread_data), _("extra card values for ") + stylesheet.stylesheetName()); - reader.handle_greedy(styling->extra_data); - styling->unread_data.clear(); - } - return styling->extra_data; -} - -// custom reflection : read into unread_data -template <> void Reader::handle(Card::Styling& s) { - handle(s.unread_data); -} -template <> void Writer::handle(const Card::Styling& s) { - handle(s.extra_data); -} -// for the love of god, don't depend on styling -template <> void GetMember::handle(const Card::Styling& s) {} -template <> void GetDefaultMember::handle(const Card::Styling& s) {} diff --git a/src/data/card.hpp b/src/data/card.hpp index bb1bc305..6dd207fe 100644 --- a/src/data/card.hpp +++ b/src/data/card.hpp @@ -41,8 +41,7 @@ class Card : public IntrusivePtrVirtualBase { StyleSheetP stylesheet; /// Extra values for specitic stylesheets, indexed by stylesheet name - DECLARE_POINTER_TYPE(Styling); - map extra_data; + DelayedIndexMaps extra_data; /// Styling information for a particular stylesheet IndexMap& extraDataFor(const StyleSheet& stylesheet) ; diff --git a/src/data/export_template.cpp b/src/data/export_template.cpp index 2b811cba..ff771997 100644 --- a/src/data/export_template.cpp +++ b/src/data/export_template.cpp @@ -7,9 +7,13 @@ // ----------------------------------------------------------------------------- : Includes #include +#include +#include // ----------------------------------------------------------------------------- : Export template, basics +ExportTemplate::ExportTemplate() {} + String ExportTemplate::typeNameStatic() { return _("export-template"); } String ExportTemplate::typeName() const { return _("export-template"); } diff --git a/src/data/export_template.hpp b/src/data/export_template.hpp index 04792fe1..440a8150 100644 --- a/src/data/export_template.hpp +++ b/src/data/export_template.hpp @@ -13,16 +13,23 @@ #include #include