GotoGroupDialog.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // GotoGroupDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "GotoGroupDialog.h"
  23. #include "Utils.H"
  24. #include "GroupMgr.H"
  25. #include "CameraMgr.H"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // GotoGroupDialogClass
  34. //
  35. GotoGroupDialogClass::GotoGroupDialogClass
  36. (
  37. GroupMgrClass *pgroup,
  38. CWnd *pParent
  39. )
  40. : m_pGroup (pgroup),
  41. CDialog(GotoGroupDialogClass::IDD, pParent)
  42. {
  43. //{{AFX_DATA_INIT(GotoGroupDialogClass)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. return ;
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. //
  50. // DoDataExchange
  51. //
  52. void
  53. GotoGroupDialogClass::DoDataExchange (CDataExchange* pDX)
  54. {
  55. CDialog::DoDataExchange(pDX);
  56. //{{AFX_DATA_MAP(GotoGroupDialogClass)
  57. DDX_Control(pDX, IDC_GROUP_LIST, m_GroupList);
  58. //}}AFX_DATA_MAP
  59. return ;
  60. }
  61. BEGIN_MESSAGE_MAP(GotoGroupDialogClass, CDialog)
  62. //{{AFX_MSG_MAP(GotoGroupDialogClass)
  63. ON_CBN_EDITCHANGE(IDC_GROUP_LIST, OnEditChangeGroupList)
  64. ON_CBN_SELCHANGE(IDC_GROUP_LIST, OnSelChangeGroupList)
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. //
  69. // OnInitDialog
  70. //
  71. BOOL
  72. GotoGroupDialogClass::OnInitDialog (void)
  73. {
  74. // Allow the base class to process this message
  75. CDialog::OnInitDialog ();
  76. // Fill the 'group list' combobox with a complete list of all the group in the level.
  77. ::Fill_Group_Combo (::GetDlgItem (m_hWnd, IDC_OBJECT_LIST), m_pGroup);
  78. return TRUE;
  79. }
  80. /////////////////////////////////////////////////////////////////////////////
  81. //
  82. // OnOK
  83. //
  84. void
  85. GotoGroupDialogClass::OnOK (void)
  86. {
  87. // Get the currently selected node, and pass it onto the camera manager
  88. int index = Get_Current_Selection ();
  89. if (index != -1) {
  90. GroupMgrClass *pgroup = (GroupMgrClass *)m_GroupList.GetItemData (index);
  91. if (pgroup != NULL) {
  92. ::Get_Camera_Mgr ()->Goto_Group (pgroup);
  93. }
  94. }
  95. // Allow the base class to process this message
  96. CDialog::OnOK ();
  97. return ;
  98. }
  99. /////////////////////////////////////////////////////////////////////////////
  100. //
  101. // Get_Current_Selection
  102. //
  103. int
  104. GotoGroupDialogClass::Get_Current_Selection (void)
  105. {
  106. // Assume failure
  107. int index = -1;
  108. CString text;
  109. m_GroupList.GetWindowText (text);
  110. index = m_GroupList.FindStringExact (-1, text);
  111. // Return the index of the currently selected group
  112. return index;
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. //
  116. // OnEditChangeGroupList
  117. //
  118. void
  119. GotoGroupDialogClass::OnEditChangeGroupList (void)
  120. {
  121. // Enable/disable the OK button based on the validity of the user's entry
  122. ::EnableWindow (::GetDlgItem (m_hWnd, IDOK), BOOL(Get_Current_Selection () != -1));
  123. return ;
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. //
  127. // OnSelChangeGroupList
  128. //
  129. void
  130. GotoGroupDialogClass::OnSelChangeGroupList (void)
  131. {
  132. // Enable the OK button
  133. ::EnableWindow (::GetDlgItem (m_hWnd, IDOK), TRUE);
  134. return ;
  135. }