mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-16 03:37:18 +00:00
commit
95ed069c6b
@ -37,7 +37,7 @@
|
||||
#define HUD_SPECTATORS (1 << 4) // show list of spectators
|
||||
#define HUD_KEYOVERLAY (1 << 5) // show a key overlay
|
||||
#define HUD_HIDEWEAPON (1 << 6) // hide the player's weapon
|
||||
#define HUD_TOPLEFT (1 << 7) // show top left white HUD with WR/PB times (css only)
|
||||
#define HUD_TOPLEFT (1 << 7) // show top left white HUD with WR/PB times
|
||||
#define HUD_SYNC (1 << 8) // shows sync at right side of the screen (css only)
|
||||
#define HUD_TIMELEFT (1 << 9) // shows time left at right tside of the screen (css only)
|
||||
#define HUD_2DVEL (1 << 10) // shows 2d velocity
|
||||
@ -71,10 +71,11 @@ int gI_HUDSettings[MAXPLAYERS+1];
|
||||
int gI_NameLength = MAX_NAME_LENGTH;
|
||||
int gI_LastScrollCount[MAXPLAYERS+1];
|
||||
int gI_ScrollCount[MAXPLAYERS+1];
|
||||
BhopStyle gBS_Style[MAXPLAYERS+1];
|
||||
|
||||
bool gB_Late = false;
|
||||
|
||||
// css hud
|
||||
// hud handle
|
||||
Handle gH_HUD = null;
|
||||
|
||||
// timer settings
|
||||
@ -112,7 +113,6 @@ public void OnPluginStart()
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
gH_HUD = CreateHudSynchronizer();
|
||||
gI_NameLength = MAX_NAME_LENGTH;
|
||||
}
|
||||
|
||||
@ -126,6 +126,9 @@ public void OnPluginStart()
|
||||
gB_Zones = LibraryExists("shavit-zones");
|
||||
gB_BhopStats = LibraryExists("bhopstats");
|
||||
|
||||
// HUD handle
|
||||
gH_HUD = CreateHudSynchronizer();
|
||||
|
||||
// cron
|
||||
CreateTimer(0.10, UpdateHUD_Timer, INVALID_HANDLE, TIMER_REPEAT);
|
||||
|
||||
@ -177,6 +180,7 @@ public void OnClientPutInServer(int client)
|
||||
{
|
||||
gI_LastScrollCount[client] = 0;
|
||||
gI_ScrollCount[client] = 0;
|
||||
gBS_Style[client] = Shavit_GetBhopStyle(client);
|
||||
}
|
||||
|
||||
public void OnClientCookiesCached(int client)
|
||||
@ -196,6 +200,8 @@ public void OnClientCookiesCached(int client)
|
||||
{
|
||||
gI_HUDSettings[client] = StringToInt(sHUDSettings);
|
||||
}
|
||||
|
||||
gBS_Style[client] = Shavit_GetBhopStyle(client);
|
||||
}
|
||||
|
||||
public Action Command_HUD(int client, int args)
|
||||
@ -243,12 +249,12 @@ Action ShowHUDMenu(int client, int item)
|
||||
FormatEx(sHudItem, 64, "%T", "HudHideWeapon", client);
|
||||
m.AddItem(sInfo, sHudItem);
|
||||
|
||||
IntToString(HUD_TOPLEFT, sInfo, 16);
|
||||
FormatEx(sHudItem, 64, "%T", "HudTopLeft", client);
|
||||
m.AddItem(sInfo, sHudItem);
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
IntToString(HUD_TOPLEFT, sInfo, 16);
|
||||
FormatEx(sHudItem, 64, "%T", "HudTopLeft", client);
|
||||
m.AddItem(sInfo, sHudItem);
|
||||
|
||||
IntToString(HUD_SYNC, sInfo, 16);
|
||||
FormatEx(sHudItem, 64, "%T", "HudSync", client);
|
||||
m.AddItem(sInfo, sHudItem);
|
||||
@ -374,10 +380,10 @@ void TriggerHUDUpdate(int client)
|
||||
{
|
||||
UpdateHUD(client);
|
||||
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", ((gI_HUDSettings[client] & HUD_HIDEWEAPON) > 0)? 0:1);
|
||||
UpdateTopLeftHUD(client, true);
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
UpdateTopLeftHUD(client, true);
|
||||
UpdateKeyHint(client);
|
||||
UpdateCenterKeys(client);
|
||||
}
|
||||
@ -458,16 +464,15 @@ void UpdateHUD(int client)
|
||||
{
|
||||
float fTime = Shavit_GetClientTime(target);
|
||||
int iJumps = Shavit_GetClientJumps(target);
|
||||
BhopStyle bsStyle = Shavit_GetBhopStyle(target);
|
||||
TimerStatus tStatus = Shavit_GetTimerStatus(target);
|
||||
int iStrafes = Shavit_GetStrafeCount(target);
|
||||
int iPotentialRank = Shavit_GetRankForTime(bsStyle, fTime);
|
||||
int iPotentialRank = Shavit_GetRankForTime(gBS_Style[target], fTime);
|
||||
|
||||
float fWR = 0.0;
|
||||
Shavit_GetWRTime(bsStyle, fWR);
|
||||
Shavit_GetWRTime(gBS_Style[target], fWR);
|
||||
|
||||
float fPB = 0.0;
|
||||
Shavit_GetPlayerPB(target, bsStyle, fPB);
|
||||
Shavit_GetPlayerPB(target, gBS_Style[target], fPB);
|
||||
|
||||
char[] sPB = new char[32];
|
||||
FormatSeconds(fPB, sPB, 32);
|
||||
@ -514,24 +519,24 @@ void UpdateHUD(int client)
|
||||
|
||||
if(fPB > 0.0)
|
||||
{
|
||||
Format(sHintText, 512, "%s%s%T: %s (#%d)", sHintText, (tStatus >= Timer_Running)? "\t":"", "HudBestText", client, sPB, (Shavit_GetRankForTime(bsStyle, fPB) - 1));
|
||||
Format(sHintText, 512, "%s%s%T: %s (#%d)", sHintText, (tStatus >= Timer_Running)? "\t":"", "HudBestText", client, sPB, (Shavit_GetRankForTime(gBS_Style[target], fPB) - 1));
|
||||
}
|
||||
|
||||
if(tStatus >= Timer_Running)
|
||||
{
|
||||
Format(sHintText, 512, "%s\n%T: %d%s\t%T: <font color='#%s'>%s</font>", sHintText, "HudJumpsText", client, iJumps, (iJumps < 1000)? "\t":"", "HudStyleText", client, gS_StyleStrings[bsStyle][sHTMLColor], gS_StyleStrings[bsStyle][sStyleName]);
|
||||
Format(sHintText, 512, "%s\n%T: %d%s\t%T: <font color='#%s'>%s</font>", sHintText, "HudJumpsText", client, iJumps, (iJumps < 1000)? "\t":"", "HudStyleText", client, gS_StyleStrings[gBS_Style[target]][sHTMLColor], gS_StyleStrings[gBS_Style[target]][sStyleName]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Format(sHintText, 512, "%s\n%T: <font color='#%s'>%s</font>", sHintText, "HudStyleText", client, gS_StyleStrings[bsStyle][sHTMLColor], gS_StyleStrings[bsStyle][sStyleName]);
|
||||
Format(sHintText, 512, "%s\n%T: <font color='#%s'>%s</font>", sHintText, "HudStyleText", client, gS_StyleStrings[gBS_Style[target]][sHTMLColor], gS_StyleStrings[gBS_Style[target]][sStyleName]);
|
||||
}
|
||||
|
||||
Format(sHintText, 512, "%s\n%T: %d", sHintText, "HudSpeedText", client, iSpeed);
|
||||
|
||||
if(tStatus >= Timer_Running)
|
||||
{
|
||||
if(gA_StyleSettings[bsStyle][bSync])
|
||||
if(gA_StyleSettings[gBS_Style[target]][bSync])
|
||||
{
|
||||
Format(sHintText, 512, "%s%s\t%T: %d (%.02f%%)", sHintText, (iSpeed < 1000)? "\t":"", "HudStrafeText", client, iStrafes, Shavit_GetSync(target));
|
||||
}
|
||||
@ -551,7 +556,7 @@ void UpdateHUD(int client)
|
||||
{
|
||||
if(Shavit_GetTimerStatus(target) == Timer_Running)
|
||||
{
|
||||
FormatEx(sHintText, 512, "%s\n%T: %s (%d)\n%T: %d\n%T: %d\n%T: %d%s", gS_StyleStrings[bsStyle][sStyleName], "HudTimeText", client, sTime, iPotentialRank, "HudJumpsText", client, iJumps, "HudStrafeText", client, iStrafes, "HudSpeedText", client, iSpeed, (gA_StyleSettings[bsStyle][fVelocityLimit] > 0.0 && Shavit_InsideZone(target, Zone_NoVelLimit))? "\nNo Speed Limit":"");
|
||||
FormatEx(sHintText, 512, "%s\n%T: %s (%d)\n%T: %d\n%T: %d\n%T: %d%s", gS_StyleStrings[gBS_Style[target]][sStyleName], "HudTimeText", client, sTime, iPotentialRank, "HudJumpsText", client, iJumps, "HudStrafeText", client, iStrafes, "HudSpeedText", client, iSpeed, (gA_StyleSettings[gBS_Style[target]][fVelocityLimit] > 0.0 && Shavit_InsideZone(target, Zone_NoVelLimit))? "\nNo Speed Limit":"");
|
||||
}
|
||||
|
||||
else
|
||||
@ -644,7 +649,7 @@ void UpdateKeyOverlay(int client, Panel panel, bool &draw)
|
||||
// that's a very ugly way, whatever :(
|
||||
char[] sPanelLine = new char[128];
|
||||
|
||||
if(gA_StyleSettings[Shavit_GetBhopStyle(target)][bAutobhop]) // don't include [JUMP] for autobhop styles
|
||||
if(gA_StyleSettings[gBS_Style[client]][bAutobhop]) // don't include [JUMP] for autobhop styles
|
||||
{
|
||||
FormatEx(sPanelLine, 128, "[%s]\n %s\n%s %s %s", (buttons & IN_DUCK) > 0? "DUCK":"----", (buttons & IN_FORWARD) > 0? "W":"-", (buttons & IN_MOVELEFT) > 0? "A":"-", (buttons & IN_BACK) > 0? "S":"-", (buttons & IN_MOVERIGHT) > 0? "D":"-");
|
||||
}
|
||||
@ -666,9 +671,14 @@ public void Bunnyhop_OnTouchGround(int client)
|
||||
|
||||
public void Bunnyhop_OnJumpPressed(int client)
|
||||
{
|
||||
if(gEV_Type != Engine_CSS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gI_ScrollCount[client] = BunnyhopStats.GetScrollCount(client);
|
||||
|
||||
if(gA_StyleSettings[Shavit_GetBhopStyle(client)][bAutobhop] || gEV_Type != Engine_CSS)
|
||||
if(gA_StyleSettings[gBS_Style[client]][bAutobhop])
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -703,7 +713,7 @@ void UpdateCenterKeys(int client)
|
||||
(buttons & IN_DUCK > 0)? "C":"-", (buttons & IN_FORWARD > 0)? "W":"-", (buttons & IN_JUMP > 0)? "J":"-",
|
||||
(buttons & IN_MOVELEFT > 0)? "A":"-", (buttons & IN_BACK > 0)? "S":"-", (buttons & IN_MOVERIGHT > 0)? "D":"-");
|
||||
|
||||
if(gB_BhopStats && !gA_StyleSettings[Shavit_GetBhopStyle(target)][bAutobhop])
|
||||
if(gB_BhopStats && !gA_StyleSettings[gBS_Style[target]][bAutobhop])
|
||||
{
|
||||
Format(sCenterText, 64, "%s\n%d %d", sCenterText, gI_ScrollCount[client], gI_LastScrollCount[target]);
|
||||
}
|
||||
@ -778,10 +788,8 @@ void UpdateTopLeftHUD(int client, bool wait)
|
||||
{
|
||||
int target = GetHUDTarget(client);
|
||||
|
||||
BhopStyle style = Shavit_GetBhopStyle(target);
|
||||
|
||||
float fWRTime = 0.0;
|
||||
Shavit_GetWRTime(style, fWRTime);
|
||||
Shavit_GetWRTime(gBS_Style[target], fWRTime);
|
||||
|
||||
if(fWRTime != 0.0)
|
||||
{
|
||||
@ -789,10 +797,10 @@ void UpdateTopLeftHUD(int client, bool wait)
|
||||
FormatSeconds(fWRTime, sWRTime, 16);
|
||||
|
||||
char[] sWRName = new char[MAX_NAME_LENGTH];
|
||||
Shavit_GetWRName(style, sWRName, MAX_NAME_LENGTH);
|
||||
Shavit_GetWRName(gBS_Style[target], sWRName, MAX_NAME_LENGTH);
|
||||
|
||||
float fPBTime = 0.0;
|
||||
Shavit_GetPlayerPB(target, style, fPBTime);
|
||||
Shavit_GetPlayerPB(target, gBS_Style[target], fPBTime);
|
||||
|
||||
char[] sPBTime = new char[16];
|
||||
FormatSeconds(fPBTime, sPBTime, MAX_NAME_LENGTH);
|
||||
@ -801,7 +809,7 @@ void UpdateTopLeftHUD(int client, bool wait)
|
||||
|
||||
if(fPBTime != 0.0)
|
||||
{
|
||||
FormatEx(sTopLeft, 64, "WR: %s (%s)\n%T: %s (#%d)", sWRTime, sWRName, "HudBestText", client, sPBTime, (Shavit_GetRankForTime(style, fPBTime) - 1));
|
||||
FormatEx(sTopLeft, 64, "WR: %s (%s)\n%T: %s (#%d)", sWRTime, sWRName, "HudBestText", client, sPBTime, (Shavit_GetRankForTime(gBS_Style[target], fPBTime) - 1));
|
||||
}
|
||||
|
||||
else
|
||||
@ -831,7 +839,7 @@ void UpdateKeyHint(int client)
|
||||
|
||||
if(IsValidClient(target) && (target == client || (gI_HUDSettings[client] & HUD_OBSERVE) > 0))
|
||||
{
|
||||
if((gI_HUDSettings[client] & HUD_SYNC) > 0 && Shavit_GetTimerStatus(target) == Timer_Running && gA_StyleSettings[Shavit_GetBhopStyle(target)][bSync] && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start)))
|
||||
if((gI_HUDSettings[client] & HUD_SYNC) > 0 && Shavit_GetTimerStatus(target) == Timer_Running && gA_StyleSettings[gBS_Style[target]][bSync] && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start)))
|
||||
{
|
||||
Format(sMessage, 256, "%s%s%T: %.02f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", "HudSync", client, Shavit_GetSync(target));
|
||||
}
|
||||
@ -916,9 +924,11 @@ public int PanelHandler_Nothing(Menu m, MenuAction action, int param1, int param
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void Shavit_OnStyleChanged(int client)
|
||||
public void Shavit_OnStyleChanged(int client, BhopStyle oldstyle, BhopStyle newstyle)
|
||||
{
|
||||
UpdateTopLeftHUD(client, false);
|
||||
|
||||
gBS_Style[client] = newstyle;
|
||||
}
|
||||
|
||||
public int Native_ForceHUDUpdate(Handle handler, int numParams)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user