mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
feat: expose extra_card and extra_card_style script accessible variables
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ Features:
|
||||
* Center align the loaded image by default in the Image Slice Window.
|
||||
* Add Buttons to Align the loaded image in the Image Slice Window. (haganbmj/#18)
|
||||
* Add filter box to Game and Stylesheet selection. (haganbmj/#1)
|
||||
* Add `extra_card("field name")` script function for accessing Extra Card Fields. (haganbmj/#2)
|
||||
* Add `extra_data("field name")` script function for accessing Extra Card Fields. (haganbmj/#2)
|
||||
* Add Clear button to console panel. (haganbmj/#4)
|
||||
* Store images internally with PNG extension for ease of manual tinkering. (haganbmj/#5)
|
||||
* Add ability to change scale (relative to template) of internally stored images. (haganbmj/#6, haganbmj/#15)
|
||||
|
||||
@@ -74,6 +74,8 @@ void init_script_variables() {
|
||||
Var(card_style);
|
||||
Var(card);
|
||||
Var(styling);
|
||||
Var(extra_card_style);
|
||||
Var(extra_card);
|
||||
Var(value);
|
||||
Var(condition);
|
||||
Var(language);
|
||||
|
||||
@@ -142,6 +142,8 @@ enum Variable
|
||||
, SCRIPT_VAR_card_style
|
||||
, SCRIPT_VAR_card
|
||||
, SCRIPT_VAR_styling
|
||||
, SCRIPT_VAR_extra_card_style
|
||||
, SCRIPT_VAR_extra_card
|
||||
, SCRIPT_VAR_value
|
||||
, SCRIPT_VAR_condition
|
||||
, SCRIPT_VAR_language
|
||||
|
||||
@@ -40,8 +40,15 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
|
||||
ctx.setVariable(SCRIPT_VAR_game, to_script(set.game));
|
||||
ctx.setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet));
|
||||
ctx.setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style));
|
||||
|
||||
// I'm not entirely clear on why a "dummy value" is necessary here.
|
||||
// It doesn't appear that these are getting accessed until a card is found anyways, so they don't trip any errors that I could see.
|
||||
// Retaining the format just for consistency in case there's something that I missed.
|
||||
ctx.setVariable(SCRIPT_VAR_card, set.cards.empty() ? script_nil : to_script(set.cards.front())); // dummy value
|
||||
ctx.setVariable(SCRIPT_VAR_styling, to_script(&set.stylingDataFor(*stylesheet)));
|
||||
ctx.setVariable(SCRIPT_VAR_styling, to_script(&set.stylingDataFor(*stylesheet)));
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card_style, to_script(&stylesheet->extra_card_style)); // dummy value
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card, set.cards.empty() ? script_nil : to_script(&set.cards.front()->extraDataFor(*stylesheet))); // dummy value
|
||||
|
||||
try {
|
||||
// perform init scripts, don't use a scope, variables stay bound in the context
|
||||
try {
|
||||
@@ -67,9 +74,13 @@ Context& SetScriptContext::getContext(const CardP& card) {
|
||||
if (card) {
|
||||
ctx.setVariable(SCRIPT_VAR_card, to_script(card));
|
||||
ctx.setVariable(SCRIPT_VAR_styling, to_script(&set.stylingDataFor(card)));
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card_style, to_script(&stylesheet->extra_card_style));
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card, to_script(&card->extraDataFor(*stylesheet)));
|
||||
} else {
|
||||
ctx.setVariable(SCRIPT_VAR_card, ScriptValueP());
|
||||
ctx.setVariable(SCRIPT_VAR_styling, to_script(&set.stylingDataFor(*stylesheet)));
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card_style, script_nil);
|
||||
ctx.setVariable(SCRIPT_VAR_extra_card, script_nil);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user