diff --git a/Source/UI/Lists/UIListBoxNaviSearch.h b/Source/UI/Lists/UIListBoxNaviSearch.h index 37eed59c..73e1a185 100644 --- a/Source/UI/Lists/UIListBoxNaviSearch.h +++ b/Source/UI/Lists/UIListBoxNaviSearch.h @@ -3,6 +3,8 @@ #include "UI/Lists/UIListBox.h" +#include + class UIListBox_NaviSearch : public UIListBox { public: void Resize(int width, int height) override; @@ -13,8 +15,7 @@ public: void Slot35(int value) override; void Clear() override; - /* 00D4 */ int unknown_00D4; - /* 00D8 */ int unknown_00D8; + /* 00D4 */ std::vector icons; }; #endif diff --git a/Source/UI/Navigation/UINavigationV4Wnd.h b/Source/UI/Navigation/UINavigationV4Wnd.h index 94856dbd..e7521386 100644 --- a/Source/UI/Navigation/UINavigationV4Wnd.h +++ b/Source/UI/Navigation/UINavigationV4Wnd.h @@ -8,6 +8,8 @@ class CNavi_Object; class CTexture; +class UIListBox_NaviSearch; +class UIStaticText; struct UIButtonContext; struct NavigationWindowInfo { @@ -30,6 +32,8 @@ public: std::string ObjectName(int type, void* object); std::string ObjectLabel(int type, void* object); std::string MobName(CNavi_Object* mob); + void SelectRoute(int route); + void FillRouteGroups(); /* 00B4 */ UIWindow* unknown_00B4; /* 00B8 */ UIWindow* unknown_00B8; @@ -44,9 +48,9 @@ public: /* 00DC */ UIWindow* unknown_00DC; /* 00E0 */ UIWindow* unknown_00E0; /* 00E4 */ UIWindow* unknown_00E4; - /* 00E8 */ UIWindow* unknown_00E8; - /* 00EC */ UIWindow* unknown_00EC; - /* 00F0 */ UIWindow* unknown_00F0; + /* 00E8 */ UIStaticText* unknown_00E8; + /* 00EC */ UIListBox_NaviSearch* unknown_00EC; + /* 00F0 */ UIListBox_NaviSearch* unknown_00F0; /* 00F4 */ UIWindow* unknown_00F4; /* 00F8 */ UIWindow* unknown_00F8; /* 00FC */ UIWindow* unknown_00FC; diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 5fc0d4ad..25e7c15f 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -29,6 +29,7 @@ #include "UI/UIStaticBitmap.h" #include "UI/Navigation/UINavigationV4Wnd.h" #include "UI/Navigation/UIPrivateAirplaneWnd.h" +#include "UI/Text/UIStaticText.h" #include "UI/Window/UIWindow.h" #include "UI/Window/UIWindowMgr.h" #include "UI/Window/WindowManagerWindows.h" @@ -1371,7 +1372,7 @@ bool UIWindow::FitSprite(const ActionFrame* frame, const CSprRes* sprite, int wi // FUNCTION: fn_03554 void UIListBox_NaviSearch::Clear() { UIListBox::Clear(); - this->unknown_00D8 = this->unknown_00D4; + this->icons.clear(); } // OFFSET: 0x005C6F20 @@ -1673,7 +1674,6 @@ void UIListBox_NaviSearch::Paint() { const int limit = this->geometry.height / this->lineHeight - this->bottomMargin + first; const int end = static_cast(std::min(static_cast(this->lines.size()), static_cast(limit))); std::uint32_t color = 0; - const int* icons = reinterpret_cast(this->unknown_00D4); for (int index = first, row = 0; index < end; ++index, ++row) { if (index == this->selected) { @@ -1682,7 +1682,7 @@ void UIListBox_NaviSearch::Paint() { int x = 3 - this->horizontalOffset; const int y = this->lineHeight * row; - const int icon = icons[index]; + const int icon = this->icons[index]; if (icon > 0) { const char* name = nullptr; if (icon == 1) { @@ -1843,6 +1843,75 @@ std::string UINavigationV4Wnd::ObjectLabel(int type, void* object) { return label; } +// OFFSET: 0x005C9640 +void UINavigationV4Wnd::SelectRoute(int route) { + this->unknown_00F0->Invalidate(); + this->unknown_00F0->Clear(); + if (g_navigationManager.nodePaths.empty()) { + return; + } + + g_navigationManager.unknown_12C4 = route; + if (route == -1) { + return; + } + + const int count = static_cast(g_navigationManager.nodePaths[route].size()); + std::string text; + for (int index = 0; index < count; ++index) { + NavigationTarget target = g_navigationManager.GetState(g_navigationManager.nodePaths[route][index]); + const bool unknownCell = target.x == -1000 && target.y == -1000; + if (unknownCell) { + text = this->MobName(static_cast(target.object)); + } else { + text = this->ObjectLabel(target.type, target.object); + if (target.type == 0) { + char coords[30] = {}; + std::sprintf(coords, " [%d,%d]", target.x, target.y); + text += coords; + } + } + + const int icon = target.type; + const char* line = text.c_str(); + UIListBox_NaviSearch* list = this->unknown_00F0; + list->icons.push_back(icon); + list->AddLine(line); + list->Invalidate(); + } + + this->Invalidate(); +} + +// OFFSET: 0x005C9A20 +void UINavigationV4Wnd::FillRouteGroups() { + this->unknown_00EC->Clear(); + this->unknown_00EC->Invalidate(); + for (unsigned int index = 0; index < g_navigationManager.nodePaths.size(); ++index) { + NavigationTarget target = g_navigationManager.GetState(g_navigationManager.nodePaths[index][0]); + const int count = static_cast(g_navigationManager.nodePaths[index].size()); + std::string name = this->ObjectName(target.type, target.object); + if (target.type == 0 && !target.name.empty()) { + name = target.name; + } + + char text[50]; + std::memset(text, 0, sizeof(text)); + std::sprintf(text, "[%d]%s", count, name.c_str()); + const int icon = target.type; + UIListBox_NaviSearch* list = this->unknown_00EC; + list->icons.push_back(icon); + list->AddLine(text); + list->Invalidate(); + } + + char summary[50]; + std::memset(summary, 0, sizeof(summary)); + std::sprintf(summary, LookupMessage(3210), static_cast(g_navigationManager.nodePaths.size())); + this->unknown_00E8->SetText(summary, 0); + this->Invalidate(); +} + // OFFSET: 0x00A7C580 // FUNCTION: fn_16947 void UIWindow::DrawActionSprite(