Skip to content

Commit

Permalink
Add online content repository
Browse files Browse the repository at this point in the history
Replaces mods and texture pack tabs with a single content tab
  • Loading branch information
rubenwardy committed Apr 19, 2018
1 parent 36eb823 commit 87ad4d8
Show file tree
Hide file tree
Showing 46 changed files with 1,685 additions and 849 deletions.
5 changes: 3 additions & 2 deletions build/android/jni/Android.mk
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
60 changes: 30 additions & 30 deletions builtin/common/filterlist.lua
Expand Up @@ -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 = {}

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -209,7 +209,7 @@ function filterlist.size(self)
if self.m_processed_list == nil then
return 0
end

return #self.m_processed_list
end

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions builtin/common/misc_helpers.lua
Expand Up @@ -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
--------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion builtin/mainmenu/common.lua
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions builtin/mainmenu/dlg_config_world.lua
Expand Up @@ -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:") .. "]" ..
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

1 comment on commit 87ad4d8

@tacotexmex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like a mese lord! 🎉

Please sign in to comment.