diff --git a/src/data/stylesheet.cpp b/src/data/stylesheet.cpp index 9bbc625f..9151c1ca 100644 --- a/src/data/stylesheet.cpp +++ b/src/data/stylesheet.cpp @@ -45,6 +45,19 @@ InputStreamP StyleSheet::openIconFile() { } } +StyleP StyleSheet::styleFor(const FieldP& field) { + if (card_style.containsKey(field)) { + return card_style[field]; + } else if (set_info_style.containsKey(field)) { + return set_info_style[field]; + } else if (styling_style.containsKey(field)) { + return styling_style[field]; + } else { + throw InternalError(_("Can not find styling for field '")+field->name+_("'in stylesheet")); + } +} + + IMPLEMENT_REFLECTION(StyleSheet) { // < 0.3.0 didn't use card_ prefix tag.addAlias(300, _("width"), _("card width")); diff --git a/src/data/stylesheet.hpp b/src/data/stylesheet.hpp index 2c1a6705..9b25047b 100644 --- a/src/data/stylesheet.hpp +++ b/src/data/stylesheet.hpp @@ -50,6 +50,9 @@ class StyleSheet : public Packaged { inline RealRect getCardRect() const { return RealRect(0, 0, card_width, card_height); } + /// Return the style for a given field, it is not specified what type of field this is. + StyleP styleFor(const FieldP& field); + /// Load a StyleSheet, given a Game and the name of the StyleSheet static StyleSheetP byGameAndName(const Game& game, const String& name); /// name of the package without the game name diff --git a/src/data/symbol.cpp b/src/data/symbol.cpp index b6bd35d7..8cb24a53 100644 --- a/src/data/symbol.cpp +++ b/src/data/symbol.cpp @@ -163,6 +163,26 @@ IMPLEMENT_REFLECTION(Symbol) { REFLECT(parts); } +// ----------------------------------------------------------------------------- : Default symbol + +// A default symbol part, a square, moved by d +SymbolPartP default_symbol_part(double d) { + SymbolPartP part = new_shared(); + part->points.push_back(new_shared2(d + .2, d + .2)); + part->points.push_back(new_shared2(d + .2, d + .8)); + part->points.push_back(new_shared2(d + .8, d + .8)); + part->points.push_back(new_shared2(d + .8, d + .2)); + part->name = _("Square"); + return part; +} + +// A default symbol, a square +SymbolP default_symbol() { + SymbolP symbol = new_shared(); + symbol->parts.push_back(default_symbol_part(0)); + return symbol; +} + // ----------------------------------------------------------------------------- : SymbolView SymbolView::SymbolView() {} diff --git a/src/data/symbol.hpp b/src/data/symbol.hpp index c726bede..8c58ab47 100644 --- a/src/data/symbol.hpp +++ b/src/data/symbol.hpp @@ -162,6 +162,8 @@ class Symbol { DECLARE_REFLECTION(); }; +/// A default symbol: a square +SymbolP default_symbol(); // ----------------------------------------------------------------------------- : SymbolView diff --git a/src/gui/symbol/window.cpp b/src/gui/symbol/window.cpp index dd7c513d..88b44b2a 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -19,26 +19,6 @@ #include #include -// ------------------------------------------------------------------------------------------------ : Default symbol - -// A default symbol part, a square, moved by d -SymbolPartP defaultSymbolPart(double d) { - SymbolPartP part = new_shared(); - part->points.push_back(new_shared2(d + .2, d + .2)); - part->points.push_back(new_shared2(d + .2, d + .8)); - part->points.push_back(new_shared2(d + .8, d + .8)); - part->points.push_back(new_shared2(d + .8, d + .2)); - part->name = _("Square"); - return part; -} - -// A default symbol, a square -SymbolP default_symbol() { - SymbolP symbol = new_shared(); - symbol->parts.push_back(defaultSymbolPart(0)); - return symbol; -} - // ----------------------------------------------------------------------------- : Constructor SymbolWindow::SymbolWindow(Window* parent) { diff --git a/src/script/image.cpp b/src/script/image.cpp index 803af797..7630cf84 100644 --- a/src/script/image.cpp +++ b/src/script/image.cpp @@ -10,8 +10,16 @@ #include