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:
@@ -17,7 +17,11 @@
|
||||
#include <render/symbol/filter.hpp>
|
||||
#include <gui/util.hpp> // load_resource_image
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolStyle::VariationP);
|
||||
#include <gfx/generated_image.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolVariationP);
|
||||
|
||||
bool parse_enum(const String&, ImageCombine& out);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Macros
|
||||
|
||||
@@ -32,6 +36,84 @@ template <> inline ScriptImageP from_script<ScriptImageP>(const ScriptValueP& va
|
||||
|
||||
#define SCRIPT_IMAGE_PARAM_UP_TO_DATE(name) script_image_up_to_date(ctx.getVariable(_(#name)))
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility
|
||||
|
||||
// TODO : use this system
|
||||
|
||||
template <> inline GeneratedImageP from_script<GeneratedImageP>(const ScriptValueP& value) {
|
||||
return image_from_script(value);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image functions
|
||||
|
||||
SCRIPT_FUNCTION(linear_blend2) {
|
||||
SCRIPT_PARAM(GeneratedImageP, image1);
|
||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
|
||||
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
|
||||
return new_intrusive6<LinearBlendImage>(image1, image2, x1,y1, x2,y2);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(masked_blend2) {
|
||||
SCRIPT_PARAM(GeneratedImageP, light);
|
||||
SCRIPT_PARAM(GeneratedImageP, dark);
|
||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||
return new_intrusive3<MaskedBlendImage>(light, dark, mask);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(combine_blend2) {
|
||||
SCRIPT_PARAM(String, combine);
|
||||
SCRIPT_PARAM(GeneratedImageP, image1);
|
||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||
ImageCombine image_combine;
|
||||
if (!parse_enum(combine, image_combine)) {
|
||||
throw ScriptError(_("Not a valid combine mode: '") + combine + _("'"));
|
||||
}
|
||||
return new_intrusive3<CombineBlendImage>(image1, image2, image_combine);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(set_mask2) {
|
||||
SCRIPT_PARAM(GeneratedImageP, image);
|
||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||
return new_intrusive2<SetMaskImage>(image, mask);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(set_combine2) {
|
||||
SCRIPT_PARAM(String, combine);
|
||||
SCRIPT_PARAM(GeneratedImageP, input);
|
||||
ImageCombine image_combine;
|
||||
if (!parse_enum(combine, image_combine)) {
|
||||
throw ScriptError(_("Not a valid combine mode: '") + combine + _("'"));
|
||||
}
|
||||
return new_intrusive2<SetCombineImage>(input, image_combine);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(symbol_variation2) {
|
||||
// find symbol
|
||||
SCRIPT_PARAM(ValueP, symbol);
|
||||
SymbolValueP value = dynamic_pointer_cast<SymbolValue>(symbol);
|
||||
SCRIPT_PARAM(String, variation);
|
||||
// find style
|
||||
SCRIPT_PARAM(Set*, set);
|
||||
SCRIPT_OPTIONAL_PARAM_(CardP, card);
|
||||
SymbolStyleP style = dynamic_pointer_cast<SymbolStyle>(set->stylesheetFor(card)->styleFor(value->fieldP));
|
||||
if (!style) throw InternalError(_("Symbol value has a style of the wrong type"));
|
||||
// find variation
|
||||
FOR_EACH(v, style->variations) {
|
||||
if (v->name == variation) {
|
||||
// found it
|
||||
return new_intrusive3<SymbolToImage>(value->filename, value->last_update, v);
|
||||
}
|
||||
}
|
||||
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(built_in_image2) {
|
||||
SCRIPT_PARAM(String, input);
|
||||
return new_intrusive1<BuiltInImage>(input);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image functions
|
||||
|
||||
SCRIPT_IMAGE_FUNCTION(linear_blend) {
|
||||
@@ -62,6 +144,22 @@ SCRIPT_IMAGE_FUNCTION_UP_TO_DATE
|
||||
);
|
||||
}
|
||||
|
||||
SCRIPT_IMAGE_FUNCTION(combine_blend) {
|
||||
SCRIPT_PARAM(String, combine);
|
||||
SCRIPT_PARAM(ScriptImageP, image1);
|
||||
SCRIPT_PARAM(ScriptImageP, image2);
|
||||
if (!parse_enum(combine, image1->combine)) {
|
||||
throw ScriptError(_("Not a valid combine mode: '") + combine + _("'"));
|
||||
}
|
||||
combine_image(image1->image, image2->image, image1->combine);
|
||||
return image1;
|
||||
SCRIPT_IMAGE_FUNCTION_UP_TO_DATE
|
||||
SCRIPT_RETURN(
|
||||
SCRIPT_IMAGE_PARAM_UP_TO_DATE(image1) &&
|
||||
SCRIPT_IMAGE_PARAM_UP_TO_DATE(image2)
|
||||
);
|
||||
}
|
||||
|
||||
SCRIPT_IMAGE_FUNCTION(set_mask) {
|
||||
SCRIPT_PARAM(ScriptImageP, image);
|
||||
SCRIPT_PARAM(ScriptImageP, mask);
|
||||
@@ -74,8 +172,6 @@ SCRIPT_IMAGE_FUNCTION_UP_TO_DATE
|
||||
);
|
||||
}
|
||||
|
||||
bool parse_enum(const String&, ImageCombine& out);
|
||||
|
||||
SCRIPT_IMAGE_FUNCTION(set_combine) {
|
||||
SCRIPT_PARAM(String, combine);
|
||||
SCRIPT_PARAM(ScriptImageP, input);
|
||||
@@ -136,6 +232,7 @@ SCRIPT_IMAGE_FUNCTION_UP_TO_DATE
|
||||
void init_script_image_functions(Context& ctx) {
|
||||
ctx.setVariable(_("linear blend"), script_linear_blend);
|
||||
ctx.setVariable(_("masked blend"), script_masked_blend);
|
||||
ctx.setVariable(_("combine blend"), script_combine_blend);
|
||||
ctx.setVariable(_("set mask"), script_set_mask);
|
||||
ctx.setVariable(_("set combine"), script_set_combine);
|
||||
ctx.setVariable(_("symbol variation"), script_symbol_variation);
|
||||
|
||||
Reference in New Issue
Block a user