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.

107 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // EditPrefabDlg.cpp : implementation file
  9. //
  10. #include "stdafx.h"
  11. #include "hammer.h"
  12. #include "EditPrefabDlg.h"
  13. #include "Prefabs.h"
  14. // memdbgon must be the last include file in a .cpp file!!!
  15. #include <tier0/memdbgon.h>
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CEditPrefabDlg dialog
  18. CEditPrefabDlg::CEditPrefabDlg(CWnd* pParent /*=NULL*/)
  19. : CDialog(CEditPrefabDlg::IDD, pParent)
  20. {
  21. //{{AFX_DATA_INIT(CEditPrefabDlg)
  22. m_strDescript = _T("");
  23. m_strName = _T("");
  24. //}}AFX_DATA_INIT
  25. iMaxDescriptChars = 80;
  26. iMaxNameChars = 30;
  27. m_bEnableLibrary = FALSE;
  28. }
  29. void CEditPrefabDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CEditPrefabDlg)
  33. DDX_Control(pDX, IDC_CREATEIN, m_CreateIn);
  34. DDX_Control(pDX, IDC_NAME, m_Name);
  35. DDX_Control(pDX, IDC_DESCRIPT, m_Descript);
  36. DDX_Text(pDX, IDC_DESCRIPT, m_strDescript);
  37. DDX_Text(pDX, IDC_NAME, m_strName);
  38. //}}AFX_DATA_MAP
  39. DDV_MaxChars(pDX, m_strDescript, iMaxDescriptChars);
  40. DDV_MaxChars(pDX, m_strName, iMaxNameChars);
  41. }
  42. BEGIN_MESSAGE_MAP(CEditPrefabDlg, CDialog)
  43. //{{AFX_MSG_MAP(CEditPrefabDlg)
  44. ON_CBN_SELCHANGE(IDC_CREATEIN, OnSelchangeCreatein)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CEditPrefabDlg message handlers
  49. void CEditPrefabDlg::SetRanges(int iMaxDescript, int iMaxName)
  50. {
  51. if(iMaxDescript != -1)
  52. iMaxDescriptChars = iMaxDescript;
  53. if(iMaxName != -1)
  54. iMaxNameChars = iMaxName;
  55. }
  56. void CEditPrefabDlg::EnableLibrary(BOOL b)
  57. {
  58. m_bEnableLibrary = b;
  59. }
  60. BOOL CEditPrefabDlg::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. if(!m_bEnableLibrary)
  64. {
  65. GetDlgItem(IDC_CREATEINPROMPT)->SetRedraw(FALSE);
  66. m_CreateIn.SetRedraw(FALSE);
  67. }
  68. else
  69. {
  70. // set title
  71. SetWindowText("Create Prefab");
  72. // add all the prefab libraries to it
  73. POSITION p = ENUM_START;
  74. CPrefabLibrary *pLibrary = CPrefabLibrary::EnumLibraries(p);
  75. while(pLibrary)
  76. {
  77. int iIndex = m_CreateIn.AddString(pLibrary->GetName());
  78. m_CreateIn.SetItemData(iIndex, pLibrary->GetID());
  79. pLibrary = CPrefabLibrary::EnumLibraries(p);
  80. }
  81. m_CreateIn.SetCurSel(0);
  82. OnSelchangeCreatein();
  83. }
  84. return TRUE;
  85. }
  86. void CEditPrefabDlg::OnSelchangeCreatein()
  87. {
  88. m_dwLibraryID = m_CreateIn.GetItemData(m_CreateIn.GetCurSel());
  89. }