| 1 |
// |
| 2 |
// Copyright(C) 2022 by Ryan Krafnick |
| 3 |
// |
| 4 |
// This program is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU General Public License |
| 6 |
// as published by the Free Software Foundation; either version 2 |
| 7 |
// of the License, or (at your option) any later version. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
// |
| 14 |
// DESCRIPTION: |
| 15 |
// DSDA Line Display HUD Component |
| 16 |
// |
| 17 |
|
| 18 |
#include "base.h" |
| 19 |
|
| 20 |
#include "line_display.h" |
| 21 |
|
| 22 |
typedef struct { |
| 23 |
dsda_text_t line_display[LINE_ACTIVATION_INDEX_MAX]; |
| 24 |
} local_component_t; |
| 25 |
|
| 26 |
static local_component_t* local; |
| 27 |
|
| 28 |
void dsda_InitLineDisplayHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) { |
| 29 |
int i; |
| 30 |
|
| 31 |
*data = Z_Calloc(1, sizeof(local_component_t)); |
| 32 |
local = *data; |
| 33 |
|
| 34 |
for (i = 0; i < LINE_ACTIVATION_INDEX_MAX; ++i) |
| 35 |
dsda_InitTextHC(&local->line_display[i], x_offset, y_offset + i * 8, vpt); |
| 36 |
} |
| 37 |
|
| 38 |
void dsda_UpdateLineDisplayHC(void* data) { |
| 39 |
int* line_ids; |
| 40 |
int i; |
| 41 |
|
| 42 |
local = data; |
| 43 |
|
| 44 |
line_ids = dsda_PlayerActivatedLines(); |
| 45 |
|
| 46 |
for (i = 0; line_ids[i] != -1; ++i) { |
| 47 |
snprintf(local->line_display[i].msg, sizeof(local->line_display[i].msg), "%s%d", |
| 48 |
dsda_TextColor(dsda_tc_exhud_line_activation), line_ids[i]); |
| 49 |
dsda_RefreshHudText(&local->line_display[i]); |
| 50 |
} |
| 51 |
|
| 52 |
if (line_ids[0] != -1 && i < LINE_ACTIVATION_INDEX_MAX) { |
| 53 |
local->line_display[i].msg[0] = '\0'; |
| 54 |
dsda_RefreshHudText(&local->line_display[i]); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
void dsda_DrawLineDisplayHC(void* data) { |
| 59 |
int i; |
| 60 |
|
| 61 |
local = data; |
| 62 |
|
| 63 |
for (i = 0; i < LINE_ACTIVATION_INDEX_MAX; ++i) { |
| 64 |
if (!local->line_display[i].msg[0]) |
| 65 |
break; |
| 66 |
|
| 67 |
dsda_DrawBasicText(&local->line_display[i]); |
| 68 |
} |
| 69 |
} |