mirror of
https://github.com/DarkStore-3DS/Universal-Core.git
synced 2026-07-03 00:39:23 +00:00
Add Fade Effects for the Screens.
This commit is contained in:
@@ -38,6 +38,10 @@ C2D_TextBuf TextBuf;
|
|||||||
C2D_Font Font;
|
C2D_Font Font;
|
||||||
std::unique_ptr<Screen> usedScreen, tempScreen; // tempScreen used for "fade" effects.
|
std::unique_ptr<Screen> usedScreen, tempScreen; // tempScreen used for "fade" effects.
|
||||||
bool currentScreen = false;
|
bool currentScreen = false;
|
||||||
|
bool fadeout = false;
|
||||||
|
bool fadein = false;
|
||||||
|
int fadealpha = 0;
|
||||||
|
int fadecolor = 0;
|
||||||
|
|
||||||
// Clear Text.
|
// Clear Text.
|
||||||
void Gui::clearTextBufs(void) { C2D_TextBufClear(TextBuf); }
|
void Gui::clearTextBufs(void) { C2D_TextBufClear(TextBuf); }
|
||||||
@@ -245,8 +249,14 @@ void Gui::DrawScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do the current screen's logic.
|
// Do the current screen's logic.
|
||||||
void Gui::ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch) {
|
void Gui::ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade) {
|
||||||
if (usedScreen != nullptr) usedScreen->Logic(hDown, hHeld, touch);
|
if (waitFade) {
|
||||||
|
if (!fadein && !fadeout) {
|
||||||
|
if (usedScreen != nullptr) usedScreen->Logic(hDown, hHeld, touch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (usedScreen != nullptr) usedScreen->Logic(hDown, hHeld, touch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calls the current screen's constructor.
|
// Calls the current screen's constructor.
|
||||||
@@ -260,10 +270,38 @@ void Gui::transferScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the current Screen.
|
// Set the current Screen.
|
||||||
void Gui::setScreen(std::unique_ptr<Screen> screen, bool screenSwitch) {
|
void Gui::setScreen(std::unique_ptr<Screen> screen, bool fade) {
|
||||||
tempScreen = std::move(screen);
|
tempScreen = std::move(screen);
|
||||||
if (screenSwitch) {
|
// Switch screen without fade.
|
||||||
|
if (!fade) {
|
||||||
Gui::transferScreen();
|
Gui::transferScreen();
|
||||||
|
} else {
|
||||||
|
// Fade, then switch.
|
||||||
|
fadeout = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fade's the screen in and out and transfer the screen.
|
||||||
|
// Credits goes to RocketRobz & SavvyManager.
|
||||||
|
void Gui::fadeEffects(int fadeoutFrames, int fadeinFrames) {
|
||||||
|
if (fadein) {
|
||||||
|
fadealpha -= fadeinFrames;
|
||||||
|
if (fadealpha < 0) {
|
||||||
|
fadealpha = 0;
|
||||||
|
fadecolor = 255;
|
||||||
|
fadein = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fadeout) {
|
||||||
|
fadealpha += fadeoutFrames;
|
||||||
|
if (fadealpha > 255) {
|
||||||
|
fadealpha = 255;
|
||||||
|
Gui::transferScreen(); // Transfer Temp screen to the used one.
|
||||||
|
Gui::CallConstructor(); // Here we call the constructor for the current screen.
|
||||||
|
fadein = true;
|
||||||
|
fadeout = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,8 +139,9 @@ namespace Gui {
|
|||||||
* hDown: the hidKeysDown() variable.
|
* hDown: the hidKeysDown() variable.
|
||||||
* hHeld: the HidKeysHeld() variable.
|
* hHeld: the HidKeysHeld() variable.
|
||||||
* touch: The TouchPosition variable.
|
* touch: The TouchPosition variable.
|
||||||
|
* waitFade: Wheter to wait until the fade ends.
|
||||||
*/
|
*/
|
||||||
void ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch);
|
void ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade = true);
|
||||||
|
|
||||||
/* Used for the current Screen's Constructor call. (Optional!)
|
/* Used for the current Screen's Constructor call. (Optional!)
|
||||||
* This is useful if you need to call the screen's constructor.
|
* This is useful if you need to call the screen's constructor.
|
||||||
@@ -156,7 +157,13 @@ namespace Gui {
|
|||||||
* screen: unique_ptr of the screen. (Optional by using the screen class.)
|
* screen: unique_ptr of the screen. (Optional by using the screen class.)
|
||||||
* screenSwitch: Wheter to switch to the current screen.
|
* screenSwitch: Wheter to switch to the current screen.
|
||||||
*/
|
*/
|
||||||
void setScreen(std::unique_ptr<Screen> screen, bool screenSwitch = true);
|
void setScreen(std::unique_ptr<Screen> screen, bool fade = false);
|
||||||
|
|
||||||
|
/* Fades into screens and calls the constructor after it. (Optional!)
|
||||||
|
* fadeoutFrames: Amount of frames for fadeout.
|
||||||
|
* fadeinFrames: Amount of frames for fadein.
|
||||||
|
*/
|
||||||
|
void fadeEffects(int fadeoutFrames = 6, int fadeinFrames = 6);
|
||||||
|
|
||||||
/* Set on which screen to draw.
|
/* Set on which screen to draw.
|
||||||
* screen: The render target. (Targets are inside the screenCommon.hpp file.)
|
* screen: The render target. (Targets are inside the screenCommon.hpp file.)
|
||||||
|
|||||||
@@ -33,5 +33,9 @@
|
|||||||
extern C3D_RenderTarget* Top;
|
extern C3D_RenderTarget* Top;
|
||||||
extern C3D_RenderTarget* TopRight;
|
extern C3D_RenderTarget* TopRight;
|
||||||
extern C3D_RenderTarget* Bottom;
|
extern C3D_RenderTarget* Bottom;
|
||||||
|
extern bool fadeout;
|
||||||
|
extern bool fadein;
|
||||||
|
extern int fadealpha;
|
||||||
|
extern int fadecolor;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user