ScriptDialog.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. #if !defined(AFX_SCRIPTDIALOG_H__885FEF28_85F9_4556_9908_1BEC0B6E4C62__INCLUDED_)
  19. #define AFX_SCRIPTDIALOG_H__885FEF28_85F9_4556_9908_1BEC0B6E4C62__INCLUDED_
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif // _MSC_VER > 1000
  23. // ScriptDialog.h : header file
  24. //
  25. #include "GameLogic/SidesList.h"
  26. class ListType {
  27. public:
  28. enum {BOGUS_TYPE = 0, PLAYER_TYPE = 1, GROUP_TYPE, SCRIPT_IN_PLAYER_TYPE, SCRIPT_IN_GROUP_TYPE};
  29. unsigned char m_objType; // 4 bits
  30. unsigned char m_playerIndex; // 4 bits
  31. unsigned short int m_groupIndex; // 12 bits
  32. unsigned short int m_scriptIndex; // 12 bits
  33. ListType(void) {m_objType=BOGUS_TYPE;m_playerIndex=0;m_groupIndex = 0; m_scriptIndex=0;}
  34. Int ListToInt(void) { return((m_objType<<28)+(m_playerIndex<<24)+(m_groupIndex<<12)+m_scriptIndex);}
  35. void IntToList(int i) {m_objType = ((i)>>28)&0x0F; m_playerIndex = ((i)>>24)&0x0F; m_groupIndex = ((i)>>12)&0x0FFF; m_scriptIndex = (i)&0x0FFF;}
  36. };
  37. class ScriptList;
  38. class ScriptGroup;
  39. class Script;
  40. class Parameter;
  41. /** Class Definition for overridden Tree control that
  42. supports Right-click context sensitive menu.*/
  43. class CSDTreeCtrl : public CTreeCtrl
  44. {
  45. public:
  46. protected:
  47. virtual void OnRButtonDown(UINT nFlags, CPoint point);
  48. DECLARE_MESSAGE_MAP()
  49. };
  50. /////////////////////////////////////////////////////////////////////////////
  51. // ScriptDialog dialog
  52. class ScriptDialog : public CDialog
  53. {
  54. // Construction
  55. public:
  56. ScriptDialog(CWnd* pParent = NULL); // standard constructor
  57. ~ScriptDialog(); // destructor
  58. // Dialog Data
  59. //{{AFX_DATA(ScriptDialog)
  60. enum { IDD = IDD_ScriptDialog };
  61. // NOTE: the ClassWizard will add data members here
  62. //}}AFX_DATA
  63. // Overrides
  64. // ClassWizard generated virtual function overrides
  65. //{{AFX_VIRTUAL(ScriptDialog)
  66. protected:
  67. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  68. //}}AFX_VIRTUAL
  69. // Implementation
  70. public:
  71. static void updateWarnings(void);
  72. static void updateScriptWarning(Script *pScript);
  73. /// To allow CSDTreeCtrl access to these member functions of ScriptDialog
  74. Script *friend_getCurScript(void);
  75. ScriptGroup *friend_getCurGroup(void);
  76. protected:
  77. ListType m_curSelection;
  78. CImageList m_imageList;
  79. SidesList m_sides;
  80. static ScriptDialog *m_staticThis;
  81. CSDTreeCtrl *mTree;
  82. Bool m_draggingTreeView;
  83. HTREEITEM m_dragItem;
  84. MapObject *m_firstReadObject;
  85. PolygonTrigger *m_firstTrigger;
  86. Int m_waypointBase;
  87. Int m_maxWaypoint;
  88. AsciiString m_readPlayerNames[MAX_PLAYER_COUNT];
  89. protected:
  90. HTREEITEM addPlayer(Int playerIndx);
  91. void addScriptList(HTREEITEM hPlayer, Int playerIndex, ScriptList *pSL);
  92. void doDropOn(HTREEITEM hDrop, HTREEITEM hTarget);
  93. Script *getCurScript(void);
  94. ScriptGroup *getCurGroup(void);
  95. void reloadPlayer(Int playerIndex, ScriptList *pSL);
  96. HTREEITEM findItem(ListType sel, Bool failSafe = FALSE);
  97. void insertScript(Script *pNewScript);
  98. void scanForWaypointsAndTeams(Script *pScript, Bool doUnits, Bool doWaypoints, Bool doTriggers);
  99. void scanParmForWaypointsAndTeams(Parameter *pParm, Bool doUnits, Bool doWaypoints, Bool doTriggers);
  100. void updateSelection(ListType sel);
  101. void setIconScript(HTREEITEM item);
  102. void setIconGroup(HTREEITEM item);
  103. Bool updateIcons(HTREEITEM hItem);
  104. void markWaypoint(MapObject *pObj);
  105. static Bool ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  106. static Bool ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  107. static Bool ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  108. static Bool ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  109. static Bool ParseTeamsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  110. static Bool ParsePlayersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  111. protected:
  112. // Generated message map functions
  113. //{{AFX_MSG(ScriptDialog)
  114. afx_msg void OnSelchangedScriptTree(NMHDR* pNMHDR, LRESULT* pResult);
  115. virtual BOOL OnInitDialog();
  116. afx_msg void OnNewFolder();
  117. afx_msg void OnNewScript();
  118. afx_msg void OnEditScript();
  119. afx_msg void OnCopyScript();
  120. afx_msg void OnDelete();
  121. afx_msg void OnSave();
  122. afx_msg void OnLoad();
  123. afx_msg void OnDblclkScriptTree(NMHDR* pNMHDR, LRESULT* pResult);
  124. virtual void OnOK();
  125. virtual void OnCancel();
  126. afx_msg void OnBegindragScriptTree(NMHDR* pNMHDR, LRESULT* pResult);
  127. afx_msg void OnScriptActivate();
  128. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  129. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  130. afx_msg void OnMove(int x, int y);
  131. //}}AFX_MSG
  132. DECLARE_MESSAGE_MAP()
  133. };
  134. //{{AFX_INSERT_LOCATION}}
  135. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  136. #endif // !defined(AFX_SCRIPTDIALOG_H__885FEF28_85F9_4556_9908_1BEC0B6E4C62__INCLUDED_)