From 7da046760971556d2137294a4a5b00ecfc7219f2 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 24 Nov 2013 16:24:37 -0500 Subject: [PATCH] plString-ify plOperationProgress --- Sources/Plasma/Apps/plClient/plClient.cpp | 8 ++--- .../PubUtilLib/plAgeLoader/plResPatcher.cpp | 2 +- .../plNetClient/plNetCliAgeJoiner.cpp | 2 +- .../PubUtilLib/plPipeline/plDTProgressMgr.cpp | 10 +++---- .../plProgressMgr/plProgressMgr.cpp | 24 --------------- .../PubUtilLib/plProgressMgr/plProgressMgr.h | 30 +++++++++---------- 6 files changed, 26 insertions(+), 50 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 498df1c1..808f4222 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1196,7 +1196,7 @@ void plClient::IRoomLoaded(plSceneNode* node, bool hold) }; char name[256]; - strcpy(name, &fProgressBar->GetTitle()[strlen("Loading ")]); + strcpy(name, &fProgressBar->GetTitle().c_str()[strlen("Loading ")]); name[strlen(name)-3] = '\0'; // Get the precalculated value for how many messages will be @@ -1222,7 +1222,7 @@ void plClient::IRoomLoaded(plSceneNode* node, bool hold) #ifndef PLASMA_EXTERNAL_RELEASE if (plDispatchLogBase::IsLogging()) - plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle(), "displaying messages"); + plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle().c_str(), "displaying messages"); #endif // PLASMA_EXTERNAL_RELEASE #endif } @@ -1349,7 +1349,7 @@ void plClient::IStartProgress( const char *title, float len ) fProgressBar = plProgressMgr::GetInstance()->RegisterOperation(len, title, plProgressMgr::kNone, false, true); #ifndef PLASMA_EXTERNAL_RELEASE if (plDispatchLogBase::IsLogging()) - plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle(), "starting"); + plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle().c_str(), "starting"); #endif // PLASMA_EXTERNAL_RELEASE ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(IReadKeyedObjCallback); @@ -1371,7 +1371,7 @@ void plClient::IStopProgress( void ) { #ifndef PLASMA_EXTERNAL_RELEASE if (plDispatchLogBase::IsLogging()) - plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle(), "done"); + plDispatchLogBase::GetInstance()->LogStatusBarChange(fProgressBar->GetTitle().c_str(), "done"); #endif // PLASMA_EXTERNAL_RELEASE plDispatch::SetMsgRecieveCallback(nil); diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp index 446c4be1..896059de 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp @@ -249,7 +249,7 @@ void plResPatcher::IssueRequest() } } - fProgress->SetTitle(title.c_str()); + fProgress->SetTitle(title); } } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index 582e3599..4502bf7b 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -188,7 +188,7 @@ void plNCAgeJoiner::IDispatchMsgReceiveCallback () { void plNCAgeJoiner::IResMgrProgressBarCallback (plKey key) { #ifndef PLASMA_EXTERNAL_RELEASE if (s_instance) - s_instance->progressBar->SetStatusText(key->GetName().c_str()); + s_instance->progressBar->SetStatusText(key->GetName()); #endif } diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp index 94ba4a42..ab197cb5 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp @@ -245,16 +245,16 @@ bool plDTProgressMgr::IDrawTheStupidThing(plPipeline *p, plOperationProgress if (drawText) { - if (prog->GetTitle()) + if (!prog->GetTitle().IsEmpty()) { - text.DrawString( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 ); - x += (uint16_t)text.CalcStringWidth( prog->GetTitle() ); + text.DrawString_TEMP( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 ); + x += (uint16_t)text.CalcStringWidth_TEMP( prog->GetTitle() ); drew_something = true; } - if (prog->GetStatusText()) + if (!prog->GetStatusText().IsEmpty()) { - text.DrawString( x, y, prog->GetStatusText(), (uint32_t)0xccb0b0b0 ); + text.DrawString_TEMP( x, y, prog->GetStatusText(), (uint32_t)0xccb0b0b0 ); drew_something = true; } } diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp index a3ac71f2..363cc764 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp @@ -268,8 +268,6 @@ plOperationProgress::plOperationProgress( float length ) : fRemainingSecs(0), fAmtPerSec(0.f) { - memset( fStatusText, 0, sizeof( fStatusText ) ); - memset( fTitle, 0, sizeof( fTitle ) ); } plOperationProgress::~plOperationProgress() @@ -347,28 +345,6 @@ void plOperationProgress::SetHowMuch( float howMuch ) plProgressMgr::GetInstance()->IUpdateCallbackProc( this ); } -//// SetStatusText /////////////////////////////////////////////////////////// - -void plOperationProgress::SetStatusText( const char *text ) -{ - if( text != nil ) - strncpy( fStatusText, text, sizeof( fStatusText ) ); - else - fStatusText[ 0 ] = 0; -} - -//// SetTitle //////////////////////////////////////////////////////////////// - -void plOperationProgress::SetTitle( const char *text ) -{ - if (text != nil) - { - strncpy(fTitle, text, sizeof(fTitle)); - } - else - fTitle[0] = 0; -} - //// SetLength /////////////////////////////////////////////////////////////// void plOperationProgress::SetLength( float length ) diff --git a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h index 7ecbf390..bf36035d 100644 --- a/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h +++ b/Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h @@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define _plProgressMgr_h #include "HeadSpin.h" - +#include "plString.h" class plPipeline; class plPlate; @@ -74,10 +74,10 @@ class plOperationProgress protected: float fValue, fMax; - char fStatusText[ 256 ]; - char fTitle[ 256 ]; - uint32_t fContext; - double fStartTime; + plString fTitle; + plString fStatusText; + uint32_t fContext; + double fStartTime; uint32_t fElapsedSecs, fRemainingSecs; float fAmtPerSec; @@ -109,11 +109,11 @@ class plOperationProgress ~plOperationProgress(); - float GetMax( void ) const { return fMax; } - float GetProgress( void ) const { return fValue; } - const char * GetTitle( void ) const { return fTitle; } - const char * GetStatusText( void ) const { return fStatusText; } - uint32_t GetContext( void ) const { return fContext; } + float GetMax() const { return fMax; } + float GetProgress() const { return fValue; } + plString GetTitle() const { return fTitle; } + plString GetStatusText() const { return fStatusText; } + uint32_t GetContext() const { return fContext; } uint32_t GetElapsedSecs() { return fElapsedSecs; } uint32_t GetRemainingSecs() { return fRemainingSecs; } float GetAmtPerSec() { return fAmtPerSec; } @@ -127,16 +127,16 @@ class plOperationProgress // Set the length void SetLength( float length ); - // Sets the display text above the bar (nil for nothing) - void SetStatusText( const char *text ); + /** Sets the progress bar's status text */ + void SetStatusText(const plString& status) { fStatusText = status; } - // Sets the title - void SetTitle( const char *title ); + /** Sets the progress bar's title */ + void SetTitle(const plString& title) { fTitle = title; } // Application data void SetContext( uint32_t context ) { fContext = context;} - bool IsDone( void ) { return ( fValue < fMax ) ? false : true; } + bool IsDone() { return ( fValue < fMax ) ? false : true; } // True if this is the initial update (progress was just created) bool IsInitUpdate() { return hsCheckBits(fFlags, kInitUpdate); }