haganbmj / MagicSetEditor2

Magic Set Editor is a program for designing trading cards
Other
17 stars 7 forks source link

feat: add extra_card() function to expose extra card fields #2

Closed haganbmj closed 2 years ago

haganbmj commented 2 years ago

Still running through some stylesheet validations. Currently using the below stylesheet as a test bed. It covers multiple field types, derived fields from script evaluation, boolean evaluation of the retrieved value, and custom function usage. Really not sure what else to test, but I'm hoping it's pretty safe since it is just returning a ValueP.

Also need to investigate what script dependencies is doing, the combine function has a block that seems to bind which particular fields it show re-evaluate after changes to? This might be just blanket declaring a dependency against the entire Card without that, which while not atrocious is probably inefficient.

https://github.com/haganbmj/MagicSetEditor2/blob/5840f6c4936f1e9ae74b98a4013d39e8aca0e2c0/src/script/functions/editor.cpp#L146

mse version:    2.0.0
game:           magic
short name:     Test Template
full name:      Test Shit Yo
icon:           card-sample.png
position hint:  100

depends on:     magic.mse-game

card width: 375
card height: 523
card dpi: 150

init script:
    guild_mana := { false }
    ancestral_mana := { false }

extra card field:
    type: text
    name: extra text field
    save value: true
    script: replace(value, match: "_", replace: "*")
extra card field:
    type: choice
    name: extra choice field
    save value: true
    choice: a
    choice: b
    choice: c
extra card field:
    type: boolean
    name: extra boolean field

extra card field:
    type: text
    name: extra boolean evaluated
    save value: false
    script: if extra_data("extra boolean field") then "true" else "false"
extra card field:
    type: text
    name: extra text field custom func
    # This makes use of a magic.mse-game defined function.
    script: space_to_comma(extra_data("extra_text_field"))
extra card field:
    type: text
    name: extra scripted field
    save value: false
    script: 
        extra_data("extra_text_field") + " / "
        + extra_data("extra text field custom func") + " / "
        + extra_data("extra_choice_field") + " / "
        + extra_data("extra_boolean_field")
        + " (" + extra_data("extra_boolean_evaluated") + ")"

extra card style:
    extra text field:
        left: 20
        top: 20
        width: 335
        height: 20
        font:
            name: MPlantin
            italic name: MPlantin-Italic
            size: 12
            scale down to: 6
            color: black
        alignment: middle left
        z index: 10
extra card style:
    extra choice field:
        left: 20
        top: 40
        width: 335
        height: 20
        font:
            name: MPlantin
            italic name: MPlantin-Italic
            size: 12
            scale down to: 6
            color: black
        alignment: middle left
        z index: 10
extra card style:
    extra boolean field:
        left: 20
        top: 60
        width: 335
        height: 20
        font:
            name: MPlantin
            italic name: MPlantin-Italic
            size: 12
            scale down to: 6
            color: black
        alignment: middle left
        z index: 10

extra card style:
    extra scripted field:
        left: 20
        top: 450
        width: 335
        height: 75
        font:
            name: MPlantin
            italic name: MPlantin-Italic
            size: 12
            color: black
        alignment: middle left
        z index: 10