| 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 Features |
| 16 |
// |
| 17 |
|
| 18 |
#include <string.h> |
| 19 |
|
| 20 |
#include "z_zone.h" |
| 21 |
|
| 22 |
#include "dsda/utility.h" |
| 23 |
|
| 24 |
#include "features.h" |
| 25 |
|
| 26 |
static byte used_features[FEATURE_SLOTS]; |
| 27 |
|
| 28 |
static const char* feature_names[FEATURE_SIZE] = { |
| 29 |
[uf_menu] = "Menu", |
| 30 |
[uf_exhud] = "Extended HUD", |
| 31 |
[uf_advhud] = "Advanced HUD", |
| 32 |
[uf_crosshair] = "Crosshair", |
| 33 |
[uf_quickstartcache] = "Quickstart Cache", |
| 34 |
[uf_100k] = "100K Tracker", |
| 35 |
[uf_console] = "Console", |
| 36 |
|
| 37 |
[uf_iddt] = "IDDT", |
| 38 |
[uf_automap] = "IDBEHOLD Map", |
| 39 |
[uf_liteamp] = "IDBEHOLD Light", |
| 40 |
[uf_build] = "Build Mode", |
| 41 |
[uf_buildzero] = "Build First Frame", |
| 42 |
[uf_bruteforce] = "Brute Force", |
| 43 |
[uf_tracker] = "TAS Tracker", |
| 44 |
[uf_keyframe] = "Key Frame", |
| 45 |
[uf_skip] = "Skip Forward", |
| 46 |
[uf_wipescreen] = "Skip Wipe Screen", |
| 47 |
[uf_speedup] = "Speed Up", |
| 48 |
[uf_slowdown] = "Slow Down", |
| 49 |
[uf_coordinates] = "Show Coordinates", |
| 50 |
[uf_mouselook] = "Mouse Look", |
| 51 |
[uf_weaponalignment] = "Weapon Alignment", |
| 52 |
[uf_commanddisplay] = "Command Display", |
| 53 |
[uf_crosshaircolor] = "Dynamic Crosshair Color", |
| 54 |
[uf_crosshairlock] = "Crosshair Lock", |
| 55 |
[uf_shadows] = "Shadows", |
| 56 |
[uf_painpalette] = "Disable Pain Palette", |
| 57 |
[uf_bonuspalette] = "Disable Bonus Palette", |
| 58 |
[uf_powerpalette] = "Disable Power Palette", |
| 59 |
[uf_healthbar] = "Show Health Bars", |
| 60 |
[uf_alwayssr50] = "Always SR50", |
| 61 |
[uf_maxplayercorpse] = "Edit Corpse Limit", |
| 62 |
[uf_hideweapon] = "Hide Weapon", |
| 63 |
[uf_showalive] = "Show Alive", |
| 64 |
[uf_join] = "Join", |
| 65 |
[uf_mouse_and_controller] = "Mouse and Controller", |
| 66 |
[uf_ghost] = "Ghost", |
| 67 |
[uf_advanced_map] = "Advanced Map", |
| 68 |
[uf_vanillatrans] = "Vanilla Translucency", |
| 69 |
[uf_ghosttrans] = "Ghost Translucency", |
| 70 |
[uf_levelbrightness] = "Extra Lighting", |
| 71 |
}; |
| 72 |
|
| 73 |
void dsda_TrackFeature(int feature) { |
| 74 |
BITSET(used_features, feature); |
| 75 |
} |
| 76 |
|
| 77 |
void dsda_ResetFeatures(void) { |
| 78 |
memset(used_features, 0, FEATURE_SLOTS); |
| 79 |
} |
| 80 |
|
| 81 |
byte *dsda_UsedFeatures(void) { |
| 82 |
return used_features; |
| 83 |
} |
| 84 |
|
| 85 |
void dsda_MergeFeatures(byte *source) { |
| 86 |
for (int f = 0; f < FEATURE_SLOTS; f++) { |
| 87 |
used_features[f] |= source[f]; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
void dsda_CopyFeatures(byte* result) { |
| 92 |
for (int f = 0; f < FEATURE_SLOTS; f++) { |
| 93 |
result[f] = used_features[f]; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
char* dsda_DescribeFeatures(void) { |
| 98 |
int i; |
| 99 |
dboolean first = true; |
| 100 |
dsda_string_t description; |
| 101 |
|
| 102 |
dsda_InitString(&description, NULL); |
| 103 |
|
| 104 |
for (i = 0; i < FEATURE_SIZE; i++) { |
| 105 |
if (BITTEST(used_features, i) && feature_names[i]) { |
| 106 |
if (first) |
| 107 |
first = false; |
| 108 |
else |
| 109 |
dsda_StringCat(&description, ", "); |
| 110 |
|
| 111 |
dsda_StringCat(&description, feature_names[i]); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
if (!description.string) |
| 116 |
dsda_StringCat(&description, "Tachyeres pteneres"); |
| 117 |
|
| 118 |
return description.string; |
| 119 |
} |