1
0

PlugNotFoundDlg.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * PlugNotFoundDlg.cpp
  3. * -------------------
  4. * Purpose: Dialog for handling missing plugins
  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 "PlugNotFoundDlg.h"
  11. #include "../soundlib/plugins/PluginManager.h"
  12. #include "Mptrack.h"
  13. #include "resource.h"
  14. OPENMPT_NAMESPACE_BEGIN
  15. BEGIN_MESSAGE_MAP(PlugNotFoundDialog, ResizableDialog)
  16. ON_COMMAND(IDC_BUTTON_REMOVE, &PlugNotFoundDialog::OnRemove)
  17. END_MESSAGE_MAP()
  18. void PlugNotFoundDialog::DoDataExchange(CDataExchange *pDX)
  19. {
  20. ResizableDialog::DoDataExchange(pDX);
  21. DDX_Control(pDX, IDC_LIST1, m_List);
  22. }
  23. PlugNotFoundDialog::PlugNotFoundDialog(std::vector<VSTPluginLib *> &plugins, CWnd *parent)
  24. : ResizableDialog(IDD_MISSINGPLUGS, parent)
  25. , m_plugins(plugins)
  26. {
  27. }
  28. BOOL PlugNotFoundDialog::OnInitDialog()
  29. {
  30. ResizableDialog::OnInitDialog();
  31. // Initialize table
  32. const CListCtrlEx::Header headers[] =
  33. {
  34. { _T("Plugin"), 128, LVCFMT_LEFT },
  35. { _T("File Path"), 308, LVCFMT_LEFT },
  36. };
  37. m_List.SetHeaders(headers);
  38. m_List.SetExtendedStyle(m_List.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
  39. for(const auto &plug : m_plugins)
  40. {
  41. const int insertAt = m_List.InsertItem(m_List.GetItemCount(), plug->libraryName.AsNative().c_str());
  42. if(insertAt == -1)
  43. continue;
  44. m_List.SetItemText(insertAt, 1, plug->dllPath.AsNative().c_str());
  45. m_List.SetItemDataPtr(insertAt, plug);
  46. m_List.SetCheck(insertAt);
  47. }
  48. m_List.SetFocus();
  49. return TRUE;
  50. }
  51. void PlugNotFoundDialog::OnRemove()
  52. {
  53. const int plugs = m_List.GetItemCount();
  54. for(int i = 0; i < plugs; i++)
  55. {
  56. if(m_List.GetCheck(i))
  57. {
  58. theApp.GetPluginManager()->RemovePlugin(static_cast<VSTPluginLib *>(m_List.GetItemDataPtr(i)));
  59. }
  60. }
  61. OnOK();
  62. }
  63. OPENMPT_NAMESPACE_END