MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RenderTextFade

Function RenderTextFade

Descent3/TelcomEffectsRender.cpp:292–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290 tce->age += frametime;
291}
292void RenderTextFade(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render) {
293 if (!ok_to_render)
294 return;
295 ASSERT(tce->type == EFX_TEXT_FADE);
296 ASSERT(tce->text_buffer);
297 // See if we have any events waiting
298 tTCEvent evt;
299 while (PopEvent(tce, &evt)) {
300 switch (evt.id) {
301 case TEVT_SCROLLDOWN:
302 if (tce->textinfo.scroll_d) {
303 // mprintf(0,"Down Baby Down!\n");
304 tce->textinfo.line_index++;
305 }
306 break;
307 case TEVT_SCROLLUP:
308 if (tce->textinfo.line_index > 0) {
309 // mprintf(0,"Up Baby Up!\n");
310 tce->textinfo.line_index--;
311 }
312 break;
313 case TEVT_GAINFOCUS: {
314 // mprintf(0,"Text %d Gain Focus\n",tce-TCEffects);
315 } break;
316 case TEVT_LOSTFOCUS: {
317 // mprintf(0,"Text %d Lost Focus\n",tce-TCEffects);
318 } break;
319 }
320 }
321
322 if (tce->speed == 0)
323 tce->speed = 0.0001f;
324 float amount = tce->age * (255.0 / tce->speed);
325 uint8_t alpha;
326 if (tce->flags == TC_TEXTF_IN) {
327 // fade in, but not fade out
328 tce->alpha += amount;
329 if (tce->alpha > 255.0f) {
330 tce->alpha = 255.0f;
331 }
332 alpha = tce->alpha;
333 } else if (tce->flags == TC_TEXTF_OUT) {
334 // fade out, but not fade in
335 tce->alpha -= amount;
336 if (tce->alpha < 0.0f) {
337 tce->alpha = 0.0f;
338 }
339 alpha = tce->alpha;
340 } else {
341 // fade in, then fade out (if alpha is negative, then we are fading out)
342 if (tce->alpha < 0.0f) {
343 tce->alpha += amount;
344 alpha = (-tce->alpha);
345 if (tce->alpha > 0.0f) {
346 // we're done fading out
347 tce->alpha = 1234.0f;
348 alpha = 0;
349 }

Callers 1

RenderEffectFunction · 0.85

Calls 9

PopEventFunction · 0.85
grtext_GetAlphaFunction · 0.85
grtext_SetFontFunction · 0.85
grtext_SetColorFunction · 0.85
grtext_SetAlphaFunction · 0.85
grfont_GetHeightFunction · 0.85
textaux_CopyTextLineFunction · 0.85
grtext_PrintfFunction · 0.85

Tested by

no test coverage detected