feat: add card regions to declare image slice regions for DFCs

This commit is contained in:
Brendan Hagan
2022-08-13 22:43:42 -04:00
parent 05855b812a
commit 6435055d53
15 changed files with 92 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#include <util/prec.hpp>
#include <data/card_region.hpp>
CardRegion::CardRegion()
: name("")
, x(0.0)
, y(0.0)
, width(0)
, height(0)
{}
CardRegion::~CardRegion() {}
IMPLEMENT_REFLECTION(CardRegion) {
REFLECT(name);
REFLECT(x);
REFLECT(y);
REFLECT(width);
REFLECT(height);
}
+34
View File
@@ -0,0 +1,34 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#pragma once
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE(CardRegion);
class CardRegion : public IntrusivePtrBase<CardRegion> {
public:
CardRegion();
virtual ~CardRegion();
String name;
double x, y;
int width, height;
private:
DECLARE_REFLECTION();
};
inline String type_name(const CardRegion&) {
return _TYPE_("card region");
}
inline String type_name(const vector<CardRegionP>&) {
return _TYPE_("card regions");
}
+2 -1
View File
@@ -97,7 +97,8 @@ IMPLEMENT_REFLECTION(StyleSheet) {
REFLECT(card_width);
REFLECT(card_height);
REFLECT(card_dpi);
REFLECT(card_background);
REFLECT(card_background);
REFLECT(card_regions);
REFLECT(init_script);
// styling
REFLECT(styling_fields);
+9 -3
View File
@@ -11,12 +11,17 @@
#include <util/prec.hpp>
#include <util/io/package.hpp>
#include <util/real_point.hpp>
#include <script/scriptable.hpp>
#include <script/scriptable.hpp>
// This isn't strictly needed for this file,
// but CardRegion needs to be referenced from _somewhere_ in the codebase for compilation reasons.
// Eventually if somewhere else is using the type then this can be removed.
#include <data/card_region.hpp>
DECLARE_POINTER_TYPE(Game);
DECLARE_POINTER_TYPE(StyleSheet);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(CardRegion);
// ----------------------------------------------------------------------------- : StyleSheet
@@ -33,7 +38,8 @@ public:
double card_width; ///< The width of a card in pixels
double card_height; ///< The height of a card in pixels
double card_dpi; ///< The resolution of a card in dots per inch
Color card_background; ///< The background color of cards
Color card_background; ///< The background color of cards
vector<CardRegionP> card_regions;
/// The styling for card fields
/** The indices should correspond to the card_fields in the Game */
IndexMap<FieldP, StyleP> card_style;