From c44e1141e340c80ded8524e99c683a1efb2e780e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 29 Sep 2013 22:21:20 -0700 Subject: Changing the message box for failure to open MIDI. When Sekaiju cannot open a MIDI device; if you click OK on the dialog box, it will just forget the device. The new behavior is not great, but better: an Abort, Retry, Ignore error dialog is shown instead. Abort will forget the nonworking MIDI device (same as OK) before. Ignore will keep the device in the list. Retry will try opening it again: very useful for plugging in a USB MIDI adapter and trying again. --- src/SekaijuApp.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/SekaijuApp.cpp b/src/SekaijuApp.cpp index a63ea75..12e0a3c 100644 --- a/src/SekaijuApp.cpp +++ b/src/SekaijuApp.cpp @@ -2528,6 +2528,7 @@ void CSekaijuApp::OpenAllMIDIInDevice () { CString strMsg2; m_theCriticalSection.Lock (); for (i = 0; i < MAXMIDIINDEVICENUM; i++) { + retry: MIDIStatus_Delete (m_pMIDIInStatus[i]); m_pMIDIInStatus[i] = NULL; m_pMIDIIn[i] = MIDIIn_Reopen (m_pMIDIIn[i], m_strMIDIInName[i]); @@ -2545,8 +2546,17 @@ void CSekaijuApp::OpenAllMIDIInDevice () { strMsg.LoadString (IDS_S_N_MIDIINDEVICE_D_OPEN_FAILED); strMsg2.Format (strMsg, m_strMIDIInName[i], i + 1); m_theCriticalSection.Unlock (); - AfxMessageBox (strMsg2, MB_OK | MB_ICONEXCLAMATION); + int boxresult = AfxMessageBox (strMsg2, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION); m_theCriticalSection.Lock (); + switch (boxresult) { + case IDRETRY: + goto retry; + case IDIGNORE: + continue; // m_strMIDIInName[i]を消さない + case IDABORT: + default: + break; + } } m_strMIDIInName[i] = _T(""); } @@ -2561,6 +2571,7 @@ void CSekaijuApp::OpenAllMIDIOutDevice () { CString strMsg2; m_theCriticalSection.Lock (); for (i = 0; i < MAXMIDIOUTDEVICENUM; i++) { + retry: MIDIStatus_Delete (m_pMIDIOutStatus[i]); m_pMIDIOutStatus[i] = NULL; MIDIStatus_Delete (m_pTempMIDIStatus[i]); @@ -2581,9 +2592,17 @@ void CSekaijuApp::OpenAllMIDIOutDevice () { strMsg.LoadString (IDS_S_N_MIDIOUTDEVICE_D_OPEN_FAILED); strMsg2.Format (strMsg, m_strMIDIOutName[i], i + 1); m_theCriticalSection.Unlock (); - AfxMessageBox (strMsg2, MB_OK | MB_ICONEXCLAMATION); + int boxresult = AfxMessageBox (strMsg2, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION); m_theCriticalSection.Lock (); - } + switch (boxresult) { + case IDRETRY: + goto retry; + case IDIGNORE: + continue; // m_strMIDIInName[i]を消さない + case IDABORT: + default: + break; + } } m_strMIDIOutName[i] = _T(""); } } -- cgit v1.2.3