Skip to content

Commit c8702fa

Browse files
committed
screenswitch anim
1 parent 9124f64 commit c8702fa

5 files changed

Lines changed: 27 additions & 8 deletions

File tree

freesprite/UILayerButton.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void LayerActiveButton::render(XY at)
132132
previewRect.x = at.x - previewRect.w;
133133
previewRect.y = at.y;
134134

135+
//unclip to escape scrollpanel bounds
135136
g_pushClip({ 0,0,g_windowW, g_windowH });
136137
SDL_SetRenderDrawColor(g_rd, 0, 0, 0, 0x80);
137138
SDL_RenderFillRect(g_rd, &previewRect);

freesprite/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void g_addNotificationFromThread(Notification a);
358358
void g_addScreen(BaseScreen* a, bool switchTo = true);
359359
void g_addScreenToWindow(VSPWindow* wd, BaseScreen* a, bool switchTo = true);
360360
void g_closeScreen(BaseScreen* screen);
361-
void g_switchScreen(int index);
361+
void g_switchScreen(int index, int vfxExt = 0);
362362

363363
void g_addPopup(BasePopup* a);
364364
void g_closePopup(BasePopup* a, bool dispose = true);

freesprite/multiwindow.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ bool VSPWindow::closeScreen(BaseScreen* screen) {
336336
}
337337
}
338338

339-
void VSPWindow::switchScreen(int index) {
339+
void VSPWindow::switchScreen(int index, int vfxExt) {
340340
if (index >= 0 && index < screenStack.size()) {
341341
if (index != currentScreen) {
342342
currentScreen = index;
343343
screenStack[currentScreen]->onReturnToScreen();
344-
g_newVFX(VFX_SCREENSWITCH, 800);
344+
g_newVFX(VFX_SCREENSWITCH, 800, vfxExt);
345345
}
346346
overlayWidgets.forceUnfocus();
347347
}
@@ -351,10 +351,10 @@ void VSPWindow::switchScreenLeft() {
351351
if (popupStack.empty()) {
352352
if (currentScreen != 0) {
353353
if (g_ctrlModifier) {
354-
g_switchScreen(0);
354+
g_switchScreen(0, 1);
355355
}
356356
else {
357-
g_switchScreen(currentScreen - 1);
357+
g_switchScreen(currentScreen - 1, 1);
358358
}
359359
}
360360
}
@@ -364,10 +364,10 @@ void VSPWindow::switchScreenRight() {
364364
if (popupStack.empty()) {
365365
if (currentScreen < screenStack.size() - 1) {
366366
if (g_ctrlModifier) {
367-
g_switchScreen(screenStack.size() - 1);
367+
g_switchScreen(screenStack.size() - 1, 2);
368368
}
369369
else {
370-
g_switchScreen(currentScreen + 1);
370+
g_switchScreen(currentScreen + 1, 2);
371371
}
372372
}
373373
}

freesprite/multiwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class VSPWindow {
124124

125125
bool closeScreen(BaseScreen* screen);
126126

127-
void switchScreen(int index);
127+
void switchScreen(int index, int vfxExt = 0);
128128

129129
void switchScreenLeft();
130130
void switchScreenRight();

freesprite/vfx.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "vfx.h"
33
#include "Timer64.h"
44
#include "main.h"
5+
#include "multiwindow.h"
6+
#include "BaseScreen.h"
57

68
class VFX {
79
private:
@@ -58,6 +60,22 @@ class VFX {
5860
{
5961
double animTimer = interpolation(timer.percentElapsedTime(duration));
6062
double reverseAnimTimer = 1.0 - animTimer;
63+
if (extData1 != 0) {
64+
int prevScreenIndex = g_currentWindow->currentScreen + (extData1 == 1 ? 1 : -1);
65+
if (g_currentWindow->screenStack.size() > prevScreenIndex) {
66+
double animTimer2 = interpolation(timer.percentElapsedTime(duration/3));
67+
int w = g_windowW * (1.0-animTimer2);
68+
if (w > 0) {
69+
int divLinePos = extData1 == 1 ? g_windowW - w : w;
70+
SDL_Rect clipRect = { extData1 == 1 ? divLinePos : 0, 0, w, g_windowH };
71+
SDL_SetRenderDrawColor(g_rd, 255, 255, 255, 0x60);
72+
drawLine({ divLinePos, 0 }, { divLinePos, g_windowH });
73+
g_pushClip(clipRect);
74+
g_currentWindow->screenStack[prevScreenIndex]->render();
75+
g_popClip();
76+
}
77+
}
78+
}
6179
SDL_Rect rect = { 0,0,g_windowW, g_windowH };
6280
XY windowOffset = { g_windowW / 16 , g_windowH / 16 };
6381
rect = offsetRect(rect, windowOffset.x * -reverseAnimTimer, windowOffset.y * -reverseAnimTimer);

0 commit comments

Comments
 (0)