diff --git a/mp/src/game/client/neo/ui/neo_loading.cpp b/mp/src/game/client/neo/ui/neo_loading.cpp index 5facbeac..7377e70e 100644 --- a/mp/src/game/client/neo/ui/neo_loading.cpp +++ b/mp/src/game/client/neo/ui/neo_loading.cpp @@ -137,27 +137,20 @@ void CNeoLoading::FetchGameUIPanels() { continue; } -#define NAME_EQ(STRCHECK) (V_strcmp(curLoadChPanelName, STRCHECK) == 0) -#define CLASS_EQ(CNAME_CHECK) (V_strcmp(curLoadChPanelClass, CNAME_CHECK) == 0) - if (NAME_EQ("Progress")) + if (V_strcmp(curLoadChPanelName, "Progress") == 0) { - Assert(CLASS_EQ("ProgressBar")); + Assert(V_strcmp(curLoadChPanelClass, "ProgressBar") == 0); m_pProgressBarMain = static_cast(pPanel); } - else if (NAME_EQ("InfoLabel")) + else if (V_strcmp(curLoadChPanelName, "InfoLabel") == 0) { - Assert(CLASS_EQ("Label")); + Assert(V_strcmp(curLoadChPanelClass, "Label") == 0); m_pLabelInfo = static_cast(pPanel); } -#if 0 - else if (NAME_EQ("TimeRemainingLabel")) - { - Assert(CLASS_EQ("Label")); - m_pLabelTimeRemaining = static_cast(pPanel); - } -#endif -#undef CLASS_EQ -#undef NAME_EQ + // NEO NOTE (nullsystem): Unused panels: + // "Progress2" - Don't seem utilized + // "TimeRemainingLabel" - Don't seem utilized + // "CancelButton" - Can't do mouse input proper/workaround doesn't work well } } @@ -181,12 +174,9 @@ void CNeoLoading::OnMainLoop(const NeoUI::Mode eMode) // NEO JANK (nullsystem): Since we don't have proper access to loading internals, // determining by localization text index should be good enough to differ between // loading and disconnect state. - const StringIndex_t iStrIdx = m_pLoadingPanel->_title->_unlocalizedTextSymbol; - NeoUI::BeginContext(&m_uiCtx, eMode, - (m_pLoadingPanel && m_pLoadingPanel->_title) ? - m_pLoadingPanel->_title->GetUText() : - L"Loading...", - "NeoLoadingMainCtx"); + vgui::TextImage *pTITitle = m_pLoadingPanel ? m_pLoadingPanel->TITitlePtr() : nullptr; + const StringIndex_t iStrIdx = pTITitle ? pTITitle->GetUnlocalizedTextSymbol() : INVALID_LOCALIZE_STRING_INDEX; + NeoUI::BeginContext(&m_uiCtx, eMode, pTITitle ? pTITitle->GetUText() : L"Loading...", "NeoLoadingMainCtx"); if (iStrIdx == m_aStrIdxMap[LOADINGSTATE_LOADING]) { NeoUI::BeginSection(); @@ -214,8 +204,7 @@ void CNeoLoading::OnMainLoop(const NeoUI::Mode eMode) m_uiCtx.bgColor = COLOR_NEOPANELFRAMEBG; NeoUI::BeginSection(true); { - // TODO: Text-Wrappable label - if (m_pLabelInfo) NeoUI::Label(m_pLabelInfo->GetTextImage()->GetUText()); + if (m_pLabelInfo) NeoUI::LabelWrap(m_pLabelInfo->GetTextImage()->GetUText()); NeoUI::Pad(); NeoUI::Label(L"Press ESC to go back"); } diff --git a/mp/src/game/client/neo/ui/neo_loading.h b/mp/src/game/client/neo/ui/neo_loading.h index 285d8d86..ed368d44 100644 --- a/mp/src/game/client/neo/ui/neo_loading.h +++ b/mp/src/game/client/neo/ui/neo_loading.h @@ -32,9 +32,6 @@ class CNeoLoading : public vgui::EditablePanel vgui::Frame *m_pLoadingPanel = nullptr; vgui::ProgressBar *m_pProgressBarMain = nullptr; vgui::Label *m_pLabelInfo = nullptr; -#if 0 - vgui::Label *m_pLabelTimeRemaining = nullptr; -#endif enum ELoadingState { diff --git a/mp/src/game/client/neo/ui/neo_ui.cpp b/mp/src/game/client/neo/ui/neo_ui.cpp index ef4fe130..d6f84c75 100644 --- a/mp/src/game/client/neo/ui/neo_ui.cpp +++ b/mp/src/game/client/neo/ui/neo_ui.cpp @@ -409,6 +409,67 @@ void GCtxSkipActive() } } +void LabelWrap(const wchar_t *wszText) +{ + if (!wszText || wszText[0] == '\0') + { + NeoUI::Pad(); + return; + } + + GCtxSkipActive(); + int iLines = 0; + if (IN_BETWEEN_AR(0, g_pCtx->iLayoutY, g_pCtx->dPanel.tall)) + { + const auto *pFontI = &g_pCtx->fonts[g_pCtx->eFont]; + const int iWszSize = V_wcslen(wszText); + int iSumWidth = 0; + int iStart = 0; + int iYOffset = 0; + int iLastSpace = 0; + for (int i = 0; i < iWszSize; ++i) + { + const wchar_t ch = wszText[i]; + if (ch == L' ') + { + iLastSpace = i; + } + const int chWidth = surface()->GetCharacterWidth(pFontI->hdl, ch); + iSumWidth += chWidth; + if (iSumWidth >= g_pCtx->dPanel.wide) + { + if (g_pCtx->eMode == MODE_PAINT) + { + GCtxDrawSetTextPos(g_pCtx->iMarginX, g_pCtx->iLayoutY + pFontI->iYOffset + iYOffset); + surface()->DrawPrintText(wszText + iStart, iLastSpace - iStart); + } + ++iLines; + + iYOffset += g_pCtx->iRowTall; + iSumWidth = 0; + iStart = iLastSpace + 1; + i = iLastSpace; + } + } + if (iSumWidth > 0) + { + if (g_pCtx->eMode == MODE_PAINT) + { + GCtxDrawSetTextPos(g_pCtx->iMarginX, g_pCtx->iLayoutY + pFontI->iYOffset + iYOffset); + surface()->DrawPrintText(wszText + iStart, iWszSize - iStart); + } + ++iLines; + } + } + + g_pCtx->iPartitionY += iLines; + g_pCtx->iLayoutY += (g_pCtx->iRowTall * iLines); + + ++g_pCtx->iWidget; + surface()->DrawSetColor(g_pCtx->normalBgColor); + surface()->DrawSetTextColor(COLOR_NEOPANELTEXTNORMAL); +} + void Label(const wchar_t *wszText) { GCtxSkipActive(); diff --git a/mp/src/game/client/neo/ui/neo_ui.h b/mp/src/game/client/neo/ui/neo_ui.h index fbe37e64..0353ad8f 100644 --- a/mp/src/game/client/neo/ui/neo_ui.h +++ b/mp/src/game/client/neo/ui/neo_ui.h @@ -210,6 +210,7 @@ struct RetButton bool bMouseDoublePressed; }; void Pad(); +void LabelWrap(const wchar_t *wszText); void Label(const wchar_t *wszText); void Label(const wchar_t *wszLabel, const wchar_t *wszText); void Tabs(const wchar_t **wszLabelsList, const int iLabelsSize, int *iIndex); diff --git a/mp/src/public/vgui_controls/Frame.h b/mp/src/public/vgui_controls/Frame.h index d864e4c4..c0ea5afb 100644 --- a/mp/src/public/vgui_controls/Frame.h +++ b/mp/src/public/vgui_controls/Frame.h @@ -133,6 +133,10 @@ class Frame : public EditablePanel // Temporarily enables or disables the fade effect rather than zeroing the fade times as done in DisableFadeEffect void SetFadeEffectDisableOverride( bool disabled ); +#ifdef NEO + TextImage *TITitlePtr() { return _title; } +#endif + protected: // Respond to mouse presses virtual void OnMousePressed(MouseCode code); @@ -206,13 +210,7 @@ class Frame : public EditablePanel Color _titleBarDisabledFgColor; Color m_InFocusBgColor; Color m_OutOfFocusBgColor; -#ifdef NEO -public: - TextImage *_title; -private: -#else TextImage *_title; -#endif #if !defined( _X360 ) Panel *_topGrip; diff --git a/mp/src/public/vgui_controls/ProgressBar.h b/mp/src/public/vgui_controls/ProgressBar.h index 72a785dd..7d5a9779 100644 --- a/mp/src/public/vgui_controls/ProgressBar.h +++ b/mp/src/public/vgui_controls/ProgressBar.h @@ -74,9 +74,6 @@ class ProgressBar : public Panel protected: int m_iProgressDirection; -#ifdef NEO -public: // Get out of my way -#endif float _progress; private: diff --git a/mp/src/public/vgui_controls/TextImage.h b/mp/src/public/vgui_controls/TextImage.h index a19ba10f..20446e7b 100644 --- a/mp/src/public/vgui_controls/TextImage.h +++ b/mp/src/public/vgui_controls/TextImage.h @@ -125,13 +125,7 @@ class TextImage : public Image int _drawWidth; // this is the width of the window we are drawing into. // if there is not enough room truncate the txt and add an elipsis -#ifdef NEO -public: - StringIndex_t _unlocalizedTextSymbol; -private: -#else StringIndex_t _unlocalizedTextSymbol; // store off the unlocalized text index for build mode -#endif wchar_t *m_pwszEllipsesPosition; bool m_bRecalculateTruncation : 1;