-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path02_macros.lua
More file actions
executable file
·112 lines (90 loc) · 2.09 KB
/
02_macros.lua
File metadata and controls
executable file
·112 lines (90 loc) · 2.09 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Macro = {}
Macro.__index = Macro
function Macro:from(obj)
local instance = setmetatable({}, Macro)
instance.id = obj.No
instance.obj = obj
return instance
end
function Macro:get(id)
local obj = DataPool().Macros[id]
if obj == nil then
return nil
end
local instance = setmetatable({}, Macro)
instance.id = id
instance.obj = obj
return instance
end
function Macro:create(id, name)
local instance = setmetatable({}, Macro)
instance.id = id
Cmd(string.format("ClearAll; Store Macro %d", id))
local obj = DataPool().Macros[id] --DataPool().Macros:Create(id)
obj.Name = name
instance.obj = obj
return instance
end
function Macro:acquire(name)
local macro = Macro:from(DataPool().Macros:Acquire())
if name ~= nil then
macro:setName(name)
end
return macro
end
function Macro:getOrCreate(id, name)
local instance = Macro:get(id)
if instance == nil then
return Macro:create(id, name)
end
return instance
end
function Macro:address()
return ToAddr(self.obj, false)
end
function Macro:addLine(cmd)
local line = self.obj:Acquire()
line.Command = cmd
return MacroLine:from(line)
end
function Macro:setLineOrCreate(n, cmd)
local lineObj = self.obj[n]
while lineObj == nil do
self.obj:Acquire()
lineObj = self.obj[n]
end
local line = MacroLine:from(lineObj)
line:set(cmd)
return line
end
function Macro:setAppearance(appearance)
self.obj.Appearance = appearance.obj
end
function Macro:setName(name)
self.obj.Name = name
end
function Macro:Delete()
self.obj:Delete()
end
MacroLine = {}
MacroLine.__index = MacroLine
function MacroLine:from(line)
local instance = setmetatable({}, MacroLine)
instance.obj = line
return instance
end
function MacroLine:set(line)
self.obj.Command = line
end
function MacroLine:disable()
self.obj.Enabled = false
end
function MacroLine:enable()
self.obj.Enabled = false
end
function MacroLine:address()
return ToAddr(self.obj)
end
function MacroLine:delete()
self.obj:Delete()
end