(Wii) message box fixes

Have ROM error boxes display for a short period and not reset the file browser
This commit is contained in:
Toad King 2012-06-28 21:13:45 -04:00
parent a8c3b9c8ee
commit 1db8efedbc
4 changed files with 43 additions and 17 deletions

View File

@ -201,7 +201,7 @@ void rarch_settings_msg(unsigned setting, unsigned delay)
break;
case S_MSG_LOADING_ROM:
fill_pathname_base(tmp, g_console.rom_path, sizeof(tmp));
snprintf(str, sizeof(str), "INFO - Loading %.38s...", tmp);
snprintf(str, sizeof(str), "INFO - Loading %s...", tmp);
break;
case S_MSG_ROM_LOADING_ERROR:
snprintf(str, sizeof(str), "ERROR - An error occurred during ROM loading.");

View File

@ -19,7 +19,7 @@
enum
{
S_DELAY_0 = 0,
S_DELAY_0 = 1, // display for one frame
S_DELAY_90 = 90,
S_DELAY_180 = 180,
S_DELAY_270 = 270

View File

@ -70,7 +70,7 @@ static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
return true;
}
static const char *get_rom_path(rgui_handle_t *rgui)
static bool get_rom_path(rgui_handle_t *rgui)
{
uint16_t old_input_state = 0;
bool can_quit = false;
@ -85,7 +85,7 @@ static const char *get_rom_path(rgui_handle_t *rgui)
if (input_wii.key_pressed(NULL, RARCH_QUIT_KEY))
{
if (can_quit)
return NULL;
return false;
}
else
can_quit = true;
@ -114,7 +114,12 @@ static const char *get_rom_path(rgui_handle_t *rgui)
RGUI_WIDTH * sizeof(uint16_t), NULL);
if (ret)
return ret;
{
g_console.initialize_rarch_enable = true;
strlcpy(g_console.rom_path, ret, sizeof(g_console.rom_path));
if (rarch_startup(NULL))
return true;
}
old_input_state = input_state;
rarch_sleep(10);
@ -143,13 +148,9 @@ int main(void)
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
_binary_console_font_bmp_start, folder_cb, NULL);
const char *rom_path;
int ret = 0;
while ((rom_path = get_rom_path(rgui)) && ret == 0)
while (get_rom_path(rgui) && ret == 0)
{
g_console.initialize_rarch_enable = true;
strlcpy(g_console.rom_path, rom_path, sizeof(g_console.rom_path));
rarch_startup(NULL);
bool repeat = false;
input_wii.poll(NULL);

View File

@ -44,6 +44,7 @@ struct rgui_handle
rgui_list_t *folder_buf;
size_t directory_ptr;
bool need_refresh;
bool displaying_message;
char path_buf[PATH_MAX];
@ -204,7 +205,16 @@ static void render_text(rgui_handle_t *rgui, size_t begin, size_t end)
static void render_messagebox(rgui_handle_t *rgui, const char *message)
{
unsigned width = strlen(message) * FONT_WIDTH_STRIDE - 1 + 6 + 10;
char *msg = strdup(message);
if (strlen(msg) > TERM_WIDTH)
{
msg[TERM_WIDTH - 2] = '.';
msg[TERM_WIDTH - 1] = '.';
msg[TERM_WIDTH - 0] = '.';
msg[TERM_WIDTH + 1] = '\0';
}
unsigned width = strlen(msg) * FONT_WIDTH_STRIDE - 1 + 6 + 10;
unsigned height = FONT_HEIGHT + 6 + 10;
unsigned x = (RGUI_WIDTH - width) / 2;
unsigned y = (RGUI_HEIGHT - height) / 2;
@ -224,7 +234,8 @@ static void render_messagebox(rgui_handle_t *rgui, const char *message)
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
x, y + 5, 5, height - 5, green_filler);
blit_line(rgui, x + 8, y + 8, message, false);
blit_line(rgui, x + 8, y + 8, msg, false);
free(msg);
}
const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
@ -281,11 +292,9 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
snprintf(rgui->path_buf, sizeof(rgui->path_buf), "%s/%s",
strcmp(dir, "/") == 0 ? "" : dir, path);
strlcpy(g_console.rom_path, rgui->path_buf, sizeof(g_console.rom_path));
strlcpy(g_console.rom_path, rgui->path_buf, sizeof(g_console.rom_path));
rarch_settings_msg(S_MSG_LOADING_ROM, S_DELAY_0);
const char * message = msg_queue_pull(g_extern.msg_queue);
const char * message = msg_queue_pull(g_extern.msg_queue);
render_messagebox(rgui, message);
return rgui->path_buf;
}
@ -297,7 +306,18 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
break;
default:
return NULL;
if (msg_queue_pull(g_extern.msg_queue))
{
rgui->displaying_message = true;
}
else if (rgui->displaying_message)
{
rgui->displaying_message = false;
}
else
{
return NULL;
}
}
if (rgui->need_refresh)
@ -327,6 +347,11 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
end = begin + TERM_HEIGHT;
render_text(rgui, begin, end);
const char * message = msg_queue_pull(g_extern.msg_queue);
if (message)
render_messagebox(rgui, message);
return NULL;
}