1
0

MoveFXSlotDialog.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * MoveFXSlotDialog.h
  3. * ------------------
  4. * Purpose: Implementationof OpenMPT's move plugin dialog.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #include "stdafx.h"
  10. #include "Mptrack.h"
  11. #include "MoveFXSlotDialog.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. void CMoveFXSlotDialog::DoDataExchange(CDataExchange* pDX)
  14. {
  15. CDialog::DoDataExchange(pDX);
  16. DDX_Control(pDX, IDC_COMBO1, m_CbnEmptySlots);
  17. }
  18. CMoveFXSlotDialog::CMoveFXSlotDialog(CWnd *pParent, PLUGINDEX currentSlot, const std::vector<PLUGINDEX> &emptySlots, PLUGINDEX defaultIndex, bool clone, bool hasChain) :
  19. CDialog(CMoveFXSlotDialog::IDD, pParent),
  20. m_EmptySlots(emptySlots),
  21. m_nDefaultSlot(defaultIndex),
  22. moveChain(hasChain)
  23. {
  24. if(clone)
  25. {
  26. m_csPrompt.Format(_T("Clone plugin in slot %d to the following empty slot:"), currentSlot + 1);
  27. m_csTitle = _T("Clone To Slot...");
  28. m_csChain = _T("&Clone follow-up plugin chain if possible");
  29. } else
  30. {
  31. m_csPrompt.Format(_T("Move plugin in slot %d to the following empty slot:"), currentSlot + 1);
  32. m_csTitle = _T("Move To Slot...");
  33. m_csChain = _T("&Move follow-up plugin chain if possible");
  34. }
  35. }
  36. BOOL CMoveFXSlotDialog::OnInitDialog()
  37. {
  38. CDialog::OnInitDialog();
  39. SetDlgItemText(IDC_STATIC1, m_csPrompt);
  40. SetDlgItemText(IDC_CHECK1, m_csChain);
  41. SetWindowText(m_csTitle);
  42. if(m_EmptySlots.empty())
  43. {
  44. Reporting::Error("No empty plugin slots are availabe.");
  45. OnCancel();
  46. return TRUE;
  47. }
  48. CString slotText;
  49. std::size_t defaultSlot = 0;
  50. bool foundDefault = false;
  51. for(size_t nSlot = 0; nSlot < m_EmptySlots.size(); nSlot++)
  52. {
  53. slotText.Format(_T("FX%d"), m_EmptySlots[nSlot] + 1);
  54. m_CbnEmptySlots.SetItemData(m_CbnEmptySlots.AddString(slotText), nSlot);
  55. if(m_EmptySlots[nSlot] >= m_nDefaultSlot && !foundDefault)
  56. {
  57. defaultSlot = nSlot;
  58. foundDefault = true;
  59. }
  60. }
  61. m_CbnEmptySlots.SetCurSel(static_cast<int>(defaultSlot));
  62. GetDlgItem(IDC_CHECK1)->EnableWindow(moveChain ? TRUE : FALSE);
  63. CheckDlgButton(IDC_CHECK1, moveChain ? BST_CHECKED : BST_UNCHECKED);
  64. return TRUE;
  65. }
  66. void CMoveFXSlotDialog::OnOK()
  67. {
  68. m_nToSlot = m_CbnEmptySlots.GetItemData(m_CbnEmptySlots.GetCurSel());
  69. moveChain = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED;
  70. CDialog::OnOK();
  71. }
  72. OPENMPT_NAMESPACE_END