summaryrefslogtreecommitdiffstats
path: root/src/menu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu.cpp')
-rw-r--r--src/menu.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index dfd973d..92131d4 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -59,8 +59,7 @@ bool g_fog_disable = false;
59int g_fog_rgb[3] = {160, 170, 190}; 59int g_fog_rgb[3] = {160, 170, 190};
60int g_fog_start = 200; 60int g_fog_start = 200;
61int g_fog_end = 3000; 61int g_fog_end = 3000;
62FeatureState g_skybox{false, 0}; // sv_skyname override 62FeatureState g_skybox{false, 0}; // skybox.png image override
63int g_skybox_choice = 0; // 0 = map default
64bool g_item_health = true; 63bool g_item_health = true;
65bool g_item_ammo = true; 64bool g_item_ammo = true;
66bool g_item_armor = true; 65bool g_item_armor = true;
@@ -214,8 +213,8 @@ void config_save() {
214 "start=%d\nend=%d\nskybox=%d\ndisable=%d\n", 213 "start=%d\nend=%d\nskybox=%d\ndisable=%d\n",
215 g_fog.active, g_fog.bind, g_fog_rgb[0], g_fog_rgb[1], g_fog_rgb[2], 214 g_fog.active, g_fog.bind, g_fog_rgb[0], g_fog_rgb[1], g_fog_rgb[2],
216 g_fog_start, g_fog_end, (int)g_fog_skybox, (int)g_fog_disable); 215 g_fog_start, g_fog_end, (int)g_fog_skybox, (int)g_fog_disable);
217 fprintf(f, "[skybox]\nactive=%d\nbind=%d\nchoice=%d\n", g_skybox.active, 216 fprintf(f, "[skybox]\nactive=%d\nbind=%d\n", g_skybox.active,
218 g_skybox.bind, g_skybox_choice); 217 g_skybox.bind);
219 fprintf(f, "[items]\nactive=%d\nbind=%d\nhealth=%d\nammo=%d\n" 218 fprintf(f, "[items]\nactive=%d\nbind=%d\nhealth=%d\nammo=%d\n"
220 "armor=%d\nweapons=%d\ncrates=%d\ndistance=%d\nmax_dist=%d\n", 219 "armor=%d\nweapons=%d\ncrates=%d\ndistance=%d\nmax_dist=%d\n",
221 g_item_esp.active, g_item_esp.bind, (int)g_item_health, 220 g_item_esp.active, g_item_esp.bind, (int)g_item_health,
@@ -250,7 +249,7 @@ static bool config_load() {
250 FeatureState *cur = nullptr; 249 FeatureState *cur = nullptr;
251 bool in_esp = false, in_bhop = false, in_aim = false, in_silent = false, 250 bool in_esp = false, in_bhop = false, in_aim = false, in_silent = false,
252 in_jumpbug = false, in_spread = false, in_items = false, 251 in_jumpbug = false, in_spread = false, in_items = false,
253 in_tint = false, in_fog = false, in_skybox = false; 252 in_tint = false, in_fog = false;
254 while (fgets(line, sizeof(line), f)) { 253 while (fgets(line, sizeof(line), f)) {
255 line[strcspn(line, "\r\n")] = 0; 254 line[strcspn(line, "\r\n")] = 0;
256 if (line[0] == '[') { 255 if (line[0] == '[') {
@@ -293,7 +292,6 @@ static bool config_load() {
293 in_items = (cur == &g_item_esp); 292 in_items = (cur == &g_item_esp);
294 in_tint = (cur == &g_world_tint); 293 in_tint = (cur == &g_world_tint);
295 in_fog = (cur == &g_fog); 294 in_fog = (cur == &g_fog);
296 in_skybox = (cur == &g_skybox);
297 } else if (cur) { 295 } else if (cur) {
298 char *eq = strchr(line, '='); 296 char *eq = strchr(line, '=');
299 if (!eq) 297 if (!eq)
@@ -414,12 +412,6 @@ static bool config_load() {
414 g_fog_disable = atoi(val) != 0; 412 g_fog_disable = atoi(val) != 0;
415 } 413 }
416 } 414 }
417 if (in_skybox && strcmp(key, "choice") == 0) {
418 int v = atoi(val);
419 if (v < 0) v = 0;
420 if (v >= skybox_option_count()) v = 0;
421 g_skybox_choice = v;
422 }
423 if (in_esp) { 415 if (in_esp) {
424 if (strcmp(key, "neutral") == 0) 416 if (strcmp(key, "neutral") == 0)
425 g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; 417 g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0;
@@ -459,6 +451,16 @@ const char *config_path_cstr() {
459 return path.c_str(); 451 return path.c_str();
460} 452}
461 453
454const char *config_file_cstr(const char *name) {
455 static std::string path;
456 std::string p = config_path();
457 size_t slash = p.find_last_of('/');
458 std::string dir =
459 slash == std::string::npos ? std::string(".") : p.substr(0, slash);
460 path = dir + "/" + (name ? name : "");
461 return path.c_str();
462}
463
462void config_reset_defaults() { 464void config_reset_defaults() {
463 g_bhop = {true, 0}; 465 g_bhop = {true, 0};
464 g_bhop_autostrafe = true; 466 g_bhop_autostrafe = true;
@@ -489,7 +491,6 @@ void config_reset_defaults() {
489 g_fog_start = 200; 491 g_fog_start = 200;
490 g_fog_end = 3000; 492 g_fog_end = 3000;
491 g_skybox = {false, 0}; 493 g_skybox = {false, 0};
492 g_skybox_choice = 0;
493 g_item_health = true; 494 g_item_health = true;
494 g_item_ammo = true; 495 g_item_ammo = true;
495 g_item_armor = true; 496 g_item_armor = true;