mirror of https://github.com/parasyte/alt64
Add a way to delete files in the menu.
This commit is contained in:
parent
8afb574905
commit
481a811b04
69
src/main.c
69
src/main.c
|
@ -171,6 +171,7 @@ enum InputMap
|
||||||
mp3,
|
mp3,
|
||||||
abort_screen,
|
abort_screen,
|
||||||
control_screen,
|
control_screen,
|
||||||
|
delete_prompt,
|
||||||
};
|
};
|
||||||
enum InputMap input_mapping = file_manager;
|
enum InputMap input_mapping = file_manager;
|
||||||
|
|
||||||
|
@ -721,7 +722,10 @@ void drawBoxNumber(display_context_t disp, int box)
|
||||||
box_color = graphics_make_color(0x00, 0x60, 0x00, 0xC3);
|
box_color = graphics_make_color(0x00, 0x60, 0x00, 0xC3);
|
||||||
drawBox(20, 24, 277, 193, disp);
|
drawBox(20, 24, 277, 193, disp);
|
||||||
break; //filebrowser
|
break; //filebrowser
|
||||||
|
case 13:
|
||||||
|
box_color = graphics_make_color(0x60, 0x00, 0x00, 0xD3);
|
||||||
|
drawBox(28, 105, 260, 40, disp);
|
||||||
|
break; //delete
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3082,6 +3086,25 @@ void drawSet4(display_context_t disp)
|
||||||
graphics_draw_text(disp, 209, 100, "_");
|
graphics_draw_text(disp, 209, 100, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void showDeletePrompt(display_context_t disp)
|
||||||
|
{
|
||||||
|
while (!(disp = display_lock()))
|
||||||
|
;
|
||||||
|
new_scroll_pos(&cursor, &page, MAX_LIST, count);
|
||||||
|
clearScreen(disp);
|
||||||
|
display_dir(list, cursor, page, MAX_LIST, count, disp);
|
||||||
|
drawBoxNumber(disp, 13);
|
||||||
|
display_show(disp);
|
||||||
|
|
||||||
|
bool isdir = list[cursor].type == DT_DIR;
|
||||||
|
|
||||||
|
if (sound_on)
|
||||||
|
playSound(2 + isdir);
|
||||||
|
|
||||||
|
menu_delete(disp, isdir);
|
||||||
|
}
|
||||||
|
|
||||||
void showAboutScreen(display_context_t disp)
|
void showAboutScreen(display_context_t disp)
|
||||||
{
|
{
|
||||||
while (!(disp = display_lock()))
|
while (!(disp = display_lock()))
|
||||||
|
@ -3636,7 +3659,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (keys.c[0].L)
|
else if (keys.c[0].L && !keys.c[0].R)
|
||||||
{
|
{
|
||||||
switch (input_mapping)
|
switch (input_mapping)
|
||||||
{
|
{
|
||||||
|
@ -3688,7 +3711,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (keys.c[0].R)
|
else if (keys.c[0].R && !keys.c[0].L)
|
||||||
{
|
{
|
||||||
switch (input_mapping)
|
switch (input_mapping)
|
||||||
{
|
{
|
||||||
|
@ -4147,6 +4170,19 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (keys.c[0].R && keys.c[0].L)
|
||||||
|
{
|
||||||
|
switch (input_mapping)
|
||||||
|
{
|
||||||
|
case file_manager:
|
||||||
|
showDeletePrompt(disp);
|
||||||
|
input_mapping = delete_prompt;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (keys.c[0].A)
|
else if (keys.c[0].A)
|
||||||
{
|
{
|
||||||
switch (input_mapping)
|
switch (input_mapping)
|
||||||
|
@ -4313,6 +4349,32 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
input_mapping = file_manager;
|
input_mapping = file_manager;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case delete_prompt:
|
||||||
|
{
|
||||||
|
if (list[cursor].type != DT_DIR)
|
||||||
|
{
|
||||||
|
char name_file[256];
|
||||||
|
|
||||||
|
if (strcmp(pwd, "/") == 0)
|
||||||
|
sprintf(name_file, "/%s", list[cursor].filename);
|
||||||
|
else
|
||||||
|
sprintf(name_file, "%s/%s", pwd, list[cursor].filename);
|
||||||
|
|
||||||
|
f_unlink(name_file);
|
||||||
|
|
||||||
|
while (!(disp = display_lock()))
|
||||||
|
;
|
||||||
|
graphics_set_color(graphics_make_color(0xFF, 0xFF, 0xFF, 0xFF), graphics_make_color(0x00, 0x00, 0x00, 0x00));
|
||||||
|
new_scroll_pos(&cursor, &page, MAX_LIST, count);
|
||||||
|
clearScreen(disp);
|
||||||
|
display_show(disp);
|
||||||
|
|
||||||
|
input_mapping = file_manager;
|
||||||
|
readSDcard(disp, pwd);
|
||||||
|
display_show(disp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4392,6 +4454,7 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mempak_menu:
|
case mempak_menu:
|
||||||
|
case delete_prompt:
|
||||||
|
|
||||||
while (!(disp = display_lock()))
|
while (!(disp = display_lock()))
|
||||||
;
|
;
|
||||||
|
|
|
@ -29,30 +29,5 @@ void menu_about(display_context_t disp)
|
||||||
printText("Conle Z: Page 2", 9, -1, disp);
|
printText("Conle Z: Page 2", 9, -1, disp);
|
||||||
printText("AriaHiro64", 9, -1, disp);
|
printText("AriaHiro64", 9, -1, disp);
|
||||||
printText("moparisthebest", 9, -1, disp);
|
printText("moparisthebest", 9, -1, disp);
|
||||||
|
printText("Skawo", 9, -1, disp);
|
||||||
} //TODO: make scrolling text, should include libraries used.
|
} //TODO: make scrolling text, should include libraries used.
|
||||||
void menu_controls(display_context_t disp)
|
|
||||||
{
|
|
||||||
printText(" - Controls -", 4, 4, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" L: brings up the mempak", 4, -1, disp);
|
|
||||||
printText(" menu", 5, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" Z: about screen", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" A: start rom/directory", 4, -1, disp);
|
|
||||||
printText(" mempak", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" B: back/cancel", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" START: start last rom", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" C-left: rom info/mempak", 4, -1, disp);
|
|
||||||
printText(" content view", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText("C-right: rom config creen", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" C-up: view full filename", 4, -1, disp);
|
|
||||||
printText(" ", 4, -1, disp);
|
|
||||||
printText(" C-down: Toplist 15", 4, -1, disp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
#include <libdragon.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "types.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "everdrive.h"
|
||||||
|
|
||||||
|
void menu_controls(display_context_t disp)
|
||||||
|
{
|
||||||
|
printText(" - Controls -", 4, 4, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" L: show mempak menu", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" Z: about screen", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" A: start rom/directory", 4, -1, disp);
|
||||||
|
printText(" mempak", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" B: back/cancel", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" START: start last rom", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" C-left: rom info/mempak", 4, -1, disp);
|
||||||
|
printText(" content view", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText("C-right: rom config creen", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" C-up: view full filename", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" C-down: Toplist 15", 4, -1, disp);
|
||||||
|
printText(" ", 4, -1, disp);
|
||||||
|
printText(" R + L: Delete file", 4, -1, disp);
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
#include <libdragon.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "types.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "everdrive.h"
|
||||||
|
|
||||||
|
|
||||||
|
void menu_delete(display_context_t disp, bool isdir)
|
||||||
|
{
|
||||||
|
if (isdir)
|
||||||
|
{
|
||||||
|
printText("Cannot delete directories!", 7, 14, disp);
|
||||||
|
printText("B: Exit", 13, 16, disp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printText("Delete this file?", 10, 14, disp);
|
||||||
|
printText("A: Confirm", 13, 16, disp);
|
||||||
|
printText("B: Cancel", 13, 17, disp);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue