diff --git a/Quake/draw.h b/Quake/draw.h index 41fd5dcd..f7043d50 100644 --- a/Quake/draw.h +++ b/Quake/draw.h @@ -47,6 +47,7 @@ extern qboolean custom_conchars; // woods (iw) #democontrols void Draw_Init (void); void Draw_Character (int x, int y, int num); void Draw_CharacterRGBA (int x, int y, int num, plcolour_t c, float alpha); // woods #iwtabcomplete +void Draw_Character_Rotation (int x, int y, int num, int rotation); // woods #movementkeys void Draw_DebugChar (char num); void Draw_Pic (int x, int y, qpic_t *pic); void Draw_Pic_RGBA_Outline (int x, int y, qpic_t* pic, plcolour_t c, float alpha, float outlineThickness); // woods #varmatchclock diff --git a/Quake/gl_draw.c b/Quake/gl_draw.c index 89869c40..3c5bed4a 100644 --- a/Quake/gl_draw.c +++ b/Quake/gl_draw.c @@ -674,6 +674,52 @@ void Draw_CharacterRGBA (int x, int y, int num, plcolour_t c, float alpha) glColor4f (1, 1, 1, 1); } +void Draw_Character_Rotation (int x, int y, int num, int rotation) // woods #movementkeys +{ + num &= 255; + + if (num == 32) + return; // don't waste verts on spaces + + GL_Bind(char_texture); + glPushMatrix(); // Save the current transformation state + + glTranslatef(x + 4, y + 4, 0); // Move the center of rotation to the character's center + + glRotatef(rotation, 0, 0, 1); // Rotate clockwise by using a positive angle + + if (rotation == 360 || rotation == -360) + glScalef(-1, 1, 1); // Flip horizontally + + glTranslatef(-4, -4, 0); // Move back by the offset + + glBegin(GL_QUADS); + + int row, col; + float frow, fcol, size; + + row = num >> 4; + col = num & 15; + + frow = row * 0.0625; + fcol = col * 0.0625; + size = 0.0625; + + // Normal rendering + glTexCoord2f(fcol, frow); + glVertex2f(0, 0); + glTexCoord2f(fcol + size, frow); + glVertex2f(8, 0); + glTexCoord2f(fcol + size, frow + size); + glVertex2f(8, 8); + glTexCoord2f(fcol, frow + size); + glVertex2f(0, 8); + + glEnd(); + + glPopMatrix(); // Restore the previous transformation state +} + /* ================ Draw_String -- johnfitz -- modified to call Draw_CharacterQuad diff --git a/Quake/gl_screen.c b/Quake/gl_screen.c index d7c9d831..a3cf6308 100644 --- a/Quake/gl_screen.c +++ b/Quake/gl_screen.c @@ -125,6 +125,7 @@ cvar_t scr_ping = {"scr_ping", "1", CVAR_ARCHIVE}; // woods #scrping cvar_t scr_match_hud = {"scr_match_hud", "1", CVAR_ARCHIVE}; // woods #matchhud cvar_t scr_showspeed = {"scr_showspeed", "0",CVAR_ARCHIVE}; // woods #speed cvar_t scr_showspeed_y = {"scr_showspeed_y", "176", CVAR_ARCHIVE}; // woods - #speedometer +cvar_t scr_movekeys = {"scr_movekeys", "0", CVAR_ARCHIVE}; // woods #movementkeys cvar_t scr_matchclock = {"scr_matchclock", "0",CVAR_ARCHIVE}; // woods #varmatchclock cvar_t scr_matchclock_y = {"scr_matchclock_y", "0",CVAR_ARCHIVE}; // woods #varmatchclock cvar_t scr_matchclock_x = {"scr_matchclock_x", "0",CVAR_ARCHIVE}; // woods #varmatchclock @@ -832,6 +833,7 @@ void SCR_Init (void) Cvar_RegisterVariable(&scr_match_hud); // woods #matchhud Cvar_RegisterVariable (&scr_showspeed); // woods #speed Cvar_RegisterVariable (&scr_showspeed_y); // woods #speedometer + Cvar_RegisterVariable (&scr_movekeys); // woods #movementkeys Cvar_RegisterVariable (&scr_matchclock); // woods #varmatchclock Cvar_RegisterVariable (&scr_matchclock_y); // woods #varmatchclock Cvar_RegisterVariable (&scr_matchclock_x); // woods #varmatchclock @@ -2070,6 +2072,59 @@ void SCR_DrawSpeed (void) } +/* +=============== +SCR_DrawMovementKeys -- woods #movementkeys (soruced from: https://github.com/j0zzz/JoeQuake/commit/bc56fea) +=============== +*/ +void SCR_DrawMovementKeys(void) +{ + if (!scr_movekeys.value || cl.intermission || qeintermission || scr_viewsize.value > 110) + return; + + extern kbutton_t in_moveleft, in_moveright, in_forward, in_back, in_jump, in_up; + + int x, y, size = 8; + int clampedSbar = CLAMP(1, (int)scr_sbar.value, 3); + + switch (clampedSbar) + { + case 1: + x = 10; + y = (scr_showspeed.value == 1) ? 186 : 198; + if (scr_viewsize.value == 110) + y += 26; + GL_SetCanvas(CANVAS_SBAR2); + break; + case 2: + x = 10; + y = (scr_showspeed.value == 1 || !strcmp(mute, "y")) ? 210 : 224; + GL_SetCanvas(CANVAS_SBAR2); + break; + case 3: // #qehud + x = (scr_showspeed.value == 1) ? 172 : 174; + y = (scr_showspeed.value == 1) ? 148 : 166; + GL_SetCanvas(CANVAS_BOTTOMLEFTQESMALL); + break; + default: + return; // Invalid clampedSbar value + } + + // Draw movement keys + if (in_forward.state & 1) + Draw_Character_Rotation(x, y - size, '^', 0); + if (in_back.state & 1) + Draw_Character_Rotation(x, y + size, '^', 180); + if (in_moveleft.state & 1) + Draw_Character_Rotation(x - size, y, '^', 270); + if (in_moveright.state & 1) + Draw_Character_Rotation(x + size, y, '^', 90); + if (in_jump.state & 1) + M_Print(x, y - 1, "j"); + else if (in_up.state & 1) + M_Print(x, y -1, "s"); +} + /* ============== SCR_DrawMute -- woods #usermute @@ -3289,6 +3344,7 @@ void SCR_UpdateScreen (void) SCR_ShowFlagStatus (); // woods #matchhud #flagstatus SCR_ShowObsFrags (); // woods #observerhud SCR_DrawSpeed (); // woods #speed + SCR_DrawMovementKeys (); // woods #movementkeys TP_DrawClosestLocText (); // woods #locext SCR_Mute (); // woods #usermute SCR_Observing (); // woods