From fbe821ab112b1f3fdf69329d0cc09c52797caede Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 27 May 2013 23:02:09 -0400 Subject: [PATCH 1/3] OpProgress: only skip space if we drew something --- .../PubUtilLib/plPipeline/plDTProgressMgr.cpp | 29 ++++++++++++------- .../PubUtilLib/plPipeline/plDTProgressMgr.h | 6 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp index dc5ce0d7..7a7d8bcb 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp @@ -138,9 +138,7 @@ void plDTProgressMgr::Draw( plPipeline *p ) width = scrnWidth - 64; height = 16; x = ( scrnWidth - width ) >> 1; - y = scrnHeight - 32 - height; - if( fOperations->GetNext() == nil ) - y -= text.GetFontSize() + 8 + height + 4; + y = scrnHeight - 44 - (2 * height) - text.GetFontSize(); text.SetDrawOnTopMode( true ); @@ -166,8 +164,8 @@ void plDTProgressMgr::Draw( plPipeline *p ) for( prog = fOperations; prog != nil; prog = prog->GetNext() ) { - IDrawTheStupidThing( p, prog, x, y, width, height ); - y -= text.GetFontSize() + 8 + height + 4; + if (IDrawTheStupidThing(p, prog, x, y, width, height)) + y -= text.GetFontSize() + 8 + height + 4; } text.SetDrawOnTopMode( false ); @@ -175,10 +173,11 @@ void plDTProgressMgr::Draw( plPipeline *p ) //// IDrawTheStupidThing ///////////////////////////////////////////////////// -void plDTProgressMgr::IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog, - uint16_t x, uint16_t y, uint16_t width, uint16_t height ) +bool plDTProgressMgr::IDrawTheStupidThing(plPipeline *p, plOperationProgress *prog, + uint16_t x, uint16_t y, uint16_t width, uint16_t height) { plDebugText &text = plDebugText::Instance(); + bool drew_something = false; // Lets just set the color to blue uint32_t color = 0xff302b3a; @@ -226,26 +225,34 @@ void plDTProgressMgr::IDrawTheStupidThing( plPipeline *p, plOperationProgress x -= 2; y -= 2; + drew_something = true; } y -= ( text.GetFontSize() << 1 ) + 4; #ifndef PLASMA_EXTERNAL_RELEASE - bool drawText = true; + static bool drawText = true; #else - bool drawText = false; + static bool drawText = false; #endif if (drawText) { - if( prog->GetTitle()[ 0 ] != 0 ) + if (prog->GetTitle()) { text.DrawString( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 ); 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 ); + drew_something = true; + } } + + // return whether or not we drew stuff + return drew_something; } diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h index 9c548380..8cb3d50c 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.h @@ -61,7 +61,7 @@ class plPipeline; class plDTProgressMgr : public plProgressMgr { protected: - int32_t fCurrentImage; + int32_t fCurrentImage; float fLastDraw; plPlate* fActivePlate; plPlate* fStaticTextPlate; @@ -70,8 +70,8 @@ class plDTProgressMgr : public plProgressMgr void Activate(); void Deactivate(); - void IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog, - uint16_t x, uint16_t y, uint16_t width, uint16_t height ); + bool IDrawTheStupidThing( plPipeline *p, plOperationProgress *prog, + uint16_t x, uint16_t y, uint16_t width, uint16_t height ); public: From f27cf09cf5ccd6098df7b8e274a0a36a5536847e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 27 May 2013 23:18:03 -0400 Subject: [PATCH 2/3] StringStream means less recursive sprintf... --- .../PubUtilLib/plPipeline/plDTProgressMgr.cpp | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp index 7a7d8bcb..94ba4a42 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp @@ -203,25 +203,32 @@ bool plDTProgressMgr::IDrawTheStupidThing(plPipeline *p, plOperationProgress if( drawWidth > 0 ) text.DrawRect( drawX, y, rightX, y + height, color ); - int timeRemain = prog->fRemainingSecs; - char remainStr[1024]; - strcpy(remainStr, "APPROXIMATELY "); - if (timeRemain > 3600) - { - const char* term = ((timeRemain / 3600) > 1) ? "HOURS" : "HOUR"; - sprintf(remainStr, "%s%d %s ", remainStr, (timeRemain / 3600), term); - timeRemain %= 3600; - } - if (timeRemain > 60) - { - const char* term = ((timeRemain / 60) > 1) ? "MINUTES" : "MINUTE"; - sprintf(remainStr, "%s%d %s ", remainStr, (timeRemain / 60), term); - timeRemain %= 60; + uint32_t timeRemain = prog->fRemainingSecs; + if (timeRemain > 0) { + plStringStream ss; + ss << "APPROXIMATELY "; + if (timeRemain > 3600) + { + uint32_t hours = timeRemain / 3600; + const char* plural = (hours > 1) ? "S" : ""; + ss << hours << " HOUR" << plural << " "; + timeRemain %= 3600; + } + if (timeRemain > 60) + { + uint32_t minutes = timeRemain / 60; + const char* plural = (minutes > 1) ? "S" : ""; + ss << minutes << " MINUTE" << plural << " "; + timeRemain %= 60; + } + if (timeRemain > 0) + { + const char* plural = (timeRemain > 1) ? "S" : ""; + ss << timeRemain << " SECOND" << plural << " "; + } + ss << "REMAINING"; + text.DrawString(x, y + height + 2, ss.GetString().c_str(), (uint32_t)0xff635e6d); } - const char* unitTerm = (timeRemain == 1) ? "SECOND" : "SECONDS"; - sprintf(remainStr, "%s%d %s REMAINING", remainStr, timeRemain, unitTerm); - - text.DrawString(x, y + height + 2, remainStr, (uint32_t)0xff635e6d ); x -= 2; y -= 2; From dcb0e2f046724272e5f4546d903ed949c2d80c24 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 27 May 2013 23:52:09 -0400 Subject: [PATCH 3/3] Ensure there is always book-spinning while linking This should help people realize that things are happening... Even if whatever server they're connected to takes a very long time to process a join request. At some point in the future, the linking process should be de-serialized. --- .../PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp | 1 + .../PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp | 1 + .../PubUtilLib/plNetClient/plNetClientMgr.cpp | 15 ++++++++++++--- .../PubUtilLib/plNetClient/plNetClientMgr.h | 11 ++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index 8288317f..582e3599 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -338,6 +338,7 @@ void plNCAgeJoiner::ExecNextOp () { ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(nil); delete progressBar; progressBar = nil; + nc->EndTask(); nextOp = kEnableClickables; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp index 5cc98ed7..c15310e0 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeLeaver.cpp @@ -216,6 +216,7 @@ void plNCAgeLeaver::ExecNextOp () { //==================================================================== case kUnloadAge: { + nc->BeginTask(); NetCliGameDisconnect(); // Cull nodes that were part of this age vault (but not shared by the player's vault) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 5e10ef77..16c60dce 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -131,8 +131,7 @@ plNetClientMgr::plNetClientMgr() : fLocalPlayerKey(nil), fMsgHandler(this), fJoinOrder(0), - // fProgressBar( nil ), - fTaskProgBar( nil ), + fTaskProgBar(nullptr), fMsgRecorder(nil), fServerTimeOffset(0), fTimeSamples(0), @@ -168,8 +167,8 @@ plNetClientMgr::~plNetClientMgr() if (this==GetInstance()) SetInstance(nil); // we're going down boys - IClearPendingLoads(); + delete fTaskProgBar; } // @@ -1467,6 +1466,16 @@ void plNetClientMgr::ClearPendingPagingRoomMsgs() 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 { diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h index 7d034687..4cac0c0f 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h @@ -134,9 +134,8 @@ public: }; private: - // plOperationProgress *fProgressBar; - plOperationProgress *fTaskProgBar; - + plOperationProgress* fTaskProgBar; + typedef std::list PendingLoadsList; PendingLoadsList fPendingLoads; @@ -369,8 +368,10 @@ public: void NotifyRcvdAllSDLStates(); - plOperationProgress* GetTaskProgBar() { return fTaskProgBar; } - + plOperationProgress* GetTaskProgBar() { return fTaskProgBar; } + void BeginTask(); + void EndTask(); + bool DebugMsgV(const char* fmt, va_list args) const; bool ErrorMsgV(const char* fmt, va_list args) const; bool WarningMsgV(const char* fmt, va_list args) const;