Fix 'Download complete' dialog in the mods store

This commit is contained in:
ngosang 2015-02-11 17:00:20 +01:00 committed by Loic Blot
parent a9355284b5
commit 704453ff12

@ -122,35 +122,36 @@ end
function modstore.showdownloading(title) function modstore.showdownloading(title)
local new_dlg = dialog_create("store_downloading", local new_dlg = dialog_create("store_downloading",
function(data) function(data)
return "size[6,2]label[0.25,0.75;" .. fgettext("Downloading") .. return "size[6,2]label[0.25,0.75;" ..
" " .. data.title .. " " .. fgettext("Downloading $1, please wait...", data.title) .. "]"
fgettext("please wait...") .. "]"
end, end,
function(this,fields) function(this,fields)
if fields["btn_hidden_close_download"] ~= nil then if fields["btn_hidden_close_download"] ~= nil then
if fields["btn_hidden_close_download"].successfull then if fields["btn_hidden_close_download"].successfull then
modstore.lastmodentry = fields["btn_hidden_close_download"] modstore.lastmodentry = fields["btn_hidden_close_download"]
modstore.successfulldialog() modstore.successfulldialog(this)
else else
this.parent:show()
this:delete()
modstore.lastmodtitle = "" modstore.lastmodtitle = ""
end end
this:delete()
return true return true
end end
return false return false
end, end,
nil, nil)
modstore.tv_store)
new_dlg:set_parent(modstore.tv_store)
modstore.tv_store:hide()
new_dlg.data.title = title new_dlg.data.title = title
new_dlg:show() new_dlg:show()
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- @function [parent=#modstore] successfulldialog -- @function [parent=#modstore] successfulldialog
function modstore.successfulldialog() function modstore.successfulldialog(downloading_dlg)
local new_dlg = dialog_create("store_downloading", local new_dlg = dialog_create("store_downloading",
function(data) function(data)
local retval = "" local retval = ""
@ -158,18 +159,16 @@ function modstore.successfulldialog()
if modstore.lastmodentry ~= nil then if modstore.lastmodentry ~= nil then
retval = retval .. "label[0,0.25;" .. fgettext("Successfully installed:") .. "]" retval = retval .. "label[0,0.25;" .. fgettext("Successfully installed:") .. "]"
retval = retval .. "label[3,0.25;" .. modstore.lastmodentry.moddetails.title .. "]" retval = retval .. "label[3,0.25;" .. modstore.lastmodentry.moddetails.title .. "]"
retval = retval .. "label[0,0.75;" .. fgettext("Shortname:") .. "]" retval = retval .. "label[0,0.75;" .. fgettext("Shortname:") .. "]"
retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]" retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]"
end end
retval = retval .. "button[2.5,1.5;1,0.5;btn_confirm_mod_successfull;" .. fgettext("ok") .. "]" retval = retval .. "button[2.2,1.5;1.5,0.5;btn_confirm_mod_successfull;" .. fgettext("Ok") .. "]"
return retval
end, end,
function(this,fields) function(this,fields)
if fields["btn_confirm_mod_successfull"] ~= nil then if fields["btn_confirm_mod_successfull"] ~= nil then
this.parent:show() this.parent:show()
this:hide() downloading_dlg:delete()
this:delete() this:delete()
return true return true
@ -177,10 +176,10 @@ function modstore.successfulldialog()
return false return false
end, end,
nil, nil)
modstore.tv_store)
new_dlg.data.title = title new_dlg:set_parent(modstore.tv_store)
modstore.tv_store:hide()
new_dlg:show() new_dlg:show()
end end
@ -217,7 +216,9 @@ function modstore.handle_buttons(parent, fields, name, data)
end end
if fields["btn_modstore_close"] then if fields["btn_modstore_close"] then
local maintab = ui.find_by_name("maintab")
parent:hide() parent:hide()
maintab:show()
return true return true
end end
@ -228,12 +229,7 @@ function modstore.handle_buttons(parent, fields, name, data)
for i=1,#modstore.modlist_unsorted.data,1 do for i=1,#modstore.modlist_unsorted.data,1 do
if modstore.modlist_unsorted.data[i].id == modid then if modstore.modlist_unsorted.data[i].id == modid then
local moddetails = modstore.modlist_unsorted.data[i].details local moddetails = modstore.modlist_unsorted.data[i].details
modstore.lastmodtitle = moddetails.title
if modstore.lastmodtitle ~= "" then
modstore.lastmodtitle = modstore.lastmodtitle .. ", "
end
modstore.lastmodtitle = modstore.lastmodtitle .. moddetails.title
if not core.handle_async( if not core.handle_async(
function(param) function(param)
@ -281,7 +277,7 @@ function modstore.handle_buttons(parent, fields, name, data)
texturename = modstore.modlist_unsorted.data[i].texturename texturename = modstore.modlist_unsorted.data[i].texturename
}, },
function(result) function(result)
print("Result from async: " .. dump(result.successfull)) --print("Result from async: " .. dump(result.successfull))
if result.successfull then if result.successfull then
modmgr.installmod(result.filename,result.moddetails.basename) modmgr.installmod(result.filename,result.moddetails.basename)
os.remove(result.filename) os.remove(result.filename)
@ -299,7 +295,7 @@ function modstore.handle_buttons(parent, fields, name, data)
print("ERROR: async event failed") print("ERROR: async event failed")
gamedata.errormessage = "Failed to download " .. modstore.lastmodtitle gamedata.errormessage = "Failed to download " .. modstore.lastmodtitle
end end
parent:hide()
modstore.showdownloading(modstore.lastmodtitle) modstore.showdownloading(modstore.lastmodtitle)
return true return true
end end