Add symbol-set selection to shogi themes.
[tagua/yd.git] / data / themes / pieces / ShogiSVG / theme.lua
blob8039ebcb7ab1041d5e13983dfcbcb24556b005ff
1 import("piece_theme.lua")
2 import("shogi_themelib.lua")
4 shadow=7.0
5 shadow_color="#404050"
6 shadow_offset_x=6
7 shadow_offset_y=4
8 shadow_grow=5
10 fontnames = {"Potraced from ???", "Potraced from shogi.net", "Potraced from daemonshogi"}
11 fontlist = {"default", "shogi.net", "daemonshogi"}
13 theme.options = OptList {
14 BoolOpt("moves_overlay", "Moves overlay", true),
15 SelectOpt("symbols", "Symbol set", BoolOptList {
16 BoolOpt("use_predefined", "Predefined", true, OptList {
17 ComboOpt("font", "Symbol set", fontnames)
18 }),
19 BoolOpt("use_custom", "Custom", false, OptList {
20 UrlOpt("dir", "SVG glyph directory", "default/")
21 }),
25 function addGlyph(file)
26 return function(i, size)
27 local dir
28 if theme.options.symbols.options.use_predefined.value then
29 dir = fontlist[theme.options.symbols.options.use_predefined.sub_options.font.selected+1]
30 else
31 dir = theme.options.symbols.options.use_custom.sub_options.dir.value
32 end
33 i:draw_svg(Rect(0,0,size,size), dir .. '/' .. file)
34 return i
35 end
36 end
38 function shogi_piece(file, white, ratio, moves)
39 return addShadow(overlay(tile(white, ratio),
40 shogi_moves(moves),
41 addGlyph(file)))
42 end
44 theme.black_king = shogi_piece("king.svg", false, 1, shogimoves_king)
45 theme.black_rook = shogi_piece("rook.svg", false, 0.96, shogimoves_rook)
46 theme.black_p_rook = shogi_piece("prook.svg", false, 0.96, shogimoves_dragon)
47 theme.black_bishop = shogi_piece("bishop.svg", false, 0.93, shogimoves_bishop)
48 theme.black_p_bishop = shogi_piece("pbishop.svg", false, 0.93, shogimoves_horse)
49 theme.black_gold = shogi_piece("gold.svg", false, 0.9, shogimoves_gold)
50 theme.black_silver = shogi_piece("silver.svg", false, 0.9, shogimoves_silver)
51 theme.black_p_silver = shogi_piece("psilver.svg", false, 0.9, shogimoves_gold)
52 theme.black_knight = shogi_piece("horse.svg", false, 0.86, shogimoves_knight)
53 theme.black_p_knight = shogi_piece("phorse.svg", false, 0.86, shogimoves_gold)
54 theme.black_lance = shogi_piece("lance.svg", false, 0.83, shogimoves_lance)
55 theme.black_p_lance = shogi_piece("plance.svg", false, 0.83, shogimoves_gold)
56 theme.black_pawn = shogi_piece("pawn.svg", false, 0.8, shogimoves_pawn)
57 theme.black_p_pawn = shogi_piece("ppawn.svg", false, 0.8, shogimoves_gold)
59 theme.white_king = shogi_piece("king.svg", true, 1, shogimoves_king)
60 theme.white_rook = shogi_piece("rook.svg", true, 0.96, shogimoves_rook)
61 theme.white_p_rook = shogi_piece("prook.svg", true, 0.96, shogimoves_dragon)
62 theme.white_bishop = shogi_piece("bishop.svg", true, 0.93, shogimoves_bishop)
63 theme.white_p_bishop = shogi_piece("pbishop.svg", true, 0.93, shogimoves_horse)
64 theme.white_gold = shogi_piece("gold.svg", true, 0.9, shogimoves_gold)
65 theme.white_silver = shogi_piece("silver.svg", true, 0.9, shogimoves_silver)
66 theme.white_p_silver = shogi_piece("psilver.svg", true, 0.9, shogimoves_gold)
67 theme.white_knight = shogi_piece("horse.svg", true, 0.86, shogimoves_knight)
68 theme.white_p_knight = shogi_piece("phorse.svg", true, 0.86, shogimoves_gold)
69 theme.white_lance = shogi_piece("lance.svg", true, 0.83, shogimoves_lance)
70 theme.white_p_lance = shogi_piece("plance.svg", true, 0.83, shogimoves_gold)
71 theme.white_pawn = shogi_piece("pawn.svg", true, 0.8, shogimoves_pawn)
72 theme.white_p_pawn = shogi_piece("ppawn.svg", true, 0.8, shogimoves_gold)
74 -- To be able to adapt this theme to chess too
75 theme.black_queen = shogi_piece("gold.svg", false, 0.9, shogimoves_freeking)
76 theme.white_queen = shogi_piece("gold.svg", true, 0.9, shogimoves_freeking)