Permalink
Browse files

Add in-game online content repository

Replaces mods and texture pack tabs with a single content tab
  • Loading branch information...
rubenwardy committed Apr 17, 2018
1 parent 36eb823 commit 3ea6acead817162cf7a42e1a9efab77fa3b925de
Showing with 1,685 additions and 849 deletions.
  1. +3 −2 build/android/jni/Android.mk
  2. +30 −30 builtin/common/filterlist.lua
  3. +10 −0 builtin/common/misc_helpers.lua
  4. +1 −1 builtin/mainmenu/common.lua
  5. +5 −5 builtin/mainmenu/dlg_config_world.lua
  6. +451 −0 builtin/mainmenu/dlg_contentstore.lua
  7. +8 −8 builtin/mainmenu/dlg_create_world.lua
  8. +24 −24 builtin/mainmenu/{dlg_delete_mod.lua → dlg_delete_content.lua}
  9. +8 −8 builtin/mainmenu/dlg_rename_modpack.lua
  10. +2 −2 builtin/mainmenu/dlg_settings_advanced.lua
  11. +0 −83 builtin/mainmenu/gamemgr.lua
  12. +7 −10 builtin/mainmenu/init.lua
  13. +256 −121 builtin/mainmenu/{modmgr.lua → pkgmgr.lua}
  14. +217 −0 builtin/mainmenu/tab_content.lua
  15. +17 −17 builtin/mainmenu/tab_local.lua
  16. +0 −151 builtin/mainmenu/tab_mods.lua
  17. +0 −135 builtin/mainmenu/tab_texturepacks.lua
  18. +7 −4 doc/lua_api.txt
  19. +54 −31 doc/menu_lua_api.txt
  20. +10 −1 doc/texture_packs.txt
  21. +2 −2 src/CMakeLists.txt
  22. +1 −1 src/client.cpp
  23. +7 −0 src/content/CMakeLists.txt
  24. +108 −0 src/content/content.cpp
  25. +33 −0 src/content/content.h
  26. +70 −53 src/{ → content}/mods.cpp
  27. +22 −26 src/{ → content}/mods.h
  28. +68 −0 src/content/packages.cpp
  29. +49 −0 src/content/packages.h
  30. +76 −61 src/{subgame.cpp → content/subgames.cpp}
  31. +25 −35 src/{subgame.h → content/subgames.h}
  32. +1 −1 src/convert_json.cpp
  33. +1 −0 src/defaultsettings.cpp
  34. +1 −1 src/httpfetch.cpp
  35. +1 −1 src/script/cpp_api/s_base.cpp
  36. +1 −1 src/script/lua_api/l_base.cpp
  37. +96 −24 src/script/lua_api/l_mainmenu.cpp
  38. +4 −1 src/script/lua_api/l_mainmenu.h
  39. +1 −1 src/script/lua_api/l_storage.cpp
  40. +1 −1 src/script/scripting_mainmenu.cpp
  41. +1 −1 src/server.cpp
  42. +2 −2 src/server.h
  43. +1 −1 src/server/mods.cpp
  44. +1 −1 src/server/mods.h
  45. +1 −1 src/serverlist.h
  46. +1 −1 src/unittest/test.cpp
@@ -130,6 +130,9 @@ LOCAL_SRC_FILES := \
jni/src/content_mapnode.cpp \
jni/src/content_nodemeta.cpp \
jni/src/content_sao.cpp \
jni/src/content/contentdb.cpp \
jni/src/content/mods.cpp \
jni/src/content/subgames.cpp \
jni/src/convert_json.cpp \
jni/src/craftdef.cpp \
jni/src/database/database-dummy.cpp \
@@ -198,7 +201,6 @@ LOCAL_SRC_FILES := \
jni/src/mapgen/mg_ore.cpp \
jni/src/mapgen/mg_schematic.cpp \
jni/src/minimap.cpp \
jni/src/mods.cpp \
jni/src/modchannels.cpp \
jni/src/nameidmapping.cpp \
jni/src/nodedef.cpp \
@@ -229,7 +231,6 @@ LOCAL_SRC_FILES := \
jni/src/shader.cpp \
jni/src/sky.cpp \
jni/src/staticobject.cpp \
jni/src/subgame.cpp \
jni/src/tileanimation.cpp \
jni/src/translation.cpp \
jni/src/tool.cpp \
@@ -47,17 +47,17 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa

assert((raw_fct ~= nil) and (type(raw_fct) == "function"))
assert((compare_fct ~= nil) and (type(compare_fct) == "function"))

local self = {}

self.m_raw_list_fct = raw_fct
self.m_compare_fct = compare_fct
self.m_filter_fct = filter_fct
self.m_uid_match_fct = uid_match_fct

self.m_filtercriteria = nil
self.m_fetch_param = fetch_param

self.m_sortmode = "none"
self.m_sort_list = {}

@@ -79,7 +79,7 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
self.refresh = filterlist.refresh

filterlist.process(self)

return self
end

@@ -128,49 +128,49 @@ function filterlist.get_raw_element(self,idx)
if type(idx) ~= "number" then
idx = tonumber(idx)
end

if idx ~= nil and idx > 0 and idx <= #self.m_raw_list then
return self.m_raw_list[idx]
end

return nil
end

--------------------------------------------------------------------------------
function filterlist.get_raw_index(self,listindex)
assert(self.m_processed_list ~= nil)

if listindex ~= nil and listindex > 0 and
listindex <= #self.m_processed_list then
local entry = self.m_processed_list[listindex]

for i,v in ipairs(self.m_raw_list) do

if self.m_compare_fct(v,entry) then
return i
end
end
end

return 0
end

--------------------------------------------------------------------------------
function filterlist.get_current_index(self,listindex)
assert(self.m_processed_list ~= nil)

if listindex ~= nil and listindex > 0 and
listindex <= #self.m_raw_list then
local entry = self.m_raw_list[listindex]

for i,v in ipairs(self.m_processed_list) do

if self.m_compare_fct(v,entry) then
return i
end
end
end

return 0
end

@@ -183,23 +183,23 @@ function filterlist.process(self)
self.m_processed_list = self.m_raw_list
return
end

self.m_processed_list = {}

for k,v in pairs(self.m_raw_list) do
if self.m_filtercriteria == nil or
self.m_filter_fct(v,self.m_filtercriteria) then
self.m_processed_list[#self.m_processed_list + 1] = v
end
end

if self.m_sortmode == "none" then
return
end

if self.m_sort_list[self.m_sortmode] ~= nil and
type(self.m_sort_list[self.m_sortmode]) == "function" then

self.m_sort_list[self.m_sortmode](self)
end
end
@@ -209,7 +209,7 @@ function filterlist.size(self)
if self.m_processed_list == nil then
return 0
end

return #self.m_processed_list
end

@@ -233,8 +233,8 @@ function filterlist.raw_index_by_uid(self, uid)
elementidx = i
end
end


-- If there are more elements than one with same name uid can't decide which
-- one is meant. self shouldn't be possible but just for sure.
if elementcount > 1 then
@@ -254,11 +254,11 @@ function compare_worlds(world1,world2)
if world1.path ~= world2.path then
return false
end

if world1.name ~= world2.name then
return false
end

if world1.gameid ~= world2.gameid then
return false
end
@@ -288,11 +288,11 @@ function sort_mod_list(self)

table.sort(self.m_processed_list, function(a, b)
-- Show game mods at bottom
if a.typ ~= b.typ then
if b.typ == "game" then
return a.typ ~= "game_mod"
if a.type ~= b.type or a.loc ~= b.loc then
if b.type == "game" then
return a.loc ~= "game"
end
return b.typ == "game_mod"
return b.loc == "game"
end
-- If in same or no modpack, sort by name
if a.modpack == b.modpack then
@@ -308,7 +308,7 @@ function sort_mod_list(self)
elseif b.name == a.modpack then
return false
end

local name_a = a.modpack or a.name
local name_b = b.modpack or b.name
if name_a:lower() == name_b:lower() then
@@ -551,6 +551,16 @@ function table.copy(t, seen)
end
return n
end


function table.insert_all(t, other)
for i=1, #other do
t[#t + 1] = other[i]
end
return t
end


--------------------------------------------------------------------------------
-- mainmenu only functions
--------------------------------------------------------------------------------
@@ -41,7 +41,7 @@ local function render_client_count(n)
end

local function configure_selected_world_params(idx)
local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
local worldconfig = pkgmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
core.settings:set("creative_mode", worldconfig.creative_mode)
end
@@ -35,7 +35,7 @@ local function get_formspec(data)
mod = {name=""}
end

local hard_deps, soft_deps = modmgr.get_dependencies(mod.path)
local hard_deps, soft_deps = pkgmgr.get_dependencies(mod.path)

retval = retval ..
"label[0,0.7;" .. fgettext("Mod:") .. "]" ..
@@ -88,7 +88,7 @@ local function get_formspec(data)
retval = retval ..
"tablecolumns[color;tree;text]" ..
"table[5.5,0.75;5.75,6;world_config_modlist;"
retval = retval .. modmgr.render_modlist(data.list)
retval = retval .. pkgmgr.render_packagelist(data.list)
retval = retval .. ";" .. data.selected_mod .."]"

return retval
@@ -237,7 +237,7 @@ function create_configure_world_dlg(worldidx)
dlg.data.worldspec = core.get_worlds()[worldidx]
if dlg.data.worldspec == nil then dlg:delete() return nil end

dlg.data.worldconfig = modmgr.get_worldconfig(dlg.data.worldspec.path)
dlg.data.worldconfig = pkgmgr.get_worldconfig(dlg.data.worldspec.path)

if dlg.data.worldconfig == nil or dlg.data.worldconfig.id == nil or
dlg.data.worldconfig.id == "" then
@@ -247,8 +247,8 @@ function create_configure_world_dlg(worldidx)
end

dlg.data.list = filterlist.create(
modmgr.preparemodlist, --refresh
modmgr.comparemod, --compare
pkgmgr.preparemodlist, --refresh
pkgmgr.comparemod, --compare
function(element,uid) --uid match
if element.name == uid then
return true
Oops, something went wrong.

0 comments on commit 3ea6ace

Please sign in to comment.