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-24 23:43:44 +02:00
|
|
|
qa_block.fs = smartfs.create("qa_block:block", function(state)
|
2016-11-06 13:58:04 +01:00
|
|
|
state:size(13,7.25)
|
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 13:58:04 +01:00
|
|
|
local textarea = state:textarea(5.0,1,8,6.25,"textarea","Source")
|
2016-11-06 01:38:44 +01:00
|
|
|
|
2016-10-24 23:43:44 +02:00
|
|
|
-- Listbox
|
2016-11-06 13:58:04 +01:00
|
|
|
local listbox = state:listbox(0,1,4.5,5.5,"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 13:58:04 +01:00
|
|
|
local runbutton = state:button(10,7,2,0.5,"Run","Run")
|
2016-10-24 23:43:44 +02:00
|
|
|
runbutton:onClick(function(self)
|
2016-11-15 21:39:21 +01:00
|
|
|
qa_block.do_source(textarea:getText(), "from textarea")
|
2016-10-24 23:43:44 +02:00
|
|
|
end)
|
2016-11-06 01:38:44 +01:00
|
|
|
|
2016-11-06 18:10:56 +01:00
|
|
|
if not qa_block.restricted_mode then
|
|
|
|
-- Refersh Button
|
|
|
|
local refreshbutton = state:button(0,7,2,0.5,"refresh","Refresh")
|
|
|
|
refreshbutton:onClick(function(self)
|
|
|
|
fileslist = qa_block.get_checks_list()
|
|
|
|
update_fileslist(listbox)
|
|
|
|
end)
|
2016-11-06 19:29:18 +01:00
|
|
|
else
|
|
|
|
state:label(0,7,"restricted","not trusted fallback mode")
|
2016-11-06 18:10:56 +01:00
|
|
|
end
|
2016-11-06 01:38:44 +01:00
|
|
|
|
2016-11-06 19:29:18 +01:00
|
|
|
state:button(5,7,2,0.5,"Close","Close", true)
|
2016-10-24 23:43:44 +02:00
|
|
|
return true
|
|
|
|
end)
|