| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- /*
- ** Command & Conquer(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /* $Header: F:\projects\c&c\vcs\code\confdlg.cpv 2.17 16 Oct 1995 16:49:52 JOE_BOSTIC $ */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Command & Conquer *
- * *
- * File Name : CONFDLG.CPP *
- * *
- * Programmer : Maria del Mar McCready Legg *
- * Joe L. Bostic *
- * *
- * Start Date : Jan 30, 1995 *
- * *
- * Last Update : Jan 30, 1995 [MML] *
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * ConfirmationClass::Process -- Handles all the options graphic interface. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "function.h"
- #include "confdlg.h"
- bool ConfirmationClass::Process(int text)
- {
- return(Process(Text_String(text)));
- }
- /***********************************************************************************************
- * ConfirmationClass::Process -- Handles all the options graphic interface. *
- * *
- * This dialog uses an edit box to confirm a deletion. *
- * *
- * INPUT: char *string - display in edit box. *
- * OUTPUT: none *
- * WARNINGS: none *
- * HISTORY: 12/31/1994 MML : Created. *
- *=============================================================================================*/
- bool ConfirmationClass::Process(char const * string)
- {
- int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
- enum {
- NUM_OF_BUTTONS = 2
- };
- char buffer[80*3];
- int result = true;
- int width;
- int bwidth, bheight; // button width and height
- int height;
- int selection;
- bool pressed;
- int curbutton;
- TextButtonClass *buttons[NUM_OF_BUTTONS];
- /*
- ** Set up the window. Window x-coords are in bytes not pixels.
- */
- strcpy(buffer, string);
- Fancy_Text_Print(TXT_NONE,0,0,TBLACK,TBLACK,TPF_6PT_GRAD | TPF_NOSHADOW);
- Format_Window_String(buffer, 200*factor, width, height);
- width += 60*factor;
- height += 60*factor;
- int x = (320*factor - width) / 2;
- int y = (200*factor - height) / 2;
- Set_Logic_Page(SeenBuff);
- /*
- ** Create Buttons. Button coords are in pixels, but are window-relative.
- */
- bheight = FontHeight + FontYSpacing + 2;
- bwidth = MAX( (String_Pixel_Width( Text_String( TXT_YES ) ) + 8), 30);
- TextButtonClass yesbtn(BUTTON_YES, TXT_YES,
- TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
- x + 10*factor, y + height - (bheight + 5*factor), bwidth );
- TextButtonClass nobtn(BUTTON_NO, TXT_NO,
- TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
- x + width - (bwidth + 10*factor),
- y + height - (bheight + 5*factor), bwidth );
- nobtn.Add_Tail(yesbtn);
- curbutton = 1;
- buttons[0] = &yesbtn;
- buttons[1] = &nobtn;
- buttons[curbutton]->Turn_On();
- /*
- ** This causes left mouse button clicking within the confines of the dialog to
- ** be ignored if it wasn't recognized by any other button or slider.
- */
- GadgetClass dialog(x, y, width, height, GadgetClass::LEFTPRESS);
- dialog.Add_Tail(yesbtn);
- /*
- ** This causes a right click anywhere or a left click outside the dialog region
- ** to be equivalent to clicking on the return to options dialog.
- */
- ControlClass background(BUTTON_NO, 0, 0, SeenBuff.Get_Width(), SeenBuff.Get_Height(), GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS);
- background.Add_Tail(yesbtn);
- /*
- ** Main Processing Loop.
- */
- bool display = true;
- bool process = true;
- pressed = false;
- while (process) {
- /*
- ** Invoke game callback.
- */
- if (GameToPlay == GAME_NORMAL) {
- Call_Back();
- } else {
- if (Main_Loop()) {
- process = false;
- result = false;
- }
- }
- /*
- ** If we have just received input focus again after running in the background then
- ** we need to redraw.
- */
- if (AllSurfaces.SurfacesRestored){
- AllSurfaces.SurfacesRestored=FALSE;
- display=TRUE;
- }
- /*
- ** Refresh display if needed.
- */
- if (display) {
- Hide_Mouse();
- /*
- ** Draw the background.
- */
- Dialog_Box(x, y, width, height);
- Draw_Caption(TXT_CONFIRMATION, x, y, width);
- Fancy_Text_Print(buffer, x+20*factor, y+30*factor, CC_GREEN, TBLACK, TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
- /*
- ** Draw the titles.
- */
- yesbtn.Draw_All();
- Show_Mouse();
- display = false;
- }
- /*
- ** Get user input.
- */
- KeyNumType input = yesbtn.Input();
- /*
- ** Process Input.
- */
- switch (input) {
- case (BUTTON_YES | KN_BUTTON):
- selection = BUTTON_YES;
- pressed = true;
- break;
- case (KN_ESC):
- case (BUTTON_NO | KN_BUTTON):
- selection = BUTTON_NO;
- pressed = true;
- break;
- case (KN_LEFT):
- buttons[curbutton]->Turn_Off();
- buttons[curbutton]->Flag_To_Redraw();
- curbutton--;
- if (curbutton < 0) {
- curbutton = NUM_OF_BUTTONS - 1;
- }
- buttons[curbutton]->Turn_On();
- buttons[curbutton]->Flag_To_Redraw();
- break;
- case (KN_RIGHT):
- buttons[curbutton]->Turn_Off();
- buttons[curbutton]->Flag_To_Redraw();
- curbutton++;
- if (curbutton > (NUM_OF_BUTTONS - 1) ) {
- curbutton = 0;
- }
- buttons[curbutton]->Turn_On();
- buttons[curbutton]->Flag_To_Redraw();
- break;
- case (KN_RETURN):
- selection = curbutton + BUTTON_YES;
- pressed = true;
- break;
- default:
- break;
- }
- if (pressed) {
- switch (selection) {
- case (BUTTON_YES):
- result = true;
- process = false;
- break;
- case (BUTTON_NO):
- result = false;
- process = false;
- break;
- }
- pressed = false;
- }
- }
- return(result);
- }
|