diff --git a/README.md b/README.md index 4fe935fd..f5000573 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,10 @@ To update to the latest version, use `git submodule update --remote ` from the t # Generate documentation Run `doxygen` from the dev container terminal. Make sure you fix the warnings before creating a PR! + + +# OSS licenses used for libraries +* UNLICENSE (libdragon) +* BSD 2-Clause (libspng) +* CC0 1.0 Universal (minimp3) +* Permissive, unspecific (miniz) diff --git a/src/menu/menu_res_setup.h b/src/menu/menu_res_setup.h deleted file mode 100644 index 48ccea39..00000000 --- a/src/menu/menu_res_setup.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file menu_res_setup.h - * @brief Menu Resolution (non RDPQ) - * @ingroup menu - */ - -#ifndef MENU_RES_SETUP_H__ -#define MENU_RES_SETUP_H__ - -#include - -static const int16_t font_vertical_pixels = 8; -static const int16_t overscan_vertical_pixels = 24; -static const int16_t vertical_start_position = overscan_vertical_pixels / 2; - -static const int16_t font_horizontal_pixels = 8; -static const int16_t overscan_horizontal_pixels = 32; -static const int16_t horizontal_start_position = overscan_horizontal_pixels + font_horizontal_pixels; -static const int16_t horizontal_indent = horizontal_start_position + (font_horizontal_pixels * 2); - -#endif diff --git a/src/menu/views/credits.c b/src/menu/views/credits.c index a81b24d8..ac5eb26e 100644 --- a/src/menu/views/credits.c +++ b/src/menu/views/credits.c @@ -1,11 +1,11 @@ #include -#include "../menu_res_setup.h" +#include "fragments/fragments.h" #include "views.h" #ifndef MENU_VERSION -#define MENU_VERSION "0.0.0.4" +#define MENU_VERSION "0.0.0.5.ALPHA" #endif @@ -16,37 +16,52 @@ static void process (menu_t *menu) { } static void draw (menu_t *menu, surface_t *d) { - graphics_fill_screen(d, 0x00); + layout_t *layout = layout_get(); - graphics_draw_text(d, (d->width / 2) - 64, vertical_start_position, "MENU INFORMATION"); // centre = numchars * font_horizontal_pixels / 2 - graphics_draw_line(d, 0, 30, d->width, 30, 0xff); + const int text_x = layout->offset_x + layout->offset_text_x; + int text_y = layout->offset_y + layout->offset_text_y; - int16_t vertical_position = 40; + const color_t bg_color = RGBA32(0x00, 0x00, 0x00, 0xFF); + const color_t text_color = RGBA32(0xFF, 0xFF, 0xFF, 0xFF); - graphics_draw_text(d, horizontal_start_position, vertical_position, "Menu Revision: V"); - graphics_draw_text(d, horizontal_start_position + 16 * 8, vertical_position, MENU_VERSION); - vertical_position += (font_vertical_pixels * 2); - graphics_draw_text(d, horizontal_start_position, vertical_position, "Authors:"); - graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "JonesAlmighty / NetworkFusion"); - graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "korgeaux / Polprzewodnikowy"); - vertical_position += (font_vertical_pixels * 2); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, "Credits:"); - graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "N64Brew / libdragon contributors."); - vertical_position += (font_vertical_pixels * 2); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, "Github:"); - // graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "https://github.com/Polprzewodnikowy/SummerCart64"); - graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "https://github.com/Polprzewodnikowy/N64FlashcartMenu"); - graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "https://github.com/NetworkFusion/N64FlashcartMenu"); - //graphics_draw_text(d, horizontal_indent, vertical_position += font_vertical_pixels, "https://github.com/dragonminded/libdragon"); - vertical_position += (font_vertical_pixels * 2); - graphics_draw_text(d, horizontal_start_position, vertical_position, "OSS licenses used:"); - graphics_draw_text(d, horizontal_indent,vertical_position += font_vertical_pixels, "UNLICENSE"); - graphics_draw_text(d, horizontal_indent,vertical_position += font_vertical_pixels, "MIT"); + rdpq_attach(d, NULL); + rdpq_clear(bg_color); - graphics_draw_line(d, 0, d->height - overscan_vertical_pixels - font_vertical_pixels, d->width,d->height - overscan_vertical_pixels - font_vertical_pixels, 0xff); - graphics_draw_text(d, (d->width / 2) - 80,d->height - overscan_vertical_pixels, "Press (B) to return!"); // centre = numchars * font_horizontal_pixels / 2 + // Layout + fragment_borders(d); - display_show(d); + // Text start + fragment_text_start(text_color); + + text_y += fragment_textf((d->width / 2) - 76, text_y, "MENU INFORMATION"); + + text_y += fragment_textf(text_x, text_y, "\n"); + + text_y += fragment_textf(text_x, text_y, "Menu Revision: V%s", MENU_VERSION); + text_y += fragment_textf(text_x, text_y, "\n"); + text_y += fragment_textf(text_x, text_y, "Authors:"); + text_y += fragment_textf(text_x, text_y, " JonesAlmighty / NetworkFusion"); + text_y += fragment_textf(text_x, text_y, " korgeaux / Polprzewodnikowy"); + text_y += fragment_textf(text_x, text_y, "\n"); + text_y += fragment_textf(text_x, text_y, "Credits:"); + text_y += fragment_textf(text_x, text_y, " N64Brew / libdragon contributors."); + text_y += fragment_textf(text_x, text_y, "\n"); + text_y += fragment_textf(text_x, text_y, "Github:"); + text_y += fragment_textf(text_x, text_y, " https://github.com/Polprzewodnikowy/N64FlashcartMenu"); + text_y += fragment_textf(text_x, text_y, "\n"); + text_y += fragment_textf(text_x, text_y, "OSS licenses used:"); + text_y += fragment_textf(text_x, text_y, " UNLICENSE"); /* libdragon license */ + text_y += fragment_textf(text_x, text_y, " MIT"); + text_y += fragment_textf(text_x, text_y, " BSD 2-Clause"); /* libspng license */ + text_y += fragment_textf(text_x, text_y, " CC0 1.0 Universal"); /* minimp3 license */ + // text_y += fragment_textf(text_x, text_y, " Permissive, unspecific"); /* miniz license */ + + + // Actions bar + text_y = layout->actions_y + layout->offset_text_y; + text_y += fragment_textf(text_x, text_y, "B: Exit"); + + rdpq_detach_show(); } diff --git a/src/menu/views/error.c b/src/menu/views/error.c index d096bcb5..cf14dd91 100644 --- a/src/menu/views/error.c +++ b/src/menu/views/error.c @@ -1,6 +1,5 @@ #include -#include "../menu_res_setup.h" #include "views.h" @@ -13,7 +12,7 @@ static void process (menu_t *menu) { static void draw (menu_t *menu, surface_t *d) { graphics_fill_screen(d, graphics_make_color(0, 0, 0, 255)); - graphics_draw_text(d, overscan_horizontal_pixels, overscan_vertical_pixels, "ERROR!"); + graphics_draw_text(d, 40, 32, "ERROR!"); display_show(d); } diff --git a/src/menu/views/file_info.c b/src/menu/views/file_info.c index 0c37c75d..d4b36ba4 100644 --- a/src/menu/views/file_info.c +++ b/src/menu/views/file_info.c @@ -5,6 +5,7 @@ #include "../png_decoder.h" #include "../rom_database.h" #include "fragments/fragments.h" +#include "utils/fs.h" #include "utils/str_utils.h" #include "views.h" @@ -14,6 +15,7 @@ static FILINFO info; +static const char *n64_rom_extensions[] = { "z64", "n64", "v64", NULL }; static rom_header_t rom_header; static surface_t *boxart_image; static rspq_block_t *cached_boxart_image_dl; @@ -316,8 +318,7 @@ static void draw (menu_t *menu, surface_t *d) { fragment_text_start(text_color); - if (strcmp(format_file_type(), "N64 ROM") == 0) { - + if (file_has_extensions(info.fname, n64_rom_extensions)) { menu_fileinfo_draw_n64_rom_info(d, layout); } else { @@ -359,7 +360,7 @@ void view_file_info_init (menu_t *menu) { if (f_stat(path_get(file), &info) != FR_OK) { menu->next_mode = MENU_MODE_ERROR; } - if (strcmp(format_file_type(), "N64 ROM") == 0) { + if (file_has_extensions(info.fname, n64_rom_extensions)) { rom_header = file_read_rom_header(path_get(file)); boxart_image_load(rom_header.metadata.unique_identifier); diff --git a/src/menu/views/system_info.c b/src/menu/views/system_info.c index 5b802f29..536160c7 100644 --- a/src/menu/views/system_info.c +++ b/src/menu/views/system_info.c @@ -1,8 +1,7 @@ #include - #include -#include "../menu_res_setup.h" +#include "fragments/fragments.h" #include "views.h" @@ -30,66 +29,70 @@ static void process (menu_t *menu) { } static void draw (menu_t *menu, surface_t *d) { - char str_buffer[512]; - graphics_fill_screen(d, 0x00); + layout_t *layout = layout_get(); - graphics_draw_text(d, (d->width / 2) - 64, vertical_start_position, "N64 SYSTEM INFORMATION"); // centre = numchars * font_horizontal_pixels / 2 - graphics_draw_line(d, 0, 30, d->width, 30, 0xff); + const int text_x = layout->offset_x + layout->offset_text_x; + int text_y = layout->offset_y + layout->offset_text_y; + + const color_t bg_color = RGBA32(0x00, 0x00, 0x00, 0xFF); + const color_t text_color = RGBA32(0xFF, 0xFF, 0xFF, 0xFF); + + rdpq_attach(d, NULL); + rdpq_clear(bg_color); + + // Layout + fragment_borders(d); + + // Text start + fragment_text_start(text_color); + + text_y += fragment_textf((d->width / 2) - 108, text_y, "N64 SYSTEM INFORMATION\n\n"); + + text_y += fragment_textf(text_x, text_y, "\n"); - int16_t vertical_position = 40; time_t current_time = -1; current_time = time( NULL ); if( current_time != -1 ) { - sprintf(str_buffer, "Current date & time: %s\n\n", ctime( ¤t_time )); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, "To change the time, use USB App..."); + text_y += fragment_textf(text_x, text_y, "Current date & time: %s\n\n", ctime( ¤t_time )); + text_y += fragment_textf(text_x, text_y, "To change the time, use USB App..."); } - vertical_position += font_vertical_pixels; + text_y += fragment_textf(text_x, text_y, "\n"); - sprintf(str_buffer, "Expansion PAK is %sinserted\n", is_memory_expanded() ? "" : "not " ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); + text_y += fragment_textf(text_x, text_y, "Expansion PAK is %sinserted\n", is_memory_expanded() ? "" : "not " ); - vertical_position += font_vertical_pixels; + text_y += fragment_textf(text_x, text_y, "\n"); int controllers = get_controllers_present(); - sprintf(str_buffer, "JoyPad 1 is %sconnected\n", (controllers & CONTROLLER_1_INSERTED) ? "" : "not " ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 2 is %sconnected\n", (controllers & CONTROLLER_2_INSERTED) ? "" : "not " ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 3 is %sconnected\n", (controllers & CONTROLLER_3_INSERTED) ? "" : "not " ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 4 is %sconnected\n", (controllers & CONTROLLER_4_INSERTED) ? "" : "not " ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); + text_y += fragment_textf(text_x, text_y, "JoyPad 1 is %sconnected\n", (controllers & CONTROLLER_1_INSERTED) ? "" : "not " ); + text_y += fragment_textf(text_x, text_y, "JoyPad 2 is %sconnected\n", (controllers & CONTROLLER_2_INSERTED) ? "" : "not " ); + text_y += fragment_textf(text_x, text_y, "JoyPad 3 is %sconnected\n", (controllers & CONTROLLER_3_INSERTED) ? "" : "not " ); + text_y += fragment_textf(text_x, text_y, "JoyPad 4 is %sconnected\n", (controllers & CONTROLLER_4_INSERTED) ? "" : "not " ); - vertical_position += font_vertical_pixels; + text_y += fragment_textf(text_x, text_y, "\n"); struct controller_data output; int accessories = get_accessories_present( &output ); - sprintf(str_buffer, "JoyPad 1 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_1_INSERTED) ? "" : "not ", + text_y += fragment_textf(text_x, text_y, "JoyPad 1 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_1_INSERTED) ? "" : "not ", (accessories & CONTROLLER_1_INSERTED) ? accessory_type_s( identify_accessory( 0 ) ) : "" ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 2 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_2_INSERTED) ? "" : "not ", + text_y += fragment_textf(text_x, text_y, "JoyPad 2 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_2_INSERTED) ? "" : "not ", (accessories & CONTROLLER_2_INSERTED) ? accessory_type_s( identify_accessory( 1 ) ) : "" ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 3 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_3_INSERTED) ? "" : "not ", + text_y += fragment_textf(text_x, text_y, "JoyPad 3 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_3_INSERTED) ? "" : "not ", (accessories & CONTROLLER_3_INSERTED) ? accessory_type_s( identify_accessory( 2 ) ) : "" ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - sprintf(str_buffer, "JoyPad 4 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_4_INSERTED) ? "" : "not ", + text_y += fragment_textf(text_x, text_y, "JoyPad 4 Accessory Pak is %sinserted %s\n", (accessories & CONTROLLER_4_INSERTED) ? "" : "not ", (accessories & CONTROLLER_4_INSERTED) ? accessory_type_s( identify_accessory( 3 ) ) : "" ); - graphics_draw_text(d, horizontal_start_position, vertical_position += font_vertical_pixels, str_buffer); - graphics_draw_line(d, 0, d->height - overscan_vertical_pixels - font_vertical_pixels, d->width,d->height - overscan_vertical_pixels - font_vertical_pixels, 0xff); - graphics_draw_text(d, (d->width / 2) - 80,d->height - overscan_vertical_pixels, "Press (B) to return!"); // centre = numchars * font_horizontal_pixels / 2 + // Actions bar + text_y = layout->actions_y + layout->offset_text_y; + text_y += fragment_textf(text_x, text_y, "B: Exit"); - display_show(d); + rdpq_detach_show(); }