1 ------------------------------------------------------------------------------------------------------------
9 ChangePriorityLock
= false
12 ------------------------------------------------------------------------------------------------------------
13 function bgdownloader
:getProgressGroup()
15 local grp
= getUI("ui:interface:bg_downloader")
18 local grp
= getUI("ui:outgame:charsel:bgd_progress")
23 ------------------------------------------------------------------------------------------------------------
24 function bgdownloader
:getPrioCB()
25 return self
:getProgressGroup():find("prio")
28 ------------------------------------------------------------------------------------------------------------
29 function bgdownloader
:getProgressBar()
30 return self
:getProgressGroup():find("progress")
33 ------------------------------------------------------------------------------------------------------------
34 function bgdownloader
:setIcon(icon
)
35 local bm
= self
:getProgressGroup():find("bm")
44 local pausedText
= i18n
.get("uiBGD_Paused")
46 ------------------------------------------------------------------------------------------------------------
47 function bgdownloader
:setProgressText(ucstr
, color
, progress
, ellipsis
)
48 local text
= self
:getProgressGroup():find("text")
49 local ellipsisTxt
= self
:getProgressGroup():find("ellipsis")
51 text
.uc_hardtext
= ucstr
53 ellipsisTxt
.hardtext
= ellipsis
55 ellipsisTxt
.hardtext
= ""
57 ellipsisTxt
.color
= color
58 if getBGDownloaderPriority() == 0 then -- paused ?
59 -- don't update progress when in pause (it may change because the pause actually wait
60 -- any current download to finish, otherwise connection may be lost)
61 self
:setIcon("bgd_pause.tga")
62 ellipsisTxt
.hardtext
= ""
63 text
.uc_hardtext
= pausedText
66 local progressCtrl
= self
:getProgressBar()
67 progressCtrl
.range
= 100
68 progressCtrl
.value
= progress
* 100
69 progressCtrl
.active
= true
71 self
:displayPriority()
75 local progress progressSymbol
= { ".", "..", "..." }
78 ------------------------------------------------------------------------------------------------------------
79 -- set patching progression (from 0 to 1)
80 function bgdownloader
:setPatchProgress(progress
)
81 if not isInGame() then
82 self
:getProgressGroup().active
= true
85 self
:getPrioCB().active
= true
86 local progressPercentText
= string.format("%d%%", 100 * progress
)
87 local progressPostfix
= math
.fmod(os
.time(), 3)
88 local progressDate
= nltime
.getLocalTime() / 500
89 local colValue
= math
.floor(230 + 24 * math
.sin(progressDate
))
90 local color
= string.format("%d %d %d %d", colValue
, colValue
, colValue
, 255)
91 self
:setProgressText(concatUCString(i18n
.get("uiBGD_Progress"), ucstring(progressPercentText
)), color
, progress
, progressSymbol
[progressPostfix
+ 1])
94 ------------------------------------------------------------------------------------------------------------
95 function bgdownloader
:setPatchSuccess()
96 if not isInGame() then
97 self
:getProgressGroup().active
= true
99 self
:setProgressText(i18n
.get("uiBGD_PatchUpToDate"), "0 255 0 255", 1)
100 self
:setIcon("W_answer_16_valid.tga")
102 self
:getPrioCB().active
= false
107 ------------------------------------------------------------------------------------------------------------
108 function bgdownloader
:setPatchError()
109 if not isInGame() then
110 self
:getProgressGroup().active
= true
112 local errMsg
= getPatchLastErrorMessage()
113 if errMsg
== ucstring() then
114 self
:setProgressText(i18n
.get("uiBGD_PatchError"), "255 0 0 255", 0)
116 self
:setProgressText(errMsg
, "255 0 0 255", 0)
118 self
:setIcon("W_answer_16_cancel.tga")
120 self
:getPrioCB().active
= false
124 ------------------------------------------------------------------------------------------------------------
125 function bgdownloader
:setNoDownloader()
127 self
:setProgressText(i18n
.get("uiBGD_NotUsed"), "255 255 255 255", 0)
129 self
:getProgressGroup().active
= false
133 self
:getPrioCB().active
= false
135 self
:getProgressBar().active
= false
138 ------------------------------------------------------------------------------------------------------------
139 function bgdownloader
:setNoNecessaryPatch()
141 self
:setProgressText(i18n
.get("uiBGD_PatchUpToDate"), "255 255 255 255", 0)
144 self
:getProgressGroup().active
= false
148 self
:getPrioCB().active
= false
150 self
:getProgressBar().active
= false
153 ------------------------------------------------------------------------------------------------------------
154 -- the priority was changed by the user
155 function bgdownloader
:onChangePriority()
156 if not self
.ChangePriorityLock
then
157 requestBGDownloaderPriority(self
:getPrioCB().selection
)
158 self
:displayPriority()
162 ------------------------------------------------------------------------------------------------------------
163 -- the priority has been changed externally, display it
164 function bgdownloader
:displayPriority()
165 --if not isInGame() then return end
166 self
.ChangePriorityLock
= true
167 self
:getPrioCB().selection
= getBGDownloaderPriority()
168 self
.ChangePriorityLock
= false
169 self
:getPrioCB().active
= (getBGDownloaderPriority() ~= -1)
172 ------------------------------------------------------------------------------------------------------------
173 -- display a warning telling that the user need a fully patched client to go further
174 function bgdownloader
:inGamePatchUncompleteWarning()
175 local pg
= self
:getProgressGroup()
179 messageBoxWithHelp(i18n
.get("uiBGD_InGamePatchIncomplete"), "ui:interface", tonumber(getDefine("case_normal")))
180 displaySystemInfo(i18n
.get("uiBGD_InGamePatchIncompleteBC"), "BC")