LayersList.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. ** Command & Conquer Generals(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. // FILE: LayersList.h
  19. /*---------------------------------------------------------------------------*/
  20. /* EA Pacific */
  21. /* Confidential Information */
  22. /* Copyright (C) 2001 - All Rights Reserved */
  23. /* DO NOT DISTRIBUTE */
  24. /*---------------------------------------------------------------------------*/
  25. /* Project: RTS3 */
  26. /* File name: LayersList.h */
  27. /* Created: John K. McDonald, Jr., 5/10/2002 */
  28. /* Desc: Layers List Declarations */
  29. /* Revision History: */
  30. /* 5/10/2002 : Initial creation */
  31. /*---------------------------------------------------------------------------*/
  32. #pragma once
  33. #ifndef _H_LAYERSLIST_
  34. #define _H_LAYERSLIST_
  35. // INCLUDES ///////////////////////////////////////////////////////////////////
  36. #include "Common/AsciiString.h"
  37. #include <list>
  38. #include <string>
  39. // DEFINES ////////////////////////////////////////////////////////////////////
  40. // FORWARD DECLARATIONS ///////////////////////////////////////////////////////
  41. class MapObject;
  42. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  43. typedef std::list<MapObject*> ListMapObjectPtr;
  44. typedef ListMapObjectPtr::iterator ListMapObjectPtrIt;
  45. struct Layer
  46. {
  47. AsciiString layerName;
  48. ListMapObjectPtr objectsInLayer;
  49. Bool show;
  50. };
  51. typedef std::list<Layer> ListLayer;
  52. typedef ListLayer::iterator ListLayerIt;
  53. // Class Definition for overridden Tree control that supports Right-click context sensitive menu.
  54. class CLLTreeCtrl : public CTreeCtrl
  55. {
  56. public:
  57. AsciiString getLastClickedLayer(void) { return mLastClickedLayer; }
  58. AsciiString getLastClickedObject(void) { return mLastClickedObject; }
  59. protected:
  60. AsciiString mLastClickedLayer;
  61. AsciiString mLastClickedObject;
  62. void buildMoveMenu(CMenu* pPopup, UINT firstID);
  63. virtual void OnRButtonDown(UINT nFlags, CPoint point);
  64. DECLARE_MESSAGE_MAP()
  65. };
  66. // Class Definition
  67. class LayersList : public CDialog
  68. {
  69. public:
  70. enum { IDD = IDD_LAYERSLIST };
  71. LayersList(UINT nIDTemplate = LayersList::IDD, CWnd *parentWnd = NULL);
  72. virtual ~LayersList();
  73. void resetLayers();
  74. void addMapObjectToLayersList(IN MapObject *objToAdd, AsciiString layerToAddTo = AsciiString(TheDefaultLayerName.c_str()));
  75. AsciiString removeMapObjectFromLayersList(IN MapObject *objToRemove);
  76. void changeMapObjectLayer(IN MapObject *objToChange, AsciiString layerToPlaceOn);
  77. void addLayerNamed(IN AsciiString layerToAdd);
  78. void removeLayerNamed(IN AsciiString layerToRemove);
  79. void changeLayerName(IN AsciiString oldLayerName, IN AsciiString newLayerName);
  80. void mergeLayerInto(IN ListLayerIt src, IN ListLayerIt dst);
  81. Bool isLayerHidden(IN AsciiString layerToTest);
  82. void updateUIFromList(void);
  83. void disableUpdates() { m_performUpdates = false; }
  84. void enableUpdates() { m_performUpdates = true; updateUIFromList(); }
  85. const ListLayer& GetAllLayers(void) const { return mLayers; }
  86. static MapObject *findObjectByUID(AsciiString objectIDToFind);
  87. protected:
  88. AsciiString mCurrentlyEditingLabel;
  89. ListLayer mLayers;
  90. CLLTreeCtrl *mTree;
  91. CImageList mImageList;
  92. Bool m_performUpdates;
  93. HTREEITEM findTreeLayerNamed(const AsciiString& nameToFind);
  94. HTREEITEM findTreeObjectNamed(const AsciiString& objectToFind, HTREEITEM layerItem);
  95. // This is a string because making it an AsciiString makes us barf on construction. :-(
  96. static std::string TheDefaultLayerName;
  97. static std::string TheDefaultNewLayerName;
  98. static const std::string TheUnmutableDefaultLayerName;
  99. // This function takes an MapObject, and does one of the following:
  100. // 1) Return true if the MapObject can be found, and
  101. // layerIt points to a valid layer iterator in which the MapObject was found
  102. // MapObjectIt points to a valid MapObject iterator on the layerIts MapObjectsInLayer member
  103. // 2) Returns false if the MapObject cannot be found.
  104. Bool findMapObjectAndList(IN MapObject *MapObjectToFind, OUT ListLayerIt *layerIt = NULL, OUT ListMapObjectPtrIt *MapObjectIt = NULL);
  105. // This function takes a layer name, and does one of the following:
  106. // 1) Return true if the layer can be found, and
  107. // layerIt points to a valid layer iterator named layerName
  108. // 2) Returns false if the layer cannot be found.
  109. Bool findLayerNamed(IN AsciiString layerName, OUT ListLayerIt *layerIt = NULL);
  110. void addMapObjectToLayer(IN MapObject *objToAdd, IN ListLayerIt *layerIt);
  111. void removeMapObjectFromLayer(IN MapObject *objToRemove, IN ListLayerIt *layerIt = NULL, IN ListMapObjectPtrIt *MapObjectIt = NULL);
  112. protected:
  113. virtual void OnOK();
  114. virtual void OnCancel();
  115. virtual BOOL OnInitDialog();
  116. afx_msg void OnBeginEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult);
  117. afx_msg void OnEndEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult);
  118. afx_msg void OnMergeLayer(UINT commandID);
  119. afx_msg void OnMergeObject(UINT commandID);
  120. afx_msg void OnMergeViewSelection(UINT commandID);
  121. afx_msg void OnNewLayer();
  122. afx_msg void OnDeleteLayer();
  123. afx_msg void OnHideShowLayer();
  124. DECLARE_MESSAGE_MAP()
  125. };
  126. extern LayersList *TheLayersList;
  127. #endif /* _H_LAYERSLIST_ */