src/mess/osd/winui/messui.c
| r6120 | r6121 | |
| 847 | 847 | |
| 848 | 848 | /* This is used to Mount an image in the device view of MESSUI. The directory in the dialog box is not |
| 849 | 849 | set, and is thus random. |
| 850 | | 2009-10-17 Robbbert: |
| 850 | 2009-10-18 Robbbert: |
| 851 | 851 | I've attempted to set the directory properly. Since the emulation is not running at this time, |
| 852 | 852 | we cannot do the same as the NEWUI does, that is, "initial_dir = image_working_directory(dev);" |
| 853 | 853 | because a crash occurs (the image system isn't set up yet). So, if an image is already mounted |
| 854 | 854 | we can use the directory it is in. Otherwise, we can use the "software" folder assuming that |
| 855 | | the user has set one up. If this fails, then the previous random behaviour will occur. */ |
| 855 | the user has set one up. If this fails, use the mess software directory if it exists. Otherwise |
| 856 | use the mess root directory. */ |
| 856 | 857 | |
| 857 | | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *conf, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 858 | static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 858 | 859 | { |
| 859 | 860 | BOOL bResult; |
| 860 | 861 | char *s; |
| r6120 | r6121 | |
| 865 | 866 | astring *as = astring_alloc(); |
| 866 | 867 | |
| 867 | 868 | /* Get the path to the currently mounted image */ |
| 868 | | zippath_parent(as, GetSelectedSoftware(drvindex, conf, dev)); |
| 869 | zippath_parent(as, GetSelectedSoftware(drvindex, config, dev)); |
| 870 | s = (char*)astring_c(as); |
| 869 | 871 | |
| 870 | | /* See if a path returned (blank means no image was loaded) */ |
| 871 | | if (astring_chr(as, 0, ':') == -1) |
| 872 | /* See if an image was loaded, and that the path still exists */ |
| 873 | if ((!osd_opendir(astring_c(as))) || (astring_chr(as, 0, ':') == -1)) |
| 872 | 874 | { |
| 873 | 875 | /* Get the path from the software tab */ |
| 874 | 876 | astring_cpyc(as, GetExtraSoftwarePaths(drvindex)); |
| r6120 | r6121 | |
| 876 | 878 | /* We only want the first path; throw out the rest */ |
| 877 | 879 | i = astring_chr(as, 0, ';'); |
| 878 | 880 | if (i > 0) astring_substr(as, 0, i); |
| 881 | s = (char*)astring_c(as); |
| 882 | |
| 883 | /* Make sure a folder was specified in the tab, and that it exists */ |
| 884 | if ((!osd_opendir(astring_c(as))) || (astring_chr(as, 0, ':') == -1)) |
| 885 | { |
| 886 | /* Default to emu directory */ |
| 887 | char mess_directory[1024]; |
| 888 | osd_get_emulator_directory(mess_directory, ARRAY_LENGTH(mess_directory)); |
| 889 | s = mess_directory; |
| 890 | |
| 891 | /* If software folder exists, use it instead - TODO: do properly when bug 1709 gets done */ |
| 892 | zippath_combine(as, mess_directory, "software"); |
| 893 | if (osd_opendir(astring_c(as))) s = (char*)astring_c(as); |
| 894 | } |
| 879 | 895 | } |
| 880 | | |
| 881 | | s = (char*)astring_c(as); |
| 896 | |
| 882 | 897 | astring_free(as); |
| 883 | | SetupImageTypes(conf, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 884 | | bResult = CommonFileImageDialog(s, GetOpenFileName, pszFilename, conf, imagetypes); |
| 898 | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 899 | bResult = CommonFileImageDialog(s, GetOpenFileName, pszFilename, config, imagetypes); |
| 885 | 900 | |
| 886 | 901 | return bResult; |
| 887 | 902 | } |
| r6120 | r6121 | |
| 889 | 904 | |
| 890 | 905 | /* This is used to Create an image in the device view of MESSUI. The directory in the dialog box is not |
| 891 | 906 | set, and is thus random. |
| 892 | | 2009-10-17 Robbbert: |
| 893 | | If the user has set up a "software" folder, this will be used. If this fails, then the previous |
| 894 | | random behaviour will occur. */ |
| 907 | 2009-10-18 Robbbert: |
| 908 | If the user has set up a "software" folder, this will be used. If this fails, we can use the |
| 909 | mess software directory if it exists. Otherwise use the mess root directory. */ |
| 895 | 910 | |
| 896 | 911 | static BOOL DevView_GetCreateFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength) |
| 897 | 912 | { |
| r6120 | r6121 | |
| 909 | 924 | /* We only want the first path; throw out the rest */ |
| 910 | 925 | i = astring_chr(as, 0, ';'); |
| 911 | 926 | if (i > 0) astring_substr(as, 0, i); |
| 912 | | |
| 913 | 927 | s = (char*)astring_c(as); |
| 928 | |
| 929 | /* Make sure a folder was specified in the tab, and that it exists */ |
| 930 | if ((!osd_opendir(astring_c(as))) || (astring_chr(as, 0, ':') == -1)) |
| 931 | { |
| 932 | /* Default to emu directory */ |
| 933 | char mess_directory[1024]; |
| 934 | osd_get_emulator_directory(mess_directory, ARRAY_LENGTH(mess_directory)); |
| 935 | s = mess_directory; |
| 936 | |
| 937 | /* If software folder exists, use it instead - TODO: do properly when bug 1709 gets done */ |
| 938 | zippath_combine(as, mess_directory, "software"); |
| 939 | if (osd_opendir(astring_c(as))) s = (char*)astring_c(as); |
| 940 | } |
| 941 | |
| 914 | 942 | astring_free(as); |
| 915 | 943 | |
| 916 | 944 | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |