mirror of
https://github.com/smogon/sprites.git
synced 2026-08-20 00:34:22 -05:00
remove frames from rule/foreach_rule
This commit is contained in:
118
Tupfile.lua
118
Tupfile.lua
@@ -1,45 +1,47 @@
|
||||
|
||||
-- Generate uniform size minisprites
|
||||
|
||||
foreach_rule{
|
||||
display="pad g6 minisprite %f",
|
||||
input="newsrc/minisprites/pokemon/gen6/*.png",
|
||||
command=pad{w=40, h=30},
|
||||
output="build/gen6-minisprites-padded/%b"
|
||||
}
|
||||
foreach_rule(
|
||||
"newsrc/minisprites/pokemon/gen6/*.png",
|
||||
{
|
||||
display="pad g6 minisprite %f",
|
||||
pad{w=40, h=30}
|
||||
},
|
||||
"build/gen6-minisprites-padded/%b"
|
||||
)
|
||||
|
||||
-- PS spritesheet
|
||||
|
||||
rule{
|
||||
display="ps pokemon sheet",
|
||||
input={"ps-pokemon.sheet.mjs"},
|
||||
command={
|
||||
rule(
|
||||
"ps-pokemon.sheet.mjs",
|
||||
{
|
||||
display="ps pokemon sheet",
|
||||
"node tools/sheet %f %o",
|
||||
compresspng{config="SPRITESHEET"}
|
||||
},
|
||||
output={"build/ps/pokemonicons-sheet.png"}
|
||||
}
|
||||
"build/ps/pokemonicons-sheet.png"
|
||||
)
|
||||
|
||||
-- TODO: reenable when trainers are moved
|
||||
-- rule{
|
||||
-- display="ps trainers sheet",
|
||||
-- input={"ps-trainers.sheet.mjs"},
|
||||
-- command={
|
||||
-- {"ps-trainers.sheet.mjs"},
|
||||
-- {
|
||||
-- "node tools/sheet %f %o",
|
||||
-- compresspng{config="SPRITESHEET"}
|
||||
-- },
|
||||
-- output={"build/ps/trainers-sheet.png"}
|
||||
-- {"build/ps/trainers-sheet.png"}
|
||||
-- }
|
||||
|
||||
rule{
|
||||
display="ps items sheet",
|
||||
input={"ps-items.sheet.mjs"},
|
||||
command={
|
||||
rule(
|
||||
"ps-items.sheet.mjs",
|
||||
{
|
||||
display="ps items sheet",
|
||||
"node tools/sheet %f %o",
|
||||
compresspng{config="SPRITESHEET"}
|
||||
},
|
||||
output={"build/ps/itemicons-sheet.png"}
|
||||
}
|
||||
"build/ps/itemicons-sheet.png"
|
||||
)
|
||||
|
||||
-- PS pokeball icons
|
||||
|
||||
@@ -49,15 +51,15 @@ local balls = {
|
||||
"src/noncanonical/ui/battle/Ball-Null.png",
|
||||
}
|
||||
|
||||
rule{
|
||||
display="pokemonicons-pokeball-sheet",
|
||||
input=balls,
|
||||
command={
|
||||
rule(
|
||||
balls,
|
||||
{
|
||||
display="pokemonicons-pokeball-sheet",
|
||||
"convert -background transparent -gravity center -extent 40x30 %f +append %o",
|
||||
compresspng{config="SPRITESHEET"}
|
||||
},
|
||||
output={"build/ps/pokemonicons-pokeball-sheet.png"}
|
||||
}
|
||||
"build/ps/pokemonicons-pokeball-sheet.png"
|
||||
)
|
||||
|
||||
-- Smogdex social images
|
||||
|
||||
@@ -66,25 +68,25 @@ for file in iglob("newsrc/models/*") do
|
||||
goto continue
|
||||
end
|
||||
|
||||
rule{
|
||||
display="fbsprite %f",
|
||||
input={file},
|
||||
command={
|
||||
rule(
|
||||
file,
|
||||
{
|
||||
display="fbsprite %f",
|
||||
"tools/fbsprite.sh %f %o",
|
||||
compresspng{config="MODELS"}
|
||||
},
|
||||
output="build/smogon/fbsprites/xy/%B.png"
|
||||
}
|
||||
"build/smogon/fbsprites/xy/%B.png"
|
||||
)
|
||||
|
||||
rule{
|
||||
display="twittersprite %f",
|
||||
input={file},
|
||||
command={
|
||||
rule(
|
||||
file,
|
||||
{
|
||||
display="twittersprite %f",
|
||||
"tools/twittersprite.sh %f %o",
|
||||
compresspng{config="MODELS"}
|
||||
},
|
||||
output="build/smogon/twittersprites/xy/%B.png"
|
||||
}
|
||||
"build/smogon/twittersprites/xy/%B.png"
|
||||
)
|
||||
|
||||
::continue::
|
||||
end
|
||||
@@ -95,40 +97,40 @@ end
|
||||
-- TODO: reenable when trainers are moved
|
||||
-- foreach_rule{
|
||||
-- display="pad trainer %f",
|
||||
-- input={"src/canonical/trainers/*"},
|
||||
-- command={
|
||||
-- {"src/canonical/trainers/*"},
|
||||
-- {
|
||||
-- pad{w=80, h=80},
|
||||
-- compresspng{config="TRAINERS"}
|
||||
-- },
|
||||
-- output={"build/padded-trainers/canonical/%b"}
|
||||
-- {"build/padded-trainers/canonical/%b"}
|
||||
-- }
|
||||
|
||||
-- Padded Dex
|
||||
|
||||
foreach_rule{
|
||||
display="pad dex %f",
|
||||
input="newsrc/dex/*",
|
||||
command={
|
||||
foreach_rule(
|
||||
"newsrc/dex/*",
|
||||
{
|
||||
display="pad dex %f",
|
||||
pad{w=120, h=120},
|
||||
compresspng{config="DEX"}
|
||||
},
|
||||
output="build/padded-dex/%b",
|
||||
}
|
||||
"build/padded-dex/%b"
|
||||
)
|
||||
|
||||
-- Build missing CAP dex
|
||||
|
||||
foreach_rule{
|
||||
input={"newsrc/sprites/gen5/*.gif", "newsrc/models/*.gif"},
|
||||
display="missing dex %B",
|
||||
command={
|
||||
local input = glob({"newsrc/sprites/gen5/*.gif", "newsrc/models/*.gif"}, {filter=function()
|
||||
return not ((expand("%B")):find("-b") or (expand("%B")):find("-s")) and not glob_matches("newsrc/dex/%B.png")
|
||||
end, key="%B"})
|
||||
|
||||
foreach_rule(
|
||||
input,
|
||||
{
|
||||
display="missing dex %B",
|
||||
"convert %f'[0]' -trim %o",
|
||||
"mogrify -background transparent -gravity center -resize '120x120>' -extent 120x120 %o",
|
||||
compresspng{config="DEX"}
|
||||
},
|
||||
key="%B",
|
||||
filter=function()
|
||||
return not ((expand("%B")):find("-b") or (expand("%B")):find("-s")) and not glob_matches("newsrc/dex/%B.png")
|
||||
end,
|
||||
output="build/padded-dex/%B-missing.png",
|
||||
}
|
||||
"build/padded-dex/%B-missing.png"
|
||||
)
|
||||
|
||||
|
||||
@@ -95,68 +95,27 @@ local function cspec2cmd(cmdSpec)
|
||||
end
|
||||
cmd = cmd .. newcmd
|
||||
end
|
||||
-- Abstract over tup's arcane display override
|
||||
if cmdSpec.display then
|
||||
cmd = rep{"^ ${display}^ ${cmd}", display=cmdSpec.display, cmd=cmd}
|
||||
end
|
||||
return cmd
|
||||
end
|
||||
|
||||
-- Abstract over tup's arcane display override
|
||||
local function display_cmd(display, cmd)
|
||||
if display == nil then
|
||||
return cmd
|
||||
else
|
||||
return rep{"^ ${display}^ ${cmd}", display=display, cmd=cmd}
|
||||
end
|
||||
end
|
||||
|
||||
local function do_rule_frame(opts, foreach)
|
||||
local cspec = opts.command
|
||||
local cmd = display_cmd(opts.display, cspec2cmd(cspec))
|
||||
local function do_rule(input, cspec, output, foreach)
|
||||
local cmd = cspec2cmd(cspec)
|
||||
if foreach then
|
||||
local input = glob(opts.input, opts)
|
||||
for i in iter(input) do
|
||||
local frame = {}
|
||||
push_frame(frame)
|
||||
frame.input = i
|
||||
local output = {}
|
||||
for v in iter(astable(opts.output)) do
|
||||
table.insert(output, expand(v))
|
||||
end
|
||||
frame.output = tostring(output)
|
||||
tup.rule(i, expand(cmd), output)
|
||||
pop_frame()
|
||||
end
|
||||
tup.foreach_rule(input, cmd, output)
|
||||
else
|
||||
local frame = {}
|
||||
push_frame(frame)
|
||||
local input = glob(opts.input)
|
||||
frame.input = tostring(input)
|
||||
local output = {}
|
||||
for v in iter(astable(opts.output)) do
|
||||
table.insert(output, expand(v))
|
||||
end
|
||||
frame.output = tostring(output)
|
||||
tup.rule(input, expand(cmd), output)
|
||||
pop_frame()
|
||||
tup.rule(input, cmd, output)
|
||||
end
|
||||
end
|
||||
|
||||
local function do_rule(opts, foreach)
|
||||
local dimensions = opts.dimensions or {}
|
||||
local ret = {}
|
||||
iter_rep(dimensions,
|
||||
function()
|
||||
for v in iter{do_rule_frame(opts, foreach, ret)} do
|
||||
table.insert(ret, v)
|
||||
end
|
||||
end
|
||||
)
|
||||
return ret
|
||||
function rule(input, cmd, output)
|
||||
return do_rule(input, cmd, output, false)
|
||||
end
|
||||
|
||||
function rule(opts)
|
||||
return do_rule(opts, false)
|
||||
end
|
||||
|
||||
function foreach_rule(opts)
|
||||
return do_rule(opts, true)
|
||||
function foreach_rule(input, cmd, output)
|
||||
return do_rule(input, cmd, output, true)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user