Merge branch 'MihailRis:main' into main
This commit is contained in:
@@ -185,8 +185,14 @@ function refresh()
|
||||
end
|
||||
end
|
||||
|
||||
local packids = {unpack(packs_installed)}
|
||||
for i,k in ipairs(packs_available) do
|
||||
table.insert(packids, k)
|
||||
end
|
||||
local packinfos = pack.get_info(packids)
|
||||
|
||||
for i,id in ipairs(packs_installed) do
|
||||
local packinfo = pack.get_info(id)
|
||||
local packinfo = packinfos[id]
|
||||
packinfo.index = i
|
||||
callback = not table.has(base_packs, id) and string.format('move_pack("%s")', id) or nil
|
||||
packinfo.error = check_dependencies(packinfo)
|
||||
@@ -194,7 +200,7 @@ function refresh()
|
||||
end
|
||||
|
||||
for i,id in ipairs(packs_available) do
|
||||
local packinfo = pack.get_info(id)
|
||||
local packinfo = packinfos[id]
|
||||
packinfo.index = i
|
||||
callback = string.format('move_pack("%s")', id)
|
||||
packinfo.error = check_dependencies(packinfo)
|
||||
|
||||
@@ -247,8 +247,9 @@ function refresh()
|
||||
local contents = document.contents
|
||||
contents:clear()
|
||||
|
||||
local packinfos = pack.get_info(packs_installed)
|
||||
for i, id in ipairs(packs_installed) do
|
||||
local packinfo = pack.get_info(id)
|
||||
local packinfo = packinfos[id]
|
||||
|
||||
packinfo.id = id
|
||||
packs_installed[i] = {packinfo.id, packinfo.title}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
<button onclick='menu.page="worlds"'>@Worlds</button>
|
||||
<button onclick='menu.page="scripts"'>@Scripts</button>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='menu.page="content_menu"'>@Contents Menu</button>
|
||||
<button onclick='core.quit()'>@Quit</button>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<panel size='400' color='#00000030' context='menu'>
|
||||
<container size='400,32'>
|
||||
<label pos='2,10'>@Scripts</label>
|
||||
<image onclick='refresh()' interactive='true' src='gui/refresh'
|
||||
size='32' gravity='top-right'
|
||||
color='#FFFFFF80' hover-color='#FFFFFF10'/>
|
||||
</container>
|
||||
<panel id="list" size='400' interval='1' color='0' max-length='300'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
@@ -0,0 +1,40 @@
|
||||
function run_script(path)
|
||||
debug.log("starting application script "..path)
|
||||
|
||||
local code = file.read(path)
|
||||
local chunk, err = loadstring(code, path)
|
||||
if chunk == nil then
|
||||
error(err)
|
||||
end
|
||||
setfenv(chunk, setmetatable({app=__vc_app}, {__index=_G}))
|
||||
start_coroutine(chunk, path)
|
||||
end
|
||||
|
||||
function refresh()
|
||||
document.list:clear()
|
||||
|
||||
local available = pack.get_available()
|
||||
local infos = pack.get_info(available)
|
||||
for _, name in ipairs(available) do
|
||||
local info = infos[name]
|
||||
local scripts_dir = info.path.."/scripts/app"
|
||||
if not file.exists(scripts_dir) then
|
||||
goto continue
|
||||
end
|
||||
local files = file.list(scripts_dir)
|
||||
for _, filename in ipairs(files) do
|
||||
if file.ext(filename) == "lua" then
|
||||
document.list:add(gui.template("script", {
|
||||
pack=name,
|
||||
name=file.stem(filename),
|
||||
path=filename
|
||||
}))
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function on_open()
|
||||
refresh()
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
<button color='#10305080' hover-color='#10305040' onclick='run_script("%{path}")'>
|
||||
%{name} [%{pack}]
|
||||
</button>
|
||||
Reference in New Issue
Block a user