mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
add set_metadata, get_metadata script functions
This commit is contained in:
@@ -10,7 +10,7 @@ To see the required syntax, use an output of the [[fun:to_json]] function.
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:string]] JSON string to convert to an MSE script value.
|
| @input@ [[type:string]] JSON string to convert to an MSE script value.
|
||||||
| @set@ [[type:set]] The active set. This can be omited since "set" is a predefined variable.
|
| @set@ [[type:set]] The active set. This can be omitted since "set" is a predefined variable.
|
||||||
|
|
||||||
--Examples--
|
--Examples--
|
||||||
> add_card_to_set(from_json("\{\"mse_object_type\":\"card\", \"data\":\{\"name\":\"Ajani\", \"rarity\":\"mythic rare\"\}\}"))
|
> add_card_to_set(from_json("\{\"mse_object_type\":\"card\", \"data\":\{\"name\":\"Ajani\", \"rarity\":\"mythic rare\"\}\}"))
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ Returns nil if no link of type "Back Face", or no card was found.
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:card]] The card whose links we'll inspect.
|
| @input@ [[type:card]] The card whose links we'll inspect.
|
||||||
| @set@ [[type:set]] The set in which to look. This can be omited since 'set' is a predefined variable.
|
| @set@ [[type:set]] The set in which to look. This can be omitted since 'set' is a predefined variable.
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ Returns and array whose first element is the zoom percentage, the second is the
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:card]] The card you want to retrieve the export settings from.
|
| @input@ [[type:card]] The card you want to retrieve the export settings from.
|
||||||
| @set@ [[type:set]] The set the card belongs to. This can be omited since "set" is a predefined variable.
|
| @set@ [[type:set]] The set the card belongs to. This can be omitted since "set" is a predefined variable.
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ Returns nil if no card was found.
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:string]] The uid of the card we want to retrieve.
|
| @input@ [[type:string]] The uid of the card we want to retrieve.
|
||||||
| @set@ [[type:set]] The set in which to look. This can be omited since 'set' is a predefined variable.
|
| @set@ [[type:set]] The set in which to look. This can be omitted since 'set' is a predefined variable.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ This is for use in exporter scripts. In card scripts, use the "stylesheet" prede
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:card]] The card you want to retrieve the stylesheet from.
|
| @input@ [[type:card]] The card you want to retrieve the stylesheet from.
|
||||||
| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be omited since "set" is a predefined variable.
|
| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be omitted since "set" is a predefined variable.
|
||||||
|
|
||||||
--Examples--
|
--Examples--
|
||||||
> # Retrieve the card regions from the card's stylesheet
|
> # Retrieve the card regions from the card's stylesheet
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ This is for use in exporter scripts. In card scripts, use the 'styling' predefin
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:card]] The card you want to retrieve the styling data from.
|
| @input@ [[type:card]] The card you want to retrieve the styling data from.
|
||||||
| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be omited since 'set' is a predefined variable.
|
| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be omitted since 'set' is a predefined variable.
|
||||||
|
|
||||||
--Examples--
|
--Examples--
|
||||||
> # Retrieve the value "is foil" from the card's styling options
|
> # Retrieve the value "is foil" from the card's styling options
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ Returns nil if no link of type "Front Face", or no card was found.
|
|||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ [[type:card]] The card whose links we'll inspect.
|
| @input@ [[type:card]] The card whose links we'll inspect.
|
||||||
| @set@ [[type:set]] The set in which to look. This can be omited since 'set' is a predefined variable.
|
| @set@ [[type:set]] The set in which to look. This can be omitted since 'set' is a predefined variable.
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
Function: get_metadata
|
||||||
|
|
||||||
|
--Usage--
|
||||||
|
> get_metadata(input: image)
|
||||||
|
|
||||||
|
Returns the metadata of an image, or an empty string if there isn't any.
|
||||||
|
|
||||||
|
Metadata is only stored when an image is saved as a PNG.
|
||||||
|
It is saved in a uncompressed iTXt chunk with the key "Description".
|
||||||
|
If the image is saved as a JPG, the metadata is lost.
|
||||||
|
|
||||||
|
--Parameters--
|
||||||
|
! Parameter Type Description
|
||||||
|
| @input@ [[type:image]] The image whose metadata we'll get.
|
||||||
|
| @set@ [[type:set]] The active set. This can be omitted since 'set' is a predefined variable.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
Function: set_metadata
|
||||||
|
|
||||||
|
--Usage--
|
||||||
|
> set_metadata(input: image, metadata: string)
|
||||||
|
|
||||||
|
Returns a copy of the input image with the metadata set to the given string.
|
||||||
|
|
||||||
|
Metadata is only stored when an image is saved as a PNG.
|
||||||
|
It is saved in a uncompressed iTXt chunk with the key "Description".
|
||||||
|
If the image is saved as a JPG, the metadata is lost.
|
||||||
|
|
||||||
|
--Parameters--
|
||||||
|
! Parameter Type Description
|
||||||
|
| @input@ [[type:image]] The image that will be copied.
|
||||||
|
| @metadata@ [[type:string]] The metadata that will be stored in the copy.
|
||||||
|
| @set@ [[type:set]] The active set. This can be omitted since 'set' is a predefined variable.
|
||||||
@@ -3,13 +3,14 @@ Function: to_json
|
|||||||
--Usage--
|
--Usage--
|
||||||
> to_json(some_script_value)
|
> to_json(some_script_value)
|
||||||
|
|
||||||
Convert a [[type:list]], a [[type:map]], a [[type:card]], a [[type:keyword]], a [[type:pack_type]] or a [[type:set]] to a JSON string.
|
Convert a [[type:list]], a [[type:map]], a [[type:style]], a [[type:card]], a [[type:keyword]], a [[type:pack_type]] or a [[type:set]] to a JSON string.
|
||||||
|
|
||||||
|
This method is also useful for debugging purposes.
|
||||||
|
|
||||||
--Parameters--
|
--Parameters--
|
||||||
! Parameter Type Description
|
! Parameter Type Description
|
||||||
| @input@ some_script_value MSE script value to convert to a JSON string.
|
| @input@ some_script_value MSE script value to convert to a JSON string.
|
||||||
| @set@ [[type:set]] The active set. This can be omited since "set" is a predefined variable.
|
| @set@ [[type:set]] The active set. This can be omitted since "set" is a predefined variable.
|
||||||
|
|
||||||
--Examples--
|
--Examples--
|
||||||
> to_json(card)
|
> to_json(card)
|
||||||
|
|||||||
@@ -65,6 +65,22 @@ SCRIPT_FUNCTION(download_image) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Image functions
|
// ----------------------------------------------------------------------------- : Image functions
|
||||||
|
|
||||||
|
SCRIPT_FUNCTION(get_metadata) {
|
||||||
|
SCRIPT_PARAM(Set*, set);
|
||||||
|
SCRIPT_PARAM(GeneratedImageP, input);
|
||||||
|
Image img = input->generate(GeneratedImage::Options(0, 0, set));
|
||||||
|
SCRIPT_RETURN(img.GetOption(wxIMAGE_OPTION_PNG_DESCRIPTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPT_FUNCTION(set_metadata) {
|
||||||
|
SCRIPT_PARAM(Set*, set);
|
||||||
|
SCRIPT_PARAM(GeneratedImageP, input);
|
||||||
|
SCRIPT_PARAM(String, metadata);
|
||||||
|
Image img = input->generate(GeneratedImage::Options(0, 0, set));
|
||||||
|
img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, metadata);
|
||||||
|
return make_intrusive<ArbitraryImage>(img);
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(width_of) {
|
SCRIPT_FUNCTION(width_of) {
|
||||||
SCRIPT_PARAM(Set*, set);
|
SCRIPT_PARAM(Set*, set);
|
||||||
SCRIPT_PARAM(GeneratedImageP, input);
|
SCRIPT_PARAM(GeneratedImageP, input);
|
||||||
@@ -311,6 +327,8 @@ SCRIPT_FUNCTION(built_in_image) {
|
|||||||
void init_script_image_functions(Context& ctx) {
|
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(_("to_card_image"), script_to_card_image);
|
||||||
|
ctx.setVariable(_("set_metadata"), script_set_metadata);
|
||||||
|
ctx.setVariable(_("get_metadata"), script_get_metadata);
|
||||||
ctx.setVariable(_("width_of"), script_width_of);
|
ctx.setVariable(_("width_of"), script_width_of);
|
||||||
ctx.setVariable(_("height_of"), script_height_of);
|
ctx.setVariable(_("height_of"), script_height_of);
|
||||||
ctx.setVariable(_("dimensions_of"), script_dimensions_of);
|
ctx.setVariable(_("dimensions_of"), script_dimensions_of);
|
||||||
|
|||||||
Reference in New Issue
Block a user