int menu_width,
int menu_height)
{
+ int font_width = 16;
+
const menu_item_type& pitem = pmenu->item[index];
- int arrange = 0;
- if(pmenu->arrange_left == YES)
- arrange = ((menu_width - 48) + (16 * (strlen(pitem.text)
- + strlen(pitem.input)
- + strlen(string_list_active(pitem.list)))))/2;
-
- int f = 0;
+ int effect_offset = 0;
{
int effect_time = 0;
if(timer_check(&pmenu->effect))
effect_time = timer_get_left(&pmenu->effect) / 4;
- f = (index % 2) ? effect_time : -effect_time;
+ effect_offset = (index % 2) ? effect_time : -effect_time;
}
- int x_pos = screen->w/2 - menu_width/2;
- int y_pos = index * 24 - menu_height/2;
-
- int start_x = screen->w/2 + arrange;
- int center_y = screen->h /2;
-
- int cen_y = center_y + y_pos;
- int cen_y_10_f = 10 + f + cen_y;
-
+ int x_pos = screen->w/2;
+ int y_pos = screen->h/2 + 24*index - menu_height/2 + 12 + effect_offset;
int shadow_size = 2;
+ int text_width = strlen(pitem.text) * font_width;
+ int input_width = strlen(pitem.input) * font_width;
+ int list_width = strlen(string_list_active(pitem.list)) * font_width;
text_type* text_font = &white_text;
+
+ if(pmenu->arrange_left == YES)
+ x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2;
+
if(index == pmenu->active_item)
{
shadow_size = 3;
{
case MN_DEACTIVE:
{
- text_drawf(&black_text, pitem.text,
- arrange, y_pos + 10 + f,
+ text_draw_align(&black_text, pitem.text,
+ x_pos, y_pos,
A_HMIDDLE, A_VMIDDLE, 2);
break;
}
case MN_HL:
{
+ int x = screen->w/2 - menu_width/2;
+ int y = y_pos - 12 - effect_offset;
/* Draw a horizontal line with a little 3d effect */
- fillrect(x_pos, cen_y + 6,
+ fillrect(x, y + 6,
menu_width, 4,
210,50,50,225);
- fillrect(x_pos, 10 + cen_y + 6,
+ fillrect(x, y + 10 + 6,
menu_width, 2,
0,0,0,255);
break;
}
case MN_LABEL:
{
- text_drawf(&white_big_text, pitem.text,
- arrange, y_pos + 10,
- A_HMIDDLE, A_VMIDDLE, 2);
+ text_draw_align(&white_big_text, pitem.text,
+ x_pos, y_pos,
+ A_HMIDDLE, A_VMIDDLE, 2);
break;
}
case MN_TEXTFIELD:
case MN_NUMFIELD:
{
- int input_pos = ((strlen(pitem.input)*16)/2);
- int text_pos = ((strlen(pitem.text) + 1)*16)/2;
+ int input_pos = input_width/2;
+ int text_pos = (text_width + font_width)/2;
- fillrect(start_x - input_pos + text_pos - 1, cen_y_10_f - 10,
- (strlen(pitem.input)+1)*16 + 2, 20,
+ fillrect(x_pos - input_pos + text_pos - 1, y_pos - 10,
+ input_width + font_width + 2, 20,
255,255,255,255);
- fillrect(start_x - input_pos + text_pos, cen_y_10_f - 9,
- (strlen(pitem.input)+1)*16, 18,
+ fillrect(x_pos - input_pos + text_pos, y_pos - 9,
+ input_width + font_width, 18,
0,0,0,128);
- text_drawf(&gold_text, pitem.input,
- arrange + text_pos, 10 + f + y_pos,
- A_HMIDDLE, A_VMIDDLE, 2);
+ text_draw_align(&gold_text, pitem.input,
+ x_pos + text_pos, y_pos,
+ A_HMIDDLE, A_VMIDDLE, 2);
- text_drawf(text_font, pitem.text,
- arrange - (((strlen(pitem.input)+1) * 16)/2), y_pos + 10 + f,
- A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_draw_align(text_font, pitem.text,
+ x_pos - (input_width + font_width)/2, y_pos,
+ A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
case MN_STRINGSELECT:
{
- int list_pos_2 = (strlen(string_list_active(pitem.list))+1)*16;
- int list_pos = (strlen(string_list_active(pitem.list))*16)/2;
- int text_pos = ((strlen(pitem.text) + 1)*16)/2;
+ int list_pos_2 = list_width + font_width;
+ int list_pos = list_width/2;
+ int text_pos = (text_width + font_width)/2;
/* Draw arrows */
- texture_draw(&arrow_left, start_x - list_pos + text_pos - 17, cen_y_10_f - 8);
- texture_draw(&arrow_right, start_x - list_pos + text_pos - 1 + list_pos_2, cen_y_10_f - 8);
+ texture_draw(&arrow_left, x_pos - list_pos + text_pos - 17, y_pos - 8);
+ texture_draw(&arrow_right, x_pos - list_pos + text_pos - 1 + list_pos_2, y_pos - 8);
/* Draw input background */
- fillrect(start_x - list_pos + text_pos - 1, cen_y_10_f - 10,
+ fillrect(x_pos - list_pos + text_pos - 1, y_pos - 10,
list_pos_2 + 2, 20,
255,255,255,255);
- fillrect(start_x - list_pos + text_pos, cen_y_10_f - 9,
+ fillrect(x_pos - list_pos + text_pos, y_pos - 9,
list_pos_2, 18,
0,0,0,128);
- text_drawf(&gold_text, string_list_active(pitem.list),
- arrange + text_pos, 10 + f + y_pos,
+ text_draw_align(&gold_text, string_list_active(pitem.list),
+ x_pos + text_pos, y_pos,
A_HMIDDLE, A_VMIDDLE,2);
- text_drawf(text_font, pitem.text,
- arrange - list_pos_2/2, 10 + f + y_pos,
- A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_draw_align(text_font, pitem.text,
+ x_pos - list_pos_2/2, y_pos,
+ A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
}
case MN_BACK:
{
- texture_draw(&back, start_x + (strlen(pitem.text) * 16)/2 + 16, cen_y_10_f - 8);
+ texture_draw(&back, x_pos + text_width/2 + font_width, y_pos - 8);
break;
}
case MN_TOGGLE:
{
if(pitem.toggled == YES)
- texture_draw(&checkbox_checked, start_x + (strlen(pitem.text) * 16)/2 + 16, cen_y_10_f - 8);
+ texture_draw(&checkbox_checked,
+ x_pos + (text_width+font_width)/2,
+ y_pos - 8);
else
- texture_draw(&checkbox, start_x + (strlen(pitem.text) * 16)/2 + 16, cen_y_10_f - 8);
+ texture_draw(&checkbox,
+ x_pos + (text_width+font_width)/2,
+ y_pos - 8);
break;
}
case MN_ACTION:
case MN_GOTO:
case MN_TOGGLE:
case MN_BACK:
- text_drawf(text_font, pitem.text, arrange, 10 + f + y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
+ text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
break;
case MN_DEACTIVE:
case MN_TEXTFIELD:
}
}
- menu_width = menu_width * 16 + 48;
+ menu_width = menu_width * 16 + 48;
menu_height = (pmenu->num_items) * 24;
int center_x = screen->w/2;