conversationmgr.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/conversationmgr.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/15/02 9:37p $*
  29. * *
  30. * $Revision:: 16 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __CONVERSATION_MGR_H
  39. #define __CONVERSATION_MGR_H
  40. #include "saveloadsubsystem.h"
  41. #include "vector.h"
  42. ////////////////////////////////////////////////////////////////
  43. // Forward declarations
  44. ////////////////////////////////////////////////////////////////
  45. class ChunkSaveClass;
  46. class ChunkLoadClass;
  47. class ConversationClass;
  48. class ActiveConversationClass;
  49. class PhysicalGameObj;
  50. class OratorClass;
  51. ////////////////////////////////////////////////////////////////
  52. // Singleton instance
  53. ////////////////////////////////////////////////////////////////
  54. extern class ConversationMgrClass _ConversationMgrSaveLoad;
  55. ////////////////////////////////////////////////////////////////
  56. // Typedefs
  57. ////////////////////////////////////////////////////////////////
  58. typedef DynamicVectorClass<ConversationClass *> CONVERSATION_LIST;
  59. typedef DynamicVectorClass<ActiveConversationClass *> ACTIVE_CONVERSATION_LIST;
  60. ////////////////////////////////////////////////////////////////
  61. //
  62. // ConversationMgrClass
  63. //
  64. ////////////////////////////////////////////////////////////////
  65. class ConversationMgrClass : public SaveLoadSubSystemClass
  66. {
  67. public:
  68. ////////////////////////////////////////////////////////////////
  69. // Public constants
  70. ////////////////////////////////////////////////////////////////
  71. typedef enum
  72. {
  73. CATEGORY_GLOBAL = 0,
  74. CATEGORY_LEVEL,
  75. CATEGORY_MAX
  76. } CATEGORY;
  77. ////////////////////////////////////////////////////////////////
  78. // Public constructors/destructors
  79. ////////////////////////////////////////////////////////////////
  80. ConversationMgrClass (void);
  81. virtual ~ConversationMgrClass (void);
  82. ////////////////////////////////////////////////////////////////
  83. // Public methods
  84. ////////////////////////////////////////////////////////////////
  85. //
  86. // Initialization
  87. //
  88. static void Initialize (void) {}
  89. static void Shutdown (void) { Reset (); }
  90. //
  91. // Conversation editing
  92. //
  93. static void Add_Conversation (ConversationClass *conversation);
  94. static int Get_Conversation_Count (void);
  95. static int Get_Conversation_Count (int category_index) { return ConversationList[category_index].Count (); }
  96. static ConversationClass * Peek_Conversation (int index);
  97. static ConversationClass * Peek_Conversation (int category_index, int index) { return ConversationList[category_index][index]; }
  98. static void Remove_Conversation (ConversationClass *conversation);
  99. //
  100. // Runtime conversation access
  101. //
  102. static ActiveConversationClass * Create_New_Conversation (ConversationClass *conversation, DynamicVectorClass<PhysicalGameObj *> &buddy_list);
  103. static ActiveConversationClass * Create_New_Conversation (ConversationClass *conversation);
  104. static void Start_Conversation (PhysicalGameObj *orator);
  105. static ActiveConversationClass * Start_Conversation (PhysicalGameObj *orator, const char *conversation_name, bool force = false);
  106. static ActiveConversationClass * Start_Conversation (PhysicalGameObj *orator, int conversation_id, bool force = false);
  107. static ActiveConversationClass * Start_Conversation (PhysicalGameObj *orator, ConversationClass *conversation, bool force = false);
  108. static ConversationClass * Pick_Conversation (PhysicalGameObj *initiator, const DynamicVectorClass<PhysicalGameObj *> &available_orator_list, DynamicVectorClass<PhysicalGameObj *> &orator_list);
  109. static ConversationClass * Find_Conversation (const char *conversation_name);
  110. static ConversationClass * Find_Conversation (int conversation_id);
  111. static ActiveConversationClass * Find_Active_Conversation (int id);
  112. static void Reset_All_Other_Conversations (ActiveConversationClass *active_conversation);
  113. static bool Is_Key_Conversation_Playing (void);
  114. static int Get_Active_Conversation_Count (void) { return ActiveConversationList.Count (); }
  115. static void Think (void);
  116. //
  117. // State access
  118. //
  119. static void Reset (void);
  120. static void Reset_Conversations (int category_index, bool reset_start_id = false);
  121. static void Reset_Active_Conversations (void);
  122. static void Set_Category_To_Save (CATEGORY category_index) { SaveCategoryID = category_index; }
  123. //
  124. // EmotIcon control
  125. //
  126. static bool Are_Emot_Icons_Displayed (void) { return DisplayEmotIcons; }
  127. static void Display_Emot_Icons (bool onoff) { DisplayEmotIcons = onoff; }
  128. //
  129. // From SaveLoadSubSystemClass
  130. //
  131. uint32 Chunk_ID (void) const;
  132. protected:
  133. ////////////////////////////////////////////////////////////////
  134. // Protected methods
  135. ////////////////////////////////////////////////////////////////
  136. static void Build_Buddy_List (PhysicalGameObj *orator, DynamicVectorClass<PhysicalGameObj *> &list, bool include_soldier);
  137. static bool Test_Conversation (PhysicalGameObj *initiator, ConversationClass *conversation, DynamicVectorClass<PhysicalGameObj *> &buddy_list, bool force = false);
  138. static bool Test_Orator (ConversationClass *conversation, OratorClass *orator, PhysicalGameObj *game_obj);
  139. //
  140. // From SaveLoadSubSystemClass
  141. //
  142. bool Contains_Data (void) const { return true; }
  143. const char * Name (void) const { return "ConversationMgrClass"; }
  144. bool Save (ChunkSaveClass &csave);
  145. bool Load (ChunkLoadClass &cload);
  146. void Load_Variables (ChunkLoadClass &cload);
  147. bool Load_Conversations (ChunkLoadClass &cload, int category_id);
  148. private:
  149. ////////////////////////////////////////////////////////////////
  150. // Private member data
  151. ////////////////////////////////////////////////////////////////
  152. static CONVERSATION_LIST ConversationList[CATEGORY_MAX];
  153. static ACTIVE_CONVERSATION_LIST ActiveConversationList;
  154. static int NextActiveConversationID;
  155. static int NextGlobalConversationID;
  156. static int NextLevelConversationID;
  157. static CATEGORY SaveCategoryID;
  158. static bool DisplayEmotIcons;
  159. };
  160. ////////////////////////////////////////////////////////////////
  161. // Get_Conversation_Count
  162. ////////////////////////////////////////////////////////////////
  163. inline int
  164. ConversationMgrClass::Get_Conversation_Count (void)
  165. {
  166. int total = 0;
  167. for (int index = 0; index < CATEGORY_MAX; index ++) {
  168. total += ConversationList[index].Count ();
  169. }
  170. return total;
  171. }
  172. ////////////////////////////////////////////////////////////////
  173. // Peek_Conversation
  174. ////////////////////////////////////////////////////////////////
  175. inline ConversationClass *
  176. ConversationMgrClass::Peek_Conversation (int index_to_find)
  177. {
  178. ConversationClass *conversation = NULL;
  179. //
  180. // Loop over all the categories
  181. //
  182. for (int index = 0; index < CATEGORY_MAX; index ++) {
  183. //
  184. // Is the specified index inside of this category?
  185. //
  186. int curr_count = ConversationList[index].Count ();
  187. if (index_to_find < curr_count) {
  188. //
  189. // Index into this category to find the conversation
  190. //
  191. conversation = ConversationList[index][index_to_find];
  192. break;
  193. } else {
  194. //
  195. // Adjust the specified index to be within the range
  196. // of the next category
  197. //
  198. index_to_find -= curr_count;
  199. }
  200. }
  201. return conversation;
  202. }
  203. #endif //__CONVERSATION_MGR_H