From 53697562109f19c4bd35b7427339452cc9d5dc7b Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 31 Aug 2010 09:43:59 +0200 Subject: [PATCH] Changed: #1051 Progress tweak --- .../tools/client/client_patcher/main.cpp | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 23e2c9420..9f4e8c166 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -82,13 +82,32 @@ void printDownload(const std::string &str) static const uint maxLength = 160; static char spaces[maxLength]; + + uint length = 0; + + if (useUtf8) + { + ucstring utf8Str; + utf8Str.fromUtf8(str); + length = (uint)utf8Str.length(); + } + else + { + length = (uint)str.length(); + } + + sint diff = length - previousLength; + + if (diff > 0 && length < maxLength) + { + memset(spaces, ' ', length); + spaces[length] = '\0'; + + // "erase" previous line + printf("%s\r", spaces); + fflush(stdout); + } - memset(spaces, ' ', previousLength); - spaces[previousLength] = '\0'; - - // "erase" previous line - printf("%s\r", spaces); - // display download in purple if (useEsc) { @@ -108,8 +127,10 @@ void printDownload(const std::string &str) SetConsoleTextAttribute(hStdout, attributes); #endif } + + fflush(stdout); - previousLength = (uint)str.length(); + previousLength = length; } int main(int argc, char *argv[])