33
33
#define UI_MENU_POOL_SIZE 65536
34
34
#define UI_MENU_ALLOC_ITEMS 256
36
#define MENU_TEXTCOLOR ARGB_WHITE
37
#define MENU_SELECTCOLOR MAKE_ARGB(0xff,0xff,0xff,0x00)
38
#define MENU_UNAVAILABLECOLOR MAKE_ARGB(0xff,0x40,0x40,0x40)
40
36
#define VISIBLE_GAMES_IN_LIST 15
42
38
#define MAX_PHYSICAL_DIPS 10
242
238
static const char backtext[] = "Return to " CAPSTARTGAMENOUN;
243
239
static const char exittext[] = "Exit";
245
static const rgb_t text_fgcolor = MAKE_ARGB(0xff,0xff,0xff,0xff);
246
static const rgb_t text_bgcolor = MAKE_ARGB(0xe0,0x80,0x80,0x80);
247
static const rgb_t sel_fgcolor = MAKE_ARGB(0xff,0xff,0xff,0x00);
248
static const rgb_t sel_bgcolor = MAKE_ARGB(0xe0,0x80,0x80,0x00);
249
static const rgb_t mouseover_fgcolor = MAKE_ARGB(0xff,0xff,0xff,0x80);
250
static const rgb_t mouseover_bgcolor = MAKE_ARGB(0x70,0x40,0x40,0x00);
251
static const rgb_t mousedown_fgcolor = MAKE_ARGB(0xff,0xff,0xff,0x80);
252
static const rgb_t mousedown_bgcolor = MAKE_ARGB(0xB0,0x60,0x60,0x00);
256
243
/***************************************************************************
278
265
static void menu_input_specific_populate(running_machine *machine, ui_menu *menu, input_menu_state *menustate);
279
266
static void menu_input_common(running_machine *machine, ui_menu *menu, void *parameter, void *state);
280
267
static int CLIB_DECL menu_input_compare_items(const void *i1, const void *i2);
281
static void menu_input_populate_and_sort(ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate);
268
static void menu_input_populate_and_sort(running_machine *machine, ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate);
282
269
static void menu_settings_dip_switches(running_machine *machine, ui_menu *menu, void *parameter, void *state);
283
270
static void menu_settings_driver_config(running_machine *machine, ui_menu *menu, void *parameter, void *state);
284
271
static void menu_settings_categories(running_machine *machine, ui_menu *menu, void *parameter, void *state);
815
802
x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
816
803
y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
818
ui_draw_outlined_box(x1, y1, x2, y2, UI_FILLCOLOR);
805
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR);
820
807
/* determine the first visible line based on the current selection */
821
808
top_line = menu->selected - visible_lines / 2;
848
835
int itemnum = top_line + linenum;
849
836
const ui_menu_item *item = &menu->item[itemnum];
850
837
const char *itemtext = item->text;
851
rgb_t fgcolor = text_fgcolor;
852
rgb_t bgcolor = text_bgcolor;
838
rgb_t fgcolor = UI_TEXT_COLOR;
839
rgb_t bgcolor = UI_TEXT_BG_COLOR;
840
rgb_t fgcolor2 = UI_SUBITEM_COLOR;
841
rgb_t fgcolor3 = UI_CLONE_COLOR;
853
842
float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
854
843
float line_y0 = line_y;
855
844
float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
862
851
/* if we're selected, draw with a different background */
863
852
if (itemnum == menu->selected)
865
fgcolor = sel_fgcolor;
866
bgcolor = sel_bgcolor;
854
fgcolor = UI_SELECTED_COLOR;
855
bgcolor = UI_SELECTED_BG_COLOR;
856
fgcolor2 = UI_SELECTED_COLOR;
857
fgcolor3 = UI_SELECTED_COLOR;
869
860
/* else if the mouse is over this item, draw with a different background */
870
861
else if (itemnum == menu->hover)
872
fgcolor = mouseover_fgcolor;
873
bgcolor = mouseover_bgcolor;
863
fgcolor = UI_MOUSEOVER_COLOR;
864
bgcolor = UI_MOUSEOVER_BG_COLOR;
865
fgcolor2 = UI_MOUSEOVER_COLOR;
866
fgcolor3 = UI_MOUSEOVER_COLOR;
876
869
/* if we have some background hilighting to do, add a quad behind everything else */
877
if (bgcolor != text_bgcolor)
870
if (bgcolor != UI_TEXT_BG_COLOR)
878
871
render_ui_add_quad(line_x0, line_y0, line_x1, line_y1, bgcolor, hilight_texture,
879
872
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
909
902
/* if we're just a divider, draw a line */
910
903
else if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0)
911
render_ui_add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
904
render_ui_add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
913
906
/* if we don't have a subitem, just draw the string centered */
914
907
else if (item->subtext == NULL)
940
933
/* draw the subitem right-justified */
941
934
ui_draw_text_full(subitem_text, effective_left + item_width, line_y, effective_width - item_width,
942
JUSTIFY_RIGHT, WRAP_TRUNCATE, subitem_invert ? DRAW_OPAQUE : DRAW_NORMAL, fgcolor, bgcolor, &subitem_width, NULL);
935
JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, NULL);
944
937
/* apply arrows */
945
938
if (itemnum == menu->selected && (item->flags & MENU_FLAG_LEFT_ARROW))
989
982
ui_draw_outlined_box(target_x - UI_BOX_LR_BORDER,
990
983
target_y - UI_BOX_TB_BORDER,
991
984
target_x + target_width + UI_BOX_LR_BORDER,
992
target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? sel_bgcolor : UI_FILLCOLOR);
985
target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR);
993
986
ui_draw_text_full(item->subtext, target_x, target_y, target_width,
994
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, sel_fgcolor, sel_bgcolor, NULL, NULL);
987
JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL);
997
/* if there is somthing special to add, do it by calling the passed routine */
990
/* if there is something special to add, do it by calling the passed routine */
998
991
if (menu->custom != NULL)
1000
993
void *selectedref = (menu->selected >= 0 && menu->selected < menu->numitems) ? menu->item[menu->selected].ref : NULL;
1051
1044
ui_draw_outlined_box(target_x - UI_BOX_LR_BORDER - gutter_width,
1052
1045
target_y - UI_BOX_TB_BORDER,
1053
1046
target_x + target_width + gutter_width + UI_BOX_LR_BORDER,
1054
target_y + target_height + UI_BOX_TB_BORDER, (menu->item[0].flags & MENU_FLAG_REDTEXT) ? UI_REDCOLOR : UI_FILLCOLOR);
1047
target_y + target_height + UI_BOX_TB_BORDER, (menu->item[0].flags & MENU_FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR);
1055
1048
ui_draw_text_full(text, target_x, target_y, target_width,
1056
JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
1049
JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
1058
1051
/* draw the "return to prior menu" text with a hilight behind it */
1059
1052
render_ui_add_quad( target_x + 0.5f * UI_LINE_WIDTH,
1060
1053
target_y + target_height - line_height,
1061
1054
target_x + target_width - 0.5f * UI_LINE_WIDTH,
1062
1055
target_y + target_height,
1056
UI_SELECTED_BG_COLOR,
1064
1057
hilight_texture,
1065
1058
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
1066
1059
ui_draw_text_full(backtext, target_x, target_y + target_height - line_height, target_width,
1067
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, sel_fgcolor, sel_bgcolor, NULL, NULL);
1060
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, NULL, NULL);
1069
1062
/* artificially set the hover to the last item so a double-click exits */
1070
1063
menu->hover = menu->numitems - 1;
1228
1221
if (!ignorepause && exclusive_input_pressed(menu, IPT_UI_PAUSE, 0))
1229
1222
mame_pause(menu->machine, !mame_is_paused(menu->machine));
1224
/* handle a toggle cheats request */
1225
if (ui_input_pressed_repeat(menu->machine, IPT_UI_TOGGLE_CHEAT, 0))
1226
cheat_set_global_enable(menu->machine, !cheat_get_global_enable(menu->machine));
1231
1228
/* see if any other UI keys are pressed */
1232
1229
if (menu->event.iptkey == IPT_INVALID)
1233
1230
for (code = __ipt_ui_start; code <= __ipt_ui_end; code++)
1855
1852
-------------------------------------------------*/
1857
static void menu_input_populate_and_sort(ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate)
1854
static void menu_input_populate_and_sort(running_machine *machine, ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate)
1859
1856
const char *nameformat[INPUT_TYPE_TOTAL] = { 0 };
1860
1857
input_item_data **itemarray, *item;
2104
2101
y2 = y1 + bottom;
2106
2103
/* draw extra menu area */
2107
ui_draw_outlined_box(x1, y1, x2, y2, UI_FILLCOLOR);
2104
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR);
2108
2105
y1 += (float)DIP_SWITCH_SPACING;
2110
2107
/* iterate over DIP switches */
2171
2168
/* first outline the switch */
2172
ui_draw_outlined_box(x1, y1, x1 + switch_field_width, y2, UI_FILLCOLOR);
2169
ui_draw_outlined_box(x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
2174
2171
/* compute x1/x2 for the inner filled in switch */
2175
2172
innerx1 = x1 + (switch_field_width - switch_width) / 2;
2180
2177
float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
2181
2178
render_ui_add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT,
2182
(selectedmask & (1 << toggle)) ? MENU_SELECTCOLOR : ARGB_WHITE,
2179
(selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR,
2183
2180
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2187
2184
render_ui_add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT,
2188
MENU_UNAVAILABLECOLOR,
2185
UI_UNAVAILABLE_COLOR,
2189
2186
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2530
2531
case IPT_UI_RIGHT:
2531
2532
changed = cheat_select_next_state(machine, event->itemref);
2535
/* bring up display comment if one exists */
2536
case IPT_UI_DISPLAY_COMMENT:
2539
if (cheat_get_comment(event->itemref) != NULL)
2540
popmessage("Cheat Comment:\n%s", astring_c(cheat_get_comment(event->itemref)));
2545
/* handle reload all */
2546
if ((FPTR)event->itemref == 2 && event->iptkey == IPT_UI_SELECT)
2548
/* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */
2549
cheat_reload(machine);
2551
/* display the reloaded cheats */
2552
ui_menu_reset(menu, UI_MENU_RESET_REMEMBER_REF);
2553
popmessage("All cheats reloaded");
2536
2556
/* if things changed, update */
2538
2558
ui_menu_reset(menu, UI_MENU_RESET_REMEMBER_REF);
2717
2740
/* decrease value */
2718
2741
case IPT_UI_LEFT:
2719
if (input_code_pressed(KEYCODE_LALT) || input_code_pressed(KEYCODE_RALT))
2742
if (input_code_pressed(machine, KEYCODE_LALT) || input_code_pressed(machine, KEYCODE_RALT))
2720
2743
increment = -1;
2721
else if (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT))
2744
else if (input_code_pressed(machine, KEYCODE_LSHIFT) || input_code_pressed(machine, KEYCODE_RSHIFT))
2722
2745
increment = (slider->incval > 10) ? -(slider->incval / 10) : -1;
2723
else if (input_code_pressed(KEYCODE_LCONTROL) || input_code_pressed(KEYCODE_RCONTROL))
2746
else if (input_code_pressed(machine, KEYCODE_LCONTROL) || input_code_pressed(machine, KEYCODE_RCONTROL))
2724
2747
increment = -slider->incval * 10;
2726
2749
increment = -slider->incval;
2729
2752
/* increase value */
2730
2753
case IPT_UI_RIGHT:
2731
if (input_code_pressed(KEYCODE_LALT) || input_code_pressed(KEYCODE_RALT))
2754
if (input_code_pressed(machine, KEYCODE_LALT) || input_code_pressed(machine, KEYCODE_RALT))
2733
else if (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT))
2756
else if (input_code_pressed(machine, KEYCODE_LSHIFT) || input_code_pressed(machine, KEYCODE_RSHIFT))
2734
2757
increment = (slider->incval > 10) ? (slider->incval / 10) : 1;
2735
else if (input_code_pressed(KEYCODE_LCONTROL) || input_code_pressed(KEYCODE_RCONTROL))
2758
else if (input_code_pressed(machine, KEYCODE_LCONTROL) || input_code_pressed(machine, KEYCODE_RCONTROL))
2736
2759
increment = slider->incval * 10;
2738
2761
increment = slider->incval;
2847
2870
x2 = 1.0f - UI_BOX_LR_BORDER;
2849
2872
/* draw extra menu area */
2850
ui_draw_outlined_box(x1, y1, x2, y2, UI_FILLCOLOR);
2873
ui_draw_outlined_box(x1, y1, x2, y2, UI_BACKGROUND_COLOR);
2851
2874
y1 += UI_BOX_TB_BORDER;
2853
2876
/* determine the text height */
2867
2890
current_x = bar_left + bar_width * percentage;
2869
2892
/* fill in the percentage */
2870
render_ui_add_rect(bar_left, bar_top, current_x, bar_bottom, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2893
render_ui_add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2872
2895
/* draw the top and bottom lines */
2873
render_ui_add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2874
render_ui_add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2896
render_ui_add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2897
render_ui_add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2876
2899
/* draw default marker */
2877
render_ui_add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2878
render_ui_add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, ARGB_WHITE, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2900
render_ui_add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2901
render_ui_add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
2880
2903
/* draw the actual text */
2881
2904
ui_draw_text_full(astring_c(tempstring), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
2882
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, &text_height);
2905
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height);
2884
2907
astring_free(tempstring);
3244
3267
/* look for files ending in .png with a name not larger then 9 chars*/
3245
3268
if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) &&
3246
3269
dir->name[length - 4] == '.' &&
3247
tolower(dir->name[length - 3]) == 'p' &&
3248
tolower(dir->name[length - 2]) == 'n' &&
3249
tolower(dir->name[length - 1]) == 'g')
3270
tolower((UINT8)dir->name[length - 3]) == 'p' &&
3271
tolower((UINT8)dir->name[length - 2]) == 'n' &&
3272
tolower((UINT8)dir->name[length - 1]) == 'g')
3252
3275
/* remove .png from length */
3630
3653
/* draw the text within it */
3631
3654
ui_draw_text_full(&tempbuf[0][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
3632
DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
3655
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
3634
3657
/* determine the text to render below */
3635
3658
driver = ((FPTR)selectedref > 1) ? (const game_driver *)selectedref : NULL;
3725
3750
for (line = 0; line < 4; line++)
3727
3752
ui_draw_text_full(&tempbuf[line][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
3728
DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
3753
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL);
3729
3754
y1 += ui_get_line_height();