diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index 9b0b242e..b31eb19d 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -200,6 +200,7 @@ public: 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); void DrawPanelBackgroundAt(int x, int y, int width, const char* bitmapName); + void DrawRobeSprite(int job, int sex, int robe, int x, int y, bool overlay, int animation, int frame); int DrawButtonBar(int style, int width, int rows); int DrawButtonBarAt(int style, int x, int width, int rows); CBitmapRes* LoadStyledBitmap(int style, const char* format, const char* name); diff --git a/Source/UI/WindowBackground.cpp b/Source/UI/WindowBackground.cpp index 17438764..51d01641 100644 --- a/Source/UI/WindowBackground.cpp +++ b/Source/UI/WindowBackground.cpp @@ -1,11 +1,22 @@ +#include "Client/Session.h" +#include "Contents/Configuration/ServiceConfiguration.h" +#include "Contents/Skills/ClientSkills.h" +#include "Render/DeviceContext/DeviceContext.h" +#include "Render/Renderer.h" +#include "Render/Textures/SpriteAtlas.h" +#include "Render/Textures/SpritePixels.h" +#include "Render/Textures/Texture.h" #include "Resource/Bitmap/BitmapResource.h" #include "Resource/ResourceMgr.h" #include "Resource/SkinPalette.h" +#include "Resource/Sprites/ActionResource.h" +#include "Resource/Sprites/SpriteResource.h" #include "Resource/TextureNames.h" #include "UI/Window/UIWindow.h" #include "UI/Window/WindowBorder.h" #include +#include #include // OFFSET: 0x008D03E0 @@ -62,3 +73,55 @@ void UIWindow::DrawPanelBackgroundAt(int x, int y, int width, const char* bitmap this->FillRegion(x + 1, y, width - 2, height - y - 2, RGB(red, green, blue)); this->FillRegion(x + 2, height - 2, width - 4, 1, RGB(red, green, blue)); } + +// OFFSET: 0x008D0680 +// FUNCTION: fn_12087 +void UIWindow::DrawRobeSprite(int job, int sex, int robe, int x, int y, bool overlay, int animation, int frame) { + if (robe <= 0) { + return; + } + + std::string sprName = g_session.GetRobeSprName(job, job, sex, robe, false, job); + if (!ResourceMgr::Instance().Exists(sprName.c_str())) { + return; + } + + std::string actName = g_session.GetRobeActName(job, job, sex, robe, false, job); + if (!ResourceMgr::Instance().Exists(actName.c_str())) { + return; + } + + CActRes* action = static_cast(ResourceMgr::Instance().Load(actName.c_str())); + CSprRes* sprite = static_cast(ResourceMgr::Instance().Load(sprName.c_str())); + const SpriteFrameCell& cell = action->Frame(animation, frame).Cell(0); + if (cell.image == -1) { + return; + } + + SpriteAtlasRecord record{}; + record.u0 = 0.0f; + record.v0 = 0.0f; + const SpriteRleImage* image = sprite->images[cell.imageType][cell.image]; + CTexture* texture; + if (cell.imageType == 0) { + texture = g_renderer->atlas.Find(image, sprite->palette, record); + if (!texture) { + texture = g_renderer->atlas.Insert(this->m_context->renderSystem, image, sprite->palette, record, g_serviceType, g_resourceReuseDelay); + } + } else { + texture = static_cast(const_cast(image->unknown_0008)); + } + + if (overlay) { + const std::uint32_t color = this->Color(); + this->AddSpriteCellOverlay( + x, y, reinterpret_cast(action), reinterpret_cast(sprite), image, &cell, GetSkillFactor(job), 0.0f, color, sprite->palette, 1.0f + ); + return; + } + + this->geometry.surface->DrawSurface( + x + cell.x, y + cell.y, texture, static_cast(record.u0 * 256.0f), static_cast(record.v0 * 256.0f), image->width, image->height, + cell.mirrored != 0, static_cast(image->unknown_0004) + 1, static_cast(image->unknown_0006) + 1, 0, 0 + ); +}