mirror of
https://github.com/parasyte/alt64
synced 2025-02-28 09:21:46 -05:00
Merge pull request #7 from skawo/master
Add a way to delete files in the menu.
This commit is contained in:
commit
349869ab95
@ -11,5 +11,7 @@ extern int text_offset;
|
|||||||
void printText(char *msg, int x, int y, display_context_t dcon);
|
void printText(char *msg, int x, int y, display_context_t dcon);
|
||||||
|
|
||||||
void menu_about(display_context_t disp);
|
void menu_about(display_context_t disp);
|
||||||
|
void menu_controls(display_context_t disp);
|
||||||
|
void menu_delete(display_context_t disp, bool isdir);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
103
src/main.c
103
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;
|
||||||
}
|
}
|
||||||
@ -1722,14 +1726,14 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pushSaveToCart(stype, cartsave_data))
|
if (pushSaveToCart(stype, cartsave_data))
|
||||||
{
|
{
|
||||||
printText("transferred save data...", 3, -1, disp);
|
printText("transferred save data...", 3, -1, disp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printText("error transfering save data", 3, -1, disp);
|
printText("error transfering save data", 3, -1, disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1778,13 +1782,13 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
|
|||||||
if (getSaveFromCart(stype, cartsave_data))
|
if (getSaveFromCart(stype, cartsave_data))
|
||||||
{
|
{
|
||||||
UINT bw;
|
UINT bw;
|
||||||
result = f_write (
|
result = f_write (
|
||||||
&file, /* [IN] Pointer to the file object structure */
|
&file, /* [IN] Pointer to the file object structure */
|
||||||
cartsave_data, /* [IN] Pointer to the data to be written */
|
cartsave_data, /* [IN] Pointer to the data to be written */
|
||||||
size, /* [IN] Number of bytes to write */
|
size, /* [IN] Number of bytes to write */
|
||||||
&bw /* [OUT] Pointer to the variable to return number of bytes written */
|
&bw /* [OUT] Pointer to the variable to return number of bytes written */
|
||||||
);
|
);
|
||||||
f_close(&file);
|
f_close(&file);
|
||||||
|
|
||||||
printText("RAM area copied to SD card.", 3, -1, disp);
|
printText("RAM area copied to SD card.", 3, -1, disp);
|
||||||
return 1;
|
return 1;
|
||||||
@ -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()))
|
||||||
;
|
;
|
||||||
@ -4451,8 +4514,8 @@ void handleInput(display_context_t disp, sprite_t *contr)
|
|||||||
mp3_Stop();
|
mp3_Stop();
|
||||||
mp3playing = 0;
|
mp3playing = 0;
|
||||||
audio_close();
|
audio_close();
|
||||||
free(buf_ptr);
|
free(buf_ptr);
|
||||||
buf_ptr = 0;
|
buf_ptr = 0;
|
||||||
audio_init(44100, 8);
|
audio_init(44100, 8);
|
||||||
|
|
||||||
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);
|
||||||
} //TODO: make scrolling text, should include libraries used.
|
printText("Skawo", 9, -1, disp);
|
||||||
void menu_controls(display_context_t disp)
|
} //TODO: make scrolling text, should include libraries used.
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
35
src/menu_controls.c
Normal file
35
src/menu_controls.c
Normal file
@ -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);
|
||||||
|
}
|
24
src/menu_delete.c
Normal file
24
src/menu_delete.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
#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…
x
Reference in New Issue
Block a user