This commit is contained in:
MotoLegacy 2024-12-26 16:52:18 -05:00
commit 18cb18c6ba
7 changed files with 66 additions and 58 deletions

View file

@ -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

View file

@ -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);
};

View file

@ -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 *
*******************/
@ -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();

View file

@ -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;
@ -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)

View file

@ -1,49 +0,0 @@
/*
client/user_input.qc
User Input scheme for menus.
Copyright (C) 2021-2024 NZ:P Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
string(string source, float spec_key, float key, float max_length) GetUserInput =
{
// Welcome to the world's worst user input implementation.
// Seriously, though -- it's kind of hacked together.
// I think at least. Upon further looking it seems,, decent?
// Backspace -- just return the string minus 1.
if (spec_key == K_BACKSPACE) {
return substring(source, 0, strlen(source) - 1);
}
// If we've hit our max length, do nothing.
if (strlen(source) >= max_length)
return source;
// Key is out of range (thanks Nuclide)
if ((key < 32 || key > 125))
return source;
// Append and send that shit out!
return sprintf("%s%s", source, chr2str(key));
}

View file

@ -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)
@ -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)

View file

@ -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 == "")
@ -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 == "")
@ -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");
@ -122,4 +122,4 @@ void() Menu_Pause =
}
sui_pop_frame();
};
};