mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 07:41:51 +00:00
[USETUP] Make countdown progress bar smoother
This commit is contained in:
parent
b0ecee7b6e
commit
13310b3acf
1 changed files with 16 additions and 10 deletions
|
@ -4548,7 +4548,7 @@ ProgressTimeOutStringHandler(
|
||||||
(AlwaysUpdate || (Bar->Progress != OldProgress)))
|
(AlwaysUpdate || (Bar->Progress != OldProgress)))
|
||||||
{
|
{
|
||||||
RtlStringCchPrintfA(Buffer, cchBufferSize,
|
RtlStringCchPrintfA(Buffer, cchBufferSize,
|
||||||
Bar->ProgressFormatText, Bar->Progress);
|
Bar->ProgressFormatText, Bar->Progress / max(1, Bar->Width) + 1);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -4578,9 +4578,9 @@ ProgressCountdown(
|
||||||
IN LONG TimeOut)
|
IN LONG TimeOut)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG StartTime;
|
ULONG StartTime, BarWidth, TimerDiv;
|
||||||
LONG TimeElapsed;
|
LONG TimeElapsed;
|
||||||
LONG TimerValue = TimeOut, OldTimerValue;
|
LONG TimerValue, OldTimerValue;
|
||||||
LARGE_INTEGER Timeout;
|
LARGE_INTEGER Timeout;
|
||||||
PPROGRESSBAR ProgressBar;
|
PPROGRESSBAR ProgressBar;
|
||||||
BOOLEAN RefreshProgress = TRUE;
|
BOOLEAN RefreshProgress = TRUE;
|
||||||
|
@ -4598,14 +4598,20 @@ ProgressCountdown(
|
||||||
24,
|
24,
|
||||||
TRUE,
|
TRUE,
|
||||||
FOREGROUND_RED | BACKGROUND_BLUE,
|
FOREGROUND_RED | BACKGROUND_BLUE,
|
||||||
TimerValue,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
MUIGetString(STRING_REBOOTPROGRESSBAR),
|
MUIGetString(STRING_REBOOTPROGRESSBAR),
|
||||||
ProgressTimeOutStringHandler);
|
ProgressTimeOutStringHandler);
|
||||||
|
|
||||||
|
BarWidth = max(1, ProgressBar->Width);
|
||||||
|
TimerValue = TimeOut * BarWidth;
|
||||||
|
ProgressSetStepCount(ProgressBar, TimerValue);
|
||||||
|
|
||||||
StartTime = NtGetTickCount();
|
StartTime = NtGetTickCount();
|
||||||
CONSOLE_Flush();
|
CONSOLE_Flush();
|
||||||
|
|
||||||
|
TimerDiv = 1000 / BarWidth;
|
||||||
|
TimerDiv = max(1, TimerDiv);
|
||||||
OldTimerValue = TimerValue;
|
OldTimerValue = TimerValue;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
|
@ -4617,11 +4623,11 @@ ProgressCountdown(
|
||||||
* elapsed if something slowed down.
|
* elapsed if something slowed down.
|
||||||
*/
|
*/
|
||||||
TimeElapsed = NtGetTickCount() - StartTime;
|
TimeElapsed = NtGetTickCount() - StartTime;
|
||||||
if (TimeElapsed >= 1000)
|
if (TimeElapsed >= TimerDiv)
|
||||||
{
|
{
|
||||||
/* Increase StartTime by steps of 1 second */
|
/* Increase StartTime by steps of 1 / ProgressBar->Width seconds */
|
||||||
TimeElapsed /= 1000;
|
TimeElapsed /= TimerDiv;
|
||||||
StartTime += (1000 * TimeElapsed);
|
StartTime += (TimerDiv * TimeElapsed);
|
||||||
|
|
||||||
if (TimeElapsed <= TimerValue)
|
if (TimeElapsed <= TimerValue)
|
||||||
TimerValue -= TimeElapsed;
|
TimerValue -= TimeElapsed;
|
||||||
|
@ -4651,10 +4657,10 @@ ProgressCountdown(
|
||||||
|
|
||||||
/* Wait a maximum of 1 second for input events */
|
/* Wait a maximum of 1 second for input events */
|
||||||
TimeElapsed = NtGetTickCount() - StartTime;
|
TimeElapsed = NtGetTickCount() - StartTime;
|
||||||
if (TimeElapsed < 1000)
|
if (TimeElapsed < TimerDiv)
|
||||||
{
|
{
|
||||||
/* Convert the time to NT Format */
|
/* Convert the time to NT Format */
|
||||||
Timeout.QuadPart = (1000 - TimeElapsed) * -10000LL;
|
Timeout.QuadPart = (TimerDiv - TimeElapsed) * -10000LL;
|
||||||
Status = NtWaitForSingleObject(StdInput, FALSE, &Timeout);
|
Status = NtWaitForSingleObject(StdInput, FALSE, &Timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue