diff options
| author | Mosder <xmosder12@gmail.com> | 2026-07-20 17:58:02 +0200 |
|---|---|---|
| committer | Mosder <xmosder12@gmail.com> | 2026-07-20 17:58:02 +0200 |
| commit | f73349115edbc75021885eefd33ee33ee504d9a7 (patch) | |
| tree | 5d2d79af731bcbc85d07e9d6dd69f6c836c25a5b /analyzer/render.c | |
| parent | c182f2f4f850589c23b2241e11dab143e1003ff2 (diff) | |
feat: added drif parsing and coloring of items depending on type
Diffstat (limited to 'analyzer/render.c')
| -rw-r--r-- | analyzer/render.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/analyzer/render.c b/analyzer/render.c index 402fcb5..28d1673 100644 --- a/analyzer/render.c +++ b/analyzer/render.c @@ -75,6 +75,24 @@ void print_column_names() { printf("\n"); } +int item_type_to_color(ItemType type) { + switch (type) { + case NORMAL: + return COLOR_WHITE; + case DRIF: + return COLOR_YELLOW; + case SYNG: + return COLOR_RED; + case SET: + return COLOR_GREEN; + case RARE: + return COLOR_AQUA; + case EPIC: + return COLOR_PURPLE; + } + return COLOR_WHITE; +} + void print_player_rewards(FriendlyResults results) { char buffers[TABLE_COLUMN_COUNT][TABLE_LINE_WIDTH]; size_t widths[TABLE_COLUMN_COUNT] = TABLE_COLUMN_WIDTHS; @@ -116,12 +134,13 @@ void print_player_rewards(FriendlyResults results) { size_t line_len = 0; for (size_t i = 0; i < results.num_items; i++) { char *sep = i < results.num_items - 1 ? ", " : ""; - size_t item_len = utf8_strlen(results.items[i]) + strlen(sep); + size_t item_len = utf8_strlen(results.items[i].data) + strlen(sep); if (line_len + item_len > TABLE_ITEMS_WIDTH) { printf("%*s" TABLE_LINE_END "\n" TABLE_LINE_START, (int)(TABLE_ITEMS_WIDTH - line_len), ""); line_len = 0; } - printf("%s%s", results.items[i], sep); + print_color(results.items[i].data, item_type_to_color(results.items[i].type)); + printf("%s", sep); line_len += item_len; } printf("%*s" TABLE_LINE_END "\n", (int)(TABLE_ITEMS_WIDTH - line_len), ""); |
