2024-08-06 05:52:32 -04:00
|
|
|
function ModDownloadCancel(arg0, arg1)
|
|
|
|
download.abort()
|
|
|
|
LUI.FlowManager.RequestLeaveMenu(arg0)
|
2024-08-06 05:15:59 -04:00
|
|
|
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"
|
2024-08-06 05:15:59 -04:00
|
|
|
|
|
|
|
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
|
2024-08-06 05:15:59 -04:00
|
|
|
end
|
|
|
|
|
2024-08-06 05:52:32 -04:00
|
|
|
MenuBuilder.registerType("ModDownloadPopup", ModDownloadPopup)
|
2024-08-06 05:15:59 -04:00
|
|
|
|
|
|
|
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)
|
2024-08-06 05:15:59 -04:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2024-08-06 05:52:32 -04:00
|
|
|
scheduler.once(reg_func)
|