diff --git a/README.md b/README.md index 3198589..d91aee3 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,11 @@ Default: `4.0`. Scale of the text for speed display. Default: `0.9`. +#### `cg_strafeHelperSpeedX` (#) + +Horizontal offset of the text for speed display, relative to the center of the screen. +Default: `0.0` (center of the screen). + #### `cg_strafeHelperSpeedY` (#) Vertical offset of the text for speed display, relative to the strafe helper. @@ -86,6 +91,12 @@ Default: `0.0` (directly under the strafe helper). Vertical position of the strafe helper. Default: `50.0`. +#### `cg_strafeHelperColor[...]` (0.0 - 1.0) + +Color components (red, green, blue, alpha) for different strafe helper elements. +These are `Accelerating`, `Optimal`, `CenterMarker` and `Speed`. +Colors can be set more conveniently with the corresponding commands. + ### Cosmetics #### `g_saber_color` (color) @@ -128,3 +139,11 @@ Default: `0`. Create an automatic save when a checkpoint is reached in checkpoint mode. Default: `0`. + +## New Commands + +### HUD + +#### `strafeHelperColor[...] ` (components in range 0.0 to 1.0) + +Sets the color for one of the strafe helper elements `Accelerating`, `Optimal`, `CenterMarker` or `Speed` to the given red, green, blue and alpha values. diff --git a/code/cgame/cg_consolecmds.cpp b/code/cgame/cg_consolecmds.cpp index 18bd6c1..9c8ef6b 100644 --- a/code/cgame/cg_consolecmds.cpp +++ b/code/cgame/cg_consolecmds.cpp @@ -168,6 +168,71 @@ static void CG_InfoUp_f( void ) // cg.showInformation = qfalse; } +static void CG_SetStrafeHelperColorAccelerating_f( void ) { + if (cgi_Argc() != 5) { + Com_Printf("Usage: strafeHelperColorAccelerating \n" ); + Com_Printf("Current color is: %f %f %f %f\n", + cg_strafeHelperColorAcceleratingR.value, + cg_strafeHelperColorAcceleratingG.value, + cg_strafeHelperColorAcceleratingB.value, + cg_strafeHelperColorAcceleratingA.value); + return; + } + cgi_Cvar_Set("cg_strafeHelperColorAcceleratingR", CG_Argv(1)); + cgi_Cvar_Set("cg_strafeHelperColorAcceleratingG", CG_Argv(2)); + cgi_Cvar_Set("cg_strafeHelperColorAcceleratingB", CG_Argv(3)); + cgi_Cvar_Set("cg_strafeHelperColorAcceleratingA", CG_Argv(4)); +} + +static void CG_SetStrafeHelperColorOptimal_f( void ) { + if (cgi_Argc() != 5) { + Com_Printf("Usage: strafeHelperColorOptimal \n" ); + Com_Printf("Current color is: %f %f %f %f\n", + cg_strafeHelperColorOptimalR.value, + cg_strafeHelperColorOptimalG.value, + cg_strafeHelperColorOptimalB.value, + cg_strafeHelperColorOptimalA.value); + return; + } + cgi_Cvar_Set("cg_strafeHelperColorOptimalR", CG_Argv(1)); + cgi_Cvar_Set("cg_strafeHelperColorOptimalG", CG_Argv(2)); + cgi_Cvar_Set("cg_strafeHelperColorOptimalB", CG_Argv(3)); + cgi_Cvar_Set("cg_strafeHelperColorOptimalA", CG_Argv(4)); +} + +static void CG_SetStrafeHelperColorCenterMarker_f( void ) { + if (cgi_Argc() != 5) { + Com_Printf("Usage: strafeHelperColorCenterMarker \n" ); + Com_Printf("Current color is: %f %f %f %f\n", + cg_strafeHelperColorCenterMarkerR.value, + cg_strafeHelperColorCenterMarkerG.value, + cg_strafeHelperColorCenterMarkerB.value, + cg_strafeHelperColorCenterMarkerA.value); + return; + } + cgi_Cvar_Set("cg_strafeHelperColorCenterMarkerR", CG_Argv(1)); + cgi_Cvar_Set("cg_strafeHelperColorCenterMarkerG", CG_Argv(2)); + cgi_Cvar_Set("cg_strafeHelperColorCenterMarkerB", CG_Argv(3)); + cgi_Cvar_Set("cg_strafeHelperColorCenterMarkerA", CG_Argv(4)); +} + +static void CG_SetStrafeHelperColorSpeed_f( void ) { + if (cgi_Argc() != 5) { + Com_Printf("Usage: strafeHelperColorSpeed \n" ); + Com_Printf("Current color is: %f %f %f %f\n", + cg_strafeHelperColorSpeedR.value, + cg_strafeHelperColorSpeedG.value, + cg_strafeHelperColorSpeedB.value, + cg_strafeHelperColorSpeedA.value); + return; + } + cgi_Cvar_Set("cg_strafeHelperColorSpeedR", CG_Argv(1)); + cgi_Cvar_Set("cg_strafeHelperColorSpeedG", CG_Argv(2)); + cgi_Cvar_Set("cg_strafeHelperColorSpeedB", CG_Argv(3)); + cgi_Cvar_Set("cg_strafeHelperColorSpeedA", CG_Argv(4)); +} + + typedef struct { char *cmd; void (*function)(void); @@ -217,6 +282,11 @@ Ghoul2 Insert End { "dpinvprev", CG_DPPrevInventory_f }, { "dpforcenext", CG_DPNextForcePower_f }, { "dpforceprev", CG_DPPrevForcePower_f }, + + { "strafeHelperColorAccelerating", CG_SetStrafeHelperColorAccelerating_f }, + { "strafeHelperColorOptimal", CG_SetStrafeHelperColorOptimal_f }, + { "strafeHelperColorCenterMarker", CG_SetStrafeHelperColorCenterMarker_f }, + { "strafeHelperColorSpeed", CG_SetStrafeHelperColorSpeed_f }, }; diff --git a/code/cgame/cg_draw.cpp b/code/cgame/cg_draw.cpp index ce4aa98..b608426 100644 --- a/code/cgame/cg_draw.cpp +++ b/code/cgame/cg_draw.cpp @@ -2349,6 +2349,7 @@ static void CG_DrawStrafeHelper( void ) { params.height = cg_strafeHelperHeight.value; params.y = cg_strafeHelperY.value; params.speed_scale = cg_strafeHelperSpeedScale.value; + params.speed_x = cg_strafeHelperSpeedX.value; params.speed_y = cg_strafeHelperSpeedY.value; StrafeHelper_Draw( ¶ms, SCREEN_WIDTH, SCREEN_HEIGHT ); } diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index bf5aa59..9f8882b 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -627,8 +627,25 @@ extern vmCvar_t cg_strafeHelperCenterMarker; extern vmCvar_t cg_strafeHelperHeight; extern vmCvar_t cg_strafeHelperScale; extern vmCvar_t cg_strafeHelperSpeedScale; +extern vmCvar_t cg_strafeHelperSpeedX; extern vmCvar_t cg_strafeHelperSpeedY; extern vmCvar_t cg_strafeHelperY; +extern vmCvar_t cg_strafeHelperColorAcceleratingR; +extern vmCvar_t cg_strafeHelperColorAcceleratingG; +extern vmCvar_t cg_strafeHelperColorAcceleratingB; +extern vmCvar_t cg_strafeHelperColorAcceleratingA; +extern vmCvar_t cg_strafeHelperColorOptimalR; +extern vmCvar_t cg_strafeHelperColorOptimalG; +extern vmCvar_t cg_strafeHelperColorOptimalB; +extern vmCvar_t cg_strafeHelperColorOptimalA; +extern vmCvar_t cg_strafeHelperColorCenterMarkerR; +extern vmCvar_t cg_strafeHelperColorCenterMarkerG; +extern vmCvar_t cg_strafeHelperColorCenterMarkerB; +extern vmCvar_t cg_strafeHelperColorCenterMarkerA; +extern vmCvar_t cg_strafeHelperColorSpeedR; +extern vmCvar_t cg_strafeHelperColorSpeedG; +extern vmCvar_t cg_strafeHelperColorSpeedB; +extern vmCvar_t cg_strafeHelperColorSpeedA; void CG_NewClientinfo( int clientNum ); // diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index 25466c5..d7bde44 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -324,8 +324,25 @@ vmCvar_t cg_strafeHelperCenterMarker; vmCvar_t cg_strafeHelperHeight; vmCvar_t cg_strafeHelperScale; vmCvar_t cg_strafeHelperSpeedScale; +vmCvar_t cg_strafeHelperSpeedX; vmCvar_t cg_strafeHelperSpeedY; vmCvar_t cg_strafeHelperY; +vmCvar_t cg_strafeHelperColorAcceleratingR; +vmCvar_t cg_strafeHelperColorAcceleratingG; +vmCvar_t cg_strafeHelperColorAcceleratingB; +vmCvar_t cg_strafeHelperColorAcceleratingA; +vmCvar_t cg_strafeHelperColorOptimalR; +vmCvar_t cg_strafeHelperColorOptimalG; +vmCvar_t cg_strafeHelperColorOptimalB; +vmCvar_t cg_strafeHelperColorOptimalA; +vmCvar_t cg_strafeHelperColorCenterMarkerR; +vmCvar_t cg_strafeHelperColorCenterMarkerG; +vmCvar_t cg_strafeHelperColorCenterMarkerB; +vmCvar_t cg_strafeHelperColorCenterMarkerA; +vmCvar_t cg_strafeHelperColorSpeedR; +vmCvar_t cg_strafeHelperColorSpeedG; +vmCvar_t cg_strafeHelperColorSpeedB; +vmCvar_t cg_strafeHelperColorSpeedA; typedef struct { vmCvar_t *vmCvar; @@ -445,8 +462,25 @@ Ghoul2 Insert End { &cg_strafeHelperHeight, "cg_strafeHelperHeight", "20", CVAR_ARCHIVE }, { &cg_strafeHelperScale, "cg_strafeHelperScale", "4", CVAR_ARCHIVE }, { &cg_strafeHelperSpeedScale, "cg_strafeHelperSpeedScale", "0.9", CVAR_ARCHIVE }, + { &cg_strafeHelperSpeedX, "cg_strafeHelperSpeedX", "0", CVAR_ARCHIVE }, { &cg_strafeHelperSpeedY, "cg_strafeHelperSpeedY", "0", CVAR_ARCHIVE }, { &cg_strafeHelperY, "cg_strafeHelperY", "50", CVAR_ARCHIVE }, + { &cg_strafeHelperColorAcceleratingR, "cg_strafeHelperColorAcceleratingR", "0.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorAcceleratingG, "cg_strafeHelperColorAcceleratingG", "0.5", CVAR_ARCHIVE }, + { &cg_strafeHelperColorAcceleratingB, "cg_strafeHelperColorAcceleratingB", "0.125", CVAR_ARCHIVE }, + { &cg_strafeHelperColorAcceleratingA, "cg_strafeHelperColorAcceleratingA", "0.375", CVAR_ARCHIVE }, + { &cg_strafeHelperColorOptimalR, "cg_strafeHelperColorOptimalR", "0.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorOptimalG, "cg_strafeHelperColorOptimalG", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorOptimalB, "cg_strafeHelperColorOptimalB", "0.25", CVAR_ARCHIVE }, + { &cg_strafeHelperColorOptimalA, "cg_strafeHelperColorOptimalA", "0.75", CVAR_ARCHIVE }, + { &cg_strafeHelperColorCenterMarkerR, "cg_strafeHelperColorCenterMarkerR", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorCenterMarkerG, "cg_strafeHelperColorCenterMarkerG", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorCenterMarkerB, "cg_strafeHelperColorCenterMarkerB", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorCenterMarkerA, "cg_strafeHelperColorCenterMarkerA", "0.75", CVAR_ARCHIVE }, + { &cg_strafeHelperColorSpeedR, "cg_strafeHelperColorSpeedR", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorSpeedG, "cg_strafeHelperColorSpeedG", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorSpeedB, "cg_strafeHelperColorSpeedB", "1.0", CVAR_ARCHIVE }, + { &cg_strafeHelperColorSpeedA, "cg_strafeHelperColorSpeedA", "0.9", CVAR_ARCHIVE }, }; int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); diff --git a/code/speedrun/strafe_helper b/code/speedrun/strafe_helper index 3c8b79e..23f2765 160000 --- a/code/speedrun/strafe_helper +++ b/code/speedrun/strafe_helper @@ -1 +1 @@ -Subproject commit 3c8b79ee50ce07eb6589dc3ca451d5b5bc29f603 +Subproject commit 23f2765ec70a72f6682f417e43de54bb12f248e4 diff --git a/code/speedrun/strafe_helper_includes.cpp b/code/speedrun/strafe_helper_includes.cpp index 8a296e7..a40f743 100644 --- a/code/speedrun/strafe_helper_includes.cpp +++ b/code/speedrun/strafe_helper_includes.cpp @@ -5,16 +5,47 @@ extern "C" { +shi_ColorRGBA shi_getColorAccelerating() { + return {cg_strafeHelperColorAcceleratingR.value, + cg_strafeHelperColorAcceleratingG.value, + cg_strafeHelperColorAcceleratingB.value, + cg_strafeHelperColorAcceleratingA.value}; +} + +shi_ColorRGBA shi_getColorOptimal() { + return {cg_strafeHelperColorOptimalR.value, + cg_strafeHelperColorOptimalG.value, + cg_strafeHelperColorOptimalB.value, + cg_strafeHelperColorOptimalA.value}; +} + +shi_ColorRGBA shi_getColorCenterMarker() { + return {cg_strafeHelperColorCenterMarkerR.value, + cg_strafeHelperColorCenterMarkerG.value, + cg_strafeHelperColorCenterMarkerB.value, + cg_strafeHelperColorCenterMarkerA.value}; +} + +shi_ColorRGBA shi_getColorSpeed() { + return {cg_strafeHelperColorSpeedR.value, + cg_strafeHelperColorSpeedG.value, + cg_strafeHelperColorSpeedB.value, + cg_strafeHelperColorSpeedA.value}; +} + void shi_drawFilledRectangle(const float x, const float y, - const float w, const float h, const vec4_t color) + const float w, const float h, + const shi_ColorRGBA color) { - CG_FillRect(x, y, w, h, color); + const vec4_t color_converted = {color.r, color.g, color.b, color.a}; + CG_FillRect(x, y, w, h, color_converted); } -void shi_drawString(float x, float y, const char* string, float scale, const vec4_t color) +void shi_drawString(float x, float y, const char* string, float scale, const shi_ColorRGBA color) { + const vec4_t color_converted = {color.r, color.g, color.b, color.a}; const float w = cgi_R_Font_StrLenPixels(string, cgs.media.qhFontMedium, scale); - cgi_R_Font_DrawString(x - w/2, y, string, color, cgs.media.qhFontMedium, -1, scale); + cgi_R_Font_DrawString(x - w/2, y, string, color_converted, cgs.media.qhFontMedium, -1, scale); } } // extern "C" diff --git a/code/speedrun/strafe_helper_includes.h b/code/speedrun/strafe_helper_includes.h index aba98e4..a44446a 100644 --- a/code/speedrun/strafe_helper_includes.h +++ b/code/speedrun/strafe_helper_includes.h @@ -8,13 +8,20 @@ extern "C" { #include #include -static const float shi_color_accelerating[4] = {0.0f, 0.5f, 0.125f, 0.375f}; -static const float shi_color_optimal[4] = {0.0f, 1.0f, 0.25f, 0.75f}; -static const float shi_color_center_marker[4] = {1.0f, 1.0f, 1.0f, 0.75f}; -static const float shi_color_speed[4] = {1.0f, 1.0f, 1.0f, 0.9f}; +struct shi_ColorRGBA { + float r; + float g; + float b; + float a; +}; -void shi_drawFilledRectangle(float x, float y, float w, float h, const float color[4]); -void shi_drawString(float x, float y, const char* string, float scale, const float color[4]); +struct shi_ColorRGBA shi_getColorAccelerating(void); +struct shi_ColorRGBA shi_getColorOptimal(void); +struct shi_ColorRGBA shi_getColorCenterMarker(void); +struct shi_ColorRGBA shi_getColorSpeed(void); + +void shi_drawFilledRectangle(float x, float y, float w, float h, struct shi_ColorRGBA color); +void shi_drawString(float x, float y, const char* string, float scale, struct shi_ColorRGBA color); #ifdef __cplusplus } // extern "C"