diff --git a/Source/Client/Mode/GameModeNotices.cpp b/Source/Client/Mode/GameModeNotices.cpp index 9dbb5698..2ccca872 100644 --- a/Source/Client/Mode/GameModeNotices.cpp +++ b/Source/Client/Mode/GameModeNotices.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "Client/Application/Launcher.h" #include "Client/Input/InputCharset.h" #include "Client/Mode/CGameMode.h" @@ -7654,7 +7655,7 @@ void CGameMode::sub_D1A520(int unknown_0004, std::string name, std::string text, body = std::move(linked); } if (std::strstr(message.data(), g_whisperItemLinkTag.c_str()) != nullptr) { - body = reinterpret_cast(g_chatSuggestions)->ConvertChat(body); + body = static_cast(g_windowMgr.window_01C8)->ConvertChat(body); header = header + " ] : " + body; } else { header = header + " ] : " + message.data(); @@ -7716,7 +7717,7 @@ void CGameMode::sub_D1A520(int unknown_0004, std::string name, std::string text, if (flag) { if (UIBroadcastBalloon* balloon = this->EnsureBroadcastBalloon()) { if (prefix.find(g_whisperItemLinkTag) != std::string::npos) { - prefix = reinterpret_cast(g_chatSuggestions)->ConvertChat(prefix); + prefix = static_cast(g_windowMgr.window_01C8)->ConvertChat(prefix); } { std::string linked; diff --git a/Source/Client/Mode/GameModePackets.cpp b/Source/Client/Mode/GameModePackets.cpp index 1ebd2a4a..912044ff 100644 --- a/Source/Client/Mode/GameModePackets.cpp +++ b/Source/Client/Mode/GameModePackets.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "Resource/World/TerrainResource.h" #include "Client/Application/Launcher.h" #include "File/ShortcutFilename.h" @@ -15362,7 +15363,7 @@ void CGameMode::ReceiveColorBroadcast(const unsigned char* data) { BroadcastBalloonMessage balloonMessage{{}, {}, std::chrono::seconds(20), 12, 0x40000000, 0, 0}; balloonMessage.start = std::chrono::system_clock::now(); balloonMessage.fontHeight = *reinterpret_cast(data + 10); - message = reinterpret_cast(g_chatSuggestions)->ConvertChat(message); + message = static_cast(g_windowMgr.window_01C8)->ConvertChat(message); balloonMessage.lines.emplace_back(message, color); balloon->AddMessage(0, balloonMessage); g_windowMgr.SendNotice(3, 0, 0, 0, 0, 0); @@ -15475,7 +15476,7 @@ void CGameMode::ReceiveTaggedBroadcast(const unsigned char* data) { ); } - message = reinterpret_cast(g_chatSuggestions)->ConvertChat(message); + message = static_cast(g_windowMgr.window_01C8)->ConvertChat(message); std::string linked; DisplayNavigationLink(linked, message); message = std::move(linked); diff --git a/Source/UI/Chat/UINewChatWnd.h b/Source/UI/Chat/UINewChatWnd.h index e2de33eb..d5f89ab0 100644 --- a/Source/UI/Chat/UINewChatWnd.h +++ b/Source/UI/Chat/UINewChatWnd.h @@ -6,6 +6,7 @@ #include #include +class UIChatHisBox; class UITabControl; extern std::uint8_t g_chatInputFlag; @@ -28,6 +29,7 @@ public: void Slot43() override; void SaveChatLogs(); void RefreshTabs(bool arrange); + std::string ConvertChat(std::string text); private: /* 00BC */ int unknown_00BC; @@ -40,7 +42,7 @@ private: /* 00D8 */ std::uint32_t m_listColor; /* 00DC */ unsigned char unknown_00DC[0x14]; /* 00F0 */ int unknown_00F0; - /* 00F4 */ std::vector m_tabs; + /* 00F4 */ std::vector m_tabs; /* 0100 */ unsigned char unknown_0100[0x8]; /* 0108 */ int m_lockButtonX; /* 010C */ int m_chatModeX; diff --git a/Source/UI/Quest/UIQuestDisplay.cpp b/Source/UI/Quest/UIQuestDisplay.cpp index c1b9e4a4..9bdb4cb7 100644 --- a/Source/UI/Quest/UIQuestDisplay.cpp +++ b/Source/UI/Quest/UIQuestDisplay.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "UI/Quest/UIQuestDisplay.h" #include "Client/Input/Mouse.h" #include "Contents/MessageTable.h" @@ -67,8 +68,8 @@ void UIQuestDisplay::Paint() { description = static_cast(DisplayTipBoxTextTag(description)); description = static_cast(DisplayItemTextTag(description)); description = static_cast(RemoveTextLinkInfo(description)); - if (this->m_context->chatConverter) { - description = this->m_context->chatConverter->ConvertChat(description); + if (g_windowMgr.window_01C8) { + description = static_cast(g_windowMgr.window_01C8)->ConvertChat(description); } std::string navigation; DisplayNavigationLink(navigation, description); @@ -113,8 +114,8 @@ void UIQuestDisplay::Paint() { description = static_cast(DisplayTipBoxTextTag(description)); description = static_cast(DisplayItemTextTag(description)); description = static_cast(RemoveTextLinkInfo(description)); - if (this->m_context->chatConverter) { - description = this->m_context->chatConverter->ConvertChat(description); + if (g_windowMgr.window_01C8) { + description = static_cast(g_windowMgr.window_01C8)->ConvertChat(description); } std::string huntNavigation; DisplayNavigationLink(huntNavigation, description); diff --git a/Source/UI/Shortcuts/UIShortCutWnd.cpp b/Source/UI/Shortcuts/UIShortCutWnd.cpp index e588f747..7cbef6fa 100644 --- a/Source/UI/Shortcuts/UIShortCutWnd.cpp +++ b/Source/UI/Shortcuts/UIShortCutWnd.cpp @@ -510,7 +510,7 @@ void UINewChatWnd::Show(int visible) { g_windowMgr.StoreSnapRectangle(this); } else g_windowMgr.RemoveSnapRectangle(this); - for (UIWindow* tab : this->m_tabs) { + for (UIChatHisBox* tab : this->m_tabs) { tab->Show(this->geometry.visible); } @@ -943,7 +943,7 @@ void UINewChatWnd::SaveChatLogs() { std::string name; int index = 0; - for (std::vector::iterator tab = this->m_tabs.begin(); tab != this->m_tabs.end(); ++tab, ++index) { + for (std::vector::iterator tab = this->m_tabs.begin(); tab != this->m_tabs.end(); ++tab, ++index) { const std::map::iterator info = g_session.m_noSubChatWnds.find(index); if (info != g_session.m_noSubChatWnds.end()) { name = info->second.name; @@ -957,7 +957,7 @@ void UINewChatWnd::SaveChatLogs() { sprintf(path, "%s\\Chat\\Chat_%s_%03d.txt", g_applicationDirectory, name.c_str(), number); } - if (static_cast(*tab)->SaveChatLog(path)) { + if ((*tab)->SaveChatLog(path)) { std::string message(path); message += " is Saved."; g_windowMgr.SendNotice(3, 0, 0, 0, 0, 0); @@ -990,7 +990,7 @@ void UINewChatWnd::SaveChatLogs() { void UINewChatWnd::RefreshTabs(bool arrange) { if (arrange && this->geometry.unknown_0030 != 0) { int index = 0; - for (std::vector::iterator tab = this->m_tabs.begin(); tab != this->m_tabs.end(); ++tab, ++index) { + for (std::vector::iterator tab = this->m_tabs.begin(); tab != this->m_tabs.end(); ++tab, ++index) { if (this->m_currentTab == index) { (*tab)->Move(5, this->m_inputOffsetY + 2); (*tab)->Invalidate(); diff --git a/Source/UI/Text/UITextViewer.h b/Source/UI/Text/UITextViewer.h index 931e8237..7177f66e 100644 --- a/Source/UI/Text/UITextViewer.h +++ b/Source/UI/Text/UITextViewer.h @@ -6,7 +6,6 @@ #include class UITextButton; -class UIChatHisBox; class TextViewerActions { public: @@ -23,7 +22,6 @@ struct UITextViewerContext { TextViewerActions& actions; HWND& applicationWindow; - const std::vector* const& chatConversions; }; class UITextViewer : public UIListBox { @@ -55,7 +53,6 @@ public: private: UITextViewerContext* m_text; - std::string ConvertChat(std::string text); std::pair LinkPosition(unsigned position, unsigned addedLines); void AddLinks(const char* text, unsigned addedLines, int kind); bool AddItemLinks(std::string text, unsigned addedLines); diff --git a/Source/UI/Text/UITextViewerLinks.cpp b/Source/UI/Text/UITextViewerLinks.cpp index 3c6bab4c..237f52ce 100644 --- a/Source/UI/Text/UITextViewerLinks.cpp +++ b/Source/UI/Text/UITextViewerLinks.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "Client/Input/InputCharset.h" #include "Contents/Items/ItemNaming.h" #include "Render/Text/TextContext.h" @@ -18,15 +19,11 @@ // OFFSET: 0x0091B800 // FUNCTION: fn_12605 -std::string UITextViewer::ConvertChat(std::string text) { +std::string UINewChatWnd::ConvertChat(std::string text) { std::string converted; DisplayNavigationLink(converted, text); - const auto* owners = this->m_text->chatConversions; - - if (owners) { - for (std::size_t index = 0; index < owners->size(); ++index) { - converted = (*owners)[0]->Convert(converted); - } + for (std::size_t index = 0; index < this->m_tabs.size(); ++index) { + converted = this->m_tabs[0]->Convert(converted); } return converted; @@ -60,8 +57,8 @@ bool UITextViewer::AddItemLinks(std::string text, unsigned addedLines) { parsed = DisplayTextTag(std::move(parsed), "", ""); parsed = DisplayTextTag(std::move(parsed), "", ""); - if (this->m_text->chatConversions) { - parsed = this->ConvertChat(std::move(parsed)); + if (g_windowMgr.window_01C8) { + parsed = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(parsed)); } std::string navigation; @@ -103,8 +100,8 @@ bool UITextViewer::AddNaviLinks(std::string text, unsigned addedLines) { parsed = DisplayTextTag(std::move(parsed), "", ""); parsed = DisplayTextTag(std::move(parsed), "", ""); - if (this->m_text->chatConversions) { - parsed = this->ConvertChat(std::move(parsed)); + if (g_windowMgr.window_01C8) { + parsed = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(parsed)); } parsed = DisplayTextTag(std::move(parsed), "", ""); @@ -203,8 +200,8 @@ bool UITextViewer::AddQuestLinks(std::string text, unsigned addedLines) { parsed = DisplayTextTag(std::move(parsed), "", ""); parsed = DisplayTextTag(std::move(parsed), "", ""); - if (this->m_text->chatConversions) { - parsed = this->ConvertChat(std::move(parsed)); + if (g_windowMgr.window_01C8) { + parsed = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(parsed)); } std::string navigation; @@ -248,8 +245,8 @@ void UITextViewer::AddTipLinks(std::string text, unsigned addedLines) { parsed = DisplayTextTag(std::move(parsed), "", ""); parsed = DisplayTextTag(std::move(parsed), "", ""); - if (this->m_text->chatConversions) { - parsed = this->ConvertChat(std::move(parsed)); + if (g_windowMgr.window_01C8) { + parsed = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(parsed)); } std::string navigation; @@ -345,8 +342,8 @@ bool UITextViewer::AddUrlLinks(std::string text, unsigned addedLines) { parsed = DisplayTextTag(std::move(parsed), "", ""); parsed = DisplayTextTag(std::move(parsed), "", ""); - if (this->m_text->chatConversions) { - parsed = this->ConvertChat(std::move(parsed)); + if (g_windowMgr.window_01C8) { + parsed = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(parsed)); } parsed = DisplayTextTag(std::move(parsed), "", ""); diff --git a/Source/UI/Text/UITextViewerMessages.cpp b/Source/UI/Text/UITextViewerMessages.cpp index c5373375..dc3db739 100644 --- a/Source/UI/Text/UITextViewerMessages.cpp +++ b/Source/UI/Text/UITextViewerMessages.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "UI/Window/UIWindowMgr.h" #include "Contents/Items/ItemInfo.h" #include "UI/Lists/UIScrollBar.h" @@ -138,8 +139,8 @@ void UITextViewer::AppendText(char* text, int width, bool carriageReturns, bool display = DisplayTextTag(std::move(display), "", ""); display = RemoveTextLinkInfo(std::move(display)); - if (this->m_text->chatConversions) { - display = this->ConvertChat(std::move(display)); + if (g_windowMgr.window_01C8) { + display = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(display)); } std::string navigation; diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 7952e970..e3a0a2b0 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -1,3 +1,4 @@ +#include "UI/Chat/UINewChatWnd.h" #include "Client/Application/Launcher.h" #include "Client/Input/InputCharset.h" #include "UI/Window/WindowDialogs.h" @@ -1536,8 +1537,8 @@ std::string UIWindow::FitDisplayText(int width, const char* text, int family, in display = DisplayTextTag(std::move(display), "", ""); display = RemoveTextLinkInfo(std::move(display)); - if (this->m_context->chatConverter) { - display = this->m_context->chatConverter->ConvertChat(std::move(display)); + if (g_windowMgr.window_01C8) { + display = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(display)); } std::string navigation; @@ -1606,8 +1607,8 @@ std::string UIWindow::FitVerticalDisplayText(int height, const char* text, int f display = DisplayTextTag(std::move(display), "", ""); display = RemoveTextLinkInfo(std::move(display)); - if (this->m_context->chatConverter) { - display = this->m_context->chatConverter->ConvertChat(std::move(display)); + if (g_windowMgr.window_01C8) { + display = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(display)); } std::string navigation;