GotoObjectByIDDialog.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. // GotoObjectByIDDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "gotoobjectbyiddialog.h"
  23. #include "node.h"
  24. #include "nodemgr.h"
  25. #include "cameramgr.h"
  26. #include "utils.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. //
  34. // GotoObjectByIDDialogClass
  35. //
  36. /////////////////////////////////////////////////////////////////////////////
  37. GotoObjectByIDDialogClass::GotoObjectByIDDialogClass(CWnd* pParent /*=NULL*/)
  38. : CDialog(GotoObjectByIDDialogClass::IDD, pParent)
  39. {
  40. //{{AFX_DATA_INIT(GotoObjectByIDDialogClass)
  41. // NOTE: the ClassWizard will add member initialization here
  42. //}}AFX_DATA_INIT
  43. return ;
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. //
  47. // DoDataExchange
  48. //
  49. /////////////////////////////////////////////////////////////////////////////
  50. void
  51. GotoObjectByIDDialogClass::DoDataExchange (CDataExchange* pDX)
  52. {
  53. CDialog::DoDataExchange(pDX);
  54. //{{AFX_DATA_MAP(GotoObjectByIDDialogClass)
  55. // NOTE: the ClassWizard will add DDX and DDV calls here
  56. //}}AFX_DATA_MAP
  57. return ;
  58. }
  59. BEGIN_MESSAGE_MAP(GotoObjectByIDDialogClass, CDialog)
  60. //{{AFX_MSG_MAP(GotoObjectByIDDialogClass)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. //
  65. // OnOK
  66. //
  67. /////////////////////////////////////////////////////////////////////////////
  68. void
  69. GotoObjectByIDDialogClass::OnOK (void)
  70. {
  71. int obj_id = GetDlgItemInt (IDC_OBJECT_ID_EDIT);
  72. //
  73. // Try to find the object that the user entered
  74. //
  75. NodeClass *node = NodeMgrClass::Find_Node (obj_id);
  76. if (node == NULL) {
  77. //
  78. // Warn the user
  79. //
  80. ::MessageBox (m_hWnd, "There is not object in the current level with that ID.", "Object Not Found", MB_ICONERROR | MB_OK);
  81. //
  82. // Return focus to the edit control so the user can re-enter the ID
  83. //
  84. ::SetFocus (::GetDlgItem (m_hWnd, IDC_OBJECT_ID_EDIT));
  85. SendDlgItemMessage (IDC_OBJECT_ID_EDIT, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  86. } else {
  87. //
  88. // 'Goto' the requested object
  89. //
  90. ::Get_Camera_Mgr ()->Goto_Node (node);
  91. CDialog::OnOK ();
  92. }
  93. return ;
  94. }