TrackViewNewSequenceDialog.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "EditorDefs.h"
  9. #include "TrackViewNewSequenceDialog.h"
  10. // Qt
  11. #include <QMessageBox>
  12. // CryCommon
  13. #include <CryCommon/Maestro/Types/SequenceType.h>
  14. // Editor
  15. #include "TrackView/TrackViewSequenceManager.h"
  16. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  17. #include <ui_TrackViewNewSequenceDialog.h>
  18. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  19. namespace
  20. {
  21. struct seqTypeComboPair
  22. {
  23. const char* name;
  24. SequenceType type;
  25. };
  26. }
  27. // TrackViewNewSequenceDialog dialog
  28. CTVNewSequenceDialog::CTVNewSequenceDialog(QWidget* parent)
  29. : QDialog(parent)
  30. , ui(new Ui::CTVNewSequenceDialog)
  31. , m_inputFocusSet(false)
  32. {
  33. ui->setupUi(this);
  34. connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &CTVNewSequenceDialog::OnOK);
  35. connect(ui->NAME, &QLineEdit::returnPressed, this, &CTVNewSequenceDialog::OnOK);
  36. setWindowTitle("Add New Sequence");
  37. OnInitDialog();
  38. }
  39. CTVNewSequenceDialog::~CTVNewSequenceDialog()
  40. {
  41. }
  42. void CTVNewSequenceDialog::OnInitDialog()
  43. {
  44. }
  45. void CTVNewSequenceDialog::OnOK()
  46. {
  47. m_sequenceType = SequenceType::SequenceComponent;
  48. m_sequenceName = ui->NAME->text();
  49. if (m_sequenceName.isEmpty())
  50. {
  51. QMessageBox::warning(this, "New Sequence", "A sequence name cannot be empty!");
  52. return;
  53. }
  54. else if (m_sequenceName.contains('/'))
  55. {
  56. QMessageBox::warning(this, "New Sequence", "A sequence name cannot contain a '/' character!");
  57. return;
  58. }
  59. else if (m_sequenceName == LIGHT_ANIMATION_SET_NAME)
  60. {
  61. QMessageBox::warning(this, "New Sequence", QString("The sequence name '%1' is reserved.\n\nPlease choose a different name.").arg(LIGHT_ANIMATION_SET_NAME));
  62. return;
  63. }
  64. for (unsigned int k = 0; k < GetIEditor()->GetSequenceManager()->GetCount(); ++k)
  65. {
  66. CTrackViewSequence* pSequence = GetIEditor()->GetSequenceManager()->GetSequenceByIndex(k);
  67. QString fullname = QString::fromUtf8(pSequence->GetName().c_str());
  68. if (fullname.compare(m_sequenceName, Qt::CaseInsensitive) == 0)
  69. {
  70. QMessageBox::warning(this, "New Sequence", "Sequence with this name already exists!");
  71. return;
  72. }
  73. }
  74. accept();
  75. }
  76. void CTVNewSequenceDialog::showEvent(QShowEvent* event)
  77. {
  78. if (!m_inputFocusSet)
  79. {
  80. ui->NAME->setFocus();
  81. m_inputFocusSet = true;
  82. }
  83. QDialog::showEvent(event);
  84. }
  85. #include <moc_TrackViewNewSequenceDialog.cpp>