Browse Source

Merge pull request #330 from Hoikas/progress-fixes

OpProgress Improvements
Adam Johnson 12 years ago
parent
commit
51866d11ac
  1. 1
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  2. 1
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp
  3. 15
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  4. 5
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
  5. 56
      Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp
  6. 2
      Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h

1
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp

@ -338,6 +338,7 @@ void plNCAgeJoiner::ExecNextOp () {
((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(nil); ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(nil);
delete progressBar; delete progressBar;
progressBar = nil; progressBar = nil;
nc->EndTask();
nextOp = kEnableClickables; nextOp = kEnableClickables;
} }

1
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp

@ -216,6 +216,7 @@ void plNCAgeLeaver::ExecNextOp () {
//==================================================================== //====================================================================
case kUnloadAge: { case kUnloadAge: {
nc->BeginTask();
NetCliGameDisconnect(); NetCliGameDisconnect();
// Cull nodes that were part of this age vault (but not shared by the player's vault) // Cull nodes that were part of this age vault (but not shared by the player's vault)

15
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -131,8 +131,7 @@ plNetClientMgr::plNetClientMgr() :
fLocalPlayerKey(nil), fLocalPlayerKey(nil),
fMsgHandler(this), fMsgHandler(this),
fJoinOrder(0), fJoinOrder(0),
// fProgressBar( nil ), fTaskProgBar(nullptr),
fTaskProgBar( nil ),
fMsgRecorder(nil), fMsgRecorder(nil),
fServerTimeOffset(0), fServerTimeOffset(0),
fTimeSamples(0), fTimeSamples(0),
@ -168,8 +167,8 @@ plNetClientMgr::~plNetClientMgr()
if (this==GetInstance()) if (this==GetInstance())
SetInstance(nil); // we're going down boys SetInstance(nil); // we're going down boys
IClearPendingLoads(); IClearPendingLoads();
delete fTaskProgBar;
} }
// //
@ -1467,6 +1466,16 @@ void plNetClientMgr::ClearPendingPagingRoomMsgs()
fPendingPagingRoomMsgs.clear(); fPendingPagingRoomMsgs.clear();
} }
void plNetClientMgr::BeginTask()
{
fTaskProgBar = plProgressMgr::GetInstance()->RegisterOverallOperation(0.f);
}
void plNetClientMgr::EndTask()
{
delete fTaskProgBar;
fTaskProgBar = nullptr;
}
bool plNetClientMgr::DebugMsgV(const char* fmt, va_list args) const bool plNetClientMgr::DebugMsgV(const char* fmt, va_list args) const
{ {

5
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h

@ -134,8 +134,7 @@ public:
}; };
private: private:
// plOperationProgress *fProgressBar; plOperationProgress* fTaskProgBar;
plOperationProgress *fTaskProgBar;
typedef std::list<PendingLoad*> PendingLoadsList; typedef std::list<PendingLoad*> PendingLoadsList;
PendingLoadsList fPendingLoads; PendingLoadsList fPendingLoads;
@ -370,6 +369,8 @@ public:
void NotifyRcvdAllSDLStates(); void NotifyRcvdAllSDLStates();
plOperationProgress* GetTaskProgBar() { return fTaskProgBar; } plOperationProgress* GetTaskProgBar() { return fTaskProgBar; }
void BeginTask();
void EndTask();
bool DebugMsgV(const char* fmt, va_list args) const; bool DebugMsgV(const char* fmt, va_list args) const;
bool ErrorMsgV(const char* fmt, va_list args) const; bool ErrorMsgV(const char* fmt, va_list args) const;

56
Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp

@ -138,9 +138,7 @@ void plDTProgressMgr::Draw( plPipeline *p )
width = scrnWidth - 64; width = scrnWidth - 64;
height = 16; height = 16;
x = ( scrnWidth - width ) >> 1; x = ( scrnWidth - width ) >> 1;
y = scrnHeight - 32 - height; y = scrnHeight - 44 - (2 * height) - text.GetFontSize();
if( fOperations->GetNext() == nil )
y -= text.GetFontSize() + 8 + height + 4;
text.SetDrawOnTopMode( true ); text.SetDrawOnTopMode( true );
@ -166,7 +164,7 @@ void plDTProgressMgr::Draw( plPipeline *p )
for( prog = fOperations; prog != nil; prog = prog->GetNext() ) for( prog = fOperations; prog != nil; prog = prog->GetNext() )
{ {
IDrawTheStupidThing( p, prog, x, y, width, height ); if (IDrawTheStupidThing(p, prog, x, y, width, height))
y -= text.GetFontSize() + 8 + height + 4; y -= text.GetFontSize() + 8 + height + 4;
} }
@ -175,10 +173,11 @@ void plDTProgressMgr::Draw( plPipeline *p )
//// IDrawTheStupidThing ///////////////////////////////////////////////////// //// IDrawTheStupidThing /////////////////////////////////////////////////////
void plDTProgressMgr::IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog, bool plDTProgressMgr::IDrawTheStupidThing(plPipeline *p, plOperationProgress *prog,
uint16_t x, uint16_t y, uint16_t width, uint16_t height ) uint16_t x, uint16_t y, uint16_t width, uint16_t height)
{ {
plDebugText &text = plDebugText::Instance(); plDebugText &text = plDebugText::Instance();
bool drew_something = false;
// Lets just set the color to blue // Lets just set the color to blue
uint32_t color = 0xff302b3a; uint32_t color = 0xff302b3a;
@ -204,48 +203,63 @@ void plDTProgressMgr::IDrawTheStupidThing( plPipeline *p, plOperationProgress
if( drawWidth > 0 ) if( drawWidth > 0 )
text.DrawRect( drawX, y, rightX, y + height, color ); text.DrawRect( drawX, y, rightX, y + height, color );
int timeRemain = prog->fRemainingSecs; uint32_t timeRemain = prog->fRemainingSecs;
char remainStr[1024]; if (timeRemain > 0) {
strcpy(remainStr, "APPROXIMATELY "); plStringStream ss;
ss << "APPROXIMATELY ";
if (timeRemain > 3600) if (timeRemain > 3600)
{ {
const char* term = ((timeRemain / 3600) > 1) ? "HOURS" : "HOUR"; uint32_t hours = timeRemain / 3600;
sprintf(remainStr, "%s%d %s ", remainStr, (timeRemain / 3600), term); const char* plural = (hours > 1) ? "S" : "";
ss << hours << " HOUR" << plural << " ";
timeRemain %= 3600; timeRemain %= 3600;
} }
if (timeRemain > 60) if (timeRemain > 60)
{ {
const char* term = ((timeRemain / 60) > 1) ? "MINUTES" : "MINUTE"; uint32_t minutes = timeRemain / 60;
sprintf(remainStr, "%s%d %s ", remainStr, (timeRemain / 60), term); const char* plural = (minutes > 1) ? "S" : "";
ss << minutes << " MINUTE" << plural << " ";
timeRemain %= 60; timeRemain %= 60;
} }
const char* unitTerm = (timeRemain == 1) ? "SECOND" : "SECONDS"; if (timeRemain > 0)
sprintf(remainStr, "%s%d %s REMAINING", remainStr, timeRemain, unitTerm); {
const char* plural = (timeRemain > 1) ? "S" : "";
text.DrawString(x, y + height + 2, remainStr, (uint32_t)0xff635e6d ); ss << timeRemain << " SECOND" << plural << " ";
}
ss << "REMAINING";
text.DrawString(x, y + height + 2, ss.GetString().c_str(), (uint32_t)0xff635e6d);
}
x -= 2; x -= 2;
y -= 2; y -= 2;
drew_something = true;
} }
y -= ( text.GetFontSize() << 1 ) + 4; y -= ( text.GetFontSize() << 1 ) + 4;
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
bool drawText = true; static bool drawText = true;
#else #else
bool drawText = false; static bool drawText = false;
#endif #endif
if (drawText) if (drawText)
{ {
if( prog->GetTitle()[ 0 ] != 0 ) if (prog->GetTitle())
{ {
text.DrawString( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 ); text.DrawString( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 );
x += (uint16_t)text.CalcStringWidth( prog->GetTitle() ); x += (uint16_t)text.CalcStringWidth( prog->GetTitle() );
drew_something = true;
} }
if( prog->GetStatusText()[ 0 ] != 0 ) if (prog->GetStatusText())
{
text.DrawString( x, y, prog->GetStatusText(), (uint32_t)0xccb0b0b0 ); text.DrawString( x, y, prog->GetStatusText(), (uint32_t)0xccb0b0b0 );
drew_something = true;
} }
}
// return whether or not we drew stuff
return drew_something;
} }

2
Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h

@ -70,7 +70,7 @@ class plDTProgressMgr : public plProgressMgr
void Activate(); void Activate();
void Deactivate(); void Deactivate();
void IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog, bool IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog,
uint16_t x, uint16_t y, uint16_t width, uint16_t height ); uint16_t x, uint16_t y, uint16_t width, uint16_t height );
public: public:

Loading…
Cancel
Save