Debian Codegraph @

Descent3/TelComGoals.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/TelComGoals.cpp $
21 * $Revision: 17 $
22 * $Date: 4/20/99 1:45a $
23 * $Author: Matt $
24 *
25 * TelCom Goal Status screen
26 *
27 * $Log: /DescentIII/main/TelComGoals.cpp $
28 *
29 * 17 4/20/99 1:45a Matt
30 * Fixed a dereferencing bug that was causing this screen to use totally
31 * different fonts than the code intended. It now uses the two briefing
32 * fonts.
33 *
34 * 16 4/17/99 6:15p Samir
35 * replaced gr.h with grdefs.h and fixed resulting compile bugs.
36 *
37 * 15 4/14/99 3:57a Jeff
38 * fixed case mismatch in #includes
39 *
40 * 14 4/05/99 3:28p Jeff
41 * failed mission added to telcom goal screen
42 *
43 * 13 4/02/99 9:24p Jeff
44 * fixed tooltip detection
45 *
46 * 12 3/31/99 5:34p Jeff
47 * fixed 0 byte malloc
48 *
49 * 11 3/27/99 2:59p Jeff
50 * handle multiple line goals...tooltips don't go off screen now
51 *
52 * 10 3/24/99 3:01p Jeff
53 * fixed 0 byte malloc
54 *
55 * 9 2/27/99 2:48p Jeff
56 * adjust to bottom right corner of mouse pointer (tool tips)
57 *
58 * 7 2/26/99 5:01p Jeff
59 * added background screen and some new artwork
60 *
61 * 6 2/26/99 12:07a Jeff
62 * fixed up tooltip stuff
63 *
64 * 5 2/24/99 9:39p Jeff
65 * updated
66 *
67 * 4 2/21/99 9:06p Jeff
68 * fixed bug where nothing would display on the screen if there were
69 * goals, but none are enabled or viewable by telcom
70 *
71 * 3 2/20/99 9:22p Jeff
72 * finished telcom level goals screen. Made it so if you go into the
73 * telcom from the game it goes to main menu instead of briefings.
74 *
75 * 2 2/20/99 4:37p Jeff
76 * added telcomgoals
77 *
78 * 1 2/20/99 4:31p Jeff
79 *
80 * $NoKeywords: $
81 */
82
83 #include "TelComGoals.h"
84 #include <stdlib.h>
85 #include <string.h>
86 #include <ctype.h>
87
88 #include "cfile.h"
89 #include "pserror.h"
90 #include "ddio.h"
91 #include "bitmap.h"
92
93 #include "TelCom.h"
94 #include "renderer.h"
95 #include "game.h"
96 #include "mem.h"
97 #include "stringtable.h"
98 #include "gametexture.h"
99 #include "textaux.h"
100 #include "TelComEfxStructs.h"
101 #include "TelComEffects.h"
102 #include "levelgoal.h"
103 #include "textaux.h"
104 #include "Mission.h"
105 #include "Macros.h"
106 #include "hlsoundlib.h"
107
108 #include <algorithm>
109
110 #define TITLE_X 30 + TGminx
111 #define VALUE_X 400 + TGminx
112 int TGminx, TGmaxx, TGminy, TGmaxy;
113 #define SM_FONT BRIEFING_FONT
114 #define BG_FONT BIG_BRIEFING_FONT
115
116 #define UI_RIGHT_ARROW_CHAR 26
117
118 struct tGoalLineInfo {
119 bool primary;
120 bool is_objective;
121 bool is_active;
122 int goal_index;
123 int lx, rx, ty, by; // bounding box
124 };
125
126 static tGoalLineInfo *TG_Lines;
127 static int TG_NumLines;
128 static int *TG_SortedList;
129 static int TG_CurrObjectiveArrow;
130
131 struct tToolTipData {
132 int w, h;
133 };
134
135 static tToolTipData TG_TT_dest;
136 static tToolTipData TG_TT_curr;
137 static chunked_bitmap TG_Tooltipbitmap;
138 static int TG_MouseOffset_x = -1, TG_MouseOffset_y = -1;
139 // returns true if left < right
140 bool TG_compare_slots(int left, int right) {
141 int left_index, right_index;
142 int left_priority, right_priority;
143 char left_list, right_list;
144
145 left_index = TG_Lines[left].goal_index;
146 right_index = TG_Lines[right].goal_index;
147
148 // Primaries have precedence over secondaries
149 if (TG_Lines[left].primary && !TG_Lines[right].primary)
150 return false; // right is a secondary, left is a primary
151 if (!TG_Lines[left].primary && TG_Lines[right].primary)
152 return true; // right is a primary, left is secondary
153
154 Level_goals.GoalPriority(left_index, LO_GET_SPECIFIED, &left_priority);
155 Level_goals.GoalPriority(right_index, LO_GET_SPECIFIED, &right_priority);
156 Level_goals.GoalGoalList(left_index, LO_GET_SPECIFIED, &left_list);
157 Level_goals.GoalGoalList(right_index, LO_GET_SPECIFIED, &right_list);
158
159 // check goal list...the lower has priority
160 if (left_list < right_list)
161 return false;
162 if (right_list < left_list)
163 return true;
164
165 // the have same goal list, if it's an object, then that has priority, else sort by
166 // goal priority
167 if (TG_Lines[left].is_objective)
168 return false;
169 if (TG_Lines[right].is_objective)
170 return true;
171
172 // they are both goals, and not objectives, check based on priority
173 return (left_priority > right_priority);
174 }
175
176 void TCGoalsBuildLineData(void) {
177 int number_of_goals = Level_goals.GetNumGoals();
178 int index, goal_status, count = 0, i;
179
180 // see how many of these are something we want
181 for (index = 0; index < number_of_goals; index++) {
182 Level_goals.GoalStatus(index, LO_GET_SPECIFIED, &goal_status);
183
184 if (goal_status & LGF_ENABLED)
185 count++;
186 }
187
188 //'count' goals are what we have to display
189 // allocate memory needed and start filling in
190 if (count) {
191 TG_Lines = (tGoalLineInfo *)mem_malloc(sizeof(tGoalLineInfo) * count);
192 TG_NumLines = count;
193 TG_SortedList = (int *)mem_malloc(sizeof(int) * count);
194 if (!TG_SortedList || !TG_Lines) {
195 // out of memory
196 Telcom_system.current_status = TS_OFF;
197 return;
198 }
199
200 // fill in data
201 i = 0;
202 for (index = 0; index < number_of_goals; index++) {
203 Level_goals.GoalStatus(index, LO_GET_SPECIFIED, &goal_status);
204
205 if (goal_status & LGF_ENABLED) {
206 TG_Lines[i].goal_index = index;
207 TG_Lines[i].is_active = false;
208
209 // Is this a primary or secondary goal?
210 if (goal_status & LGF_SECONDARY_GOAL) {
211 TG_Lines[i].primary = false;
212 } else {
213 TG_Lines[i].primary = true;
214 }
215
216 if (goal_status & LGF_TELCOM_LISTS) {
217 TG_Lines[i].is_objective = true;
218 } else {
219 TG_Lines[i].is_objective = false;
220 }
221
222 // initialize x/y values to -1, that way they will be filled in when drawn first
223 // frame.
224 TG_Lines[i].lx = TG_Lines[i].rx = TG_Lines[i].ty = TG_Lines[i].by = -1;
225
226 i++;
227 }
228 }
229
230 // Determine which goals are active
231 int num_active, act_g_index;
232 num_active = Level_goals.GetNumActivePrimaryGoals();
233 for (i = 0; i < num_active; i++) {
234 act_g_index = Level_goals.GetActivePrimaryGoal(i);
235
236 // search for that index
237 for (index = 0; index < TG_NumLines; index++) {
238 if (act_g_index == TG_Lines[index].goal_index) {
239 TG_Lines[index].is_active = true;
240 break;
241 }
242 }
243 }
244 num_active = Level_goals.GetNumActiveSecondaryGoals();
245 for (i = 0; i < num_active; i++) {
246 act_g_index = Level_goals.GetActiveSecondaryGoal(i);
247
248 // search for that index
249 for (index = 0; index < TG_NumLines; index++) {
250 if (act_g_index == TG_Lines[index].goal_index) {
251 TG_Lines[index].is_active = true;
252 break;
253 }
254 }
255 }
256
257 // All data has been filled in, now sort it all
258 int t, j;
259 for (i = 0; i < TG_NumLines; i++) {
260 TG_SortedList[i] = i;
261 }
262
263 for (i = 1; i <= TG_NumLines - 1; i++) {
264 t = TG_SortedList[i];
265
266 // Shift elements down until
267 // insertion point found.
268 for (j = i - 1; j >= 0 && TG_compare_slots(TG_SortedList[j], t); j--) {
269 TG_SortedList[j + 1] = TG_SortedList[j];
270 }
271 // insert
272 TG_SortedList[j + 1] = t;
273 }
274 } else {
275 TG_Lines = NULL;
276 TG_NumLines = 0;
277 TG_SortedList = NULL;
278 }
279 }
280
281 int FindHighlightedItem(int x, int y) {
282 for (int i = 0; i < TG_NumLines; i++) {
283 if (x >= TG_Lines[i].lx && x <= TG_Lines[i].rx && y >= TG_Lines[i].ty && y <= TG_Lines[i].by) {
284 return TG_Lines[i].goal_index;
285 }
286 }
287 return -1;
288 }
289
290 #define ACTIVE_ALPHA_PER_SEC 255.0f
291 #define ACTIVE_ALPHA_MIN 100.0f
292 #define ACTIVE_ALPHA_MAX 255.0f
293
294 #define COLOR_OBJECTIVE_HEADING GR_WHITE
295 #define COLOR_OBJECTIVE_NAME GR_RGB(255, 255, 40)
296 #define COLOR_GOAL_NAME GR_WHITE
297 #define COLOR_COMPLETED GR_RGB(40, 255, 40)
298 #define COLOR_INCOMPLETE GR_RGB(255, 40, 40)
299 #define COLOR_FAILED GR_RGB(255, 255, 40)
300
301 void TCGoalsRenderCallback(void) {
302 static bool active_alpha_in = false;
303 static float active_alpha = ACTIVE_ALPHA_MAX;
304
305 // recalculate alpha
306 float alpha_change = last_frametime * ACTIVE_ALPHA_PER_SEC;
307 float alpha_amount;
308 while (alpha_change > 0) {
309 if (active_alpha_in) {
310 alpha_amount = std::min(ACTIVE_ALPHA_MAX - active_alpha, alpha_change);
311 active_alpha += alpha_amount;
312
313 if (active_alpha > (ACTIVE_ALPHA_MAX - 1.0f))
314 active_alpha_in = false;
315 } else {
316 alpha_amount = std::min(alpha_change, active_alpha - ACTIVE_ALPHA_MIN);
317 active_alpha -= alpha_amount;
318
319 if (active_alpha < (ACTIVE_ALPHA_MIN + 1.0f))
320 active_alpha_in = true;
321 }
322 alpha_change -= alpha_amount;
323 }
324
325 int old_font = grtext_GetFont();
326
327 grtext_SetAlpha(255);
328 rend_SetOverlayType(OT_NONE);
329 rend_SetLighting(LS_NONE);
330 rend_SetColorModel(CM_MONO);
331 rend_SetZBufferState(0);
332 rend_SetAlphaType(AT_CONSTANT + AT_TEXTURE);
333 rend_SetAlphaValue(255);
334 rend_SetZBufferState(0);
335
336 int y = TGminy;
337
338 int obj_x, obj_max_width, goal_x, goal_max_width, status_x, status_max_width;
339 obj_x = TGminx + 25;
340 obj_max_width = 315;
341 status_x = obj_x + obj_max_width;
342 status_max_width = TGmaxx - status_x;
343 goal_x = obj_x + 20;
344 goal_max_width = status_x - goal_x;
345 /*
346 int goal_name_x,goal_status_x,goal_name_max_width,goal_status_max_width;
347 goal_name_x = TGminx + 20;
348 goal_name_max_width = 320;
349 goal_status_x = goal_name_x + goal_name_max_width;
350 goal_status_max_width = TGmaxx-goal_status_x;
351 */
352
353 int period_length;
354 period_length = grfont_GetCharWidth(SM_FONT, '.') + Grtext_spacing;
355
356 //@@@ASSERT(goal_status_max_width>0);
357 ASSERT(status_max_width > 0);
358
359 int big_height = grfont_GetHeight(BG_FONT);
360 int small_height = grfont_GetHeight(SM_FONT);
361
362 grtext_SetAlpha(255);
363 grtext_SetColor(GR_WHITE);
364
365 // render here
366 // grtext_SetFont(BRIEFING_FONT);
367 //@@@int number_of_goals = Level_goals.GetNumGoals();
368 int goal_index;
369 int goal_status, i, width, x;
370 bool first_primary, first_secondary;
371 first_primary = first_secondary = true;
372
373 #define GOAL_NAME_BUFFER_SIZE 256
374 #define BUFFER_SIZE GOAL_NAME_BUFFER_SIZE * 4
375 char buffer[BUFFER_SIZE];
376
377 // Print out Heading
378 char level_string[32];
379 snprintf(level_string, sizeof(level_string), TXT_LEVELSTRING, Current_mission.cur_level);
380 grtext_SetFont(BG_FONT);
381 grtext_SetColor(GR_RGB(255, 255, 255));
382 int level_name_x = TGmaxx - grtext_GetTextLineWidth(level_string) - 15;
383 grtext_Printf(level_name_x, y, level_string);
384 if (!Level_info.name[0]) {
385 grtext_Printf(TGminx + 15, y, TXT_UNNAMED);
386 } else {
387 grtext_Printf(TGminx + 15, y, Level_info.name);
388 }
389 y += (big_height + 15);
390
391 for (i = 0; i < TG_NumLines; i++) {
392 goal_index = TG_SortedList[i];
393 grtext_SetAlpha(255);
394
395 // Print out heading
396 if (TG_Lines[goal_index].primary) {
397 if (first_primary) {
398 // this is the first primary goal, print out heading
399 grtext_SetFont(BG_FONT);
400 grtext_SetColor(COLOR_OBJECTIVE_HEADING);
401 grtext_Printf(TGminx + 15, y, TXT_PRIMGOALS);
402 y += (big_height + 1);
403 first_primary = false;
404 }
405 } else {
406 if (first_secondary) {
407 if (!first_primary)
408 y += 10;
409
410 // this is the first secondary goal, print out heading
411 grtext_SetFont(BG_FONT);
412 grtext_SetColor(COLOR_OBJECTIVE_HEADING);
413 grtext_Printf(TGminx + 15, y, TXT_SECONDARYGOALS);
414 y += (big_height + 1);
415 first_secondary = false;
416 }
417 }
418
419 grtext_SetFont(SM_FONT);
420
421 // determine x position
422 if (TG_Lines[goal_index].is_objective) {
423 x = obj_x;
424 width = obj_max_width;
425 } else {
426 x = goal_x;
427 width = goal_max_width;
428 }
429
430 // get the name of our goal
431 Level_goals.GoalGetName(TG_Lines[goal_index].goal_index, buffer, GOAL_NAME_BUFFER_SIZE);
432
433 // clip goal_name to our max width
434 //@@textaux_ClipString(width,buffer,1.0,UI_RIGHT_ARROW_CHAR);
435 if (TG_Lines[goal_index].is_objective) {
436 grtext_SetColor(COLOR_OBJECTIVE_NAME);
437 } else {
438 grtext_SetColor(COLOR_GOAL_NAME);
439 }
440 //@@grtext_Printf(x,y,buffer);
441 char wrap_buffer[BUFFER_SIZE];
442 textaux_WordWrap(buffer, wrap_buffer, width, SM_FONT);
443 const char *nextline;
444 char linebuffer[256];
445 int wrap_y = y;
446
447 nextline = textaux_CopyTextLine(wrap_buffer, linebuffer);
448 while ((nextline) && ((y + small_height + 2) < TGmaxy)) {
449 grtext_Printf(x, y, linebuffer);
450 y += (small_height + 2);
451 nextline = textaux_CopyTextLine(nextline, linebuffer);
452 }
453 grtext_Printf(x, y, linebuffer);
454
455 // see if we need to fill in x/y coords
456 if (TG_Lines[goal_index].lx == -1) {
457 TG_Lines[goal_index].lx = x;
458 TG_Lines[goal_index].rx = status_x + status_max_width;
459 TG_Lines[goal_index].ty = wrap_y;
460 TG_Lines[goal_index].by = y + small_height;
461 }
462
463 // fill with '.' until the start of the next column
464 int end_x = x + grtext_GetTextLineWidth(linebuffer) + Grtext_spacing;
465 // move end_x to mod period_length
466 while ((end_x % period_length) != 0) {
467 end_x++;
468 }
469
470 int length_to_fill = ((status_x - (end_x + 10)) / period_length) * period_length;
471 int index = 0;
472 while (length_to_fill > period_length && index < (BUFFER_SIZE - 1)) {
473 buffer[index] = '.';
474 index++;
475 length_to_fill -= period_length;
476 }
477 buffer[index] = '\0';
478 grtext_SetColor(GR_WHITE);
479 grtext_Printf(end_x, y, buffer);
480
481 if (TG_Lines[goal_index].is_active) {
482
483 if (TG_CurrObjectiveArrow > BAD_BITMAP_HANDLE) {
484 rend_SetAlphaType(AT_CONSTANT_TEXTURE);
485 rend_SetAlphaValue(active_alpha);
486 rend_SetLighting(LS_NONE);
487 rend_SetColorModel(CM_MONO);
488 rend_SetOverlayType(OT_NONE);
489 rend_SetWrapType(WT_CLAMP);
490 rend_SetFiltering(0);
491
492 rend_DrawScaledBitmap(x - small_height - 2, wrap_y, x - 2, wrap_y + small_height, TG_CurrObjectiveArrow, 0, 0,
493 1, 1);
494
495 rend_SetAlphaValue(255.0);
496 rend_SetFiltering(1);
497 } else {
498 uint8_t alpha_to_use;
499 alpha_to_use = (uint8_t)active_alpha;
500 grtext_SetAlpha(alpha_to_use);
501 }
502 }
503
504 // get the status of the goal
505 Level_goals.GoalStatus(TG_Lines[goal_index].goal_index, LO_GET_SPECIFIED, &goal_status);
506 if (goal_status & LGF_COMPLETED) {
507 // completed goal
508 grtext_SetColor(COLOR_COMPLETED);
509 grtext_Printf(status_x, y, TXT_COMPLETED);
510 } else if (goal_status & LGF_FAILED) {
511 // failed goal
512 grtext_SetColor(COLOR_FAILED);
513 grtext_Printf(status_x, y, TXT_FAILED);
514 } else {
515 // not completed
516 grtext_SetColor(COLOR_INCOMPLETE);
517 grtext_Printf(status_x, y, TXT_NOTCOMPLETEDYET);
518 }
519
520 y += (small_height + 2);
521 }
522
523 if ((TG_NumLines <= 0) || (first_primary && first_secondary)) {
524 // no goals for this level
525 grtext_SetFont(BG_FONT);
526
527 y = TGminy + ((TGmaxy - TGminy) / 2) - (grfont_GetHeight(BG_FONT) / 2);
528 grtext_CenteredPrintf(0, y, TXT_NOGOALSAVAIL);
529 }
530
531 grtext_Flush();
532
533 // Display tooltip box
534 int mouse_x, mouse_y;
535 ddio_MouseGetState(&mouse_x, &mouse_y, NULL, NULL);
536 int index = FindHighlightedItem(mouse_x, mouse_y);
537 char desc_buffer[1024], s_desc_buffer[1024], *ptr;
538 ptr = desc_buffer;
539 *ptr = '\0';
540
541 if (index != -1) {
542 #define MIN_TOOLTIP_WIDTH 100
543 #define MAX_TOOLTIP_WIDTH 300
544 #define MIN_TOOLTIP_HEIGHT 40
545 // we're over an item
546
547 Level_goals.GoalGetDesc(index, desc_buffer, 1024);
548 while (*ptr && (*ptr == ' ' || *ptr == '\t'))
549 ptr++;
550 if (strlen(ptr) > 0) {
551 int width = grtext_GetTextLineWidth(ptr);
552
553 if (width > MAX_TOOLTIP_WIDTH)
554 width = MAX_TOOLTIP_WIDTH;
555 textaux_WordWrap(ptr, s_desc_buffer, width - 45, SM_FONT);
556
557 int num_lines = 0;
558 char *dptr = s_desc_buffer;
559 while (*dptr) {
560 if (*dptr == '\n')
561 num_lines++;
562 dptr++;
563 }
564 num_lines++;
565 ptr = s_desc_buffer;
566
567 // figure out true width
568 const char *next_line = textaux_CopyTextLine(ptr, desc_buffer);
569 width = grtext_GetTextLineWidth(desc_buffer);
570 int t;
571 while (next_line) {
572 next_line = textaux_CopyTextLine(next_line, desc_buffer);
573 t = grtext_GetTextLineWidth(desc_buffer);
574 if (t > width)
575 width = t;
576 }
577
578 TG_TT_dest.w = width + 20;
579 TG_TT_dest.h = 10 + (num_lines * small_height);
580 } else {
581 memset(&TG_TT_dest, 0, sizeof(tToolTipData)); // start shrinking
582 }
583 } else {
584 memset(&TG_TT_dest, 0, sizeof(tToolTipData)); // start shrinking
585 }
586
587 #define TOOLTIP_SPEED 400.0f
588
589 // adjust box
590 if (TG_TT_curr.w > TG_TT_dest.w) {
591 // shrinking
592 TG_TT_curr.w -= std::min(TG_TT_curr.w - TG_TT_dest.w, (int)(TOOLTIP_SPEED * last_frametime));
593 } else {
594 // enlarging
595 TG_TT_curr.w += std::min(TG_TT_dest.w - TG_TT_curr.w, (int)(TOOLTIP_SPEED * last_frametime));
596 }
597
598 if (TG_TT_curr.h > TG_TT_dest.h) {
599 // shrinking
600 TG_TT_curr.h -= std::min(TG_TT_curr.h - TG_TT_dest.h, (int)(TOOLTIP_SPEED * last_frametime));
601 } else {
602 // enlarging
603 TG_TT_curr.h += std::min(TG_TT_dest.h - TG_TT_curr.h, (int)(TOOLTIP_SPEED * last_frametime));
604 }
605
606 // rend_SetAlphaType (AT_CONSTANT_TEXTURE);
607 // rend_SetAlphaValue (200.0);
608 rend_SetLighting(LS_NONE);
609 rend_SetColorModel(CM_MONO);
610 rend_SetOverlayType(OT_NONE);
611 rend_SetWrapType(WT_CLAMP);
612 rend_SetFiltering(0);
613
614 if (TG_MouseOffset_x == -1) {
615 // determine bottom-right x/y of mouse cursor
616 uint16_t *data = bm_data(TC_cursor, 0);
617 int width = bm_w(TC_cursor, 0);
618 int index = width * bm_h(TC_cursor, 0) - 1;
619 while (index > 0 && (!(data[index] & OPAQUE_FLAG)))
620 index--;
621
622 TG_MouseOffset_x = index % width;
623 TG_MouseOffset_y = index / width;
624 }
625
626 // Adjust X box if it is to far to the right
627 if (mouse_x + TG_TT_curr.w > Telcom_system.Monitor_coords[MONITOR_MAIN].right ||
628 mouse_x + TG_TT_dest.w > Telcom_system.Monitor_coords[MONITOR_MAIN].right) {
629 // we must adjust
630 mouse_x -= TG_TT_curr.w;
631 }
632
633 rend_DrawScaledChunkedBitmap(&TG_Tooltipbitmap, mouse_x + TG_MouseOffset_x, mouse_y + TG_MouseOffset_y, TG_TT_curr.w,
634 TG_TT_curr.h, 255);
635 rend_SetFiltering(1);
636
637 if (TG_TT_curr.w != 0 && TG_TT_curr.h != 0) {
638 // See if we need to draw any text
639 // only when curr==dest
640 if (TG_TT_curr.w == TG_TT_dest.w && TG_TT_curr.h == TG_TT_dest.h) {
641 // write text description
642 grtext_SetAlpha(255);
643 grtext_SetColor(GR_WHITE);
644 grtext_SetFont(SM_FONT);
645
646 const char *next_line;
647 int c_x, c_y;
648 c_x = mouse_x + TG_MouseOffset_x + 10;
649 c_y = mouse_y + TG_MouseOffset_y + 5;
650
651 next_line = textaux_CopyTextLine(ptr, desc_buffer);
652 while (next_line) {
653 grtext_Printf(c_x, c_y, desc_buffer);
654 next_line = textaux_CopyTextLine(next_line, desc_buffer);
655 c_y += small_height;
656 }
657 grtext_Printf(c_x, c_y, desc_buffer);
658 grtext_Flush();
659 }
660 }
661
662 grtext_SetFont(old_font);
663 rend_SetZBufferState(1);
664 }
665
666 // This is the function called by TelCom
667 // return true if TelCom should exit to TelCom Main Menu
668 // return false if you should exit out of TelCom completly
669 bool TelComGoalStatus(tTelComInfo *tcs) {
670 bool done = false;
671
672 TelcomStartScreen(0);
673
674 TCBKGDESC backg;
675 backg.color = BACKGROUND_COLOR;
676 backg.caps = TCBGD_COLOR;
677 backg.type = TC_BACK_STATIC;
678 CreateBackgroundEffect(&backg, MONITOR_MAIN, 0);
679 CreateBackgroundEffect(&backg, MONITOR_TOP, 0);
680
681 TCBMPDESC bmpdesc;
682 bmpdesc.type = TC_BMP_STATIC;
683 bmpdesc.flags = 0;
684 bmpdesc.caps = TCBD_XY;
685 bmpdesc.x = 0;
686 bmpdesc.y = 0;
687 strcpy(bmpdesc.filename, "TelcomGoalBkg.ogf");
688 CreateBitmapEffect(&bmpdesc, MONITOR_MAIN, 0);
689 /*
690 $$TABLE_GAMEFILE "TelcomGoalBkg.ogf"
691 */
692
693 TGminx = tcs->Monitor_coords[MONITOR_MAIN].left + 10;
694 TGminy = tcs->Monitor_coords[MONITOR_MAIN].top + 10;
695 TGmaxy = tcs->Monitor_coords[MONITOR_MAIN].bottom - 10;
696 TGmaxx = tcs->Monitor_coords[MONITOR_MAIN].right - 10;
697 TG_Lines = NULL;
698 TG_SortedList = NULL;
699 TG_NumLines = 0;
700 memset(&TG_TT_dest, 0, sizeof(tToolTipData));
701 memset(&TG_TT_curr, 0, sizeof(tToolTipData));
702
703 int bm_handle = bm_AllocLoadFileBitmap("TelcomToolTip.ogf", 0);
704 if (bm_handle <= BAD_BITMAP_HANDLE) {
705 bm_handle = bm_AllocBitmap(32, 32, 0);
706 if (bm_handle > BAD_BITMAP_HANDLE) {
707 uint16_t *data = bm_data(bm_handle, 0);
708 for (int i = 0; i < 1024; i++) {
709 data[i] = GR_RGB16(0, 0, 0) | OPAQUE_FLAG;
710 }
711 }
712 }
713
714 bm_CreateChunkedBitmap(bm_handle, &TG_Tooltipbitmap);
715
716 TCTEXTDESC textdesc;
717 textdesc.type = TC_TEXT_STATIC;
718 textdesc.font = BG_FONT;
719 textdesc.caps = TCTD_TEXTBOX | TCTD_COLOR | TCTD_FONT;
720 textdesc.textbox.left = 0;
721 textdesc.textbox.right = 380;
722 textdesc.textbox.top = 4;
723 textdesc.textbox.bottom = 50;
724 textdesc.color = GR_RGB(255, 255, 255);
725
726 CreateTextEffect(&textdesc, TXT_GOALSTATUSHEADING, MONITOR_TOP, 0);
727 TelcomEndScreen();
728 TelcomRenderSetScreen(0);
729
730 TelcomRenderSetCallback(TCGoalsRenderCallback);
731
732 TCGoalsBuildLineData();
733
734 TG_CurrObjectiveArrow = bm_AllocLoadFileBitmap("CurrObjectiveArrow.ogf", 0);
735
736 while (!done) {
737 Sound_system.BeginSoundFrame(Telcom_called_from_game);
738
739 if (tcs->state != TCS_POWERON || tcs->current_status != TS_GOALS) {
740 // we're done with the loop
741 done = true;
742 }
743
744 // Process all waiting events for the TelCom (we may only want to handle this once a frame!)
745 TelComHandleAllEvents(&Telcom_system);
746
747 TelcomRenderScreen();
748 Descent->defer();
749 if (KEY_STATE(KEY_ESC))
750 Telcom_system.state = TCS_POWEROFF;
751
752 Sound_system.EndSoundFrame();
753 }
754
755 DestroyAllScreens();
756 TelcomRenderSetScreen(DUMMY_SCREEN);
757 TelcomRenderSetCallback(NULL);
758
759 if (TG_Lines) {
760 mem_free(TG_Lines);
761 TG_Lines = NULL;
762 }
763 if (TG_SortedList) {
764 mem_free(TG_SortedList);
765 TG_SortedList = NULL;
766 }
767 TG_NumLines = 0;
768
769 if (TG_CurrObjectiveArrow > BAD_BITMAP_HANDLE)
770 bm_FreeBitmap(TG_CurrObjectiveArrow);
771
772 bm_DestroyChunkedBitmap(&TG_Tooltipbitmap);
773
774 return true;
775 }