(RMenu) Refactor system-specific bits

This commit is contained in:
Twinaphex 2012-08-19 11:57:58 +02:00
parent e71851940f
commit a94410a068
4 changed files with 34 additions and 26 deletions

View File

@ -38,6 +38,10 @@
#define CURRENT_PATH_Y_POSITION 0.15f
#define CURRENT_PATH_FONT_SIZE FONT_SIZE
#define FONT_SIZE (g_console.menu_font_size)
#define NUM_ENTRY_PER_PAGE 15
static void rmenu_ctx_ps3_clear(void)
{
gfx_ctx_clear();
@ -92,6 +96,8 @@ static void rmenu_ctx_ps3_set_default_pos(rmenu_default_positions_t *position)
position->msg_prev_next_y_position = MSG_PREV_NEXT_Y_POSITION;
position->current_path_font_size = CURRENT_PATH_FONT_SIZE;
position->current_path_y_position = CURRENT_PATH_Y_POSITION;
position->variable_font_size = FONT_SIZE;
position->entries_per_page = NUM_ENTRY_PER_PAGE;
}
static void rmenu_ctx_ps3_render_msg(float xpos, float ypos, float scale, unsigned color, const char *msg, ...)

View File

@ -39,6 +39,10 @@
#define CURRENT_PATH_Y_POSITION (m_menuMainRomListPos_y - ((POSITION_Y_INCREMENT/2)))
#define CURRENT_PATH_FONT_SIZE 21
#define FONT_SIZE 21
#define NUM_ENTRY_PER_PAGE 12
int xpos, ypos;
texture_image m_menuMainRomSelectPanel;
texture_image m_menuMainBG;
@ -129,6 +133,8 @@ static void rmenu_ctx_xdk_set_default_pos(rmenu_default_positions_t *position)
position->msg_prev_next_y_position = MSG_PREV_NEXT_Y_POSITION;
position->current_path_font_size = CURRENT_PATH_FONT_SIZE;
position->current_path_y_position = CURRENT_PATH_Y_POSITION;
position->variable_font_size = FONT_SIZE;
position->entries_per_page = NUM_ENTRY_PER_PAGE;
}
static void rmenu_ctx_xdk_render_msg(float xpos, float ypos, float scale, unsigned color, const char *msg, ...)

View File

@ -408,7 +408,7 @@ static void menu_stack_refresh (item *items, menu *current_menu)
for(i = current_menu->first_setting; i < current_menu->max_settings; i++)
{
if(!(j < (NUM_ENTRY_PER_PAGE)))
if(!(j < default_pos.entries_per_page))
{
j = 0;
default_pos.y_position = POSITION_Y_BEGIN;
@ -694,37 +694,35 @@ static void browser_update(filebrowser_t * b, uint64_t input, const char *extens
rarch_settings_msg(S_MSG_DIR_LOADING_ERROR, S_DELAY_180);
}
static void browser_render(filebrowser_t * b, float current_x, float current_y, float y_spacing)
static void browser_render(filebrowser_t * b)
{
unsigned file_count = b->current_dir.list->size;
unsigned int current_index, page_number, page_base, i;
float currentX, currentY, ySpacing;
rmenu_default_positions_t default_pos;
context->set_default_pos(&default_pos);
current_index = b->current_dir.ptr;
page_number = current_index / NUM_ENTRY_PER_PAGE;
page_base = page_number * NUM_ENTRY_PER_PAGE;
page_number = current_index / default_pos.entries_per_page;
page_base = page_number * default_pos.entries_per_page;
currentX = current_x;
currentY = current_y;
ySpacing = y_spacing;
for ( i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i)
for ( i = page_base; i < file_count && i < page_base + default_pos.entries_per_page; ++i)
{
char fname_tmp[256];
fill_pathname_base(fname_tmp, b->current_dir.list->elems[i].data, sizeof(fname_tmp));
currentY = currentY + ySpacing;
default_pos.starting_y_position += default_pos.y_position_increment;
//check if this is the currently selected file
const char *current_pathname = filebrowser_get_current_path(b);
if(strcmp(current_pathname, b->current_dir.list->elems[i].data) == 0)
{
rmenu_position_t position = {0};
position.x = currentX;
position.y = currentY;
position.x = default_pos.x_position;
position.y = default_pos.starting_y_position;
context->render_selection_panel(&position);
}
context->render_msg(currentX, currentY, FONT_SIZE, i == current_index ? RED : b->current_dir.list->elems[i].attr.b ? GREEN : WHITE, fname_tmp);
context->render_msg(default_pos.x_position, default_pos.starting_y_position, default_pos.variable_font_size, i == current_index ? RED : b->current_dir.list->elems[i].attr.b ? GREEN : WHITE, fname_tmp);
}
}
@ -941,7 +939,7 @@ static void select_directory(item *items, menu *current_menu, uint64_t input)
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg);
snprintf(msg, sizeof(msg), "[%s] - Reset to startdir", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_START));
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), FONT_SIZE, YELLOW, msg);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg);
snprintf(msg, sizeof(msg), "INFO - Browse to a directory and assign it as the path by\npressing [%s].", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_Y));
context->render_msg(default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg);
@ -1741,8 +1739,8 @@ static void select_setting(item *items, menu *current_menu, uint64_t input)
{
if(items[i].page == current_menu->page)
{
context->render_msg(items[i].text_xpos, items[i].text_ypos, FONT_SIZE, current_menu->selected == items[i].enum_id ? YELLOW : items[i].item_color, items[i].text);
context->render_msg(default_pos.x_position_center, items[i].text_ypos, FONT_SIZE, items[i].text_color, items[i].setting_text);
context->render_msg(items[i].text_xpos, items[i].text_ypos, default_pos.variable_font_size, current_menu->selected == items[i].enum_id ? YELLOW : items[i].item_color, items[i].text);
context->render_msg(default_pos.x_position_center, items[i].text_ypos, default_pos.variable_font_size, items[i].text_color, items[i].setting_text);
if(current_menu->selected == items[i].enum_id)
{
@ -1758,9 +1756,9 @@ static void select_setting(item *items, menu *current_menu, uint64_t input)
context->render_msg(default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, items[current_menu->selected].comment);
snprintf(msg, sizeof(msg), "[%s] + [%s] - resume game | [%s] - go forward", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_L3), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_R3), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_R));
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position, FONT_SIZE, YELLOW, msg);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg);
snprintf(msg, sizeof(msg), "[%s] - default | [%s]/[%s] - go back", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_START), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_L), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_A));
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), FONT_SIZE, YELLOW, msg);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg);
}
static void menu_romselect_iterate(filebrowser_t *filebrowser, item *items, menu_romselect_action_t action)
@ -1824,8 +1822,8 @@ static void select_rom(item *items, menu *current_menu, uint64_t input)
snprintf(msg, sizeof(msg), "[%s] + [%s] - resume game", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_L3), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_R3));
snprintf(msg2, sizeof(msg2), "[%s] - Settings", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_SELECT));
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position, FONT_SIZE, YELLOW, msg);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), FONT_SIZE, YELLOW, msg2);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg);
context->render_msg(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg2);
}
@ -2443,7 +2441,7 @@ void menu_loop(void)
switch(current_menu->category_id)
{
case CATEGORY_FILEBROWSER:
browser_render(fb, default_pos.x_position, default_pos.starting_y_position, default_pos.y_position_increment);
browser_render(fb);
break;
case CATEGORY_SETTINGS:
case CATEGORY_INGAME_MENU:

View File

@ -21,16 +21,12 @@
#define DEVICE_CAST gl_t*
#define input_ptr input_ps3
#define video_ptr video_gl
#define FONT_SIZE (g_console.menu_font_size)
#define NUM_ENTRY_PER_PAGE 15
#elif defined(_XBOX1)
#define DEVICE_CAST xdk_d3d_video_t*
#define input_ptr input_xinput
#define video_ptr video_xdk_d3d
#define FONT_SIZE 21
#define NUM_ENTRY_PER_PAGE 12
#endif
typedef struct
@ -81,6 +77,8 @@ typedef struct rmenu_default_positions
float msg_prev_next_y_position;
float current_path_font_size;
float current_path_y_position;
float variable_font_size;
unsigned entries_per_page;
} rmenu_default_positions_t;
typedef struct rmenu_context