@@ -2,7 +2,6 @@ local top
22
33local initpacklist = PackList :new ()
44local packlist = initpacklist :GetPackTable ()
5- local downloading = DLMAN :GetDownloadingPacks ()
65
76-- make lookup table for installed packs
87local installedPacks = {}
@@ -144,10 +143,17 @@ local function input(event)
144143end
145144
146145local downloading = DLMAN :GetDownloadingPacks ()
146+ local queued = DLMAN :GetQueuedPacks ()
147147local function update (self , delta )
148+ downloading = DLMAN :GetDownloadingPacks ()
149+ queued = DLMAN :GetQueuedPacks ()
148150 for _ ,pack in ipairs (downloading ) do
149151 local download = pack :GetDownload ()
150- self :GetChild (" PackList" ):playcommand (" DownloadStatus" , {pack = pack , download = download })
152+ self :GetChild (" PackList" ):playcommand (" DownloadStatus" , {pack = pack , download = download , queued = false })
153+ end
154+ for _ ,pack in ipairs (queued ) do
155+ local download = pack :GetDownload ()
156+ self :GetChild (" PackList" ):playcommand (" DownloadStatus" , {pack = pack , download = download , queued = true })
151157 end
152158
153159end
@@ -423,7 +429,6 @@ local function packList()
423429 end ,
424430 DFRFinishedMessageCommand = function (self ) -- Download Finished, a Diff Reload happens (forced by the game)
425431 refreshInstalledPacks ()
426- downloading = DLMAN :GetDownloadingPacks ()
427432 MESSAGEMAN :Broadcast (" UpdateList" )
428433 end ,
429434 }
@@ -611,17 +616,21 @@ local function packList()
611616 end
612617 end ,
613618 DownloadStatusCommand = function (self , params ) -- Download status update from updatefunction
614- if not params .download then
619+ if not params .download and not params . queued then
615620 return
616621 end
617-
618622 if params .pack == packlist [packIndex ] then
619- download = params .download
620-
621- self :GetChild (" Status" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.8 )
622- self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.2 )
623- self :GetChild (" Size" ):settextf (" Downloading %5.2f MB / %5.2f MB" , download :GetKBDownloaded ()/ 1048576 , download :GetTotalKB ()/ 1048576 )
624- self :GetChild (" ProgressBar" ):zoomx (download :GetKBDownloaded ()/ download :GetTotalKB ()* packItemWidth )
623+ if params .queued then
624+ self :GetChild (" Status" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.8 )
625+ self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.2 )
626+ self :GetChild (" ProgressBar" ):zoomx (0 )
627+ else
628+ download = params .download
629+ self :GetChild (" Status" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.8 )
630+ self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.2 )
631+ self :GetChild (" Size" ):settextf (" Downloading %5.2f MB / %5.2f MB" , download :GetKBDownloaded ()/ 1048576 , download :GetTotalKB ()/ 1048576 )
632+ self :GetChild (" ProgressBar" ):zoomx (download :GetKBDownloaded ()/ download :GetTotalKB ()* packItemWidth )
633+ end
625634 end
626635 end ,
627636 StartDownloadCommand = function (self ) -- Start download
@@ -630,22 +639,28 @@ local function packList()
630639 return
631640 end
632641 download = packlist [packIndex ]:DownloadAndInstall ()
633- downloading = DLMAN :GetDownloadingPacks ()
634642 if not packExists (packlist [packIndex ]:GetName ()) then
635643 self :GetChild (" Status" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.8 )
636644 self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .downloading )):diffusealpha (0.2 )
637645 end
638646 end ,
639647 StopDownloadCommand = function (self ) -- Stop download
640- download :Stop ()
641- downloading = DLMAN :GetDownloadingPacks ()
648+ if packlist [packIndex ]:IsQueued () then
649+ local success = packlist [packIndex ]:RemoveFromQueue ()
650+ if success then
651+ self :GetChild (" Status" ):playcommand (" Set" )
652+ self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .available )):diffusealpha (0.2 )
653+ self :GetChild (" Size" ):settextf (" Download Removed from Queue" )
654+ end
655+ else
656+ download :Stop ()
657+ end
642658 end ,
643659 PackDownloadedMessageCommand = function (self , params ) -- Download Stopped/Finished
644- downloading = DLMAN : GetDownloadingPacks ()
660+ -- nothing?
645661 end ,
646662 DownloadFailedMessageCommand = function (self , params ) -- Download Failed
647663 if packlist [packIndex ] ~= nil and packlist [packIndex ]:GetName () == params .pack :GetName () then
648- downloading = DLMAN :GetDownloadingPacks ()
649664 self :GetChild (" Status" ):playcommand (" Set" )
650665 self :GetChild (" ProgressBar" ):diffuse (color (colorConfig :get_data ().downloadStatus .available )):diffusealpha (0.2 )
651666 self :GetChild (" Size" ):settextf (" Download Failed or Cancelled" )
@@ -689,7 +704,7 @@ local function packList()
689704 self :zoomto (packItemWidth , packItemHeight )
690705 end ,
691706 MouseDownCommand = function (self )
692- if packlist [packIndex ] ~= nil and packlist [packIndex ]:IsDownloading () then -- IsDownloading() returns the wrong boolean for some reason.
707+ if packlist [packIndex ] ~= nil and packlist [packIndex ]:IsDownloading () and not packlist [ packIndex ]: IsQueued () then -- IsDownloading() returns the wrong boolean for some reason.
693708 self :GetParent ():playcommand (" StartDownload" )
694709 elseif packlist [packIndex ] ~= nil then
695710 self :GetParent ():playcommand (" StopDownload" )
0 commit comments