AddToLineupDialog.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. // AddToLineupDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "AddToLineupDialog.h"
  23. #include "ViewerScene.h"
  24. #include <rendobj.h>
  25. #include <assetmgr.h>
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CAddToLineupDialog dialog
  33. CAddToLineupDialog::CAddToLineupDialog(ViewerSceneClass *scene, CWnd* pParent /*=NULL*/)
  34. : CDialog(CAddToLineupDialog::IDD, pParent),
  35. m_pCScene(scene)
  36. {
  37. //{{AFX_DATA_INIT(CAddToLineupDialog)
  38. m_Object = _T("");
  39. //}}AFX_DATA_INIT
  40. }
  41. void CAddToLineupDialog::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CAddToLineupDialog)
  45. DDX_CBString(pDX, IDC_OBJECT, m_Object);
  46. DDV_MaxChars(pDX, m_Object, 64);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CAddToLineupDialog, CDialog)
  50. //{{AFX_MSG_MAP(CAddToLineupDialog)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CAddToLineupDialog message handlers
  55. BOOL CAddToLineupDialog::OnInitDialog()
  56. {
  57. CDialog::OnInitDialog();
  58. if (m_pCScene)
  59. {
  60. // Get a pointer to the combo box control.
  61. CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_OBJECT);
  62. ASSERT_VALID(pCombo);
  63. // Populate the combo box with the names of the objects that
  64. // can be added to the lineup.
  65. WW3DAssetManager *assets = WW3DAssetManager::Get_Instance();
  66. ASSERT(assets != NULL);
  67. RenderObjIterator *it = assets->Create_Render_Obj_Iterator();
  68. ASSERT(it != NULL);
  69. for (; !it->Is_Done(); it->Next())
  70. {
  71. if (m_pCScene->Can_Line_Up(it->Current_Item_Class_ID()))
  72. pCombo->AddString(it->Current_Item_Name());
  73. }
  74. assets->Release_Render_Obj_Iterator(it);
  75. }
  76. return TRUE; // return TRUE unless you set the focus to a control
  77. // EXCEPTION: OCX Property Pages should return FALSE
  78. }
  79. void CAddToLineupDialog::OnOK()
  80. {
  81. // Make sure the user actually chose a name.
  82. CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_OBJECT);
  83. ASSERT_VALID(pCombo);
  84. CString text;
  85. pCombo->GetWindowText(text);
  86. if (text.IsEmpty())
  87. {
  88. ::AfxMessageBox("Please select an object, or type in an object name.");
  89. return;
  90. }
  91. CDialog::OnOK();
  92. }