From 1f25becf8e01dac2ed579b8d0fca7420b57952f4 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 17 May 2017 21:07:49 -1000 Subject: [PATCH] Finish CAuiImagePane --- DataSpec/DNACommon/Tweaks/ITweakGui.hpp | 10 +- DataSpec/DNAMP1/Tweaks/CTweakGui.hpp | 28 +-- Runtime/Graphics/CTexture.hpp | 1 + .../Graphics/Shaders/CTexturedQuadFilter.cpp | 3 +- .../Graphics/Shaders/CTexturedQuadFilter.hpp | 3 +- .../Shaders/CTexturedQuadFilterGLSL.cpp | 12 +- .../Shaders/CTexturedQuadFilterHLSL.cpp | 12 +- .../Shaders/CTexturedQuadFilterMetal.cpp | 12 +- Runtime/GuiSys/CAuiImagePane.cpp | 164 +++++++++++++++++- Runtime/GuiSys/CAuiImagePane.hpp | 29 +++- Runtime/GuiSys/CScanDisplay.cpp | 15 +- Runtime/MP1/CLogBookScreen.cpp | 2 +- 12 files changed, 243 insertions(+), 48 deletions(-) diff --git a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp index 90385735c..99657edf6 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp @@ -94,7 +94,7 @@ struct ITweakGui : ITweak virtual float GetHudDecoShakeTranslateGain() const=0; virtual float GetHudLagOffsetScale() const=0; virtual float GetScanAppearanceDuration() const=0; - virtual float GetScanPaneFadeAlpha() const=0; + virtual float GetScanPaneFlashFactor() const=0; virtual float GetScanPaneFadeInTime() const=0; virtual float GetScanPaneFadeOutTime() const=0; virtual float GetBallViewportYReduction() const=0; @@ -109,10 +109,10 @@ struct ITweakGui : ITweak virtual float GetScanSidesEndTime() const=0; virtual float GetScanDataDotRadius() const=0; virtual float GetScanDataDotPosRandMagnitude() const=0; - virtual float GetScanDataDotDuration1Min() const=0; - virtual float GetScanDataDotDuration1Max() const=0; - virtual float GetScanDataDotDuration2Min() const=0; - virtual float GetScanDataDotDuration2Max() const=0; + virtual float GetScanDataDotSeekDurationMin() const=0; + virtual float GetScanDataDotSeekDurationMax() const=0; + virtual float GetScanDataDotHoldDurationMin() const=0; + virtual float GetScanDataDotHoldDurationMax() const=0; virtual float GetScanSidesPositionStart() const=0; virtual bool GetLatchArticleText() const=0; virtual float GetWorldTransManagerCharsPerSfx() const=0; diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp index 15b5d8288..bb5f45e4d 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp @@ -132,12 +132,12 @@ struct CTweakGui : ITweakGui float x228_scanSidesEndTime; Value x22c_scanDataDotRadius; Value x230_scanDataDotPosRandMag; - Value x234_scanDataDotDuration1Min; - Value x238_scanDataDotDuration1Max; - Value x23c_scanDataDotDuration2Min; - Value x240_scanDataDotDuration2Max; + Value x234_scanDataDotSeekDurationMin; + Value x238_scanDataDotSeekDurationMax; + Value x23c_scanDataDotHoldDurationMin; + Value x240_scanDataDotHoldDurationMax; Value x244_scanAppearanceDuration; - Value x248_scanPaneFadeAlpha; + Value x248_scanPaneFlashFactor; Value x24c_scanPaneFadeInTime; Value x250_scanPaneFadeOutTime; Value x254_ballViewportYReduction; @@ -255,11 +255,6 @@ struct CTweakGui : ITweakGui float GetHudDamageColorGain() const { return x1d4_hudDamageColorGain; } float GetHudDecoShakeTranslateGain() const { return x1d8_hudDecoShakeTranslateGain; } float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; } - float GetScanAppearanceDuration() const { return x244_scanAppearanceDuration; } - float GetScanPaneFadeAlpha() const { return x248_scanPaneFadeAlpha; } - float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; } - float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; } - float GetBallViewportYReduction() const { return x254_ballViewportYReduction; } float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; } float GetXrayBlurScaleQuadratic() const { return x208_xrayBlurScaleQuadratic; } float GetScanSidesAngle() const { return x210_scanSidesAngle; } @@ -270,10 +265,15 @@ struct CTweakGui : ITweakGui float GetScanSidesEndTime() const { return x228_scanSidesEndTime; } float GetScanDataDotRadius() const { return x22c_scanDataDotRadius; } float GetScanDataDotPosRandMagnitude() const { return x230_scanDataDotPosRandMag; } - float GetScanDataDotDuration1Min() const { return x234_scanDataDotDuration1Min; } - float GetScanDataDotDuration1Max() const { return x238_scanDataDotDuration1Max; } - float GetScanDataDotDuration2Min() const { return x23c_scanDataDotDuration2Min; } - float GetScanDataDotDuration2Max() const { return x240_scanDataDotDuration2Max; } + float GetScanDataDotSeekDurationMin() const { return x234_scanDataDotSeekDurationMin; } + float GetScanDataDotSeekDurationMax() const { return x238_scanDataDotSeekDurationMax; } + float GetScanDataDotHoldDurationMin() const { return x23c_scanDataDotHoldDurationMin; } + float GetScanDataDotHoldDurationMax() const { return x240_scanDataDotHoldDurationMax; } + float GetScanAppearanceDuration() const { return x244_scanAppearanceDuration; } + float GetScanPaneFlashFactor() const { return x248_scanPaneFlashFactor; } + float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; } + float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; } + float GetBallViewportYReduction() const { return x254_ballViewportYReduction; } float GetScanSidesPositionStart() const { return x270_scanSidesPositionStart; } bool GetLatchArticleText() const { return x275_latchArticleText; } float GetWorldTransManagerCharsPerSfx() const { return x278_wtMgrCharsPerSfx; } diff --git a/Runtime/Graphics/CTexture.hpp b/Runtime/Graphics/CTexture.hpp index 8bed8466f..d4a1a6ce4 100644 --- a/Runtime/Graphics/CTexture.hpp +++ b/Runtime/Graphics/CTexture.hpp @@ -67,6 +67,7 @@ public: {return x0_fmt == ETexelFormat::C8PC ? ETexelFormat::C8 : ETexelFormat::RGB5A3;} u16 GetWidth() const {return x4_w;} u16 GetHeight() const {return x6_h;} + u32 GetNumMips() const {return x8_mips;} void Load(int slot, EClampMode clamp) const; boo::ITexture* GetBooTexture() const {return m_booTex;} boo::ITexture* GetPaletteTexture() const {return m_paletteTex;} diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp index 09a8ba798..857f3b6fc 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp @@ -73,12 +73,13 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) CGraphics::g_BooMainCommandQueue->draw(0, 4); } -void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[4]) +void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[4], float lod) { m_vbo->load(verts, sizeof(Vert) * 4); m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_color = color; + m_uniform.m_lod = lod; m_uniBuf->load(&m_uniform, sizeof(m_uniform)); CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp index 4ecfab111..e786c78be 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp @@ -23,6 +23,7 @@ protected: { zeus::CMatrix4f m_matrix; zeus::CColor m_color; + float m_lod = 0.f; }; TLockedToken m_tex; boo::ITexture* m_booTex; @@ -50,7 +51,7 @@ public: CTexturedQuadFilter& operator=(CTexturedQuadFilter&&) = default; void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect); void drawCropped(const zeus::CColor& color, float uvScale); - void drawVerts(const zeus::CColor& color, const Vert verts[4]); + void drawVerts(const zeus::CColor& color, const Vert verts[4], float lod=0.f); const TLockedToken& GetTex() const { return m_tex; } using _CLS = CTexturedQuadFilter; diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index ee649954a..cad03fc62 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -15,12 +15,14 @@ BOO_GLSL_BINDING_HEAD "{\n" " mat4 mtx;\n" " vec4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" "{\n" " vec4 color;\n" " vec2 uv;\n" +" float lod;\n" "};\n" "\n" "SBINDING(0) out VertToFrag vtf;\n" @@ -28,6 +30,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vtf.color = color;\n" " vtf.uv = uvIn.xy;\n" +" vtf.lod = lod;\n" " gl_Position = mtx * vec4(posIn.xyz, 1.0);\n" " gl_Position = FLIPFROMGL(gl_Position);\n" "}\n"; @@ -42,12 +45,14 @@ BOO_GLSL_BINDING_HEAD "{\n" " mat4 mtx;\n" " vec4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" "{\n" " vec4 color;\n" " vec2 uv;\n" +" float lod;\n" "};\n" "\n" "SBINDING(0) out VertToFrag vtf;\n" @@ -55,6 +60,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vtf.color = color;\n" " vtf.uv = -uvIn.xy;\n" +" vtf.lod = lod;\n" " gl_Position = mtx * vec4(posIn.xyz, 1.0);\n" " gl_Position = FLIPFROMGL(gl_Position);\n" "}\n"; @@ -66,6 +72,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vec4 color;\n" " vec2 uv;\n" +" float lod;\n" "};\n" "\n" "SBINDING(0) in VertToFrag vtf;\n" @@ -73,7 +80,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = vtf.color * vec4(texture(tex, vtf.uv).rgb, 1.0);\n" +" colorOut = vtf.color * vec4(textureLod(tex, vtf.uv, lod).rgb, 1.0);\n" "}\n"; static const char* FSAlpha = @@ -83,6 +90,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vec4 color;\n" " vec2 uv;\n" +" float lod;\n" "};\n" "\n" "SBINDING(0) in VertToFrag vtf;\n" @@ -90,7 +98,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = vtf.color * texture(tex, vtf.uv);\n" +" colorOut = vtf.color * textureLod(tex, vtf.uv, lod);\n" "}\n"; URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp index f7aecfb4c..51e9c35d8 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp @@ -16,6 +16,7 @@ static const char* VSFlip = "{\n" " float4x4 mat;\n" " float4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" @@ -23,6 +24,7 @@ static const char* VSFlip = " float4 position : SV_Position;\n" " float4 color : COLOR;\n" " float2 uv : UV;\n" +" float lod : LOD;\n" "};\n" "\n" "VertToFrag main(in VertData v)\n" @@ -30,6 +32,7 @@ static const char* VSFlip = " VertToFrag vtf;\n" " vtf.color = color;\n" " vtf.uv = v.uvIn.xy;\n" +" vtf.lod = lod;\n" " vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " return vtf;\n" "}\n"; @@ -45,6 +48,7 @@ static const char* VSNoFlip = "{\n" " float4x4 mat;\n" " float4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" @@ -52,6 +56,7 @@ static const char* VSNoFlip = " float4 position : SV_Position;\n" " float4 color : COLOR;\n" " float2 uv : UV;\n" +" float lod : LOD;\n" "};\n" "\n" "VertToFrag main(in VertData v)\n" @@ -60,6 +65,7 @@ static const char* VSNoFlip = " vtf.color = color;\n" " vtf.uv = v.uvIn.xy;\n" " vtf.uv.y = -vtf.uv.y;\n" +" vtf.lod = lod;\n" " vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " return vtf;\n" "}\n"; @@ -70,6 +76,7 @@ static const char* FS = " float4 position : SV_Position;\n" " float4 color : COLOR;\n" " float2 uv : UV;\n" +" float lod : LOD;\n" "};\n" "\n" "Texture2D tex : register(t0);\n" @@ -77,7 +84,7 @@ static const char* FS = "\n" "float4 main(in VertToFrag vtf) : SV_Target0\n" "{\n" -" return vtf.color * float4(tex.Sample(samp, vtf.uv).rgb, 1.0);\n" +" return vtf.color * float4(tex.SampleLevel(samp, vtf.uv, vtf.lod).rgb, 1.0);\n" "}\n"; static const char* FSAlpha = @@ -86,6 +93,7 @@ static const char* FSAlpha = " float4 position : SV_Position;\n" " float4 color : COLOR;\n" " float2 uv : UV;\n" +" float lod : LOD;\n" "};\n" "\n" "Texture2D tex : register(t0);\n" @@ -93,7 +101,7 @@ static const char* FSAlpha = "\n" "float4 main(in VertToFrag vtf) : SV_Target0\n" "{\n" -" return vtf.color * tex.Sample(samp, vtf.uv);\n" +" return vtf.color * tex.SampleLevel(samp, vtf.uv, vtf.lod);\n" "}\n"; URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp index 014282fec..df484f3a0 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp @@ -18,6 +18,7 @@ static const char* VSFlip = "{\n" " float4x4 mat;\n" " float4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" @@ -25,6 +26,7 @@ static const char* VSFlip = " float4 position [[ position ]];\n" " float4 color;\n" " float2 uv;\n" +" float lod;\n" "};\n" "\n" "vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n" @@ -32,6 +34,7 @@ static const char* VSFlip = " VertToFrag vtf;\n" " vtf.color = tqu.color;\n" " vtf.uv = v.uvIn.xy;\n" +" vtf.lod = tqu.lod;\n" " vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n" " return vtf;\n" "}\n"; @@ -49,6 +52,7 @@ static const char* VSNoFlip = "{\n" " float4x4 mat;\n" " float4 color;\n" +" float lod;\n" "};\n" "\n" "struct VertToFrag\n" @@ -56,6 +60,7 @@ static const char* VSNoFlip = " float4 position [[ position ]];\n" " float4 color;\n" " float2 uv;\n" +" float lod;\n" "};\n" "\n" "vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n" @@ -64,6 +69,7 @@ static const char* VSNoFlip = " vtf.color = tqu.color;\n" " vtf.uv = v.uvIn.xy;\n" " vtf.uv.y = -vtf.uv.y;\n" +" vtf.lod = tqu.lod;\n" " vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n" " return vtf;\n" "}\n"; @@ -78,11 +84,12 @@ static const char* FS = " float4 position [[ position ]];\n" " float4 color;\n" " float2 uv;\n" +" float lod;\n" "};\n" "\n" "fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d tex [[ texture(0) ]])\n" "{\n" -" return vtf.color * float4(tex.sample(samp, vtf.uv).rgb, 1.0);\n" +" return vtf.color * float4(tex.sample(samp, vtf.uv, level(vtf.lod)).rgb, 1.0);\n" "}\n"; static const char* FSAlpha = @@ -94,11 +101,12 @@ static const char* FSAlpha = " float4 position [[ position ]];\n" " float4 color;\n" " float2 uv;\n" +" float lod;\n" "};\n" "\n" "fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d tex [[ texture(0) ]])\n" "{\n" -" return vtf.color * tex.sample(samp, vtf.uv);\n" +" return vtf.color * tex.sample(samp, vtf.uv, level(vtf.lod));\n" "}\n"; URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) diff --git a/Runtime/GuiSys/CAuiImagePane.cpp b/Runtime/GuiSys/CAuiImagePane.cpp index 25289d13a..05b82cef4 100644 --- a/Runtime/GuiSys/CAuiImagePane.cpp +++ b/Runtime/GuiSys/CAuiImagePane.cpp @@ -1,5 +1,7 @@ #include "CAuiImagePane.hpp" #include "CSimplePool.hpp" +#include "Graphics/CTexture.hpp" +#include "CGuiWidgetDrawParms.hpp" namespace urde { @@ -34,6 +36,160 @@ std::shared_ptr CAuiImagePane::Create(CGuiFrame* frame, CInputStream return ret; } +void CAuiImagePane::Update(float dt) +{ + xd0_uvBias0.x = std::fmod(xd0_uvBias0.x, 1.f); + xd0_uvBias0.y = std::fmod(xd0_uvBias0.y, 1.f); + if (x138_tileSize != zeus::CVector2f::skZero && xb8_tex0Tok.IsLoaded()) + { + zeus::CVector2f tmp = zeus::CVector2f(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()) / x138_tileSize; + x144_frameTimer = std::fmod(x144_frameTimer + dt * x140_interval, std::floor(tmp.x) * std::floor(tmp.y)); + } + + CGuiWidget::Update(dt); +} + +CAuiImagePane::Filters::Filters(TLockedToken& tex) +: m_darkenerQuad(CCameraFilterPass::EFilterType::Blend, tex), + m_flashQuad{{CCameraFilterPass::EFilterType::Add, tex}, {CCameraFilterPass::EFilterType::Add, tex}}, + m_alphaQuad{{CCameraFilterPass::EFilterType::Blend, tex}, {CCameraFilterPass::EFilterType::Blend, tex}}, + m_addQuad{{CCameraFilterPass::EFilterType::Add, tex}, {CCameraFilterPass::EFilterType::Add, tex}} +{ +} + +void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, + int frame, float alpha, bool noBlur, CTexturedQuadFilterAlpha& quad) const +{ + zeus::CColor useColor = color; + useColor.a *= alpha; + + rstl::reserved_vector vec; + const rstl::reserved_vector* useUVs; + if (x138_tileSize != zeus::CVector2f::skZero) + { + zeus::CVector2f res(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()); + zeus::CVector2f tmp = res / x138_tileSize; + zeus::CVector2f tmpRecip = x138_tileSize / res; + float x0 = tmpRecip.x * (frame % int(tmp.x)); + float x1 = x0 + tmpRecip.x; + float y0 = tmpRecip.y * (frame % int(tmp.y)); + float y1 = y0 + tmpRecip.y; + vec.push_back(zeus::CVector2f(x0, y0)); + vec.push_back(zeus::CVector2f(x0, y1)); + vec.push_back(zeus::CVector2f(x1, y0)); + vec.push_back(zeus::CVector2f(x1, y1)); + useUVs = &vec; + } + else + { + useUVs = &x114_uvs; + } + + CTexturedQuadFilter::Vert verts[] = + { + {xe0_coords[0], (*useUVs)[0] + xd0_uvBias0}, + {xe0_coords[1], (*useUVs)[1] + xd0_uvBias0}, + {xe0_coords[2], (*useUVs)[2] + xd0_uvBias0}, + {xe0_coords[3], (*useUVs)[3] + xd0_uvBias0} + }; + + if (noBlur) + { + quad.drawVerts(useColor, verts); + } + else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumMips() == 1) + { + quad.drawVerts(useColor, verts, 0.f); + } + else + { + float tmp = (1.f - x14c_deResFactor) * alpha; + float tmp3 = 1.f - tmp * tmp * tmp; + float mip = tmp3 * (tex.GetNumMips() - 1); + quad.drawVerts(useColor, verts, mip); + } +} + +void CAuiImagePane::Draw(const CGuiWidgetDrawParms& params) const +{ + CGraphics::SetModelMatrix(x34_worldXF); + if (!GetIsVisible() || !xb8_tex0Tok.IsLoaded()) + return; + GetIsFinishedLoadingWidgetSpecific(); + if (!m_filters) + const_cast(this)->m_filters.emplace(const_cast(this)->xb8_tex0Tok); + Filters& filters = const_cast(*m_filters); + zeus::CColor color = xa8_color2; + color.a *= params.x0_alphaMod; + //SetZUpdate(xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque); + float blur0 = 1.f; + float blur1 = 0.f; + int frame0 = x144_frameTimer; + int frame1 = 0; + if (x140_interval < 1.f && x140_interval > 0.f) + { + zeus::CVector2f tmp = zeus::CVector2f(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()) / x138_tileSize; + frame1 = (frame0 + 1) % int(tmp.x * tmp.y); + if (x148_fadeDuration == 0.f) + blur1 = 1.f; + else + blur1 = std::min(std::fmod(x144_frameTimer, 1.f) / x148_fadeDuration, 1.f); + blur0 = 1.f - blur1; + } + + // Alpha blend + DoDrawImagePane(color * zeus::CColor(0.f, 0.5f), *xb8_tex0Tok, frame0, 1.f, true, filters.m_darkenerQuad); + + if (x150_flashFactor > 0.f) + { + // Additive blend + zeus::CColor color2 = xa8_color2; + color2.a = x150_flashFactor; + DoDrawImagePane(color2, *xb8_tex0Tok, frame0, blur0, false, filters.m_flashQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color2, *xb8_tex0Tok, frame1, blur1, false, filters.m_flashQuad[1]); + } + + switch (xac_drawFlags) + { + case EGuiModelDrawFlags::Shadeless: + case EGuiModelDrawFlags::Opaque: + // Opaque blend + DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]); + break; + case EGuiModelDrawFlags::Alpha: + // Alpha blend + DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]); + break; + case EGuiModelDrawFlags::Additive: + // Additive blend + DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_addQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_addQuad[1]); + break; + case EGuiModelDrawFlags::AlphaAdditiveOverdraw: + // Alpha blend + DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]); + // Full additive blend + DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_addQuad[0]); + if (blur1 > 0.f) + DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_addQuad[1]); + break; + default: break; + } +} + +bool CAuiImagePane::GetIsFinishedLoadingWidgetSpecific() const +{ + return xb8_tex0Tok.IsLoaded(); +} + void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp) { xc8_tex0 = tex; @@ -45,12 +201,12 @@ void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp) xb8_tex0Tok = TLockedToken(); } -void CAuiImagePane::SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration) +void CAuiImagePane::SetAnimationParms(const zeus::CVector2f& tileSize, float interval, float fadeDuration) { - x138_ = vec; + x138_tileSize = tileSize; x140_interval = interval; - x144_ = 0.f; - x148_duration = duration; + x144_frameTimer = 0.f; + x148_fadeDuration = fadeDuration; } } diff --git a/Runtime/GuiSys/CAuiImagePane.hpp b/Runtime/GuiSys/CAuiImagePane.hpp index c53f60175..f0e8978fe 100644 --- a/Runtime/GuiSys/CAuiImagePane.hpp +++ b/Runtime/GuiSys/CAuiImagePane.hpp @@ -3,6 +3,7 @@ #include "CGuiWidget.hpp" #include "CToken.hpp" +#include "Graphics/Shaders/CTexturedQuadFilter.hpp" namespace urde { @@ -14,16 +15,27 @@ class CAuiImagePane : public CGuiWidget TLockedToken xb8_tex0Tok; // Used to be optional ResId xc8_tex0; ResId xcc_tex1; - zeus::CVector2f xd0_; - zeus::CVector2f xd8_; + zeus::CVector2f xd0_uvBias0; + zeus::CVector2f xd8_uvBias1; rstl::reserved_vector xe0_coords; rstl::reserved_vector x114_uvs; - zeus::CVector2f x138_; + zeus::CVector2f x138_tileSize; float x140_interval = 0.f; - float x144_ = 0.f; - float x148_duration = 0.f; + float x144_frameTimer = 0.f; + float x148_fadeDuration = 0.f; float x14c_deResFactor = 0.f; - float x150_alpha = 0.f; + float x150_flashFactor = 0.f; + struct Filters + { + CTexturedQuadFilterAlpha m_darkenerQuad; + CTexturedQuadFilterAlpha m_flashQuad[2]; + CTexturedQuadFilterAlpha m_alphaQuad[2]; + CTexturedQuadFilterAlpha m_addQuad[2]; + Filters(TLockedToken& tex); + }; + std::experimental::optional m_filters; + void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, + int frame, float blurAmt, bool noBlur, CTexturedQuadFilterAlpha& quad) const; public: CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId, rstl::reserved_vector&& coords, @@ -31,10 +43,13 @@ public: FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); } static std::shared_ptr Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); + void Update(float dt); + void Draw(const CGuiWidgetDrawParms& params) const; + bool GetIsFinishedLoadingWidgetSpecific() const; void SetTextureID0(ResId tex, CSimplePool* sp); void SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration); void SetDeResFactor(float d) { x14c_deResFactor = d; } - void SetAlpha(float t) { x150_alpha = t; } + void SetFlashFactor(float t) { x150_flashFactor = t; } }; } diff --git a/Runtime/GuiSys/CScanDisplay.cpp b/Runtime/GuiSys/CScanDisplay.cpp index 0e81eb796..db48ae44b 100644 --- a/Runtime/GuiSys/CScanDisplay.cpp +++ b/Runtime/GuiSys/CScanDisplay.cpp @@ -79,6 +79,8 @@ CScanDisplay::CScanDisplay(const CGuiFrame& selHud) : xa0_selHud(selHud) { x0_dataDot = g_SimplePool->GetObj("TXTR_DataDot"); + for (int i=0 ; i<4 ; ++i) + xbc_dataDots.emplace_back(x0_dataDot); } void CScanDisplay::ProcessInput(const CFinalInput& input) @@ -242,7 +244,7 @@ void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo, bucket.x14_interval, bucket.x18_fadeDuration); } state.second->SetTextureID0(bucket.x0_texture, g_SimplePool); - state.second->SetAlpha(0.f); + state.second->SetFlashFactor(0.f); if (scanTime >= GetDownloadStartTime(i)) x170_paneStates[i].first = 0.f; else @@ -301,12 +303,7 @@ void CScanDisplay::SetScanMessageTypeEffect(CGuiTextPane* pane, bool type) void CScanDisplay::Update(float dt, float scanningTime) { if (xc_state == EScanState::Inactive) - { - x0_dataDot.Unlock(); return; - } - - x0_dataDot.Lock(); bool active = false; if (xc_state == EScanState::Done) @@ -379,7 +376,7 @@ void CScanDisplay::Update(float dt, float scanningTime) tmp = 1.f - (x170_paneStates[i].first - g_tweakGui->GetScanPaneFadeOutTime()) / g_tweakGui->GetScanPaneFadeInTime(); else tmp = x170_paneStates[i].first / g_tweakGui->GetScanPaneFadeOutTime(); - x170_paneStates[i].second->SetAlpha(tmp * g_tweakGui->GetScanPaneFadeAlpha() * x1a8_bodyAlpha); + x170_paneStates[i].second->SetFlashFactor(tmp * g_tweakGui->GetScanPaneFlashFactor() * x1a8_bodyAlpha); } float alphaMul = ((xc_state == EScanState::Downloading) ? GetDownloadFraction(i, scanningTime) : 1.f) * x1a8_bodyAlpha; zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor(); @@ -426,8 +423,8 @@ void CScanDisplay::Update(float dt, float scanningTime) if (tmp == 0.f) { float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude(); - float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Min() : g_tweakGui->GetScanDataDotDuration1Min(); - float durMax = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Max() : g_tweakGui->GetScanDataDotDuration1Max(); + float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMin() : g_tweakGui->GetScanDataDotSeekDurationMin(); + float durMax = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMax() : g_tweakGui->GetScanDataDotSeekDurationMax(); zeus::CVector2f vec(dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().x : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand), dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().y : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand)); dot.StartTransitionTo(vec, (durMax - durMin) * (rand() / float(RAND_MAX)) + durMin); diff --git a/Runtime/MP1/CLogBookScreen.cpp b/Runtime/MP1/CLogBookScreen.cpp index 7750799ab..abf761cf4 100644 --- a/Runtime/MP1/CLogBookScreen.cpp +++ b/Runtime/MP1/CLogBookScreen.cpp @@ -244,7 +244,7 @@ void CLogBookScreen::UpdateBodyImagesAndText() bucket.x14_interval, bucket.x18_fadeDuration); } pane->SetTextureID0(bucket.x0_texture, g_SimplePool); - pane->SetAlpha(0.f); + pane->SetFlashFactor(0.f); } x260_26_exitTextScroll = false;