rodecomp/Source/UI/Guild/UIGuildWnd.cpp
ragnarok-clanker 3a08f43d42 Decompile 14 functions in Source/UI/Guild/UIGuildWnd.cpp, Source/UI/Guild/UIGuildWnd.h, ...
Batch #5563 by Yommy: 0 byte-identical, 14 confirmed by peer review.

- fn_13053 UIGuildWnd::CreateTabs: logic confirmed by peer review
- fn_13116 UIGuildBanishedMemberWnd::UpdateScroll: logic confirmed by peer review
- fn_13083 UIGuildBanishedMemberWnd::Slot25: logic confirmed by peer review
- fn_13125 UIGuildBanishedMemberWnd::SendMsg: logic confirmed by peer review
- fn_13120 UIGuildTotalInfoWnd::UpdateScroll: logic confirmed by peer review
- fn_13090 UIGuildTotalInfoWnd::Slot25: logic confirmed by peer review
- fn_13134 UIGuildTotalInfoWnd::SendMsg: logic confirmed by peer review
- fn_13066 UIGuildTotalInfoWnd::Slot15: logic confirmed by peer review
- fn_13051 UIGuildInfoManageWnd::HideAgitMenu: logic confirmed by peer review
- fn_13102 UIGuildInfoManageWnd::Slot32: logic confirmed by peer review
- fn_13085 UIGuildInfoManageWnd::Slot25: logic confirmed by peer review
- fn_13107 UIGuildInfoManageWnd::Slot33: logic confirmed by peer review
- fn_13052 UIGuildInfoManageWnd::RefreshAgitList: logic confirmed by peer review
- fn_13128 UIGuildLeaveReasonDescWnd::SendMsg: logic confirmed by peer review

Peer-reviewed-by: willerthal, Lumen
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-10-30 14:24:45 +00:00

963 lines
24 KiB
C++

#include "UI/Guild/UIGuildWnd.h"
#include "Client/Mode/CMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Contents/GuildInfo.h"
#include "Contents/GuildMgr.h"
#include "Contents/MessageTable.h"
#include "Contents/UserData/NormalItemSlots.h"
#include "Resource/EmblemResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/SkinPalette.h"
#include "Script/LuaScript.h"
#include "UI/Buttons/UIButton.h"
#include "UI/Edit/UIEditCtrl.h"
#include "UI/Guild/UIAgitWnd.h"
#include "UI/Guild/UIGuildHelperWnd.h"
#include "UI/Lists/UIScrollBar.h"
#include "UI/Text/UIStaticText.h"
#include "UI/Window/InputFocus.h"
#include "UI/Window/UIWindowMgr.h"
#include "UI/Window/WindowManagerWindows.h"
#include <windows.h>
#include <timeapi.h>
#include <cstring>
#include <cwchar>
#include <string>
// GLOBAL: gl_24918
int g_guildPositionRowHeight = 19;
// GLOBAL: gl_24919
int g_guildBanishedColumnWidths[2] = {82, 292};
// GLOBAL: gl_24920
int g_guildBanishedRowHeight = 19;
// GLOBAL: gl_24921
int g_guildTotalInfoRowHeight = 19;
static GuildInfo& GuildData() {
return *reinterpret_cast<GuildInfo*>(reinterpret_cast<char*>(&g_guildId) - offsetof(GuildInfo, m_guildId));
}
// OFFSET: 0x00957D30
// FUNCTION: fn_13044
int UIGuildBanishedMemberWnd::Tab() {
return 4;
}
// OFFSET: 0x00957D40
// FUNCTION: fn_13045
int UIGuildInfoManageWnd::Tab() {
return 0;
}
// OFFSET: 0x00957D50
// FUNCTION: fn_13046
int UIGuildMemberManageWnd::Tab() {
return 1;
}
// OFFSET: 0x00957D80
// FUNCTION: fn_13049
int UIGuildSkillWnd::Tab() {
return 3;
}
// OFFSET: 0x00957D90
// FUNCTION: fn_13050
int UIGuildTotalInfoWnd::Tab() {
return 6;
}
// OFFSET: 0x0095F860
// FUNCTION: fn_13080
void UIGuildWnd::Paint() {
const int tab = this->Tab();
unsigned red, green, blue;
SkinPaletteChannels(ResourceMgr::Instance(), 10, 2, red, green, blue);
this->FillRegion(0, 17, this->geometry.width, 24, RGB(red, green, blue));
for (int x = 1, index = 0; x < 397; x += 66, ++index) {
if (tab == index) {
SkinPaletteChannels(ResourceMgr::Instance(), 2, 2, red, green, blue);
} else {
SkinPaletteChannels(ResourceMgr::Instance(), 14, 6, red, green, blue);
}
this->FillRegion(x, 18, 64, 23, RGB(red, green, blue));
}
auto& controls = *this->m_controls;
this->DrawTitleBar(controls.fonts, controls.locale, false, "", 0);
unsigned borderRed, borderGreen, borderBlue;
SkinPaletteChannels(ResourceMgr::Instance(), 14, 6, borderRed, borderGreen, borderBlue);
this->FillRegion(0, 41, this->geometry.width, this->geometry.height - 41, RGB(borderRed, borderGreen, borderBlue));
SkinPaletteChannels(ResourceMgr::Instance(), 2, 2, borderRed, borderGreen, borderBlue);
this->FillRegion(1, 41, this->geometry.width - 2, this->geometry.height - 41, RGB(borderRed, borderGreen, borderBlue));
this->DrawButtonBar(2, 0, 1);
}
// OFFSET: 0x00960020
// FUNCTION: fn_13091
void UIGuildWnd::Slot25(int x, int y) {
if (y < 17) {
UIFrameWnd::Slot25(x, y);
return;
}
if (y <= 41) {
const int current = this->Tab();
this->Tab();
const int tab = x / 66;
if (tab < 6 && current != tab) {
this->SendMsg(nullptr, 69, tab, 0, 0, 0);
}
}
}
// OFFSET: 0x0095FE10
// FUNCTION: fn_13087
void UIGuildNoticeWnd::Slot25(int x, int y) {
UIGuildWnd::Slot25(x, y);
}
// OFFSET: 0x009602E0
// FUNCTION: fn_13100
void UIGuildMemberManageWnd::Slot19() {
if (this->m_buttonTime != 0 && timeGetTime() > this->m_buttonTime + 400) {
UIButton* button = this->m_button;
this->m_buttonTime = 0;
button->SetDisabled(0);
button->Invalidate();
}
}
// OFFSET: 0x00960330
// FUNCTION: fn_13101
void UIGuildPositionManageWnd::Slot19() {
if (this->m_buttonTime != 0 && timeGetTime() > this->m_buttonTime + 400) {
UIButton* button = this->m_button;
this->m_buttonTime = 0;
button->SetDisabled(0);
button->Invalidate();
}
}
// OFFSET: 0x00958050
// FUNCTION: fn_13054
void UIGuildPositionManageWnd::Invalidate() {
this->UIWindow::Invalidate();
InputFocus focus{g_windowMgr.hoverWindow};
focus.Set(nullptr);
}
// OFFSET: 0x009603C0
// FUNCTION: fn_13103
void UIGuildMemberManageWnd::Slot32(int x, int y) {
const int previous = this->m_hoverRow;
int row;
if (static_cast<unsigned>(x - 5) <= 377 && static_cast<unsigned>(y - 66) <= 217) {
row = (y - 66) / (this->m_rowSpacing + 36) + this->m_columns * this->m_scrollTop;
if (static_cast<unsigned>(row) >= this->m_rowCount) {
row = -1;
}
} else {
row = -1;
}
this->m_hoverRow = row;
if (previous != row) {
this->Invalidate();
}
}
// OFFSET: 0x00960620
// FUNCTION: fn_13108
void UIGuildMemberManageWnd::Slot33(int, int) {
this->SendMsg(nullptr, 49, 0, 0, 0, 0);
}
// OFFSET: 0x00960640
// FUNCTION: fn_13109
void UIGuildSkillWnd::Slot33(int, int) {
this->SendMsg(nullptr, 49, 0, 0, 0, 0);
}
// OFFSET: 0x00960960
// FUNCTION: fn_13111
void UIGuildBanishedMemberWnd::Slot35(int delta) {
if (this->m_scrollable != 0) {
int step = this->m_visibleRows - 1;
if (step > 3) {
step = 3;
}
if (delta >= 0) {
step = -step;
}
this->SendMsg(this->m_scrollBar, 7, step, 0, 0, 0);
}
}
// OFFSET: 0x009609B0
// FUNCTION: fn_13112
void UIGuildMemberManageWnd::Slot35(int delta) {
if (this->m_scrollable != 0) {
int step = this->m_visibleRows - 1;
if (step > 3) {
step = 3;
}
if (delta >= 0) {
step = -step;
}
this->SendMsg(this->m_scrollBar, 7, step, 0, 0, 0);
}
}
// OFFSET: 0x00960A00
// FUNCTION: fn_13113
void UIGuildPositionManageWnd::Slot35(int delta) {
if (this->m_scrollable != 0) {
int step = this->m_visibleRows - 1;
if (step > 3) {
step = 3;
}
if (delta >= 0) {
step = -step;
}
this->SendMsg(this->m_scrollBar, 7, step, 0, 0, 0);
}
}
// OFFSET: 0x00960A50
// FUNCTION: fn_13114
void UIGuildSkillWnd::Slot35(int delta) {
if (this->m_scrollable != 0) {
int step = this->m_visibleRows - 1;
if (step > 3) {
step = 3;
}
if (delta >= 0) {
step = -step;
}
this->SendMsg(this->m_scrollBar, 7, step, 0, 0, 0);
}
}
// OFFSET: 0x00960AA0
// FUNCTION: fn_13115
void UIGuildTotalInfoWnd::Slot35(int delta) {
if (this->m_scrollable != 0) {
int step = this->m_visibleRows - 1;
if (step > 3) {
step = 3;
}
if (delta >= 0) {
step = -step;
}
this->SendMsg(this->m_scrollBar, 7, step, 0, 0, 0);
}
}
UIGuildWnd::UIGuildWnd(UIWindowContext& windows, UIFrameContext& frames, UIButtonContext& controls)
: UIFrameWnd(windows, frames, 0), m_saved(nullptr), m_tabs{}, m_controls(&controls) {
}
// OFFSET: 0x00953D70
// FUNCTION: fn_13001
UIGuildPositionManageWnd::UIGuildPositionManageWnd(UIWindowContext& windows, UIFrameContext& frames, UIButtonContext& controls)
: UIGuildWnd(windows, frames, controls), m_buttonTime(0) {
for (int index = 0; index < 11; ++index) {
this->unknown_00D0[index] = 0;
this->unknown_00FC[index] = 0;
this->unknown_0128[index] = 0;
this->unknown_0180[index] = 0;
this->unknown_0154[index] = 0;
this->unknown_01D8[index] = 0;
this->unknown_01AC[index] = 0;
}
}
// OFFSET: 0x00956050
// FUNCTION: fn_13035
bool CompareWideText(const char* left, const char* right) {
wchar_t wideLeft[260];
wchar_t wideRight[260];
memset(wideLeft, 0, sizeof(wideLeft));
memset(wideRight, 0, sizeof(wideRight));
MultiByteToWideChar(CP_ACP, 0, left, -1, wideLeft, 260);
MultiByteToWideChar(CP_ACP, 0, right, -1, wideRight, 260);
return wcscmp(wideLeft, wideRight) < 0;
}
// OFFSET: 0x009578F0
// FUNCTION: fn_13039
int UIGuildSkillWnd::SkillIndexAt(int x, int y) {
if (x >= 40 && y >= 41 && y < this->m_visibleRows * 32 + 41) {
const int row = (y - 41) / 32;
int visible = 0;
int index = 0;
for (auto skill = this->m_skills.begin(); skill != this->m_skills.end(); ++skill, ++index) {
if (index >= this->m_scrollTop * this->m_columns) {
if (visible == this->m_columns * row) {
return index;
}
++visible;
}
}
}
return -1;
}
// OFFSET: 0x00957850
// FUNCTION: fn_13038
int UIGuildPositionManageWnd::PositionIndexAt(int x, int y) {
if (x <= this->geometry.width - 14 && x > 3 && y >= g_guildPositionRowHeight + 46 && y < (this->m_visibleRows + 1) * g_guildPositionRowHeight + 46) {
const int row = (y - g_guildPositionRowHeight - 46) / g_guildPositionRowHeight;
int visible = 0;
int index = 0;
for (auto position = this->m_positions.begin(); position != this->m_positions.end(); ++position, ++index) {
if (index >= this->m_scrollTop * this->m_columns) {
if (visible == this->m_columns * row) {
return index;
}
++visible;
}
}
}
return -1;
}
// OFFSET: 0x00957A90
// FUNCTION: fn_13041
const GuildPositionEntry& UIGuildPositionManageWnd::PositionAt(int index, int* found) {
*found = 1;
// GLOBAL: gl_24922
static GuildPositionEntry s_emptyGuildPosition;
int current = 0;
for (auto position = this->m_positions.begin(); position != this->m_positions.end(); ++position, ++current) {
if (index == current) {
return *position;
}
}
*found = 0;
return s_emptyGuildPosition;
}
// OFFSET: 0x00957BB0
// FUNCTION: fn_13042
CSkillInfo UIGuildSkillWnd::SkillAt(int index) {
CSkillInfo result(0);
int current = 0;
for (auto skill = this->m_skills.begin(); skill != this->m_skills.end(); ++skill, ++current) {
if (index == current) {
result = *skill;
break;
}
}
return result;
}
// OFFSET: 0x00957CA0
// FUNCTION: fn_13043
CSkillInfo UIGuildSkillWnd::VisibleSkillAt(int row) {
int index = 0;
for (auto skill = this->m_skills.begin(); skill != this->m_skills.end(); ++skill, ++index) {
if (row + this->m_scrollTop == index) {
return *skill;
}
}
return CSkillInfo(0);
}
// OFFSET: 0x0095FE20
// FUNCTION: fn_13088
void UIGuildPositionManageWnd::Slot25(int x, int y) {
UIGuildWnd::Slot25(x, y);
const int previous = this->m_hoverIndex;
this->m_hoverIndex = this->PositionIndexAt(x, y);
if (previous != this->m_hoverIndex) {
this->Invalidate();
}
}
// OFFSET: 0x00960430
// FUNCTION: fn_13104
void UIGuildPositionManageWnd::Slot32(int x, int y) {
const int previous = this->m_hoverIndex;
this->m_hoverIndex = this->PositionIndexAt(x, y);
if (previous != this->m_hoverIndex) {
this->Invalidate();
}
}
// OFFSET: 0x00960470
// FUNCTION: fn_13105
void UIGuildSkillWnd::Slot32(int x, int y) {
const int previous = this->m_hoverIndex;
this->m_hoverIndex = this->SkillIndexAt(x, y);
if (previous != this->m_hoverIndex) {
this->Invalidate();
}
}
// OFFSET: 0x00960BA0
// FUNCTION: fn_13117
void UIGuildMemberManageWnd::UpdateScroll() {
if (!this->m_scrollBar) {
return;
}
this->m_visibleRows = 6 - this->m_rowSpacing * 6 / 36;
const int visible = this->m_visibleRows;
const int rows = this->m_rowCount / this->m_columns + (this->m_rowCount % this->m_columns != 0);
int range = 0;
if (rows - visible >= 0) {
range = rows - visible;
}
this->m_scrollable = range != 0;
if (range == 0) {
this->m_scrollTop = 0;
this->m_scrollBar->SetRange(0, visible, rows);
} else {
this->m_scrollBar->SetRange(range, visible, rows);
int top = this->m_scrollTop;
if (top < 0) {
this->m_scrollTop = 0;
top = 0;
}
const int last = rows - this->m_visibleRows;
if (last < top) {
this->m_scrollTop = last;
top = last;
}
this->m_scrollBar->SetPosition(top);
}
this->m_scrollBar->Invalidate();
}
// OFFSET: 0x00960C80
// FUNCTION: fn_13118
void UIGuildPositionManageWnd::UpdateScroll() {
if (!this->m_scrollBar) {
return;
}
const int visible = this->m_visibleRows;
const int rows = this->m_positions.size() / this->m_columns + (this->m_positions.size() % this->m_columns != 0);
int range = 0;
if (rows - visible >= 0) {
range = rows - visible;
}
this->m_scrollable = range != 0;
if (range == 0) {
this->m_scrollTop = 0;
this->m_scrollBar->SetRange(0, visible, rows);
} else {
this->m_scrollBar->SetRange(range, visible, rows);
int top = this->m_scrollTop;
if (top < 0) {
this->m_scrollTop = 0;
top = 0;
}
const int last = rows - this->m_visibleRows;
if (last < top) {
this->m_scrollTop = last;
top = last;
}
this->m_scrollBar->SetPosition(top);
}
this->m_scrollBar->Invalidate();
}
// OFFSET: 0x00960D30
// FUNCTION: fn_13119
void UIGuildSkillWnd::UpdateScroll() {
if (!this->m_scrollBar) {
return;
}
const int visible = this->m_visibleRows;
const int rows = this->m_skills.size() / this->m_columns + (this->m_skills.size() % this->m_columns != 0);
int range = 0;
if (rows - visible >= 0) {
range = rows - visible;
}
this->m_scrollable = range != 0;
if (range == 0) {
this->m_scrollTop = 0;
this->m_scrollBar->SetRange(0, visible, rows);
} else {
this->m_scrollBar->SetRange(range, visible, rows);
int top = this->m_scrollTop;
if (top < 0) {
this->m_scrollTop = 0;
top = 0;
}
const int last = rows - this->m_visibleRows;
if (last < top) {
this->m_scrollTop = last;
top = last;
}
this->m_scrollBar->SetPosition(top);
}
this->m_scrollBar->Invalidate();
}
// OFFSET: 0x00960230
// FUNCTION: fn_13099
void UIGuildInfoManageWnd::Slot19() {
const std::string name = g_guildMgr->GetEmblemFilename(this->m_guildId);
CEmblemRes* emblem = static_cast<CEmblemRes*>(ResourceMgr::Instance().Load(name));
if (emblem && emblem->gif.frameChanged == true) {
this->Invalidate();
}
}
// OFFSET: 0x009656A0
// FUNCTION: fn_13140
void UIGuildWnd::Slot11() {
if (this->m_saved) {
this->m_saved->x = this->geometry.x;
this->m_saved->y = this->geometry.y;
this->m_saved->width = this->geometry.width;
this->m_saved->height = this->geometry.height;
this->m_saved->unknown_0010 = this->Tab();
}
}
// OFFSET: 0x00957EF0
// FUNCTION: fn_13053
__declspec(noinline) void UIGuildWnd::CreateTabs() {
if (this->m_tabs[0]) {
return;
}
if (GuildData().unknown_00A4 == -1) {
g_modeMgr.gameMode->SendMsg(105, 0, 0, 0, 0);
}
const char* names[6];
names[0] = LookupMessage(340);
names[1] = LookupMessage(341);
names[2] = LookupMessage(342);
names[3] = LookupMessage(343);
names[4] = LookupMessage(344);
names[5] = LookupMessage(345);
const char** name = names;
UIStaticText** tab = this->m_tabs;
for (int x = 3; x < 399; x += 66) {
*tab = new UIStaticText(*this->m_context, *this->m_controls);
(*tab)->SetSize(62, 15);
(*tab)->SetTextFitted(*name);
(*tab)->Move(x, 22);
this->AddChild(*tab);
++name;
++tab;
}
this->AddCloseButton(*this->m_controls, "Alt+G", 0);
}
// OFFSET: 0x00964D50
// FUNCTION: fn_13135
int UIGuildWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a1, std::intptr_t a2, std::intptr_t a3, std::intptr_t a4) {
if (message == 34) {
this->m_saved = reinterpret_cast<GuildWndInfo*>(a1);
if (!this->m_saved->IsValid()) {
this->m_saved->Reset();
}
this->Move(this->m_saved->x, this->m_saved->y);
return 0;
}
if (message == 60) {
this->InvalidateChildren();
return 0;
}
if (message != 69) {
return UIFrameWnd::SendMsg(sender, message, a1, a2, a3, a4);
}
int permissions[7] = {0, 1, 2, 4, 16, 128, 64};
switch (a1) {
case 1:
case 2:
case 4:
case 5:
if ((permissions[a1] & GuildData().unknown_00A4) == 0) {
return 0;
}
break;
case 6:
return 0;
}
this->m_frameContext->windows.CloseWindow(59);
switch (a1) {
case 0:
this->m_frameContext->windows.EnsureWindow(60);
return 0;
case 1:
this->m_frameContext->windows.EnsureWindow(61);
return 0;
case 2:
this->m_frameContext->windows.EnsureWindow(62);
return 0;
case 3:
this->m_frameContext->windows.EnsureWindow(63);
return 0;
case 4:
this->m_frameContext->windows.EnsureWindow(64);
return 0;
case 5:
this->m_frameContext->windows.EnsureWindow(65);
return 0;
case 6:
this->m_frameContext->windows.EnsureWindow(66);
return 0;
}
return 0;
}
// OFFSET: 0x00960AF0
// FUNCTION: fn_13116
void UIGuildBanishedMemberWnd::UpdateScroll() {
if (!this->m_scrollBar) {
return;
}
const int rows = GuildData().unknown_00EC.size() / this->m_columns + (GuildData().unknown_00EC.size() % this->m_columns != 0);
const int visible = this->m_visibleRows;
int range = 0;
if (rows - visible >= 0) {
range = rows - visible;
}
this->m_scrollable = range != 0;
if (range == 0) {
this->m_scrollTop = 0;
this->m_scrollBar->SetRange(0, visible, rows);
} else {
this->m_scrollBar->SetRange(range, visible, rows);
int top = this->m_scrollTop;
if (top < 0) {
this->m_scrollTop = 0;
top = 0;
}
const int last = rows - this->m_visibleRows;
if (last < top) {
this->m_scrollTop = last;
top = last;
}
this->m_scrollBar->SetPosition(top);
}
this->m_scrollBar->Invalidate();
}
// OFFSET: 0x0095FBF0
// FUNCTION: fn_13083
void UIGuildBanishedMemberWnd::Slot25(int x, int y) {
UIGuildWnd::Slot25(x, y);
const int previous = this->m_hoverRow;
int hover = -1;
if (x <= this->geometry.width - 14 && x >= 4 && y >= g_guildBanishedRowHeight + 46 && y < (this->m_visibleRows + 1) * g_guildBanishedRowHeight + 46) {
const int row = (y - g_guildBanishedRowHeight - 46) / g_guildBanishedRowHeight;
int visible = 0;
int index = 0;
const auto& members = GuildData().unknown_00EC;
for (auto member = members.begin(); member != members.end(); ++member, ++index) {
if (index >= this->m_scrollTop * this->m_columns) {
if (visible == this->m_columns * row) {
hover = index;
break;
}
++visible;
}
}
}
this->m_hoverRow = hover;
if (previous != hover) {
this->Invalidate();
}
}
// OFFSET: 0x00961600
// FUNCTION: fn_13125
int UIGuildBanishedMemberWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a1, std::intptr_t a2, std::intptr_t a3, std::intptr_t a4) {
switch (message) {
case 6:
if (a1 == 201) {
this->m_frameContext->windows.CloseWindow(59);
return 0;
}
break;
case 7:
case 9:
case 10: {
const int previous = this->m_scrollTop;
int top;
if (message == 9) {
top = previous - this->m_visibleRows + 1;
} else {
top = a1;
if (message == 10) {
top = this->m_visibleRows - 1;
}
top += previous;
}
this->m_scrollTop = top;
if (previous != top) {
this->UpdateScroll();
this->Invalidate();
}
return this->m_scrollTop - previous;
}
case 60:
this->InvalidateChildren();
this->UpdateScroll();
break;
default:
return UIGuildWnd::SendMsg(sender, message, a1, a2, a3, a4);
}
return 0;
}
// OFFSET: 0x00960DE0
// FUNCTION: fn_13120
void UIGuildTotalInfoWnd::UpdateScroll() {
if (!this->m_scrollBar) {
return;
}
const int rows = GuildData().unknown_00F4.size() / this->m_columns + (GuildData().unknown_00F4.size() % this->m_columns != 0);
const int visible = this->m_visibleRows;
int range = 0;
if (rows - visible >= 0) {
range = rows - visible;
}
this->m_scrollable = range != 0;
if (range == 0) {
this->m_scrollTop = 0;
this->m_scrollBar->SetRange(0, visible, rows);
} else {
this->m_scrollBar->SetRange(range, visible, rows);
int top = this->m_scrollTop;
if (top < 0) {
this->m_scrollTop = 0;
top = 0;
}
const int last = rows - this->m_visibleRows;
if (last < top) {
this->m_scrollTop = last;
top = last;
}
this->m_scrollBar->SetPosition(top);
}
this->m_scrollBar->Invalidate();
}
// OFFSET: 0x0095FF60
// FUNCTION: fn_13090
void UIGuildTotalInfoWnd::Slot25(int x, int y) {
UIGuildWnd::Slot25(x, y);
const int previous = this->m_hoverRow;
int hover = -1;
if (x <= this->geometry.width - 14 && x >= 4 && y >= g_guildTotalInfoRowHeight + 46 && y < (this->m_visibleRows + 1) * g_guildTotalInfoRowHeight + 46) {
const int row = (y - g_guildTotalInfoRowHeight - 46) / g_guildTotalInfoRowHeight;
int visible = 0;
int index = 0;
const auto& entries = GuildData().unknown_00F4;
for (auto entry = entries.begin(); entry != entries.end(); ++entry, ++index) {
if (index >= this->m_scrollTop * this->m_columns) {
if (visible == this->m_columns * row) {
hover = index;
break;
}
++visible;
}
}
}
this->m_hoverRow = hover;
if (previous != hover) {
this->Invalidate();
}
}
// OFFSET: 0x00964C90
// FUNCTION: fn_13134
int UIGuildTotalInfoWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a1, std::intptr_t a2, std::intptr_t a3, std::intptr_t a4) {
switch (message) {
case 6:
if (a1 == 201) {
this->m_frameContext->windows.CloseWindow(59);
}
return 0;
case 7:
case 9:
case 10: {
const int previous = this->m_scrollTop;
int top;
if (message == 9) {
top = previous - this->m_visibleRows + 1;
} else {
top = a1;
if (message == 10) {
top = this->m_visibleRows - 1;
}
top += previous;
}
this->m_scrollTop = top;
if (previous != top) {
this->UpdateScroll();
this->Invalidate();
}
return this->m_scrollTop - previous;
}
default:
return UIGuildWnd::SendMsg(sender, message, a1, a2, a3, a4);
}
}
// OFFSET: 0x0095D3A0
// FUNCTION: fn_13066
void UIGuildTotalInfoWnd::Slot15(int, int) {
this->CreateTabs();
if (std::strcmp(g_guildName.c_str(), "") == 0) {
g_modeMgr.gameMode->SendMsg(107, 0, 0, 0, 0);
}
GuildData().unknown_00D0 = 1;
g_modeMgr.gameMode->SendMsg(107, 5, 0, 0, 0);
this->m_scrollTop = 0;
this->m_hoverRow = 0;
this->m_columns = 1;
this->m_visibleRows = 12;
this->m_scrollable = 0;
this->m_scrollBar = new UIScrollBar(*this->m_context);
this->m_scrollBar->Configure(this->geometry.width - 15, 63, 1, this->geometry.height - 87);
this->AddChild(this->m_scrollBar);
for (int index = 0; index < 12; ++index) {
this->m_rows[index] = new UIStaticText(*this->m_context, *this->m_controls);
this->m_rows[index]->SetSize(g_guildBanishedColumnWidths[0] - 4, 15);
this->m_rows[index]->SetTextFitted("");
this->m_rows[index]->Move(8, index * g_guildTotalInfoRowHeight + 63);
this->AddChild(this->m_rows[index]);
}
this->UpdateScroll();
}
// OFFSET: 0x00957DA0
// FUNCTION: fn_13051
void UIGuildInfoManageWnd::HideAgitMenu() {
if (this->m_agitMenu && this->m_agitMenu->geometry.visible) {
this->m_agitMenu->Show(0);
this->m_agitMenu->m_agitIndex = -1;
this->Invalidate();
}
}
// OFFSET: 0x00960380
// FUNCTION: fn_13102
void UIGuildInfoManageWnd::Slot32(int, int) {
this->HideAgitMenu();
}
// OFFSET: 0x0095FCF0
// FUNCTION: fn_13085
void UIGuildInfoManageWnd::Slot25(int x, int y) {
UIGuildWnd::Slot25(x, y);
this->HideAgitMenu();
}
// OFFSET: 0x00960540
// FUNCTION: fn_13107
void UIGuildInfoManageWnd::Slot33(int x, int y) {
if (x < 201 || x > 287) {
return;
}
if (y > 157 && y < 205) {
const int count = GuildData().CountRelatedGuilds(0);
this->m_allyRow = -1;
this->m_hostileRow = -1;
if (count != 0) {
this->m_allyRow = (y - 157) / 16;
if (count > this->m_allyRow) {
this->SendMsg(nullptr, 49, 0, 0, 0, 0);
}
}
} else if (y > 231 && y < 279) {
const int count = GuildData().CountRelatedGuilds(1);
this->m_allyRow = -1;
this->m_hostileRow = -1;
if (count != 0) {
this->m_hostileRow = (y - 231) / 16;
if (count > this->m_hostileRow) {
this->SendMsg(nullptr, 49, 0, 0, 0, 0);
}
}
} else {
return;
}
this->Invalidate();
}
// OFFSET: 0x00957DE0
// FUNCTION: fn_13052
void UIGuildInfoManageWnd::RefreshAgitList() {
this->m_agitList->Clear();
const int count = GuildData().GetUnknown0114Count();
if (count != 0) {
for (int index = 0; index < count; ++index) {
const int agitId = GuildData().GetUnknown0114(index);
char* agitName = nullptr;
g_luaScript->Call("get_agit_name", "d>s", agitId, &agitName);
if (strnlen(agitName, 256) != 0) {
this->m_agitList->AddLine(agitName);
}
}
}
}
// OFFSET: 0x00962310
// FUNCTION: fn_13128
int UIGuildLeaveReasonDescWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a1, std::intptr_t a2, std::intptr_t a3, std::intptr_t a4) {
if (message != 6) {
return UIFrameWnd::SendMsg(sender, message, a1, a2, a3, a4);
}
if (a1 == 184) {
g_modeMgr.gameMode->SendMsg(110, reinterpret_cast<int>(this->m_reasonEdit->Text()), 0, 0, 0);
this->m_frameContext->windows.CloseWindow(75);
} else if (a1 == 185) {
this->m_frameContext->windows.CloseWindow(75);
}
return 0;
}