World config dialog: Use engine determined path for game mods

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

View File

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

View File

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

View File

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