Skip to content

Commit

Permalink
Displaying current song in deathmix
Browse files Browse the repository at this point in the history
  • Loading branch information
afska committed Jan 19, 2024
1 parent 2fa6436 commit 16a3ed4
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gameplay/DeathMix.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DeathMix {

bool isInitialSong() { return next == 1; }
SongChart getNextSongChart();
u32 getCurrentSongNumber() { return next - 1; }

private:
const GBFS_FILE* fs;
Expand Down
7 changes: 6 additions & 1 deletion src/scenes/SongScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ void SongScene::continueDeathMix() {
deathMix->points = scores[0]->getPoints();
deathMix->longNotes = scores[0]->getLongNotes();

scores[0]->getCombo()->setValue(deathMix->getCurrentSongNumber());
scores[0]->getCombo()->show();
SPRITE_hide(scores[0]->getFeedback()->get());
SPRITE_hide(scores[0]->getCombo()->getTitle()->get());

#ifdef SENV_DEVELOPMENT
auto stageBreak = GameState.mods.stageBreak;
#endif
Expand All @@ -778,7 +783,7 @@ void SongScene::continueDeathMix() {
engine->transitionIntoScene(
new SongScene(engine, fs, songChart.song, songChart.chart, NULL,
std::move(deathMix)),
new PixelTransitionEffect());
new FadeOutPixelTransitionEffect());
} else {
auto evaluation = scores[localPlayerId]->evaluate();
auto grade = evaluation->getGrade();
Expand Down
37 changes: 37 additions & 0 deletions src/utils/FadeOutPixelTransitionEffect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef FADE_OUT_PIXEL_TRANSITION_EFFECT_H
#define FADE_OUT_PIXEL_TRANSITION_EFFECT_H

#include <libgba-sprite-engine/effects/scene_effect.h>
#include <libgba-sprite-engine/scene.h>

#include "utils/EffectUtils.h"
#include "utils/SceneUtils.h"

const u32 FINAL_OPACITY = 15;
const u32 FINAL_MOSAIC = 10;

class FadeOutPixelTransitionEffect : public SceneEffect {
public:
FadeOutPixelTransitionEffect(){};

void update() override {
EFFECT_setBlendAlpha(opacity * 3 / 4);
EFFECT_setMosaic(mosaic);

if (opacity * 3 / 4 < FINAL_OPACITY)
opacity++;
else
mosaic++;

if (isDone())
BACKGROUND_enable(false, false, false, false);
}

bool isDone() override { return mosaic >= FINAL_MOSAIC; }

private:
u32 opacity = 0;
u32 mosaic = 0;
};

#endif // FADE_OUT_PIXEL_TRANSITION_EFFECT_H
7 changes: 7 additions & 0 deletions src/utils/PixelTransitionEffect.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef PIXEL_TRANSITION_EFFECT_H
#define PIXEL_TRANSITION_EFFECT_H

#include <libgba-sprite-engine/effects/scene_effect.h>
#include <libgba-sprite-engine/scene.h>

Expand All @@ -12,7 +15,9 @@ class PixelTransitionEffect : public SceneEffect {

void update() override {
EFFECT_setMosaic(value);

value++;

if (isDone())
BACKGROUND_enable(false, false, false, false);
}
Expand All @@ -22,3 +27,5 @@ class PixelTransitionEffect : public SceneEffect {
private:
u32 value = 0;
};

#endif // PIXEL_TRANSITION_EFFECT_H
1 change: 1 addition & 0 deletions src/utils/SceneUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "BackgroundUtils.h"
#include "EffectUtils.h"
#include "FadeOutPixelTransitionEffect.h"
#include "PixelTransitionEffect.h"
#include "SpriteUtils.h"
#include "utils/IOPort.h"
Expand Down

0 comments on commit 16a3ed4

Please sign in to comment.