-
Notifications
You must be signed in to change notification settings - Fork 1
/
osd_styler.lua
78 lines (60 loc) · 1.54 KB
/
osd_styler.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
--[[
Copyright: Ren Tatsumoto
License: GNU GPL, version 3 or later; https://www.gnu.org/licenses/gpl-3.0.html
]]
local OSD = {}
OSD.__index = OSD
function OSD:new()
return setmetatable({ messages = {} }, self)
end
function OSD:append(s)
table.insert(self.messages, tostring(s))
return self
end
function OSD:newline()
return self:append([[\N]])
end
function OSD:tab()
return self:append([[\h\h\h\h]])
end
function OSD:size(size)
return self:append('{\\fs'):append(size):append('}')
end
function OSD:align(number)
return self:append('{\\an'):append(number):append('}')
end
function OSD:get_text()
return table.concat(self.messages)
end
function OSD:color(code)
return self:append('{\\1c&H')
:append(code:sub(5, 6))
:append(code:sub(3, 4))
:append(code:sub(1, 2))
:append('&}')
end
function OSD:text(text)
return self:append(text)
end
function OSD:bold(s)
return self:append('{\\b1}'):append(s):append('{\\b0}')
end
function OSD:italics(s)
return self:append('{\\i1}'):append(s):append('{\\i0}')
end
function OSD:submenu(text)
return self:color('ffe1d0'):bold(text):color('ffffff')
end
function OSD:item(text)
return self:color('fef6dd'):bold(text):color('ffffff')
end
function OSD:selected(text)
return self:color('48a868'):bold(text):color('ffffff')
end
function OSD:red(text)
return self:color('ff0000'):bold(text):color('ffffff')
end
function OSD:blue(text)
return self:color('0693e3'):bold(text):color('ffffff')
end
return OSD