GotoObjectDialog.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. // GotoObjectDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "gotoobjectdialog.h"
  23. #include "utils.h"
  24. #include "node.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. // GotoObjectDialogClass
  34. //
  35. /////////////////////////////////////////////////////////////////////////////
  36. GotoObjectDialogClass::GotoObjectDialogClass
  37. (
  38. NodeClass * node,
  39. CWnd * parent
  40. )
  41. : m_pNode (node),
  42. CDialog(GotoObjectDialogClass::IDD, parent)
  43. {
  44. //{{AFX_DATA_INIT(GotoObjectDialogClass)
  45. // NOTE: the ClassWizard will add member initialization here
  46. //}}AFX_DATA_INIT
  47. return ;
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. //
  51. // DoDataExchange
  52. //
  53. void
  54. GotoObjectDialogClass::DoDataExchange (CDataExchange* pDX)
  55. {
  56. CDialog::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(GotoObjectDialogClass)
  58. DDX_Control(pDX, IDC_OBJECT_LIST, m_NodeList);
  59. //}}AFX_DATA_MAP
  60. }
  61. BEGIN_MESSAGE_MAP(GotoObjectDialogClass, CDialog)
  62. //{{AFX_MSG_MAP(GotoObjectDialogClass)
  63. ON_CBN_EDITCHANGE(IDC_OBJECT_LIST, OnEditChangeObjectList)
  64. ON_CBN_SELCHANGE(IDC_OBJECT_LIST, OnSelChangeObjectList)
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. //
  69. // OnInitDialog
  70. //
  71. /////////////////////////////////////////////////////////////////////////////
  72. BOOL
  73. GotoObjectDialogClass::OnInitDialog (void)
  74. {
  75. // Allow the base class to process this message
  76. CDialog::OnInitDialog ();
  77. // Fill the 'object list' combobox with a complete list of all the objects in the level.
  78. ::Fill_Node_Instance_Combo (::GetDlgItem (m_hWnd, IDC_OBJECT_LIST), m_pNode);
  79. return TRUE;
  80. }
  81. /////////////////////////////////////////////////////////////////////////////
  82. //
  83. // OnOK
  84. //
  85. /////////////////////////////////////////////////////////////////////////////
  86. void
  87. GotoObjectDialogClass::OnOK (void)
  88. {
  89. // Get the currently selected node, and pass it onto the camera manager
  90. int index = Get_Current_Selection ();
  91. if (index != -1) {
  92. NodeClass *node = (NodeClass *)m_NodeList.GetItemData (index);
  93. if (node != NULL) {
  94. ::Get_Camera_Mgr ()->Goto_Node (node);
  95. }
  96. }
  97. // Allow the base class to process this message
  98. CDialog::OnOK ();
  99. return ;
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. //
  103. // Get_Current_Selection
  104. //
  105. /////////////////////////////////////////////////////////////////////////////
  106. int
  107. GotoObjectDialogClass::Get_Current_Selection (void)
  108. {
  109. // Assume failure
  110. int index = -1;
  111. CString text;
  112. m_NodeList.GetWindowText (text);
  113. index = m_NodeList.FindStringExact (-1, text);
  114. // Return the index of the currently selected node
  115. return index;
  116. }
  117. /////////////////////////////////////////////////////////////////////////////
  118. //
  119. // OnEditChangeObjectList
  120. //
  121. /////////////////////////////////////////////////////////////////////////////
  122. void
  123. GotoObjectDialogClass::OnEditChangeObjectList (void)
  124. {
  125. // Enable/disable the OK button based on the validity of the user's entry
  126. ::EnableWindow (::GetDlgItem (m_hWnd, IDOK), BOOL(Get_Current_Selection () != -1));
  127. return ;
  128. }
  129. /////////////////////////////////////////////////////////////////////////////
  130. //
  131. // OnSelChangeObjectList
  132. //
  133. /////////////////////////////////////////////////////////////////////////////
  134. void
  135. GotoObjectDialogClass::OnSelChangeObjectList (void)
  136. {
  137. // Enable the OK button
  138. ::EnableWindow (::GetDlgItem (m_hWnd, IDOK), TRUE);
  139. return ;
  140. }