mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Animation time? 😛
I just ripped the animation selector code from LeafEdit for it, because it's basically the same like LeafEdit because of Rectangles.
This commit is contained in:
@@ -48,6 +48,7 @@ namespace Gui
|
||||
void sprite(int key, int x, int y, float ScaleX = 1, float ScaleY = 1);
|
||||
void spriteBlend(int key, int x, int y, float ScaleX = 1, float ScaleY = 1);
|
||||
void DrawArrow(int x, int y, float rotation = 0, int arrowSprite = 0);
|
||||
void drawAnimatedSelector(float xPos, float yPos, float Width, float Height, float speed = .060, u32 colour = C2D_Color32(0, 0, 0, 0));
|
||||
|
||||
// Misc.
|
||||
bool Draw_Rect(float x, float y, float w, float h, u32 color);
|
||||
|
||||
@@ -136,6 +136,28 @@ void Gui::DrawArrow(int x, int y, float rotation, int arrowSprite) {
|
||||
C2D_DrawSpriteTinted(&sprite, &tint);
|
||||
}
|
||||
|
||||
void Gui::drawAnimatedSelector(float xPos, float yPos, float Width, float Height, float speed, u32 colour)
|
||||
{
|
||||
static constexpr int w = 2;
|
||||
static float timer = 0.0f;
|
||||
float highlight_multiplier = fmax(0.0, fabs(fmod(timer, 1.0) - 0.5) / 0.5);
|
||||
u8 r = Config::SelectedColor & 0xFF;
|
||||
u8 g = (Config::SelectedColor >> 8) & 0xFF;
|
||||
u8 b = (Config::SelectedColor >> 16) & 0xFF;
|
||||
u32 color = C2D_Color32(r + (255 - r) * highlight_multiplier, g + (255 - g) * highlight_multiplier, b + (255 - b) * highlight_multiplier, 255);
|
||||
|
||||
// BG Color for the Selector.
|
||||
C2D_DrawRectSolid(xPos, yPos, 0.5, Width, Height, colour); // Black.
|
||||
|
||||
// Animated Selector part.
|
||||
C2D_DrawRectSolid(xPos, yPos, 0.5, Width, w, color); // top
|
||||
C2D_DrawRectSolid(xPos, yPos + w, 0.5, w, Height - 2 * w, color); // left
|
||||
C2D_DrawRectSolid(xPos + Width - w, yPos + w, 0.5, w, Height - 2 * w, color); // right
|
||||
C2D_DrawRectSolid(xPos, yPos + Height - w, 0.5, Width, w, color); // bottom
|
||||
|
||||
timer += speed; // Speed of the animation. Example : .030 / .060
|
||||
}
|
||||
|
||||
void Gui::DisplayWarnMsg(std::string Text)
|
||||
{
|
||||
Gui::clearTextBufs();
|
||||
|
||||
@@ -53,10 +53,9 @@ void MainMenu::Draw(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
if (Selection == i) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,10 +141,9 @@ void ScriptBrowse::Draw(void) const {
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)infoJson.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
if(screenPos + i == selection) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, Config::SelectedColor);
|
||||
}
|
||||
|
||||
if(infoJson[screenPos+i]["curRevision"] < infoJson[screenPos+i]["revision"]) {
|
||||
@@ -157,12 +156,10 @@ void ScriptBrowse::Draw(void) const {
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)infoJson.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
if(screenPosList + i == selection) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, Config::SelectedColor);
|
||||
}
|
||||
|
||||
if(infoJson[screenPosList+i]["curRevision"] < infoJson[screenPosList+i]["revision"]) {
|
||||
Gui::Draw_Rect(302, ((i+1)*27)+7, 11, 11, C2D_Color32(0xfb, 0x5b, 0x5b, 255));
|
||||
} else {
|
||||
|
||||
@@ -281,10 +281,9 @@ void ScriptList::DrawSubMenu(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::UnselectedColor);
|
||||
if (SubSelection == i) {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,23 +318,21 @@ void ScriptList::DrawList(void) const {
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
line1 = fileInfo[screenPos + i].title;
|
||||
line2 = fileInfo[screenPos + i].author;
|
||||
if(screenPos + i == selection) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
line1 = fileInfo[screenPosList + i].title;
|
||||
if(screenPosList + i == selection) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, line1, 320);
|
||||
}
|
||||
@@ -383,22 +380,20 @@ void ScriptList::DrawSingleObject(void) const {
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo2.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, unselected);
|
||||
info = fileInfo2[screenPos2 + i];
|
||||
if(screenPos2 + i == selection2) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, selected);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, unselected);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, selected);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, TextColor, info, 320);
|
||||
}
|
||||
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)fileInfo2.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, unselected);
|
||||
info = fileInfo2[screenPosList2 + i];
|
||||
if(screenPosList2 + i == selection2) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, selected);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, unselected);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, selected);
|
||||
}
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, TextColor, info, 320);
|
||||
}
|
||||
|
||||
@@ -64,10 +64,9 @@ void Settings::DrawSubMenu(void) const {
|
||||
Gui::DrawArrow(318, 240, 180.0, 1);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
if (Selection == i) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +86,9 @@ void Settings::DrawLanguageSelection(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int language = 0; language < 10; language++) {
|
||||
Gui::Draw_Rect(langBlocks[language].x, langBlocks[language].y, langBlocks[language].w, langBlocks[language].h, Config::UnselectedColor);
|
||||
if (Config::lang == language) {
|
||||
Gui::Draw_Rect(langBlocks[language].x, langBlocks[language].y, langBlocks[language].w, langBlocks[language].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(langBlocks[language].x, langBlocks[language].y, langBlocks[language].w, langBlocks[language].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(langBlocks[language].x, langBlocks[language].y, langBlocks[language].w, langBlocks[language].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +136,7 @@ void Settings::DrawColorChanging(void) const {
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (colorMode == i) {
|
||||
Gui::Draw_Rect(54 + i * 25, 2, 16, 16, C2D_Color32(140, 140, 140, 255));
|
||||
Gui::drawAnimatedSelector(54 + i * 25, 2, 16, 16, .060, C2D_Color32(140, 140, 140, 255));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,10 +198,9 @@ void Settings::DrawMiscSettings(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
if (Selection == i) {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-14
@@ -198,10 +198,9 @@ void UniStore::DrawSubMenu(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::UnselectedColor);
|
||||
if (subSelection == i) {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(subPos[i].x, subPos[i].y, subPos[i].w, subPos[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,23 +237,21 @@ void UniStore::DrawStoreList(void) const {
|
||||
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)storeInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
line1 = storeInfo[screenPos + i].title;
|
||||
line2 = storeInfo[screenPos + i].author;
|
||||
if(screenPos + i == selection) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 38+(i*57), 0.7f, Config::TxtColor, line1, 320);
|
||||
Gui::DrawStringCentered(0, 62+(i*57), 0.7f, Config::TxtColor, line2, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)storeInfo.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
line1 = storeInfo[screenPosList + i].title;
|
||||
if(screenPosList + i == selection) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, line1, 320);
|
||||
}
|
||||
@@ -323,7 +320,7 @@ void UniStore::DrawStore(void) const {
|
||||
if (appStoreJson.at("storeInfo").contains("buttonLarge") && sheetHasLoaded == true) {
|
||||
drawNormal(appStoreJson["storeInfo"]["buttonLarge"], 0, 40+(i*57));
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, selected);
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, selected);
|
||||
}
|
||||
} else {
|
||||
if (appStoreJson.at("storeInfo").contains("buttonLarge") && sheetHasLoaded == true) {
|
||||
@@ -341,7 +338,7 @@ void UniStore::DrawStore(void) const {
|
||||
if (appStoreJson.at("storeInfo").contains("buttonSmall") && sheetHasLoaded == true) {
|
||||
drawNormal(appStoreJson["storeInfo"]["buttonSmall"], 0, (i+1)*27);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, selected);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, selected);
|
||||
}
|
||||
} else {
|
||||
if (appStoreJson.at("storeInfo").contains("buttonSmall") && sheetHasLoaded == true) {
|
||||
@@ -882,10 +879,9 @@ void UniStore::DrawSearch(void) const {
|
||||
Gui::DrawArrow(0, 218, 0, 1);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Gui::Draw_Rect(URLBtn[i].x, URLBtn[i].y, URLBtn[i].w, URLBtn[i].h, Config::UnselectedColor);
|
||||
if (searchSelection == i) {
|
||||
Gui::Draw_Rect(URLBtn[i].x, URLBtn[i].y, URLBtn[i].w, URLBtn[i].h, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(URLBtn[i].x, URLBtn[i].y, URLBtn[i].w, URLBtn[i].h, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(URLBtn[i].x, URLBtn[i].y, URLBtn[i].w, URLBtn[i].h, .060, Config::SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -238,21 +238,19 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
|
||||
Gui::DrawBottom();
|
||||
if (Config::viewMode == 0) {
|
||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)dirContents.size();i++) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::UnselectedColor);
|
||||
dirs = dirContents[screenPos + i].name;
|
||||
if(screenPos + i == selectedFile) {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, C2D_Color32(120, 192, 216, 255));
|
||||
} else {
|
||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, C2D_Color32(77, 118, 132, 255));
|
||||
Gui::drawAnimatedSelector(0, 40+(i*57), 320, 45, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, 50+(i*57), 0.7f, WHITE, dirs, 320);
|
||||
}
|
||||
} else if (Config::viewMode == 1) {
|
||||
for(int i=0;i<ENTRIES_PER_LIST && i<(int)dirContents.size();i++) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
dirs = dirContents[screenPosList + i].name;
|
||||
if(screenPosList + i == selectedFile) {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::SelectedColor);
|
||||
} else {
|
||||
Gui::Draw_Rect(0, (i+1)*27, 320, 25, Config::UnselectedColor);
|
||||
Gui::drawAnimatedSelector(0, (i+1)*27, 320, 25, .060, Config::SelectedColor);
|
||||
}
|
||||
Gui::DrawStringCentered(0, ((i+1)*27)+1, 0.7f, Config::TxtColor, dirs, 320);
|
||||
}
|
||||
@@ -279,7 +277,6 @@ std::string selectFilePath(std::string selectText, const std::vector<std::string
|
||||
C3D_FrameEnd(0);
|
||||
|
||||
// The input part.
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
hidTouchRead(&touch);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user