* Add old exporter from ancient times. --------- Co-authored-by: cajun <12363371+CajunAvenger@users.noreply.github.com>
262 lines
9.1 KiB
Plaintext
262 lines
9.1 KiB
Plaintext
# Simple exporter for HTML files
|
|
mse version: 2.0.0
|
|
game: magic
|
|
short name: Spoiler
|
|
full name: List of cards
|
|
installer group: magic/Export/Spoiler (list of cards)
|
|
icon: preview.png
|
|
create directory: true
|
|
version: 2014-06-19
|
|
depends on: magic.mse-game 2008-05-18
|
|
|
|
########################################################################################
|
|
|
|
option field:
|
|
type: boolean
|
|
name: include set file
|
|
description: Should a link to the MSE set file be included in the spoiler?
|
|
initial: no
|
|
option field:
|
|
type: choice
|
|
name: grouping
|
|
description: How should cards be grouped?
|
|
choice: no grouping
|
|
choice: group by color
|
|
initial: group by color
|
|
option field:
|
|
type: choice
|
|
name: images
|
|
choice: no
|
|
choice: full card image, linked
|
|
choice: full card image, preview
|
|
choice: full card image only
|
|
initial: full card image, preview
|
|
option field:
|
|
type: boolean
|
|
name: mana symbols
|
|
description: Should mana symbols be used, or should they be written as text?
|
|
option field:
|
|
type: boolean
|
|
name: rarity symbols
|
|
description: Should rarity be shown using a symbol or as text?
|
|
option field:
|
|
type: color
|
|
name: background color
|
|
initial: rgb(255,255,255)
|
|
choice:
|
|
name: white
|
|
color: rgb(255,255,255)
|
|
choice:
|
|
name: black
|
|
color: rgb(0,0,0)
|
|
option field:
|
|
type: color
|
|
name: text color
|
|
initial: rgb(0,0,0)
|
|
choice:
|
|
name: white
|
|
color: rgb(255,255,255)
|
|
choice:
|
|
name: black
|
|
color: rgb(0,0,0)
|
|
|
|
option style:
|
|
grouping:
|
|
render style: both
|
|
choice images:
|
|
no grouping: { built_in_image("bool_no") }
|
|
group by color: /magic-spoiler.mse-export-template/card_color.png
|
|
images:
|
|
render style: both
|
|
choice images:
|
|
no: { built_in_image("bool_no") }
|
|
|
|
script:
|
|
if options.mana_symbols then (
|
|
symbol_font := "magic-mana-small"
|
|
symbol_font_size := 12
|
|
) else (
|
|
symbols_to_html := to_html
|
|
)
|
|
include file: workaround
|
|
write_card := {
|
|
if contains(options.images, match:"full card image") then
|
|
card_image_file := write_image_file(card, file:"card{position(of:card,in:set)}.jpg")
|
|
else
|
|
card_image_file := ""
|
|
|
|
if options.images == "full card image, preview" then
|
|
card_image_preview := write_image_file(card, file:"card-preview{position(of:card,in:set)}.jpg", height: 100)
|
|
else
|
|
card_image_preview := card_image_file
|
|
|
|
if options.images == "full card image only" then
|
|
"<li class='fullcard'><img src='{card_image_file}' alt=''></li>"
|
|
else
|
|
"<li class='card'>
|
|
{if options.images == "full card image, preview" then
|
|
"<a href='{card_image_file}'><img src='{card_image_preview}' alt='' class='card-image'></a>
|
|
<div class='box'>
|
|
<div><span class='name' >{ to_html(card.name ) }</span>"
|
|
else if card_image_file != "" and contains(options.images, match:"linked") then
|
|
"<div class='box'>
|
|
<div><span class='name' ><a href='{card_image_file}'>{ to_html(card.name) }</a></span>"
|
|
else
|
|
"<div class='box'>
|
|
<div><span class='name' >{ to_html(card.name ) }</span>"
|
|
}<span class='casting-cost' >{ symbols_to_html(card.casting_cost ) }</span></div>
|
|
{if card_image_file != "" and contains(options.images, match:"inline") then
|
|
"<img src='{card_image_preview}' alt='' class='image'>"
|
|
}
|
|
<div><span class='type'>{ to_html(card.type) }</span><span class='rarity'>{
|
|
if options.rarity_symbols then
|
|
"<img src='{ var := if card.rarity == "" then "common"
|
|
else if card.rarity == "basic land" then "common"
|
|
else card.rarity
|
|
write_image_file(
|
|
file: "set-symbol-{var}.png",
|
|
width: 20,
|
|
symbol_variation(
|
|
symbol: set.symbol,
|
|
variation: var
|
|
)
|
|
)}' alt='{card.rarity}' title='{card.rarity}'>"
|
|
else if card.rarity == "" then "(Common)"
|
|
else "(" + card.rarity + ")"
|
|
}
|
|
</span></div>
|
|
<span class='rule-text' >{ to_html(if card.special_text != "" then card.special_text else card.rule_text) }</span>
|
|
<span class='flavor-text' >{ to_html(remove_tag(tag: "<i-flavor>", card.flavor_text)) }</span>
|
|
<span class='pt' >{ card.pt + card.loyalty }</span>
|
|
<span class='card-number' >{ to_html(card.card_number) }</span>
|
|
</div>
|
|
</li>"
|
|
}
|
|
kind_of_card := { if contains(card.shape, match:"token") then ""
|
|
else if contains(card.shape, match:"rulestip") then ""
|
|
else if contains(card.shape, match:"counter") then ""
|
|
else if contains(card.shape, match:"emblem") then ""
|
|
else if contains(card.shape, match:"split") then write_card()
|
|
else if contains(card.shape, match:"double faced") then write_card()
|
|
else if card.name_2 != "" then write_card()
|
|
else if card.loyalty != "" then write_card()
|
|
else if contains(card.shape, match:"leveler") then write_card()
|
|
else write_card()
|
|
}
|
|
write_cards := {
|
|
"<ul class='cards'>{
|
|
for each card in sort_list(cards, order_by: {input.card_number}) do
|
|
kind_of_card()
|
|
}</ul>"
|
|
}
|
|
write_group := {
|
|
cards := filter_list(cards, filter:
|
|
{
|
|
# The first character of the color_of_card code must be equal to 'code'
|
|
substring(color_of_card(card:input), begin:0, end:1) == code
|
|
}
|
|
)
|
|
count := number_of_items(in:cards)
|
|
if count > 0 then
|
|
"<h2>{title} ({count} {if count == 1 then "card" else "cards"})</h2>" +
|
|
write_cards()
|
|
else ""
|
|
}
|
|
# Used by print_cards() to format saga text, since those have unique boxes.
|
|
print_saga_text :=
|
|
{
|
|
"<span class='rule-text' > {to_html(card.chapter_text)} </span>
|
|
<span class='rule-text' > {to_html(card.level_1_text)} </span>
|
|
<span class='rule-text' > {to_html(card.level_2_text)} </span>
|
|
<span class='rule-text' > {to_html(card.level_3_text)} </span>
|
|
<span class='rule-text' > {to_html(card.level_4_text)} </span>"
|
|
}
|
|
# Used by print_cards() to format planeswalker text, since those have unique boxes.
|
|
print_walker_text :=
|
|
{
|
|
"<span class='rule-text' > {to_html(card.level_1_text)} </span>" +
|
|
"<span class='rule-text' > {to_html(card.level_2_text)} </span>" +
|
|
"<span class='rule-text' > {to_html(card.level_3_text)} </span>" +
|
|
"<span class='rule-text' > {to_html(card.level_4_text)} </span>"
|
|
}
|
|
|
|
# Actual export-ey bit starts here.
|
|
file_path := replace(copy_file("blank.gif"), match:"blank.gif", replace:"")
|
|
write_image_file(
|
|
file: "set-symbol.png",
|
|
width: 200,
|
|
symbol_variation(symbol: set.symbol, variation: "rare")
|
|
)
|
|
write_image_file(
|
|
file: "set-icon.png",
|
|
width: 16,
|
|
heght: 16
|
|
symbol_variation(symbol: set.symbol, variation: "rare")
|
|
)
|
|
write_text_file(
|
|
script_string,
|
|
file: "script.js",
|
|
)
|
|
write_text_file(
|
|
css_string,
|
|
file: "style.css"
|
|
)
|
|
|
|
# Generate html largely by string interpolation.
|
|
html := "<!DOCTYPE HTML>
|
|
<html lang='en'>
|
|
<head>
|
|
<title>{set.title}</title>
|
|
<link rel='stylesheet' type='text/css' href='{file_path}style.css'>
|
|
<link rel='shortcut icon' type='image/png' href='set-icon.png'>
|
|
<script type='text/javascript' src='{file_path}script.js'></script>
|
|
<style type='text/css'>
|
|
body \{
|
|
# This is here vs the css so the user can control text colors.
|
|
background: {options.background_color};
|
|
color: {options.text_color};
|
|
font-family: 'mplantin', serif;
|
|
# Should match with Scryfall based on my terrible understanding.
|
|
font-size: 15px;
|
|
\}
|
|
</style>
|
|
</head>
|
|
<body{if options.images == "full card image, preview" then " class='with-previews'"}>
|
|
<img src='{ write_image_file(
|
|
file: "set-symbol.png",
|
|
width: 200,
|
|
symbol_variation(symbol: set.symbol, variation: "rare")
|
|
)}' alt='' class='set-symbol'>
|
|
<h1>{set.title}</h1>
|
|
<div class='copyright'>{set.copyright}</div>
|
|
<div class='description'>{set.description}</div>
|
|
{ if options.include_set_file then
|
|
"<div class='set-file'><a href='{ write_set_file(file:"set.mse-set") }'>Download set in MSE format</a></div>"
|
|
}
|
|
{ if options.grouping == "group by color" then
|
|
# Codes as by sort_index
|
|
# Can't find anything that goes in other letters so far.
|
|
write_group(title: "Colorless" code:"A") +
|
|
write_group(title: "White", code:"B") +
|
|
write_group(title: "Blue", code:"C") +
|
|
write_group(title: "Black", code:"D") +
|
|
write_group(title: "Red", code:"E") +
|
|
write_group(title: "Green", code:"F") +
|
|
write_group(title: "Multicolor", code:"G") +
|
|
write_group(title: "Hybrids", code:"H") +
|
|
write_group(title: "Multicolor split", code:"I") +
|
|
write_group(title: "Artifact", code:"J") +
|
|
write_group(title: "Non-basic lands", code:"L") +
|
|
write_group(title: "Basic lands", code:"")
|
|
else write_cards(cards: cards)
|
|
}
|
|
<script><!--
|
|
init();
|
|
--></script>
|
|
</body>
|
|
</html>"
|
|
|
|
write_text_file(html, file:"index.html")
|
|
# make sure the urls are relative to the right directory
|
|
replace(html, match:"<[^<>]*(href|src)='", replace:"&{directory}/")
|