Skip to content

Commit a72cd59

Browse files
authored
Merge pull request #376 from CommitteeOfZero/simul-adv-nvl
Simultaneous ADV and NVL text
2 parents 5b34b3e + 94b6d8c commit a72cd59

File tree

11 files changed

+325
-187
lines changed

11 files changed

+325
-187
lines changed

src/animation.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ class Animation {
6262
StartOut(reset);
6363
}
6464

65-
void Finish() {
65+
void Finish(std::optional<AnimationDirection> direction = std::nullopt) {
6666
State = AnimationState::Stopped;
67+
if (direction.has_value()) Direction = direction.value();
6768
Progress = Direction == AnimationDirection::In ? 1.0f : 0.0f;
6869
FinishImpl();
6970
}
7071

72+
void Reset(std::optional<AnimationDirection> direction = std::nullopt) {
73+
State = AnimationState::Stopped;
74+
if (direction.has_value()) Direction = direction.value();
75+
Progress = Direction == AnimationDirection::In ? 0.0f : 1.0f;
76+
}
77+
7178
void Update(float dt) {
7279
if (State == AnimationState::Stopped) return;
7380
UpdateImpl(dt);
@@ -93,6 +100,7 @@ class Animation {
93100
virtual void StartInImpl(bool reset = false) {}
94101
virtual void StartOutImpl(bool reset = false) {}
95102
virtual void FinishImpl() {};
103+
virtual void ResetImpl() {};
96104
virtual void UpdateImpl(float dt) {
97105
if (SkipOnSkipMode && GetFlag(Profile::ScriptVars::SF_MESALLSKIP) &&
98106
State != AnimationState::Stopped) {

src/game.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ void UpdateSystem(float dt) {
265265
SaveIconDisplay::Update(UpdateSecondCounter);
266266
LoadingDisplay::Update(UpdateSecondCounter);
267267
DateDisplay::Update(UpdateSecondCounter);
268-
if (ScrWork[SW_GAMESTATE] & 5 && !GetFlag(SF_GAMEPAUSE) &&
269-
!GetFlag(SF_SYSMENUDISABLE)) {
268+
if (ScrWork[SW_GAMESTATE] & 5 && !GetFlag(SF_GAMEPAUSE)) {
270269
UI::GameSpecific::Update(UpdateSecondCounter);
271270

272271
if (Profile::UseWaveEffects && IsBgWaveEffectActive()) {
@@ -313,8 +312,7 @@ void Update(float dt) {
313312
}
314313

315314
if (Profile::GameFeatures & GameFeature::Renderer2D) {
316-
for (int i = 0; i < Profile::Dialogue::PageCount; i++)
317-
DialoguePages[i].Update(dt);
315+
for (DialoguePage& page : DialoguePages) page.Update(dt);
318316
}
319317
}
320318

@@ -501,9 +499,15 @@ void Render() {
501499
if (!GetFlag(SF_UIHIDDEN) &&
502500
(!GetFlag(SF_SELECTMODE) || GetFlag(SF_SYSTEMMENUCAPTURE))) {
503501
// Dialogue pages drawn in reverse order, at least for cclcc
504-
for (int pageId = Profile::Dialogue::PageCount - 1; pageId >= 0;
505-
pageId--)
506-
DialoguePages[pageId].Render();
502+
for (auto pageIt = DialoguePages.rbegin();
503+
pageIt != DialoguePages.rend(); pageIt++) {
504+
// TODO: Consistently just use the ScrWork variable internally
505+
// after tips and backlog entry pages have been refactored out of
506+
// DialoguePage
507+
pageIt->Mode = static_cast<DialoguePageMode>(
508+
ScrWork[SW_MESMODE0 + 10 * pageIt->Id]);
509+
pageIt->Render();
510+
}
507511
}
508512
// System menu capture
509513
if (Profile::Vm::GameInstructionSet == +Vm::InstructionSet::CC &&

src/hud/waiticondisplay.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#include "../animation.h"
99

10+
#include <ranges>
11+
#include <numeric>
12+
1013
namespace Impacto {
1114
namespace WaitIconDisplay {
1215

@@ -43,13 +46,20 @@ void Init() {
4346
}
4447
}
4548

49+
static bool AnyPageWaiting() {
50+
return std::ranges::any_of(std::views::iota(0, std::ssize(DialoguePages)),
51+
[](int dialoguePageId) {
52+
return GetFlag(SF_SHOWWAITICON + dialoguePageId);
53+
});
54+
}
55+
4656
void Update(float dt) {
4757
switch (WaitIconCurrentType) {
4858
case WaitIconType::None:
4959
return;
5060

5161
case WaitIconType::SpriteAnim: {
52-
bool showWaitIcon = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON);
62+
const bool showWaitIcon = AnyPageWaiting();
5363
if (showWaitIcon && SpriteAnim.IsOut())
5464
SpriteAnim.StartIn();
5565
else if (!showWaitIcon && SpriteAnim.IsIn())
@@ -60,7 +70,7 @@ void Update(float dt) {
6070
}
6171

6272
case WaitIconType::SpriteAnimFixed: {
63-
bool showWaitIcon = GetFlag(Profile::ScriptVars::SF_SHOWWAITICON);
73+
const bool showWaitIcon = AnyPageWaiting();
6474
if (showWaitIcon && FixedSpriteAnim.IsOut())
6575
FixedSpriteAnim.StartIn();
6676
else if (!showWaitIcon && FixedSpriteAnim.IsIn())
@@ -77,8 +87,8 @@ void Update(float dt) {
7787
}
7888

7989
static void RenderSpriteAnim(glm::vec2 pos, glm::vec4 opacityTint,
80-
DialoguePageMode mode) {
81-
if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return;
90+
DialoguePageMode mode, int dialoguePageId) {
91+
if (!GetFlag(SF_SHOWWAITICON + dialoguePageId)) return;
8292

8393
glm::vec2 offset = WaitIconOffset;
8494

@@ -102,8 +112,9 @@ static void RenderSpriteAnimFixed(glm::vec4 opacityTint) {
102112
opacityTint);
103113
}
104114

105-
static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) {
106-
if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return;
115+
static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint,
116+
int dialoguePageId) {
117+
if (!GetFlag(SF_SHOWWAITICON + dialoguePageId)) return;
107118

108119
// TODO: MO6TW only for now
109120
glm::vec3 euler(SimpleAnim.Progress * 2.0f * std::numbers::pi_v<float>, 0,
@@ -119,35 +130,36 @@ static void RenderRotateZ(glm::vec2 pos, glm::vec4 opacityTint) {
119130
Renderer->DrawSprite(WaitIconSprite, dest, opacityTint);
120131
}
121132

122-
static void RenderFixed(glm::vec4 opacityTint) {
123-
if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return;
133+
static void RenderFixed(glm::vec4 opacityTint, int dialoguePageId) {
134+
if (!GetFlag(SF_SHOWWAITICON + dialoguePageId)) return;
124135

125136
Renderer->DrawSprite(WaitIconSprite, WaitIconOffset, opacityTint);
126137
}
127138

128-
void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode) {
139+
void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode,
140+
int dialoguePageId) {
129141
switch (WaitIconCurrentType) {
130142
case WaitIconType::None:
131143
return;
132144

133145
case WaitIconType::SpriteAnim:
134-
RenderSpriteAnim(pos, opacityTint, mode);
146+
RenderSpriteAnim(pos, opacityTint, mode, dialoguePageId);
135147
return;
136148

137149
case WaitIconType::SpriteAnimFixed:
138150
RenderSpriteAnimFixed(opacityTint);
139151
return;
140152

141153
case WaitIconType::RotateZ:
142-
RenderRotateZ(pos, opacityTint);
154+
RenderRotateZ(pos, opacityTint, dialoguePageId);
143155
return;
144156

145157
case WaitIconType::Fixed:
146-
RenderFixed(opacityTint);
158+
RenderFixed(opacityTint, dialoguePageId);
147159
return;
148160

149161
default: {
150-
if (!GetFlag(Profile::ScriptVars::SF_SHOWWAITICON)) return;
162+
if (!GetFlag(SF_SHOWWAITICON + dialoguePageId)) return;
151163

152164
const CornersQuad dest =
153165
WaitIconSprite.ScaledBounds()

src/hud/waiticondisplay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ BETTER_ENUM(WaitIconType, int, None, SpriteAnim, SpriteAnimFixed, Rotate, Fixed,
1313

1414
void Init();
1515
void Update(float dt);
16-
void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode);
16+
void Render(glm::vec2 pos, glm::vec4 opacityTint, DialoguePageMode mode,
17+
int dialoguePageId);
1718

1819
} // namespace WaitIconDisplay
1920
} // namespace Impacto

src/profile/dialogue.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,9 @@ void Configure() {
197197
MaxPageSize = EnsureGetMember<int>("MaxPageSize");
198198
PageCount = EnsureGetMember<int>("PageCount");
199199

200-
Impacto::DialoguePages = new DialoguePage[PageCount];
201-
Impacto::DialoguePageCount = PageCount;
202-
for (int i = 0; i < PageCount; i++) {
203-
Impacto::DialoguePages[i].Glyphs.reserve(MaxPageSize);
200+
Impacto::DialoguePages.resize(PageCount);
201+
for (DialoguePage& page : Impacto::DialoguePages) {
202+
page.Glyphs.reserve(MaxPageSize);
204203
}
205204

206205
{

0 commit comments

Comments
 (0)