SHAPEBTN.CPP (10531B)
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/SHAPEBTN.CPP 1 3/03/97 10:25a 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 : SHAPEBTN.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 01/15/95 * 28 * * 29 * Last Update : September 20, 1995 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * ShapeButtonClass::Draw_Me -- Renders the shape button's imagery. * 34 * ShapeButtonClass::Set_Shape -- Assigns a shape to this shape button. * 35 * ShapeButtonClass::ShapeButtonClass -- Constructor for a shape type button. * 36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 37 38 #include "function.h" 39 #include "shapebtn.h" 40 41 42 /*********************************************************************************************** 43 * ShapeButtonClass::ShapeButtonClass -- Default Constructor for a shape type button. * 44 * * 45 * INPUT: none * 46 * * 47 * OUTPUT: none * 48 * * 49 * WARNINGS: You must call Set_Shape() before using a button constructed with this function, * 50 * and you must set X & Y, and ID. * 51 * * 52 * HISTORY: * 53 * 01/15/1995 JLB : Created. * 54 *=============================================================================================*/ 55 ShapeButtonClass::ShapeButtonClass(void) : 56 ToggleClass(0, 0, 0, 0, 0), 57 ReflectButtonState(false) 58 { 59 } 60 61 62 /*********************************************************************************************** 63 * ShapeButtonClass::ShapeButtonClass -- Constructor for a shape type button. * 64 * * 65 * This is the normal constructor for a shape type button. Shape buttons are ones that * 66 * have their imagery controlled by a shape file. The various states of the button are * 67 * given a visual form as one of these shapes. Button dimensions are controlled by the * 68 * first shape. * 69 * * 70 * INPUT: id -- The button ID. * 71 * * 72 * shape -- Pointer to the shape file that controls the button's display. * 73 * * 74 * x,y -- The pixel coordinate of the upper left corner of the button. * 75 * * 76 * OUTPUT: none * 77 * * 78 * WARNINGS: The width and height of the shape is controlled by the first shape in the * 79 * shape file provided. This means that all the shapes in the shape file must be * 80 * the same size. * 81 * * 82 * HISTORY: * 83 * 01/15/1995 JLB : Created. * 84 *=============================================================================================*/ 85 ShapeButtonClass::ShapeButtonClass(unsigned id, void const * shape, int x, int y) : 86 ToggleClass(id, x, y, 0, 0), 87 ReflectButtonState(false) 88 { 89 // Width = 0; 90 // Height = 0; 91 Set_Shape(shape); 92 } 93 94 95 /*********************************************************************************************** 96 * ShapeButtonClass::Set_Shape -- Assigns a shape to this shape button. * 97 * * 98 * This routine will assign the specified shape to this shape object. * 99 * * 100 * INPUT: data -- Pointer to the shape to assign. * 101 * * 102 * OUTPUT: none * 103 * * 104 * WARNINGS: none * 105 * * 106 * HISTORY: * 107 * 09/20/1995 JLB : Created. * 108 *=============================================================================================*/ 109 void ShapeButtonClass::Set_Shape(void const * data) 110 { 111 ShapeData = data; 112 if (ShapeData) { 113 Width = Get_Build_Frame_Width(ShapeData); 114 Height = Get_Build_Frame_Height(ShapeData); 115 } 116 } 117 118 119 /*********************************************************************************************** 120 * ShapeButtonClass::Draw_Me -- Renders the shape button's imagery. * 121 * * 122 * This function is called when the button detects that it must be redrawn. The actual * 123 * shape to use is controled by the button's state and the shape file provided when then * 124 * button was constructed. * 125 * * 126 * INPUT: forced -- Should the button be redrawn regardless of the redraw flag? * 127 * * 128 * OUTPUT: bool; Was the shape redrawn? * 129 * * 130 * WARNINGS: none * 131 * * 132 * HISTORY: * 133 * 01/15/1995 JLB : Created. * 134 *=============================================================================================*/ 135 int ShapeButtonClass::Draw_Me(int forced) 136 { 137 if (ControlClass::Draw_Me(forced) && ShapeData) { 138 139 /* 140 ** Hide the mouse. 141 */ 142 if (LogicPage == &SeenBuff) { 143 Conditional_Hide_Mouse(X, Y, X+Width-1, Y+Height-1); 144 } 145 146 /* 147 ** Draw the body & set text color. 148 */ 149 int shapenum = 0; 150 if (IsDisabled) { 151 shapenum = DISABLED_SHAPE; 152 } else { 153 154 if (!ReflectButtonState) { 155 156 if (IsPressed) { 157 shapenum = DOWN_SHAPE; 158 } else { 159 shapenum = UP_SHAPE; 160 } 161 } else { 162 shapenum = IsOn; 163 } 164 165 } 166 CC_Draw_Shape(ShapeData, shapenum, X, Y, WINDOW_MAIN, SHAPE_NORMAL); 167 /* 168 ** Display the mouse. 169 */ 170 if (LogicPage == &SeenBuff) { 171 Conditional_Show_Mouse(); 172 } 173 return(true); 174 } 175 return(false); 176 } 177 178 179