Decompile fn_16922 (UIWindow::AddSpriteCellOverlay)
Batch #1909 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_16922 UIWindow::AddSpriteCellOverlay: logic confirmed by peer review Peer-reviewed-by: eAthena, Yommy Reviewed-by: ragnarok-clanker Adds to the build: Source/UI/WindowSprite.cpp
This commit is contained in:
parent
5a145c119d
commit
16419b914e
3 changed files with 109 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ struct tagRECT;
|
|||
struct tagSIZE;
|
||||
struct ActionFrame;
|
||||
class CSprRes;
|
||||
struct SpriteRleImage;
|
||||
struct SpriteFrameCell;
|
||||
class CBitmapRes;
|
||||
|
||||
struct UIWindowContext {
|
||||
|
|
@ -148,6 +150,10 @@ public:
|
|||
int FormattedTextWidth(FontCache& fonts, const TextLocale& locale, std::string text, int family, int height, unsigned char bold);
|
||||
int RestoreEditTexts(const unsigned char* data);
|
||||
bool FitSprite(const ActionFrame* frame, const CSprRes* sprite, int width, int height, int* x, int* y, float* scale);
|
||||
void AddSpriteCellOverlay(
|
||||
int x, int y, int, int, const SpriteRleImage* image, const SpriteFrameCell* cell, float scale, float angle, std::uint32_t color,
|
||||
const std::uint32_t* palette, float extentScale
|
||||
);
|
||||
int DrawTitleBar(FontCache& fonts, const TextLocale& locale, bool closeButton, const char* title, int width);
|
||||
int DrawTitleBarAt(FontCache& fonts, const TextLocale& locale, int x, int width, bool closeButton, const char* title);
|
||||
void DrawPanelBackground(int y, int width, const char* bitmapName);
|
||||
|
|
|
|||
102
Source/UI/WindowSprite.cpp
Normal file
102
Source/UI/WindowSprite.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#include "Contents/Configuration/ServiceConfiguration.h"
|
||||
#include "Render/DeviceContext/DCSurface.h"
|
||||
#include "Render/Primitives/RenderPrimitivePool.h"
|
||||
#include "Render/Renderer.h"
|
||||
#include "Render/Textures/SpriteAtlas.h"
|
||||
#include "Render/Textures/SpritePixels.h"
|
||||
#include "Render/Textures/Texture.h"
|
||||
#include "Resource/ResourceMgr.h"
|
||||
#include "UI/Window/UIWindow.h"
|
||||
#include "Utility/Math/AffineMatrix.h"
|
||||
|
||||
// OFFSET: 0x00A7A0C0
|
||||
// FUNCTION: fn_16922
|
||||
void UIWindow::AddSpriteCellOverlay(
|
||||
int x, int y, int, int, const SpriteRleImage* image, const SpriteFrameCell* cell, float scale, float angle, std::uint32_t color,
|
||||
const std::uint32_t* palette, float extentScale
|
||||
) {
|
||||
x += this->geometry.x;
|
||||
y += this->geometry.y;
|
||||
|
||||
SpriteAtlasRecord record{};
|
||||
RenderPrimitive* primitive = g_renderer->primitives.Acquire();
|
||||
|
||||
float left = static_cast<float>(cell->x) * scale * cell->scaleX;
|
||||
float right = static_cast<float>((image->unknown_0004 + 1) * image->width + cell->x - 1) * scale * cell->scaleX * extentScale;
|
||||
float top = static_cast<float>(cell->y) * scale * cell->scaleY;
|
||||
float bottom = static_cast<float>((image->unknown_0006 + 1) * image->height - 1 + cell->y) * scale * cell->scaleY * extentScale;
|
||||
|
||||
CTexture* texture;
|
||||
if (cell->imageType == 0) {
|
||||
texture = g_renderer->atlas.Find(image, palette, record);
|
||||
if (!texture) {
|
||||
texture = g_renderer->atlas.Insert(*GetRenderSystemHolder()->system, image, palette, record, g_serviceType, g_resourceReuseDelay);
|
||||
}
|
||||
} else {
|
||||
texture = static_cast<CTexture*>(const_cast<void*>(image->unknown_0008));
|
||||
record.u1 = static_cast<float>(image->width) / static_cast<float>(texture->TextureWidth());
|
||||
record.v1 = static_cast<float>(image->height) / static_cast<float>(texture->TextureHeight());
|
||||
}
|
||||
primitive->texture = texture;
|
||||
|
||||
RenderVertex* vertices = primitive->quad;
|
||||
if (angle != 0.0f) {
|
||||
const float cosine = ClientCosine(static_cast<int>(angle));
|
||||
const float sine = ClientSine(static_cast<int>(angle));
|
||||
const int farX = (image->unknown_0004 + 1) * image->width + cell->x;
|
||||
const float startX = static_cast<float>((cell->mirrored & 1) ? farX : cell->x) * scale + static_cast<float>(x);
|
||||
const float endX = static_cast<float>((cell->mirrored & 1) ? cell->x : farX) * scale + static_cast<float>(x) + 1.0f;
|
||||
const float upper = static_cast<float>(cell->y) * scale + static_cast<float>(y);
|
||||
const float lower = static_cast<float>((image->unknown_0006 + 1) * image->height + cell->y) * scale + static_cast<float>(y) + 1.0f;
|
||||
const float halfWidth = (endX - startX) * 0.5f;
|
||||
const float halfHeight = (lower - upper) * 0.5f;
|
||||
const float centerX = startX + halfWidth;
|
||||
const float centerY = upper + halfHeight;
|
||||
const float minX = -halfWidth;
|
||||
const float minY = -halfHeight;
|
||||
|
||||
vertices[0].x = minX * cosine - minY * sine + centerX + 0.5f;
|
||||
vertices[0].y = minY * cosine + minX * sine + centerY + 0.5f;
|
||||
vertices[1].x = halfWidth * cosine - minY * sine + centerX + 0.5f;
|
||||
vertices[1].y = minY * cosine + halfWidth * sine + centerY + 0.5f;
|
||||
vertices[2].x = minX * cosine - halfHeight * sine + centerX + 0.5f;
|
||||
vertices[2].y = halfHeight * cosine + minX * sine + centerY + 0.5f;
|
||||
vertices[3].x = halfWidth * cosine - halfHeight * sine + centerX + 0.5f;
|
||||
vertices[3].y = halfHeight * cosine + halfWidth * sine + centerY + 0.5f;
|
||||
} else {
|
||||
if (cell->mirrored & 1) {
|
||||
const float swap = left;
|
||||
left = right;
|
||||
right = swap;
|
||||
}
|
||||
left += static_cast<float>(x);
|
||||
right += static_cast<float>(x);
|
||||
top += static_cast<float>(y);
|
||||
bottom += static_cast<float>(y);
|
||||
|
||||
vertices[0].x = left + 0.5f;
|
||||
vertices[0].y = top + 0.5f;
|
||||
vertices[1].x = right + 0.5f;
|
||||
vertices[1].y = top + 0.5f;
|
||||
vertices[2].x = left + 0.5f;
|
||||
vertices[2].y = bottom + 0.5f;
|
||||
vertices[3].x = right + 0.5f;
|
||||
vertices[3].y = bottom + 0.5f;
|
||||
}
|
||||
|
||||
for (RenderVertex& vertex : primitive->quad) {
|
||||
vertex.z = 0.000001f;
|
||||
vertex.rhw = 0.999999f;
|
||||
vertex.diffuse = color;
|
||||
}
|
||||
vertices[0].u = record.u0;
|
||||
vertices[0].v = record.v0;
|
||||
vertices[1].u = record.u1;
|
||||
vertices[1].v = record.v0;
|
||||
vertices[2].u = record.u0;
|
||||
vertices[2].v = record.v1;
|
||||
vertices[3].u = record.u1;
|
||||
vertices[3].v = record.v1;
|
||||
|
||||
this->m_overlayPrimitives.push_back(primitive);
|
||||
}
|
||||
|
|
@ -698,6 +698,7 @@
|
|||
"Source/UI/Window/WindowRetirement.cpp": 2,
|
||||
"Source/UI/WindowBackground.cpp": 2,
|
||||
"Source/UI/WindowLowerBorder.cpp": 2,
|
||||
"Source/UI/WindowSprite.cpp": 2,
|
||||
"Source/UI/WindowTitlebar.cpp": 2,
|
||||
"Source/Utility/AES.cpp": 0,
|
||||
"Source/Utility/Async/AsyncDiagnostic.cpp": 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue