From 9c4455af43da34127864b09ad2a3d3e996c9dce1 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 3 Nov 2026 23:58:59 +0100 Subject: World: replace skybox changer with a PNG skybox image sv_skyname did not take effect at runtime in this build, so the Skybox card now replaces the skybox materials' textures with /skybox.png. The PNG is decoded through libpng16's simplified API (dlopen'ed, so no new link dependency) and uploaded with IMaterialSystem::CreateTextureFromBits as an RGBA8888 texture. IMaterialVar::SetTextureValue assigns it to $basetexture and the HDR variants for every material in the SkyBox textures group (all six faces get the same image). Original textures are recorded per material/var (texture pointer plus string fallback) and restored when the feature is off. Records survive level changes so a reused sky material is still restorable; the override is re-applied to a new map automatically. The card shows the image path and has a Reload image button; a missing/unreadable PNG raises an error toast. --- src/menu.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/menu.cpp') 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; int g_fog_rgb[3] = {160, 170, 190}; int g_fog_start = 200; int g_fog_end = 3000; -FeatureState g_skybox{false, 0}; // sv_skyname override -int g_skybox_choice = 0; // 0 = map default +FeatureState g_skybox{false, 0}; // skybox.png image override bool g_item_health = true; bool g_item_ammo = true; bool g_item_armor = true; @@ -214,8 +213,8 @@ void config_save() { "start=%d\nend=%d\nskybox=%d\ndisable=%d\n", g_fog.active, g_fog.bind, g_fog_rgb[0], g_fog_rgb[1], g_fog_rgb[2], g_fog_start, g_fog_end, (int)g_fog_skybox, (int)g_fog_disable); - fprintf(f, "[skybox]\nactive=%d\nbind=%d\nchoice=%d\n", g_skybox.active, - g_skybox.bind, g_skybox_choice); + fprintf(f, "[skybox]\nactive=%d\nbind=%d\n", g_skybox.active, + g_skybox.bind); fprintf(f, "[items]\nactive=%d\nbind=%d\nhealth=%d\nammo=%d\n" "armor=%d\nweapons=%d\ncrates=%d\ndistance=%d\nmax_dist=%d\n", g_item_esp.active, g_item_esp.bind, (int)g_item_health, @@ -250,7 +249,7 @@ static bool config_load() { FeatureState *cur = nullptr; bool in_esp = false, in_bhop = false, in_aim = false, in_silent = false, in_jumpbug = false, in_spread = false, in_items = false, - in_tint = false, in_fog = false, in_skybox = false; + in_tint = false, in_fog = false; while (fgets(line, sizeof(line), f)) { line[strcspn(line, "\r\n")] = 0; if (line[0] == '[') { @@ -293,7 +292,6 @@ static bool config_load() { in_items = (cur == &g_item_esp); in_tint = (cur == &g_world_tint); in_fog = (cur == &g_fog); - in_skybox = (cur == &g_skybox); } else if (cur) { char *eq = strchr(line, '='); if (!eq) @@ -414,12 +412,6 @@ static bool config_load() { g_fog_disable = atoi(val) != 0; } } - if (in_skybox && strcmp(key, "choice") == 0) { - int v = atoi(val); - if (v < 0) v = 0; - if (v >= skybox_option_count()) v = 0; - g_skybox_choice = v; - } if (in_esp) { if (strcmp(key, "neutral") == 0) g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; @@ -459,6 +451,16 @@ const char *config_path_cstr() { return path.c_str(); } +const char *config_file_cstr(const char *name) { + static std::string path; + std::string p = config_path(); + size_t slash = p.find_last_of('/'); + std::string dir = + slash == std::string::npos ? std::string(".") : p.substr(0, slash); + path = dir + "/" + (name ? name : ""); + return path.c_str(); +} + void config_reset_defaults() { g_bhop = {true, 0}; g_bhop_autostrafe = true; @@ -489,7 +491,6 @@ void config_reset_defaults() { g_fog_start = 200; g_fog_end = 3000; g_skybox = {false, 0}; - g_skybox_choice = 0; g_item_health = true; g_item_ammo = true; g_item_armor = true; -- cgit v1.2.3