From 6a40f9aef32aa1bb45be0104b6c0625e1e3e89f6 Mon Sep 17 00:00:00 2001 From: cypress Date: Sat, 29 Jun 2024 19:25:28 -0700 Subject: [PATCH] CLIENT: Add cl_controllerglyphs cvar, control Glyph Brand in settings --- source/client/main.qc | 1 + source/client/menu.qc | 49 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/source/client/main.qc b/source/client/main.qc index 42b923d..f7a951d 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -80,6 +80,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = cvar_set("sv_cheats", ftos(1)); cvar_set("r_fb_models", ftos(0)); autocvar(r_viewmodel_default_fov, 70); + autocvar(cl_controllerglyphs, "xbox"); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") diff --git a/source/client/menu.qc b/source/client/menu.qc index e55c205..4f34728 100644 --- a/source/client/menu.qc +++ b/source/client/menu.qc @@ -843,6 +843,29 @@ void() setting_connect = localcmd(strcat("connect ", temp_server_name)); } +void() setting_glyph = +{ + string current_glyph_brand = cvar_string("cl_controllerglyphs"); + string new_glyph_brand = ""; + + switch(current_glyph_brand) { + case "xbox": + new_glyph_brand = "sony"; + break; + case "sony": + new_glyph_brand = "nintendo"; + break; + case "nintendo": + new_glyph_brand = "generic"; + break; + default: + new_glyph_brand = "xbox"; + break; + } + + cvar_set("cl_controllerglyphs", new_glyph_brand); +} + //rmb null void() null = { return; @@ -978,6 +1001,7 @@ var struct // Control Settings (cont.) {[6, 115], "Invert Mouse", -1, setting_invert, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 66 + {[6, 135], "Controller Glyphs", -1, setting_glyph, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 67 // Main menu (cont.) {[6, 145], "Achievements (Not on Web)", -1, null, null, MENU_MAIN, 1, OPTION_WEB_ONLY}, // 3 @@ -1477,6 +1501,28 @@ void() Draw_Extra_CSettings = else drawstring([320, 115], S_ENABLED, [14, 14], [1, 1, 1], 1, 0); + // Controller Glyphs + string controller_glyph_brand = "Unknown"; + switch(cvar_string("cl_controllerglyphs")) { + case "xbox": + controller_glyph_brand = "Microsoft"; + break; + case "sony": + controller_glyph_brand = "Sony"; + break; + case "nintendo": + controller_glyph_brand = "Nintendo"; + break; + case "generic": + controller_glyph_brand = "Libre"; + break; + default: + controller_glyph_brand = sprintf("User (\"%s\")", cvar_string("cl_controllerglyphs")); + break; + } + drawstring([320, 135], controller_glyph_brand, [14, 14], [1, 1, 1], 1, 0); + drawsubpic([325 + strlen(controller_glyph_brand)*14, 132], [80, 20], sprintf("gfx/controller_glyphs/%s.tga", cvar_string("cl_controllerglyphs")), [0, 0], [0.5, 0.125], [1, 1, 1], 1); + // Descriptions switch(lastActive) { case 54: @@ -1488,6 +1534,9 @@ void() Draw_Extra_CSettings = case 66: cset_desc = "Invert Mouse Input on the Y Axis."; break; + case 67: + cset_desc = "Glyph Branding type to display for Controllers."; + break; default: cset_desc = ""; break;