diff --git a/Source/UI/Window/UIRoMapWnd.cpp b/Source/UI/Window/UIRoMapWnd.cpp index f64edd18f..539cc5985 100644 --- a/Source/UI/Window/UIRoMapWnd.cpp +++ b/Source/UI/Window/UIRoMapWnd.cpp @@ -171,6 +171,11 @@ void UIRoMapWnd::DrawHoverTooltip() { DrawRoundedBorder(*this, boxX, y, width, height, 0xFFFFFF); } +// INLINED +static int CenteredTextX(UIWindow& window, std::string text, int left, int right, int fontHeight, unsigned char bold) { + return std::abs(static_cast(static_cast(window.TextWidth(text.c_str(), 0, 0, fontHeight, bold, 0) - right - left) * g_depthAverageHalf)); +} + // OFFSET: 0x00919E00 // FUNCTION: fn_12599 void UIRoMapWnd::DrawMapNames() { @@ -192,10 +197,7 @@ void UIRoMapWnd::DrawMapNames() { continue; } - const int left = area[0]; - const int right = area[2]; - const int textWidth = this->TextWidth(std::string(name).c_str(), 0, 0, fontHeight, 0, 0); - const int x = std::abs(static_cast(static_cast(textWidth - right - left) * g_depthAverageHalf)); + const int x = CenteredTextX(*this, name, area[0], area[2], fontHeight, 0); const int y = area[1] + 2; this->DrawTextAt(x + 1, y + 1, name.c_str(), 0, 0, fontHeight, outline, 0, 0); this->DrawTextAt(x, y, name.c_str(), 0, 0, fontHeight, color, 0, 0); @@ -444,6 +446,18 @@ void UIRoMapWnd::DrawRecordFaces(int) { } } +// INLINED +static bool AddRelatedName(std::string map, std::string name, std::list& records) { + for (WorldViewRecord& record : records) { + if (record.name == map) { + record.relatedNames.push_back(name); + return true; + } + } + + return false; +} + // OFFSET: 0x0091BF80 // FUNCTION: fn_12612 void UIRoMapWnd::RefreshPartyRecords() {