Skip to content

Commit

Permalink
Implemented CCLCC wait icon
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Oct 2, 2024
1 parent 7643601 commit d70f506
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
40 changes: 33 additions & 7 deletions src/hud/waiticondisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
#include "../renderer/renderer.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;
Expand All @@ -24,8 +28,8 @@ void Init() {
case WaitIconType::SpriteAnimFixed:
SpriteAnim = WaitIconSpriteAnim.Instantiate();
SpriteAnim.LoopMode = ALM_Stop;
FixedSpriteAnim = static_cast<FixedSpriteAnimation*>(&SpriteAnim);
FixedSpriteAnim->Def->FixSpriteId = WaitIconFixedSpriteId;
FixedSpriteAnim = static_cast<FixedSpriteAnimation&>(SpriteAnim);
FixedSpriteAnim.Def->FixSpriteId = WaitIconFixedSpriteId;
break;
default:
SimpleAnim.DurationIn = WaitIconAnimationDuration;
Expand All @@ -40,16 +44,23 @@ 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;
}
}

void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) {
opacityTint *= opacity;
if (opacityTint.a == 0.0f) return;

switch (WaitIconCurrentType) {
case WaitIconType::SpriteAnim:
if (DialogueBoxCurrentType == +DialogueBoxType::CHLCC) {
Expand Down Expand Up @@ -83,7 +94,7 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) {

case WaitIconType::SpriteAnimFixed:
Renderer->DrawSprite(
FixedSpriteAnim->CurrentSprite(),
FixedSpriteAnim.CurrentSprite(),
glm::vec2(WaitIconOffset.x - 50, WaitIconOffset.y - 50), opacityTint);
break;

Expand Down Expand Up @@ -122,15 +133,22 @@ void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) {
}

void Show(bool reset) {
opacity = 1.0f;

switch (WaitIconCurrentType) {
case WaitIconType::SpriteAnim:
case WaitIconType::SpriteAnimFixed:
SpriteAnim.StartIn(reset);
break;

case WaitIconType::SpriteAnimFixed:
FixedSpriteAnim.StartIn(reset);
break;

case WaitIconType::Rotate:
case WaitIconType::RotateZ:
SimpleAnim.StartIn(reset);
break;

default:
break;
}
Expand All @@ -139,14 +157,22 @@ void Show(bool reset) {
void Hide(bool reset) {
switch (WaitIconCurrentType) {
case WaitIconType::SpriteAnim:
case WaitIconType::SpriteAnimFixed:
opacity = 0.0f;
SpriteAnim.StartOut(reset);
break;

case WaitIconType::SpriteAnimFixed:
FixedSpriteAnim.StartOut(reset);
break;

case WaitIconType::Rotate:
case WaitIconType::RotateZ:
opacity = 0.0f;
SimpleAnim.StartOut(reset);
break;

default:
opacity = 0.0f;
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/spriteanimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ 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);
void StartInImpl(bool reset) override;
void StartOutImpl(bool reset) override;
void UpdateImpl(float dt) override;
Sprite CurrentSprite();

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-arm64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 40 in src/spriteanimation.h

View workflow job for this annotation

GitHub Actions / macos-x64

'CurrentSprite' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
float GetFixedSpriteProgress() const;
};
Expand Down
20 changes: 12 additions & 8 deletions src/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,11 @@ void DialoguePage::AddString(Vm::Sc3VmThread* ctx, Audio::AudioStream* voice,
}

void DialoguePage::Update(float dt) {
bool typewriterJustFinished = !TextIsFullyOpaque();
bool typewriterJustFinished = !Typewriter.IsIn();

Typewriter.Update(dt);

typewriterJustFinished &= TextIsFullyOpaque();
typewriterJustFinished &= Typewriter.IsIn();

for (int i = 0; i < Glyphs.size(); i++) {
Glyphs[i].Opacity = Typewriter.CalcOpacity(i);
Expand All @@ -686,7 +686,10 @@ void DialoguePage::Update(float dt) {
if (AutoWaitTime < 0) AutoWaitTime = 0;
}

if (typewriterJustFinished) WaitIconDisplay::Show();
if (typewriterJustFinished)
WaitIconDisplay::Show();
else if (GetFlag(1905 + Id))
WaitIconDisplay::Hide();

TextBox->Update(dt);
FadeAnimation.Update(dt);
Expand Down Expand Up @@ -727,11 +730,12 @@ 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);
if (!GetFlag(SF_MESSKIP)) {
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);
Expand Down
2 changes: 2 additions & 0 deletions src/vm/inst_dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ VmInstruction(InstMes) {

ScrWork[2 * dialoguePage.Id + SW_LINEID] = lineId;
ScrWork[2 * dialoguePage.Id + SW_SCRIPTID] = scriptId;
SetFlag(1905 + thread->DialoguePageId, false);

Audio::AudioStream* audioStream = nullptr;
if (voiced) {
Expand Down Expand Up @@ -190,6 +191,7 @@ VmInstruction(InstMesMain) {
// Advance to next line
SaveSystem::SetLineRead(ScrWork[2 * currentPage->Id + SW_SCRIPTID],
ScrWork[2 * currentPage->Id + SW_LINEID]);
SetFlag(thread->DialoguePageId + 1905, true);

BlockThread;
return;
Expand Down

0 comments on commit d70f506

Please sign in to comment.