Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: SelectEntityDlg.cpp $
  6. // $Date: 8/03/99 6:57p $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "stdafx.h"
  10. #include "hammer.h"
  11. #include "SelectEntityDlg.h"
  12. #include "GlobalFunctions.h"
  13. #include "MapDoc.h"
  14. #include "MapEntity.h"
  15. #include "MapSolid.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include <tier0/memdbgon.h>
  18. CSelectEntityDlg::CSelectEntityDlg(const CMapObjectList *pList,
  19. CWnd* pParent /*=NULL*/)
  20. : CDialog(CSelectEntityDlg::IDD, pParent)
  21. {
  22. //{{AFX_DATA_INIT(CSelectEntityDlg)
  23. // NOTE: the ClassWizard will add member initialization here
  24. //}}AFX_DATA_INIT
  25. m_pEntityList = pList;
  26. }
  27. void CSelectEntityDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CSelectEntityDlg)
  31. DDX_Control(pDX, IDC_ENTITIES, m_cEntities);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CSelectEntityDlg, CDialog)
  35. //{{AFX_MSG_MAP(CSelectEntityDlg)
  36. ON_LBN_SELCHANGE(IDC_ENTITIES, OnSelchangeEntities)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. //-----------------------------------------------------------------------------
  40. // Purpose:
  41. //-----------------------------------------------------------------------------
  42. void CSelectEntityDlg::OnSelchangeEntities()
  43. {
  44. int iSel = m_cEntities.GetCurSel();
  45. CMapEntity *pEntity = (CMapEntity*) m_cEntities.GetItemData(iSel);
  46. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  47. pDoc->SelectObject(pEntity, scClear|scSelect|scSaveChanges);
  48. }
  49. BOOL CSelectEntityDlg::OnInitDialog()
  50. {
  51. CDialog::OnInitDialog();
  52. // add entities from our list of entities to the listbox
  53. FOR_EACH_OBJ( *m_pEntityList, pos )
  54. {
  55. CMapClass *pObject = m_pEntityList->Element(pos);
  56. if(!pObject->IsMapClass(MAPCLASS_TYPE(CMapEntity)))
  57. continue;
  58. CMapEntity *pEntity = (CMapEntity*) pObject;
  59. if(pEntity->IsPlaceholder())
  60. continue;
  61. int iIndex = m_cEntities.AddString(pEntity->GetClassName());
  62. m_cEntities.SetItemData(iIndex, DWORD(pEntity));
  63. }
  64. m_cEntities.SetCurSel(0);
  65. OnSelchangeEntities();
  66. return TRUE;
  67. }
  68. void CSelectEntityDlg::OnOK()
  69. {
  70. int iSel = m_cEntities.GetCurSel();
  71. m_pFinalEntity = (CMapEntity*) m_cEntities.GetItemData(iSel);
  72. CDialog::OnOK();
  73. }