Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/nzp-team/quakec
Browse files Browse the repository at this point in the history
  • Loading branch information
MotoLegacy committed Dec 26, 2024
2 parents efc004b + 54502a5 commit 18cb18c
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 58 deletions.
3 changes: 1 addition & 2 deletions progs/csqc.src
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ defs/custom.qc
achievements.qc
hud.qc
chat.qc
user_input.qc
view_model.qc
particles.qc
chasecam.qc
main.qc
#endlist
#endlist
16 changes: 15 additions & 1 deletion source/client/draw.qc
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ void(vector position, string text, vector size, vector rgb, float alpha, float d
else
x += (font_kerningamount[(chr - 33)] + 1) * (size_x/8);
}
};
};

void(vector pos, string label, vector v) Draw_FancyVector =
{
Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0);
Draw_String(pos + [32, 16], sprintf("X: %d", v.x), [12, 12], [1, 1, 1], 1, 0);
Draw_String(pos + [32, 32], sprintf("Y: %d", v.y), [12, 12], [1, 1, 1], 1, 0);
Draw_String(pos + [32, 48], sprintf("Z: %d", v.z), [12, 12], [1, 1, 1], 1, 0);
};

void(vector pos, string label, float f, string suffix) Draw_FancyFloat =
{
Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0);
Draw_String(pos + [32, 16], sprintf("%d %s", f, suffix), [12, 12], [1, 1, 1], 1, 0);
};
37 changes: 37 additions & 0 deletions source/client/hud.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,41 @@ void(float width, float height) HUD_RoundStopWatch =
Draw_String([width - (getTextWidth(stopwatch, 12)) - 2, 16], stopwatch, [12, 12], [1, 1, 1], 1, 0);
}

/*******************
* HUD Debug Info *
*******************/

// set from CSQC_Ent_Update
vector player_velocity;

void(float width, float height) HUD_PlayerDebugInfo =
{
static float lastupstime;
static float lastups;

if (!cvar("scr_playerdebuginfo"))
return;

if ((time - lastupstime) >= 1.0 / 20)
{
lastups = vlen(player_velocity);
lastupstime = time;
}

vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")];
pos.x += GetUltraWideOffset();

drawfill(pos - [8, 8], [128, 192], [0, 0, 0], 0.75, 0);

Draw_FancyFloat(pos, "Speed:", lastups, "qu/s");

if (cvar("scr_playerdebuginfo") >= 2)
{
Draw_FancyVector(pos + [0, 36], "Angles:", getproperty(VF_ANGLES));
Draw_FancyVector(pos + [0, 106], "Origin:", getproperty(VF_ORIGIN));
}
};

/*******************
* HUD Draw *
*******************/
Expand Down Expand Up @@ -2014,6 +2049,8 @@ void(float width, float height) HUD_Draw =
HUD_Scores();

HUD_Achievements(width, height);

HUD_PlayerDebugInfo(width, height);

if (screenflash_duration > time)
HUD_Screenflash();
Expand Down
7 changes: 7 additions & 0 deletions source/client/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
autocvar(in_rumbleenabled, 1);
autocvar(in_aimassist, 0);

autocvar(scr_playerdebuginfo, 0);
autocvar(scr_playerdebuginfo_x, 64);
autocvar(scr_playerdebuginfo_y, 6);

// Runtime check if we're running this in WebASM/WebGL.
if (cvar_string("sys_platform") == "Web")
platform_is_web = true;
Expand Down Expand Up @@ -418,6 +422,9 @@ noref void(float isnew) CSQC_Ent_Update =
self.is_in_menu = readbyte();
self.is_spectator = readbyte();

// set for HUD_PlayerDebugInfo
player_velocity = self.velocity;

setmodelindex(self, self.modelindex);

if (self.is_spectator)
Expand Down
49 changes: 0 additions & 49 deletions source/client/user_input.qc

This file was deleted.

4 changes: 2 additions & 2 deletions source/menu/menu_coop.qc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ string(string prev_id) fn ## _GetNextButton = \
} \
\
return ret; \
}; \
};

NEXTBUTTON_FUNC(Menu_Coop_Browse, menu_coop_browse_buttons)
NEXTBUTTON_FUNC(Menu_Coop_Direct, menu_coop_direct_buttons)
Expand Down Expand Up @@ -337,7 +337,7 @@ string(string next_id) fn ## _GetPreviousButton = \
} \
\
return ret; \
}; \
};

PREVBUTTON_FUNC(Menu_Coop_Browse, menu_coop_browse_buttons)
PREVBUTTON_FUNC(Menu_Coop_Direct, menu_coop_direct_buttons)
Expand Down
8 changes: 4 additions & 4 deletions source/menu/menu_paus.qc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ string(string prev_id) Menu_Pause_GetNextButton =
}
}

if (player_count != 0 && ret == "pm_reloa")
if (player_count != 1 && ret == "pm_reloa")
ret = "pm_opts";

if (ret == "")
Expand All @@ -47,7 +47,7 @@ string(string next_id) Menu_Pause_GetPreviousButton =
}
}

if (player_count != 0 && ret == "pm_reloa")
if (player_count != 1 && ret == "pm_reloa")
ret = "pm_resum";

if (ret == "")
Expand Down Expand Up @@ -86,7 +86,7 @@ void() Menu_Pause =
{
Menu_Button(1, "pm_resum", "RESUME CARNAGE", "Return to Game.") ? ToggleMenu() : 0;

if (player_count == 0)
if (player_count == 1)
Menu_Button(2, "pm_reloa", "RESTART LEVEL", "Tough luck? Give things another go.") ? Menu_Pause_EnterSubMenu(1) : 0;
else
Menu_GreyButton(2, "RESTART LEVEL");
Expand Down Expand Up @@ -122,4 +122,4 @@ void() Menu_Pause =
}

sui_pop_frame();
};
};

0 comments on commit 18cb18c

Please sign in to comment.