rodecomp/Source/UI/Window/UIResizer.cpp
ragnarok-clanker b6436d5059 Maintenance: [forced, user-approved] Family F1: UIWindowContext field reads replaced by the real objects. primitives->g_renderer->pri
Batch #10209 by ragnarok-clanker: forced by an admin (36 lower score(s), 108 changed function(s)); checked with 561 compiled unit(s), including every includer of Source/Client/Mode/CMode.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h.
2026-11-02 23:01:18 +00:00

144 lines
3.4 KiB
C++

#include "Client/Mode/CMode.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/TextureNames.h"
#include "UI/Window/UINewSelectCharWnd.h"
#include "UI/Window/UIResizer.h"
#include "UI/Window/UIWindowMgr.h"
// OFFSET: 0x008656E0
// FUNCTION: fn_10929
void UIResizer::SetBitmapName(const char* name) {
this->bitmapName = name;
CBitmapRes* bitmap = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve(this->bitmapName.c_str())));
this->geometry.width = bitmap->image.width;
this->geometry.height = bitmap->image.height;
}
// OFFSET: 0x00865970
// FUNCTION: fn_10933
void UIResizer::SetColors(std::uint32_t line, std::uint32_t background) {
this->Invalidate();
this->lineColor = line;
this->backgroundColor = background;
}
// OFFSET: 0x0085D650
// FUNCTION: fn_10815
void UIResizer::Paint() {
if (!this->bitmapName.empty()) {
CBitmapRes* bitmap = static_cast<CBitmapRes*>(ResourceMgr::Instance().Load(Resolve(this->bitmapName.c_str())));
this->DrawBitmap(0, 0, bitmap ? &bitmap->image : nullptr, false);
return;
}
this->ClearSurface(this->backgroundColor);
this->FillRegion(0, 0, this->geometry.width, 2, this->lineColor);
}
// OFFSET: 0x0085ECE0
// FUNCTION: fn_10845
void UIResizer::Slot25(int x, int y) {
g_windowMgr.SetCapture(this);
this->startX = x;
this->startY = y;
if (this->parent) {
this->parentWidth = this->parent->geometry.width;
this->parentHeight = this->parent->geometry.height;
}
this->ToScreen(this->startX, this->startY);
}
// OFFSET: 0x0085F470
// FUNCTION: fn_10862
void UIResizer::Slot28(int, int) {
}
// OFFSET: 0x0085F6D0
// FUNCTION: fn_10869
void UIResizer::Slot27(int x, int y) {
if (g_windowMgr.Capture() != this) {
return;
}
int screenX = x;
int screenY = y;
this->ToScreen(screenX, screenY);
if (!this->parent) {
return;
}
const int dx = screenX - this->startX;
int width = this->parentWidth;
int height = this->parentHeight;
const int dy = screenY - this->startY;
switch (this->direction) {
case 0:
width -= dx;
break;
case 1:
width += dx;
break;
case 2:
height -= dy;
break;
case 3:
height += dy;
break;
case 4:
width -= dx;
height -= dy;
break;
case 5:
width += dx;
height -= dy;
break;
case 6:
width -= dx;
height += dy;
break;
case 7:
width += dx;
height += dy;
break;
}
this->parent->SendMsg(this, 14, this->direction, width, height, 0);
}
// OFFSET: 0x0085FA20
// FUNCTION: fn_10879
void UIResizer::ResetCursor(int x, int y) {
if (g_windowMgr.Capture() == this || (x >= 0 && x < this->geometry.width && y >= 0 && y <= this->geometry.height)) {
static_cast<CMode*>(g_charViewMode)->SetCursorAction(2);
} else if (g_windowMgr.Capture() != this) {
static_cast<CMode*>(g_charViewMode)->SetCursorAction(0);
}
}
// OFFSET: 0x0085EFD0
// FUNCTION: fn_10853
void UIResizer::Slot31(int, int) {
if (g_windowMgr.Capture() != this) {
return;
}
if (this->parent) {
this->parent->Slot36();
}
g_windowMgr.ReleaseCapture();
}
// OFFSET: 0x008697F0
// FUNCTION: fn_10971
void UIResizer::SetDirection(int value) {
this->direction = value;
}
// OFFSET: 0x00850120
// FUNCTION: fn_10671
UIResizer::UIResizer(UIWindowContext& windows)
: UIWindow(windows, 0), direction(0), parentWidth(0), parentHeight(0), lineColor(0xFFFF00FF), backgroundColor(0xFFFF00FF) {
}