Decompile 7 functions in Source/UI/UILapineScrollBar.cpp, Source/UI/UILapineScrollBar.h, ...

Batch #4796 by willerthal: 0 byte-identical, 7 confirmed by peer review.

- fn_04150 UILapineBoxWnd::Slot10: logic confirmed by peer review
- fn_04151 UILapineBox_IngredientListWnd::Slot10: logic confirmed by peer review
- fn_04153 UILapineBoxWnd::Slot15: logic confirmed by peer review
- fn_04154 UILapineBox_IngredientListWnd::Slot15: logic confirmed by peer review
- fn_04156 UILapineBoxWnd::Paint: logic confirmed by peer review
- fn_04177 UILapineBoxWnd::AddIngredient: logic confirmed by peer review
- fn_45447 UILapineBox_IngredientListWnd::UILapineBox_IngredientListWnd: logic confirmed by peer review

Peer-reviewed-by: eAthena, Lumen, Snow
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-10-30 04:58:50 +00:00
commit 76fc225a01
4 changed files with 295 additions and 0 deletions

View file

@ -1,12 +1,33 @@
#ifndef RAGNAROK_SOURCE_UI_UIINGREDIENTINFOWND_H
#define RAGNAROK_SOURCE_UI_UIINGREDIENTINFOWND_H
#include "Contents/Items/ItemInfo.h"
#include "UI/Window/UIFrameWnd.h"
#include <string>
struct UIButtonContext;
class UILapineBox_IngredientListWnd;
class UIIngredientInfoWnd : public UIFrameWnd {
friend class UILapineBox_IngredientListWnd;
public:
// INLINED
UIIngredientInfoWnd(UIWindowContext& windows, UIFrameContext& frames)
: UIFrameWnd(windows, frames, 0), selected(0), insufficient(0), quantity(0), m_controls(nullptr) {}
void Move(int x, int y) override;
void Slot10(int argument1, int argument2, std::intptr_t argument3) override;
void Paint() override;
/* 00B8 */ ITEM_INFO item;
/* 01B0 */ unsigned char selected;
/* 01B1 */ unsigned char insufficient;
/* 01B4 */ std::string tooltip;
/* 01CC */ int quantity;
protected:
UIButtonContext* m_controls;
};
#endif

View file

@ -1,9 +1,23 @@
#include "UI/UIIngredientInfoWnd.h"
#include "UI/UILapineScrollBar.h"
#include "Client/Mode/CMode.h"
#include "Client/Mode/ModeDragState.h"
#include "Client/Mode/ModeMgr.h"
#include "Client/Session.h"
#include "Contents/Items/ItemDescription.h"
#include "Contents/MessageTable.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/TextureNames.h"
#include "UI/Buttons/UIBitmapButton.h"
#include "UI/Shop/ItemDrawing.h"
#include "Utility/Text/FormatString.h"
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <timeapi.h>
// OFFSET: 0x005FF800
// FUNCTION: fn_04148
@ -91,3 +105,197 @@ void UILapineScrollBar::Paint() {
void UILapineBox_IngredientListWnd::Paint() {
this->ClearSurface(0xFFF7F7);
}
// OFFSET: 0x005FF130
// FUNCTION: fn_45447
UILapineBox_IngredientListWnd::UILapineBox_IngredientListWnd(UIWindowContext& windows, int width, int height)
: UIScrollWnd(windows, width, height, 0), minRefine(0), maxRefine(20) {
this->Resize(width, height);
this->Slot15(width, height);
}
// OFFSET: 0x005FF820
// FUNCTION: fn_04150
void UILapineBoxWnd::Slot10(int, int, std::intptr_t value) {
CMode* mode = g_modeMgr.GetGameMode();
const ModeDragState* drag = reinterpret_cast<const ModeDragState*>(value);
if (this->items.size() < static_cast<unsigned>(this->maxItems) && drag->source == 27) {
const int result = this->ingredientList->SendMsg(this, 104, drag->id, 0, 0, 0);
if (result >= 0) {
this->AddIngredient(drag->id, drag->quantity);
}
}
mode->SendMsg(18, 0, 0, 0, 0);
}
// OFFSET: 0x005FF8B0
// FUNCTION: fn_04151
void UILapineBox_IngredientListWnd::Slot10(int, int, std::intptr_t value) {
CMode* mode = g_modeMgr.GetGameMode();
const ModeDragState* drag = reinterpret_cast<const ModeDragState*>(value);
if (drag->source == 26) {
if (this->AddIngredient(drag->id) == 1) {
this->parent->SendMsg(this, 104, drag->id, 0, 0, 0);
}
}
mode->SendMsg(18, 0, 0, 0, 0);
}
// OFFSET: 0x005FF920
// FUNCTION: fn_04153
void UILapineBoxWnd::Slot15(int, int) {
UIButtonContext& controls = *this->m_controls;
UIBitmapButton* base = new UIBitmapButton(*this->m_context, controls);
base->SetBitmap("유저인터페이스\\basic_interface\\sys_base_off.bmp", 0, 0);
base->SetBitmap("유저인터페이스\\basic_interface\\sys_base_on.bmp", 1, 0);
base->SetBitmap("유저인터페이스\\basic_interface\\sys_base_on.bmp", 2, 0);
base->SetSize(base->BitmapWidth(), base->BitmapHeight());
base->Move(3, 3);
this->AddChild(base);
this->AddCloseButton(controls, "", 0);
UILapineBox_IngredientListWnd* list = new UILapineBox_IngredientListWnd(*this->m_context, 150, 204);
this->ingredientList = list;
list->Move(241, 17);
this->AddChild(list);
UIBitmapButton* cancel = new UIBitmapButton(*this->m_context, controls);
this->cancelButton = cancel;
cancel->SetBitmap("유저인터페이스\\lapine\\btn_cancel_out.bmp", 0, 0);
cancel->SetBitmap("유저인터페이스\\lapine\\btn_cancel_over.bmp", 1, 0);
cancel->SetBitmap("유저인터페이스\\lapine\\btn_cancel_press.bmp", 2, 0);
cancel->SetBitmap("유저인터페이스\\lapine\\btn_cancel_dis.bmp", 3, 0);
cancel->SetSize(cancel->BitmapWidth(), cancel->BitmapHeight());
cancel->Move(280, 226);
cancel->SetId(201);
this->AddChild(cancel);
UIBitmapButton* make = new UIBitmapButton(*this->m_context, controls);
this->makeButton = make;
make->SetBitmap("유저인터페이스\\lapine\\btn_make_out.bmp", 0, 0);
make->SetBitmap("유저인터페이스\\lapine\\btn_make_over.bmp", 1, 0);
make->SetBitmap("유저인터페이스\\lapine\\btn_make_press.bmp", 2, 0);
make->SetBitmap("유저인터페이스\\lapine\\btn_make_dis.bmp", 3, 0);
make->SetSize(make->BitmapWidth(), make->BitmapHeight());
make->Move(340, 226);
make->SetId(503);
this->AddChild(make);
UIBitmapButton* move = new UIBitmapButton(*this->m_context, controls);
this->moveButton = move;
move->SetBitmap("유저인터페이스\\lapine\\btn_moveitem_out.bmp", 0, 0);
move->SetBitmap("유저인터페이스\\lapine\\btn_moveitem_over.bmp", 1, 0);
move->SetBitmap("유저인터페이스\\lapine\\btn_moveitem_press.bmp", 2, 0);
move->SetBitmap("유저인터페이스\\lapine\\btn_moveitem_dis.bmp", 3, 0);
move->SetSize(move->BitmapWidth(), move->BitmapHeight());
move->Move(213, 110);
move->SetId(505);
this->AddChild(move);
}
// OFFSET: 0x005FFCD0
// FUNCTION: fn_04154
void UILapineBox_IngredientListWnd::Slot15(int width, int height) {
this->scrollBarWidth = 9;
if (this->scrollBar != nullptr) {
this->RemoveChild(this->scrollBar, 0);
if (this->scrollBar != nullptr) {
delete this->scrollBar;
}
this->scrollBar = nullptr;
}
UILapineScrollBar* bar = new UILapineScrollBar(*this->m_context);
this->scrollBar = bar;
bar->Configure(width - this->scrollBarWidth, 0, 1, height - this->scrollBarHeight);
this->AddChild(this->scrollBar);
}
// OFFSET: 0x005FFDC0
// OFFSET: 0x005FFF90
// FUNCTION: fn_04156
void UILapineBoxWnd::Paint() {
UIButtonContext& controls = *this->m_controls;
CBitmapRes* background = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\lapine\\bg_lapine.bmp")));
this->DrawBitmap(0, 0, &background->image, true);
if (this->title.size() != 0) {
this->DrawTitleBar(controls.fonts, controls.locale, false, this->title.c_str(), 0);
}
this->DrawCenteredText(33, 47, LookupMessage(2896), 160, 0, 11, 0xCD7A51, 0);
this->DrawCenteredText(33, 63, this->description.c_str(), 160, 0, 11, 0x844A42, 0);
const std::string count = FormatOwnedString("%d", static_cast<int>(this->items.size()));
this->DrawCenteredText(98, 76, count.c_str(), 14, 0, 11, 0xFFFFFF, 0);
const std::string maximum = FormatOwnedString("%d", this->maxItems);
this->DrawCenteredText(115, 76, maximum.c_str(), 14, 0, 11, 0xFFFFFF, 0);
ItemDescriptions descriptions{g_itemDescriptions};
const unsigned total = static_cast<unsigned>(this->items.size());
for (unsigned index = 0; index < total; ++index) {
int x = 0;
int y = 0;
if (static_cast<int>(index) >= 0 && index < total) {
int left = 33;
int top = 162;
if (5 < static_cast<int>(total)) {
left = 25;
top = 152;
}
if (static_cast<int>(index) >= 5) {
left = 42;
top = 183;
}
x = left + static_cast<int>(index % 5) * 34;
y = top;
}
CBitmapRes* slot = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\lapine\\shadow_item_off.bmp")));
this->DrawBitmap(x - 4, y + 11, &slot->image, true);
DrawItemWithQuantity(*this, controls.resources, descriptions, controls.fonts, controls.locale, x, y, this->items[index], 0, 0);
}
if (timeGetTime() < this->noticeTick + this->noticeDuration) {
CBitmapRes* icon = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\lapine\\icon_notify.bmp")));
this->DrawBitmap(6, 229, &icon->image, true);
this->DrawTextAt(controls.fonts, controls.locale, 25, 230, this->notice.c_str(), 0, 0, 12, 0xFF0000, 0, 0);
}
}
// OFFSET: 0x00601D20
// FUNCTION: fn_04177
int UILapineBoxWnd::AddIngredient(std::uint32_t id, int quantity) {
if (this->items.size() < 10) {
for (const ITEM_INFO& entry : this->items) {
if (entry.unknown_0000[1] == id) {
return 0;
}
}
ITEM_INFO item = LookupClientItemByIdentity(g_session.m_inventoryItems, id);
item.quantity = quantity;
char name[260];
std::memset(name, 0, sizeof(name));
int capacity = 260;
ItemDescriptions descriptions{g_itemDescriptions};
descriptions.Name(item, name, capacity, 1);
if (item.identified == 1 && item.unknown_0098 != 0) {
char formatted[260];
StringFormat(formatted, sizeof(formatted), sizeof(formatted), LookupMessage(2600), name, item.unknown_0098);
item.SetName(formatted);
} else {
item.SetName(name);
}
this->items.push_back(item);
if (static_cast<int>(this->items.size()) == this->maxItems) {
this->moveButton->SetDisabled(1);
this->moveButton->Invalidate();
}
this->Invalidate();
return 1;
}
return 0;
}
// OFFSET: 0x00602030

View file

@ -3,15 +3,26 @@
#include "Contents/Items/ItemInfo.h"
#include "UI/Lists/UIScrollBar.h"
#include "UI/UIIngredientInfoWnd.h"
#include "UI/UIScrollWnd.h"
#include "UI/Window/UIFrameWnd.h"
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
class UIBitmapButton;
struct UIButtonContext;
class UILapineUpgradeBox_IngredientInfoWnd;
class UILapineBoxWnd;
class UILapineScrollBar : public UIScrollBar {
public:
// INLINED
explicit UILapineScrollBar(UIWindowContext& windows) : UIScrollBar(windows) {
this->arrowLength = 0;
}
void Paint() override;
};
@ -38,8 +49,56 @@ static_assert(offsetof(UILapineUpgradeBox_IngredientListWnd, maxRefine) == 0xD0)
#endif
class UILapineBox_IngredientListWnd : public UIScrollWnd {
friend class UILapineBoxWnd;
public:
UILapineBox_IngredientListWnd(UIWindowContext& windows, int width, int height);
void Slot10(int x, int y, std::intptr_t value) override;
void Slot15(int width, int height) override;
void Paint() override;
unsigned char AddIngredient(std::uint32_t id);
/* 00B0 */ std::vector<ITEM_INFO> materials;
/* 00BC */ std::vector<UIIngredientInfoWnd*> items;
/* 00C8 */ int minRefine;
/* 00CC */ int maxRefine;
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(offsetof(UILapineBox_IngredientListWnd, materials) == 0xB0);
static_assert(offsetof(UILapineBox_IngredientListWnd, items) == 0xBC);
static_assert(offsetof(UILapineBox_IngredientListWnd, minRefine) == 0xC8);
static_assert(offsetof(UILapineBox_IngredientListWnd, maxRefine) == 0xCC);
#endif
class UILapineBoxWnd : public UIFrameWnd {
friend class UILapineBox_IngredientListWnd;
public:
void Slot10(int x, int y, std::intptr_t value) override;
void Slot15(int width, int height) override;
void Paint() override;
int AddIngredient(std::uint32_t id, int quantity);
// INLINED
UIFrameContext& FrameContext() {
return *this->m_frameContext;
}
/* 00B4 */ UIBitmapButton* cancelButton;
/* 00B8 */ UIBitmapButton* makeButton;
/* 00BC */ UIBitmapButton* moveButton;
/* 00C0 */ UILapineBox_IngredientListWnd* ingredientList;
/* 00C4 */ int unknown_00C4;
/* 00C8 */ std::string title;
/* 00E0 */ std::vector<ITEM_INFO> items;
/* 00EC */ int maxItems;
/* 00F0 */ std::string description;
/* 0108 */ std::string notice;
/* 0120 */ std::uint32_t noticeTick;
/* 0124 */ std::uint32_t noticeDuration;
protected:
UIButtonContext* m_controls;
};
#endif

View file

@ -11,6 +11,13 @@ class UIScrollBar;
class UIScrollWnd : public UIWindow {
public:
// INLINED
UIScrollWnd(UIWindowContext& windows, int width, int height, unsigned char cached)
: UIWindow(windows, cached), viewHeight(0), contentWidth(0), contentHeight(0), horizontalBar(nullptr), scrollBar(nullptr),
scrollBarWidth(13), scrollBarHeight(13), unknown_009C(0), scrollPosition(0), unknown_00A4(0), wheelScroll(0) {
this->Resize(width, height);
this->Slot15(width, height);
}
~UIScrollWnd() override;
void Slot15(int width, int height) override;
void Slot35(int delta) override;