Skip to content

Commit

Permalink
(RGUI) Add restart game item
Browse files Browse the repository at this point in the history
fix messages only staying up for half as long as they should
general cleanup
(GX) force vsync for menu rendering
general cleanup
  • Loading branch information
ToadKing committed Aug 19, 2012
1 parent 8ce7514 commit d478e8b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 33 deletions.
52 changes: 36 additions & 16 deletions console/rgui/rgui.c
Expand Up @@ -46,6 +46,7 @@ struct rgui_handle
rgui_list_t *folder_buf;
int directory_ptr;
bool need_refresh;
bool msg_force;

char path_buf[PATH_MAX];

Expand Down Expand Up @@ -385,7 +386,23 @@ static void render_text(rgui_handle_t *rgui)
blit_line(rgui, x, y, message, i == rgui->directory_ptr);
}

render_messagebox(rgui, msg_queue_pull(g_extern.msg_queue));
const char *message_queue;
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)driver.video_data;
if (rgui->msg_force)
{
message_queue = msg_queue_pull(g_extern.msg_queue);
rgui->msg_force = false;
}
else
{
message_queue = gx->msg;
}
#else
message_queue = msg_queue_pull(g_extern.msg_queue);
#endif
render_messagebox(rgui, message_queue);

}

#ifdef GEKKO
Expand All @@ -397,7 +414,9 @@ static void render_text(rgui_handle_t *rgui)
static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t action, rgui_file_type_t menu_type)
{
unsigned port = menu_type - RGUI_SETTINGS_CONTROLLER_1;
void *data = (gx_video_t*)driver.video_data;
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)driver.video_data;
#endif

switch (setting)
{
Expand Down Expand Up @@ -437,6 +456,13 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
msg_queue_push(g_extern.msg_queue, r ? "Screenshot saved" : "Screenshot failed to save", 1, S_DELAY_90);
}
break;
case RGUI_SETTINGS_RESTART_GAME:
if (action == RGUI_ACTION_OK)
{
rarch_settings_change(S_RETURN_TO_GAME);
rarch_game_reset();
}
break;
case RGUI_SETTINGS_VIDEO_FILTER:
if (action == RGUI_ACTION_START)
rarch_settings_default(S_DEF_HW_TEXTURE_FILTER);
Expand All @@ -446,7 +472,6 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
#ifdef HW_RVL
case RGUI_SETTINGS_VIDEO_SOFT_FILTER:
{
gx_video_t *gx = (gx_video_t*)data;
g_console.soft_display_filter_enable = !g_console.soft_display_filter_enable;
gx->should_resize = true;
}
Expand All @@ -457,7 +482,6 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
{
g_console.gamma_correction = 0;
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)data;
gx->should_resize = true;
#endif
}
Expand All @@ -467,7 +491,6 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
{
g_console.gamma_correction--;
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)data;
gx->should_resize = true;
#endif
}
Expand All @@ -478,7 +501,6 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
{
g_console.gamma_correction++;
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)data;
gx->should_resize = true;
#endif
}
Expand Down Expand Up @@ -524,7 +546,7 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
else if (action == RGUI_ACTION_RIGHT)
rarch_settings_change(S_AUDIO_CONTROL_RATE_INCREMENT);
break;
case RGUI_SETTINGS_RESTART:
case RGUI_SETTINGS_RESTART_EMULATOR:
if (action == RGUI_ACTION_OK)
{
#ifdef GEKKO
Expand Down Expand Up @@ -594,6 +616,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui)
RGUI_MENU_ITEM("Save State", RGUI_SETTINGS_SAVESTATE_SAVE);
RGUI_MENU_ITEM("Load State", RGUI_SETTINGS_SAVESTATE_LOAD);
RGUI_MENU_ITEM("Take Screenshot", RGUI_SETTINGS_SCREENSHOT);
RGUI_MENU_ITEM("Restart Game", RGUI_SETTINGS_RESTART_GAME);
}
RGUI_MENU_ITEM("Hardware filtering", RGUI_SETTINGS_VIDEO_FILTER);
#ifdef HW_RVL
Expand All @@ -609,7 +632,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui)
RGUI_MENU_ITEM("Controller #2 Config", RGUI_SETTINGS_CONTROLLER_2);
RGUI_MENU_ITEM("Controller #3 Config", RGUI_SETTINGS_CONTROLLER_3);
RGUI_MENU_ITEM("Controller #4 Config", RGUI_SETTINGS_CONTROLLER_4);
RGUI_MENU_ITEM("Restart RetroArch", RGUI_SETTINGS_RESTART);
RGUI_MENU_ITEM("Restart RetroArch", RGUI_SETTINGS_RESTART_EMULATOR);
}

static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
Expand All @@ -635,7 +658,7 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
RGUI_MENU_ITEM("R3", RGUI_SETTINGS_BIND_R3);
}

static const char *rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
void rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
rgui_file_type_t type = 0;
const char *label = 0;
Expand Down Expand Up @@ -713,12 +736,11 @@ static const char *rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t acti

render_text(rgui);

return NULL;
return;
}

const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
bool found = false;
const char *dir = 0;
rgui_file_type_t menu_type = 0;
size_t directory_ptr = 0;
Expand Down Expand Up @@ -772,7 +794,7 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_OK:
{
if (rgui_list_size(rgui->folder_buf) == 0)
return NULL;
return;

const char *path = 0;
rgui_file_type_t type = 0;
Expand Down Expand Up @@ -815,7 +837,7 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
snprintf(rgui->path_buf, sizeof(rgui->path_buf), "%s/%s", dir, path);
rarch_console_load_game_wrap(rgui->path_buf, g_console.zip_extract_mode, S_DELAY_1);
found = true;
rgui->msg_force = true;
}
}
break;
Expand Down Expand Up @@ -860,6 +882,4 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
}

render_text(rgui);

return found ? rgui->path_buf : NULL;
}
5 changes: 3 additions & 2 deletions console/rgui/rgui.h
Expand Up @@ -37,6 +37,7 @@ typedef enum
RGUI_SETTINGS_SAVESTATE_SAVE,
RGUI_SETTINGS_SAVESTATE_LOAD,
RGUI_SETTINGS_SCREENSHOT,
RGUI_SETTINGS_RESTART_GAME,
RGUI_SETTINGS_VIDEO_FILTER,
#ifdef HW_RVL
RGUI_SETTINGS_VIDEO_SOFT_FILTER,
Expand All @@ -51,7 +52,7 @@ typedef enum
RGUI_SETTINGS_CONTROLLER_2,
RGUI_SETTINGS_CONTROLLER_3,
RGUI_SETTINGS_CONTROLLER_4,
RGUI_SETTINGS_RESTART,
RGUI_SETTINGS_RESTART_EMULATOR,

RGUI_SETTINGS_BIND_DEVICE,
RGUI_SETTINGS_BIND_UP,
Expand Down Expand Up @@ -101,7 +102,7 @@ rgui_handle_t *rgui_init(const char *base_path,
const uint8_t *font_buf,
rgui_folder_enum_cb_t folder_cb, void *userdata);

const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);
void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);

void rgui_free(rgui_handle_t *rgui);

Expand Down
16 changes: 3 additions & 13 deletions gx/frontend/main.c
Expand Up @@ -182,12 +182,6 @@ static void menu_loop(void)
bool first = true;

g_console.menu_enable = true;

if(g_console.ingame_menu_enable)
{
//TODO: fill in some stuff here to bring up ingame menu
}

gx->menu_render = true;

do
Expand Down Expand Up @@ -253,9 +247,7 @@ static void menu_loop(void)
first = false;
}

const char *ret = rgui_iterate(rgui, action);

(void)ret;
rgui_iterate(rgui, action);

rarch_render_cached_frame();

Expand Down Expand Up @@ -336,7 +328,6 @@ int main(void)
#endif

fatInitDefault();

get_environment_settings();

#ifdef HAVE_LOGGER
Expand Down Expand Up @@ -417,11 +408,10 @@ int main(void)
video_gx.stop();
menu_free();

#ifdef HAVE_FILE_LOGGER
fclose(log_fp);
#endif
#ifdef HAVE_LOGGER
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
fclose(log_fp);
#endif

if(g_console.return_to_launcher)
Expand Down
9 changes: 7 additions & 2 deletions gx/gx_video.c
Expand Up @@ -199,6 +199,7 @@ static void gx_stop(void)
GX_Flush();
VIDEO_SetBlack(true);
VIDEO_Flush();
VIDEO_WaitVSync();

for (unsigned i = 0; i < 2; i++)
free(MEM_K1_TO_K0(g_framebuf[i]));
Expand Down Expand Up @@ -492,7 +493,11 @@ static bool gx_frame(void *data, const void *frame,
bool should_resize = gx->should_resize;

(void)data;
(void)msg;

if (msg)
snprintf(gx->msg, sizeof(gx->msg), "%s", msg);
else
gx->msg[0] = 0;

if(!frame && !menu_render)
return true;
Expand All @@ -504,7 +509,7 @@ static bool gx_frame(void *data, const void *frame,
gx_resize(gx);
}

while (g_vsync && !g_draw_done)
while ((g_vsync || menu_render) && !g_draw_done)
LWP_ThreadSleep(g_video_cond);

g_draw_done = false;
Expand Down
1 change: 1 addition & 0 deletions gx/gx_video.h
Expand Up @@ -23,6 +23,7 @@ typedef struct gx_video
bool keep_aspect;
uint32_t frame_count;
uint32_t *menu_data;
char msg[128];
} gx_video_t;

void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx);
Expand Down

0 comments on commit d478e8b

Please sign in to comment.