rodecomp/Source/Contents/TipBoxTitles.cpp
ragnarok-clanker a47d20f8be Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.

Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
2026-10-25 07:42:41 +00:00

63 lines
1.6 KiB
C++

#include "Contents/TipBoxTitles.h"
#include <windows.h>
namespace {
// OFFSET: 0x009B45D0
// FUNCTION: fn_13832
void SplitTitle(const char* text, std::vector<std::string>& lines, int width, unsigned short codePage) {
const char* begin = text;
const char* current = text;
const char* end = text + std::char_traits<char>::length(text);
const char* limit = text + width;
while (current < end) {
if (current >= limit || *current == '\n') {
lines.emplace_back(begin, current);
begin = current;
limit = current + width;
}
current = CharNextExA(codePage, current, 0);
}
}
}
// OFFSET: 0x007ABEC0
// FUNCTION: fn_09118
TipBoxEntry::TipBoxEntry() : unknown_0018(0), unknown_0044(0), unknown_0048(0) {
this->unknown_004C[0] = 0;
this->unknown_004C[1] = 0;
this->unknown_004C[2] = 0;
}
// OFFSET: 0x007ACC70
// FUNCTION: fn_09127
std::string TipBoxTitles::Title(int id, std::string* abbreviated, int width) const {
const auto entry = this->entries.find(id);
const auto& title = entry == this->entries.end() ? this->missing.title : entry->second.title;
if (title.empty()) {
return title;
}
std::string result = title.substr(0, title.find('#'));
if (abbreviated) {
if (width <= 10 || result.size() <= static_cast<unsigned>(width) + 4u) {
*abbreviated = result;
} else {
std::vector<std::string> lines;
SplitTitle(result.c_str(), lines, width, this->codePage);
abbreviated->clear();
for (const auto& line : lines) {
*abbreviated += line;
}
*abbreviated += "...";
}
}
return result;
}