mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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
This commit is contained in:
+6
-44
@@ -12,7 +12,7 @@
|
||||
#include <data/field.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <wx/sstream.h>
|
||||
#include <util/delayed_index_maps.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(FieldP);
|
||||
DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
|
||||
@@ -45,6 +45,10 @@ String Card::identification() const {
|
||||
}
|
||||
}
|
||||
|
||||
IndexMap<FieldP, ValueP>& 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<Card::Styling> {
|
||||
public:
|
||||
/// The values on the extra card fields of the card.
|
||||
/** The indices should correspond to the extra_card_fields in the StyleSheet */
|
||||
IndexMap<FieldP, ValueP> extra_data;
|
||||
/// Unparsed extra_data
|
||||
String unread_data;
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
IndexMap<FieldP, ValueP>& Card::extraDataFor(const StyleSheet& stylesheet) {
|
||||
StylingP& styling = extra_data[stylesheet.name()];
|
||||
if (!styling) {
|
||||
styling = new_intrusive<Styling>();
|
||||
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<wxStringInputStream>(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) {}
|
||||
|
||||
Reference in New Issue
Block a user