CnC_Remastered_Collection

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

DESCDLG.CPP (6195B)


      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/DESCDLG.CPP 1     3/03/97 10:24a 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  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : DESCDLG.CPP                                                  *
     24  *                                                                                             *
     25  *                   Programmer : Maria del Mar McCready Legg                                  *
     26  *                                  Joe L. Bostic                                              *
     27  *                                                                                             *
     28  *                   Start Date : Jan 26, 1995                                                 *
     29  *                                                                                             *
     30  *                  Last Update : Jan 26, 1995   [MML]                                         *
     31  *                                                                                             *
     32  *---------------------------------------------------------------------------------------------*
     33  * Functions:                                                                                  *
     34  *   DescriptionClass::Process -- Handles all the options graphic interface.                   *
     35  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     36 
     37 #include	"function.h"
     38 #include	"descdlg.h"
     39 
     40 
     41 /***********************************************************************************************
     42  * DescriptionClass::Process -- Handles all the options graphic interface.                     *
     43  *                                                                                             *
     44  *    This dialog uses an edit box to "fill-out" a description.                                *
     45  *                                                                                             *
     46  * INPUT:      char *string - return answer here.                                              *
     47  * OUTPUT:     none                                                                            *
     48  * WARNINGS:   none                                                                            *
     49  * HISTORY:    12/31/1994 MML : Created.                                                       *
     50  *=============================================================================================*/
     51 void DescriptionClass::Process(char * string)
     52 {
     53 	/*
     54 	**	Set up the window.  Window x-coords are in bytes not pixels.
     55 	*/
     56 	Set_Window(WINDOW_EDITOR, OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT);
     57 	Set_Logic_Page(SeenBuff);
     58 
     59 	/*
     60 	**	Create Buttons.  Button coords are in pixels, but are window-relative.
     61 	*/
     62 	TextButtonClass optionsbtn(BUTTON_OPTIONS, TXT_OK, TPF_BUTTON, 0, BUTTON_Y);
     63 	TextButtonClass cancelbtn(BUTTON_CANCEL, TXT_CANCEL, TPF_BUTTON, 0, BUTTON_Y);
     64 
     65 	cancelbtn.X  = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3)*2;
     66 	optionsbtn.X = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3);
     67 	optionsbtn.Add_Tail(cancelbtn);
     68 
     69 	EditClass edit(
     70 		BUTTON_EDIT,
     71 		string,
     72 		31,
     73 		TPF_6PT_GRAD,
     74 		0,
     75 		EDIT_Y,
     76 		EDIT_W);
     77 
     78 	edit.Set_Focus();
     79 	edit.X = OPTION_X + (OPTION_WIDTH - edit.Width)/2,
     80 	optionsbtn.Add_Tail(edit);
     81 
     82 	/*
     83 	**	This causes left mouse button clicking within the confines of the dialog to
     84 	**	be ignored if it wasn't recognized by any other button or slider.
     85 	*/
     86 	GadgetClass dialog(OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT, GadgetClass::LEFTPRESS);
     87 	optionsbtn.Add_Tail(dialog);
     88 
     89 	/*
     90 	**	This causes a right click anywhere or a left click outside the dialog region
     91 	**	to be equivalent to clicking on the return to options dialog.
     92 	*/
     93 	ControlClass background(BUTTON_OPTIONS, 0, 0, 320, 200, GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS);
     94 	optionsbtn.Add_Tail(background);
     95 
     96 	/*
     97 	**	Main Processing Loop
     98 	*/
     99 	bool display = true;
    100 	bool process = true;
    101 	while (process) {
    102 
    103 		/*
    104 		**	Invoke game callback
    105 		*/
    106 		Call_Back();
    107 
    108 		/*
    109 		**	Refresh display if needed
    110 		*/
    111 		if (display) {
    112 
    113 			Window_Hide_Mouse(WINDOW_EDITOR);
    114 
    115 			/*
    116 			**	Draw the background
    117 			*/
    118 			Window_Box (WINDOW_EDITOR, BOXSTYLE_BORDER); // has border, raised up
    119 			Draw_Caption(TXT_MISSION_DESCRIPTION, OPTION_X, OPTION_Y, OPTION_WIDTH);
    120 
    121 			/*
    122 			**	Draw the titles
    123 			*/
    124 			optionsbtn.Draw_All();
    125 			Window_Show_Mouse();
    126 			display = false;
    127 		}
    128 
    129 		/*
    130 		**	Get user input
    131 		*/
    132 		KeyNumType input = optionsbtn.Input();
    133 
    134 		/*
    135 		**	Process Input
    136 		*/
    137 		switch (input) {
    138 
    139 			case KN_RETURN:
    140 			case KeyNumType(BUTTON_OPTIONS|KN_BUTTON):
    141 				strtrim(string);
    142 				process = false;
    143 				break;
    144 
    145 			case KN_ESC:
    146 			case KeyNumType(BUTTON_CANCEL|KN_BUTTON):
    147 				string[0]= NULL;
    148 				strtrim(string);
    149 				process = false;
    150 				break;
    151 
    152 			case KeyNumType(BUTTON_EDIT|KN_BUTTON):
    153 				break;
    154 
    155 			default:
    156 				break;
    157 		}
    158 	}
    159 }
    160