iw7-mod/data/cdata/ui_scripts/Mods/ModDownload.lua

41 lines
1.2 KiB
Lua
Raw Normal View History

2024-08-06 05:52:32 -04:00
function ModDownloadCancel(arg0, arg1)
download.abort()
LUI.FlowManager.RequestLeaveMenu(arg0)
end
2024-08-06 05:52:32 -04:00
function ModDownloadPopup(arg0, arg1)
local popup = MenuBuilder.BuildRegisteredType("FenceDialogPopup", {
message = "Downloading files...",
controllerIndex = arg1.controllerIndex,
onCancel = ModDownloadCancel
})
popup.id = "ModDownloadPopup"
local file = ""
popup:registerEventHandler("mod_download_set_file", function(element, event)
file = event.request.name
popup.Message:setText(string.format("Downloading %s...", file))
end)
popup:registerEventHandler("mod_download_progress", function(element, event)
popup.Message:setText(string.format("Downloading %s (%i%%)...", file, math.floor(event.fraction * 100)))
end)
popup:registerEventHandler("mod_download_done", function()
LUI.FlowManager.RequestLeaveMenu(popup)
end)
2024-08-06 05:52:32 -04:00
return popup
end
2024-08-06 05:52:32 -04:00
MenuBuilder.registerType("ModDownloadPopup", ModDownloadPopup)
local function reg_func()
Engine.GetLuiRoot():registerEventHandler("mod_download_start", function(element, event)
2024-08-06 05:52:32 -04:00
LUI.FlowManager.RequestPopupMenu(element, "ModDownloadPopup", true, event.controller, false)
end)
end
2024-08-06 05:52:32 -04:00
scheduler.once(reg_func)