Skip to content

Commit 284a627

Browse files
committed
Add clear button in dat viewer
1 parent ded0ba3 commit 284a627

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Export/Main.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ USE_DAT64 = true
99
local ipairs = ipairs
1010
local t_insert = table.insert
1111
local t_remove = table.remove
12+
local t_maxn = table.maxn
1213
local m_ceil = math.ceil
1314
local m_max = math.max
1415
local m_min = math.min
@@ -109,6 +110,17 @@ function main:Init()
109110
function printf(...)
110111
print(string.format(...))
111112
end
113+
114+
function clearScriptOutput()
115+
if t_maxn(self.scriptOutput) == 0 then
116+
return
117+
end
118+
local removed = -1
119+
while removed ~= nil do
120+
removed = t_remove(self.scriptOutput)
121+
end
122+
end
123+
112124
function processTemplateFile(name, inDir, outDir, directiveTable)
113125
local state = { }
114126
local out = io.open(outDir..name..".lua", "w")
@@ -198,6 +210,13 @@ function main:Init()
198210
return not self.curDatFile
199211
end
200212
}
213+
self.controls.clearOutput = new("ButtonControl", nil, {1190, 10, 100, 18}, "Clear", function()
214+
clearScriptOutput()
215+
end) {
216+
shown = function()
217+
return t_maxn(self.scriptOutput) > 0
218+
end
219+
}
201220

202221
self.controls.scriptList = new("ScriptListControl", nil, {270, 35, 100, 300}) {
203222
shown = function()

0 commit comments

Comments
 (0)