Decompile 6 functions in Source/UI/Text/TextMarkup.cpp, Source/UI/Text/TextMarkup.h, ...

Batch #12699 by Yommy: 0 byte-identical, 6 confirmed by peer review.

- fn_11210 UITextViewer::SplitTextLinkArguments: logic confirmed by peer review
- fn_11205 UITextViewer::AddItemLinks: logic confirmed by peer review
- fn_11206 UITextViewer::AddNaviLinks: logic confirmed by peer review
- fn_11209 UITextViewer::AddQuestLinks: logic confirmed by peer review
- fn_11211 UITextViewer::AddTipLinks: logic confirmed by peer review
- fn_11212 UITextViewer::AddUrlLinks: logic confirmed by peer review

Peer-reviewed-by: Tanke, aDw, cremane
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-06 01:55:56 +00:00
commit 5df36e74a3
4 changed files with 31 additions and 22 deletions

View file

@ -1,5 +1,7 @@
#include "UI/Text/ColoredText.h"
#include "UI/Text/TextMarkup.h"
#include "UI/Buttons/UITextButton.h"
#include "UI/Text/UITextViewer.h"
#include <windows.h>
#include <utility>
@ -271,20 +273,27 @@ void ExtractTextLinks(const std::string& source, const std::string& begin, const
} while (position != std::string::npos);
}
// INLINED
static void AddTextLinkArgument(std::vector<std::string>& lines, std::string argument) {
lines.push_back(argument);
}
// OFFSET: 0x00877650
// FUNCTION: fn_11210
void SplitTextLinkArguments(std::string text, std::vector<std::string>& arguments) {
void UITextViewer::SplitTextLinkArguments(std::string text, UITextButton* button) {
if (text.empty()) {
return;
}
auto comma = text.find(',');
std::string remaining = text;
auto comma = remaining.find(",");
while (comma != std::string::npos) {
arguments.push_back(text.substr(0, comma));
text = text.substr(comma + 1);
comma = text.find(',');
const std::string argument = remaining.substr(0, comma);
AddTextLinkArgument(button->m_lines, argument);
remaining = remaining.substr(comma + 1);
comma = remaining.find(',');
}
arguments.push_back(text);
AddTextLinkArgument(button->m_lines, remaining);
}

View file

@ -27,7 +27,6 @@ void ExtractTextLinks(const std::string& source, const std::string& begin, const
void ExtractNavigationTextLinks(const std::string& text, std::vector<TextLink>& links);
void ExtractTipBoxTextLinks(const std::string& text, std::vector<TextLink>& links);
void ExtractUrlTextLinks(const std::string& text, std::vector<TextLink>& links);
void SplitTextLinkArguments(std::string text, std::vector<std::string>& arguments);
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(TextLink) == 60);

View file

@ -41,6 +41,7 @@ private:
bool AddNaviLinks(std::string text, unsigned addedLines);
bool AddQuestLinks(std::string text, unsigned addedLines);
void AddTipLinks(std::string text, unsigned addedLines);
void SplitTextLinkArguments(std::string text, UITextButton* button);
void AppendText(char* text, int width, int carriageReturns, int pixels);
void Activate(UITextButton* button, int id);
};

View file

@ -96,7 +96,7 @@ bool UITextViewer::AddItemLinks(std::string text, unsigned addedLines) {
button->ResizeToTextClipped(width + 1, height);
button->m_hoverColor = 0x00FF7864;
button->SetId(464);
SplitTextLinkArguments(link.metadata, button->m_lines);
this->SplitTextLinkArguments(link.metadata, button);
const auto position = this->LinkPosition(link.position, addedLines);
button->m_value = position.first;
button->Move(position.second, -100);
@ -143,7 +143,7 @@ bool UITextViewer::AddNaviLinks(std::string text, unsigned addedLines) {
button->ResizeToTextClipped(width + 1, height);
button->m_hoverColor = 0x00FF7864;
button->SetId(438);
SplitTextLinkArguments(link.metadata, button->m_lines);
this->SplitTextLinkArguments(link.metadata, button);
const auto position = this->LinkPosition(link.position, addedLines);
button->m_value = position.first;
button->Move(position.second, -100);
@ -245,7 +245,7 @@ bool UITextViewer::AddQuestLinks(std::string text, unsigned addedLines) {
button->ResizeToTextClipped(width + 1, height);
button->m_hoverColor = 0x00FF7864;
button->SetId(539);
SplitTextLinkArguments(link.metadata, button->m_lines);
this->SplitTextLinkArguments(link.metadata, button);
const auto position = this->LinkPosition(link.position, addedLines);
button->m_value = position.first;
button->Move(position.second, -100);
@ -281,13 +281,12 @@ void UITextViewer::AddTipLinks(std::string text, unsigned addedLines) {
if (!extracted.empty()) {
for (unsigned index = 0; index < extracted.size(); ++index) {
const TextLink& link = extracted[index];
if (this->splitTipLinks == 1) {
std::vector<std::string> labels;
const char* begin = link.display.c_str();
const char* begin = extracted[index].display.c_str();
const char* const end = begin + std::strlen(begin);
std::uintptr_t limit = reinterpret_cast<std::uintptr_t>(begin) + 32u - link.position;
std::uintptr_t limit = reinterpret_cast<std::uintptr_t>(begin) + 32u - extracted[index].position;
const char* current = begin;
const char* breakAt = begin;
@ -327,8 +326,8 @@ void UITextViewer::AddTipLinks(std::string text, unsigned addedLines) {
button->ResizeToTextClipped(width + 1, height);
button->m_hoverColor = 0x00FF7864;
button->SetId(517);
SplitTextLinkArguments(link.metadata, button->m_lines);
const auto position = this->LinkPosition(fragment == 0 ? link.position : 0, addedLines - fragment);
this->SplitTextLinkArguments(extracted[index].metadata, button);
const auto position = this->LinkPosition(fragment == 0 ? extracted[index].position : 0, addedLines - fragment);
button->m_value = position.first;
button->Move(position.second, -100);
this->AddChild(button);
@ -336,14 +335,14 @@ void UITextViewer::AddTipLinks(std::string text, unsigned addedLines) {
}
} else {
auto* button = new UITextButton();
button->Configure(link.display.c_str(), 0x00F4934A, 0, 12, 0, 1);
button->Configure(extracted[index].display.c_str(), 0x00F4934A, 0, 12, 0, 1);
const int height = button->geometry.height;
const int width = this->TextWidth(link.display.c_str(), 0, 0, 12, 0, 0);
const int width = this->TextWidth(extracted[index].display.c_str(), 0, 0, 12, 0, 0);
button->ResizeToTextClipped(width + 1, height);
button->m_hoverColor = 0x00FF7864;
button->SetId(517);
SplitTextLinkArguments(link.metadata, button->m_lines);
const auto position = this->LinkPosition(link.position, addedLines);
this->SplitTextLinkArguments(extracted[index].metadata, button);
const auto position = this->LinkPosition(extracted[index].position, addedLines);
button->m_value = position.first;
button->Move(position.second, -100);
this->AddChild(button);
@ -379,20 +378,21 @@ bool UITextViewer::AddUrlLinks(std::string text, unsigned addedLines) {
return false;
}
for (const auto& link : extracted) {
for (unsigned index = 0; index < extracted.size(); ++index) {
const TextLink& link = extracted[index];
auto* button = new UITextButton();
button->Configure(link.display.c_str(), 0x00E6A300, 0, 12, 0, 1);
button->m_hoverColor = 0x00EFB700;
button->SetId(437);
const int height = button->geometry.height;
const int width = this->TextWidth(link.display.c_str(), 0, 0, 12, 0, 0);
button->Resize(width + 1, height);
button->ResizeToTextClipped(width + 1, height);
parsed = RemoveTextLinkInfo(parsed);
const auto position = this->LinkPosition(link.position, addedLines);
button->m_value = position.first;
button->Move(position.second, -100);
this->AddChild(button);
SplitTextLinkArguments(link.metadata, button->m_lines);
this->SplitTextLinkArguments(link.metadata, button);
this->links.push_back(button);
}