CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

MSGLIST.H (11086B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/MSGLIST.H 2     3/04/97 2:53p Joe_bostic $ */
     17 /***************************************************************************
     18  ***              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               ***
     19  *                                                                         *
     20  *                 Project Name : Command & Conquer                        *
     21  *                                                                         *
     22  *                    File Name : MSGLIST.H                                *
     23  *                                                                         *
     24  *                   Programmer : Bill R. Randolph                         *
     25  *                                                                         *
     26  *                   Start Date : 05/22/95                                 *
     27  *                                                                         *
     28  *                  Last Update : May 22, 1995 [BRR]                       *
     29  *                                                                         *
     30  * Initializing:																				*
     31  *   Call Init(), giving it the coords of the upper-left corner to display	*
     32  *   the messages, the coordinates to display the editable message, max # 	*
     33  *   messages allowed, max # chars per message, and the pixel height of 	*
     34  *   the font.  MaxChars should be less than or equal to the define 			*
     35  *   MAX_MESSAGE_LENGTH.																	*
     36  * 																								*
     37  *	Displaying a message:																	*
     38  *   Call Add_Message(); the buffer you pass in is copied into a static		*
     39  *   buffer in this class.  Each message is given a timeout; after this		*
     40  *   time, the message is removed from the displayed list.						*
     41  *   Each message also has a 2-byte ID, which can be used to identify the
     42  *   sender.
     43  *																									*
     44  * Editing a message:																		*
     45  *   Call Add_Edit(), giving it the color & style to print in.  An 			*
     46  *   optional "To xxx" prefix is allowed.  The edit message can appear in 	*
     47  *   the message list itself (it's placed first), or at a separate screen 	*
     48  *   location, depending on the values passed to Init().							*
     49  *																									*
     50  *	Updating messages:																		*
     51  *   The Input() routine passes new keys to the editable message; this 		*
     52  *   routine's return code tells the app whether to redraw the messages,	*
     53  *   and whether to send it the edit message.  As the user types 				*
     54  *   characters into the edit field, if he overflows the max storage			*
     55  *   for the edit field, the field is parsed & the first few words 			*
     56  *   removed; these words are put into the Overflow buffer, and the app		*
     57  *   is told so; the app should send this buffer across to the destination.*
     58  *																									*
     59  * - MessageList is a gadget list of all current messages						*
     60  * - MessageX & Y are the upper left corner of the 1st message					*
     61  * - MaxMessages is the max # of messages allowed, including the editable 	*
     62  *   message; 0 = no limit.																*
     63  * - MaxChars is the max # of chars allowed per message							*
     64  * - Height is the pixel height of a single line									*
     65  * - EditLabel points to the textmessage gadget for the current editable	*
     66  *   field.  EditBuf points to the char buffer being edited.  EditInitPos	*
     67  *   & EditCurPos define buffer index positions.									*
     68  * - EditSendAddress is the IPX Address to send the message to when RETURN	*
     69  *   is pressed.																				*
     70  *																									*
     71  * The low word in the UserData field in the TextLabelClass tells what the *
     72  * timeout for each message is (0 = none); the high byte of the UserData	*
     73  * field is used for the text message ID.												*
     74  * When a message's timeout expires, it's deleted.  When a new message		*
     75  * is added, the top message is deleted if MPlayerMaxMessages is exceeded.	*
     76  *                                                                         *
     77  * The Edit-able message is never deleted until ESC or RETURN is pressed.	*
     78  *                                                                         *
     79  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     80 
     81 #ifndef MSGLIST_H
     82 #define MSGLIST_H
     83 
     84 //***************************************************************************
     85 // Defines
     86 //***************************************************************************
     87 //---------------------------------------------------------------------------
     88 //	Max length of inter-player message buffers.  Messages.Init() should specify
     89 // a value <= this.  For editing messages, the "to" field length is added to
     90 // this length to generate the entire editable message length.  For displayed
     91 // messages, a "From" prefix length should be added to this value to generate
     92 // the entire max displayable message length.
     93 //---------------------------------------------------------------------------
     94 #define	MAX_MESSAGE_LENGTH		120
     95 
     96 //---------------------------------------------------------------------------
     97 // Max # of allowed messages at one time
     98 //---------------------------------------------------------------------------
     99 #define	MAX_NUM_MESSAGES			14
    100 
    101 //***************************************************************************
    102 // Forward declarations
    103 //***************************************************************************
    104 class TextLabelClass;
    105 
    106 //***************************************************************************
    107 // Class declaration
    108 //***************************************************************************
    109 class MessageListClass {
    110 	public:
    111 		//.....................................................................
    112 		// Constructor/Destructor
    113 		//.....................................................................
    114 		MessageListClass (void);
    115 		~MessageListClass ();
    116 
    117 		//.....................................................................
    118 		// Initialization
    119 		//.....................................................................
    120 		void Reset(void);
    121 		void Init (int x, int y, int max_msg, int maxchars, int height,
    122 			int edit_x, int edit_y, int overflow_on, int over_start,
    123 			int over_end, int width = 640);
    124 		TextLabelClass * Add_Message (char const * name, int id, char const * txt,
    125 			PlayerColorType color, TextPrintType style, int timeout);
    126 		int Concat_Message (char const * name, int id, char const * txt, int timeout);
    127 
    128 		//.....................................................................
    129 		// Message access utility routines
    130 		//.....................................................................
    131 		char * Get_Message (int id);
    132 		TextLabelClass * Get_Label (int id);
    133 
    134 		//.....................................................................
    135 		// Message-editing support routines
    136 		//.....................................................................
    137 		TextLabelClass * Add_Edit(PlayerColorType color, TextPrintType style,
    138 			char *to, char cursor = 0, int width = 640);
    139 		void Remove_Edit (void);
    140 		char * Get_Edit_Buf (void);
    141 		char * Get_Overflow_Buf (void) {return (OverflowBuf);}
    142 		void Clear_Overflow_Buf (void) {OverflowBuf[0] = 0;}
    143 		int Is_Edit(void) {return (IsEdit);}
    144 		void Set_Edit_Color(PlayerColorType color);
    145 
    146 		//.....................................................................
    147 		// Maintenance routines
    148 		//.....................................................................
    149 		int Manage (void);
    150 		int Input (KeyNumType &input);
    151 		void Draw(void);
    152 		int Num_Messages(void);
    153 		void Set_Width(int width);
    154 		void Set_Edit_Focus(void);
    155 		bool Has_Edit_Focus(void);
    156 
    157 	private:
    158 
    159 		//.....................................................................
    160 		// Message parsing
    161 		//.....................................................................
    162 		int Trim_Message(char *dest, char *src, int min_chars, int max_chars,
    163 			int scandir);
    164 
    165 		//.....................................................................
    166 		// Compute the y-coord of the message list
    167 		//.....................................................................
    168 		void Compute_Y(void);
    169 
    170 		//.....................................................................
    171 		// Private Data
    172 		//.....................................................................
    173 		TextLabelClass * MessageList;				// list of messages
    174 		int MessageX;									// x-coord of upper-left
    175 		int MessageY;									// y-coord of upper-left
    176 		int MaxMessages;								// max messages allowed
    177 		int MaxChars;									// max allowed chars per message
    178 		int Height;										// height in pixels
    179 
    180 		//.....................................................................
    181 		// Data for the edit field: the edit field will either appear at
    182 		// exact coordinates specified by the application, or it will appear
    183 		// vertically above the other messages.
    184 		//.....................................................................
    185 		unsigned EnableOverflow	: 1;					// 1 = enable overflow feature
    186 		unsigned IsEdit				: 1;					// 1 = there's an edit field
    187 		unsigned AdjustEdit			: 1;					// 1 = edit field appears over msgs
    188 		int EditX;										// x-coord of edit field
    189 		int EditY;										// y-coord of edit field
    190 		TextLabelClass *EditLabel;					// ptr to current edit label
    191 		char EditBuf[MAX_MESSAGE_LENGTH + 30];	// buffer for editable message
    192 		char OverflowBuf[MAX_MESSAGE_LENGTH + 30];	// overflow area
    193 		int EditCurPos;								// current edit position
    194 		int EditInitPos;								// initial edit position
    195 		char CursorChar;								// character to use a cursor
    196 		int OverflowStart;							// 1st index for overflow trimming
    197 		int OverflowEnd;								// last index for overflow trimming
    198 		int Width;										// Maximum width in pixels of editable string
    199 
    200 		//.....................................................................
    201 		// Buffers provided for messages.  They must be long enough for
    202 		// both the message, and for the "To" prefix on edited messages, or
    203 		// the "Name:" prefix on received messages.
    204 		//.....................................................................
    205 		char MessageBuffers[MAX_NUM_MESSAGES][MAX_MESSAGE_LENGTH + 30];
    206 		char BufferAvail[MAX_NUM_MESSAGES];
    207 };
    208 
    209 #endif
    210 /**************************** end of msglist.h *****************************/
    211