mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
implemented import_image function
This commit is contained in:
@@ -14,9 +14,11 @@
|
||||
#include <data/field/choice.hpp>
|
||||
#include <data/field/package_choice.hpp>
|
||||
#include <data/field/color.hpp>
|
||||
#include <data/field/image.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : new_card
|
||||
|
||||
@@ -45,6 +47,9 @@ SCRIPT_FUNCTION(new_card) {
|
||||
pvalue->package_name = v->toString();
|
||||
} else if (ColorValue* cvalue = dynamic_cast<ColorValue*>(value)) {
|
||||
cvalue->value = v->toColor();
|
||||
} else if (ImageValue* ivalue = dynamic_cast<ImageValue*>(value)) {
|
||||
wxFileName fname( static_cast<ExternalImage*>(v.get())->toString() );
|
||||
ivalue->filename = LocalFileName::fromReadString( fname.GetName(), "");
|
||||
} else {
|
||||
throw ScriptError(format_string(_("Can not set value '%s', it is not of the right type"),name));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ SCRIPT_FUNCTION(to_card_image) {
|
||||
return make_intrusive<ArbitraryImage>(export_bitmap(set, input, (zoom / 100), deg_to_rad(angle)).ConvertToImage());
|
||||
}
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(import_image) {
|
||||
SCRIPT_PARAM(String, path);
|
||||
return make_intrusive<ExternalImage>(path);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image functions
|
||||
|
||||
@@ -261,4 +266,5 @@ void init_script_image_functions(Context& ctx) {
|
||||
ctx.setVariable(_("drop_shadow"), script_drop_shadow);
|
||||
ctx.setVariable(_("symbol_variation"), script_symbol_variation);
|
||||
ctx.setVariable(_("built_in_image"), script_built_in_image);
|
||||
ctx.setVariable(_("import_image"), script_import_image);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user