mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Improve UX when no game exists and drop default_game
(#13550)
This commit is contained in:
parent
5bfc5d44c0
commit
a88e61c2cf
9 changed files with 78 additions and 80 deletions
|
@ -18,7 +18,11 @@
|
|||
|
||||
local packages_raw, packages
|
||||
|
||||
local function get_formspec(tabview, name, tabdata)
|
||||
local function on_change(type)
|
||||
if type ~= "ENTER" then
|
||||
return
|
||||
end
|
||||
|
||||
if not pkgmgr.global_mods then
|
||||
pkgmgr.refresh_globals()
|
||||
end
|
||||
|
@ -26,25 +30,25 @@ local function get_formspec(tabview, name, tabdata)
|
|||
pkgmgr.update_gamelist()
|
||||
end
|
||||
|
||||
if not packages then
|
||||
packages_raw = {}
|
||||
table.insert_all(packages_raw, pkgmgr.games)
|
||||
table.insert_all(packages_raw, pkgmgr.get_texture_packs())
|
||||
table.insert_all(packages_raw, pkgmgr.global_mods:get_list())
|
||||
packages_raw = {}
|
||||
table.insert_all(packages_raw, pkgmgr.games)
|
||||
table.insert_all(packages_raw, pkgmgr.get_texture_packs())
|
||||
table.insert_all(packages_raw, pkgmgr.global_mods:get_list())
|
||||
|
||||
local function get_data()
|
||||
return packages_raw
|
||||
end
|
||||
|
||||
local function is_equal(element, uid) --uid match
|
||||
return (element.type == "game" and element.id == uid) or
|
||||
element.name == uid
|
||||
end
|
||||
|
||||
packages = filterlist.create(get_data, pkgmgr.compare_package,
|
||||
is_equal, nil, {})
|
||||
local function get_data()
|
||||
return packages_raw
|
||||
end
|
||||
|
||||
local function is_equal(element, uid) --uid match
|
||||
return (element.type == "game" and element.id == uid) or
|
||||
element.name == uid
|
||||
end
|
||||
|
||||
packages = filterlist.create(get_data, pkgmgr.compare_package,
|
||||
is_equal, nil, {})
|
||||
end
|
||||
|
||||
local function get_formspec(tabview, name, tabdata)
|
||||
if not tabdata.selected_pkg then
|
||||
tabdata.selected_pkg = 1
|
||||
end
|
||||
|
@ -227,5 +231,5 @@ return {
|
|||
caption = fgettext("Content"),
|
||||
cbf_formspec = get_formspec,
|
||||
cbf_button_handler = handle_buttons,
|
||||
on_change = pkgmgr.update_gamelist
|
||||
on_change = on_change
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue