Skip to content

Commit

Permalink
movement indicator ui (sourced from: j0zzz/JoeQuake@bc56fea)
Browse files Browse the repository at this point in the history
  • Loading branch information
timbergeron committed Sep 19, 2024
1 parent a3c8d20 commit 0a6380d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions Quake/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions Quake/gl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions Quake/gl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a6380d

Please sign in to comment.