iw7-mod/data/cdata/ui_scripts/Mods/ModDownload.lua
quaK 7835bb0477
feat: fastdl, mod menus (#291)
* fastdl init

* ui_scripting fixes

* fastfile loading changes

* delete test ui script

* add mod select button

* Create iw7mod_code_post_gfx.ff

* fastdl progress

* fix download

* remove debug print
2024-08-06 12:15:59 +03:00

40 lines
1.2 KiB
Lua

function ModDownloadCancel( arg0, arg1 )
download.abort()
LUI.FlowManager.RequestLeaveMenu( arg0 )
end
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)
return popup
end
MenuBuilder.registerType( "ModDownloadPopup", ModDownloadPopup )
local function reg_func()
Engine.GetLuiRoot():registerEventHandler("mod_download_start", function(element, event)
LUI.FlowManager.RequestPopupMenu( element, "ModDownloadPopup", true, event.controller, false )
end)
end
scheduler.once(reg_func)