Previous 15994 Revisions Next

r2070 Sunday 23rd March, 2008 at 01:02:55 UTC by Nathan Woods
[Windows GUI] Minor cleanups
[src/mess/osd/winui]messui.c

src/mess/osd/winui/messui.c
r2069r2070
5050
5151static const LPCTSTR mess_column_names[] =
5252{
53    TEXT("Software"),
53   TEXT("Software"),
5454   TEXT("Goodname"),
55    TEXT("Manufacturer"),
56    TEXT("Year"),
57    TEXT("Playable"),
55   TEXT("Manufacturer"),
56   TEXT("Year"),
57   TEXT("Playable"),
5858   TEXT("CRC"),
5959   TEXT("SHA-1"),
6060   TEXT("MD5")
r2069r2070
6464
6565static void MessOpenOtherSoftware(int iDevice);
6666static void MessCreateDevice(int iDevice);
67static void MessRefreshPicker(int nGame);
67static void MessRefreshPicker(int drvindex);
6868
6969static int SoftwarePicker_GetItemImage(HWND hwndPicker, int nItem);
7070static void SoftwarePicker_LeavingItem(HWND hwndSoftwarePicker, int nItem);
r2069r2070
249249
250250
251251
252static int GetMessIcon(int nGame, int nSoftwareType)
252static int GetMessIcon(int drvindex, int nSoftwareType)
253253{
254254    int the_index;
255255    int nIconPos = 0;
r2069r2070
258258    char buffer[32];
259259   const char *iconname;
260260
261   assert(nGame >= 0);
262   assert(nGame < driver_list_get_count(drivers));
261   assert(drvindex >= 0);
262   assert(drvindex < driver_list_get_count(drivers));
263263
264264    if ((nSoftwareType >= 0) && (nSoftwareType < IO_COUNT))
265265   {
266266      iconname = device_brieftypename(nSoftwareType);
267        the_index = (nGame * IO_COUNT) + nSoftwareType;
267        the_index = (drvindex * IO_COUNT) + nSoftwareType;
268268
269269        nIconPos = mess_icon_index[the_index];
270270        if (nIconPos >= 0)
271271      {
272         for (drv = drivers[nGame]; drv; drv = driver_get_clone(drv))
272         for (drv = drivers[drvindex]; drv; drv = driver_get_clone(drv))
273273         {
274274            _snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%s/%s", drv->name, iconname);
275275            hIcon = LoadIconFromFile(buffer);
r2069r2070
335335
336336
337337
338void MyFillSoftwareList(int nGame, BOOL bForce)
338void MyFillSoftwareList(int drvindex, BOOL bForce)
339339{
340340   const game_driver *drv;
341341   HWND hwndSoftwarePicker;
r2069r2070
345345   hwndSoftwareDevView = GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW);
346346
347347   // Set up the device view
348   DevView_SetDriver(hwndSoftwareDevView, nGame);
348   DevView_SetDriver(hwndSoftwareDevView, drvindex);
349349
350   if (!bForce && (s_nGame == nGame))
350   if (!bForce && (s_nGame == drvindex))
351351      return;
352   s_nGame = nGame;
352   s_nGame = drvindex;
353353
354354   // Set up the software picker
355355   SoftwarePicker_Clear(hwndSoftwarePicker);
356   drv = drivers[nGame];
356   drv = drivers[drvindex];
357357   SoftwarePicker_SetDriver(hwndSoftwarePicker, drv);
358358   while(drv)
359359   {
360360      AddSoftwarePickerDirs(hwndSoftwarePicker, GetSoftwareDirs(), drv->name);
361361      drv = mess_next_compatible_driver(drv);
362362   }
363   AddSoftwarePickerDirs(hwndSoftwarePicker, GetExtraSoftwarePaths(nGame), NULL);
363   AddSoftwarePickerDirs(hwndSoftwarePicker, GetExtraSoftwarePaths(drvindex), NULL);
364364}
365365
366366
r2069r2070
373373
374374
375375
376BOOL MessApproveImageList(HWND hParent, int nGame)
376BOOL MessApproveImageList(HWND hParent, int drvindex)
377377{
378378   int i, nPos, devindex;
379379   const struct IODevice *devices;
r2069r2070
384384
385385   begin_resource_tracking();
386386
387   pDriver = drivers[nGame];
387   pDriver = drivers[drvindex];
388388   devices = devices_allocate(pDriver);
389389
390390   nPos = 0;
r2069r2070
395395      {
396396         for (i = 0; i < devices[devindex].count; i++)
397397         {
398            pszSoftware = GetSelectedSoftware(nGame, &devices[devindex].devclass, i);
398            pszSoftware = GetSelectedSoftware(drvindex, &devices[devindex].devclass, i);
399399            if (!pszSoftware || !*pszSoftware)
400400            {
401401               snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]),
r2069r2070
424424
425425
426426// this is a wrapper call to wrap the idiosycracies of SetSelectedSoftware()
427static void InternalSetSelectedSoftware(int nGame, const mess_device_class *devclass, int device_inst, const char *pszSoftware)
427static void InternalSetSelectedSoftware(int drvindex, const mess_device_class *devclass, int device_inst, const char *pszSoftware)
428428{
429429   if (!pszSoftware)
430430      pszSoftware = "";
431431
432432   // only call SetSelectedSoftware() if this value is different
433   if (strcmp(GetSelectedSoftware(nGame, devclass, device_inst), pszSoftware))
433   if (strcmp(GetSelectedSoftware(drvindex, devclass, device_inst), pszSoftware))
434434   {
435      SetSelectedSoftware(nGame, devclass, device_inst, pszSoftware);
435      SetSelectedSoftware(drvindex, devclass, device_inst, pszSoftware);
436436   }
437437}
438438
439439
440440
441441// Places the specified image in the specified slot; nID = -1 means don't matter
442static void MessSpecifyImage(int nGame, const mess_device_class *devclass, int nID, LPCSTR pszFilename)
442static void MessSpecifyImage(int drvindex, const mess_device_class *devclass, int nID, LPCSTR pszFilename)
443443{
444444   const struct IODevice *devices;
445445   const struct IODevice *dev;
r2069r2070
464464      // special case; first try to find existing image
465465      for (i = 0; i < dev->count; i++)
466466      {
467         s = GetSelectedSoftware(nGame, &dev->devclass, i);
467         s = GetSelectedSoftware(drvindex, &dev->devclass, i);
468468         if (s && !mame_stricmp(s, pszFilename))
469469         {
470470            nID = i;
r2069r2070
478478      // still not found?  locate an empty slot
479479      for (i = 0; i < dev->count; i++)
480480      {
481         s = GetSelectedSoftware(nGame, &dev->devclass, i);
481         s = GetSelectedSoftware(drvindex, &dev->devclass, i);
482482         if (!s || !*s || !mame_stricmp(s, pszFilename))
483483         {
484484            nID = i;
r2069r2070
488488   }
489489
490490   if (nID >= 0)
491      InternalSetSelectedSoftware(nGame, &dev->devclass, nID, pszFilename);
491      InternalSetSelectedSoftware(drvindex, &dev->devclass, nID, pszFilename);
492492   else if (LOG_SOFTWARE)
493493      dprintf("MessSpecifyImage(): Failed to place image '%s'\n", pszFilename);
494494
r2069r2070
497497
498498
499499
500static void MessRemoveImage(int nGame, mess_device_class devclass, LPCSTR pszFilename)
500static void MessRemoveImage(int drvindex, mess_device_class devclass, LPCSTR pszFilename)
501501{
502502   int i, nPos;
503503   const struct IODevice *devices;
r2069r2070
519519      {
520520         for (i = 0; i < dev->count; i++)
521521         {
522            if (!mame_stricmp(pszFilename, GetSelectedSoftware(nGame, &dev->devclass, i)))
522            if (!mame_stricmp(pszFilename, GetSelectedSoftware(drvindex, &dev->devclass, i)))
523523            {
524               MessSpecifyImage(nGame, &devclass, i, NULL);
524               MessSpecifyImage(drvindex, &devclass, i, NULL);
525525               break;
526526            }
527527         }
r2069r2070
533533
534534
535535
536void MessReadMountedSoftware(int nGame)
536void MessReadMountedSoftware(int drvindex)
537537{
538538   // First read stuff into device view
539539   DevView_Refresh(GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW));
540540
541541   // Now read stuff into picker
542   MessRefreshPicker(nGame);
542   MessRefreshPicker(drvindex);
543543}
544544
545545
546546
547static void MessRefreshPicker(int nGame)
547static void MessRefreshPicker(int drvindex)
548548{
549549   HWND hwndSoftware;
550550   int i, id;
r2069r2070
555555   LPCSTR pszSoftware;
556556
557557   hwndSoftware = GetDlgItem(GetMainWindow(), IDC_SWLIST);
558   pDriver = drivers[nGame];
558   pDriver = drivers[drvindex];
559559   pDeviceList = devices_allocate(pDriver);
560560   if (!pDeviceList)
561561      goto done;
r2069r2070
570570   {
571571      for (id = 0; id < pDevice->count; id++)
572572      {
573         pszSoftware = GetSelectedSoftware(nGame, &pDevice->devclass, id);
573         pszSoftware = GetSelectedSoftware(drvindex, &pDevice->devclass, id);
574574         if (pszSoftware && *pszSoftware)
575575         {
576576            i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware);
r2069r2070
796796{
797797   TCHAR filename[MAX_PATH];
798798   mess_image_type imagetypes[64];
799   int nGame;
799   int drvindex;
800800   HWND hwndList;
801801   char* utf8_filename;
802802   const struct IODevice *devices;
r2069r2070
804804   begin_resource_tracking();
805805
806806   hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
807   nGame = Picker_GetSelectedItem(hwndList);
808   devices = devices_allocate(drivers[nGame]);
807   drvindex = Picker_GetSelectedItem(hwndList);
808   devices = devices_allocate(drivers[drvindex]);
809809   SetupImageTypes(devices, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, iDevice);
810810
811811   if (CommonFileImageDialog(last_directory, cfd, filename, imagetypes))
r2069r2070
880880
881881
882882
883static void DevView_SetSelectedSoftware(HWND hwndDevView, int nGame,
883static void DevView_SetSelectedSoftware(HWND hwndDevView, int drvindex,
884884   const struct IODevice *dev, int nID, LPCTSTR pszFilename)
885885{
886886   char* utf8_filename = utf8_from_tstring(pszFilename);
887887   if( !utf8_filename )
888888      return;
889   MessSpecifyImage(nGame, &dev->devclass, nID, utf8_filename);
890   MessRefreshPicker(nGame);
889   MessSpecifyImage(drvindex, &dev->devclass, nID, utf8_filename);
890   MessRefreshPicker(drvindex);
891891   free(utf8_filename);
892892}
893893
r2069r2070
919919
920920static int SoftwarePicker_GetItemImage(HWND hwndPicker, int nItem)
921921{
922    int nType;
923    int nIcon;
924   int nGame;
922   int nType;
923   int nIcon;
924   int drvindex;
925925   const char *icon_name;
926926   HWND hwndGamePicker;
927927   HWND hwndSoftwarePicker;
928928
929929   hwndGamePicker = GetDlgItem(GetMainWindow(), IDC_LIST);
930930   hwndSoftwarePicker = GetDlgItem(GetMainWindow(), IDC_SWLIST);
931   nGame = Picker_GetSelectedItem(hwndGamePicker);
932    nType = SoftwarePicker_GetImageType(hwndSoftwarePicker, nItem);
933    nIcon = GetMessIcon(nGame, nType);
934    if (!nIcon)
931   drvindex = Picker_GetSelectedItem(hwndGamePicker);
932   nType = SoftwarePicker_GetImageType(hwndSoftwarePicker, nItem);
933   nIcon = GetMessIcon(drvindex, nType);
934   if (!nIcon)
935935   {
936936      if (nType < 0)
937937         nType = IO_BAD;
r2069r2070
965965
966966static void SoftwarePicker_LeavingItem(HWND hwndSoftwarePicker, int nItem)
967967{
968   int nGame;
968   int drvindex;
969969   mess_device_class devclass;
970970   LPCSTR pszFullName;
971971   HWND hwndList;
r2069r2070
973973   if (!s_bIgnoreSoftwarePickerNotifies)
974974   {
975975      hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
976      nGame = Picker_GetSelectedItem(hwndList);
976      drvindex = Picker_GetSelectedItem(hwndList);
977977      devclass = SoftwarePicker_LookupDevice(hwndSoftwarePicker, nItem);
978978      pszFullName = SoftwarePicker_LookupFilename(hwndSoftwarePicker, nItem);
979979
980      MessRemoveImage(nGame, devclass, pszFullName);
980      MessRemoveImage(drvindex, devclass, pszFullName);
981981   }
982982}
983983
r2069r2070
988988   LPCSTR pszFullName;
989989   LPCSTR pszName;
990990   LPSTR s;
991   int nGame;
991   int drvindex;
992992   mess_device_class devclass;
993993   HWND hwndList;
994994
r2069r2070
996996
997997   if (!s_bIgnoreSoftwarePickerNotifies)
998998   {
999      nGame = Picker_GetSelectedItem(hwndList);
999      drvindex = Picker_GetSelectedItem(hwndList);
10001000
10011001      // Get the fullname and partialname for this file
10021002      pszFullName = SoftwarePicker_LookupFilename(hwndSoftwarePicker, nItem);
r2069r2070
10071007      devclass = SoftwarePicker_LookupDevice(hwndSoftwarePicker, nItem);
10081008      if (!devclass.gamedrv)
10091009         return;
1010      MessSpecifyImage(nGame, &devclass, -1, pszFullName);
1010      MessSpecifyImage(drvindex, &devclass, -1, pszFullName);
10111011
10121012      // Set up s_szSelecteItem, for the benefit of UpdateScreenShot()
10131013      strncpyz(g_szSelectedItem, pszName, sizeof(g_szSelectedItem) / sizeof(g_szSelectedItem[0]));

Previous 15994 Revisions Next


© 1998-2018 The MESS Team