src/mess/osd/windows/menu.c
| r3757 | r3758 | |
| 1308 | 1308 | // prepare_menus |
| 1309 | 1309 | //============================================================ |
| 1310 | 1310 | |
| 1311 | | static void prepare_menus(running_machine *machine, HWND wnd) |
| 1311 | static void prepare_menus(HWND wnd) |
| 1312 | 1312 | { |
| 1313 | 1313 | int i; |
| 1314 | 1314 | char buf[MAX_PATH]; |
| r3757 | r3758 | |
| 1343 | 1343 | |
| 1344 | 1344 | if (!joystick_menu_setup) |
| 1345 | 1345 | { |
| 1346 | | setup_joystick_menu(machine, menu_bar); |
| 1346 | setup_joystick_menu(window->machine, menu_bar); |
| 1347 | 1347 | joystick_menu_setup = 1; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| r3757 | r3758 | |
| 1353 | 1353 | |
| 1354 | 1354 | speed = video_get_throttle() ? video_get_speed_factor() : 0; |
| 1355 | 1355 | |
| 1356 | | has_config = input_has_input_class(machine, INPUT_CLASS_CONFIG); |
| 1357 | | has_dipswitch = input_has_input_class(machine, INPUT_CLASS_DIPSWITCH); |
| 1358 | | has_keyboard = input_has_input_class(machine, INPUT_CLASS_KEYBOARD); |
| 1359 | | has_misc = input_has_input_class(machine, INPUT_CLASS_MISC); |
| 1356 | has_config = input_has_input_class(window->machine, INPUT_CLASS_CONFIG); |
| 1357 | has_dipswitch = input_has_input_class(window->machine, INPUT_CLASS_DIPSWITCH); |
| 1358 | has_keyboard = input_has_input_class(window->machine, INPUT_CLASS_KEYBOARD); |
| 1359 | has_misc = input_has_input_class(window->machine, INPUT_CLASS_MISC); |
| 1360 | 1360 | |
| 1361 | 1361 | has_analog = 0; |
| 1362 | | for (port = machine->portconfig; port != NULL; port = port->next) |
| 1362 | for (port = window->machine->portconfig; port != NULL; port = port->next) |
| 1363 | 1363 | { |
| 1364 | 1364 | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1365 | 1365 | { |
| r3757 | r3758 | |
| 1373 | 1373 | |
| 1374 | 1374 | set_command_state(menu_bar, ID_FILE_SAVESTATE, state_filename[0] != '\0' ? MFS_ENABLED : MFS_GRAYED); |
| 1375 | 1375 | |
| 1376 | | set_command_state(menu_bar, ID_EDIT_PASTE, inputx_can_post(machine) ? MFS_ENABLED : MFS_GRAYED); |
| 1376 | set_command_state(menu_bar, ID_EDIT_PASTE, inputx_can_post(window->machine) ? MFS_ENABLED : MFS_GRAYED); |
| 1377 | 1377 | |
| 1378 | | set_command_state(menu_bar, ID_OPTIONS_PAUSE, winwindow_ui_is_paused(machine) ? MFS_CHECKED : MFS_ENABLED); |
| 1378 | set_command_state(menu_bar, ID_OPTIONS_PAUSE, winwindow_ui_is_paused(window->machine) ? MFS_CHECKED : MFS_ENABLED); |
| 1379 | 1379 | set_command_state(menu_bar, ID_OPTIONS_CONFIGURATION, has_config ? MFS_ENABLED : MFS_GRAYED); |
| 1380 | 1380 | set_command_state(menu_bar, ID_OPTIONS_DIPSWITCHES, has_dipswitch ? MFS_ENABLED : MFS_GRAYED); |
| 1381 | 1381 | set_command_state(menu_bar, ID_OPTIONS_MISCINPUT, has_misc ? MFS_ENABLED : MFS_GRAYED); |
| r3757 | r3758 | |
| 1389 | 1389 | #endif |
| 1390 | 1390 | |
| 1391 | 1391 | set_command_state(menu_bar, ID_KEYBOARD_EMULATED, (has_keyboard) ? |
| 1392 | | (!ui_mess_get_use_natural_keyboard(machine) ? MFS_CHECKED : MFS_ENABLED) |
| 1392 | (!ui_mess_get_use_natural_keyboard(window->machine) ? MFS_CHECKED : MFS_ENABLED) |
| 1393 | 1393 | : MFS_GRAYED); |
| 1394 | | set_command_state(menu_bar, ID_KEYBOARD_NATURAL, (has_keyboard && inputx_can_post(machine)) ? (ui_mess_get_use_natural_keyboard(machine) ? MFS_CHECKED : MFS_ENABLED) |
| 1394 | set_command_state(menu_bar, ID_KEYBOARD_NATURAL, (has_keyboard && inputx_can_post(window->machine)) ? (ui_mess_get_use_natural_keyboard(window->machine) ? MFS_CHECKED : MFS_ENABLED) |
| 1395 | 1395 | : MFS_GRAYED); |
| 1396 | 1396 | set_command_state(menu_bar, ID_KEYBOARD_CUSTOMIZE, has_keyboard ? MFS_ENABLED : MFS_GRAYED); |
| 1397 | 1397 | |
| r3757 | r3758 | |
| 1414 | 1414 | // if we are using categorized input, we need to properly checkmark the categories |
| 1415 | 1415 | if (use_input_categories) |
| 1416 | 1416 | { |
| 1417 | | for (port = machine->portconfig; port != NULL; port = port->next) |
| 1417 | for (port = window->machine->portconfig; port != NULL; port = port->next) |
| 1418 | 1418 | { |
| 1419 | 1419 | for (field = port->fieldlist; field != NULL; field = field->next) |
| 1420 | 1420 | { |
| r3757 | r3758 | |
| 1423 | 1423 | input_field_get_user_settings(field, &settings); |
| 1424 | 1424 | for (setting = field->settinglist; setting != NULL; setting = setting->next) |
| 1425 | 1425 | { |
| 1426 | | command = ID_INPUT_0 + serial_number_from_input_item(machine, port, field, setting); |
| 1426 | command = ID_INPUT_0 + serial_number_from_input_item(window->machine, port, field, setting); |
| 1427 | 1427 | set_command_state(menu_bar, command, (setting->value == settings.value) ? MFS_CHECKED : MFS_ENABLED); |
| 1428 | 1428 | } |
| 1429 | 1429 | } |
| r3757 | r3758 | |
| 1456 | 1456 | remove_menu_items(device_menu); |
| 1457 | 1457 | |
| 1458 | 1458 | // then set up the actual devices |
| 1459 | | for (img = image_device_first(machine->config); img != NULL; img = image_device_next(img)) |
| 1459 | for (img = image_device_first(window->machine->config); img != NULL; img = image_device_next(img)) |
| 1460 | 1460 | { |
| 1461 | | image_device_info info = image_device_getinfo(machine->config, img); |
| 1461 | image_device_info info = image_device_getinfo(window->machine->config, img); |
| 1462 | 1462 | |
| 1463 | 1463 | new_item = ID_DEVICE_0 + (image_absolute_index(img) * DEVOPTION_MAX); |
| 1464 | 1464 | flags_for_exists = MF_STRING; |
| r3757 | r3758 | |
| 1745 | 1745 | // invoke_command |
| 1746 | 1746 | //============================================================ |
| 1747 | 1747 | |
| 1748 | | static int invoke_command(running_machine *machine, HWND wnd, UINT command) |
| 1748 | static int invoke_command(HWND wnd, UINT command) |
| 1749 | 1749 | { |
| 1750 | 1750 | int handled = 1; |
| 1751 | 1751 | int dev_command; |
| r3757 | r3758 | |
| 1760 | 1760 | |
| 1761 | 1761 | // pause while invoking certain commands |
| 1762 | 1762 | if (pause_for_command(command)) |
| 1763 | | winwindow_ui_pause_from_window_thread(machine, TRUE); |
| 1763 | winwindow_ui_pause_from_window_thread(window->machine, TRUE); |
| 1764 | 1764 | |
| 1765 | 1765 | switch(command) |
| 1766 | 1766 | { |
| 1767 | 1767 | case ID_FILE_LOADSTATE: |
| 1768 | | state_load(wnd, machine); |
| 1768 | state_load(wnd, window->machine); |
| 1769 | 1769 | break; |
| 1770 | 1770 | |
| 1771 | 1771 | case ID_FILE_SAVESTATE: |
| 1772 | | state_save(machine); |
| 1772 | state_save(window->machine); |
| 1773 | 1773 | break; |
| 1774 | 1774 | |
| 1775 | 1775 | case ID_FILE_SAVESTATE_AS: |
| 1776 | | state_save_as(wnd, machine); |
| 1776 | state_save_as(wnd, window->machine); |
| 1777 | 1777 | break; |
| 1778 | 1778 | |
| 1779 | 1779 | case ID_FILE_SAVESCREENSHOT: |
| 1780 | | video_save_active_screen_snapshots(machine); |
| 1780 | video_save_active_screen_snapshots(window->machine); |
| 1781 | 1781 | break; |
| 1782 | 1782 | |
| 1783 | 1783 | case ID_FILE_EXIT: |
| 1784 | | mame_schedule_exit(machine); |
| 1784 | mame_schedule_exit(window->machine); |
| 1785 | 1785 | break; |
| 1786 | 1786 | |
| 1787 | 1787 | case ID_EDIT_PASTE: |
| r3757 | r3758 | |
| 1789 | 1789 | break; |
| 1790 | 1790 | |
| 1791 | 1791 | case ID_KEYBOARD_NATURAL: |
| 1792 | | ui_mess_set_use_natural_keyboard(machine, TRUE); |
| 1792 | ui_mess_set_use_natural_keyboard(window->machine, TRUE); |
| 1793 | 1793 | break; |
| 1794 | 1794 | |
| 1795 | 1795 | case ID_KEYBOARD_EMULATED: |
| 1796 | | ui_mess_set_use_natural_keyboard(machine, FALSE); |
| 1796 | ui_mess_set_use_natural_keyboard(window->machine, FALSE); |
| 1797 | 1797 | break; |
| 1798 | 1798 | |
| 1799 | 1799 | case ID_KEYBOARD_CUSTOMIZE: |
| 1800 | | customize_keyboard(machine, wnd); |
| 1800 | customize_keyboard(window->machine, wnd); |
| 1801 | 1801 | break; |
| 1802 | 1802 | |
| 1803 | 1803 | case ID_VIDEO_ROTATE_0: |
| r3757 | r3758 | |
| 1817 | 1817 | break; |
| 1818 | 1818 | |
| 1819 | 1819 | case ID_OPTIONS_PAUSE: |
| 1820 | | pause(machine); |
| 1820 | pause(window->machine); |
| 1821 | 1821 | break; |
| 1822 | 1822 | |
| 1823 | 1823 | case ID_OPTIONS_HARDRESET: |
| 1824 | | mame_schedule_hard_reset(machine); |
| 1824 | mame_schedule_hard_reset(window->machine); |
| 1825 | 1825 | break; |
| 1826 | 1826 | |
| 1827 | 1827 | case ID_OPTIONS_SOFTRESET: |
| 1828 | | mame_schedule_soft_reset(machine); |
| 1828 | mame_schedule_soft_reset(window->machine); |
| 1829 | 1829 | break; |
| 1830 | 1830 | |
| 1831 | 1831 | #if HAS_PROFILER |
| r3757 | r3758 | |
| 1835 | 1835 | #endif // HAS_PROFILER |
| 1836 | 1836 | |
| 1837 | 1837 | case ID_OPTIONS_DEBUGGER: |
| 1838 | | debug_cpu_halt_on_next_instruction(debug_cpu_get_visible_cpu(machine), "User-initiated break\n"); |
| 1838 | debug_cpu_halt_on_next_instruction(debug_cpu_get_visible_cpu(window->machine), "User-initiated break\n"); |
| 1839 | 1839 | break; |
| 1840 | 1840 | |
| 1841 | 1841 | case ID_OPTIONS_CONFIGURATION: |
| 1842 | | customize_configuration(machine, wnd); |
| 1842 | customize_configuration(window->machine, wnd); |
| 1843 | 1843 | break; |
| 1844 | 1844 | |
| 1845 | 1845 | case ID_OPTIONS_DIPSWITCHES: |
| 1846 | | customize_dipswitches(machine, wnd); |
| 1846 | customize_dipswitches(window->machine, wnd); |
| 1847 | 1847 | break; |
| 1848 | 1848 | |
| 1849 | 1849 | case ID_OPTIONS_MISCINPUT: |
| 1850 | | customize_miscinput(machine, wnd); |
| 1850 | customize_miscinput(window->machine, wnd); |
| 1851 | 1851 | break; |
| 1852 | 1852 | |
| 1853 | 1853 | case ID_OPTIONS_ANALOGCONTROLS: |
| 1854 | | customize_analogcontrols(machine, wnd); |
| 1854 | customize_analogcontrols(window->machine, wnd); |
| 1855 | 1855 | break; |
| 1856 | 1856 | |
| 1857 | 1857 | #if HAS_TOGGLEFULLSCREEN |
| r3757 | r3758 | |
| 1887 | 1887 | break; |
| 1888 | 1888 | |
| 1889 | 1889 | case ID_HELP_ABOUTSYSTEM: |
| 1890 | | help_about_thissystem(machine, wnd); |
| 1890 | help_about_thissystem(window->machine, wnd); |
| 1891 | 1891 | break; |
| 1892 | 1892 | |
| 1893 | 1893 | case ID_THROTTLE_50: |
| r3757 | r3758 | |
| 1923 | 1923 | else if ((command >= ID_DEVICE_0) && (command < ID_DEVICE_0 + (MAX_DEV_INSTANCES*IO_COUNT*DEVOPTION_MAX))) |
| 1924 | 1924 | { |
| 1925 | 1925 | // change device |
| 1926 | | img = decode_deviceoption(machine, command, &dev_command); |
| 1926 | img = decode_deviceoption(window->machine, command, &dev_command); |
| 1927 | 1927 | device_command(wnd, img, dev_command); |
| 1928 | 1928 | } |
| 1929 | 1929 | else if ((command >= ID_JOYSTICK_0) && (command < ID_JOYSTICK_0 + MAX_JOYSTICKS)) |
| 1930 | 1930 | { |
| 1931 | 1931 | // customize joystick |
| 1932 | | customize_joystick(machine, wnd, command - ID_JOYSTICK_0); |
| 1932 | customize_joystick(window->machine, wnd, command - ID_JOYSTICK_0); |
| 1933 | 1933 | } |
| 1934 | 1934 | else if ((command >= ID_VIDEO_VIEW_0) && (command < ID_VIDEO_VIEW_0 + 1000)) |
| 1935 | 1935 | { |
| 1936 | 1936 | // render views |
| 1937 | 1937 | render_target_set_view(window->target, command - ID_VIDEO_VIEW_0); |
| 1938 | 1938 | } |
| 1939 | | else if (input_item_from_serial_number(machine, command - ID_INPUT_0, NULL, &field, &setting)) |
| 1939 | else if (input_item_from_serial_number(window->machine, command - ID_INPUT_0, NULL, &field, &setting)) |
| 1940 | 1940 | { |
| 1941 | 1941 | if ((field != NULL) && (field->type == IPT_CATEGORY) && (setting != NULL)) |
| 1942 | 1942 | { |
| r3757 | r3758 | |
| 1960 | 1960 | section = setting->name; |
| 1961 | 1961 | } |
| 1962 | 1962 | } |
| 1963 | | customize_categorizedinput(machine, wnd, section, category); |
| 1963 | customize_categorizedinput(window->machine, wnd, section, category); |
| 1964 | 1964 | } |
| 1965 | 1965 | else |
| 1966 | 1966 | { |
| r3757 | r3758 | |
| 1978 | 1978 | |
| 1979 | 1979 | // resume emulation |
| 1980 | 1980 | if (pause_for_command(command)) |
| 1981 | | winwindow_ui_pause_from_window_thread(machine, FALSE); |
| 1981 | winwindow_ui_pause_from_window_thread(window->machine, FALSE); |
| 1982 | 1982 | |
| 1983 | 1983 | return handled; |
| 1984 | 1984 | } |
| r3757 | r3758 | |
| 2144 | 2144 | switch(message) |
| 2145 | 2145 | { |
| 2146 | 2146 | case WM_INITMENU: |
| 2147 | | prepare_menus(Machine, wnd); |
| 2147 | prepare_menus(wnd); |
| 2148 | 2148 | break; |
| 2149 | 2149 | |
| 2150 | 2150 | case WM_PASTE: |
| r3757 | r3758 | |
| 2152 | 2152 | break; |
| 2153 | 2153 | |
| 2154 | 2154 | case WM_COMMAND: |
| 2155 | | if (invoke_command(Machine, wnd, wparam)) |
| 2155 | if (invoke_command(wnd, wparam)) |
| 2156 | 2156 | break; |
| 2157 | 2157 | /* fall through */ |
| 2158 | 2158 | |