diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index 752ddfb7..3394563a 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -7334,3 +7334,51 @@ void UIMerchantItemShopWnd::Paint() { } } } + +// OFFSET: 0x00857B60 +// FUNCTION: fn_10763 +bool UIEditCtrl3::ExtractItemLink(std::string& text, std::string& link, int& position, const char* source) { + std::size_t close = text.find(g_itemLinkClose); + if (close == std::string::npos) { + return false; + } + + do { + text = text.substr(0, close); + std::size_t open = text.find(g_itemLinkOpen); + if (close != std::string::npos && open == std::string::npos) { + position += g_itemLinkClose.size(); + text = source; + text = text.substr(position); + return true; + } + + close = text.find(g_itemLinkClose); + if (open != std::string::npos) { + for (;;) { + position += open; + text = text.substr(open + g_itemLinkOpen.size()); + open = text.find(g_itemLinkOpen); + close = text.find(g_itemLinkClose); + if (open == std::string::npos) { + break; + } + + position += g_itemLinkOpen.size(); + } + + link = text; + text = source; + std::string name = ""; + if (!this->LinkDisplayName(link, name)) { + position += link.size() + g_itemLinkOpen.size() + g_itemLinkClose.size(); + text = text.substr(position); + return true; + } + + text = text.substr(position + link.size() + g_itemLinkOpen.size() + g_itemLinkClose.size()); + } + } while (close != std::string::npos); + + return true; +} diff --git a/Source/UI/Edit/UIEditCtrl.h b/Source/UI/Edit/UIEditCtrl.h index 9f8fc334..fc26eb0e 100644 --- a/Source/UI/Edit/UIEditCtrl.h +++ b/Source/UI/Edit/UIEditCtrl.h @@ -152,6 +152,7 @@ public: int DecodeLinkCards(std::vector& fields, const char* text, int& position, const char& separator, const int& length, int index); void DecodeLinkFields(const std::string& link, std::vector& fields); bool LinkDisplayName(const std::string& encoded, std::string& output); + bool ExtractItemLink(std::string& text, std::string& link, int& position, const char* source); /* 011C */ std::list> entries; /* 0124 */ std::vector pendingText;