mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Added GraphControl; FilteredCardList; ValueEditor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@74 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -65,6 +65,7 @@ class Set : public Packaged {
|
||||
void updateFor(const CardP& card);
|
||||
|
||||
/// Stylesheet to use for a particular card
|
||||
/** card may be null */
|
||||
StyleSheetP stylesheetFor(const CardP& card);
|
||||
|
||||
/// Styling information for a particular stylesheet
|
||||
|
||||
@@ -51,7 +51,7 @@ class StyleSheet : public Packaged {
|
||||
static StyleSheetP byGameAndName(const Game& game, const String& name);
|
||||
/// name of the package without the game name
|
||||
String stylesheetName() const;
|
||||
|
||||
|
||||
static String typeNameStatic();
|
||||
virtual String typeName() const;
|
||||
virtual String fullName() const;
|
||||
|
||||
@@ -7,8 +7,96 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/symbol_font.hpp>
|
||||
#include <util/dynamic_arg.hpp>
|
||||
#include <util/io/package_manager.hpp>
|
||||
#include <script/image.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFont
|
||||
|
||||
// SymbolFont that is used for SymbolInFonts constructed with the default constructor
|
||||
DECLARE_DYNAMIC_ARG(SymbolFont*, symbol_font_for_reading);
|
||||
IMPLEMENT_DYNAMIC_ARG(SymbolFont*, symbol_font_for_reading, nullptr);
|
||||
|
||||
SymbolFont::SymbolFont()
|
||||
: img_size(12), min_size(1)
|
||||
, spacing(1,1)
|
||||
, scale_text(false)
|
||||
, text_margin_left(0), text_margin_right(0)
|
||||
, text_margin_top(0), text_margin_bottom(0)
|
||||
, text_alignment(ALIGN_MIDDLE_CENTER)
|
||||
, merge_numbers(false)
|
||||
{}
|
||||
|
||||
String SymbolFont::typeNameStatic() { return _("symbol-font"); }
|
||||
String SymbolFont::typeName() const { return _("symbol-font"); }
|
||||
|
||||
SymbolFontP SymbolFont::byName(const String& name) {
|
||||
return packages.open<SymbolFont>(name + _(".mse-symbol-font"));
|
||||
}
|
||||
|
||||
void SymbolFont::split(const String& text, SplitSymbols& out) {
|
||||
for (size_t pos = 0 ; pos < text.size() ; ) {
|
||||
// read a single symbol
|
||||
pos = pos + 1; // TODO
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolFont) {
|
||||
tag.addAlias(300, _("text align"), _("text alignment"));
|
||||
|
||||
REFLECT_N("image font size", img_size);
|
||||
REFLECT_N("scale down to", min_size);
|
||||
REFLECT_N("horizontal space", spacing.width);
|
||||
REFLECT_N("vertical space", spacing.height);
|
||||
WITH_DYNAMIC_ARG(symbol_font_for_reading, this);
|
||||
REFLECT(symbols);
|
||||
REFLECT(text_font);
|
||||
REFLECT(scale_text);
|
||||
REFLECT(merge_numbers);
|
||||
REFLECT(text_margin_left);
|
||||
REFLECT(text_margin_right);
|
||||
REFLECT(text_margin_top);
|
||||
REFLECT(text_margin_bottom);
|
||||
REFLECT(text_alignment);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFont::Symbol
|
||||
|
||||
/// A symbol in a symbol font
|
||||
class SymbolInFont {
|
||||
public:
|
||||
SymbolInFont();
|
||||
|
||||
/// Get a shrunk, zoomed bitmap
|
||||
Bitmap getBitmap(Context& ctx, double size);
|
||||
|
||||
/// Size of a (zoomed) bitmap
|
||||
/** This is the size of the resulting image, it does NOT convert back to internal coordinates */
|
||||
RealSize size(Context& ctx, double size);
|
||||
|
||||
private:
|
||||
String code; ///< Code for this symbol
|
||||
ScriptableImage image; ///< The image for this symbol
|
||||
UInt img_size; ///< Font size used by the image
|
||||
wxSize actual_size; ///< Actual image size, only known after loading the image
|
||||
/// Cached bitmaps for different sizes
|
||||
map<double, Bitmap> bitmaps;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
SymbolInFont::SymbolInFont()
|
||||
{
|
||||
assert(symbol_font_for_reading());
|
||||
img_size = symbol_font_for_reading()->img_size;
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolInFont) {
|
||||
REFLECT(code);
|
||||
REFLECT(image);
|
||||
REFLECT_N("image font size", img_size);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFontRef
|
||||
|
||||
SymbolFontRef::SymbolFontRef()
|
||||
@@ -17,6 +105,11 @@ SymbolFontRef::SymbolFontRef()
|
||||
, alignment(ALIGN_MIDDLE_CENTER)
|
||||
{}
|
||||
|
||||
bool SymbolFontRef::valid() const {
|
||||
return !!font; //TODO: does this make sense?
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolFontRef) {
|
||||
REFLECT(name);
|
||||
REFLECT(size);
|
||||
|
||||
@@ -17,32 +17,51 @@
|
||||
DECLARE_POINTER_TYPE(Font);
|
||||
DECLARE_POINTER_TYPE(SymbolFont);
|
||||
DECLARE_POINTER_TYPE(SymbolInFont);
|
||||
class RotatedDC;
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFont
|
||||
|
||||
// A font that is drawn using images
|
||||
class SymbolFont : Packaged {
|
||||
class SymbolFont : public Packaged {
|
||||
public:
|
||||
SymbolFont();
|
||||
|
||||
/// Loads the symbol font with a given name, for example "magic-mana-large"
|
||||
static SymbolFontP byName(const String& name);
|
||||
|
||||
class DrawableSymbol {
|
||||
public:
|
||||
// TODO: anything?
|
||||
private:
|
||||
String text; ///< Original text
|
||||
SymbolInFont* symbol; ///< Symbol to draw, if nullptr, use the default symbol and draw the text
|
||||
};
|
||||
typedef vector<DrawableSymbol> SplitSymbols;
|
||||
|
||||
/// Split a string into separate symbols for drawing and for determining their size
|
||||
void split(const String& text, SplitSymbols& out);
|
||||
|
||||
/// Draw a piece of text prepared using split
|
||||
void draw(RotatedDC& dc, Context& ctx, const RealRect& rect, double font_size, const Alignment& align, const SplitSymbols& text);
|
||||
|
||||
static String typeNameStatic();
|
||||
virtual String typeName() const;
|
||||
|
||||
private:
|
||||
UInt imgSize; ///< Font size that the images use
|
||||
UInt minSize; ///< Minimum font size
|
||||
UInt img_size; ///< Font size that the images use
|
||||
UInt min_size; ///< Minimum font size
|
||||
RealSize spacing; ///< Spacing between sybmols (for the default font size)
|
||||
// writing text
|
||||
bool scale_text; ///< Should text be scaled down to fit in a symbol?
|
||||
FontP text_font; ///< Font to use for missing symbols
|
||||
double text_margin_left;
|
||||
double text_margin_right;
|
||||
double text_margin_rop;
|
||||
double text_margin_top;
|
||||
double text_margin_bottom;
|
||||
Alignment text_align;
|
||||
Alignment text_alignment;
|
||||
bool merge_numbers; ///< Merge numbers? e.g. "11" is a single symbol ('1' must not exist as a symbol)
|
||||
|
||||
public:
|
||||
class Symbol;
|
||||
private:
|
||||
friend class SymbolInFont;
|
||||
vector<SymbolInFontP> symbols; ///< The individual symbols
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
@@ -60,7 +79,7 @@ class SymbolFontRef {
|
||||
void initDependencies(Context&, Dependency& dep);
|
||||
|
||||
/// Is a font loaded?
|
||||
bool valid();
|
||||
bool valid() const;
|
||||
|
||||
private:
|
||||
Scriptable<String> name; ///< Font package name, can be changed with script
|
||||
|
||||
Reference in New Issue
Block a user