diff --git a/Source/Client/ModeFade.cpp b/Source/Client/ModeFade.cpp new file mode 100644 index 0000000..31005f0 --- /dev/null +++ b/Source/Client/ModeFade.cpp @@ -0,0 +1,26 @@ +#include "Client/ModeFade.h" +#include "Contents/Sound/SoundMgr.h" +#include "Render/Primitives/AlphaRectangle.h" + +#include + +// GLOBAL: gl_24680 +std::uint32_t g_modeFadeTick = 0; + +// OFFSET: 0x00AD6740 +// FUNCTION: fn_17842 +void ModeFade::Draw() { + if (this->requested != 0) { + g_modeFadeTick = timeGetTime(); + g_soundMgr->FadeIn(); + this->requested = 0; + } + + const std::uint32_t elapsed = timeGetTime() - g_modeFadeTick; + if (elapsed < 255) { + DrawAlphaRectangle( + this->primitives, this->textures, this->queues, 0, 0, this->screenWidth, this->screenHeight, (255 - elapsed) << 24, this->depthAlpha, this->depthStart, + this->depthEnd + ); + } +} diff --git a/Source/Client/ModeFade.h b/Source/Client/ModeFade.h new file mode 100644 index 0000000..5209077 --- /dev/null +++ b/Source/Client/ModeFade.h @@ -0,0 +1,26 @@ +#ifndef RAGNAROK_SOURCE_CLIENT_MODEFADE_H +#define RAGNAROK_SOURCE_CLIENT_MODEFADE_H + +#include + +class RenderPrimitivePool; +class TextureCache; +struct RenderQueues; + +extern std::uint32_t g_modeFadeTick; + +struct ModeFade { + int& requested; + RenderPrimitivePool& primitives; + TextureCache& textures; + RenderQueues& queues; + const int& screenWidth; + const int& screenHeight; + const bool& depthAlpha; + const float& depthStart; + const float& depthEnd; + + void Draw(); +}; + +#endif diff --git a/Source/Render/AlphaRectangle.cpp b/Source/Render/AlphaRectangle.cpp new file mode 100644 index 0000000..fb4563f --- /dev/null +++ b/Source/Render/AlphaRectangle.cpp @@ -0,0 +1,38 @@ +#include "Render/Primitives/AlphaRectangle.h" +#include "Render/Primitives/RenderPrimitivePool.h" +#include "Render/Primitives/RenderQueues.h" +#include "Render/Textures/TextureCache.h" + +// OFFSET: 0x0054E460 +// FUNCTION: fn_01952 +void DrawAlphaRectangle( + RenderPrimitivePool& primitives, TextureCache& textures, RenderQueues& queues, int x, int y, int width, int height, std::uint32_t color, bool depthAlpha, + float depthStart, float depthEnd +) { + if ((color & 0xFF000000u) == 0) { + return; + } + + RenderPrimitive* primitive = primitives.Acquire(); + primitive->texture = textures.Default(); + const float left = static_cast(x); + const float top = static_cast(y); + const float right = static_cast(x + width); + const float bottom = static_cast(y + height); + primitive->quad[0].x = left; + primitive->quad[0].y = top; + primitive->quad[1].x = right; + primitive->quad[1].y = top; + primitive->quad[2].x = left; + primitive->quad[2].y = bottom; + primitive->quad[3].x = right; + primitive->quad[3].y = bottom; + for (RenderVertex& vertex : primitive->quad) { + vertex.z = 0.000001f; + vertex.rhw = 0.999999f; + vertex.diffuse = color; + vertex.u = 0.0f; + vertex.v = 0.0f; + } + queues.Submit(primitive, 513, depthAlpha, depthStart, depthEnd); +} diff --git a/compile.json b/compile.json index 22625a4..d5d850f 100644 --- a/compile.json +++ b/compile.json @@ -257,6 +257,7 @@ "Source/Client/Mode/ModeCursor.cpp": 0, "Source/Client/Mode/ModeDragState.cpp": 2, "Source/Client/Mode/ModeTooltip.cpp": 2, + "Source/Client/ModeFade.cpp": 0, "Source/Client/Registry.cpp": 0, "Source/Client/Replay.cpp": 0, "Source/Client/ReplayPacketRecorder.cpp": 2, @@ -428,6 +429,7 @@ "Source/Network/Packets/PartyJoinRequest.cpp": 2, "Source/Network/Packets/SkillUpdatePacket.cpp": 4, "Source/Network/TextEncoding.cpp": 0, + "Source/Render/AlphaRectangle.cpp": 0, "Source/Render/BlendColor.cpp": 0, "Source/Render/DX7/BackBufferDX7.cpp": 0, "Source/Render/DX7/DeviceCapabilitiesDX7.cpp": 0,