World config dialog: Use engine determined path for game mods

This commit is contained in:
Kahrl 2013-08-19 13:55:04 +02:00
parent 8548bb75b6
commit 4242782dc2
3 changed files with 39 additions and 33 deletions

@ -155,22 +155,35 @@ function gamemgr.delete_mod(gamespec,modindex)
end
--------------------------------------------------------------------------------
function gamemgr.get_game_mods(gamespec)
function gamemgr.find_by_gameid(gameid)
for i=1,#gamemgr.games,1 do
if gamemgr.games[i].id == gameid then
return gamemgr.games[i], i
end
end
return nil, nil
end
local retval = ""
if gamespec.gamemods_path ~= nil and
--------------------------------------------------------------------------------
function gamemgr.get_game_mods(gamespec, retval)
if gamespec ~= nil and
gamespec.gamemods_path ~= nil and
gamespec.gamemods_path ~= "" then
local game_mods = {}
get_mods(gamespec.gamemods_path,game_mods)
get_mods(gamespec.gamemods_path, retval)
end
end
--------------------------------------------------------------------------------
function gamemgr.get_game_modlist(gamespec)
local retval = ""
local game_mods = {}
gamemgr.get_game_mods(gamespec, game_mods)
for i=1,#game_mods,1 do
if retval ~= "" then
retval = retval..","
end
retval = retval .. game_mods[i].name
end
end
return retval
end
@ -220,7 +233,7 @@ function gamemgr.tab()
"label[6,1.4;" .. fgettext("Mods:") .."]" ..
"button[9.7,1.5;2,0.2;btn_game_mgr_edit_game;" .. fgettext("edit game") .. "]" ..
"textlist[6,2;5.5,3.3;game_mgr_modlist;"
.. gamemgr.get_game_mods(current_game) ..";0]" ..
.. gamemgr.get_game_modlist(current_game) ..";0]" ..
"button[1,4.75;3.2,0.5;btn_game_mgr_new_game;" .. fgettext("new game") .. "]"
end
return retval
@ -243,7 +256,7 @@ function gamemgr.dialog_edit_game()
retval = retval ..
"textlist[0.5,0.5;4.5,4.3;mods_current;"
.. gamemgr.get_game_mods(current_game) ..";0]"
.. gamemgr.get_game_modlist(current_game) ..";0]"
retval = retval ..

@ -238,12 +238,10 @@ function menu.update_last_game()
return
end
for i=1,#gamemgr.games,1 do
if gamemgr.games[i].id == current_world.gameid then
local gamespec, i = gamemgr.find_by_gameid(current_world.gameid)
if i ~= nil then
menu.last_game = i
engine.setting_set("main_menu_last_game_idx",menu.last_game)
break
end
end
end

@ -529,9 +529,8 @@ function modmgr.get_worldconfig(worldpath)
end
--read gamemods
local gamemodpath = engine.get_gamepath() .. DIR_DELIM .. worldconfig.id .. DIR_DELIM .. "mods"
get_mods(gamemodpath,worldconfig.game_mods)
local gamespec = gamemgr.find_by_gameid(worldconfig.id)
gamemgr.get_game_mods(gamespec, worldconfig.game_mods)
return worldconfig
end
@ -871,12 +870,8 @@ function modmgr.preparemodlist(data)
end
--read game mods
if data.gameid ~= nil and
data.gameid ~= "" then
local gamemodpath = engine.get_gamepath() .. DIR_DELIM .. data.gameid .. DIR_DELIM .. "mods"
get_mods(gamemodpath,game_mods)
end
local gamespec = gamemgr.find_by_gameid(data.gameid)
gamemgr.get_game_mods(gamespec, game_mods)
for i=1,#game_mods,1 do
game_mods[i].typ = "game_mod"