(RMenu) split up font positioning code to context file

This commit is contained in:
twinaphex 2012-08-19 00:29:38 +02:00
parent 2ebba4a347
commit f4485c29a6
4 changed files with 51 additions and 27 deletions

View File

@ -59,6 +59,16 @@ static void rmenu_ctx_ps3_swap_buffers(void)
#endif #endif
} }
static void rmenu_ctx_ps3_set_default_pos(rmenu_default_positions_t *position)
{
position->x_position = POSITION_X;
position->x_position_center = POSITION_X_CENTER;
position->comment_y_position = COMMENT_Y_POSITION;
position->y_position_increment = POSITION_Y_INCREMENT;
position->comment_two_y_position = COMMENT_TWO_Y_POSITION;
position->font_size = HARDCODE_FONT_SIZE;
}
const rmenu_context_t rmenu_ctx_ps3 = { const rmenu_context_t rmenu_ctx_ps3 = {
.clear = rmenu_ctx_ps3_clear, .clear = rmenu_ctx_ps3_clear,
.blend = rmenu_ctx_ps3_blend, .blend = rmenu_ctx_ps3_blend,
@ -67,4 +77,5 @@ const rmenu_context_t rmenu_ctx_ps3 = {
.render_selection_panel = rmenu_ctx_ps3_render_selection_panel, .render_selection_panel = rmenu_ctx_ps3_render_selection_panel,
.render_bg = rmenu_ctx_ps3_render_bg, .render_bg = rmenu_ctx_ps3_render_bg,
.swap_buffers = rmenu_ctx_ps3_swap_buffers, .swap_buffers = rmenu_ctx_ps3_swap_buffers,
.set_default_pos = rmenu_ctx_ps3_set_default_pos,
}; };

View File

@ -94,6 +94,16 @@ static void rmenu_ctx_xdk_swap_buffers(void)
gfx_ctx_swap_buffers(); gfx_ctx_swap_buffers();
} }
static void rmenu_ctx_xdk_set_default_pos(rmenu_default_positions_t *position)
{
position->x_position = POSITION_X;
position->x_position_center = POSITION_X_CENTER;
position->comment_y_position = COMMENT_Y_POSITION;
position->y_position_increment = POSITION_Y_INCREMENT;
position->comment_two_y_position = COMMENT_TWO_Y_POSITION;
position->font_size = HARDCODE_FONT_SIZE;
}
const rmenu_context_t rmenu_ctx_xdk = { const rmenu_context_t rmenu_ctx_xdk = {
rmenu_ctx_xdk_clear, rmenu_ctx_xdk_clear,
rmenu_ctx_xdk_blend, rmenu_ctx_xdk_blend,
@ -102,4 +112,5 @@ const rmenu_context_t rmenu_ctx_xdk = {
rmenu_ctx_xdk_render_selection_panel, rmenu_ctx_xdk_render_selection_panel,
rmenu_ctx_xdk_render_bg, rmenu_ctx_xdk_render_bg,
rmenu_ctx_xdk_swap_buffers, rmenu_ctx_xdk_swap_buffers,
rmenu_ctx_xdk_set_default_pos,
}; };

View File

@ -881,11 +881,9 @@ static void select_directory(item *items, menu *current_menu, uint64_t input)
bool ret = true; bool ret = true;
DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data;
float x_position = POSITION_X; rmenu_default_positions_t default_pos;
float comment_y_position = COMMENT_Y_POSITION;
float y_position_increment = POSITION_Y_INCREMENT; context->set_default_pos(&default_pos);
float comment_two_y_position = COMMENT_TWO_Y_POSITION;
float font_size = HARDCODE_FONT_SIZE;
bool is_dir = filebrowser_get_current_path_isdir(&tmpBrowser); bool is_dir = filebrowser_get_current_path_isdir(&tmpBrowser);
browser_update(&tmpBrowser, input, "empty"); browser_update(&tmpBrowser, input, "empty");
@ -957,13 +955,13 @@ static void select_directory(item *items, menu *current_menu, uint64_t input)
display_menubar(current_menu); display_menubar(current_menu);
snprintf(msg, sizeof(msg), "[%s] - Enter dir | [%s] - Go back", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_B), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_X)); snprintf(msg, sizeof(msg), "[%s] - Enter dir | [%s] - Go back", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_B), rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_X));
render_msg_place_func(x_position, comment_two_y_position, font_size, YELLOW, msg); render_msg_place_func(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)); snprintf(msg, sizeof(msg), "[%s] - Reset to startdir", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_START));
render_msg_place_func(x_position, comment_two_y_position + (y_position_increment * 1), FONT_SIZE, YELLOW, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), 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)); 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));
render_msg_place_func(x_position, comment_y_position, font_size, WHITE, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg);
} }
static void set_keybind_digital(uint64_t default_retro_joypad_id, uint64_t input) static void set_keybind_digital(uint64_t default_retro_joypad_id, uint64_t input)
@ -1734,12 +1732,9 @@ static void select_setting(item *items, menu *current_menu, uint64_t input)
char msg[256]; char msg[256];
DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data;
float x_position = POSITION_X; rmenu_default_positions_t default_pos;
float x_position_center = POSITION_X_CENTER;
float y_position_increment = POSITION_Y_INCREMENT; context->set_default_pos(&default_pos);
float comment_y_position = COMMENT_Y_POSITION;
float comment_two_y_position = COMMENT_TWO_Y_POSITION;
float font_size = HARDCODE_FONT_SIZE;
settings_action_t action = SETTINGS_ACTION_NOOP; settings_action_t action = SETTINGS_ACTION_NOOP;
@ -1765,12 +1760,12 @@ static void select_setting(item *items, menu *current_menu, uint64_t input)
if(items[i].page == current_menu->page) if(items[i].page == current_menu->page)
{ {
render_msg_place_func(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); render_msg_place_func(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);
render_msg_place_func(x_position_center, items[i].text_ypos, FONT_SIZE, items[i].text_color, items[i].setting_text); render_msg_place_func(default_pos.x_position_center, items[i].text_ypos, FONT_SIZE, items[i].text_color, items[i].setting_text);
if(current_menu->selected == items[i].enum_id) if(current_menu->selected == items[i].enum_id)
{ {
rmenu_position_t position = {0}; rmenu_position_t position = {0};
position.x = x_position; position.x = default_pos.x_position;
position.y = items[i].text_ypos; position.y = items[i].text_ypos;
context->render_selection_panel(&position); context->render_selection_panel(&position);
@ -1778,12 +1773,12 @@ static void select_setting(item *items, menu *current_menu, uint64_t input)
} }
} }
render_msg_place_func(x_position, comment_y_position, font_size, WHITE, items[current_menu->selected].comment); render_msg_place_func(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)); 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));
render_msg_place_func(x_position, comment_two_y_position, FONT_SIZE, YELLOW, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_two_y_position, 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)); 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));
render_msg_place_func(x_position, comment_two_y_position + (y_position_increment * 1), FONT_SIZE, YELLOW, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), FONT_SIZE, YELLOW, msg);
} }
static void menu_romselect_iterate(filebrowser_t *filebrowser, item *items, menu_romselect_action_t action) static void menu_romselect_iterate(filebrowser_t *filebrowser, item *items, menu_romselect_action_t action)
@ -1813,12 +1808,9 @@ static void menu_romselect_iterate(filebrowser_t *filebrowser, item *items, menu
static void select_rom(item *items, menu *current_menu, uint64_t input) static void select_rom(item *items, menu *current_menu, uint64_t input)
{ {
DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data;
rmenu_default_positions_t default_pos;
float x_position = POSITION_X; context->set_default_pos(&default_pos);
float comment_y_position = COMMENT_Y_POSITION;
float y_position_increment = POSITION_Y_INCREMENT;
float comment_two_y_position = COMMENT_TWO_Y_POSITION;
float font_size = HARDCODE_FONT_SIZE;
browser_update(&browser, input, rarch_console_get_rom_ext()); browser_update(&browser, input, rarch_console_get_rom_ext());
@ -1844,15 +1836,15 @@ static void select_rom(item *items, menu *current_menu, uint64_t input)
else else
snprintf(msg, sizeof(msg), "INFO - Press [%s] to load the game.", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_B)); snprintf(msg, sizeof(msg), "INFO - Press [%s] to load the game.", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_B));
render_msg_place_func(x_position, comment_y_position, font_size, WHITE, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg);
display_menubar(current_menu); display_menubar(current_menu);
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(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)); snprintf(msg2, sizeof(msg2), "[%s] - Settings", rarch_input_find_platform_key_label(1 << RETRO_DEVICE_ID_JOYPAD_SELECT));
render_msg_place_func (x_position, comment_two_y_position, FONT_SIZE, YELLOW, msg); render_msg_place_func(default_pos.x_position, default_pos.comment_two_y_position, FONT_SIZE, YELLOW, msg);
render_msg_place_func(x_position, comment_two_y_position + (y_position_increment * 1), FONT_SIZE, YELLOW, msg2); render_msg_place_func(default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), FONT_SIZE, YELLOW, msg2);
} }

View File

@ -102,6 +102,15 @@ typedef struct rmenu_position
float height; float height;
} rmenu_position_t; } rmenu_position_t;
typedef struct rmenu_default_positions
{
float x_position;
float x_position_center;
float comment_y_position;
float y_position_increment;
float comment_two_y_position;
float font_size;
} rmenu_default_positions_t;
typedef struct rmenu_context typedef struct rmenu_context
{ {
@ -112,6 +121,7 @@ typedef struct rmenu_context
void (*render_selection_panel)(rmenu_position_t *position); void (*render_selection_panel)(rmenu_position_t *position);
void (*render_bg)(rmenu_position_t *position); void (*render_bg)(rmenu_position_t *position);
void (*swap_buffers)(void); void (*swap_buffers)(void);
void (*set_default_pos)(rmenu_default_positions_t *position);
} rmenu_context_t; } rmenu_context_t;
enum enum