mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix line endings and tabs
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plProgressMgr_SOURCES
|
||||
plProgressMgr.cpp
|
||||
)
|
||||
|
||||
set(plProgressMgr_HEADERS
|
||||
plProgressMgr.h
|
||||
)
|
||||
|
||||
add_library(plProgressMgr STATIC ${plProgressMgr_SOURCES} ${plProgressMgr_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plProgressMgr_SOURCES})
|
||||
source_group("Header Files" FILES ${plProgressMgr_HEADERS})
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plProgressMgr_SOURCES
|
||||
plProgressMgr.cpp
|
||||
)
|
||||
|
||||
set(plProgressMgr_HEADERS
|
||||
plProgressMgr.h
|
||||
)
|
||||
|
||||
add_library(plProgressMgr STATIC ${plProgressMgr_SOURCES} ${plProgressMgr_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plProgressMgr_SOURCES})
|
||||
source_group("Header Files" FILES ${plProgressMgr_HEADERS})
|
||||
|
@ -1,387 +1,387 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plProgressMgr Functions //
|
||||
// //
|
||||
//// History /////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 10.26.2001 mcn - Created //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hsTypes.h"
|
||||
#include "plProgressMgr.h"
|
||||
#include "hsTimer.h"
|
||||
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "../Apps/plClient/res/resource.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// plProgressMgr Functions /////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
plProgressMgr *plProgressMgr::fManager = nil;
|
||||
|
||||
int plProgressMgr::fImageRotation[] = {
|
||||
IDR_LOADING_01,
|
||||
IDR_LOADING_18,
|
||||
IDR_LOADING_17,
|
||||
IDR_LOADING_16,
|
||||
IDR_LOADING_15,
|
||||
IDR_LOADING_14,
|
||||
IDR_LOADING_13,
|
||||
IDR_LOADING_12,
|
||||
IDR_LOADING_11,
|
||||
IDR_LOADING_10,
|
||||
IDR_LOADING_09,
|
||||
IDR_LOADING_08,
|
||||
IDR_LOADING_07,
|
||||
IDR_LOADING_06,
|
||||
IDR_LOADING_05,
|
||||
IDR_LOADING_04,
|
||||
IDR_LOADING_03,
|
||||
IDR_LOADING_02
|
||||
};
|
||||
|
||||
int plProgressMgr::fStaticTextIDs[] = {
|
||||
0,
|
||||
IDR_LOADING_UPDATETEXT,
|
||||
};
|
||||
|
||||
//// Constructor & Destructor ////////////////////////////////////////////////
|
||||
|
||||
plProgressMgr::plProgressMgr()
|
||||
{
|
||||
fOperations = nil;
|
||||
fManager = this;
|
||||
fCallbackProc = nil;
|
||||
fCurrentStaticText = kNone;
|
||||
}
|
||||
|
||||
plProgressMgr::~plProgressMgr()
|
||||
{
|
||||
while( fOperations != nil )
|
||||
delete fOperations;
|
||||
fManager = nil;
|
||||
}
|
||||
|
||||
//// RegisterOperation ///////////////////////////////////////////////////////
|
||||
|
||||
plOperationProgress* plProgressMgr::RegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool alwaysDrawText)
|
||||
{
|
||||
return IRegisterOperation(length, title, staticTextType, isRetry, false, alwaysDrawText);
|
||||
}
|
||||
|
||||
plOperationProgress* plProgressMgr::RegisterOverallOperation(hsScalar length, const char *title, StaticText staticTextType, bool alwaysDrawText)
|
||||
{
|
||||
return IRegisterOperation(length, title, staticTextType, false, true, alwaysDrawText);
|
||||
}
|
||||
|
||||
plOperationProgress* plProgressMgr::IRegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool isOverall, bool alwaysDrawText)
|
||||
{
|
||||
if (fOperations == nil)
|
||||
{
|
||||
fCurrentStaticText = staticTextType;
|
||||
Activate();
|
||||
}
|
||||
|
||||
plOperationProgress *op = TRACKED_NEW plOperationProgress( length );
|
||||
|
||||
op->SetTitle( title );
|
||||
|
||||
if (fOperations)
|
||||
{
|
||||
fOperations->fBack = op;
|
||||
op->fNext = fOperations;
|
||||
}
|
||||
fOperations = op;
|
||||
|
||||
if (isRetry)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kRetry);
|
||||
if (isOverall)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kOverall);
|
||||
if (alwaysDrawText)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kAlwaysDrawText);
|
||||
|
||||
IUpdateCallbackProc( op );
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
void plProgressMgr::IUnregisterOperation(plOperationProgress* op)
|
||||
{
|
||||
plOperationProgress* last = nil;
|
||||
plOperationProgress* cur = fOperations;
|
||||
|
||||
while (cur)
|
||||
{
|
||||
if (cur == op)
|
||||
{
|
||||
if (cur->fNext)
|
||||
cur->fNext->fBack = last;
|
||||
|
||||
if (last)
|
||||
last->fNext = cur->fNext;
|
||||
else
|
||||
fOperations = cur->fNext;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
last = cur;
|
||||
cur = cur->fNext;
|
||||
}
|
||||
|
||||
if (fOperations == nil)
|
||||
{
|
||||
fCurrentStaticText = kNone;
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
//// IUpdateCallbackProc /////////////////////////////////////////////////////
|
||||
|
||||
void plProgressMgr::IUpdateFlags(plOperationProgress* progress)
|
||||
{
|
||||
// Init update is done, clear it and set first update
|
||||
if (hsCheckBits(progress->fFlags, plOperationProgress::kInitUpdate))
|
||||
{
|
||||
hsClearBits(progress->fFlags, plOperationProgress::kInitUpdate);
|
||||
hsSetBits(progress->fFlags, plOperationProgress::kFirstUpdate);
|
||||
}
|
||||
// First update is done, clear it
|
||||
else if (hsCheckBits(progress->fFlags, plOperationProgress::kFirstUpdate))
|
||||
hsClearBits(progress->fFlags, plOperationProgress::kFirstUpdate);
|
||||
}
|
||||
|
||||
void plProgressMgr::IUpdateCallbackProc(plOperationProgress* progress)
|
||||
{
|
||||
// Update the parent, if necessary
|
||||
plOperationProgress* parentProgress = progress->GetNext();
|
||||
while (parentProgress && parentProgress->IsOverallProgress())
|
||||
{
|
||||
parentProgress->IChildUpdateBegin(progress);
|
||||
parentProgress = parentProgress->GetNext();
|
||||
}
|
||||
|
||||
// Update everyone who wants to know about progress
|
||||
IDerivedCallbackProc(progress);
|
||||
if (fCallbackProc != nil)
|
||||
fCallbackProc(progress);
|
||||
|
||||
IUpdateFlags(progress);
|
||||
|
||||
parentProgress = progress->GetNext();
|
||||
while (parentProgress && parentProgress->IsOverallProgress())
|
||||
{
|
||||
parentProgress->IChildUpdateEnd(progress);
|
||||
parentProgress = parentProgress->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//// SetCallbackProc /////////////////////////////////////////////////////////
|
||||
|
||||
plProgressMgrCallbackProc plProgressMgr::SetCallbackProc( plProgressMgrCallbackProc proc )
|
||||
{
|
||||
plProgressMgrCallbackProc old = fCallbackProc;
|
||||
fCallbackProc = proc;
|
||||
return old;
|
||||
}
|
||||
|
||||
//// CancelAllOps ////////////////////////////////////////////////////////////
|
||||
|
||||
void plProgressMgr::CancelAllOps( void )
|
||||
{
|
||||
plOperationProgress *op;
|
||||
|
||||
|
||||
for( op = fOperations; op != nil; op = op->GetNext() )
|
||||
op->SetCancelFlag( true );
|
||||
|
||||
fCurrentStaticText = kNone;
|
||||
}
|
||||
|
||||
int plProgressMgr::GetLoadingFrameID(int index)
|
||||
{
|
||||
if (index < (sizeof(fImageRotation) / sizeof(int)))
|
||||
return fImageRotation[index];
|
||||
else
|
||||
return fImageRotation[0];
|
||||
}
|
||||
|
||||
int plProgressMgr::GetStaticTextID(StaticText staticTextType)
|
||||
{
|
||||
return fStaticTextIDs[staticTextType];
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// plOperationProgress ////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
plOperationProgress::plOperationProgress( hsScalar length ) :
|
||||
fMax(length),
|
||||
fValue(0),
|
||||
fNext(nil),
|
||||
fBack(nil),
|
||||
fContext(0),
|
||||
fFlags(kInitUpdate),
|
||||
fStartTime(hsTimer::GetSeconds()),
|
||||
fElapsedSecs(0),
|
||||
fRemainingSecs(0),
|
||||
fAmtPerSec(0.f)
|
||||
{
|
||||
memset( fStatusText, 0, sizeof( fStatusText ) );
|
||||
memset( fTitle, 0, sizeof( fTitle ) );
|
||||
}
|
||||
|
||||
plOperationProgress::~plOperationProgress()
|
||||
{
|
||||
hsSetBits(fFlags, kLastUpdate);
|
||||
if (!IsOverallProgress())
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc(this);
|
||||
plProgressMgr::GetInstance()->IUnregisterOperation(this);
|
||||
}
|
||||
|
||||
void plOperationProgress::IUpdateStats()
|
||||
{
|
||||
double curTime = hsTimer::GetSeconds();
|
||||
double elapsed = 0;
|
||||
if (curTime > fStartTime)
|
||||
elapsed = curTime - fStartTime;
|
||||
else
|
||||
elapsed = fStartTime - curTime;
|
||||
|
||||
hsScalar progress = GetProgress();
|
||||
|
||||
if (elapsed > 0)
|
||||
fAmtPerSec = progress / hsScalar(elapsed);
|
||||
else
|
||||
fAmtPerSec = 0;
|
||||
fElapsedSecs = (UInt32)elapsed;
|
||||
if (progress < fMax)
|
||||
fRemainingSecs = (UInt32)((fMax - progress) / fAmtPerSec);
|
||||
else
|
||||
fRemainingSecs = 0;
|
||||
}
|
||||
|
||||
void plOperationProgress::IChildUpdateBegin(plOperationProgress* child)
|
||||
{
|
||||
if (child->IsFirstUpdate() && child->IsRetry())
|
||||
{
|
||||
// We're retrying this file, so update the overall stats to reflect the additional download
|
||||
fMax += child->GetMax();
|
||||
}
|
||||
fValue += child->GetProgress();
|
||||
|
||||
IUpdateStats();
|
||||
}
|
||||
|
||||
void plOperationProgress::IChildUpdateEnd(plOperationProgress* child)
|
||||
{
|
||||
// If we're aborting, modify the total bytes to reflect any data we didn't download
|
||||
if (hsCheckBits(child->fFlags, plOperationProgress::kAborting))
|
||||
fMax += child->GetProgress() - child->GetMax();
|
||||
else if (!child->IsLastUpdate())
|
||||
fValue -= child->GetProgress();
|
||||
}
|
||||
|
||||
//// Increment ///////////////////////////////////////////////////////////////
|
||||
|
||||
void plOperationProgress::Increment( hsScalar byHowMuch )
|
||||
{
|
||||
fValue += byHowMuch;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc( this );
|
||||
}
|
||||
|
||||
//// SetHowMuch //////////////////////////////////////////////////////////////
|
||||
|
||||
void plOperationProgress::SetHowMuch( hsScalar howMuch )
|
||||
{
|
||||
fValue = howMuch;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
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( hsScalar length )
|
||||
{
|
||||
fMax = length;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc( this );
|
||||
}
|
||||
|
||||
void plOperationProgress::SetAborting()
|
||||
{
|
||||
hsSetBits(fFlags, kAborting);
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc(this);
|
||||
fMax = fValue = 0.f;
|
||||
hsClearBits(fFlags, kAborting);
|
||||
}
|
||||
|
||||
void plOperationProgress::SetRetry()
|
||||
{
|
||||
hsSetBits(fFlags, kRetry);
|
||||
hsSetBits(fFlags, kFirstUpdate);
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plProgressMgr Functions //
|
||||
// //
|
||||
//// History /////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 10.26.2001 mcn - Created //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hsTypes.h"
|
||||
#include "plProgressMgr.h"
|
||||
#include "hsTimer.h"
|
||||
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "../Apps/plClient/res/resource.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// plProgressMgr Functions /////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
plProgressMgr *plProgressMgr::fManager = nil;
|
||||
|
||||
int plProgressMgr::fImageRotation[] = {
|
||||
IDR_LOADING_01,
|
||||
IDR_LOADING_18,
|
||||
IDR_LOADING_17,
|
||||
IDR_LOADING_16,
|
||||
IDR_LOADING_15,
|
||||
IDR_LOADING_14,
|
||||
IDR_LOADING_13,
|
||||
IDR_LOADING_12,
|
||||
IDR_LOADING_11,
|
||||
IDR_LOADING_10,
|
||||
IDR_LOADING_09,
|
||||
IDR_LOADING_08,
|
||||
IDR_LOADING_07,
|
||||
IDR_LOADING_06,
|
||||
IDR_LOADING_05,
|
||||
IDR_LOADING_04,
|
||||
IDR_LOADING_03,
|
||||
IDR_LOADING_02
|
||||
};
|
||||
|
||||
int plProgressMgr::fStaticTextIDs[] = {
|
||||
0,
|
||||
IDR_LOADING_UPDATETEXT,
|
||||
};
|
||||
|
||||
//// Constructor & Destructor ////////////////////////////////////////////////
|
||||
|
||||
plProgressMgr::plProgressMgr()
|
||||
{
|
||||
fOperations = nil;
|
||||
fManager = this;
|
||||
fCallbackProc = nil;
|
||||
fCurrentStaticText = kNone;
|
||||
}
|
||||
|
||||
plProgressMgr::~plProgressMgr()
|
||||
{
|
||||
while( fOperations != nil )
|
||||
delete fOperations;
|
||||
fManager = nil;
|
||||
}
|
||||
|
||||
//// RegisterOperation ///////////////////////////////////////////////////////
|
||||
|
||||
plOperationProgress* plProgressMgr::RegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool alwaysDrawText)
|
||||
{
|
||||
return IRegisterOperation(length, title, staticTextType, isRetry, false, alwaysDrawText);
|
||||
}
|
||||
|
||||
plOperationProgress* plProgressMgr::RegisterOverallOperation(hsScalar length, const char *title, StaticText staticTextType, bool alwaysDrawText)
|
||||
{
|
||||
return IRegisterOperation(length, title, staticTextType, false, true, alwaysDrawText);
|
||||
}
|
||||
|
||||
plOperationProgress* plProgressMgr::IRegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool isOverall, bool alwaysDrawText)
|
||||
{
|
||||
if (fOperations == nil)
|
||||
{
|
||||
fCurrentStaticText = staticTextType;
|
||||
Activate();
|
||||
}
|
||||
|
||||
plOperationProgress *op = TRACKED_NEW plOperationProgress( length );
|
||||
|
||||
op->SetTitle( title );
|
||||
|
||||
if (fOperations)
|
||||
{
|
||||
fOperations->fBack = op;
|
||||
op->fNext = fOperations;
|
||||
}
|
||||
fOperations = op;
|
||||
|
||||
if (isRetry)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kRetry);
|
||||
if (isOverall)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kOverall);
|
||||
if (alwaysDrawText)
|
||||
hsSetBits(op->fFlags, plOperationProgress::kAlwaysDrawText);
|
||||
|
||||
IUpdateCallbackProc( op );
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
void plProgressMgr::IUnregisterOperation(plOperationProgress* op)
|
||||
{
|
||||
plOperationProgress* last = nil;
|
||||
plOperationProgress* cur = fOperations;
|
||||
|
||||
while (cur)
|
||||
{
|
||||
if (cur == op)
|
||||
{
|
||||
if (cur->fNext)
|
||||
cur->fNext->fBack = last;
|
||||
|
||||
if (last)
|
||||
last->fNext = cur->fNext;
|
||||
else
|
||||
fOperations = cur->fNext;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
last = cur;
|
||||
cur = cur->fNext;
|
||||
}
|
||||
|
||||
if (fOperations == nil)
|
||||
{
|
||||
fCurrentStaticText = kNone;
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
//// IUpdateCallbackProc /////////////////////////////////////////////////////
|
||||
|
||||
void plProgressMgr::IUpdateFlags(plOperationProgress* progress)
|
||||
{
|
||||
// Init update is done, clear it and set first update
|
||||
if (hsCheckBits(progress->fFlags, plOperationProgress::kInitUpdate))
|
||||
{
|
||||
hsClearBits(progress->fFlags, plOperationProgress::kInitUpdate);
|
||||
hsSetBits(progress->fFlags, plOperationProgress::kFirstUpdate);
|
||||
}
|
||||
// First update is done, clear it
|
||||
else if (hsCheckBits(progress->fFlags, plOperationProgress::kFirstUpdate))
|
||||
hsClearBits(progress->fFlags, plOperationProgress::kFirstUpdate);
|
||||
}
|
||||
|
||||
void plProgressMgr::IUpdateCallbackProc(plOperationProgress* progress)
|
||||
{
|
||||
// Update the parent, if necessary
|
||||
plOperationProgress* parentProgress = progress->GetNext();
|
||||
while (parentProgress && parentProgress->IsOverallProgress())
|
||||
{
|
||||
parentProgress->IChildUpdateBegin(progress);
|
||||
parentProgress = parentProgress->GetNext();
|
||||
}
|
||||
|
||||
// Update everyone who wants to know about progress
|
||||
IDerivedCallbackProc(progress);
|
||||
if (fCallbackProc != nil)
|
||||
fCallbackProc(progress);
|
||||
|
||||
IUpdateFlags(progress);
|
||||
|
||||
parentProgress = progress->GetNext();
|
||||
while (parentProgress && parentProgress->IsOverallProgress())
|
||||
{
|
||||
parentProgress->IChildUpdateEnd(progress);
|
||||
parentProgress = parentProgress->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
//// SetCallbackProc /////////////////////////////////////////////////////////
|
||||
|
||||
plProgressMgrCallbackProc plProgressMgr::SetCallbackProc( plProgressMgrCallbackProc proc )
|
||||
{
|
||||
plProgressMgrCallbackProc old = fCallbackProc;
|
||||
fCallbackProc = proc;
|
||||
return old;
|
||||
}
|
||||
|
||||
//// CancelAllOps ////////////////////////////////////////////////////////////
|
||||
|
||||
void plProgressMgr::CancelAllOps( void )
|
||||
{
|
||||
plOperationProgress *op;
|
||||
|
||||
|
||||
for( op = fOperations; op != nil; op = op->GetNext() )
|
||||
op->SetCancelFlag( true );
|
||||
|
||||
fCurrentStaticText = kNone;
|
||||
}
|
||||
|
||||
int plProgressMgr::GetLoadingFrameID(int index)
|
||||
{
|
||||
if (index < (sizeof(fImageRotation) / sizeof(int)))
|
||||
return fImageRotation[index];
|
||||
else
|
||||
return fImageRotation[0];
|
||||
}
|
||||
|
||||
int plProgressMgr::GetStaticTextID(StaticText staticTextType)
|
||||
{
|
||||
return fStaticTextIDs[staticTextType];
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// plOperationProgress ////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
plOperationProgress::plOperationProgress( hsScalar length ) :
|
||||
fMax(length),
|
||||
fValue(0),
|
||||
fNext(nil),
|
||||
fBack(nil),
|
||||
fContext(0),
|
||||
fFlags(kInitUpdate),
|
||||
fStartTime(hsTimer::GetSeconds()),
|
||||
fElapsedSecs(0),
|
||||
fRemainingSecs(0),
|
||||
fAmtPerSec(0.f)
|
||||
{
|
||||
memset( fStatusText, 0, sizeof( fStatusText ) );
|
||||
memset( fTitle, 0, sizeof( fTitle ) );
|
||||
}
|
||||
|
||||
plOperationProgress::~plOperationProgress()
|
||||
{
|
||||
hsSetBits(fFlags, kLastUpdate);
|
||||
if (!IsOverallProgress())
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc(this);
|
||||
plProgressMgr::GetInstance()->IUnregisterOperation(this);
|
||||
}
|
||||
|
||||
void plOperationProgress::IUpdateStats()
|
||||
{
|
||||
double curTime = hsTimer::GetSeconds();
|
||||
double elapsed = 0;
|
||||
if (curTime > fStartTime)
|
||||
elapsed = curTime - fStartTime;
|
||||
else
|
||||
elapsed = fStartTime - curTime;
|
||||
|
||||
hsScalar progress = GetProgress();
|
||||
|
||||
if (elapsed > 0)
|
||||
fAmtPerSec = progress / hsScalar(elapsed);
|
||||
else
|
||||
fAmtPerSec = 0;
|
||||
fElapsedSecs = (UInt32)elapsed;
|
||||
if (progress < fMax)
|
||||
fRemainingSecs = (UInt32)((fMax - progress) / fAmtPerSec);
|
||||
else
|
||||
fRemainingSecs = 0;
|
||||
}
|
||||
|
||||
void plOperationProgress::IChildUpdateBegin(plOperationProgress* child)
|
||||
{
|
||||
if (child->IsFirstUpdate() && child->IsRetry())
|
||||
{
|
||||
// We're retrying this file, so update the overall stats to reflect the additional download
|
||||
fMax += child->GetMax();
|
||||
}
|
||||
fValue += child->GetProgress();
|
||||
|
||||
IUpdateStats();
|
||||
}
|
||||
|
||||
void plOperationProgress::IChildUpdateEnd(plOperationProgress* child)
|
||||
{
|
||||
// If we're aborting, modify the total bytes to reflect any data we didn't download
|
||||
if (hsCheckBits(child->fFlags, plOperationProgress::kAborting))
|
||||
fMax += child->GetProgress() - child->GetMax();
|
||||
else if (!child->IsLastUpdate())
|
||||
fValue -= child->GetProgress();
|
||||
}
|
||||
|
||||
//// Increment ///////////////////////////////////////////////////////////////
|
||||
|
||||
void plOperationProgress::Increment( hsScalar byHowMuch )
|
||||
{
|
||||
fValue += byHowMuch;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc( this );
|
||||
}
|
||||
|
||||
//// SetHowMuch //////////////////////////////////////////////////////////////
|
||||
|
||||
void plOperationProgress::SetHowMuch( hsScalar howMuch )
|
||||
{
|
||||
fValue = howMuch;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
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( hsScalar length )
|
||||
{
|
||||
fMax = length;
|
||||
if( fValue > fMax )
|
||||
fValue = fMax;
|
||||
IUpdateStats();
|
||||
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc( this );
|
||||
}
|
||||
|
||||
void plOperationProgress::SetAborting()
|
||||
{
|
||||
hsSetBits(fFlags, kAborting);
|
||||
plProgressMgr::GetInstance()->IUpdateCallbackProc(this);
|
||||
fMax = fValue = 0.f;
|
||||
hsClearBits(fFlags, kAborting);
|
||||
}
|
||||
|
||||
void plOperationProgress::SetRetry()
|
||||
{
|
||||
hsSetBits(fFlags, kRetry);
|
||||
hsSetBits(fFlags, kFirstUpdate);
|
||||
}
|
||||
|
@ -1,234 +1,234 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plProgressMgr Header //
|
||||
// //
|
||||
//// Description /////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// The plProgressMgr is a method by which any part of the client can //
|
||||
// display a progress bar indicating a lengthy operation. //
|
||||
// Basically, a function/class/whatnot registers an operation with the //
|
||||
// plProgressMgr.
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _plProgressMgr_h
|
||||
#define _plProgressMgr_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
class plPipeline;
|
||||
class plPlate;
|
||||
|
||||
//// plOperationProgress Definition //////////////////////////////////////////
|
||||
// The object you get back when you register a lengthy operation. Call this
|
||||
// to update your progress, destroy it when you're done.
|
||||
|
||||
class plProgressMgr;
|
||||
class plOperationProgress
|
||||
{
|
||||
friend class plProgressMgr;
|
||||
friend class plDTProgressMgr;
|
||||
|
||||
protected:
|
||||
|
||||
hsScalar fValue, fMax;
|
||||
char fStatusText[ 256 ];
|
||||
char fTitle[ 256 ];
|
||||
UInt32 fContext;
|
||||
double fStartTime;
|
||||
|
||||
UInt32 fElapsedSecs, fRemainingSecs;
|
||||
hsScalar fAmtPerSec;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
kShouldCancel = 0x1,
|
||||
kInitUpdate = 0x2,
|
||||
kFirstUpdate = 0x4,
|
||||
kLastUpdate = 0x8,
|
||||
kAborting = 0x10,
|
||||
kRetry = 0x20,
|
||||
kOverall = 0x40,
|
||||
kAlwaysDrawText = 0x80,
|
||||
};
|
||||
UInt8 fFlags;
|
||||
|
||||
plOperationProgress *fNext, *fBack;
|
||||
|
||||
void IUpdateStats();
|
||||
|
||||
// For overall progress bars
|
||||
void IChildUpdateBegin(plOperationProgress* child);
|
||||
void IChildUpdateEnd(plOperationProgress* child);
|
||||
|
||||
plOperationProgress( hsScalar length );
|
||||
|
||||
public:
|
||||
|
||||
~plOperationProgress();
|
||||
|
||||
hsScalar GetMax( void ) const { return fMax; }
|
||||
hsScalar GetProgress( void ) const { return fValue; }
|
||||
const char * GetTitle( void ) const { return fTitle; }
|
||||
const char * GetStatusText( void ) const { return fStatusText; }
|
||||
UInt32 GetContext( void ) const { return fContext; }
|
||||
UInt32 GetElapsedSecs() { return fElapsedSecs; }
|
||||
UInt32 GetRemainingSecs() { return fRemainingSecs; }
|
||||
hsScalar GetAmtPerSec() { return fAmtPerSec; }
|
||||
|
||||
// Adds on to current value
|
||||
void Increment( hsScalar byHowMuch );
|
||||
|
||||
// Sets current value
|
||||
void SetHowMuch( hsScalar byHowMuch );
|
||||
|
||||
// Set the length
|
||||
void SetLength( hsScalar length );
|
||||
|
||||
// Sets the display text above the bar (nil for nothing)
|
||||
void SetStatusText( const char *text );
|
||||
|
||||
// Sets the title
|
||||
void SetTitle( const char *title );
|
||||
|
||||
// Application data
|
||||
void SetContext( UInt32 context ) { fContext = context;}
|
||||
|
||||
hsBool IsDone( void ) { return ( fValue < fMax ) ? false : true; }
|
||||
|
||||
// True if this is the initial update (progress was just created)
|
||||
bool IsInitUpdate() { return hsCheckBits(fFlags, kInitUpdate); }
|
||||
// True if this is the first time the progress was updated
|
||||
bool IsFirstUpdate() { return hsCheckBits(fFlags, kFirstUpdate); }
|
||||
// Returns true if this is the last update you'll get from this
|
||||
// operation (because it's getting deleted)
|
||||
bool IsLastUpdate() { return hsCheckBits(fFlags, kLastUpdate); }
|
||||
|
||||
// This type of progress is just tracking the overall progress of it's children
|
||||
bool IsOverallProgress() { return hsCheckBits(fFlags, kOverall); }
|
||||
|
||||
// Set if this progress is aborting before it completes. This will let any overall
|
||||
// progress bars above this one know to adjust their totals to not include any amount
|
||||
// that wasn't completed, and will set this progress bar to zero
|
||||
void SetAborting();
|
||||
// If you're reusing an existing progress bar to retry a failed operation, call this.
|
||||
// It will set the retry flag, and reset the progress bar so the next update will
|
||||
// count as the first. If you set retry in RegisterOperation, don't use this too.
|
||||
void SetRetry();
|
||||
bool IsRetry() { return hsCheckBits(fFlags, kRetry); }
|
||||
|
||||
// The progress manager can decide at any time to cancel your operation on you. Check this
|
||||
// value if you want to play nice and behave.
|
||||
bool ShouldCancel() const { return hsCheckBits(fFlags, kShouldCancel); }
|
||||
|
||||
bool AlwaysDrawText() const { return hsCheckBits(fFlags, kAlwaysDrawText); }
|
||||
|
||||
// Please ignore this and don't use it unless you're me :P
|
||||
plOperationProgress* GetPrev() const { return fBack; }
|
||||
plOperationProgress* GetNext() const { return fNext; }
|
||||
|
||||
// Or this
|
||||
void SetCancelFlag( hsBool f ) { hsChangeBits(fFlags, kShouldCancel, f); }
|
||||
};
|
||||
|
||||
// This is a callback proc you set that gets called every time the progressManager
|
||||
// needs updating (like, say, you need to redraw progress bars). The client generally
|
||||
// sets this callback and nobody should ever touch it.
|
||||
typedef void(*plProgressMgrCallbackProc)( plOperationProgress* );
|
||||
|
||||
//// Manager Class Definition ////////////////////////////////////////////////
|
||||
|
||||
class plProgressMgr
|
||||
{
|
||||
friend class plOperationProgress;
|
||||
|
||||
public:
|
||||
// this must match the order of the fStaticTextIDs array
|
||||
// for it to be useful
|
||||
enum StaticText
|
||||
{
|
||||
kNone,
|
||||
kUpdateText,
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
static plProgressMgr *fManager;
|
||||
static int fImageRotation[];
|
||||
static int fStaticTextIDs[];
|
||||
|
||||
protected:
|
||||
|
||||
plProgressMgr();
|
||||
|
||||
plOperationProgress *fOperations;
|
||||
|
||||
plProgressMgrCallbackProc fCallbackProc;
|
||||
|
||||
StaticText fCurrentStaticText;
|
||||
|
||||
void IUpdateCallbackProc(plOperationProgress* progress);
|
||||
// For derived classes to use, so they don't have to set a callback proc
|
||||
virtual void IDerivedCallbackProc(plOperationProgress* progress) {}
|
||||
|
||||
void IUpdateFlags(plOperationProgress* progress);
|
||||
|
||||
plOperationProgress* IRegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool isOverall, bool alwaysDrawText);
|
||||
// Called by the operation
|
||||
void IUnregisterOperation(plOperationProgress* op);
|
||||
|
||||
virtual void Activate() {}
|
||||
virtual void Deactivate() {}
|
||||
|
||||
static plProgressMgr *IGetManager( void ) { return fManager; }
|
||||
|
||||
public:
|
||||
|
||||
virtual ~plProgressMgr();
|
||||
|
||||
static plProgressMgr* GetInstance() { return fManager; }
|
||||
static int GetLoadingFrameID(int index);
|
||||
static int GetStaticTextID(StaticText staticTextType);
|
||||
|
||||
virtual void Draw( plPipeline *p ) { }
|
||||
|
||||
plOperationProgress* RegisterOperation(hsScalar length, const char *title = nil, StaticText staticTextType = kNone, bool isRetry = false, bool alwaysDrawText = false);
|
||||
plOperationProgress* RegisterOverallOperation(hsScalar length, const char *title = nil, StaticText staticTextType = kNone, bool alwaysDrawText = false);
|
||||
|
||||
|
||||
plProgressMgrCallbackProc SetCallbackProc( plProgressMgrCallbackProc proc );
|
||||
|
||||
hsBool IsActive( void ) const { return ( fOperations != nil ) ? true : false; }
|
||||
|
||||
void CancelAllOps( void );
|
||||
};
|
||||
|
||||
|
||||
#endif //_plProgressMgr_h
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plProgressMgr Header //
|
||||
// //
|
||||
//// Description /////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// The plProgressMgr is a method by which any part of the client can //
|
||||
// display a progress bar indicating a lengthy operation. //
|
||||
// Basically, a function/class/whatnot registers an operation with the //
|
||||
// plProgressMgr.
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _plProgressMgr_h
|
||||
#define _plProgressMgr_h
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
class plPipeline;
|
||||
class plPlate;
|
||||
|
||||
//// plOperationProgress Definition //////////////////////////////////////////
|
||||
// The object you get back when you register a lengthy operation. Call this
|
||||
// to update your progress, destroy it when you're done.
|
||||
|
||||
class plProgressMgr;
|
||||
class plOperationProgress
|
||||
{
|
||||
friend class plProgressMgr;
|
||||
friend class plDTProgressMgr;
|
||||
|
||||
protected:
|
||||
|
||||
hsScalar fValue, fMax;
|
||||
char fStatusText[ 256 ];
|
||||
char fTitle[ 256 ];
|
||||
UInt32 fContext;
|
||||
double fStartTime;
|
||||
|
||||
UInt32 fElapsedSecs, fRemainingSecs;
|
||||
hsScalar fAmtPerSec;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
kShouldCancel = 0x1,
|
||||
kInitUpdate = 0x2,
|
||||
kFirstUpdate = 0x4,
|
||||
kLastUpdate = 0x8,
|
||||
kAborting = 0x10,
|
||||
kRetry = 0x20,
|
||||
kOverall = 0x40,
|
||||
kAlwaysDrawText = 0x80,
|
||||
};
|
||||
UInt8 fFlags;
|
||||
|
||||
plOperationProgress *fNext, *fBack;
|
||||
|
||||
void IUpdateStats();
|
||||
|
||||
// For overall progress bars
|
||||
void IChildUpdateBegin(plOperationProgress* child);
|
||||
void IChildUpdateEnd(plOperationProgress* child);
|
||||
|
||||
plOperationProgress( hsScalar length );
|
||||
|
||||
public:
|
||||
|
||||
~plOperationProgress();
|
||||
|
||||
hsScalar GetMax( void ) const { return fMax; }
|
||||
hsScalar GetProgress( void ) const { return fValue; }
|
||||
const char * GetTitle( void ) const { return fTitle; }
|
||||
const char * GetStatusText( void ) const { return fStatusText; }
|
||||
UInt32 GetContext( void ) const { return fContext; }
|
||||
UInt32 GetElapsedSecs() { return fElapsedSecs; }
|
||||
UInt32 GetRemainingSecs() { return fRemainingSecs; }
|
||||
hsScalar GetAmtPerSec() { return fAmtPerSec; }
|
||||
|
||||
// Adds on to current value
|
||||
void Increment( hsScalar byHowMuch );
|
||||
|
||||
// Sets current value
|
||||
void SetHowMuch( hsScalar byHowMuch );
|
||||
|
||||
// Set the length
|
||||
void SetLength( hsScalar length );
|
||||
|
||||
// Sets the display text above the bar (nil for nothing)
|
||||
void SetStatusText( const char *text );
|
||||
|
||||
// Sets the title
|
||||
void SetTitle( const char *title );
|
||||
|
||||
// Application data
|
||||
void SetContext( UInt32 context ) { fContext = context;}
|
||||
|
||||
hsBool IsDone( void ) { return ( fValue < fMax ) ? false : true; }
|
||||
|
||||
// True if this is the initial update (progress was just created)
|
||||
bool IsInitUpdate() { return hsCheckBits(fFlags, kInitUpdate); }
|
||||
// True if this is the first time the progress was updated
|
||||
bool IsFirstUpdate() { return hsCheckBits(fFlags, kFirstUpdate); }
|
||||
// Returns true if this is the last update you'll get from this
|
||||
// operation (because it's getting deleted)
|
||||
bool IsLastUpdate() { return hsCheckBits(fFlags, kLastUpdate); }
|
||||
|
||||
// This type of progress is just tracking the overall progress of it's children
|
||||
bool IsOverallProgress() { return hsCheckBits(fFlags, kOverall); }
|
||||
|
||||
// Set if this progress is aborting before it completes. This will let any overall
|
||||
// progress bars above this one know to adjust their totals to not include any amount
|
||||
// that wasn't completed, and will set this progress bar to zero
|
||||
void SetAborting();
|
||||
// If you're reusing an existing progress bar to retry a failed operation, call this.
|
||||
// It will set the retry flag, and reset the progress bar so the next update will
|
||||
// count as the first. If you set retry in RegisterOperation, don't use this too.
|
||||
void SetRetry();
|
||||
bool IsRetry() { return hsCheckBits(fFlags, kRetry); }
|
||||
|
||||
// The progress manager can decide at any time to cancel your operation on you. Check this
|
||||
// value if you want to play nice and behave.
|
||||
bool ShouldCancel() const { return hsCheckBits(fFlags, kShouldCancel); }
|
||||
|
||||
bool AlwaysDrawText() const { return hsCheckBits(fFlags, kAlwaysDrawText); }
|
||||
|
||||
// Please ignore this and don't use it unless you're me :P
|
||||
plOperationProgress* GetPrev() const { return fBack; }
|
||||
plOperationProgress* GetNext() const { return fNext; }
|
||||
|
||||
// Or this
|
||||
void SetCancelFlag( hsBool f ) { hsChangeBits(fFlags, kShouldCancel, f); }
|
||||
};
|
||||
|
||||
// This is a callback proc you set that gets called every time the progressManager
|
||||
// needs updating (like, say, you need to redraw progress bars). The client generally
|
||||
// sets this callback and nobody should ever touch it.
|
||||
typedef void(*plProgressMgrCallbackProc)( plOperationProgress* );
|
||||
|
||||
//// Manager Class Definition ////////////////////////////////////////////////
|
||||
|
||||
class plProgressMgr
|
||||
{
|
||||
friend class plOperationProgress;
|
||||
|
||||
public:
|
||||
// this must match the order of the fStaticTextIDs array
|
||||
// for it to be useful
|
||||
enum StaticText
|
||||
{
|
||||
kNone,
|
||||
kUpdateText,
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
static plProgressMgr *fManager;
|
||||
static int fImageRotation[];
|
||||
static int fStaticTextIDs[];
|
||||
|
||||
protected:
|
||||
|
||||
plProgressMgr();
|
||||
|
||||
plOperationProgress *fOperations;
|
||||
|
||||
plProgressMgrCallbackProc fCallbackProc;
|
||||
|
||||
StaticText fCurrentStaticText;
|
||||
|
||||
void IUpdateCallbackProc(plOperationProgress* progress);
|
||||
// For derived classes to use, so they don't have to set a callback proc
|
||||
virtual void IDerivedCallbackProc(plOperationProgress* progress) {}
|
||||
|
||||
void IUpdateFlags(plOperationProgress* progress);
|
||||
|
||||
plOperationProgress* IRegisterOperation(hsScalar length, const char *title, StaticText staticTextType, bool isRetry, bool isOverall, bool alwaysDrawText);
|
||||
// Called by the operation
|
||||
void IUnregisterOperation(plOperationProgress* op);
|
||||
|
||||
virtual void Activate() {}
|
||||
virtual void Deactivate() {}
|
||||
|
||||
static plProgressMgr *IGetManager( void ) { return fManager; }
|
||||
|
||||
public:
|
||||
|
||||
virtual ~plProgressMgr();
|
||||
|
||||
static plProgressMgr* GetInstance() { return fManager; }
|
||||
static int GetLoadingFrameID(int index);
|
||||
static int GetStaticTextID(StaticText staticTextType);
|
||||
|
||||
virtual void Draw( plPipeline *p ) { }
|
||||
|
||||
plOperationProgress* RegisterOperation(hsScalar length, const char *title = nil, StaticText staticTextType = kNone, bool isRetry = false, bool alwaysDrawText = false);
|
||||
plOperationProgress* RegisterOverallOperation(hsScalar length, const char *title = nil, StaticText staticTextType = kNone, bool alwaysDrawText = false);
|
||||
|
||||
|
||||
plProgressMgrCallbackProc SetCallbackProc( plProgressMgrCallbackProc proc );
|
||||
|
||||
hsBool IsActive( void ) const { return ( fOperations != nil ) ? true : false; }
|
||||
|
||||
void CancelAllOps( void );
|
||||
};
|
||||
|
||||
|
||||
#endif //_plProgressMgr_h
|
||||
|
||||
|
Reference in New Issue
Block a user