TAB.CPP (13789B)
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: F:\projects\c&c\vcs\code\tab.cpv 2.18 16 Oct 1995 16:52:04 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 : TAB.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 12/15/94 * 28 * * 29 * Last Update : August 25, 1995 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * TabClass::AI -- Handles player I/O with the tab buttons. * 34 * TabClass::Draw_It -- Displays the tab buttons as necessary. * 35 * TabClass::Set_Active -- Activates a "filefolder tab" button. * 36 * TabClass::TabClass -- Default construct for the tab button class. * 37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 38 39 #include "function.h" 40 41 42 void const * TabClass::TabShape = NULL; 43 44 45 /*********************************************************************************************** 46 * TabClass::TabClass -- Default construct for the tab button class. * 47 * * 48 * The default constructor merely sets the tab buttons to default non-selected state. * 49 * * 50 * INPUT: none * 51 * * 52 * OUTPUT: none * 53 * * 54 * WARNINGS: none * 55 * * 56 * HISTORY: * 57 * 12/15/1994 JLB : Created. * 58 *=============================================================================================*/ 59 TabClass::TabClass(void) 60 { 61 IsToRedraw = false; 62 // Select = -1; 63 } 64 65 66 /*********************************************************************************************** 67 * TabClass::Draw_It -- Displays the tab buttons as necessary. * 68 * * 69 * This routine is called whenever the display is being redrawn (in some fashion). The * 70 * parameter can be used to force the tab buttons to redraw completely. The default action * 71 * is to only redraw if the tab buttons have been explicitly flagged to be redraw. The * 72 * result of this is the elimination of unnecessary redraws. * 73 * * 74 * INPUT: complete -- bool; Force redraw of the entire tab button graphics? * 75 * * 76 * OUTPUT: none * 77 * * 78 * WARNINGS: none * 79 * * 80 * HISTORY: * 81 * 12/15/1994 JLB : Created. * 82 * 05/19/1995 JLB : New EVA style. * 83 *=============================================================================================*/ 84 void TabClass::Draw_It(bool complete) 85 { 86 87 SidebarClass::Draw_It(complete); 88 89 if (Debug_Map){ 90 //HidPage.Unlock(); 91 return; 92 } 93 94 // Disable tab drawing. ST - 3/1/2019 11:35AM 95 #if 0 96 /* 97 ** Redraw the top bar imagery if flagged to do so or if the entire display needs 98 ** to be redrawn. 99 */ 100 int width = SeenBuff.Get_Width(); 101 int rightx = width - 1; 102 103 if (complete || IsToRedraw) { 104 105 if (Tab_Height != 0) { 106 107 108 if (LogicPage->Lock()){ 109 110 LogicPage->Fill_Rect(0, 0, rightx, Tab_Height-2, BLACK); 111 CC_Draw_Shape(TabShape, 0, 0, 0, WINDOW_MAIN, SHAPE_NORMAL); 112 CC_Draw_Shape(TabShape, 0, width-Eva_Width, 0, WINDOW_MAIN, SHAPE_NORMAL); 113 Draw_Credits_Tab(); 114 LogicPage->Draw_Line(0, Tab_Height-1, rightx, Tab_Height-1, BLACK); 115 116 Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, Eva_Width/2, 0, 11, TBLACK, TPF_GREEN12_GRAD|TPF_CENTER | TPF_USE_GRAD_PAL); 117 Fancy_Text_Print(TXT_TAB_SIDEBAR, width-(Eva_Width/2), 0, 11, TBLACK, TPF_GREEN12_GRAD|TPF_CENTER | TPF_USE_GRAD_PAL); 118 } 119 LogicPage->Unlock(); 120 121 122 } 123 124 } 125 126 Credits.Graphic_Logic(complete || IsToRedraw); 127 #endif 128 IsToRedraw = false; 129 } 130 131 132 void TabClass::Draw_Credits_Tab(void) 133 { 134 CC_Draw_Shape(TabShape, 0, 320, 0, WINDOW_MAIN, SHAPE_NORMAL); 135 } 136 137 138 /*********************************************************************************************** 139 * TC::Hilite_Tab -- Draw a tab in its depressed state * 140 * * 141 * * 142 * * 143 * INPUT: Tab to draw (not used) * 144 * * 145 * OUTPUT: Nothing * 146 * * 147 * WARNINGS: None * 148 * * 149 * HISTORY: * 150 * 5/21/96 10:47AM ST : Created * 151 *=============================================================================================*/ 152 153 void TabClass::Hilite_Tab(int tab) 154 { 155 int xpos = 0; 156 int text = TXT_TAB_BUTTON_CONTROLS; 157 tab = tab; 158 159 CC_Draw_Shape(TabShape, 1 , xpos, 0, WINDOW_MAIN, SHAPE_NORMAL); 160 Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, 80, 0, 11, TBLACK, TPF_GREEN12|TPF_CENTER | TPF_USE_GRAD_PAL); 161 } 162 163 164 /*********************************************************************************************** 165 * TabClass::AI -- Handles player I/O with the tab buttons. * 166 * * 167 * This routine is called every game tick and passed whatever key the player has supplied. * 168 * If the input selects a tab button, then the graphic gets updated accordingly. * 169 * * 170 * INPUT: input -- The player's input character (might be mouse click). * 171 * * 172 * x,y -- Mouse coordinates at time of input. * 173 * * 174 * OUTPUT: none * 175 * * 176 * WARNINGS: none * 177 * * 178 * HISTORY: * 179 * 12/15/1994 JLB : Created. * 180 * 12/31/1994 JLB : Uses mouse coordinate parameters. * 181 * 05/31/1995 JLB : Fixed to handle mouse shape properly. * 182 * 08/25/1995 JLB : Handles new scrolling option. * 183 *=============================================================================================*/ 184 void TabClass::AI(KeyNumType &input, int x, int y) 185 { 186 if (y >= 0 && y < Tab_Height && x < (SeenBuff.Get_Width() - 1) && x > 0) { 187 188 bool ok = false; 189 int width = SeenBuff.Get_Width(); 190 191 /* 192 ** If the mouse is at the top of the screen, then the tab bars only work 193 ** in certain areas. If the special scroll modification is not active, then 194 ** the tabs never work when the mouse is at the top of the screen. 195 */ 196 if (y > 0 || (Special.IsScrollMod && ((x > 3 && x < Eva_Width) || (x < width-3 && x > width-Eva_Width)))) { 197 ok = true; 198 } 199 200 if (ok) { 201 if (input == KN_LMOUSE) { 202 int sel = -1; 203 if (x < Eva_Width) sel = 0; 204 if (x > width-Eva_Width) sel = 1; 205 if (sel >= 0) { 206 Set_Active(sel); 207 input = KN_NONE; 208 } 209 } 210 211 Override_Mouse_Shape(MOUSE_NORMAL, false); 212 } 213 } 214 215 Credits.AI(); 216 217 SidebarClass::AI(input, x, y); 218 } 219 220 221 /*********************************************************************************************** 222 * TabClass::Set_Active -- Activates a "filefolder tab" button. * 223 * * 224 * This function is used to activate one of the file folder tab buttons that appear at the * 225 * top edge of the screen. * 226 * * 227 * INPUT: select -- The button to activate. 0 = left button, 1=next button, etc. * 228 * * 229 * OUTPUT: none * 230 * * 231 * WARNINGS: none * 232 * * 233 * HISTORY: * 234 * 12/15/1994 JLB : Created. * 235 *=============================================================================================*/ 236 void TabClass::Set_Active(int select) 237 { 238 switch (select) { 239 case 0: 240 Queue_Options(); 241 break; 242 243 case 1: 244 Map.SidebarClass::Activate(-1); 245 break; 246 247 default: 248 break; 249 } 250 } 251 252 void TabClass::One_Time(void) 253 { 254 int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2; 255 Eva_Width = 80 * factor; 256 //Tab_Height = 8 * factor; 257 Tab_Height = 0; // Disable tab drawing. ST - 3/1/2019 11:35AM 258 259 SidebarClass::One_Time(); 260 TabShape = Hires_Retrieve("TABS.SHP"); 261 }