src/mess/osd/winui/messui.c
| r2321 | r2322 | |
| 66 | 66 | static void SoftwarePicker_LeavingItem(HWND hwndSoftwarePicker, int nItem); |
| 67 | 67 | static void SoftwarePicker_EnteringItem(HWND hwndSoftwarePicker, int nItem); |
| 68 | 68 | |
| 69 | | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength); |
| 70 | | static BOOL DevView_GetCreateFileName(HWND hwndDevView, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength); |
| 71 | | static void DevView_SetSelectedSoftware(HWND hwndDevView, int nDriverIndex, const device_config *dev, LPCTSTR pszFilename); |
| 72 | | static LPCTSTR DevView_GetSelectedSoftware(HWND hwndDevView, int nDriverIndex, const device_config *dev, LPTSTR pszBuffer, UINT nBufferLength); |
| 69 | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength); |
| 70 | static BOOL DevView_GetCreateFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength); |
| 71 | static void DevView_SetSelectedSoftware(HWND hwndDevView, int nDriverIndex, const machine_config *config, const device_config *dev, LPCTSTR pszFilename); |
| 72 | static LPCTSTR DevView_GetSelectedSoftware(HWND hwndDevView, int nDriverIndex, const machine_config *config, const device_config *dev, LPTSTR pszBuffer, UINT nBufferLength); |
| 73 | 73 | |
| 74 | 74 | #ifdef MAME_DEBUG |
| 75 | 75 | static void MessTestsBegin(void); |
| r2321 | r2322 | |
| 353 | 353 | nPos = 0; |
| 354 | 354 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 355 | 355 | { |
| 356 | | image_device_info info = image_device_getinfo(dev); |
| 356 | image_device_info info = image_device_getinfo(config, dev); |
| 357 | 357 | |
| 358 | 358 | // confirm any mandatory devices are loaded |
| 359 | 359 | if (info.must_be_loaded) |
| 360 | 360 | { |
| 361 | | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 361 | pszSoftware = GetSelectedSoftware(drvindex, config, dev); |
| 362 | 362 | if (!pszSoftware || !*pszSoftware) |
| 363 | 363 | { |
| 364 | 364 | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| r2321 | r2322 | |
| 386 | 386 | |
| 387 | 387 | |
| 388 | 388 | // this is a wrapper call to wrap the idiosycracies of SetSelectedSoftware() |
| 389 | | static void InternalSetSelectedSoftware(int drvindex, const device_config *device, const char *pszSoftware) |
| 389 | static void InternalSetSelectedSoftware(int drvindex, const machine_config *config, const device_config *device, const char *pszSoftware) |
| 390 | 390 | { |
| 391 | 391 | if (!pszSoftware) |
| 392 | 392 | pszSoftware = ""; |
| 393 | 393 | |
| 394 | 394 | // only call SetSelectedSoftware() if this value is different |
| 395 | | if (strcmp(GetSelectedSoftware(drvindex, device), pszSoftware)) |
| 395 | if (strcmp(GetSelectedSoftware(drvindex, config, device), pszSoftware)) |
| 396 | 396 | { |
| 397 | | SetSelectedSoftware(drvindex, device, pszSoftware); |
| 397 | SetSelectedSoftware(drvindex, config, device, pszSoftware); |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| r2321 | r2322 | |
| 417 | 417 | { |
| 418 | 418 | for (device = image_device_first(config); device != NULL; device = image_device_next(device)) |
| 419 | 419 | { |
| 420 | | s = GetSelectedSoftware(drvindex, device); |
| 420 | s = GetSelectedSoftware(drvindex, config, device); |
| 421 | 421 | if ((s != NULL) && !mame_stricmp(s, pszFilename)) |
| 422 | 422 | break; |
| 423 | 423 | } |
| r2321 | r2322 | |
| 445 | 445 | if (device != NULL) |
| 446 | 446 | { |
| 447 | 447 | // place the image |
| 448 | | InternalSetSelectedSoftware(drvindex, device, pszFilename); |
| 448 | InternalSetSelectedSoftware(drvindex, config, device, pszFilename); |
| 449 | 449 | } |
| 450 | 450 | else |
| 451 | 451 | { |
| r2321 | r2322 | |
| 500 | 500 | |
| 501 | 501 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 502 | 502 | { |
| 503 | | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 503 | pszSoftware = GetSelectedSoftware(drvindex, config, dev); |
| 504 | 504 | if (pszSoftware && *pszSoftware) |
| 505 | 505 | { |
| 506 | 506 | i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware); |
| r2321 | r2322 | |
| 569 | 569 | const char *ext; |
| 570 | 570 | } mess_image_type; |
| 571 | 571 | |
| 572 | | static BOOL CommonFileImageDialog(LPTSTR the_last_directory, common_file_dialog_proc cfd, LPTSTR filename, mess_image_type *imagetypes) |
| 572 | static BOOL CommonFileImageDialog(LPTSTR the_last_directory, common_file_dialog_proc cfd, LPTSTR filename, const machine_config *config, mess_image_type *imagetypes) |
| 573 | 573 | { |
| 574 | 574 | BOOL success; |
| 575 | 575 | OPENFILENAME of; |
| r2321 | r2322 | |
| 611 | 611 | if (!imagetypes[i].dev) |
| 612 | 612 | typname = "Compressed images"; |
| 613 | 613 | else |
| 614 | | typname = lookupdevice(image_device_getinfo(imagetypes[i].dev).type)->dlgname; |
| 614 | typname = lookupdevice(image_device_getinfo(config, imagetypes[i].dev).type)->dlgname; |
| 615 | 615 | |
| 616 | 616 | strcpy(s, typname); |
| 617 | 617 | s += strlen(s); |
| r2321 | r2322 | |
| 695 | 695 | /* special case; all non-printer devices */ |
| 696 | 696 | for (dev = image_device_first(config); dev != NULL; dev = image_device_next(dev)) |
| 697 | 697 | { |
| 698 | | image_device_info info = image_device_getinfo(dev); |
| 698 | image_device_info info = image_device_getinfo(config, dev); |
| 699 | 699 | |
| 700 | 700 | if (info.type != IO_PRINTER) |
| 701 | 701 | SetupImageTypes(config, &types[num_extensions], count - num_extensions, FALSE, dev); |
| r2321 | r2322 | |
| 704 | 704 | } |
| 705 | 705 | else |
| 706 | 706 | { |
| 707 | | image_device_info info = image_device_getinfo(dev); |
| 707 | image_device_info info = image_device_getinfo(config, dev); |
| 708 | 708 | const char *ext = info.file_extensions; |
| 709 | 709 | |
| 710 | 710 | if (ext != NULL) |
| r2321 | r2322 | |
| 744 | 744 | |
| 745 | 745 | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 746 | 746 | |
| 747 | | if (CommonFileImageDialog(last_directory, cfd, filename, imagetypes)) |
| 747 | if (CommonFileImageDialog(last_directory, cfd, filename, config, imagetypes)) |
| 748 | 748 | { |
| 749 | 749 | utf8_filename = utf8_from_tstring(filename); |
| 750 | 750 | if( !utf8_filename ) |
| r2321 | r2322 | |
| 773 | 773 | |
| 774 | 774 | |
| 775 | 775 | |
| 776 | | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 776 | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 777 | 777 | { |
| 778 | 778 | BOOL bResult; |
| 779 | 779 | mess_image_type imagetypes[64]; |
| 780 | 780 | HWND hwndList; |
| 781 | 781 | int gamenum; |
| 782 | | machine_config *config; |
| 783 | 782 | |
| 784 | 783 | hwndList = GetDlgItem(GetMainWindow(), IDC_LIST); |
| 785 | 784 | gamenum = Picker_GetSelectedItem(hwndList); |
| 786 | 785 | |
| 787 | | // allocate the machine config |
| 788 | | config = machine_config_alloc_with_mess_devices(drivers[gamenum]); |
| 789 | | |
| 790 | 786 | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 791 | | bResult = CommonFileImageDialog(last_directory, GetOpenFileName, pszFilename, imagetypes); |
| 787 | bResult = CommonFileImageDialog(last_directory, GetOpenFileName, pszFilename, config, imagetypes); |
| 792 | 788 | |
| 793 | | machine_config_free(config); |
| 794 | 789 | return bResult; |
| 795 | 790 | } |
| 796 | 791 | |
| 797 | 792 | |
| 798 | 793 | |
| 799 | | static BOOL DevView_GetCreateFileName(HWND hwndDevView, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 794 | static BOOL DevView_GetCreateFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 800 | 795 | { |
| 801 | 796 | BOOL bResult; |
| 802 | 797 | mess_image_type imagetypes[64]; |
| 803 | 798 | HWND hwndList; |
| 804 | 799 | int gamenum; |
| 805 | | machine_config *config; |
| 806 | 800 | |
| 807 | 801 | hwndList = GetDlgItem(GetMainWindow(), IDC_LIST); |
| 808 | 802 | gamenum = Picker_GetSelectedItem(hwndList); |
| 809 | 803 | |
| 810 | | // allocate the machine config |
| 811 | | config = machine_config_alloc_with_mess_devices(drivers[gamenum]); |
| 812 | | |
| 813 | 804 | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 814 | | bResult = CommonFileImageDialog(last_directory, GetSaveFileName, pszFilename, imagetypes); |
| 805 | bResult = CommonFileImageDialog(last_directory, GetSaveFileName, pszFilename, config, imagetypes); |
| 815 | 806 | |
| 816 | | machine_config_free(config); |
| 817 | 807 | return bResult; |
| 818 | 808 | } |
| 819 | 809 | |
| 820 | 810 | |
| 821 | 811 | |
| 822 | 812 | static void DevView_SetSelectedSoftware(HWND hwndDevView, int drvindex, |
| 823 | | const device_config *dev, LPCTSTR pszFilename) |
| 813 | const machine_config *config, const device_config *dev, LPCTSTR pszFilename) |
| 824 | 814 | { |
| 825 | 815 | char* utf8_filename = utf8_from_tstring(pszFilename); |
| 826 | 816 | if( !utf8_filename ) |
| r2321 | r2322 | |
| 833 | 823 | |
| 834 | 824 | |
| 835 | 825 | static LPCTSTR DevView_GetSelectedSoftware(HWND hwndDevView, int nDriverIndex, |
| 836 | | const device_config *dev, LPTSTR pszBuffer, UINT nBufferLength) |
| 826 | const machine_config *config, const device_config *dev, LPTSTR pszBuffer, UINT nBufferLength) |
| 837 | 827 | { |
| 838 | 828 | LPCTSTR t_buffer = NULL; |
| 839 | 829 | TCHAR* t_s; |
| 840 | | LPCSTR s = GetSelectedSoftware(nDriverIndex, dev); |
| 830 | LPCSTR s = GetSelectedSoftware(nDriverIndex, config, dev); |
| 841 | 831 | |
| 842 | 832 | t_s = tstring_from_utf8(s); |
| 843 | 833 | if( !t_s ) |
src/mess/messopts.c
| r2321 | r2322 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | /*************************************************************************** |
| 20 | TYPE DEFINITIONS |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | typedef void (*device_enum_func)(core_options *opts, const game_driver *gamedrv, |
| 24 | const machine_config *config, const device_config *device, int global_index); |
| 25 | |
| 26 | |
| 27 | |
| 28 | /*************************************************************************** |
| 20 | 29 | LOCAL VARIABLES |
| 21 | 30 | ***************************************************************************/ |
| 22 | 31 | |
| r2321 | r2322 | |
| 41 | 50 | option, by device and index |
| 42 | 51 | -------------------------------------------------*/ |
| 43 | 52 | |
| 44 | | const char *mess_get_device_option(const device_config *device) |
| 53 | const char *mess_get_device_option(const image_device_info *info) |
| 45 | 54 | { |
| 46 | 55 | const char *result = NULL; |
| 47 | | image_device_info info; |
| 48 | 56 | |
| 49 | 57 | if (options_get_bool(mame_options(), OPTION_ADDED_DEVICE_OPTIONS)) |
| 50 | 58 | { |
| 51 | | /* get the device information */ |
| 52 | | info = image_device_getinfo(device); |
| 53 | | |
| 54 | 59 | /* access the option */ |
| 55 | | result = options_get_string(mame_options(), info.instance_name); |
| 60 | result = options_get_string(mame_options(), info->instance_name); |
| 56 | 61 | } |
| 57 | 62 | return result; |
| 58 | 63 | } |
| r2321 | r2322 | |
| 65 | 70 | -------------------------------------------------*/ |
| 66 | 71 | |
| 67 | 72 | static void mess_enumerate_devices(core_options *opts, const machine_config *config, const game_driver *gamedrv, |
| 68 | | void (*proc)(core_options *opts, const game_driver *gamedrv, const device_config *device, int global_index)) |
| 73 | device_enum_func proc) |
| 69 | 74 | { |
| 70 | 75 | const device_config *device; |
| 71 | 76 | int index = 0; |
| r2321 | r2322 | |
| 73 | 78 | /* loop on each device instance */ |
| 74 | 79 | for (device = image_device_first(config); device != NULL; device = image_device_next(device)) |
| 75 | 80 | { |
| 76 | | proc(opts, gamedrv, device, index++); |
| 81 | proc(opts, gamedrv, config, device, index++); |
| 77 | 82 | } |
| 78 | 83 | } |
| 79 | 84 | |
| r2321 | r2322 | |
| 85 | 90 | -------------------------------------------------*/ |
| 86 | 91 | |
| 87 | 92 | static void add_device_options_for_device(core_options *opts, const game_driver *gamedrv, |
| 88 | | const device_config *device, int global_index) |
| 93 | const machine_config *config, const device_config *device, int global_index) |
| 89 | 94 | { |
| 90 | 95 | image_device_info info; |
| 91 | 96 | options_entry this_entry[2]; |
| r2321 | r2322 | |
| 101 | 106 | } |
| 102 | 107 | |
| 103 | 108 | /* retrieve info about the device instance */ |
| 104 | | info = image_device_getinfo(device); |
| 109 | info = image_device_getinfo(config, device); |
| 105 | 110 | snprintf(dev_full_name, sizeof(dev_full_name) / sizeof(dev_full_name[0]), |
| 106 | 111 | "%s;%s", info.instance_name, info.brief_instance_name); |
| 107 | 112 | |
| r2321 | r2322 | |
| 185 | 190 | -------------------------------------------------*/ |
| 186 | 191 | |
| 187 | 192 | static void extract_device_options_for_device(core_options *opts, const game_driver *gamedrv, |
| 188 | | const device_config *device, int global_index) |
| 193 | const machine_config *config, const device_config *device, int global_index) |
| 189 | 194 | { |
| 190 | 195 | image_device_info info; |
| 191 | 196 | const char *filename; |
| r2321 | r2322 | |
| 196 | 201 | filename = image_filename(device); |
| 197 | 202 | |
| 198 | 203 | /* access other info */ |
| 199 | | info = image_device_getinfo(device); |
| 204 | info = image_device_getinfo(config, device); |
| 200 | 205 | |
| 201 | 206 | /* and set the option */ |
| 202 | 207 | options_set_string(opts, info.instance_name, filename ? filename : "", OPTION_PRIORITY_CMDLINE); |