2016-10-24 23:43:44 +02:00
|
|
|
-- the smartfs.lua is loaded
|
|
|
|
|
2016-10-25 15:33:39 +02:00
|
|
|
--- temporary provide smartfs as builtin, till the needed changes are upstream
|
|
|
|
local smartfs = qa_block.smartfs
|
|
|
|
--- temporary end
|
|
|
|
|
2016-11-06 01:38:44 +01:00
|
|
|
local fileslist
|
|
|
|
|
|
|
|
local function update_fileslist(listbox)
|
|
|
|
if not fileslist then -- initial update the fileslist
|
|
|
|
fileslist = qa_block.get_checks_list()
|
|
|
|
end
|
|
|
|
listbox:clearItems()
|
|
|
|
if fileslist then
|
|
|
|
for idx, file in ipairs(fileslist) do
|
|
|
|
listbox:addItem(file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-25 15:33:39 +02:00
|
|
|
|
2016-10-24 23:43:44 +02:00
|
|
|
qa_block.fs = smartfs.create("qa_block:block", function(state)
|
|
|
|
state:size(10,7)
|
2016-11-05 18:27:46 +01:00
|
|
|
state:label(0,0,"header","Please select a mod check which you want to perform.")
|
2016-10-24 23:43:44 +02:00
|
|
|
if state.location.type == "nodemeta" then
|
2016-11-05 18:27:46 +01:00
|
|
|
state:label(0,0.5,"header2", "Node position: ".. minetest.pos_to_string(state.location.pos))
|
|
|
|
elseif state.location.type == "player" then
|
|
|
|
state:label(0,0.5,"header2", "Player: "..state.location.player)
|
2016-10-24 23:43:44 +02:00
|
|
|
end
|
2016-11-06 01:38:44 +01:00
|
|
|
|
|
|
|
-- Text area for the info
|
2016-11-06 12:31:39 +01:00
|
|
|
local textarea = state:textarea(4.5,1,5.75,6.25,"textarea","Source")
|
2016-11-06 01:38:44 +01:00
|
|
|
|
2016-10-24 23:43:44 +02:00
|
|
|
-- Listbox
|
2016-11-06 12:31:39 +01:00
|
|
|
local listbox = state:listbox(0,1,4,5.25,"fileslist")
|
2016-11-06 01:38:44 +01:00
|
|
|
update_fileslist(listbox)
|
|
|
|
|
2016-11-06 12:31:39 +01:00
|
|
|
listbox:onClick(function(self, state, index)
|
|
|
|
textarea:setText(qa_block.get_source(self:getItem(index)))
|
2016-11-06 01:38:44 +01:00
|
|
|
end)
|
2016-10-24 23:43:44 +02:00
|
|
|
|
|
|
|
listbox:onDoubleClick(function(self,state, index)
|
2016-11-06 12:31:39 +01:00
|
|
|
textarea:setText(qa_block.get_source(self:getItem(index)))
|
2016-10-24 23:43:44 +02:00
|
|
|
qa_block.do_module(self:getItem(index))
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Run Button
|
2016-11-06 12:31:39 +01:00
|
|
|
local runbutton = state:button(8,6.5,2,0.5,"Run","Run")
|
2016-10-24 23:43:44 +02:00
|
|
|
runbutton:onClick(function(self)
|
2016-11-06 12:31:39 +01:00
|
|
|
qa_block.do_source(textarea:getText())
|
2016-10-24 23:43:44 +02:00
|
|
|
end)
|
2016-11-06 01:38:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- Refersh Button
|
2016-11-06 12:31:39 +01:00
|
|
|
local refreshbutton = state:button(0,6.5,2,0.5,"refresh","Refresh")
|
2016-11-06 01:38:44 +01:00
|
|
|
refreshbutton:onClick(function(self)
|
|
|
|
fileslist = qa_block.get_checks_list()
|
|
|
|
update_fileslist(listbox)
|
|
|
|
end)
|
|
|
|
|
2016-11-06 12:31:39 +01:00
|
|
|
state:button(2,6.5,2,0.5,"Close","Close", true)
|
2016-10-24 23:43:44 +02:00
|
|
|
return true
|
|
|
|
end)
|