From 8e43bb1a74874f6d685d8b850a21c0ec5488a53e Mon Sep 17 00:00:00 2001 From: LiquidFenrir Date: Thu, 10 May 2018 18:52:14 +0200 Subject: [PATCH] Shuffle without bgm (#157) * add ability to shuffle without bgm press B twice * add license thingy for icons8, and thanks for their amazing icons --- README.md | 2 ++ include/common.h | 1 + include/loading.h | 1 + romfs/shuffle_no_bgm.png | Bin 0 -> 511 bytes source/draw.c | 6 +++++- source/main.c | 21 ++++++++++++++++++--- source/themes.c | 26 +++++++++++++++++++------- 7 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 romfs/shuffle_no_bgm.png diff --git a/README.md b/README.md index ab70650..49f76a1 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ This project is licensed under the GNU GPLv3. See LICENSE.md for details. Additi # Credits The following people contributed to Anemone3DS in some way. Without these people, Anemone3DS wouldn't exist, or wouldn't be as good as it is: [CONTRIBUTORS.md](CONTRIBUTORS.md) +Most of the icons under `romfs` are from the site [icons8.com](https://icons8.com) and are licensed under the [CC-BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/3.0/) + Special thanks go to these people who, whilst not directly contributing, helped immensely: * [Rinnegatamante](https://github.com/Rinnegatamante), whose code served as reference on theme installation. * [SteveIce10](https://github.com/SteveIce10), whose QR code in FBI was essential. diff --git a/include/common.h b/include/common.h index 75429e9..95d088a 100644 --- a/include/common.h +++ b/include/common.h @@ -60,6 +60,7 @@ enum TextureID { TEXTURE_ARROW, TEXTURE_ARROW_SIDE, TEXTURE_SHUFFLE, + TEXTURE_SHUFFLE_NO_BGM, TEXTURE_INSTALLED, TEXTURE_PREVIEW_ICON, TEXTURE_SORT, diff --git a/include/loading.h b/include/loading.h index 68d4b00..a1fbcee 100644 --- a/include/loading.h +++ b/include/loading.h @@ -71,6 +71,7 @@ typedef struct { bool is_zip; bool in_shuffle; + bool no_bgm_shuffle; bool installed; json_int_t tp_download_id; diff --git a/romfs/shuffle_no_bgm.png b/romfs/shuffle_no_bgm.png new file mode 100644 index 0000000000000000000000000000000000000000..d5ff7329f7f0f545dd09a0234189b3536408bc9e GIT binary patch literal 511 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0hCEZK~zXf-IcvA zL{SulZ=%!?e?3zuB?_bQ0$xC;mZ&ufItmGiQm0Z#B*Hv{3K5k~Awgv-mASrktot+9 z+&foH!HxB)!^OL1Cb9&pg*M=Zsi}Lf3<(Xa)t&~@Te<< zyLhH%EJ+K02%LwOGQyTV@G$>ztx@76EC4KX_T5{`(4Y=HE{42>1;BmSp0=fo@VX`} z$cLxR1UsvnTu$qrCP3D zr+Vv~!4${y>idH6TZl(hAuGX97v6V;SPqnh{21P+A(pg!k=j9e`entry_size+6, vertical_offset + 16, 0.55, 0.55, font_color, name); - if(current_entry->in_shuffle) + if(current_entry->no_bgm_shuffle) + pp2d_draw_texture_blend(TEXTURE_SHUFFLE_NO_BGM, 320-24-4, vertical_offset, font_color); + else if(current_entry->in_shuffle) pp2d_draw_texture_blend(TEXTURE_SHUFFLE, 320-24-4, vertical_offset, font_color); + if(current_entry->installed) pp2d_draw_texture_blend(TEXTURE_INSTALLED, 320-24-4, vertical_offset + 22, font_color); diff --git a/source/main.c b/source/main.c index 14d732f..0c9590d 100644 --- a/source/main.c +++ b/source/main.c @@ -286,9 +286,24 @@ static void change_selected(Entry_List_s * list, int change_value) static void toggle_shuffle(Entry_List_s * list) { Entry_s * current_entry = &list->entries[list->selected_entry]; - if(current_entry->in_shuffle) list->shuffle_count--; - else list->shuffle_count++; - current_entry->in_shuffle = !current_entry->in_shuffle; + if(current_entry->in_shuffle) + { + if(current_entry->no_bgm_shuffle) + { + current_entry->in_shuffle = false; + current_entry->no_bgm_shuffle = false; + list->shuffle_count--; + } + else + { + current_entry->no_bgm_shuffle = true; + } + } + else + { + current_entry->in_shuffle = true; + list->shuffle_count++; + } } int main(void) diff --git a/source/themes.c b/source/themes.c index 6fd1290..ee45fe5 100644 --- a/source/themes.c +++ b/source/themes.c @@ -100,13 +100,22 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) { char bgm_cache_path[26] = {0}; sprintf(bgm_cache_path, "/BgmCache_%.2i.bin", shuffle_count); - music_size = load_data("/bgm.bcstm", *current_theme, &music); - if(music_size > BGM_MAX_SIZE) + if(current_theme->no_bgm_shuffle) { - free(music); - DEBUG("bgm too big\n"); - return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_TOO_LARGE); + music = NULL; + music_size = 0; + } + else + { + music_size = load_data("/bgm.bcstm", *current_theme, &music); + + if(music_size > BGM_MAX_SIZE) + { + free(music); + DEBUG("bgm too big\n"); + return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_TOO_LARGE); + } } shuffle_music_sizes[shuffle_count] = music_size; @@ -116,8 +125,11 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) FSUSER_OpenFile(&bgm_cache_handle, ArchiveThemeExt, fsMakePath(PATH_ASCII, bgm_cache_path), FS_OPEN_WRITE, 0); padded = calloc(BGM_MAX_SIZE, sizeof(char)); - memcpy(padded, music, music_size); - free(music); + if(!current_theme->no_bgm_shuffle) + { + memcpy(padded, music, music_size); + free(music); + } FSFILE_Write(bgm_cache_handle, NULL, 0, padded, BGM_MAX_SIZE, FS_WRITE_FLUSH);