From 4796931970f5ccecdd6b6655d885d0f19a9a2878 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Wed, 2 Oct 2024 21:59:21 +0200 Subject: [PATCH 01/14] Added show and hide functions to wait icon --- src/hud/waiticondisplay.cpp | 42 +++++++++++++++++++++++++++++++------ src/hud/waiticondisplay.h | 2 ++ src/spriteanimation.cpp | 10 +++++++++ src/text.cpp | 6 ++++++ 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 545a092e..283aa096 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -9,7 +9,7 @@ namespace WaitIconDisplay { static Animation SimpleAnim; static SpriteAnimation SpriteAnim; -static FixedSpriteAnimation FixedSpriteAnim; +static FixedSpriteAnimation* FixedSpriteAnim; using namespace Impacto::Profile::Dialogue; using namespace Impacto::Profile::CHLCC; @@ -22,9 +22,8 @@ void Init() { } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { SpriteAnim = WaitIconSpriteAnim.Instantiate(); SpriteAnim.LoopMode = ALM_Stop; - FixedSpriteAnim = static_cast(SpriteAnim); - FixedSpriteAnim.Def->FixSpriteId = WaitIconFixedSpriteId; - FixedSpriteAnim.StartIn(); + FixedSpriteAnim = static_cast(&SpriteAnim); + FixedSpriteAnim->Def->FixSpriteId = WaitIconFixedSpriteId; } else { SimpleAnim.DurationIn = WaitIconAnimationDuration; SimpleAnim.LoopMode = ALM_Loop; @@ -36,11 +35,12 @@ void Update(float dt) { if (WaitIconCurrentType == +WaitIconType::SpriteAnim) { SpriteAnim.Update(dt); } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { - FixedSpriteAnim.Update(dt); + FixedSpriteAnim->Update(dt); } else { SimpleAnim.Update(dt); } } + void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { if (WaitIconCurrentType == +WaitIconType::SpriteAnim) { if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { @@ -70,7 +70,7 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { } } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { Renderer->DrawSprite( - FixedSpriteAnim.CurrentSprite(), + FixedSpriteAnim->CurrentSprite(), glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint); } else if (WaitIconCurrentType == +WaitIconType::RotateZ) { // TODO: MO6TW only for now @@ -99,5 +99,35 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { } } +void Show(bool reset) { + switch (WaitIconCurrentType) { + case WaitIconType::SpriteAnim: + case WaitIconType::SpriteAnimFixed: + SpriteAnim.StartIn(reset); + break; + case WaitIconType::Rotate: + case WaitIconType::RotateZ: + SimpleAnim.StartIn(reset); + break; + default: + break; + } +} + +void Hide(bool reset) { + switch (WaitIconCurrentType) { + case WaitIconType::SpriteAnim: + case WaitIconType::SpriteAnimFixed: + SpriteAnim.StartOut(reset); + break; + case WaitIconType::Rotate: + case WaitIconType::RotateZ: + SimpleAnim.StartOut(reset); + break; + default: + break; + } +} + } // namespace WaitIconDisplay } // namespace Impacto \ No newline at end of file diff --git a/src/hud/waiticondisplay.h b/src/hud/waiticondisplay.h index 4e1f0d4d..cf8e3445 100644 --- a/src/hud/waiticondisplay.h +++ b/src/hud/waiticondisplay.h @@ -14,6 +14,8 @@ BETTER_ENUM(WaitIconType, int, None, SpriteAnim, SpriteAnimFixed, Rotate, Fixed, void Init(); void Update(float dt); void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode); +void Show(bool reset = false); +void Hide(bool reset = false); } // namespace WaitIconDisplay } // namespace Impacto \ No newline at end of file diff --git a/src/spriteanimation.cpp b/src/spriteanimation.cpp index 01ffee01..796e408c 100644 --- a/src/spriteanimation.cpp +++ b/src/spriteanimation.cpp @@ -3,20 +3,26 @@ namespace Impacto { bool SpriteAnimation::Exists() { return Def != 0; } + Sprite SpriteAnimation::CurrentSprite() { int frame = (int)(Progress * (float)Def->FrameCount); + if (frame >= Def->FrameCount) frame = Def->FrameCount - 1; else if (frame < 0) frame = 0; + return Def->Frames[frame]; } + void FixedSpriteAnimation::StartInImpl(bool reset) { if (reset) Progress = GetFixedSpriteProgress(); } + void FixedSpriteAnimation::StartOutImpl(bool reset) { if (reset) Progress = GetFixedSpriteProgress(); } + void FixedSpriteAnimation::UpdateImpl(float dt) { float fixedSpriteProgress = GetFixedSpriteProgress(); int animationRequest = Direction; @@ -58,6 +64,7 @@ void FixedSpriteAnimation::UpdateImpl(float dt) { State = AS_Playing; } } + Sprite FixedSpriteAnimation::CurrentSprite() { int frame; float fixedSpriteProgress = GetFixedSpriteProgress(); @@ -78,11 +85,13 @@ Sprite FixedSpriteAnimation::CurrentSprite() { return Def->Frames[frame]; } + float FixedSpriteAnimation::GetFixedSpriteProgress() const { /* Converse because in- and out directions are reversed between spritesheet and implementation */ return 1.0f - (float)Def->FixSpriteId / Def->FrameCount; } + SpriteAnimation SpriteAnimationDef::Instantiate() { SpriteAnimation result; result.Def = this; @@ -95,4 +104,5 @@ SpriteAnimation SpriteAnimationDef::Instantiate() { return result; } + } // namespace Impacto \ No newline at end of file diff --git a/src/text.cpp b/src/text.cpp index c9afde45..3b4ffe8c 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -668,8 +668,12 @@ void DialoguePage::AddString(Vm::Sc3VmThread* ctx, Audio::AudioStream* voice, } void DialoguePage::Update(float dt) { + bool typewriterJustFinished = !TextIsFullyOpaque(); + Typewriter.Update(dt); + typewriterJustFinished &= TextIsFullyOpaque(); + for (int i = 0; i < Glyphs.size(); i++) { Glyphs[i].Opacity = Typewriter.CalcOpacity(i); if (Glyphs[i].Opacity == 0.0f) { @@ -682,6 +686,8 @@ void DialoguePage::Update(float dt) { if (AutoWaitTime < 0) AutoWaitTime = 0; } + if (typewriterJustFinished) WaitIconDisplay::Show(); + TextBox->Update(dt); FadeAnimation.Update(dt); From cd9639dff306dde31758f58861c000f56b13a87b Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Wed, 2 Oct 2024 22:31:04 +0200 Subject: [PATCH 02/14] Changed wait icon display to use switch statements --- src/hud/waiticondisplay.cpp | 154 ++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 66 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 283aa096..46220ea8 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -15,87 +15,109 @@ using namespace Impacto::Profile::Dialogue; using namespace Impacto::Profile::CHLCC; void Init() { - if (WaitIconCurrentType == +WaitIconType::SpriteAnim) { - SpriteAnim = WaitIconSpriteAnim.Instantiate(); - SpriteAnim.LoopMode = ALM_Loop; - SpriteAnim.StartIn(); - } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { - SpriteAnim = WaitIconSpriteAnim.Instantiate(); - SpriteAnim.LoopMode = ALM_Stop; - FixedSpriteAnim = static_cast(&SpriteAnim); - FixedSpriteAnim->Def->FixSpriteId = WaitIconFixedSpriteId; - } else { - SimpleAnim.DurationIn = WaitIconAnimationDuration; - SimpleAnim.LoopMode = ALM_Loop; - SimpleAnim.StartIn(); + switch (WaitIconCurrentType) { + case WaitIconType::SpriteAnim: + SpriteAnim = WaitIconSpriteAnim.Instantiate(); + SpriteAnim.LoopMode = ALM_Loop; + SpriteAnim.StartIn(); + break; + case WaitIconType::SpriteAnimFixed: + SpriteAnim = WaitIconSpriteAnim.Instantiate(); + SpriteAnim.LoopMode = ALM_Stop; + FixedSpriteAnim = static_cast(&SpriteAnim); + FixedSpriteAnim->Def->FixSpriteId = WaitIconFixedSpriteId; + break; + default: + SimpleAnim.DurationIn = WaitIconAnimationDuration; + SimpleAnim.LoopMode = ALM_Loop; + SimpleAnim.StartIn(); + break; } } void Update(float dt) { - if (WaitIconCurrentType == +WaitIconType::SpriteAnim) { - SpriteAnim.Update(dt); - } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { - FixedSpriteAnim->Update(dt); - } else { - SimpleAnim.Update(dt); + switch (WaitIconCurrentType) { + case WaitIconType::SpriteAnim: + SpriteAnim.Update(dt); + break; + case WaitIconType::SpriteAnimFixed: + FixedSpriteAnim->Update(dt); + break; + default: + SimpleAnim.Update(dt); + break; } } void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { - if (WaitIconCurrentType == +WaitIconType::SpriteAnim) { - if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { - // To deal with multiple DialogueBox - glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); - // Erin DialogueBox - if (mode == DPM_REV) { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2( - pos.x + - Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.x, - pos.y + - Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.y), - col); + switch (WaitIconCurrentType) { + case WaitIconType::SpriteAnim: + if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { + // To deal with multiple DialogueBox + glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); + // Erin DialogueBox + if (mode == DPM_REV) { + Renderer->DrawSprite( + SpriteAnim.CurrentSprite(), + glm::vec2( + pos.x + + Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.x, + pos.y + + Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset + .y), + col); + } else { + Renderer->DrawSprite( + SpriteAnim.CurrentSprite(), + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + col); + } } else { Renderer->DrawSprite( SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), col); + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + opacityTint); } - } else { + break; + + case WaitIconType::SpriteAnimFixed: Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint); + FixedSpriteAnim->CurrentSprite(), + glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint); + break; + + case WaitIconType::RotateZ: { + // TODO: MO6TW only for now + glm::vec3 euler(SimpleAnim.Progress * 2.0f * M_PI, 0, 0.6f); + glm::quat quat; + eulerZYXToQuat(&euler, &quat); + + glm::vec2 vanishingPoint( + (pos.x + WaitIconOffset.x) + (WaitIconSprite.ScaledWidth() / 2.0f), + (pos.y + WaitIconOffset.y) + (WaitIconSprite.ScaledHeight() / 2.0f)); + + Renderer->DrawSprite3DRotated( + WaitIconSprite, + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, + vanishingPoint, true, quat, opacityTint); + break; } - } else if (WaitIconCurrentType == +WaitIconType::SpriteAnimFixed) { - Renderer->DrawSprite( - FixedSpriteAnim->CurrentSprite(), - glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint); - } else if (WaitIconCurrentType == +WaitIconType::RotateZ) { - // TODO: MO6TW only for now - glm::vec3 euler(SimpleAnim.Progress * 2.0f * M_PI, 0, 0.6f); - glm::quat quat; - eulerZYXToQuat(&euler, &quat); - - glm::vec2 vanishingPoint( - (pos.x + WaitIconOffset.x) + (WaitIconSprite.ScaledWidth() / 2.0f), - (pos.y + WaitIconOffset.y) + (WaitIconSprite.ScaledHeight() / 2.0f)); - - Renderer->DrawSprite3DRotated( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, - vanishingPoint, true, quat, opacityTint); - } else if (WaitIconCurrentType == +WaitIconType::None) { - Renderer->DrawSprite( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint, glm::vec2(1.0f)); - } else { - Renderer->DrawSprite( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint, glm::vec2(1.0f), SimpleAnim.Progress * 2.0f * (float)M_PI); + + case WaitIconType::None: + Renderer->DrawSprite( + WaitIconSprite, + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + opacityTint, glm::vec2(1.0f)); + break; + + default: + Renderer->DrawSprite( + WaitIconSprite, + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + opacityTint, glm::vec2(1.0f), + SimpleAnim.Progress * 2.0f * (float)M_PI); + break; } } From be8c486855843888d2ea42f8ad3acae27532229f Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 3 Oct 2024 00:50:34 +0200 Subject: [PATCH 03/14] Implemented CCLCC wait icon --- profiles/common/scriptvars.lua | 1 + src/hud/waiticondisplay.cpp | 86 ++++++++++++++++++---------------- src/hud/waiticondisplay.h | 2 - src/scriptvars.h | 1 + src/spriteanimation.h | 8 ++-- src/text.cpp | 16 ++----- 6 files changed, 55 insertions(+), 59 deletions(-) diff --git a/profiles/common/scriptvars.lua b/profiles/common/scriptvars.lua index fa023593..f51066f4 100644 --- a/profiles/common/scriptvars.lua +++ b/profiles/common/scriptvars.lua @@ -272,6 +272,7 @@ root.ScriptVars = { SF_ACTORSVOICE_UNLOCK1=840, SF_EXTRA_ENA=860, SF_MOVIE_UNLOCK1=910, + SF_SHOWWAITICON=1205, SF_MESSKIP=1233, SF_MESALLSKIP=1234, SF_MESREAD=1235, diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 46220ea8..82349479 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -1,15 +1,20 @@ #include "waiticondisplay.h" -#include "../profile/dialogue.h" #include "../renderer/renderer.h" +#include "../profile/dialogue.h" +#include "../profile/scriptvars.h" #include "../profile/games/chlcc/dialoguebox.h" +#include "../animation.h" + namespace Impacto { namespace WaitIconDisplay { static Animation SimpleAnim; static SpriteAnimation SpriteAnim; -static FixedSpriteAnimation* FixedSpriteAnim; +static FixedSpriteAnimation FixedSpriteAnim; + +static float opacity = 0.0f; using namespace Impacto::Profile::Dialogue; using namespace Impacto::Profile::CHLCC; @@ -24,8 +29,8 @@ void Init() { case WaitIconType::SpriteAnimFixed: SpriteAnim = WaitIconSpriteAnim.Instantiate(); SpriteAnim.LoopMode = ALM_Stop; - FixedSpriteAnim = static_cast(&SpriteAnim); - FixedSpriteAnim->Def->FixSpriteId = WaitIconFixedSpriteId; + FixedSpriteAnim = static_cast(SpriteAnim); + FixedSpriteAnim.Def->FixSpriteId = WaitIconFixedSpriteId; break; default: SimpleAnim.DurationIn = WaitIconAnimationDuration; @@ -40,9 +45,13 @@ void Update(float dt) { case WaitIconType::SpriteAnim: SpriteAnim.Update(dt); break; + case WaitIconType::SpriteAnimFixed: - FixedSpriteAnim->Update(dt); + FixedSpriteAnim.Update(dt); + if (FixedSpriteAnim.IsOut()) opacity = 0.0f; + break; + default: SimpleAnim.Update(dt); break; @@ -50,8 +59,20 @@ void Update(float dt) { } void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { + opacityTint *= opacity; + if (opacityTint.a == 0.0f) return; + + bool show = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON); + switch (WaitIconCurrentType) { case WaitIconType::SpriteAnim: + if (show) + SpriteAnim.StartIn(); + else + SpriteAnim.StartOut(); + + if (FixedSpriteAnim.IsOut()) return; + if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { // To deal with multiple DialogueBox glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); @@ -79,15 +100,24 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), opacityTint); } - break; + return; case WaitIconType::SpriteAnimFixed: + if (show) + FixedSpriteAnim.StartIn(); + else + FixedSpriteAnim.StartOut(); + + if (FixedSpriteAnim.IsOut()) return; + Renderer->DrawSprite( - FixedSpriteAnim->CurrentSprite(), + FixedSpriteAnim.CurrentSprite(), glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint); - break; + return; case WaitIconType::RotateZ: { + if (!show) return; + // TODO: MO6TW only for now glm::vec3 euler(SimpleAnim.Progress * 2.0f * M_PI, 0, 0.6f); glm::quat quat; @@ -101,53 +131,27 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { WaitIconSprite, glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, vanishingPoint, true, quat, opacityTint); - break; + return; } case WaitIconType::None: + if (!show) return; + Renderer->DrawSprite( WaitIconSprite, glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), opacityTint, glm::vec2(1.0f)); - break; + return; default: + if (!show) return; + Renderer->DrawSprite( WaitIconSprite, glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), opacityTint, glm::vec2(1.0f), SimpleAnim.Progress * 2.0f * (float)M_PI); - break; - } -} - -void Show(bool reset) { - switch (WaitIconCurrentType) { - case WaitIconType::SpriteAnim: - case WaitIconType::SpriteAnimFixed: - SpriteAnim.StartIn(reset); - break; - case WaitIconType::Rotate: - case WaitIconType::RotateZ: - SimpleAnim.StartIn(reset); - break; - default: - break; - } -} - -void Hide(bool reset) { - switch (WaitIconCurrentType) { - case WaitIconType::SpriteAnim: - case WaitIconType::SpriteAnimFixed: - SpriteAnim.StartOut(reset); - break; - case WaitIconType::Rotate: - case WaitIconType::RotateZ: - SimpleAnim.StartOut(reset); - break; - default: - break; + return; } } diff --git a/src/hud/waiticondisplay.h b/src/hud/waiticondisplay.h index cf8e3445..4e1f0d4d 100644 --- a/src/hud/waiticondisplay.h +++ b/src/hud/waiticondisplay.h @@ -14,8 +14,6 @@ BETTER_ENUM(WaitIconType, int, None, SpriteAnim, SpriteAnimFixed, Rotate, Fixed, void Init(); void Update(float dt); void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode); -void Show(bool reset = false); -void Hide(bool reset = false); } // namespace WaitIconDisplay } // namespace Impacto \ No newline at end of file diff --git a/src/scriptvars.h b/src/scriptvars.h index 7e647aa5..fe08cb95 100644 --- a/src/scriptvars.h +++ b/src/scriptvars.h @@ -270,6 +270,7 @@ V(SF_CLR_END1) V(SF_CLR_TRUE_CC) V(SF_ACTORSVOICE_UNLOCK1) V(SF_MOVIE_UNLOCK1) +V(SF_SHOWWAITICON) V(SF_MESSKIP) V(SF_MESALLSKIP) V(SF_MESREAD) diff --git a/src/spriteanimation.h b/src/spriteanimation.h index f0ef58a6..6319d5f1 100644 --- a/src/spriteanimation.h +++ b/src/spriteanimation.h @@ -34,10 +34,10 @@ struct SpriteAnimation : public Animation { (with 1 being fully in). */ struct FixedSpriteAnimation : public SpriteAnimation { - void StartInImpl(bool reset); - void StartOutImpl(bool reset); - void UpdateImpl(float dt); - Sprite CurrentSprite(); + void StartInImpl(bool reset) override; + void StartOutImpl(bool reset) override; + void UpdateImpl(float dt) override; + Sprite CurrentSprite() override; float GetFixedSpriteProgress() const; }; diff --git a/src/text.cpp b/src/text.cpp index 3b4ffe8c..326ffb41 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -668,12 +668,8 @@ void DialoguePage::AddString(Vm::Sc3VmThread* ctx, Audio::AudioStream* voice, } void DialoguePage::Update(float dt) { - bool typewriterJustFinished = !TextIsFullyOpaque(); - Typewriter.Update(dt); - typewriterJustFinished &= TextIsFullyOpaque(); - for (int i = 0; i < Glyphs.size(); i++) { Glyphs[i].Opacity = Typewriter.CalcOpacity(i); if (Glyphs[i].Opacity == 0.0f) { @@ -686,8 +682,6 @@ void DialoguePage::Update(float dt) { if (AutoWaitTime < 0) AutoWaitTime = 0; } - if (typewriterJustFinished) WaitIconDisplay::Show(); - TextBox->Update(dt); FadeAnimation.Update(dt); @@ -727,12 +721,10 @@ void DialoguePage::Render() { } // Wait icon - if (Typewriter.Progress == 1.0f && Glyphs.size() > 0) { - WaitIconDisplay::Render( - glm::vec2(Glyphs.back().DestRect.X + Glyphs.back().DestRect.Width, - Glyphs.back().DestRect.Y), - col, Mode); - } + const RectF& lastGlyphDest = + Glyphs.empty() ? RectF() : Glyphs.back().DestRect; + glm::vec2 waitIconPos(lastGlyphDest.X + lastGlyphDest.Width, lastGlyphDest.Y); + WaitIconDisplay::Render(waitIconPos, col, Mode); AutoIconDisplay::Render(col); SkipIconDisplay::Render(col); From 20b45b4534df34be5009224ed89357b30b748716 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 4 Oct 2024 23:50:27 +0200 Subject: [PATCH 04/14] Moved wait icon render types into static functions --- src/hud/waiticondisplay.cpp | 159 +++++++++++++++++++----------------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 82349479..942ff8d8 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -58,93 +58,104 @@ void Update(float dt) { } } +static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint, + DialoguePageMode mode) { + if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) + SpriteAnim.StartIn(); + else + SpriteAnim.StartOut(); + + if (FixedSpriteAnim.IsOut()) return; + + if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { + // To deal with multiple DialogueBox + glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); + // Erin DialogueBox + if (mode == DPM_REV) { + Renderer->DrawSprite( + SpriteAnim.CurrentSprite(), + glm::vec2( + pos.x + Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.x, + pos.y + + Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.y), + col); + + } else { + Renderer->DrawSprite( + SpriteAnim.CurrentSprite(), + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), col); + } + } else { + Renderer->DrawSprite( + SpriteAnim.CurrentSprite(), + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + opacityTint); + } + return; +} + +static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { + if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) + FixedSpriteAnim.StartIn(); + else + FixedSpriteAnim.StartOut(); + + if (FixedSpriteAnim.IsOut()) return; + + Renderer->DrawSprite(FixedSpriteAnim.CurrentSprite(), + glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), + opacityTint); + return; +} + +static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) { + if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; + + // TODO: MO6TW only for now + glm::vec3 euler(SimpleAnim.Progress * 2.0f * M_PI, 0, 0.6f); + glm::quat quat; + eulerZYXToQuat(&euler, &quat); + + glm::vec2 vanishingPoint( + (pos.x + WaitIconOffset.x) + (WaitIconSprite.ScaledWidth() / 2.0f), + (pos.y + WaitIconOffset.y) + (WaitIconSprite.ScaledHeight() / 2.0f)); + + Renderer->DrawSprite3DRotated( + WaitIconSprite, + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, + vanishingPoint, true, quat, opacityTint); + return; +} + +static void RenderNone(glm::vec2 pos, glm::vec4 opacityTint) { + if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; + + Renderer->DrawSprite( + WaitIconSprite, + glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), + opacityTint, glm::vec2(1.0f)); + return; +} + void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { opacityTint *= opacity; if (opacityTint.a == 0.0f) return; - bool show = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON); - switch (WaitIconCurrentType) { case WaitIconType::SpriteAnim: - if (show) - SpriteAnim.StartIn(); - else - SpriteAnim.StartOut(); - - if (FixedSpriteAnim.IsOut()) return; - - if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { - // To deal with multiple DialogueBox - glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); - // Erin DialogueBox - if (mode == DPM_REV) { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2( - pos.x + - Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.x, - pos.y + - Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset - .y), - col); - - } else { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - col); - } - } else { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint); - } + RenderSpriteAnim(pos, opacityTint, mode); return; - case WaitIconType::SpriteAnimFixed: - if (show) - FixedSpriteAnim.StartIn(); - else - FixedSpriteAnim.StartOut(); - - if (FixedSpriteAnim.IsOut()) return; - - Renderer->DrawSprite( - FixedSpriteAnim.CurrentSprite(), - glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint); + RenderSpriteAnimFixed(opacityTint); return; - - case WaitIconType::RotateZ: { - if (!show) return; - - // TODO: MO6TW only for now - glm::vec3 euler(SimpleAnim.Progress * 2.0f * M_PI, 0, 0.6f); - glm::quat quat; - eulerZYXToQuat(&euler, &quat); - - glm::vec2 vanishingPoint( - (pos.x + WaitIconOffset.x) + (WaitIconSprite.ScaledWidth() / 2.0f), - (pos.y + WaitIconOffset.y) + (WaitIconSprite.ScaledHeight() / 2.0f)); - - Renderer->DrawSprite3DRotated( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, - vanishingPoint, true, quat, opacityTint); + case WaitIconType::RotateZ: + RenderRotateZ(pos, opacityTint); return; - } - case WaitIconType::None: - if (!show) return; - - Renderer->DrawSprite( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint, glm::vec2(1.0f)); + RenderNone(pos, opacityTint); return; - default: - if (!show) return; + if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; Renderer->DrawSprite( WaitIconSprite, From e222b0d0d0a5a4c42b5a3c008b9e8e1222b2da99 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 5 Oct 2024 00:05:50 +0200 Subject: [PATCH 05/14] Removed RenderNone wait icon function --- src/hud/waiticondisplay.cpp | 20 +++++++------------- src/profile/dialogue.cpp | 33 +++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 942ff8d8..2c382ca3 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -20,6 +20,8 @@ using namespace Impacto::Profile::Dialogue; using namespace Impacto::Profile::CHLCC; void Init() { + if (WaitIconCurrentType == +WaitIconType::None) return; + switch (WaitIconCurrentType) { case WaitIconType::SpriteAnim: SpriteAnim = WaitIconSpriteAnim.Instantiate(); @@ -42,6 +44,9 @@ void Init() { void Update(float dt) { switch (WaitIconCurrentType) { + case WaitIconType::None: + return; + case WaitIconType::SpriteAnim: SpriteAnim.Update(dt); break; @@ -127,21 +132,13 @@ static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) { return; } -static void RenderNone(glm::vec2 pos, glm::vec4 opacityTint) { - if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; - - Renderer->DrawSprite( - WaitIconSprite, - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint, glm::vec2(1.0f)); - return; -} - void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { opacityTint *= opacity; if (opacityTint.a == 0.0f) return; switch (WaitIconCurrentType) { + case WaitIconType::None: + return; case WaitIconType::SpriteAnim: RenderSpriteAnim(pos, opacityTint, mode); return; @@ -151,9 +148,6 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { case WaitIconType::RotateZ: RenderRotateZ(pos, opacityTint); return; - case WaitIconType::None: - RenderNone(pos, opacityTint); - return; default: if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; diff --git a/src/profile/dialogue.cpp b/src/profile/dialogue.cpp index 3a437d0a..595b2bce 100644 --- a/src/profile/dialogue.cpp +++ b/src/profile/dialogue.cpp @@ -96,22 +96,27 @@ void Configure() { TryGetMemberFloat("TipsLineSpacing", TipsLineSpacing); TryGetMemberInt("TipsColorIndex", TipsColorIndex); + int WaitIconCurrentTypeInt; + if (!TryGetMemberInt("WaitIconCurrentType", WaitIconCurrentTypeInt)) + WaitIconCurrentTypeInt = +WaitIconDisplay::WaitIconType::None; WaitIconCurrentType = WaitIconDisplay::WaitIconType::_from_integral_unchecked( - EnsureGetMemberInt("WaitIconCurrentType")); - if (WaitIconCurrentType == +WaitIconDisplay::WaitIconType::SpriteAnim) { - WaitIconSpriteAnim = EnsureGetMemberAnimation("WaitIconSpriteAnim"); - } else if (WaitIconCurrentType == - +WaitIconDisplay::WaitIconType::SpriteAnimFixed) { - WaitIconSpriteAnim = EnsureGetMemberAnimation("WaitIconSpriteAnim"); - WaitIconFixedSpriteId = EnsureGetMemberInt("WaitIconFixedSpriteId"); - } else if (WaitIconCurrentType == +WaitIconDisplay::WaitIconType::None) { - WaitIconSprite = EnsureGetMemberSprite("WaitIconSprite"); - } else { - WaitIconSprite = EnsureGetMemberSprite("WaitIconSprite"); - WaitIconAnimationDuration = - EnsureGetMemberFloat("WaitIconAnimationDuration"); + WaitIconCurrentTypeInt); + if (WaitIconCurrentType != +WaitIconDisplay::WaitIconType::None) { + switch (WaitIconCurrentType) { + case WaitIconDisplay::WaitIconType::SpriteAnim: + WaitIconSpriteAnim = EnsureGetMemberAnimation("WaitIconSpriteAnim"); + break; + case WaitIconDisplay::WaitIconType::SpriteAnimFixed: + WaitIconSpriteAnim = EnsureGetMemberAnimation("WaitIconSpriteAnim"); + WaitIconFixedSpriteId = EnsureGetMemberInt("WaitIconFixedSpriteId"); + break; + default: + WaitIconSprite = EnsureGetMemberSprite("WaitIconSprite"); + WaitIconAnimationDuration = + EnsureGetMemberFloat("WaitIconAnimationDuration"); + } + WaitIconOffset = EnsureGetMemberVec2("WaitIconOffset"); } - WaitIconOffset = EnsureGetMemberVec2("WaitIconOffset"); int AutoIconCurrentTypeInt; if (!TryGetMemberInt("AutoIconCurrentType", AutoIconCurrentTypeInt)) From e8410757cfb3a0733be3d671d0f5adda569122f1 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 5 Oct 2024 00:21:21 +0200 Subject: [PATCH 06/14] Implemented fixed wait icon type --- src/hud/waiticondisplay.cpp | 16 +++++++++------- src/profile/dialogue.cpp | 3 +++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 2c382ca3..a25daa63 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -14,8 +14,6 @@ static Animation SimpleAnim; static SpriteAnimation SpriteAnim; static FixedSpriteAnimation FixedSpriteAnim; -static float opacity = 0.0f; - using namespace Impacto::Profile::Dialogue; using namespace Impacto::Profile::CHLCC; @@ -53,8 +51,6 @@ void Update(float dt) { case WaitIconType::SpriteAnimFixed: FixedSpriteAnim.Update(dt); - if (FixedSpriteAnim.IsOut()) opacity = 0.0f; - break; default: @@ -132,10 +128,13 @@ static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) { return; } -void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { - opacityTint *= opacity; - if (opacityTint.a == 0.0f) return; +static void RenderFixed(glm::vec4 opacityTint) { + if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; + Renderer->DrawSprite(WaitIconSprite, WaitIconOffset, opacityTint); +} + +void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { switch (WaitIconCurrentType) { case WaitIconType::None: return; @@ -148,6 +147,9 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { case WaitIconType::RotateZ: RenderRotateZ(pos, opacityTint); return; + case WaitIconType::Fixed: + RenderFixed(opacityTint); + return; default: if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return; diff --git a/src/profile/dialogue.cpp b/src/profile/dialogue.cpp index 595b2bce..b8f68e68 100644 --- a/src/profile/dialogue.cpp +++ b/src/profile/dialogue.cpp @@ -110,6 +110,9 @@ void Configure() { WaitIconSpriteAnim = EnsureGetMemberAnimation("WaitIconSpriteAnim"); WaitIconFixedSpriteId = EnsureGetMemberInt("WaitIconFixedSpriteId"); break; + case WaitIconDisplay::WaitIconType::Fixed: + WaitIconSprite = EnsureGetMemberSprite("WaitIconSprite"); + break; default: WaitIconSprite = EnsureGetMemberSprite("WaitIconSprite"); WaitIconAnimationDuration = From b526929f05f777d1b72929f0a242fc0ca882344a Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 5 Oct 2024 23:29:57 +0200 Subject: [PATCH 07/14] Fixed SpriteAnimFixed wait icon rendering on initialization --- src/hud/waiticondisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index a25daa63..886cac59 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -101,7 +101,7 @@ static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { else FixedSpriteAnim.StartOut(); - if (FixedSpriteAnim.IsOut()) return; + if (FixedSpriteAnim.Progress == 0.0f) return; Renderer->DrawSprite(FixedSpriteAnim.CurrentSprite(), glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), From dfaff38f3b4c3bc6b097add2dd352a696ae95ba2 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 8 Oct 2024 02:44:34 +0200 Subject: [PATCH 08/14] Changed SF_SHOWWAITICON to point to the right ID --- profiles/common/scriptvars.lua | 2 +- src/scriptvars.h | 2 +- src/vm/inst_dialogue.cpp | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/profiles/common/scriptvars.lua b/profiles/common/scriptvars.lua index f51066f4..da53ff8f 100644 --- a/profiles/common/scriptvars.lua +++ b/profiles/common/scriptvars.lua @@ -272,13 +272,13 @@ root.ScriptVars = { SF_ACTORSVOICE_UNLOCK1=840, SF_EXTRA_ENA=860, SF_MOVIE_UNLOCK1=910, - SF_SHOWWAITICON=1205, SF_MESSKIP=1233, SF_MESALLSKIP=1234, SF_MESREAD=1235, SF_TITLEMODE=1240, SF_TITLEEND=1241, SF_UIHIDDEN=1244, + SF_SHOWWAITICON=1251, SF_LOADING=1264, SF_SYSMENUDISABLE=1286, SF_SYSTEMMENUDISABLE=1221, -- i don't know SYS and SYSTEM exists diff --git a/src/scriptvars.h b/src/scriptvars.h index fe08cb95..9f7c6b47 100644 --- a/src/scriptvars.h +++ b/src/scriptvars.h @@ -270,13 +270,13 @@ V(SF_CLR_END1) V(SF_CLR_TRUE_CC) V(SF_ACTORSVOICE_UNLOCK1) V(SF_MOVIE_UNLOCK1) -V(SF_SHOWWAITICON) V(SF_MESSKIP) V(SF_MESALLSKIP) V(SF_MESREAD) V(SF_TITLEMODE) V(SF_TITLEEND) V(SF_UIHIDDEN) +V(SF_SHOWWAITICON) V(SF_LOADING) V(SF_SYSMENUDISABLE) V(SF_SYSTEMMENUDISABLE) diff --git a/src/vm/inst_dialogue.cpp b/src/vm/inst_dialogue.cpp index 10bffefd..6c48af2a 100644 --- a/src/vm/inst_dialogue.cpp +++ b/src/vm/inst_dialogue.cpp @@ -184,12 +184,15 @@ VmInstruction(InstMesMain) { } } else { // Text is fully opaque + SetFlag(1251 + thread->DialoguePageId, true); + if (!GetFlag(SF_UIHIDDEN)) { if (advanceButtonWentDown || GetFlag(SF_MESALLSKIP) || !currentPage->AutoWaitTime) { // Advance to next line SaveSystem::SetLineRead(ScrWork[2 * currentPage->Id + SW_SCRIPTID], ScrWork[2 * currentPage->Id + SW_LINEID]); + SetFlag(1251 + thread->DialoguePageId, false); BlockThread; return; From 9e768cd50a89cdcffd04f8f513bc041d3e662dcf Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 8 Oct 2024 02:53:31 +0200 Subject: [PATCH 09/14] Improved CCLCC wait icon position --- profiles/cclcc/dialogue.lua | 2 +- src/hud/waiticondisplay.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles/cclcc/dialogue.lua b/profiles/cclcc/dialogue.lua index 083f6d9b..010bb564 100644 --- a/profiles/cclcc/dialogue.lua +++ b/profiles/cclcc/dialogue.lua @@ -41,7 +41,7 @@ root.Dialogue = { WaitIconCurrentType = WaitIconType.SpriteAnimFixed, WaitIconSpriteAnim = "WaitIconSpriteAnim", WaitIconAnimationDuration = 0.7, - WaitIconOffset = { X = 1624, Y = 955 }, + WaitIconOffset = { X = 1595, Y = 895 }, WaitIconFixedSpriteId = 6, AutoIconCurrentType = AutoIconType.SpriteAnimFixed, AutoIconSpriteAnim = "AutoIconSpriteAnim", diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 886cac59..333d18a6 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -104,7 +104,7 @@ static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { if (FixedSpriteAnim.Progress == 0.0f) return; Renderer->DrawSprite(FixedSpriteAnim.CurrentSprite(), - glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), + glm::vec2(WaitIconOffset.x, WaitIconOffset.y), opacityTint); return; } From 8c377cda26599745dea22a3c0e4cf773596fe651 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 8 Oct 2024 22:51:52 +0200 Subject: [PATCH 10/14] Changed hardcoded 1251s to SF_SHOWWAITICON --- src/vm/inst_dialogue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vm/inst_dialogue.cpp b/src/vm/inst_dialogue.cpp index 6c48af2a..4ae2200b 100644 --- a/src/vm/inst_dialogue.cpp +++ b/src/vm/inst_dialogue.cpp @@ -184,7 +184,7 @@ VmInstruction(InstMesMain) { } } else { // Text is fully opaque - SetFlag(1251 + thread->DialoguePageId, true); + SetFlag(SF_SHOWWAITICON + thread->DialoguePageId, true); if (!GetFlag(SF_UIHIDDEN)) { if (advanceButtonWentDown || GetFlag(SF_MESALLSKIP) || @@ -192,7 +192,7 @@ VmInstruction(InstMesMain) { // Advance to next line SaveSystem::SetLineRead(ScrWork[2 * currentPage->Id + SW_SCRIPTID], ScrWork[2 * currentPage->Id + SW_LINEID]); - SetFlag(1251 + thread->DialoguePageId, false); + SetFlag(SF_SHOWWAITICON + thread->DialoguePageId, false); BlockThread; return; From 4c8798513014e8d8a96207200eb8e7a6a779318b Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 10 Oct 2024 20:09:20 +0200 Subject: [PATCH 11/14] Moved wait icon display StartIn/Out calls to Update function --- src/hud/waiticondisplay.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 333d18a6..145d4610 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -46,10 +46,20 @@ void Update(float dt) { return; case WaitIconType::SpriteAnim: + if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) + SpriteAnim.StartIn(false); + else + SpriteAnim.StartOut(false); + SpriteAnim.Update(dt); break; case WaitIconType::SpriteAnimFixed: + if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) + FixedSpriteAnim.StartIn(false); + else + FixedSpriteAnim.StartOut(false); + FixedSpriteAnim.Update(dt); break; @@ -61,11 +71,6 @@ void Update(float dt) { static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { - if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) - SpriteAnim.StartIn(); - else - SpriteAnim.StartOut(); - if (FixedSpriteAnim.IsOut()) return; if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { @@ -96,11 +101,6 @@ static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint, } static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { - if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) - FixedSpriteAnim.StartIn(); - else - FixedSpriteAnim.StartOut(); - if (FixedSpriteAnim.Progress == 0.0f) return; Renderer->DrawSprite(FixedSpriteAnim.CurrentSprite(), From 1737fb7c50135ba3ad6d3bba31b22d1bb7bd0ad4 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 10 Oct 2024 20:18:03 +0200 Subject: [PATCH 12/14] Simplified wait icon RenderSpriteAnim function --- src/hud/waiticondisplay.cpp | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 145d4610..2183e9a3 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -73,30 +73,18 @@ static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) { if (FixedSpriteAnim.IsOut()) return; + glm::vec2 offset = WaitIconOffset; + if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) { // To deal with multiple DialogueBox - glm::vec4 col = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); + opacityTint = glm::vec4(1.0f, 1.0f, 1.0f, opacityTint.a); + // Erin DialogueBox - if (mode == DPM_REV) { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2( - pos.x + Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.x, - pos.y + - Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset.y), - col); - - } else { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), col); - } - } else { - Renderer->DrawSprite( - SpriteAnim.CurrentSprite(), - glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), - opacityTint); + if (mode == DPM_REV) + offset = Impacto::Profile::CHLCC::DialogueBox::REVWaitIconOffset; } + + Renderer->DrawSprite(SpriteAnim.CurrentSprite(), pos + offset, opacityTint); return; } From 1a4a7277ca9c44019ee4ad51d14298a7238bf31d Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 10 Oct 2024 20:20:06 +0200 Subject: [PATCH 13/14] Removed FixedSpriteAnimationDef declaration with no implementation --- src/hud/waiticondisplay.cpp | 3 --- src/spriteanimation.h | 1 - 2 files changed, 4 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index 2183e9a3..f8ef0079 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -85,7 +85,6 @@ static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint, } Renderer->DrawSprite(SpriteAnim.CurrentSprite(), pos + offset, opacityTint); - return; } static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { @@ -94,7 +93,6 @@ static void RenderSpriteAnimFixed(glm::vec4 opacityTint) { Renderer->DrawSprite(FixedSpriteAnim.CurrentSprite(), glm::vec2(WaitIconOffset.x, WaitIconOffset.y), opacityTint); - return; } static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) { @@ -113,7 +111,6 @@ static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) { WaitIconSprite, glm::vec2(pos.x + WaitIconOffset.x, pos.y + WaitIconOffset.y), 1.0f, vanishingPoint, true, quat, opacityTint); - return; } static void RenderFixed(glm::vec4 opacityTint) { diff --git a/src/spriteanimation.h b/src/spriteanimation.h index 6319d5f1..a059c4ae 100644 --- a/src/spriteanimation.h +++ b/src/spriteanimation.h @@ -6,7 +6,6 @@ namespace Impacto { class SpriteAnimationDef; -class FixedSpriteAnimationDef; struct SpriteAnimation : public Animation { SpriteAnimationDef* Def = 0; From 42524beedd71d968fcf5282b183eec05f127f742 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 10 Oct 2024 21:24:20 +0200 Subject: [PATCH 14/14] Changed SpriteAnim wait icon Update to only StartIn/Out when fully in/out --- src/hud/waiticondisplay.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hud/waiticondisplay.cpp b/src/hud/waiticondisplay.cpp index f8ef0079..da9875ac 100644 --- a/src/hud/waiticondisplay.cpp +++ b/src/hud/waiticondisplay.cpp @@ -45,23 +45,27 @@ void Update(float dt) { case WaitIconType::None: return; - case WaitIconType::SpriteAnim: - if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) - SpriteAnim.StartIn(false); - else - SpriteAnim.StartOut(false); + case WaitIconType::SpriteAnim: { + bool showWaitIcon = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON); + if (showWaitIcon && SpriteAnim.IsOut()) + SpriteAnim.StartIn(); + else if (!showWaitIcon && SpriteAnim.IsIn()) + SpriteAnim.StartOut(); SpriteAnim.Update(dt); break; + } - case WaitIconType::SpriteAnimFixed: - if (GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) - FixedSpriteAnim.StartIn(false); - else - FixedSpriteAnim.StartOut(false); + case WaitIconType::SpriteAnimFixed: { + bool showWaitIcon = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON); + if (showWaitIcon && FixedSpriteAnim.IsOut()) + FixedSpriteAnim.StartIn(); + else if (!showWaitIcon && FixedSpriteAnim.IsIn()) + FixedSpriteAnim.StartOut(); FixedSpriteAnim.Update(dt); break; + } default: SimpleAnim.Update(dt);