mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added 'position hint' to packages, used to specify the order of the packages in a package list;
Added 'pack type', intended for playtesting (random boosters/starters); Added 'default(_image)' property to ImageStyle, and added the frame fillers for magic; Added blurring and bold printing (rather hacky) to the text rendering functions (used for "double click to add image" text); Added 'symmetric overlay' combine mode, which will look really nice for hybrids; Moved the watermark choices from the game to an include file in magic-watermarks; Working on a replacement for the image scripting system that plays nicer with the rest of the code. In particular, it will be possible to compare generated images quickly, so they can be updated continuously. This is a work in progress, currently there are two versions of everything. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@327 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+42
-10
@@ -32,11 +32,25 @@ void ImageValueViewer::draw(RotatedDC& dc) {
|
||||
handle_error(e, false, false); // don't handle now, we are in onPaint
|
||||
}
|
||||
}
|
||||
// if there is no image, generate a placeholder, only if there is enough room for it
|
||||
if (!bitmap.Ok() && style().width > 40) {
|
||||
bitmap = imagePlaceholder(dc, (int)dc.trS(style().width), (int)dc.trS(style().height), viewer.drawEditing());
|
||||
// if there is no image, generate a placeholder
|
||||
if (!bitmap.Ok()) {
|
||||
UInt w = (UInt)dc.trS(style().width), h = (UInt)dc.trS(style().height);
|
||||
loadMask(dc);
|
||||
if (alpha_mask) alpha_mask->setAlpha(bitmap);
|
||||
if (style().default_image.isReady()) {
|
||||
// we have a script to use for the default image
|
||||
Image img = style().default_image.generate(GeneratedImage::Options(w, h, viewer.stylesheet.get(), &getSet()));
|
||||
if (viewer.drawEditing()) {
|
||||
bitmap = imagePlaceholder(dc, w, h, img, viewer.drawEditing());
|
||||
if (alpha_mask) alpha_mask->setAlpha(bitmap);
|
||||
} else {
|
||||
if (alpha_mask) alpha_mask->setAlpha(img);
|
||||
bitmap = Bitmap(img);
|
||||
}
|
||||
} else if (style().width > 40) {
|
||||
// still not okay, use a checkered image, but only if there is enough room for it
|
||||
bitmap = imagePlaceholder(dc, w, h, wxNullImage, viewer.drawEditing());
|
||||
if (alpha_mask) alpha_mask->setAlpha(bitmap);
|
||||
}
|
||||
}
|
||||
// draw image, if any
|
||||
if (bitmap.Ok()) {
|
||||
@@ -65,7 +79,7 @@ void ImageValueViewer::onValueChange() {
|
||||
|
||||
void ImageValueViewer::onStyleChange() {
|
||||
bitmap = Bitmap();
|
||||
alpha_mask = AlphaMaskP();
|
||||
alpha_mask = AlphaMaskP(); // TODO: only reload whatever has changed
|
||||
}
|
||||
|
||||
void ImageValueViewer::loadMask(const Rotation& rot) const {
|
||||
@@ -82,15 +96,29 @@ void ImageValueViewer::loadMask(const Rotation& rot) const {
|
||||
}
|
||||
}
|
||||
|
||||
Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, bool editing) {
|
||||
// is an image very light?
|
||||
bool very_light(const Image& image) {
|
||||
int w = image.GetWidth(), h = image.GetHeight();
|
||||
if (w*h<1) return false;
|
||||
Byte* data = image.GetData();
|
||||
int middle = w / 2 + (h*w) / 2;
|
||||
int total = (int)data[3 * middle] + (int)data[3 * middle + 1] + (int)data[3 * middle + 2];
|
||||
return total >= 210 * 3;
|
||||
}
|
||||
|
||||
Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& background, bool editing) {
|
||||
// Bitmap and memory dc
|
||||
Bitmap bmp(w, h, 24);
|
||||
wxMemoryDC mdc;
|
||||
mdc.SelectObject(bmp);
|
||||
RealRect rect(0,0,w,h);
|
||||
RotatedDC dc(mdc, 0, rect, 1.0, QUALITY_AA);
|
||||
// Draw checker background
|
||||
draw_checker(dc, rect);
|
||||
// Draw (checker) background
|
||||
if (background.Ok()) {
|
||||
dc.DrawImage(background, RealPoint(0,0));
|
||||
} else {
|
||||
draw_checker(dc, rect);
|
||||
}
|
||||
// Draw text
|
||||
if (editing) {
|
||||
// only when in editor mode
|
||||
@@ -99,8 +127,12 @@ Bitmap ImageValueViewer::imagePlaceholder(const Rotation& rot, UInt w, UInt h, b
|
||||
RealSize rs = dc.GetTextExtent(_("double click to load image"));
|
||||
if (rs.width <= w - 10 && rs.height < h - 10) {
|
||||
// text fits
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
dc.DrawText(_("double click to load image"), align_in_rect(ALIGN_MIDDLE_CENTER, rs, rect));
|
||||
RealPoint pos = align_in_rect(ALIGN_MIDDLE_CENTER, rs, rect);
|
||||
bool black_on_white = !background.Ok() || very_light(background);
|
||||
dc.SetTextForeground(black_on_white ? *wxWHITE : *wxBLACK);
|
||||
dc.DrawText(_("double click to load image"), pos, 2, 4); // blurred
|
||||
dc.SetTextForeground(black_on_white ? *wxBLACK : *wxWHITE);
|
||||
dc.DrawText(_("double click to load image"), pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ImageValueViewer : public ValueViewer {
|
||||
void loadMask(const Rotation& rot) const;
|
||||
|
||||
/// Generate a placeholder image
|
||||
static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, bool editing);
|
||||
static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& background, bool editing);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <gui/util.hpp> // draw_checker
|
||||
#include <util/error.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolStyle::VariationP);
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolVariationP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolValueViewer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user