| 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 Tracker HUD Component |
| 16 |
// |
| 17 |
|
| 18 |
#include "dsda/tracker.h" |
| 19 |
|
| 20 |
#include "base.h" |
| 21 |
|
| 22 |
#include "line_distance_tracker.h" |
| 23 |
#include "line_tracker.h" |
| 24 |
#include "mobj_tracker.h" |
| 25 |
#include "null.h" |
| 26 |
#include "player_tracker.h" |
| 27 |
#include "sector_tracker.h" |
| 28 |
|
| 29 |
#include "tracker.h" |
| 30 |
|
| 31 |
extern dsda_tracker_t dsda_tracker[TRACKER_LIMIT]; |
| 32 |
|
| 33 |
typedef struct { |
| 34 |
dsda_text_t component[TRACKER_LIMIT]; |
| 35 |
} local_component_t; |
| 36 |
|
| 37 |
static local_component_t* local; |
| 38 |
|
| 39 |
void dsda_InitTrackerHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) { |
| 40 |
int i; |
| 41 |
|
| 42 |
*data = Z_Calloc(1, sizeof(local_component_t)); |
| 43 |
local = *data; |
| 44 |
|
| 45 |
for (i = 0; i < TRACKER_LIMIT; ++i) |
| 46 |
dsda_InitTextHC(&local->component[i], x_offset, y_offset + i * 8, vpt); |
| 47 |
} |
| 48 |
|
| 49 |
void dsda_UpdateTrackerHC(void* data) { |
| 50 |
int i; |
| 51 |
|
| 52 |
local = data; |
| 53 |
|
| 54 |
for (i = 0; i < TRACKER_LIMIT; ++i) { |
| 55 |
switch (dsda_tracker[i].type) { |
| 56 |
case dsda_tracker_nothing: |
| 57 |
dsda_NullHC(local->component[i].msg, sizeof(local->component[i].msg)); |
| 58 |
break; |
| 59 |
case dsda_tracker_line: |
| 60 |
dsda_LineTrackerHC(local->component[i].msg, sizeof(local->component[i].msg), dsda_tracker[i].id); |
| 61 |
break; |
| 62 |
case dsda_tracker_line_distance: |
| 63 |
dsda_LineDistanceTrackerHC(local->component[i].msg, sizeof(local->component[i].msg), dsda_tracker[i].id); |
| 64 |
break; |
| 65 |
case dsda_tracker_sector: |
| 66 |
dsda_SectorTrackerHC(local->component[i].msg, sizeof(local->component[i].msg), dsda_tracker[i].id); |
| 67 |
break; |
| 68 |
case dsda_tracker_mobj: |
| 69 |
dsda_MobjTrackerHC(local->component[i].msg, sizeof(local->component[i].msg), dsda_tracker[i].id, dsda_tracker[i].mobj); |
| 70 |
break; |
| 71 |
case dsda_tracker_player: |
| 72 |
dsda_PlayerTrackerHC(local->component[i].msg, sizeof(local->component[i].msg)); |
| 73 |
break; |
| 74 |
} |
| 75 |
|
| 76 |
dsda_RefreshHudText(&local->component[i]); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
void dsda_DrawTrackerHC(void* data) { |
| 81 |
int i; |
| 82 |
|
| 83 |
local = data; |
| 84 |
|
| 85 |
for (i = 0; i < TRACKER_LIMIT; ++i) |
| 86 |
dsda_DrawBasicText(&local->component[i]); |
| 87 |
} |