Skip to content

Commit

Permalink
DSi theme: Re-add original scroll speed
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Sep 26, 2024
1 parent 16755bf commit 18aa216
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 12 deletions.
84 changes: 73 additions & 11 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern int titleboxXspacing;
int movingApp = -1;
int movingAppYpos = 0;
bool movingAppIsDir = false;
bool draggingIcons = false;
extern bool showMovingArrow;
extern double movingArrowYpos;
extern bool displayGameIcons;
Expand Down Expand Up @@ -3393,7 +3394,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
// Load icons
if (prevPos != CURPOS) {
for (int i = 0; i < 6; i++) {
int pos = (CURPOS - 2 + i);
const int pos = (CURPOS - 2 + i);
if (pos >= 0 && pos + PAGENUM * 40 < file_count) {
iconUpdate(dirContents[scrn][pos + PAGENUM * 40].isDirectory,
dirContents[scrn][pos + PAGENUM * 40].name.c_str(),
Expand Down Expand Up @@ -3432,6 +3433,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
touchPosition prevTouch2 = touch;

bool tapped = false;
bool dsiCursorMove = false;
while (1) {
scanKeys();
touchRead(&touch);
Expand Down Expand Up @@ -3464,12 +3466,68 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {

if (moveBy == 0) {
gameTapped = bannerTextShown && showSTARTborder;
} else if (ms().theme == TWLSettings::EThemeDSi) {
if (moveBy != -2 && moveBy != 2) {
moveCursor(moveBy == 1, dirContents[scrn]);
} else {
const int CURPOS1 = std::clamp(moveBy > 0 ? (CURPOS + 1) : (CURPOS - 1), 0, last_used_box);
CURPOS = std::clamp(CURPOS + moveBy, 0, last_used_box);

titlewindowXdest[ms().secondaryDevice] = CURPOS * 5;
titleboxXdest[ms().secondaryDevice] = CURPOS * titleboxXspacing;
boxArtLoaded = false;
settingsChanged = true;
bannerTextShown = false;
titleboxXspeed = 10;
touch = startTouch;
if (CURPOS + PAGENUM * 40 >= ((int)dirContents[scrn].size())) {
showSTARTborder = (ms().theme == TWLSettings::ETheme3DS ? true : false);
} else {
showSTARTborder = true;
}

for (int i = 0; i < 2; i++) {
swiWaitForVBlank();
}

// Load icons
for (int i = 0; i < 6; i++) {
const int pos = (CURPOS1 - 2 + i);
if (pos >= 0 && pos + PAGENUM * 40 < file_count) {
iconUpdate(dirContents[scrn][pos + PAGENUM * 40].isDirectory,
dirContents[scrn][pos + PAGENUM * 40].name.c_str(),
pos);
}
}

for (int i = 0; i < 5; i++) {
swiWaitForVBlank();
}

// Load icons again
for (int i = 0; i < 6; i++) {
const int pos = (CURPOS - 2 + i);
if (pos >= 0 && pos + PAGENUM * 40 < file_count) {
iconUpdate(dirContents[scrn][pos + PAGENUM * 40].isDirectory,
dirContents[scrn][pos + PAGENUM * 40].name.c_str(),
pos);
}
}

while (titleboxXpos[ms().secondaryDevice] != titleboxXdest[ms().secondaryDevice]) {
swiWaitForVBlank();
}
titleboxXspeed = 8;
snd().playStop();
startBorderZoomOut = true;
}
dsiCursorMove = true;
} else if (ms().theme != TWLSettings::EThemeSaturn) {
CURPOS = std::clamp(CURPOS + moveBy, 0, last_used_box);

// Load icons
for (int i = 0; i < 6; i++) {
int pos = (CURPOS - 2 + i);
const int pos = (CURPOS - 2 + i);
if (pos >= 0 && pos + PAGENUM * 40 < file_count) {
iconUpdate(dirContents[scrn][pos + PAGENUM * 40].isDirectory,
dirContents[scrn][pos + PAGENUM * 40].name.c_str(),
Expand All @@ -3478,6 +3536,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
}
}
} else if (ms().theme != TWLSettings::EThemeSaturn) {
draggingIcons = true;
int prevPos = CURPOS;
showSTARTborder = false;

Expand Down Expand Up @@ -3597,17 +3656,20 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
prevTouch1 = touch;
prevPos = CURPOS;
}
draggingIcons = false;
}

titlewindowXdest[ms().secondaryDevice] = CURPOS * 5;
titleboxXdest[ms().secondaryDevice] = CURPOS * titleboxXspacing;
boxArtLoaded = false;
settingsChanged = true;
bannerTextShown = false;
titleboxXspeed = 3;
touch = startTouch;
if (!gameTapped && CURPOS + PAGENUM * 40 < ((int)dirContents[scrn].size())) {
showSTARTborder = (ms().theme == TWLSettings::ETheme3DS ? true : false);
if (!dsiCursorMove) {
titlewindowXdest[ms().secondaryDevice] = CURPOS * 5;
titleboxXdest[ms().secondaryDevice] = CURPOS * titleboxXspacing;
boxArtLoaded = false;
settingsChanged = true;
bannerTextShown = false;
titleboxXspeed = (ms().theme == TWLSettings::EThemeDSi) ? 8 : 3;
touch = startTouch;
if (!gameTapped && CURPOS + PAGENUM * 40 < ((int)dirContents[scrn].size())) {
showSTARTborder = (ms().theme == TWLSettings::ETheme3DS ? true : false);
}
}
}

Expand Down
29 changes: 28 additions & 1 deletion romsel_dsimenutheme/arm9/source/graphics/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ extern int waitForNeedToPlayStopSound;
extern int movingApp;
extern int movingAppYpos;
extern bool movingAppIsDir;
extern bool draggingIcons;
float movingArrowYpos = 59;
bool movingArrowYdirection = true;
bool showMovingArrow = false;
Expand Down Expand Up @@ -453,7 +454,29 @@ void vBlankHandler() {
}

// Move title box/window closer to destination if moved
if (ms().theme != TWLSettings::EThemeSaturn) {
if (ms().theme == TWLSettings::EThemeDSi && !draggingIcons && !scrollWindowTouched) {
if (titleboxXpos[ms().secondaryDevice] > titleboxXdest[ms().secondaryDevice]) {
titleboxXpos[ms().secondaryDevice] -= titleboxXspeed;
if (titleboxXpos[ms().secondaryDevice] < titleboxXdest[ms().secondaryDevice]) {
titleboxXpos[ms().secondaryDevice] = titleboxXdest[ms().secondaryDevice];
}
updateFrame = true;
} else if (titleboxXpos[ms().secondaryDevice] < titleboxXdest[ms().secondaryDevice]) {
titleboxXpos[ms().secondaryDevice] += titleboxXspeed;
if (titleboxXpos[ms().secondaryDevice] > titleboxXdest[ms().secondaryDevice]) {
titleboxXpos[ms().secondaryDevice] = titleboxXdest[ms().secondaryDevice];
}
updateFrame = true;
}

if (titlewindowXpos[ms().secondaryDevice] > titlewindowXdest[ms().secondaryDevice]) {
titlewindowXpos[ms().secondaryDevice] -= std::max((titlewindowXpos[ms().secondaryDevice] - titlewindowXdest[ms().secondaryDevice]) / titleboxXspeed, 1);
updateFrame = true;
} else if (titlewindowXpos[ms().secondaryDevice] < titlewindowXdest[ms().secondaryDevice]) {
titlewindowXpos[ms().secondaryDevice] += std::max((titlewindowXdest[ms().secondaryDevice] - titlewindowXpos[ms().secondaryDevice]) / titleboxXspeed, 1);
updateFrame = true;
}
} else if (ms().theme != TWLSettings::EThemeSaturn) {
if (titleboxXpos[ms().secondaryDevice] > titleboxXdest[ms().secondaryDevice]) {
titleboxXpos[ms().secondaryDevice] -= std::max((titleboxXpos[ms().secondaryDevice] - titleboxXdest[ms().secondaryDevice]) / titleboxXspeed, 1);
updateFrame = true;
Expand Down Expand Up @@ -1479,6 +1502,10 @@ void graphicsInit() {
// launchDotFrame[i] = 5;
// }

if (ms().theme == TWLSettings::EThemeDSi) {
titleboxXspeed = 8;
}

for (int i = 0; i < 5; i++) {
dropBounce[i] = 0;
dropSpeed[i] = initialDropSpeed;
Expand Down

0 comments on commit 18aa216

Please sign in to comment.