Previous 15994 Revisions Next

r6121 Sunday 18th October, 2009 at 03:21:42 UTC by Robbbert
[MESSUI] Device View (Mount and Create) will default to the "software" folder if user didn't specify one in the software tab.
[src/mess/osd/winui]messui.c

src/mess/osd/winui/messui.c
r6120r6121
847847
848848/* This is used to Mount an image in the device view of MESSUI. The directory in the dialog box is not
849849   set, and is thus random.
850   2009-10-17 Robbbert:
850   2009-10-18 Robbbert:
851851   I've attempted to set the directory properly. Since the emulation is not running at this time,
852852   we cannot do the same as the NEWUI does, that is, "initial_dir = image_working_directory(dev);"
853853   because a crash occurs (the image system isn't set up yet). So, if an image is already mounted
854854   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. */
856857
857static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *conf, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength)
858static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength)
858859{
859860   BOOL bResult;
860861   char *s;
r6120r6121
865866   astring *as = astring_alloc();
866867
867868   /* 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);
869871
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))
872874   {
873875      /* Get the path from the software tab */
874876      astring_cpyc(as, GetExtraSoftwarePaths(drvindex));
r6120r6121
876878      /* We only want the first path; throw out the rest */
877879      i = astring_chr(as, 0, ';');
878880      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      }
879895   }
880   
881   s = (char*)astring_c(as);
896
882897   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);
885900
886901   return bResult;
887902}
r6120r6121
889904
890905/* This is used to Create an image in the device view of MESSUI. The directory in the dialog box is not
891906   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. */
895910
896911static BOOL DevView_GetCreateFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength)
897912{
r6120r6121
909924   /* We only want the first path; throw out the rest */
910925   i = astring_chr(as, 0, ';');
911926   if (i > 0) astring_substr(as, 0, i);
912   
913927   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
914942   astring_free(as);
915943
916944   SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team