NodeInfoPage.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. // NodeInfoPageClass.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "NodeInfoPage.H"
  23. #include "NodeMgr.H"
  24. #include "rendobj.h"
  25. #include "node.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. //
  33. // NodeInfoPageClass
  34. //
  35. /////////////////////////////////////////////////////////////////////////////
  36. NodeInfoPageClass::NodeInfoPageClass (void)
  37. : m_pNode (NULL),
  38. DockableFormClass(NodeInfoPageClass::IDD)
  39. {
  40. //{{AFX_DATA_INIT(NodeInfoPageClass)
  41. // NOTE: the ClassWizard will add member initialization here
  42. //}}AFX_DATA_INIT
  43. return ;
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. //
  47. // NodeInfoPageClass
  48. //
  49. /////////////////////////////////////////////////////////////////////////////
  50. NodeInfoPageClass::NodeInfoPageClass (NodeClass *node)
  51. : m_pNode (node),
  52. DockableFormClass(NodeInfoPageClass::IDD)
  53. {
  54. return ;
  55. }
  56. /////////////////////////////////////////////////////////////////////////////
  57. //
  58. // ~NodeInfoPageClass
  59. //
  60. /////////////////////////////////////////////////////////////////////////////
  61. NodeInfoPageClass::~NodeInfoPageClass (void)
  62. {
  63. return ;
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. //
  67. // DoDataExchange
  68. //
  69. /////////////////////////////////////////////////////////////////////////////
  70. void
  71. NodeInfoPageClass::DoDataExchange (CDataExchange* pDX)
  72. {
  73. DockableFormClass::DoDataExchange(pDX);
  74. //{{AFX_DATA_MAP(NodeInfoPageClass)
  75. // NOTE: the ClassWizard will add DDX and DDV calls here
  76. //}}AFX_DATA_MAP
  77. return ;
  78. }
  79. BEGIN_MESSAGE_MAP(NodeInfoPageClass, DockableFormClass)
  80. //{{AFX_MSG_MAP(NodeInfoPageClass)
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. // NodeInfoPageClass diagnostics
  85. #ifdef _DEBUG
  86. void NodeInfoPageClass::AssertValid() const
  87. {
  88. DockableFormClass::AssertValid();
  89. }
  90. void NodeInfoPageClass::Dump(CDumpContext& dc) const
  91. {
  92. DockableFormClass::Dump(dc);
  93. }
  94. #endif //_DEBUG
  95. /////////////////////////////////////////////////////////////////////////////
  96. //
  97. // HandleInitDialog
  98. //
  99. /////////////////////////////////////////////////////////////////////////////
  100. void
  101. NodeInfoPageClass::HandleInitDialog (void)
  102. {
  103. ASSERT (m_pNode != NULL);
  104. CString model_name;
  105. RenderObjClass *render_obj = m_pNode->Peek_Render_Obj ();
  106. if (render_obj != NULL) {
  107. model_name = render_obj->Get_Name ();
  108. }
  109. // Set the text of the respective dialog controls
  110. SetDlgItemText (IDC_NAME_EDIT, m_pNode->Get_Name ());
  111. SetDlgItemText (IDC_MODELNAME_EDIT, model_name);
  112. SetDlgItemText (IDC_COMMENTS_EDIT, m_pNode->Get_Comments ());
  113. SetDlgItemInt (IDC_ID_EDIT, m_pNode->Get_ID ());
  114. return ;
  115. }
  116. /////////////////////////////////////////////////////////////////////////////
  117. //
  118. // Apply_Changes
  119. //
  120. /////////////////////////////////////////////////////////////////////////////
  121. bool
  122. NodeInfoPageClass::Apply_Changes (void)
  123. {
  124. bool retval = true;
  125. // Pass the new name onto the node
  126. CString name;
  127. GetDlgItemText (IDC_NAME_EDIT, name);
  128. m_pNode->Set_Name (name);
  129. // Pass the new comments onto the base
  130. CString comments;
  131. GetDlgItemText (IDC_COMMENTS_EDIT, comments);
  132. m_pNode->Set_Comments (comments);
  133. // If the ID was changed then verify that it is unique before actually
  134. // changing it for the object.
  135. uint32 id = GetDlgItemInt(IDC_ID_EDIT, NULL, FALSE);
  136. if (m_pNode->Get_ID() != id) {
  137. //
  138. // Is this ID already used?
  139. //
  140. if (::Get_Node_Mgr().Verify_Unique_ID (id)) {
  141. //
  142. // Is this ID in the range you were assigned?
  143. //
  144. uint32 min_id = 0;
  145. uint32 max_id = 0;
  146. NodeMgrClass::Get_ID_Range (m_pNode->Get_Type (), &min_id, &max_id);
  147. if (id >= min_id && id < max_id) {
  148. m_pNode->Set_ID (id);
  149. } else {
  150. MessageBox ("This ID is not in your allocated range.\n", "ID Error!");
  151. retval = false;
  152. }
  153. } else {
  154. MessageBox ("ID already in use!\nPlease enter a unique ID\n", "ID Error!");
  155. retval = false;
  156. }
  157. }
  158. return retval;
  159. }