Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas. 449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
153 lines
3.7 KiB
C++
153 lines
3.7 KiB
C++
#include "Contents/Items/ItemInfo.h"
|
|
#include "UI/Lists/UIScrollBar.h"
|
|
#include "UI/Buttons/UITextButton.h"
|
|
#include "UI/Text/UITextViewer.h"
|
|
#include "UI/Window/WindowManagerWindows.h"
|
|
|
|
#include <bit>
|
|
#include <cstdlib>
|
|
#include <shellapi.h>
|
|
|
|
// INLINED
|
|
void UITextViewer::Activate(UITextButton* button, int id) {
|
|
if (!button) {
|
|
return;
|
|
}
|
|
|
|
auto& arguments = button->m_lines;
|
|
const auto number = [&](unsigned index) { return std::atoi(arguments.at(index).c_str()); };
|
|
|
|
switch (id) {
|
|
case 437:
|
|
if (!arguments.at(0).empty()) {
|
|
ShellExecuteA(this->m_text->applicationWindow, "open", arguments[0].c_str(), nullptr, nullptr, SW_SHOWNORMAL);
|
|
}
|
|
|
|
break;
|
|
case 438: {
|
|
if (arguments.empty()) {
|
|
break;
|
|
}
|
|
|
|
const std::string map = arguments.at(0);
|
|
const int x = number(1);
|
|
const int y = number(2);
|
|
|
|
if (arguments.size() <= 3) {
|
|
this->m_text->actions.Navigate(map, 2, 5, false, x, y, 1002);
|
|
break;
|
|
}
|
|
|
|
const int type = number(3);
|
|
int policy = number(4);
|
|
|
|
if (policy == -222) {
|
|
this->m_text->actions.NavigateNamed((type == 3 ? "$$DB " : "") + map, type, 0);
|
|
break;
|
|
}
|
|
|
|
const int option = number(5);
|
|
const int target = number(6);
|
|
unsigned char flag = 0;
|
|
|
|
if (policy >= 100) {
|
|
flag = 1;
|
|
policy -= 100;
|
|
}
|
|
|
|
if (policy >= 10) {
|
|
flag += 2;
|
|
policy -= 10;
|
|
}
|
|
|
|
if (policy >= 1) {
|
|
flag += 4;
|
|
}
|
|
|
|
this->m_text->actions.Navigate(map, type, flag, option == 0, x, y, target);
|
|
break;
|
|
}
|
|
case 464: {
|
|
if (arguments.empty()) {
|
|
break;
|
|
}
|
|
|
|
const int idValue = !arguments.at(1).empty() ? number(1) : 0;
|
|
ItemInfo item;
|
|
item.identified = 1;
|
|
item.unknown_0000[0] = static_cast<unsigned>(idValue);
|
|
item.unknown_0070 = 0;
|
|
item.itemId = arguments.at(0);
|
|
|
|
if (UIWindow* window = this->m_text->list.windows.LookupWindow(12)) {
|
|
window->SendMsg(nullptr, 24, reinterpret_cast<std::intptr_t>(&item), 0, 0, 0);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 517:
|
|
if (!arguments.empty()) {
|
|
if (UIWindow* window = this->m_text->list.windows.EnsureWindow(315)) {
|
|
this->m_text->actions.OpenTip(*window, number(0));
|
|
}
|
|
}
|
|
|
|
break;
|
|
case 539:
|
|
this->m_text->actions.OpenQuest(number(0));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00899E90
|
|
// FUNCTION: fn_11562
|
|
int UITextViewer::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) {
|
|
switch (message) {
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
case 11:
|
|
case 12: {
|
|
const int previousX = this->horizontalOffset;
|
|
UIListBox::SendMsg(sender, message, argument1, argument2, argument3, argument4);
|
|
|
|
for (UITextButton* button : this->links) {
|
|
if (!button) {
|
|
continue;
|
|
}
|
|
|
|
const int row = button->m_value;
|
|
const int limit = this->topLine + this->geometry.height / this->lineHeight - this->bottomMargin;
|
|
|
|
if (row < this->topLine || row >= limit) {
|
|
button->Enable(0);
|
|
} else {
|
|
button->Enable(1);
|
|
const int x = previousX + button->geometry.x - this->horizontalOffset;
|
|
const int y = this->lineHeight * (row - this->topLine) + 3;
|
|
button->Move(x, y);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
case 18:
|
|
case 19:
|
|
if (this->verticalOverflow != 0) {
|
|
this->SendMsg(this->verticalBar, 7, message == 18 ? -1 : 1, 0, 0, 0);
|
|
}
|
|
|
|
return 0;
|
|
case 29:
|
|
this->AppendText(reinterpret_cast<char*>(argument1), static_cast<int>(argument2), argument3 != 0, argument4 != 0);
|
|
return 0;
|
|
case 98:
|
|
this->Activate(static_cast<UITextButton*>(sender), static_cast<int>(argument1));
|
|
return 0;
|
|
default:
|
|
return UIListBox::SendMsg(sender, message, argument1, argument2, argument3, argument4);
|
|
}
|
|
}
|