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)
-
- for i=1,#game_mods,1 do
- if retval ~= "" then
- retval = retval..","
- end
- retval = retval .. game_mods[i].name
- end
+ 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
return retval
end
"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
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 ..
if current_world == nil then
return
end
-
- for i=1,#gamemgr.games,1 do
- if gamemgr.games[i].id == current_world.gameid then
- menu.last_game = i
- engine.setting_set("main_menu_last_game_idx",menu.last_game)
- break
- end
+
+ 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)
end
end
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
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"