implemented resampled text ("high quality")

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@87 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-22 20:23:28 +00:00
parent 11a0276232
commit e2544e9d53
22 changed files with 349 additions and 127 deletions
+18 -10
View File
@@ -21,14 +21,20 @@ StatsDimension::StatsDimension(const Field& field)
, description (field.description)
, icon_filename(field.icon_filename)
{
// init script!
// initialize script, card.{field_name}
Script& s = script.getScript();
s.addInstruction(I_GET_VAR, string_to_variable(_("card")));
s.addInstruction(I_MEMBER_C, field.name);
s.addInstruction(I_RET);
}
IMPLEMENT_REFLECTION(StatsDimension) {
REFLECT(name);
REFLECT(description);
REFLECT_N("icon", icon_filename);
REFLECT(script);
if (!automatic) {
REFLECT(name);
REFLECT(description);
REFLECT_N("icon", icon_filename);
REFLECT(script);
}
}
// ----------------------------------------------------------------------------- : Statistics category
@@ -53,9 +59,11 @@ IMPLEMENT_REFLECTION_ENUM(GraphType) {
}
IMPLEMENT_REFLECTION(StatsCategory) {
REFLECT(name);
REFLECT(description);
REFLECT_N("icon", icon_filename);
REFLECT(type);
REFLECT(dimensions);
if (!automatic) {
REFLECT(name);
REFLECT(description);
REFLECT_N("icon", icon_filename);
REFLECT(type);
REFLECT(dimensions);
}
}
+8 -8
View File
@@ -210,19 +210,19 @@ void SymbolFont::drawWithText(RotatedDC& dc, Context& ctx, const RealRect& rect,
if (def) {
Bitmap bmp = def->getBitmap(ctx, *this, dc.trS(font_size));
// align symbol
sym_rect.size = dc.trInvS(RealSize(bmp.GetWidth(), bmp.GetHeight()));
sym_rect.position = align_in_rect(align, sym_rect.size, rect);
sym_rect.size() = dc.trInvS(RealSize(bmp.GetWidth(), bmp.GetHeight()));
sym_rect.position() = align_in_rect(align, sym_rect.size(), rect);
// draw
dc.DrawBitmap(bmp, sym_rect.position);
dc.DrawBitmap(bmp, sym_rect.position());
}
// 2. draw text
if (!text_font) return;
// subtract margins from size
sym_rect.position.x += text_margin_left;
sym_rect.position.y += text_margin_top;
sym_rect.size.width -= text_margin_left + text_margin_right;
sym_rect.size.height -= text_margin_top + text_margin_bottom;
sym_rect.x += text_margin_left;
sym_rect.y += text_margin_top;
sym_rect.width -= text_margin_left + text_margin_right;
sym_rect.height -= text_margin_top + text_margin_bottom;
// setup text, shrink it
double size = text_font->size; // TODO : incorporate shrink factor?
RealSize ts;
@@ -230,7 +230,7 @@ void SymbolFont::drawWithText(RotatedDC& dc, Context& ctx, const RealRect& rect,
if (size <= 0) return; // text too small
dc.SetFont(text_font->font, size);
ts = dc.GetTextExtent(text);
if (ts.width <= sym_rect.size.width && ts.height <= sym_rect.size.height) {
if (ts.width <= sym_rect.width && ts.height <= sym_rect.height) {
break; // text fits
} else {
// text doesn't fit