---------------------------------------------------------------------------------
-function cleanup_path(temppath)
-
- local parts = temppath:split("-")
- temppath = ""
- for i=1,#parts,1 do
- if temppath ~= "" then
- temppath = temppath .. "_"
- end
- temppath = temppath .. parts[i]
- end
-
- parts = temppath:split(".")
- temppath = ""
- for i=1,#parts,1 do
- if temppath ~= "" then
- temppath = temppath .. "_"
- end
- temppath = temppath .. parts[i]
- end
-
- parts = temppath:split("'")
- temppath = ""
- for i=1,#parts,1 do
- if temppath ~= "" then
- temppath = temppath .. ""
- end
- temppath = temppath .. parts[i]
- end
-
- parts = temppath:split(" ")
- temppath = ""
- for i=1,#parts,1 do
- if temppath ~= "" then
- temppath = temppath
- end
- temppath = temppath .. parts[i]
- end
-
- return temppath
-end
-
---------------------------------------------------------------------------------
-
-function menu.set_texture(identifier,gamedetails)
- local texture_set = false
- if menu.texturepack ~= nil and gamedetails ~= nil then
- local path = menu.basetexturedir ..
- gamedetails.id .. "_menu_" .. identifier .. ".png"
-
- if engine.set_background(identifier,path) then
- texture_set = true
- end
- end
-
- if not texture_set and gamedetails ~= nil then
- local path = gamedetails.path .. DIR_DELIM .."menu" ..
- DIR_DELIM .. identifier .. ".png"
- if engine.set_background(identifier,path) then
- texture_set = true
- end
- end
-
- if not texture_set then
- local path = menu.basetexturedir .. DIR_DELIM .."menu_" ..
- identifier .. ".png"
- if engine.set_background(identifier,path) then
- texture_set = true
- end
- end
-
- if not texture_set then
- local path = menu.defaulttexturedir .. DIR_DELIM .."menu_" ..
- identifier .. ".png"
- engine.set_background(identifier,path)
- end
-end
-
---------------------------------------------------------------------------------
-function menu.update_gametype()
-
-
-
- if (menu.game_last_check == nil or
- menu.game_last_check ~= menu.last_game) and
- tabbuilder.current_tab == "singleplayer" then
-
- local gamedetails = menu.lastgame()
- engine.set_topleft_text(gamedetails.name)
- worldlist.set_gamefilter(gamedetails.id)
-
- --background
- local background_set = false
- if menu.texturepack ~= nil then
- local path_background_texture = menu.basetexturedir ..
- gamedetails.id .. "_menu_background.png"
-
- if engine.set_background("background",path_background_texture) then
- background_set = true
- engine.set_clouds(false)
- end
- end
-
- if not background_set then
- local path_background_texture = gamedetails.path .. DIR_DELIM .."menu" ..
- DIR_DELIM .. "background.png"
- if engine.set_background("background",path_background_texture) then
- background_set = true
- engine.set_clouds(false)
- end
- end
-
- if not background_set then
- engine.set_clouds(true)
- end
-
- menu.set_texture("overlay",gamedetails)
- menu.set_texture("header",gamedetails)
- menu.set_texture("footer",gamedetails)
-
- menu.game_last_check = menu.last_game
- else
- if menu.game_last_check ~= menu.last_game then
- menu.game_last_check = menu.last_game
- menu.reset_gametype()
- end
- end
-end
-
---------------------------------------------------------------------------------
-function menu.reset_gametype()
- worldlist.set_gamefilter(nil)
- menu.game_last_check = nil
-
- local path_background_texture = menu.basetexturedir .. "menu_background.png"
-
- if engine.set_background("background",path_background_texture) then
- background_set = true
- engine.set_clouds(false)
- else
- engine.set_clouds(true)
- end
-
- menu.set_texture("overlay",nil)
- menu.set_texture("header",nil)
- menu.set_texture("footer",nil)
- engine.set_topleft_text("")
-end
-
---------------------------------------------------------------------------------
-function get_last_folder(text,count)
- local parts = text:split(DIR_DELIM)
-
- if count == nil then
- return parts[#parts]
- end
-
- local retval = ""
- for i=1,count,1 do
- retval = retval .. parts[#parts - (count-i)] .. DIR_DELIM
- end
-
- return retval
-end
-