MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadHUDConfig

Function LoadHUDConfig

Descent3/hud.cpp:1065–1199  ·  view source on GitHub ↗

loads in hud configuration file, adds hud items.

Source from the content-addressed store, hash-verified

1063
1064// loads in hud configuration file, adds hud items.
1065void LoadHUDConfig(const char *filename, bool (*fn)(const char *, const char *, void *), void *ext_data) {
1066 CFILE *fp;
1067 char srcline[128]; // One line of mission source
1068 bool text_pos = false; // text position defined?
1069
1070 // start over.
1071 ResetHUD();
1072 InitDefaultHUDItems();
1073
1074 // open file
1075 fp = cfopen(filename, "rt");
1076 if (!fp) {
1077 mprintf(0, "Unable to find hud.inf file.\n");
1078 return;
1079 }
1080
1081 // check if valid cockpit file
1082 cf_ReadString(srcline, sizeof(srcline), fp);
1083
1084 if (stricmp(srcline, "[hud file]") == 0) {
1085 tHUDItem hud_item;
1086
1087 memset(&hud_item, 0, sizeof(hud_item));
1088 hud_item.alpha = HUD_ALPHA;
1089 hud_item.color = HUD_COLOR;
1090 hud_item.tcolor = HUD_COLOR;
1091
1092 while (!cfeof(fp)) {
1093 char command[32]; // Command read from line.
1094 char operand[96]; // operand read from line
1095 char *keyword; // parsed keyword
1096 int readcount; // read-in count
1097
1098 readcount = cf_ReadString(srcline, sizeof(srcline), fp);
1099 if (readcount) {
1100 // we have a line of source. parse out primary keyword
1101 // then parse out remainder.
1102 keyword = strtok(srcline, " \t=");
1103 CleanupStr(command, srcline, sizeof(command));
1104 CleanupStr(operand, srcline + strlen(command) + 1, sizeof(operand));
1105
1106 // skip comments
1107 if (command[0] == '@')
1108 continue;
1109
1110 // find command,
1111 if (!stricmp(command, "type")) {
1112 // get operand.
1113 hud_item.type = atoi(operand);
1114 } else if (!stricmp(command, "pos")) {
1115 // get two numbers from line
1116 int ix, iy;
1117 sscanf(operand, "%d,%d", &ix, &iy);
1118 hud_item.x = ix;
1119 hud_item.y = iy;
1120 } else if (!stricmp(command, "posA")) {
1121 // get two numbers from line
1122 int ix, iy;

Callers 2

LoadCockpitInfoFunction · 0.85
SetHUDModeFunction · 0.85

Calls 11

ResetHUDFunction · 0.85
InitDefaultHUDItemsFunction · 0.85
cfopenFunction · 0.85
cf_ReadStringFunction · 0.85
cfeofFunction · 0.85
CleanupStrFunction · 0.85
AddHUDItemFunction · 0.85
FreeReticleFunction · 0.85
InitReticleFunction · 0.85
cfcloseFunction · 0.85
GR_RGBFunction · 0.50

Tested by

no test coverage detected