Add symbol-set selection to shogi themes.
[tagua/yd.git] / data / themes / pieces / ShogiTTF / theme.lua
blob3f1a17130780129775393b32b4cb1ce4e7c88e5e
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 theme.options = OptList {
11 BoolOpt("moves_overlay", "Moves overlay", true),
12 BoolOpt("single_kanji", "Single kanji on tiles", false),
13 SelectOpt("symbols", "Symbol set", BoolOptList {
14 -- BoolOpt("use_predefined", "Predefined", true, OptList {
15 -- ComboOpt("font", "Symbol set", fontnames)
16 -- }),
17 BoolOpt("use_custom", "Custom font", false, OptList {
18 UrlOpt("file", "SVG glyph directory", "../../figurines/ShogiTTF/mikachan.ttf")
19 }),
20 -- BoolOpt("use_system", "System font", false, OptList {
21 -- FontOpt("font", "System font", Font("Arial", true, true))
22 -- }),
26 function addChar(complete, single, promoted)
27 return function(i, size)
28 font = theme.options.symbols.options.use_custom.sub_options.file.value
29 if theme.options.single_kanji.value then
30 i:draw_glyph(Rect(size*0.2,size*0.25,size*0.6,size*0.6), font, single,
31 promoted and "#d00000" or "#004000",
32 "#fff3c8", 4, false)
33 else
34 --local charsize, margin1, margin2 = 0.45, 0.09, -0.02 -- epgyobld
35 local charsize, margin1, margin2 = 0.4, 0.12, 0
36 i:draw_glyph(Rect(size*(0.5-charsize/2),size*margin1,size*charsize,size*charsize),
37 font, complete[1], promoted and "#d00000" or "#004000",
38 "#fff3c8", 4, false)
39 i:draw_glyph(Rect(size*(0.5-charsize/2),size*(0.5+margin2),size*charsize,size*charsize),
40 font, complete[2], promoted and "#d00000" or "#004000",
41 "#fff3c8", 4, false)
42 end
43 return i
44 end
45 end
47 function shogi_piece(first, char, white, promoted, ratio, moves)
48 return addShadow(overlay(tile(white, ratio),
49 shogi_moves(moves),
50 addChar(first, char, promoted)))
51 end
53 theme.black_king = shogi_piece({"0x738b", "0x5c06"}, "0x738b", false, false, 1,
54 shogimoves_king)
55 theme.black_rook = shogi_piece({"0x98db", "0x8eca"}, "0x98db", false, false, 0.96,
56 shogimoves_rook)
57 theme.black_p_rook = shogi_piece({"0x9f8d", "0x738b"}, "0x9f8d", false, true, 0.96,
58 shogimoves_dragon)
59 theme.black_bishop = shogi_piece({"0x89d2", "0x884c"}, "0x89d2", false, false, 0.93,
60 shogimoves_bishop)
61 theme.black_p_bishop = shogi_piece({"0x9f8d", "0x99ac"}, "0x99ac", false, true, 0.93,
62 shogimoves_horse)
63 theme.black_gold = shogi_piece({"0x91d1", "0x5c06"}, "0x91d1", false, false, 0.9,
64 shogimoves_gold)
65 theme.black_silver = shogi_piece({"0x9280", "0x5c06"}, "0x9280", false, false, 0.9,
66 shogimoves_silver)
67 theme.black_p_silver = shogi_piece({"0x6210", "0x9280"}, "0x5168", false, true, 0.9,
68 shogimoves_gold)
69 theme.black_knight = shogi_piece({"0x6842", "0x99ac"}, "0x6842", false, false, 0.86,
70 shogimoves_knight)
71 theme.black_p_knight = shogi_piece({"0x6210", "0x6842"}, "0x572d", false, true, 0.86,
72 shogimoves_gold)
73 theme.black_lance = shogi_piece({"0x9999", "0x8eca"}, "0x9999", false, false, 0.83,
74 shogimoves_lance)
75 theme.black_p_lance = shogi_piece({"0x6210", "0x9999"}, "0x674f", false, true, 0.83,
76 shogimoves_gold)
77 theme.black_pawn = shogi_piece({"0x6b69", "0x5175"}, "0x6b69", false, false, 0.8,
78 shogimoves_pawn)
79 theme.black_p_pawn = shogi_piece({"0x3068", "0x91d1"}, "0x3068", false, true, 0.8,
80 shogimoves_gold)
82 theme.white_king = shogi_piece({"0x7389", "0x5c06"}, "0x7389", true, false, 1,
83 shogimoves_king)
84 theme.white_rook = shogi_piece({"0x98db", "0x8eca"}, "0x98db", true, false, 0.96,
85 shogimoves_rook)
86 theme.white_p_rook = shogi_piece({"0x9f8d", "0x738b"}, "0x9f8d", true, true, 0.96,
87 shogimoves_dragon)
88 theme.white_bishop = shogi_piece({"0x89d2", "0x884c"}, "0x89d2", true, false, 0.93,
89 shogimoves_bishop)
90 theme.white_p_bishop = shogi_piece({"0x9f8d", "0x99ac"}, "0x99ac", true, true, 0.93,
91 shogimoves_horse)
92 theme.white_gold = shogi_piece({"0x91d1", "0x5c06"}, "0x91d1", true, false, 0.9,
93 shogimoves_gold)
94 theme.white_silver = shogi_piece({"0x9280", "0x5c06"}, "0x9280", true, false, 0.9,
95 shogimoves_silver)
96 theme.white_p_silver = shogi_piece({"0x6210", "0x9280"}, "0x5168", true, true, 0.9,
97 shogimoves_gold)
98 theme.white_knight = shogi_piece({"0x6842", "0x99ac"}, "0x6842", true, false, 0.86,
99 shogimoves_knight)
100 theme.white_p_knight = shogi_piece({"0x6210", "0x6842"}, "0x572d", true, true, 0.86,
101 shogimoves_gold)
102 theme.white_lance = shogi_piece({"0x9999", "0x8eca"}, "0x9999", true, false, 0.83,
103 shogimoves_lance)
104 theme.white_p_lance = shogi_piece({"0x6210", "0x9999"}, "0x674f", true, true, 0.83,
105 shogimoves_gold)
106 theme.white_pawn = shogi_piece({"0x6b69", "0x5175"}, "0x6b69", true, false, 0.8,
107 shogimoves_pawn)
108 theme.white_p_pawn = shogi_piece({"0x3068", "0x91d1"}, "0x3068", true, true, 0.8,
109 shogimoves_gold)
111 -- This is part of Dai Shohi
113 theme.black_freeking = shogi_piece({"0x5954", "0x738b"}, "0x5954", false, false, 1,
114 shogimoves_freeking)
115 theme.white_freeking = shogi_piece({"0x5954", "0x738b"}, "0x5954", true, false, 1,
116 shogimoves_freeking)
118 -- To be able to adapt this theme to chess too
119 theme.black_queen = theme.black_freeking
120 theme.white_queen = theme.white_freeking