Fixed pool problems.
[tagua/yd.git] / data / themes / controls / Cool / theme.lua
blob0017dfca6a4bfcec874df3a30474739ffd006773
1 import("../../pieces/common.lua")
4 theme.options = OptList {
5 BoolOpt("wallpaper", "Draw wallpaper", true, OptList {
6 BoolOpt("blur", "Enable blur", false),
7 UrlOpt("file", "File:", "Wallpapers/dragonballz.jpg")
8 })
11 local border_ratio = 0.67
12 local clock_ratio = 2.6
13 local clock_height_ratio = 0.4
14 local clock_border_ratio = 0.33
15 local pool_width = 3
16 local pool_piece_ratio = clock_ratio/pool_width
18 theme.layout = function(args)
19 for key,value in pairs(args) do
20 print("args[",key,"] = ",value)
21 end
23 retv = {}
24 retv.square_size = math.floor(math.min(
25 args.width/(args.grid_size.x+2*border_ratio+clock_ratio+2*clock_border_ratio),
26 args.height/(args.grid_size.y+2*border_ratio) ) )
27 retv.border_size = math.floor(retv.square_size*border_ratio)
28 retv.clock_size = math.floor(retv.square_size*clock_ratio)
29 retv.pool_width = pool_width;
30 retv.pool_piece_size = math.floor(retv.square_size*pool_piece_ratio)
32 local d = Point(math.floor((args.width-retv.square_size*(args.grid_size.x+
33 2*border_ratio+clock_ratio+2*clock_border_ratio))/2),
34 math.floor((args.height-retv.square_size*(args.grid_size.y+2*border_ratio))/2));
35 local clock_border = math.floor(retv.square_size*clock_border_ratio)
36 local clock_height = math.floor(retv.clock_size*clock_height_ratio)
37 local panel_x = retv.square_size*args.grid_size.x + 2*retv.border_size + clock_border;
38 retv.board_position = d + Point(retv.border_size, retv.border_size)
39 retv.clock0_position = d + Point(panel_x, clock_border_ratio*retv.square_size)
40 retv.clock1_position = d + Point(panel_x, retv.square_size*args.grid_size.y + 2*retv.border_size
41 - clock_height - clock_border)
42 retv.pool0_position = Point(d.x + panel_x, retv.clock0_position.y+clock_height+clock_border);
43 retv.pool1_position = Point(d.x + panel_x, retv.clock1_position.y-clock_border);
45 return retv
46 end
49 function addShadow(i, size)
50 local s = i:create_shadow( size, "#ffffff", Point(0, 0), Point(0, 0) )
51 s:draw_image(Rect(0, 0, i.width, i.height), i)
52 return s
53 end
55 theme.border = function(b, args)
56 local rb = math.floor(b*2/3);
57 local w = args.width;
58 local h = args.height;
59 local tr = Image(b, b); tr:clear(); tr:draw_svg(Rect(0,b-rb,rb,rb), "border_corner.svg"); tr = addShadow(tr, b/3)
60 local tl = Image(b, b); tl:set_paint_over(false); tl:rotate(270); tl:translate(0,b); tl:draw_image(Rect(0,0,b,b), tr)
61 local bl = Image(b, b); bl:set_paint_over(false); bl:rotate(180); bl:translate(b,b); bl:draw_image(Rect(0,0,b,b), tr)
62 local br = Image(b, b); br:set_paint_over(false); br:rotate(90); br:translate(b,0); br:draw_image(Rect(0,0,b,b), tr)
63 local t = Image(w, b); t:clear(); t:draw_svg(Rect(0,b-rb,w,rb), "border_top.svg"); t = addShadow(t, b/6)
64 local bt = Image(w, b); bt:set_paint_over(false); bt:rotate(180); bt:translate(w,b); bt:draw_image(Rect(0,0,w,b), t)
65 local l = Image(b, h); l:set_paint_over(false); l:rotate(270); l:translate(0,h); l:draw_image(Rect(0,0,h,b), t)
66 local r = Image(b, h); r:set_paint_over(false); r:rotate(90); r:translate(b,0); r:draw_image(Rect(0,0,h,b), t)
67 return {
68 [Rect(-b,-b,b,b)] = tl,
69 [Rect(w,-b,b,b)] = tr,
70 [Rect(-b,h,b,b)] = bl,
71 [Rect(w,h,b,b)] = br,
72 [Rect(0,-b,w,b)] = t,
73 [Rect(0,h,w,b)] = bt,
74 [Rect(-b,0,b,h)] = l,
75 [Rect(w,0,b,h)] = r
77 end
79 theme.wallpaper = function()
80 if(theme.options.wallpaper.value) then
81 local i = Image(theme.options.wallpaper.sub_options.file.value, false)
82 if(theme.options.wallpaper.sub_options.blur.value) then
83 i:exp_blur(5);
84 end
85 return i
86 else
87 return Image()
88 end
89 end
91 function create_clock(file, col)
92 return function(w)
93 local h = math.floor(w*clock_height_ratio)
94 local i = Image(w,h)
95 i:clear()
96 i:draw_svg(Rect(0,0,w,h), file)
97 local s = i:create_shadow( w/16, col, Point(math.floor(w/7), math.floor(w/7)), Point(0, 0) )
98 s:draw_image(Rect(math.floor(w/14), math.floor(w/14), i.width, i.height), i)
99 return s
103 theme.clock_active_background = create_clock("active_clock.svg", "#ff8080")
104 theme.clock_inactive_background = create_clock("inactive_clock.svg", "#e0e0e0")
106 theme.clock_active_text = function(size)
107 return Brush("#000000")
110 theme.clock_inactive_text = function(size)
111 return Brush("#808080")
114 theme.clock_background_offset = function(w)
115 local d = math.floor(w/14)
116 return Point(-d, -d)
119 theme.clock_height = function(w)
120 return math.floor(w*clock_height_ratio)
123 theme.clock_caption_rect = function(w)
124 local h = math.floor(w*clock_height_ratio)
125 return Rect(w*0.02, h*0.22, w*0.4, h*0.38)
128 theme.clock_time_rect = function(w)
129 local h = math.floor(w*clock_height_ratio)
130 return Rect(w*0.4, h*0.08, w*0.58, h*0.66)
133 theme.clock_player_rect = function(w)
134 local h = math.floor(w*clock_height_ratio)
135 return Rect(w*0.14, h*0.68, w*0.69, h*0.28)
138 theme.name = "Cool"
139 theme.description = "Cool controls"
140 theme.variants = { "any[default]" }