rodecomp/Source/UI/Window/InputFocus.cpp
ragnarok-clanker 67a4d82e94 Decompile 2 functions in Source/UI/Window/InputFocus.cpp
Batch #14175 by Yommy: 0 byte-identical, 2 confirmed by peer review.

- fn_17259 UIWindowMgr::FocusNext: logic confirmed by peer review
- fn_17260 UIWindowMgr::FocusPrevious: logic confirmed by peer review

Peer-reviewed-by: secret, KWDev, codeplay
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-07 07:02:06 +00:00

122 lines
2.6 KiB
C++

#include "UI/Window/UIWindowMgr.h"
#include "UI/Window/UIWindow.h"
// OFFSET: 0x00AA9B40
// FUNCTION: fn_17256
void UIWindowMgr::SetFocus(UIWindow* value) {
if (this->hoverWindow) {
const bool retained = value && value->Slot06() == this->hoverWindow;
this->hoverWindow->Slot24(retained);
}
if (value) {
this->hoverWindow = value->Slot06();
if (this->hoverWindow) {
this->hoverWindow->Slot23();
}
} else {
this->hoverWindow = nullptr;
}
}
// OFFSET: 0x00AA9BC0
// FUNCTION: fn_17257
void UIWindowMgr::FocusFirst() {
if (this->hoverWindow) {
UIWindow* parent = this->hoverWindow->parent;
for (auto it = parent->m_children.begin(); it != parent->m_children.end(); ++it) {
UIWindow* child = *it;
if (child->Slot05()) {
this->SetFocus(child);
return;
}
}
if (this->hoverWindow) {
this->hoverWindow->Slot24(0);
}
}
this->hoverWindow = nullptr;
}
// OFFSET: 0x00AA9C70
// FUNCTION: fn_17258
void UIWindowMgr::FocusLast() {
if (this->hoverWindow) {
UIWindow* parent = this->hoverWindow->parent;
for (auto it = parent->m_children.rbegin(); it != parent->m_children.rend(); ++it) {
UIWindow* child = *it;
if (child->Slot05()) {
this->SetFocus(child);
return;
}
}
if (this->hoverWindow) {
this->hoverWindow->Slot24(0);
}
}
this->hoverWindow = nullptr;
}
// OFFSET: 0x00AA9D20
// FUNCTION: fn_17259
void UIWindowMgr::FocusNext() {
if (!this->hoverWindow) {
return;
}
UIWindow* next = this->hoverWindow->parent->NextFocusable(this->hoverWindow);
if (next) {
if (next->Slot05()) {
this->SetFocus(next);
}
} else {
this->SetFocus(nullptr);
}
}
// OFFSET: 0x00A96F60
// FUNCTION: fn_17197
bool UIWindowMgr::IsLastFocus(UIWindow* value) {
return value && value->parent->NextFocusable(value) == nullptr;
}
// OFFSET: 0x00AA9DC0
// FUNCTION: fn_17260
void UIWindowMgr::FocusPrevious() {
if (!this->hoverWindow) {
return;
}
UIWindow* previous = this->hoverWindow->parent->PreviousFocusable(this->hoverWindow);
if (previous) {
if (previous->Slot05()) {
this->SetFocus(previous);
}
} else {
this->SetFocus(nullptr);
}
}
// INLINED
void UIWindowMgr::RefreshFocus(UIWindow* const& excludedRoot) {
if (this->hoverWindow) {
this->hoverWindow->Invalidate();
UIWindow* root = this->hoverWindow->Root();
if (root && root != excludedRoot) {
root->Invalidate();
}
}
}
// OFFSET: 0x00AA9E60
// FUNCTION: fn_17261
void SetPressedWindowRoot(UIWindow*& pressedRoot, UIWindow* window) {
pressedRoot = window ? window->Root() : nullptr;
}