From 83176b41a971631a7dc1af393eb9b3ce96333eca Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 29 Jan 2017 18:16:20 -1000 Subject: [PATCH] FRME bug fixes and shader adjustments --- DataSpec/DNAMP1/FRME.cpp | 8 +- DataSpec/DNAMP1/FRME.hpp | 2 +- Runtime/Graphics/CGraphics.cpp | 3 + .../Graphics/Shaders/CModelShadersGLSL.cpp | 20 ++++- .../Graphics/Shaders/CModelShadersHLSL.cpp | 20 ++++- .../Graphics/Shaders/CModelShadersMetal.cpp | 20 ++++- .../Graphics/Shaders/CTextSupportShader.hpp | 1 + .../Shaders/CTextSupportShaderGLSL.cpp | 25 +++--- .../Shaders/CTextSupportShaderHLSL.cpp | 17 ++-- .../Shaders/CTextSupportShaderMetal.cpp | 25 +++--- Runtime/GuiSys/CFontImageDef.cpp | 14 ++++ Runtime/GuiSys/CFontImageDef.hpp | 2 + Runtime/GuiSys/CFontRenderState.cpp | 24 +++--- Runtime/GuiSys/CGuiCamera.cpp | 3 +- Runtime/GuiSys/CGuiFrame.cpp | 14 +++- Runtime/GuiSys/CGuiFrame.hpp | 7 ++ Runtime/GuiSys/CGuiModel.cpp | 6 ++ Runtime/GuiSys/CGuiObject.cpp | 2 + Runtime/GuiSys/CGuiPane.cpp | 20 ++--- Runtime/GuiSys/CGuiPane.hpp | 4 +- Runtime/GuiSys/CGuiSys.cpp | 27 +++++++ Runtime/GuiSys/CGuiSys.hpp | 4 + Runtime/GuiSys/CGuiTextPane.cpp | 8 +- Runtime/GuiSys/CGuiTextSupport.cpp | 34 +++++++- Runtime/GuiSys/CGuiTextSupport.hpp | 17 ++-- Runtime/GuiSys/CGuiWidget.hpp | 2 + Runtime/GuiSys/CInstruction.cpp | 78 +++++++++++++------ Runtime/GuiSys/CInstruction.hpp | 38 +++++++-- Runtime/GuiSys/CRasterFont.cpp | 11 ++- Runtime/GuiSys/CRasterFont.hpp | 2 + Runtime/GuiSys/CSaveableState.cpp | 8 ++ Runtime/GuiSys/CSaveableState.hpp | 6 +- Runtime/GuiSys/CTextExecuteBuffer.cpp | 51 ++++++------ Runtime/GuiSys/CTextExecuteBuffer.hpp | 6 +- Runtime/GuiSys/CTextRenderBuffer.cpp | 7 +- Runtime/MP1/CFrontEndUI.cpp | 61 ++++++++------- Runtime/MP1/CSaveUI.cpp | 1 + Runtime/World/CWorldTransManager.cpp | 3 +- hecl | 2 +- 39 files changed, 424 insertions(+), 179 deletions(-) diff --git a/DataSpec/DNAMP1/FRME.cpp b/DataSpec/DNAMP1/FRME.cpp index 492cbb675..66a8ffafc 100644 --- a/DataSpec/DNAMP1/FRME.cpp +++ b/DataSpec/DNAMP1/FRME.cpp @@ -243,7 +243,7 @@ void FRME::Widget::TXPNInfo::read(athena::io::IStreamReader& __dna_reader) /* unk1 */ wordWrap = __dna_reader.readBool(); /* unk2 */ - vertical = __dna_reader.readBool(); + horizontal = __dna_reader.readBool(); /* justification */ justification = Justification(__dna_reader.readUint32Big()); /* verticalJustification */ @@ -279,7 +279,7 @@ void FRME::Widget::TXPNInfo::write(athena::io::IStreamWriter& __dna_writer) cons /* unk1 */ __dna_writer.writeBool(wordWrap); /* unk2 */ - __dna_writer.writeBool(vertical); + __dna_writer.writeBool(horizontal); /* justification */ __dna_writer.writeUint32Big(atUint32(justification)); /* verticalJustification */ @@ -608,7 +608,7 @@ bool FRME::Extract(const SpecBase &dataSpec, "frme_obj.retro_pane_scale_center = (%f,%f,%f)\n" "frme_obj.retro_textpane_font_path = '%s'\n" "frme_obj.retro_textpane_word_wrap = %s\n" - "frme_obj.retro_textpane_vertical = %s\n" + "frme_obj.retro_textpane_horizontal = %s\n" "frme_obj.retro_textpane_fill_color = (%f,%f,%f,%f)\n" "frme_obj.retro_textpane_outline_color = (%f,%f,%f,%f)\n" "frme_obj.retro_textpane_block_extent = (%f,%f)\n" @@ -622,7 +622,7 @@ bool FRME::Extract(const SpecBase &dataSpec, info->scaleCenter.vec[2], fontPath.getRelativePathUTF8().c_str(), info->wordWrap ? "True" : "False", - info->vertical ? "True" : "False", + info->horizontal ? "True" : "False", info->fillColor.vec[0], info->fillColor.vec[1], info->fillColor.vec[2], diff --git a/DataSpec/DNAMP1/FRME.hpp b/DataSpec/DNAMP1/FRME.hpp index e85f3e000..c71f70400 100644 --- a/DataSpec/DNAMP1/FRME.hpp +++ b/DataSpec/DNAMP1/FRME.hpp @@ -264,7 +264,7 @@ struct FRME : BigDNA Value scaleCenter; UniqueID32 font; Value wordWrap; - Value vertical; + Value horizontal; Value justification; Value verticalJustification; Value fillColor; diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index a812f9a4d..e8fbc0dbe 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -3,6 +3,7 @@ #include "zeus/Math.hpp" #include "CTimeProvider.hpp" #include "Shaders/CTextSupportShader.hpp" +#include "GuiSys/CGuiSys.hpp" namespace urde { @@ -456,6 +457,8 @@ void CGraphics::SetViewportResolution(const zeus::CVector2i& res) g_CroppedViewport.xc_width = res.x; g_CroppedViewport.x10_height = res.y; g_ViewportResolutionHalf = {res.x / 2, res.y / 2}; + if (g_GuiSys) + g_GuiSys->OnViewportResize(); } static boo::SWindowRect CachedVP; diff --git a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp index 044fd81fa..9f03d7ddc 100644 --- a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp @@ -85,12 +85,24 @@ CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat) hecl::Runtime::ShaderCacheExtensions ext(plat); /* Normal lit shading */ - ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, 3, BlockNames, 0, nullptr, - hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original); + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, + 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, + hecl::Backend::BlendFactor::Original); /* Thermal Visor shading */ - ext.registerExtensionSlot({}, {ThermalPostGLSL, "ThermalPostFunc"}, 3, ThermalBlockNames, 1, ThermalTextures, - hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One); + ext.registerExtensionSlot({}, {ThermalPostGLSL, "ThermalPostFunc"}, 3, ThermalBlockNames, + 1, ThermalTextures, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); + + /* Forced alpha shading */ + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, + 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha); + + /* Forced additive shading */ + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, + 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); return ext; } diff --git a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp index 2cb8f4ba1..c7a7f8e5c 100644 --- a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp @@ -76,12 +76,24 @@ CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat) hecl::Runtime::ShaderCacheExtensions ext(plat); /* Normal lit shading */ - ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, 0, nullptr, 0, nullptr, - hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original); + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::Original, + hecl::Backend::BlendFactor::Original); /* Thermal Visor shading */ - ext.registerExtensionSlot({}, {ThermalPostHLSL, "ThermalPostFunc"}, 0, nullptr, 1, ThermalTextures, - hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One); + ext.registerExtensionSlot({}, {ThermalPostMetal, "ThermalPostFunc"}, 0, nullptr, + 1, ThermalTextures, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); + + /* Forced alpha shading */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha); + + /* Forced additive shading */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); return ext; } diff --git a/Runtime/Graphics/Shaders/CModelShadersMetal.cpp b/Runtime/Graphics/Shaders/CModelShadersMetal.cpp index ee74a0b01..766f874b1 100644 --- a/Runtime/Graphics/Shaders/CModelShadersMetal.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersMetal.cpp @@ -79,12 +79,24 @@ CModelShaders::GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat hecl::Runtime::ShaderCacheExtensions ext(plat); /* Normal lit shading */ - ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, 1, BlockNames, 0, nullptr, - hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original); + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, + hecl::Backend::BlendFactor::Original); /* Thermal Visor shading */ - ext.registerExtensionSlot({}, {ThermalPostMetal, "ThermalPostFunc"}, 1, ThermalBlockNames, 1, ThermalTextures, - hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One); + ext.registerExtensionSlot({}, {ThermalPostMetal, "ThermalPostFunc"}, 1, ThermalBlockNames, + 1, ThermalTextures, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); + + /* Forced alpha shading */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha); + + /* Forced additive shading */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, + hecl::Backend::BlendFactor::One); return ext; } diff --git a/Runtime/Graphics/Shaders/CTextSupportShader.hpp b/Runtime/Graphics/Shaders/CTextSupportShader.hpp index 26a612f41..e49a84f69 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShader.hpp +++ b/Runtime/Graphics/Shaders/CTextSupportShader.hpp @@ -39,6 +39,7 @@ class CTextSupportShader zeus::CVector3f m_uv[4]; zeus::CColor m_fontColor; zeus::CColor m_outlineColor; + zeus::CColor m_mulColor; void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset); }; diff --git a/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp index 84bc22c53..fbfe42769 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp @@ -13,6 +13,7 @@ BOO_GLSL_BINDING_HEAD "layout(location=4) in vec4 uvIn[4];\n" "layout(location=8) in vec4 fontColorIn;\n" "layout(location=9) in vec4 outlineColorIn;\n" +"layout(location=10) in vec4 mulColorIn;\n" "\n" "UBINDING0 uniform TextSupportUniform\n" "{\n" @@ -24,6 +25,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vec4 fontColor;\n" " vec4 outlineColor;\n" +" vec4 mulColor;\n" " vec3 uv;\n" "};\n" "\n" @@ -32,6 +34,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vtf.fontColor = color * fontColorIn;\n" " vtf.outlineColor = color * outlineColorIn;\n" +" vtf.mulColor = mulColorIn;\n" " vtf.uv = uvIn[gl_VertexID].xyz;\n" " gl_Position = mtx * vec4(posIn[gl_VertexID].xyz, 1.0);\n" " gl_Position = FLIPFROMGL(gl_Position);\n" @@ -44,6 +47,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vec4 fontColor;\n" " vec4 outlineColor;\n" +" vec4 mulColor;\n" " vec3 uv;\n" "};\n" "\n" @@ -53,7 +57,7 @@ BOO_GLSL_BINDING_HEAD "void main()\n" "{\n" " vec4 texel = texture(tex, vtf.uv);\n" -" colorOut = vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n" +" colorOut = (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;\n" "}\n"; static const char* ImgVS = @@ -109,14 +113,14 @@ CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx) const char* uniNames[] = {"TextSupportUniform"}; s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); return nullptr; } @@ -137,12 +141,13 @@ CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx) {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2}, }; - s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt); + s_TextVtxFmt = ctx.newVertexFormat(11, TextVtxVmt); s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); boo::VertexElementDescriptor ImageVtxVmt[] = { @@ -158,9 +163,9 @@ CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx) }; s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt); s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); return nullptr; } diff --git a/Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp index 9fd4bc93f..3781bfde4 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp +++ b/Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp @@ -13,6 +13,7 @@ static const char* TextVS = " float4 uvIn[4] : UV;\n" " float4 fontColorIn : COLOR0;\n" " float4 outlineColorIn : COLOR1;\n" +" float4 mulColorIn : COLOR2;\n" "};\n" "\n" "cbuffer TextSupportUniform : register(b0)\n" @@ -26,6 +27,7 @@ static const char* TextVS = " float4 pos : SV_Position;\n" " float4 fontColor : COLOR0;\n" " float4 outlineColor : COLOR1;\n" +" float4 mulColor : COLOR2;\n" " float3 uv : UV;\n" "};\n" "\n" @@ -34,6 +36,7 @@ static const char* TextVS = " VertToFrag vtf;\n" " vtf.fontColor = color * inst.fontColorIn;\n" " vtf.outlineColor = color * inst.outlineColorIn;\n" +" vtf.mulColor = inst.mulColorIn;\n" " vtf.uv = inst.uvIn[vertId].xyz;\n" " vtf.pos = mul(mtx, float4(inst.posIn[vertId].xyz, 1.0));\n" " return vtf;\n" @@ -45,6 +48,7 @@ static const char* TextFS = " float4 pos : SV_Position;\n" " float4 fontColor : COLOR0;\n" " float4 outlineColor : COLOR1;\n" +" float4 mulColor : COLOR2;\n" " float3 uv : UV;\n" "};\n" "\n" @@ -54,7 +58,7 @@ static const char* TextFS = "float4 main(in VertToFrag vtf) : SV_Target0\n" "{\n" " float4 texel = tex.Sample(samp, vtf.uv.xyz);\n" -" return vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n" +" return (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;\n" "}\n"; static const char* ImgVS = @@ -119,14 +123,15 @@ CTextSupportShader::Initialize(boo::ID3DDataFactory::Context& ctx) {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2}, }; - s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt); + s_TextVtxFmt = ctx.newVertexFormat(11, TextVtxVmt); s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, ComPtr(), ComPtr(), ComPtr(), s_TextVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, ComPtr(), ComPtr(), ComPtr(), s_TextVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); boo::VertexElementDescriptor ImageVtxVmt[] = { @@ -143,10 +148,10 @@ CTextSupportShader::Initialize(boo::ID3DDataFactory::Context& ctx) s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt); s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, ComPtr(), ComPtr(), ComPtr(), s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, ComPtr(), ComPtr(), ComPtr(), s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); return nullptr; } diff --git a/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp index 34ea0d032..f92f2c623 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp +++ b/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp @@ -15,6 +15,7 @@ static const char* TextVS = " float4 uvIn[4];\n" " float4 fontColorIn;\n" " float4 outlineColorIn;\n" +" float4 mulColorIn;\n" "};\n" "\n" "struct TextSupportUniform\n" @@ -28,6 +29,7 @@ static const char* TextVS = " float4 pos [[ position ]];\n" " float4 fontColor;\n" " float4 outlineColor;\n" +" float4 mulColor;\n" " float3 uv;\n" "};\n" "\n" @@ -37,8 +39,9 @@ static const char* TextVS = "{\n" " VertToFrag vtf;\n" " constant InstData& inst = instArr[instId];\n" -" vtf.fontColor = uData.color * inst.fontColorIn;\n" -" vtf.outlineColor = uData.color * inst.outlineColorIn;\n" +" vtf.fontColor = inst.fontColorIn * uData.color;\n" +" vtf.outlineColor = inst.outlineColorIn * uData.color;\n" +" vtf.mulColor = inst.mulColorIn;\n" " vtf.uv = inst.uvIn[vertId].xyz;\n" " vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);\n" " return vtf;\n" @@ -47,12 +50,13 @@ static const char* TextVS = static const char* TextFS = "#include \n" "using namespace metal;\n" -"constexpr sampler samp(address::repeat);\n" +"constexpr sampler samp(address::repeat, filter::linear);\n" "struct VertToFrag\n" "{\n" " float4 pos [[ position ]];\n" " float4 fontColor;\n" " float4 outlineColor;\n" +" float4 mulColor;\n" " float3 uv;\n" "};\n" "\n" @@ -60,7 +64,7 @@ static const char* TextFS = " texture2d_array tex [[ texture(0) ]])\n" "{\n" " float4 texel = tex.sample(samp, vtf.uv.xy, vtf.uv.z);\n" -" return vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n" +" return (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;\n" "}\n"; static const char* ImgVS = @@ -101,7 +105,7 @@ static const char* ImgVS = static const char* ImgFS = "#include \n" "using namespace metal;\n" -"constexpr sampler samp(address::repeat);\n" +"constexpr sampler samp(address::repeat, filter::linear);\n" "struct VertToFrag\n" "{\n" " float4 pos [[ position ]];\n" @@ -131,12 +135,13 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx) {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2}, }; - s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt); + s_TextVtxFmt = ctx.newVertexFormat(11, TextVtxVmt); s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); boo::VertexElementDescriptor ImageVtxVmt[] = { @@ -152,9 +157,9 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx) }; s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt); s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, true, false, false); s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + boo::BlendFactor::One, boo::Primitive::TriStrips, true, false, false); return nullptr; } diff --git a/Runtime/GuiSys/CFontImageDef.cpp b/Runtime/GuiSys/CFontImageDef.cpp index 99bbc47c8..179a649c2 100644 --- a/Runtime/GuiSys/CFontImageDef.cpp +++ b/Runtime/GuiSys/CFontImageDef.cpp @@ -1,4 +1,5 @@ #include "CFontImageDef.hpp" +#include "Graphics/CTexture.hpp" namespace urde { @@ -26,4 +27,17 @@ bool CFontImageDef::IsLoaded() const return true; } +s32 CFontImageDef::CalculateBaseline() const +{ + const CTexture* tex = x4_texs.front().GetObj(); + return s32(tex->GetHeight() * x14_pointsPerTexel.y) * 2.5f / 3.f; +} + +s32 CFontImageDef::CalculateHeight() const +{ + const CTexture* tex = x4_texs.front().GetObj(); + s32 scaledH = tex->GetHeight() * x14_pointsPerTexel.y; + return scaledH - (scaledH - CalculateBaseline()); +} + } diff --git a/Runtime/GuiSys/CFontImageDef.hpp b/Runtime/GuiSys/CFontImageDef.hpp index 9186a81e9..323e1d250 100644 --- a/Runtime/GuiSys/CFontImageDef.hpp +++ b/Runtime/GuiSys/CFontImageDef.hpp @@ -20,6 +20,8 @@ public: const zeus::CVector2f& vec); CFontImageDef(const TToken& tex, const zeus::CVector2f& vec); bool IsLoaded() const; + s32 CalculateBaseline() const; + s32 CalculateHeight() const; }; } diff --git a/Runtime/GuiSys/CFontRenderState.cpp b/Runtime/GuiSys/CFontRenderState.cpp index 601f61ea7..925450d48 100644 --- a/Runtime/GuiSys/CFontRenderState.cpp +++ b/Runtime/GuiSys/CFontRenderState.cpp @@ -6,9 +6,9 @@ namespace urde CFontRenderState::CFontRenderState() { - x54_[0] = zeus::CColor::skWhite; - x54_[1] = zeus::CColor::skGrey; - x54_[2] = zeus::CColor::skWhite; + x54_colors[0] = zeus::CColor::skWhite; + x54_colors[1] = zeus::CColor::skGrey; + x54_colors[2] = zeus::CColor::skWhite; RefreshPalette(); } @@ -36,13 +36,13 @@ void CFontRenderState::SetColor(EColorType tp, const CTextColor& col) case EColorType::Main: case EColorType::Outline: case EColorType::Geometry: - x54_[int(tp)] = col; + x54_colors[int(tp)] = col; break; case EColorType::Foreground: - x54_[0] = col; + x54_colors[0] = col; break; case EColorType::Background: - x54_[1] = col; + x54_colors[1] = col; break; } RefreshColor(tp); @@ -61,15 +61,15 @@ void CFontRenderState::RefreshColor(EColorType tp) case EColorType::Main: if (!x48_font) return; - switch (x48_font.GetObj()->GetMode()) + switch (x48_font->GetMode()) { case EColorType::Main: if (!x64_colorOverrides[0]) - x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_[0]); + x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_colors[0]); break; case EColorType::Outline: if (!x64_colorOverrides[0]) - x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_[0]); + x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_colors[0]); break; default: break; } @@ -79,12 +79,12 @@ void CFontRenderState::RefreshColor(EColorType tp) return; if (x64_colorOverrides[1]) return; - if (x48_font.GetObj()->GetMode() == EColorType::Outline) - x0_drawStrOpts.x4_colors[1] = ConvertToTextureSpace(x54_[1]); + if (x48_font->GetMode() == EColorType::Outline) + x0_drawStrOpts.x4_colors[1] = ConvertToTextureSpace(x54_colors[1]); break; case EColorType::Geometry: if (!x64_colorOverrides[2]) - x0_drawStrOpts.x4_colors[2] = ConvertToTextureSpace(x54_[2]); + x0_drawStrOpts.x4_colors[2] = ConvertToTextureSpace(x54_colors[2]); break; case EColorType::Foreground: RefreshColor(EColorType::Main); diff --git a/Runtime/GuiSys/CGuiCamera.cpp b/Runtime/GuiSys/CGuiCamera.cpp index c12626db0..998039410 100644 --- a/Runtime/GuiSys/CGuiCamera.cpp +++ b/Runtime/GuiSys/CGuiCamera.cpp @@ -42,7 +42,8 @@ void CGuiCamera::Draw(const CGuiWidgetDrawParms& parms) const CGraphics::SetPerspective(xfc_fov, x100_aspect, x104_znear, x108_zfar); else CGraphics::SetOrtho(xfc_left, x100_right, x104_top, x108_bottom, x10c_znear, x110_zfar); - CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(parms.x4_cameraOffset) * x34_worldXF); + CGraphics::SetViewPointMatrix(GetGuiFrame()->GetAspectTransform() * + zeus::CTransform::Translate(parms.x4_cameraOffset) * x34_worldXF); CGuiWidget::Draw(parms); } diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index 421dde89b..e3210182f 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -20,6 +20,12 @@ CGuiFrame::CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* s CGuiWidget::CGuiWidgetParms(this, false, 0, 0, false, false, false, zeus::CColor::skWhite, CGuiWidget::EGuiModelDrawFlags::Alpha, false, x8_guiSys.x8_mode != CGuiSys::EUsageMode::Zero))); + x8_guiSys.m_registeredFrames.insert(this); +} + +CGuiFrame::~CGuiFrame() +{ + x8_guiSys.m_registeredFrames.erase(this); } CGuiWidget* CGuiFrame::FindWidget(const std::string& name) const @@ -40,7 +46,7 @@ void CGuiFrame::SortDrawOrder() std::sort(x2c_widgets.begin(), x2c_widgets.end(), [](const std::shared_ptr& a, const std::shared_ptr& b) -> bool { - return a->GetWorldPosition().y < b->GetWorldPosition().y; + return a->GetWorldPosition().y > b->GetWorldPosition().y; }); } @@ -103,6 +109,12 @@ void CGuiFrame::Touch() const widget->Touch(); } +void CGuiFrame::SetAspectConstraint(float c) +{ + m_aspectConstraint = c; + CGuiSys::ViewportResizeFrame(this); +} + void CGuiFrame::Update(float dt) { xc_headWidget->Update(dt); diff --git a/Runtime/GuiSys/CGuiFrame.hpp b/Runtime/GuiSys/CGuiFrame.hpp index 3fc66e458..6dc43fc85 100644 --- a/Runtime/GuiSys/CGuiFrame.hpp +++ b/Runtime/GuiSys/CGuiFrame.hpp @@ -19,6 +19,7 @@ class CSimplePool; class CGuiFrame { + friend class CGuiSys; private: ResId x0_id; u32 x4_ = 0; @@ -34,8 +35,12 @@ private: int x54_c; bool x58_24_loaded : 1; + zeus::CTransform m_aspectTransform; + float m_aspectConstraint = -1.f; + public: CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp); + ~CGuiFrame(); CGuiSys& GetGuiSys() {return x8_guiSys;} @@ -52,6 +57,8 @@ public: void AddLight(std::shared_ptr&& light); bool GetIsFinishedLoading() const; void Touch() const; + const zeus::CTransform& GetAspectTransform() const { return m_aspectTransform; } + void SetAspectConstraint(float c); void Update(float dt); void Draw(const CGuiWidgetDrawParms& parms) const; diff --git a/Runtime/GuiSys/CGuiModel.cpp b/Runtime/GuiSys/CGuiModel.cpp index eb2777b13..e0e9d563b 100644 --- a/Runtime/GuiSys/CGuiModel.cpp +++ b/Runtime/GuiSys/CGuiModel.cpp @@ -65,36 +65,42 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const case EGuiModelDrawFlags::Shadeless: { CModelFlags flags(0, 0, 3, zeus::CColor::skWhite); + flags.m_extendedShaderIdx = 0; model->Draw(flags); break; } case EGuiModelDrawFlags::Opaque: { CModelFlags flags(1, 0, 3, moduCol); + flags.m_extendedShaderIdx = 1; model->Draw(flags); break; } case EGuiModelDrawFlags::Alpha: { CModelFlags flags(4, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol); + flags.m_extendedShaderIdx = 3; model->Draw(flags); break; } case EGuiModelDrawFlags::Additive: { CModelFlags flags(3, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol); + flags.m_extendedShaderIdx = 4; model->Draw(flags); break; } case EGuiModelDrawFlags::AlphaAdditiveOverdraw: { CModelFlags flags(4, 0, xb6_31_depthTest, moduCol); + flags.m_extendedShaderIdx = 3; model->Draw(flags); flags.m_blendMode = 5; flags.m_matSetIdx = 0; flags.m_flags = (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest); flags.color = moduCol; + flags.m_extendedShaderIdx = 4; model->Draw(flags); break; } diff --git a/Runtime/GuiSys/CGuiObject.cpp b/Runtime/GuiSys/CGuiObject.cpp index 112cb7875..04fcfbe7d 100644 --- a/Runtime/GuiSys/CGuiObject.cpp +++ b/Runtime/GuiSys/CGuiObject.cpp @@ -1,6 +1,8 @@ #include "CGuiObject.hpp" #include "CGuiWidgetDrawParms.hpp" #include "Graphics/CTexture.hpp" +#include "CGuiWidget.hpp" +#include "CGuiFrame.hpp" namespace urde { diff --git a/Runtime/GuiSys/CGuiPane.cpp b/Runtime/GuiSys/CGuiPane.cpp index 4755d5b9c..48d8e997a 100644 --- a/Runtime/GuiSys/CGuiPane.cpp +++ b/Runtime/GuiSys/CGuiPane.cpp @@ -5,7 +5,7 @@ namespace urde CGuiPane::CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter) -: CGuiWidget(parms), xb8_dim(dim), x108_scaleCenter(scaleCenter) +: CGuiWidget(parms), xb8_dim(dim), xc8_scaleCenter(scaleCenter) { InitializeBuffers(); } @@ -14,11 +14,11 @@ void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale) { InitializeBuffers(); - for (specter::View::TexShaderVert& v : x100_verts) + for (specter::View::TexShaderVert& v : xc0_verts) { - v.m_pos -= x108_scaleCenter; + v.m_pos -= xc8_scaleCenter; v.m_pos *= scale; - v.m_pos += x108_scaleCenter; + v.m_pos += xc8_scaleCenter; } } @@ -36,13 +36,13 @@ zeus::CVector2f CGuiPane::GetDimensions() const void CGuiPane::InitializeBuffers() { - if (x100_verts.size() < 4) - x100_verts.resize(4); + if (xc0_verts.size() < 4) + xc0_verts.resize(4); - x100_verts[0].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f); - x100_verts[1].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f); - x100_verts[2].m_pos.assign(xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f); - x100_verts[3].m_pos.assign(xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f); + xc0_verts[0].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f); + xc0_verts[1].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f); + xc0_verts[2].m_pos.assign(xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f); + xc0_verts[3].m_pos.assign(xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f); } void CGuiPane::WriteData(COutputStream& out, bool flag) const diff --git a/Runtime/GuiSys/CGuiPane.hpp b/Runtime/GuiSys/CGuiPane.hpp index 28cf658ff..c64e0703b 100644 --- a/Runtime/GuiSys/CGuiPane.hpp +++ b/Runtime/GuiSys/CGuiPane.hpp @@ -13,10 +13,10 @@ protected: zeus::CVector2f xb8_dim; /* Originally a vert-buffer pointer for GX */ - std::vector x100_verts; + std::vector xc0_verts; // u32 x104_ = 4; /* vert count */ - zeus::CVector3f x108_scaleCenter; + zeus::CVector3f xc8_scaleCenter; public: CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter); diff --git a/Runtime/GuiSys/CGuiSys.cpp b/Runtime/GuiSys/CGuiSys.cpp index 916986204..03e078236 100644 --- a/Runtime/GuiSys/CGuiSys.cpp +++ b/Runtime/GuiSys/CGuiSys.cpp @@ -15,6 +15,7 @@ #include "CTextParser.hpp" #include "CSimplePool.hpp" #include "CTextExecuteBuffer.hpp" +#include "CGuiFrame.hpp" namespace urde { @@ -68,4 +69,30 @@ CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode) g_TextParser = x10_textParser.get(); } +void CGuiSys::OnViewportResize() +{ + for (CGuiFrame* frame : m_registeredFrames) + ViewportResizeFrame(frame); +} + +void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) +{ + float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y); + if (frame->m_aspectConstraint > 0.f) + { + float hPad, vPad; + if (vpAspectRatio >= frame->m_aspectConstraint) + { + hPad = frame->m_aspectConstraint / vpAspectRatio; + vPad = frame->m_aspectConstraint / 1.36f; + } + else + { + hPad = 1.f; + vPad = vpAspectRatio / 1.36f; + } + frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad}); + } +} + } diff --git a/Runtime/GuiSys/CGuiSys.hpp b/Runtime/GuiSys/CGuiSys.hpp index 5ba330d65..1677bb624 100644 --- a/Runtime/GuiSys/CGuiSys.hpp +++ b/Runtime/GuiSys/CGuiSys.hpp @@ -36,6 +36,7 @@ private: EUsageMode x8_mode; std::unique_ptr xc_textExecuteBuf; std::unique_ptr x10_textParser; + std::unordered_set m_registeredFrames; static std::shared_ptr CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame, CSimplePool* sp); @@ -44,6 +45,9 @@ public: CSimplePool& GetResStore() {return x4_resStore;} EUsageMode GetUsageMode() const {return x8_mode;} + + void OnViewportResize(); + static void ViewportResizeFrame(CGuiFrame* frame); }; /** Global GuiSys instance */ diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index 4f0b639cf..9be62ce19 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -56,7 +56,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const dims.y = 0.f; zeus::CTransform local = - zeus::CTransform::Translate(x100_verts.front().m_pos + x108_scaleCenter) * + zeus::CTransform::Translate(xc0_verts.front().m_pos + xc8_scaleCenter) * zeus::CTransform::Scale(dims.x, 1.f, dims.y); CGraphics::SetModelMatrix(x34_worldXF * local); @@ -108,10 +108,10 @@ std::shared_ptr CGuiTextPane::Create(CGuiFrame* frame, CInputStream& zeus::CVector3f vec = zeus::CVector3f::ReadBig(in); u32 fontId = in.readUint32Big(); bool wordWrap = in.readBool(); - bool vertical = in.readBool(); + bool horizontal = in.readBool(); EJustification justification = EJustification(in.readUint32Big()); EVerticalJustification vJustification = EVerticalJustification(in.readUint32Big()); - CGuiTextProperties props(wordWrap, vertical, justification, vJustification, ETextDirection::Horizontal); + CGuiTextProperties props(wordWrap, horizontal, justification, vJustification); zeus::CColor fontCol; fontCol.readRGBABig(in); zeus::CColor outlineCol; @@ -123,7 +123,7 @@ std::shared_ptr CGuiTextPane::Create(CGuiFrame* frame, CInputStream& fontCol, outlineCol, extentX, extentY); ret->ParseBaseInfo(frame, in, parms); ret->InitializeBuffers(); - ret->TextSupport()->SetText(u"?\?(?\?)"); + ret->TextSupport()->SetText(u""); return ret; } diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 28d27d52c..87e7022a5 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -142,7 +142,8 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer() { g_TextExecuteBuf->Clear(); g_TextExecuteBuf->x18_textState.x7c_enableWordWrap = x14_props.x0_wordWrap; - g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, x14_props.xc_direction, + g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, x30_imageBaseline, + ETextDirection(!x14_props.x1_horizontal), x14_props.x4_justification, x14_props.x8_vertJustification); g_TextExecuteBuf->AddColor(EColorType::Main, x24_fontColor); g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor); @@ -272,7 +273,36 @@ bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() const if (!tok.IsLoaded()) return false; } - return x2cc_font.IsLoaded(); + if (x2cc_font.IsLoaded()) + return x2cc_font->IsFinishedLoading(); + return false; +} + +void CGuiTextSupport::SetJustification(EJustification j) +{ + if (j != x14_props.x4_justification) + { + x14_props.x4_justification = j; + ClearRenderBuffer(); + } +} + +void CGuiTextSupport::SetVerticalJustification(EVerticalJustification j) +{ + if (j != x14_props.x8_vertJustification) + { + x14_props.x8_vertJustification = j; + ClearRenderBuffer(); + } +} + +void CGuiTextSupport::SetImageBaseline(bool b) +{ + if (b != x30_imageBaseline) + { + x30_imageBaseline = b; + ClearRenderBuffer(); + } } bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index fa62ea722..5ec785554 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -63,16 +63,15 @@ class CGuiTextProperties { friend class CGuiTextSupport; bool x0_wordWrap; - bool x1_multiline; + bool x1_horizontal; EJustification x4_justification; EVerticalJustification x8_vertJustification; - ETextDirection xc_direction; + u32 xc_; public: - CGuiTextProperties(bool wordWrap, bool multiline, EJustification justification, - EVerticalJustification vertJustification, - ETextDirection dir=ETextDirection::Horizontal) - : x0_wordWrap(wordWrap), x1_multiline(multiline), x4_justification(justification), - x8_vertJustification(vertJustification), xc_direction(dir) {} + CGuiTextProperties(bool wordWrap, bool horizontal, EJustification justification, + EVerticalJustification vertJustification, u32 unk=0) + : x0_wordWrap(wordWrap), x1_horizontal(horizontal), x4_justification(justification), + x8_vertJustification(vertJustification), xc_(unk) {} }; class CGuiTextSupport @@ -84,6 +83,7 @@ class CGuiTextSupport zeus::CColor x24_fontColor; zeus::CColor x28_outlineColor; zeus::CColor x2c_geometryColor; + bool x30_imageBaseline = false; s32 x34_extentX; s32 x38_extentY; float x3c_curTime = 0.f; @@ -131,6 +131,9 @@ public: void AddText(const std::u16string& str); void SetText(const std::u16string& str, bool multipage=false); void SetText(const std::string& str, bool multipage=false); + void SetJustification(EJustification j); + void SetVerticalJustification(EVerticalJustification j); + void SetImageBaseline(bool b); bool GetIsTextSupportFinishedLoading() const; }; diff --git a/Runtime/GuiSys/CGuiWidget.hpp b/Runtime/GuiSys/CGuiWidget.hpp index 2c809f71d..14ba717c7 100644 --- a/Runtime/GuiSys/CGuiWidget.hpp +++ b/Runtime/GuiSys/CGuiWidget.hpp @@ -129,6 +129,8 @@ public: CGuiWidget* FindWidget(s16 id); bool GetIsFinishedLoading() const; void DispatchInitialize(); + + CGuiFrame* GetGuiFrame() const { return xb0_frame; } }; } diff --git a/Runtime/GuiSys/CInstruction.cpp b/Runtime/GuiSys/CInstruction.cpp index da809fc91..9de7295a7 100644 --- a/Runtime/GuiSys/CInstruction.cpp +++ b/Runtime/GuiSys/CInstruction.cpp @@ -74,24 +74,39 @@ void CLineExtraSpaceInstruction::PageInvoke(CFontRenderState& state, CTextRender Invoke(state, buf); } -void CLineInstruction::TestLargestFont(s32 monoW, s32 monoH, s32 baseline) +void CLineInstruction::TestLargestFont(s32 w, s32 h, s32 b) { - if (!x18_largestBaseline) - x18_largestBaseline = baseline; + if (!x18_largestMonoBaseline) + x18_largestMonoBaseline = b; - if (x14_largestMonoWidth < monoW) - monoW = x14_largestMonoWidth; + if (x14_largestMonoWidth < w) + x14_largestMonoWidth = w; - if (x10_largestMonoHeight < monoH) + if (x10_largestMonoHeight < h) { - x10_largestMonoHeight = monoH; - x18_largestBaseline = baseline; + x10_largestMonoHeight = h; + x18_largestMonoBaseline = b; + } +} + +void CLineInstruction::TestLargestImage(s32 w, s32 h, s32 b) +{ + if (!x24_largestImageBaseline) + x24_largestImageBaseline = b; + + if (x20_largestImageWidth < w) + x20_largestImageWidth = w; + + if (x1c_largestImageHeight < h) + { + x1c_largestImageHeight = h; + x24_largestImageBaseline = b; } } void CLineInstruction::InvokeLTR(CFontRenderState& state) const { - switch (x1c_just) + switch (x28_just) { case EJustification::Left: case EJustification::Full: @@ -228,17 +243,26 @@ void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) { if (x4_image.IsLoaded() && x4_image.x4_texs.size()) { - if (state.x88_curBlock->x14_direction == ETextDirection::Horizontal) + const CTexture* tex = x4_image.x4_texs[0].GetObj(); + if (state.x88_curBlock->x14_dir == ETextDirection::Horizontal) { - const CTexture* tex = x4_image.x4_texs[0].GetObj(); if (buf) { - zeus::CVector2i coords(state.xd4_curX, - state.xd8_curY + state.xdc_currentLineInst->x18_largestBaseline - - tex->GetHeight() * x4_image.x14_pointsPerTexel.y * 2 / 3); + int y = state.xd8_curY + state.xdc_currentLineInst->GetBaseline() - x4_image.CalculateBaseline(); + zeus::CVector2i coords(state.xd4_curX, y); buf->AddImage(coords, x4_image); } - state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_pointsPerTexel.x; + state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_pointsPerTexel.y; + } + else + { + int scale = state.xdc_currentLineInst->x8_curX - tex->GetWidth() * x4_image.x14_pointsPerTexel.y; + if (buf) + { + zeus::CVector2i coords(scale / 2 + state.xd4_curX, state.xd8_curY); + buf->AddImage(coords, x4_image); + } + state.xd8_curY += x4_image.CalculateHeight(); } } } @@ -257,10 +281,20 @@ size_t CImageInstruction::GetAssetCount() const void CTextInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const { int xOut, yOut; - state.x48_font.GetObj()->DrawString(state.x0_drawStrOpts, state.xd4_curX, - state.xdc_currentLineInst->x18_largestBaseline + state.xd8_curY, - xOut, yOut, buf, x4_str.c_str(), x4_str.size()); - state.xd4_curX = xOut; + if (state.x88_curBlock->x14_dir == ETextDirection::Horizontal) + { + state.x48_font->DrawString(state.x0_drawStrOpts, state.xd4_curX, + state.xdc_currentLineInst->GetBaseline() + state.xd8_curY, + xOut, yOut, buf, x4_str.c_str(), x4_str.size()); + state.xd4_curX = xOut; + } + else + { + int scale = state.xdc_currentLineInst->x8_curX - state.x48_font->GetMonoWidth(); + state.x48_font->DrawString(state.x0_drawStrOpts, scale / 2 + state.xd4_curX, + state.xd8_curY, xOut, yOut, buf, x4_str.c_str(), x4_str.size()); + state.xd8_curY = yOut; + } } void CBlockInstruction::TestLargestFont(s32 monoW, s32 monoH, s32 baseline) @@ -307,9 +341,9 @@ void CBlockInstruction::SetupPositionLTR(CFontRenderState& state) const void CBlockInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const { - state.x0_drawStrOpts.x0_direction = x14_direction; - state.x88_curBlock = (CBlockInstruction*)this; - if (x14_direction == ETextDirection::Horizontal) + state.x0_drawStrOpts.x0_direction = x14_dir; + state.x88_curBlock = const_cast(this); + if (x14_dir == ETextDirection::Horizontal) SetupPositionLTR(state); } diff --git a/Runtime/GuiSys/CInstruction.hpp b/Runtime/GuiSys/CInstruction.hpp index e508e49c0..82d25ae0c 100644 --- a/Runtime/GuiSys/CInstruction.hpp +++ b/Runtime/GuiSys/CInstruction.hpp @@ -76,16 +76,37 @@ class CLineInstruction : public CInstruction s32 xc_curY = 0; s32 x10_largestMonoHeight = 0; s32 x14_largestMonoWidth = 0; - s32 x18_largestBaseline = 0; - EJustification x1c_just; - EVerticalJustification x20_vjust; + s32 x18_largestMonoBaseline = 0; + s32 x1c_largestImageHeight = 0; + s32 x20_largestImageWidth = 0; + s32 x24_largestImageBaseline = 0; + EJustification x28_just; + EVerticalJustification x2c_vjust; + bool x30_imageBaseline; public: - CLineInstruction(EJustification just, EVerticalJustification vjust) - : x1c_just(just), x20_vjust(vjust) {} - void TestLargestFont(s32 monoW, s32 monoH, s32 baseline); + CLineInstruction(EJustification just, EVerticalJustification vjust, bool imageBaseline) + : x28_just(just), x2c_vjust(vjust), x30_imageBaseline(imageBaseline) {} + void TestLargestFont(s32 w, s32 h, s32 b); + void TestLargestImage(s32 w, s32 h, s32 b); void InvokeLTR(CFontRenderState& state) const; void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const; void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const; + + s32 GetHeight() const + { + if (x10_largestMonoHeight && !x30_imageBaseline) + return x10_largestMonoHeight; + else + return x1c_largestImageHeight; + } + + s32 GetBaseline() const + { + if (x10_largestMonoHeight && !x30_imageBaseline) + return x18_largestMonoBaseline; + else + return x24_largestImageBaseline; + } }; class CLineSpacingInstruction : public CInstruction @@ -143,13 +164,14 @@ class CBlockInstruction : public CInstruction friend class CTextExecuteBuffer; friend class CLineInstruction; friend class CImageInstruction; + friend class CTextInstruction; friend class CWordInstruction; s32 x4_offsetX; s32 x8_offsetY; s32 xc_blockExtentX; s32 x10_blockExtentY; - ETextDirection x14_direction; + ETextDirection x14_dir; EJustification x18_justification; EVerticalJustification x1c_vertJustification; s32 x20_largestMonoW = 0; @@ -162,7 +184,7 @@ public: CBlockInstruction(s32 offX, s32 offY, s32 extX, s32 extY, ETextDirection dir, EJustification just, EVerticalJustification vjust) : x4_offsetX(offX), x8_offsetY(offY), - xc_blockExtentX(extX), x10_blockExtentY(extY), x14_direction(dir), + xc_blockExtentX(extX), x10_blockExtentY(extY), x14_dir(dir), x18_justification(just), x1c_vertJustification(vjust) {} void TestLargestFont(s32 monoW, s32 monoH, s32 baseline); void SetupPositionLTR(CFontRenderState& state) const; diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index 585eb5216..57a3c7f37 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -103,7 +103,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in { left += x; top += y - glyph->GetBaseline(); - renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x4_colors[0]); + renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x4_colors[2]); } x += glyph->GetRightPadding() + glyph->GetAdvance(); } @@ -138,7 +138,6 @@ void CRasterFont::DrawString(const CDrawStringOptions& opts, int x, int y, int& if (renderBuf) { - /* TODO: Implement this */ /* CGraphicsPalette pal = CGraphicsPalette::CGraphcisPalette(2, 4); */ /* zeus::CColor color = zeus::CColor(0.f, 0.f, 0.f, 0.f) */ /* tmp = color.ToRGB5A3(); */ @@ -148,6 +147,7 @@ void CRasterFont::DrawString(const CDrawStringOptions& opts, int x, int y, int& /* tmp5 = tmp4.ToRGBA5A3(); */ /* pal.UnLock(); */ /* renderBuf->AddPaletteChange(pal); */ + renderBuf->AddPaletteChange(opts.x4_colors[0], opts.x4_colors[1]); } SinglePassDrawString(opts, x, y, xout, yout, renderBuf, str, len); @@ -194,6 +194,13 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh } } +bool CRasterFont::IsFinishedLoading() const +{ + if (!x80_texture || !x80_texture.IsLoaded()) + return false; + return true; +} + std::unique_ptr FRasterFontFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, CObjectReference* selfRef) { diff --git a/Runtime/GuiSys/CRasterFont.hpp b/Runtime/GuiSys/CRasterFont.hpp index 5ed34571f..48bfc4c1b 100644 --- a/Runtime/GuiSys/CRasterFont.hpp +++ b/Runtime/GuiSys/CRasterFont.hpp @@ -149,6 +149,8 @@ public: void GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const; boo::ITexture* GetTexture() { return x80_texture->GetFontTexture(CTexture::EFontType(x2c_mode)); } + + bool IsFinishedLoading() const; }; std::unique_ptr FRasterFontFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, diff --git a/Runtime/GuiSys/CSaveableState.cpp b/Runtime/GuiSys/CSaveableState.cpp index 52197b1d9..8c5219762 100644 --- a/Runtime/GuiSys/CSaveableState.cpp +++ b/Runtime/GuiSys/CSaveableState.cpp @@ -1,6 +1,14 @@ #include "CSaveableState.hpp" +#include "CRasterFont.hpp" namespace urde { +bool CSaveableState::IsFinishedLoading() const +{ + if (!x48_font || !x48_font.IsLoaded()) + return false; + return x48_font->IsFinishedLoading(); +} + } diff --git a/Runtime/GuiSys/CSaveableState.hpp b/Runtime/GuiSys/CSaveableState.hpp index 97296d9fc..68c40c831 100644 --- a/Runtime/GuiSys/CSaveableState.hpp +++ b/Runtime/GuiSys/CSaveableState.hpp @@ -24,7 +24,7 @@ class CSaveableState protected: CDrawStringOptions x0_drawStrOpts; TLockedToken x48_font; - std::vector x54_; + std::vector x54_colors; std::vector x64_colorOverrides; float x74_lineSpacing = 1.f; s32 x78_extraLineSpace = 0; @@ -35,9 +35,11 @@ protected: public: CSaveableState() { - x54_.resize(3, zeus::CColor::skBlack); + x54_colors.resize(3, zeus::CColor::skBlack); x64_colorOverrides.resize(16); } + + bool IsFinishedLoading() const; }; } diff --git a/Runtime/GuiSys/CTextExecuteBuffer.cpp b/Runtime/GuiSys/CTextExecuteBuffer.cpp index 19be8224c..5961f9892 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.cpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.cpp @@ -158,9 +158,8 @@ void CTextExecuteBuffer::AddString(const char16_t* str, int count) StartNewWord(); int w, h; char16_t space = u' '; - x18_textState.x48_font.GetObj()->GetSize(x18_textState.x0_drawStrOpts, - w, h, &space, 1); - if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) + x18_textState.x48_font->GetSize(x18_textState.x0_drawStrOpts, w, h, &space, 1); + if (xa0_curBlock->x14_dir == ETextDirection::Horizontal) { xa4_curLine->x8_curX += w; xbc_spaceDistance = w; @@ -180,7 +179,7 @@ void CTextExecuteBuffer::AddString(const char16_t* str, int count) void CTextExecuteBuffer::AddStringFragment(const char16_t* str, int len) { - if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) + if (xa0_curBlock->x14_dir == ETextDirection::Horizontal) for (int i=0 ; iGetSize(x18_textState.x0_drawStrOpts, - w, h, str, len); + x18_textState.x48_font->GetSize(x18_textState.x0_drawStrOpts, w, h, str, len); if (x18_textState.x7c_enableWordWrap) { @@ -225,8 +223,7 @@ int CTextExecuteBuffer::WrapOneLTR(const char16_t* str, int len) } else { - x18_textState.x48_font.GetObj()->GetSize(x18_textState.x0_drawStrOpts, - w, h, str, rem); + x18_textState.x48_font->GetSize(x18_textState.x0_drawStrOpts, w, h, str, rem); } } while (w + xa4_curLine->x8_curX > xa0_curBlock->xc_blockExtentX && rem > 1); @@ -259,7 +256,7 @@ void CTextExecuteBuffer::MoveWordLTR() TerminateLineLTR(); xa4_curLine = static_cast(x0_instList.emplace(xa8_curWordIt, - std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust))->get()); + std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline))->get()); x0_instList.emplace(xa8_curWordIt, std::make_shared()); @@ -272,7 +269,7 @@ void CTextExecuteBuffer::StartNewLine() TerminateLine(); xa8_curWordIt = x0_instList.emplace(x0_instList.cend(), - std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust)); + std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline)); xa4_curLine = static_cast(xa8_curWordIt->get()); xbc_spaceDistance = 0; @@ -292,15 +289,16 @@ void CTextExecuteBuffer::StartNewWord() void CTextExecuteBuffer::TerminateLine() { - if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) + if (xa0_curBlock->x14_dir == ETextDirection::Horizontal) TerminateLineLTR(); } void CTextExecuteBuffer::TerminateLineLTR() { - if (!xa4_curLine->xc_curY && x18_textState.x48_font) + if (!xa4_curLine->xc_curY && x18_textState.IsFinishedLoading()) { - xa4_curLine->xc_curY = xa4_curLine->x10_largestMonoHeight; + xa4_curLine->xc_curY = std::max(xa4_curLine->GetHeight(), + x18_textState.x48_font->GetCarriageAdvance()); } if (xa0_curBlock->x1c_vertJustification == EVerticalJustification::Full) @@ -323,8 +321,8 @@ void CTextExecuteBuffer::AddPopState() if (!xa4_curLine->x8_curX) { - xa4_curLine->x1c_just = x18_textState.x80_just; - xa4_curLine->x20_vjust = x18_textState.x84_vjust; + xa4_curLine->x28_just = x18_textState.x80_just; + xa4_curLine->x2c_vjust = x18_textState.x84_vjust; } } @@ -341,7 +339,7 @@ void CTextExecuteBuffer::AddVerticalJustification(EVerticalJustification vjust) return; if (xa4_curLine->x8_curX) return; - xa4_curLine->x20_vjust = vjust; + xa4_curLine->x2c_vjust = vjust; } void CTextExecuteBuffer::AddJustification(EJustification just) @@ -351,7 +349,7 @@ void CTextExecuteBuffer::AddJustification(EJustification just) return; if (xa4_curLine->x8_curX) return; - xa4_curLine->x1c_just = just; + xa4_curLine->x28_just = just; } void CTextExecuteBuffer::AddLineExtraSpace(s32 space) @@ -391,11 +389,15 @@ void CTextExecuteBuffer::AddImage(const CFontImageDef& image) const CTexture* tex = image.x4_texs[0].GetObj(); int width = tex->GetWidth() * image.x14_pointsPerTexel.x; int height = tex->GetHeight() * image.x14_pointsPerTexel.y; - xa4_curLine->TestLargestFont(width, height, height); - if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) - if (xa4_curLine->x8_curX > width) - xa0_curBlock->x2c_lineX = xa4_curLine->x8_curX; + if (xa4_curLine->x8_curX + width > xa0_curBlock->xc_blockExtentX && xa4_curLine->x4_wordCount > 0) + StartNewLine(); + + xa4_curLine->TestLargestImage(width, height, image.CalculateBaseline()); + + xa4_curLine->x8_curX += width; + if (xa4_curLine->x8_curX > width) + xa0_curBlock->x2c_lineX = xa4_curLine->x8_curX; } x0_instList.emplace(x0_instList.cend(), std::make_shared(image)); @@ -425,12 +427,13 @@ void CTextExecuteBuffer::EndBlock() xa0_curBlock = nullptr; } -void CTextExecuteBuffer::BeginBlock(s32 offX, s32 offY, s32 padX, s32 padY, - ETextDirection dir, EJustification just, +void CTextExecuteBuffer::BeginBlock(s32 offX, s32 offY, s32 extX, s32 extY, + bool imageBaseline, ETextDirection dir, EJustification just, EVerticalJustification vjust) { + xc0_imageBaseline = imageBaseline; xa0_curBlock = static_cast(x0_instList.emplace(x0_instList.cend(), - std::make_shared(offX, offY, padX, padY, dir, just, vjust))->get()); + std::make_shared(offX, offY, extX, extY, dir, just, vjust))->get()); if (x18_textState.x48_font) { diff --git a/Runtime/GuiSys/CTextExecuteBuffer.hpp b/Runtime/GuiSys/CTextExecuteBuffer.hpp index 9cae380ac..8b8c17312 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.hpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.hpp @@ -30,7 +30,7 @@ class CTextExecuteBuffer s32 xb4_curWordX = 0; s32 xb8_curWordY = 0; s32 xbc_spaceDistance = 0; - bool xc0_ = false; + bool xc0_imageBaseline = false; std::list xc4_stateStack; u32 xd8_ = 0; @@ -68,8 +68,8 @@ public: void AddImage(const CFontImageDef& image); void AddFont(const TToken& font); void EndBlock(); - void BeginBlock(s32 offX, s32 offY, s32 padX, s32 padY, - ETextDirection dir, EJustification just, + void BeginBlock(s32 offX, s32 offY, s32 extX, s32 extY, + bool imageBaseline, ETextDirection dir, EJustification just, EVerticalJustification vjust); void Clear(); }; diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index 7af074c9d..d6c67b8c7 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -37,8 +37,7 @@ void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, floa { BooFontCharacters& fc = rb.m_fontCharacters[m_bindIdx]; CTextSupportShader::CharacterInstance& inst = fc.m_charData[m_instIdx]; - inst.m_fontColor.a = opacity; - inst.m_outlineColor.a = opacity; + inst.m_mulColor.a = opacity; fc.m_dirty = true; break; } @@ -89,8 +88,9 @@ void CTextRenderBuffer::CommitResources() {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2}, }; - vFmt = ctx.newVertexFormat(10, elems, 0, iBufInfo.second); + vFmt = ctx.newVertexFormat(11, elems, 0, iBufInfo.second); } boo::IGraphicsBuffer* uniforms[] = {uBufInfo.first}; @@ -227,6 +227,7 @@ void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, char16_t ch, inst.SetMetrics(*glyph, offset); inst.m_fontColor = m_main * color; inst.m_outlineColor = m_outline * color; + inst.m_mulColor = zeus::CColor::skWhite; } } diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index a275f888d..8f7e443c3 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -82,6 +82,8 @@ CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveUI* sui, u32 rnd) void CFrontEndUI::SNewFileSelectFrame::FinishedLoading() { + x1c_loadedFrame->SetAspectConstraint(1.78f); + x20_tablegroup_fileselect = static_cast(x1c_loadedFrame->FindWidget("tablegroup_fileselect")); x24_model_erase = static_cast(x1c_loadedFrame->FindWidget("model_erase")); xf8_model_erase_position = x24_model_erase->GetLocalPosition(); @@ -836,6 +838,8 @@ void CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::Update(float dt) void CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::FinishedLoading() { + x8_frme->SetAspectConstraint(1.78f); + xc_textpane_instructions = FindTextPanePair(x8_frme, "textpane_instructions"); x14_textpane_yes = static_cast(x8_frme->FindWidget("textpane_yes")); x18_textpane_no = static_cast(x8_frme->FindWidget("textpane_no")); @@ -867,6 +871,8 @@ CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::SGBALinkFrame(CGuiFrame* linkFram void CFrontEndUI::SFusionBonusFrame::FinishedLoading() { + x24_loadedFrame->SetAspectConstraint(1.78f); + x28_tablegroup_options = static_cast(x24_loadedFrame->FindWidget("tablegroup_options")); x2c_tablegroup_fusionsuit = static_cast(x24_loadedFrame->FindWidget("tablegroup_fusionsuit")); x30_textpane_instructions = FindTextPanePair(x24_loadedFrame, "textpane_instructions"); @@ -992,11 +998,13 @@ CFrontEndUI::SFusionBonusFrame::ProcessUserInput(const CFinalInput& input, CSave x39_fusionNotComplete = true; else if (sui) sui->SaveNESState(); - else if (x24_loadedFrame) - x24_loadedFrame->ProcessUserInput(input); } } } + else if (x24_loadedFrame) + { + x24_loadedFrame->ProcessUserInput(input); + } } return x8_action; @@ -1115,6 +1123,8 @@ void CFrontEndUI::FindAndSetPairText(CGuiFrame* frame, const char* name, const s void CFrontEndUI::SFrontEndFrame::FinishedLoading() { + x14_loadedFrme->SetAspectConstraint(1.78f); + x18_tablegroup_mainmenu = static_cast(x14_loadedFrme->FindWidget("tablegroup_mainmenu")); x1c_gbaPair = FindTextPanePair(x14_loadedFrme, "textpane_gba"); x1c_gbaPair.SetPairText(g_MainStringTable->GetString(37)); @@ -1243,8 +1253,7 @@ CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame() const SObjectTag* deface = g_ResFactory->GetResourceIdByName("FONT_Deface14B"); CGuiTextProperties props(false, true, EJustification::Left, - EVerticalJustification::Center, - ETextDirection::Horizontal); + EVerticalJustification::Center); xc_textSupport = std::make_unique(deface->id, props, zeus::CColor::skWhite, zeus::CColor::skBlack, zeus::CColor::skWhite, 0, 0, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha); @@ -1572,6 +1581,8 @@ void CFrontEndUI::SOptionsFrontEndFrame::SetTableColors(CGuiTableGroup* tbgp) co void CFrontEndUI::SOptionsFrontEndFrame::FinishedLoading() { + x1c_loadedFrame->SetAspectConstraint(1.78f); + x24_tablegroup_leftmenu = static_cast(x1c_loadedFrame->FindWidget("tablegroup_leftmenu")); x28_tablegroup_rightmenu = static_cast(x1c_loadedFrame->FindWidget("tablegroup_rightmenu")); x2c_tablegroup_double = static_cast(x1c_loadedFrame->FindWidget("tablegroup_double")); @@ -1912,22 +1923,24 @@ void CFrontEndUI::Draw() const //g_Renderer->SetDepthReadWrite(false, false); g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f); + /* Correct movie aspect ratio */ + float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y); + float hPad, vPad; + if (vpAspectRatio >= 1.78f) + { + hPad = 1.78f / vpAspectRatio; + vPad = 1.78f / 1.33f; + } + else + { + hPad = 1.f; + vPad = vpAspectRatio / 1.33f; + } + if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached()) { /* Render movie */ - float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y); - if (vpAspectRatio >= 1.78f) - { - float hPad = 1.78f / vpAspectRatio; - float vPad = 1.78f / 1.33f; - xcc_curMoviePtr->SetFrame({-hPad, vPad, 0.f}, {-hPad, -vPad, 0.f}, {hPad, -vPad, 0.f}, {hPad, vPad, 0.f}); - } - else - { - float vPad = vpAspectRatio / 1.33f; - xcc_curMoviePtr->SetFrame({-1.f, vPad, 0.f}, {-1.f, -vPad, 0.f}, {1.f, -vPad, 0.f}, {1.f, vPad, 0.f}); - } - + xcc_curMoviePtr->SetFrame({-hPad, vPad, 0.f}, {-hPad, -vPad, 0.f}, {hPad, -vPad, 0.f}, {hPad, vPad, 0.f}); xcc_curMoviePtr->DrawFrame(); } @@ -1950,18 +1963,6 @@ void CFrontEndUI::Draw() const if (x64_pressStartAlpha > 0.f && x38_pressStart.IsLoaded() && m_pressStartQuad) { /* Render "Press Start" */ - float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y); - float hPad, vPad; - if (vpAspectRatio >= 1.78f) - { - hPad = 1.78f / vpAspectRatio; - vPad = 1.78f / 1.33f; - } - else - { - hPad = 1.f; - vPad = vpAspectRatio / 1.33f; - } zeus::CRectangle rect(0.5f - x38_pressStart->GetWidth() / 2.f / 640.f * hPad, 0.5f + (x38_pressStart->GetHeight() / 2.f - 240.f + 72.f) / 480.f * vPad, x38_pressStart->GetWidth() / 640.f * hPad, @@ -2003,7 +2004,7 @@ void CFrontEndUI::Draw() const } } - if (0 && xdc_saveUI) + if (xdc_saveUI) { /* Render memory card feedback strings */ if ((CanShowSaveUI() && !xdc_saveUI->IsHiddenFromFrontEnd()) || diff --git a/Runtime/MP1/CSaveUI.cpp b/Runtime/MP1/CSaveUI.cpp index fd5ac5e9a..1240295dd 100644 --- a/Runtime/MP1/CSaveUI.cpp +++ b/Runtime/MP1/CSaveUI.cpp @@ -119,6 +119,7 @@ bool CSaveUI::PumpLoad() return false; x50_loadedFrame = x44_frmeGenericMenu.GetObj(); + x50_loadedFrame->SetAspectConstraint(1.78f); x54_textpane_message = static_cast(x50_loadedFrame->FindWidget("textpane_message")); x58_tablegroup_choices = static_cast(x50_loadedFrame->FindWidget("tablegroup_choices")); x5c_textpane_choice0 = static_cast(x50_loadedFrame->FindWidget("textpane_choice0")); diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 5a309604b..e2b5ee0bd 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -381,8 +381,7 @@ void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1, x4_modelData.reset(); x44_27_ = b2; - CGuiTextProperties props(false, true, EJustification::Center, - EVerticalJustification::Center, ETextDirection::Horizontal); + CGuiTextProperties props(false, true, EJustification::Center, EVerticalJustification::Center); x8_textData.reset(new CGuiTextSupport(fontId, props, zeus::CColor::skWhite, zeus::CColor::skBlack, zeus::CColor::skWhite, 640, 448, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha)); diff --git a/hecl b/hecl index 1dbd76929..373ec1909 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 1dbd769296619bfa0a9534c76c43c83ae7b7eede +Subproject commit 373ec1909d30ef1ba14179a0e8681ca3bce9c725