mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: initial implementation for to_card_image() function (closes #33)
This commit is contained in:
@@ -441,7 +441,18 @@ Image BuiltInImage::generate(const Options& opt) const {
|
||||
bool BuiltInImage::operator == (const GeneratedImage& that) const {
|
||||
const BuiltInImage* that2 = dynamic_cast<const BuiltInImage*>(&that);
|
||||
return that2 && name == that2->name;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ArbitraryImage
|
||||
|
||||
Image ArbitraryImage::generate(const Options& opt) const {
|
||||
return image;
|
||||
}
|
||||
bool ArbitraryImage::operator == (const GeneratedImage& that) const {
|
||||
const ArbitraryImage* that2 = dynamic_cast<const ArbitraryImage*>(&that);
|
||||
return that2 && image.IsSameAs(that2->image);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolToImage
|
||||
|
||||
|
||||
@@ -346,6 +346,19 @@ public:
|
||||
bool operator == (const GeneratedImage& that) const override;
|
||||
private:
|
||||
String name;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Arbitrary
|
||||
|
||||
class ArbitraryImage : public GeneratedImage {
|
||||
public:
|
||||
inline ArbitraryImage(const Image image)
|
||||
: image(image)
|
||||
{}
|
||||
Image generate(const Options& opt) const override;
|
||||
bool operator == (const GeneratedImage& that) const override;
|
||||
private:
|
||||
Image image;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolToImage
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
#include <data/card.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/symbol.hpp>
|
||||
#include <data/field/symbol.hpp>
|
||||
#include <data/field/symbol.hpp>
|
||||
#include <data/format/formats.hpp>
|
||||
#include <gfx/generated_image.hpp>
|
||||
#include <render/symbol/filter.hpp>
|
||||
|
||||
@@ -27,6 +28,12 @@ SCRIPT_FUNCTION(to_image) {
|
||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||
return input;
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(to_card_image) {
|
||||
SCRIPT_PARAM(Set*, set);
|
||||
SCRIPT_PARAM(CardP, input);
|
||||
return make_intrusive<ArbitraryImage>(export_bitmap(set, input).ConvertToImage());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image functions
|
||||
|
||||
@@ -209,7 +216,8 @@ SCRIPT_FUNCTION(built_in_image) {
|
||||
// ----------------------------------------------------------------------------- : Init
|
||||
|
||||
void init_script_image_functions(Context& ctx) {
|
||||
ctx.setVariable(_("to_image"), script_to_image);
|
||||
ctx.setVariable(_("to_image"), script_to_image);
|
||||
ctx.setVariable(_("to_card_image"), script_to_card_image);
|
||||
ctx.setVariable(_("linear_blend"), script_linear_blend);
|
||||
ctx.setVariable(_("masked_blend"), script_masked_blend);
|
||||
ctx.setVariable(_("combine_blend"), script_combine_blend);
|
||||
|
||||
Reference in New Issue
Block a user