mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-21 18:19:19 +01:00
about menu improvements
This commit is contained in:
parent
4c6a030d29
commit
bae2ace376
2
Makefile
2
Makefile
@ -17,6 +17,8 @@ SRCS = \
|
||||
flashcart/sc64/sc64_internal.c \
|
||||
flashcart/sc64/sc64.c \
|
||||
menu/menu_main.c \
|
||||
menu/menu_info.c \
|
||||
menu/menu_test.c \
|
||||
menu/settings.c \
|
||||
utils/fs.c \
|
||||
libs/toml/toml.c \
|
||||
|
38
src/menu/menu_info.c
Normal file
38
src/menu/menu_info.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include <libdragon.h>
|
||||
|
||||
static void draw_header(display_context_t disp) {
|
||||
graphics_draw_text(disp, 200-70, 10, "Menu Information");
|
||||
}
|
||||
|
||||
|
||||
void menu_info(void) {
|
||||
display_init(RESOLUTION_512x240, DEPTH_16_BPP, 3, GAMMA_NONE, ANTIALIAS_RESAMPLE);
|
||||
display_context_t disp = display_lock();
|
||||
graphics_fill_screen(disp, 0);
|
||||
draw_header(disp);
|
||||
|
||||
graphics_draw_text(disp, 30, 50, "Authors:");
|
||||
graphics_draw_text(disp, 30, 58, "JonesAlmighty / Networkfusion");
|
||||
graphics_draw_text(disp, 30, 66, "korgeaux / Polprzewodnikowy");
|
||||
|
||||
graphics_draw_text(disp, 30, 80, "Github:");
|
||||
graphics_draw_text(disp, 30, 88, "https://github.com/Polprzewodnikowy/SummerCart64");
|
||||
graphics_draw_text(disp, 30, 96, "https://github.com/Polprzewodnikowy/N64FlashcartMenu");
|
||||
|
||||
graphics_draw_text(disp, 30,112, "OSS licenses used:");
|
||||
graphics_draw_text(disp, 30,120, "GPL");
|
||||
graphics_draw_text(disp, 30,128, "MIT");
|
||||
|
||||
graphics_draw_text(disp, 30,144, "Press B to return!");
|
||||
|
||||
display_show(disp);
|
||||
|
||||
for (;;) {
|
||||
controller_scan();
|
||||
struct controller_data ckeys = get_keys_down();
|
||||
|
||||
if (ckeys.c[0].B) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
6
src/menu/menu_info.h
Normal file
6
src/menu/menu_info.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MENU_INFO_H__
|
||||
#define MENU_INFO_H__
|
||||
|
||||
void menu_info(void);
|
||||
|
||||
#endif
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "settings.h"
|
||||
#include "menu_main.h"
|
||||
#include "menu_info.h"
|
||||
#include "menu_test.h"
|
||||
|
||||
// FIXME: use newlib rather than fatfs to do this!
|
||||
FRESULT scan_file_path (char* path) {
|
||||
@ -46,7 +48,7 @@ FRESULT scan_file_path (char* path) {
|
||||
|
||||
void menu_main_refresh (char *dir_path) {
|
||||
console_clear();
|
||||
printf("N64 Flashcart Menu\n\n");
|
||||
printf("N64 Flashcart Menu V0.0.0\n\n");
|
||||
printf("SD Card Directory list:\n\n");
|
||||
scan_file_path(dir_path);
|
||||
}
|
||||
@ -59,26 +61,26 @@ void menu_main_init (settings_t *settings) {
|
||||
|
||||
controller_init();
|
||||
|
||||
controller_scan();
|
||||
struct controller_data joypad = get_keys_down();
|
||||
|
||||
// TODO: wait for a key input
|
||||
if ((settings->last_state.auto_load_last_rom) && !(joypad.c[0].B)) { // FIXME: the B button on any controller!
|
||||
printf("Loading last ROM: %s\n", settings->last_rom.rom_path);
|
||||
assertf(flashcart_load_rom(settings->last_rom.rom_path) == FLASHCART_OK, "ROM load error");
|
||||
|
||||
if (settings->last_state.auto_load_last_rom) { // TODO: check if there is a button input to cancel.
|
||||
|
||||
printf("Loading last ROM: %s\n", settings->last_rom.rom_path);
|
||||
assertf(flashcart_load_rom(settings->last_rom.rom_path) == FLASHCART_OK, "ROM load error");
|
||||
|
||||
printf("Loading save: %s, type: %d, writeback: %d\n", settings->last_rom.save_path, settings->last_rom.save_type, settings->last_rom.save_writeback);
|
||||
assertf(flashcart_load_save(settings->last_rom.save_path, settings->last_rom.save_type, settings->last_rom.save_writeback) == FLASHCART_OK, "Save load error");
|
||||
printf("Loading save: %s, type: %d, writeback: %d\n", settings->last_rom.save_path, settings->last_rom.save_type, settings->last_rom.save_writeback);
|
||||
assertf(flashcart_load_save(settings->last_rom.save_path, settings->last_rom.save_type, settings->last_rom.save_writeback) == FLASHCART_OK, "Save load error");
|
||||
}
|
||||
else {
|
||||
settings->last_state.auto_load_last_rom = false;
|
||||
menu_main_refresh(settings->last_state.current_directory);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
controller_scan();
|
||||
struct controller_data ckeys = get_keys_down();
|
||||
joypad = get_keys_down();
|
||||
|
||||
if (ckeys.c[0].A) {
|
||||
if (joypad.c[0].A) {
|
||||
console_clear();
|
||||
printf("TODO: loading ROM...\n");
|
||||
wait_ms(1000);
|
||||
@ -86,6 +88,16 @@ void menu_main_init (settings_t *settings) {
|
||||
wait_ms(1000);
|
||||
menu_main_refresh(settings->last_state.current_directory);
|
||||
}
|
||||
if (joypad.c[0].start) { // FIXME: the START button on any controller!
|
||||
console_clear();
|
||||
menu_info();
|
||||
menu_main_refresh(settings->last_state.current_directory);
|
||||
}
|
||||
if (joypad.c[0].B) {
|
||||
console_clear();
|
||||
menu_test();
|
||||
menu_main_refresh(settings->last_state.current_directory);
|
||||
}
|
||||
}
|
||||
// TODO: write menu state to SD card
|
||||
|
||||
|
75
src/menu/menu_test.c
Normal file
75
src/menu/menu_test.c
Normal file
@ -0,0 +1,75 @@
|
||||
#include <libdragon.h>
|
||||
#include "libs/menu_utils/include/menu.h"
|
||||
|
||||
#include "menu_test.h"
|
||||
|
||||
|
||||
void menu_test(void) {
|
||||
// display_init(RESOLUTION_512x240, DEPTH_16_BPP, 3, GAMMA_NONE, ANTIALIAS_RESAMPLE);
|
||||
// display_context_t disp = display_lock();
|
||||
// -- initializing global variables used by every menu --
|
||||
|
||||
// main init function
|
||||
// (required to set default colors, can omit if setting colors using `menu_global_set_default_colors` or setting colors for items)
|
||||
// menu_global_init();
|
||||
|
||||
// // initializes the sprites and offsets used. only required if using them (when creating the menu)
|
||||
// // !!!menu_global_set_sprites(menu_sprite, hand_sprite, hand_sprite_offset);
|
||||
|
||||
// // optionally overriding the default colors
|
||||
// //uint32_t selected = graphics_make_color(0, 0, 0, 255);
|
||||
// //... ommiting the other colors, but you can use the function above to set each color
|
||||
// // !!!menu_global_set_default_colors(selected, enabled, disabled, background, out_of_bounds, menu_background);
|
||||
|
||||
// // -- now to create the menu... --
|
||||
|
||||
// // // callback to be used. it's optional, but improves code legibility when using sub-menus.
|
||||
// // void menu_callback(int option, MenuItem* item);
|
||||
|
||||
// Menu* menu;
|
||||
// // create a new menu (memory_pool can be NULL if not using it)
|
||||
// uint8_t total_items = 10; // max items that the menu can have
|
||||
// uint8_t max_items = 5; // max items that will be displayed at any time (if more than this, there will be scrolling)
|
||||
// int top = 100, left = 100; // positions on-screen of the menu
|
||||
// uint8_t item_height = 16; // height in pixels that each item will have (used to calculate background bottom and scrolling)
|
||||
// menu = menu_init(NULL, total_items, max_items, top, left, item_height, NULL); // not using callbacks
|
||||
// //menu = menu_init(NULL, total_items, max_items, top, left, item_height, &menu_callback); // using callbacks
|
||||
|
||||
// // add items
|
||||
// //bool enabled = true; // if the item can be selected or not. color can differ baed on colors set.
|
||||
// //void *object = &my_custom_object; // this can be held to be retrieved later for custom actions baed on selected item.
|
||||
|
||||
// // adding simple text items
|
||||
// //menu_add_item(menu, "Item 1", enabled, object); // with object
|
||||
// menu_add_item(menu, "Item 2", false, NULL); // no object here, forcing disabled
|
||||
|
||||
// // adding colored item (can use different colors for each item)
|
||||
// //uint32_t color_selected = graphics_make_color(0, 0, 0, 255);
|
||||
// // omitting other colors...
|
||||
// //menu_add_item_colored(menu, "Item 3", enabled, color_selected, color_enabled, color_disabled, object);
|
||||
|
||||
// // // adding item as an image instead of text
|
||||
// // sprite_t *custom_image_sprite; // custom sprite to be used by the item
|
||||
// // int sprite_index = 2; // index for the custom sprite
|
||||
// // menu_add_item_image(menu, custom_image_sprite, sprite_index, enabled, object);
|
||||
|
||||
// // ticks the menu to calculate changes to its state. should only be called when the menu is active.
|
||||
// //struct controller_data keys_down = get_keys_down(); // you should do this only once per frame in your normal code
|
||||
// //int selected_option = menu_tick(menu, &keys_down);
|
||||
// // if 'selected_option >= 0' then the corresponding item was selected and you can act accordingly.
|
||||
// // if using callbacks, 'selected_option' can also be '>= 0', but the function will also be called.
|
||||
|
||||
// // render the menu
|
||||
// menu_render(menu, disp);
|
||||
|
||||
// // -- optional set-up steps: --
|
||||
|
||||
// // // add hand cursor
|
||||
// // int hand_position_x = 105; // X position of the hand. this will never change.
|
||||
// // int hand_position_y_offset = 5; // offset in pixels to be applied to the sprite when rendering the hand.
|
||||
// // menu_set_hand(menu, hand_position_x, hand_position_y_offset);
|
||||
|
||||
// // add background
|
||||
// int menu_width = 200; // width in pixels of the menu. this will be the same regardless of the item width.
|
||||
// menu_set_background(menu, menu_width);
|
||||
}
|
6
src/menu/menu_test.h
Normal file
6
src/menu/menu_test.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MENU_TEST_H__
|
||||
#define MENU_TEST_H__
|
||||
|
||||
void menu_test(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user