SHAPEBTN.CPP 10 KB

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