Add Content pack menu
This commit is contained in:
parent
9c911beec4
commit
1d87bcaf6e
24
res/layouts/pages/content_menu.xml
Normal file
24
res/layouts/pages/content_menu.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<container size='1000,480' color='#0F1E2DB2' padding='8' interval='5' context='menu'>
|
||||
<panel id='contents' pos='15,15' size='440,390' color='0' max-length='406' scrollable='true'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button pos='15,430' size='440,40' onclick='menu:back()'>@Back</button>
|
||||
|
||||
<panel id='content_info' pos='485,15' size='440,406' color='0' max-length='406' scrollable='true'>
|
||||
<!-- content is generated in script -->
|
||||
<label>@Creator</label>
|
||||
<label id='author' multiline="true" color='#8C8C8C'>None</label>
|
||||
<label></label>
|
||||
<label></label>
|
||||
<label>@Version</label>
|
||||
<label id='version' multiline="true" color='#8C8C8C'>None</label>
|
||||
<label></label>
|
||||
<label></label>
|
||||
<label>@Description</label>
|
||||
<label id='description' multiline="true" color='#8C8C8C'>None</label>
|
||||
<label></label>
|
||||
<label></label>
|
||||
<label>@Dependencies</label>
|
||||
<label id='dependencies' multiline="true" color='#8C8C8C'>None</label>
|
||||
</panel>
|
||||
</container>
|
||||
51
res/layouts/pages/content_menu.xml.lua
Normal file
51
res/layouts/pages/content_menu.xml.lua
Normal file
@ -0,0 +1,51 @@
|
||||
function on_open(params)
|
||||
if params then
|
||||
mode = params.mode
|
||||
end
|
||||
refresh()
|
||||
end
|
||||
|
||||
function place_pack(panel, packinfo, callback)
|
||||
if packinfo.error then
|
||||
callback = nil
|
||||
end
|
||||
if packinfo.has_indices then
|
||||
packinfo.id_verbose = packinfo.id.."*"
|
||||
else
|
||||
packinfo.id_verbose = packinfo.id
|
||||
end
|
||||
packinfo.callback = callback
|
||||
panel:add(gui.template("pack", packinfo))
|
||||
if not callback then
|
||||
document["pack_"..packinfo.id].enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
function open_pack(id)
|
||||
local packinfo = pack.get_info(id)
|
||||
|
||||
if packinfo['dependencies'] == nil then document.dependencies.text = 'None' else document.dependencies.text = table.tostring(packinfo['dependencies']) end
|
||||
if packinfo['creator'] == '' then document.author.text = 'None' else document.author.text = packinfo['creator'] end
|
||||
if packinfo['version'] == nil then document.version.text = 'None' else document.version.text = packinfo['version'] end
|
||||
if packinfo['description'] == nil then document.description.text = 'None' else document.description.text = packinfo['description'] end
|
||||
end
|
||||
|
||||
function refresh()
|
||||
local packs_installed = pack.get_installed()
|
||||
local packs_available = pack.get_available()
|
||||
|
||||
for i,k in ipairs(packs_available) do
|
||||
table.insert(packs_installed, k)
|
||||
end
|
||||
|
||||
local contents = document.contents
|
||||
contents:clear()
|
||||
|
||||
for i,id in ipairs(packs_installed) do
|
||||
local packinfo = pack.get_info(id)
|
||||
|
||||
packinfo.index = i
|
||||
local callback = string.format('open_pack("%s")', id)
|
||||
place_pack(contents, packinfo, callback)
|
||||
end
|
||||
end
|
||||
@ -3,5 +3,6 @@
|
||||
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
|
||||
</panel>
|
||||
<button onclick='menu.page="settings"'>@Settings</button>
|
||||
<button onclick='menu.page="content_menu"'>@Contents Menu</button>
|
||||
<button onclick='core.quit()'>@Quit</button>
|
||||
</panel>
|
||||
|
||||
@ -6,6 +6,10 @@ Cancel=Отмена
|
||||
Back=Назад
|
||||
Continue=Продолжить
|
||||
Add=Добавить
|
||||
Version=Версия
|
||||
Creator=Автор
|
||||
Dependencies=Зависимости
|
||||
Description=Описание
|
||||
Converting world...=Выполняется конвертация мира...
|
||||
|
||||
error.pack-not-found=Не удалось найти пакет
|
||||
@ -31,6 +35,7 @@ menu.Page not found=Страница не найдена
|
||||
menu.Quit=Выход
|
||||
menu.Save and Quit to Menu=Сохранить и Выйти в Меню
|
||||
menu.Settings=Настройки
|
||||
menu.Contents Menu=Меню контентпаков
|
||||
|
||||
world.Seed=Зерно
|
||||
world.Name=Название
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user