1 /*******************************************************************
2  *
3  *    DESCRIPTION: 	ahudgadg.cpp
4  *
5  *    AUTHOR: David Malcolm
6  *
7  *    HISTORY:  Created 14/11/97
8  *
9  *******************************************************************/
10 
11 /* Includes ********************************************************/
12 #include "3dc.h"
13 #include "ahudgadg.hpp"
14 
15 	#if UseGadgets
16 		#include "trepgadg.hpp"
17 		#include "t_ingadg.hpp"
18 		#include "iofocus.h"
19 	#endif
20 
21 	#define UseLocalAssert Yes
22 	#include "ourasert.h"
23 
24 /* Version settings ************************************************/
25 
26 /* Constants *******************************************************/
27 
28 /* Macros **********************************************************/
29 
30 /* Imported function prototypes ************************************/
31 
32 /* Imported data ***************************************************/
33 #ifdef __cplusplus
34 	extern "C"
35 	{
36 #endif
37 		#if 0
38 		extern OurBool			DaveDebugOn;
39 		extern FDIEXTENSIONTAG	FDIET_Dummy;
40 		extern IFEXTENSIONTAG	IFET_Dummy;
41 		extern FDIQUAD			FDIQuad_WholeScreen;
42 		extern FDIPOS			FDIPos_Origin;
43 		extern FDIPOS			FDIPos_ScreenCentre;
44 		extern IFOBJECTLOCATION IFObjLoc_Origin;
45 		extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
46 		extern IFCOLOUR			IFColour_Dummy;
47  		extern IFVECTOR			IFVec_Zero;
48 		#endif
49 #ifdef __cplusplus
50 	};
51 #endif
52 
53 
54 
55 /* Exported globals ************************************************/
56 
57 /* Internal type definitions ***************************************/
58 
59 /* Internal function prototypes ************************************/
60 
61 /* Internal globals ************************************************/
62 
63 /* Exported function definitions ***********************************/
64 #if UseGadgets
65 // class AlienHUDGadget : public HUDGadget
66 // public:
Render(const struct r2pos & R2Pos,const struct r2rect & R2Rect_Clip,int FixP_Alpha)67 void AlienHUDGadget :: Render
68 (
69 	const struct r2pos& R2Pos,
70 	const struct r2rect& R2Rect_Clip,
71 	int FixP_Alpha
72 )
73 {
74 	#if 0
75 	textprint
76 	(
77 		"AlienHUDGadget :: Render at (%i,%i) clipped (%i,%i,%i,%i) alpha=%i\n",
78 		R2Pos . x,
79 		R2Pos . y,
80 		R2Rect_Clip . x0,
81 		R2Rect_Clip . y0,
82 		R2Rect_Clip . x1,
83 		R2Rect_Clip . y1,
84 		FixP_Alpha
85 	);
86 	#endif
87 
88 	pTextReportGadg -> UpdateLineTimes();
89 
90 	struct r2pos R2Pos_TextReport = pTextReportGadg -> GetPos_Rel
91 	(
92 		R2Rect_Clip
93 	);
94 
95 	GLOBALASSERT( pTextReportGadg );
96 	{
97 		pTextReportGadg -> Render
98 		(
99 			R2Pos_TextReport,
100 			R2Rect_Clip,
101 			FixP_Alpha
102 		);
103 	}
104 
105 	// Render the text entry line iff input focus is set to text entry:
106 	GLOBALASSERT( pTextEntryGadg );
107 	if
108 	(
109 		IOFOCUS_AcceptTyping()
110 	)
111 	{
112 		// Force the text report gadget onto the screen
113 	   	pTextReportGadg	-> ForceOnScreen();
114 
115 		// Render the text entry gadget:
116 		pTextEntryGadg -> Render
117 		(
118 			r2pos
119 			(
120 				R2Pos_TextReport . x,
121 				R2Pos_TextReport . y +  pTextReportGadg -> GetSize
122 				(
123 					R2Rect_Clip
124 				) . h
125 			),
126 			R2Rect_Clip,
127 			FixP_Alpha
128 		);
129 	}
130 	else
131 	{
132 		// Tell the text entry gadget it's not being rendered
133 		// (so it can fade out internally; however nothing will appear on-screen)
134 		pTextEntryGadg -> DontRender();
135 	}
136 
137 }
138 
AlienHUDGadget()139 AlienHUDGadget :: AlienHUDGadget
140 (
141 ) : HUDGadget
142 	(
143 		#if debug
144 		"AlienHUDGadget"
145 		#endif
146 	)
147 {
148 	pTextReportGadg = new TextReportGadget();
149 
150 	pTextEntryGadg = new TextEntryGadget();
151 
152 }
153 
154 
~AlienHUDGadget()155 AlienHUDGadget :: ~AlienHUDGadget()
156 {
157 	delete pTextEntryGadg;
158 	delete pTextReportGadg;
159 }
160 
AddTextReport(SCString * pSCString_ToAdd)161 void AlienHUDGadget :: AddTextReport
162 (
163 	SCString* pSCString_ToAdd
164 		// ultimately turn into an MCString
165 )
166 {
167 	/* PRECONDITION */
168 	{
169 		GLOBALASSERT( pSCString_ToAdd );
170 
171 		GLOBALASSERT( pTextReportGadg );
172 	}
173 
174 	/* CODE */
175 	{
176 		pTextReportGadg -> AddTextReport
177 		(
178 			pSCString_ToAdd
179 		);
180 	}
181 }
ClearTheTextReportQueue(void)182 void AlienHUDGadget :: ClearTheTextReportQueue(void)
183 {
184 	/* PRECONDITION */
185 	{
186 		GLOBALASSERT( pTextReportGadg );
187 	}
188 
189 	/* CODE */
190 	{
191 		pTextReportGadg -> ClearQueue();
192 	}
193 }
194 
195 #if EnableStatusPanels
RequestStatusPanel(enum StatusPanelIndex I_StatusPanel)196 void AlienHUDGadget :: RequestStatusPanel
197 (
198 	enum StatusPanelIndex I_StatusPanel
199 )
200 {
201 	/* PRECONDITION */
202 	{
203 		GLOBALASSERT( I_StatusPanel < NUM_STATUS_PANELS );
204 	}
205 
206 	/* CODE */
207 	{
208 		// empty for the moment
209 	}
210 }
211 
NoRequestedPanel(void)212 void AlienHUDGadget :: NoRequestedPanel(void)
213 {
214 	// empty for the moment
215 }
216 #endif // EnableStatusPanels
217 
CharTyped(char Ch)218 void AlienHUDGadget :: CharTyped
219 (
220 	char Ch
221 		// note that this _is _ a char
222 )
223 {
224 	GLOBALASSERT( pTextEntryGadg );
225 
226 	pTextEntryGadg -> CharTyped
227 	(
228 		Ch
229 	);
230 }
231 
Key_Backspace(void)232 void AlienHUDGadget :: Key_Backspace(void)
233 {
234 	GLOBALASSERT( pTextEntryGadg );
235 	pTextEntryGadg -> Key_Backspace();
236 }
Key_End(void)237 void AlienHUDGadget :: Key_End(void)
238 {
239 	GLOBALASSERT( pTextEntryGadg );
240 	pTextEntryGadg -> Key_End();
241 }
Key_Home(void)242 void AlienHUDGadget :: Key_Home(void)
243 {
244 	GLOBALASSERT( pTextEntryGadg );
245 	pTextEntryGadg -> Key_Home();
246 }
Key_Left(void)247 void AlienHUDGadget :: Key_Left(void)
248 {
249 	GLOBALASSERT( pTextEntryGadg );
250 	pTextEntryGadg -> Key_Left();
251 }
Key_Up(void)252 void AlienHUDGadget :: Key_Up(void)
253 {
254 	GLOBALASSERT( pTextEntryGadg );
255 	pTextEntryGadg -> Key_Up();
256 }
Key_Right(void)257 void AlienHUDGadget :: Key_Right(void)
258 {
259 	GLOBALASSERT( pTextEntryGadg );
260 	pTextEntryGadg -> Key_Right();
261 }
Key_Down(void)262 void AlienHUDGadget :: Key_Down(void)
263 {
264 	GLOBALASSERT( pTextEntryGadg );
265 	pTextEntryGadg -> Key_Down();
266 }
Key_Delete(void)267 void AlienHUDGadget :: Key_Delete(void)
268 {
269 	GLOBALASSERT( pTextEntryGadg );
270 	pTextEntryGadg -> Key_Delete();
271 }
Key_Tab(void)272 void AlienHUDGadget :: Key_Tab(void)
273 {
274 	GLOBALASSERT( pTextEntryGadg );
275 	pTextEntryGadg -> Key_Tab();
276 }
277 
Jitter(int FixP_Magnitude)278 void AlienHUDGadget :: Jitter(int FixP_Magnitude)
279 {
280 	// empty for now
281 }
282 
SetString(const char * text)283 void AlienHUDGadget :: SetString(const char* text)
284 {
285 	SCString* string = new SCString(text);
286 	pTextEntryGadg -> SetString(*string);
287 	string->R_Release();
288 }
289 
290 
291 extern "C"
292 {
BringDownConsoleWithSayTypedIn()293 void BringDownConsoleWithSayTypedIn()
294 {
295 	//bring down console if it isn't already down
296 	if(!IOFOCUS_AcceptTyping()) IOFOCUS_Toggle();
297 
298 	//put "SAY " in the console
299 	((AlienHUDGadget*)HUDGadget :: GetHUD())->SetString("SAY ");
300 }
301 
BringDownConsoleWithSaySpeciesTypedIn()302 void BringDownConsoleWithSaySpeciesTypedIn()
303 {
304 	//bring down console if it isn't already down
305 	if(!IOFOCUS_AcceptTyping()) IOFOCUS_Toggle();
306 
307 	//put "SAY_SPECIES " in the console
308 	((AlienHUDGadget*)HUDGadget :: GetHUD())->SetString("SAY_SPECIES ");
309 }
310 };
311 
312 // private:
313 #endif // UseGadgets
314 
315 /* Internal function definitions ***********************************/
316