v1.2.3.b3 - HUD auto-hide
This commit is contained in:
parent
8bb69c1ea1
commit
20f1ba212a
10 changed files with 31 additions and 10 deletions
|
|
@ -60,6 +60,16 @@ public class WasdManager : IWasdMenuManager
|
||||||
menuPlayer?.UpdateActiveMenu(list);
|
menuPlayer?.UpdateActiveMenu(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetMenuPaused(CCSPlayerController? player, bool pause)
|
||||||
|
{
|
||||||
|
if (TryGetPlayer(player, out var menuPlayer) && menuPlayer != null)
|
||||||
|
{
|
||||||
|
menuPlayer.Paused = pause;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool TryGetPlayer(CCSPlayerController? player, out WasdMenuPlayer? menuPlayer)
|
private static bool TryGetPlayer(CCSPlayerController? player, out WasdMenuPlayer? menuPlayer)
|
||||||
{
|
{
|
||||||
menuPlayer = null!;
|
menuPlayer = null!;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public class WasdMenuPlayer
|
||||||
public string CenterHtml = "";
|
public string CenterHtml = "";
|
||||||
public int VisibleOptions = 3;
|
public int VisibleOptions = 3;
|
||||||
public PlayerButtons Buttons { get; set; }
|
public PlayerButtons Buttons { get; set; }
|
||||||
|
public bool Paused = false;
|
||||||
|
|
||||||
public int scrollIndex = 0;
|
public int scrollIndex = 0;
|
||||||
public int maxLength = 21;
|
public int maxLength = 21;
|
||||||
|
|
@ -128,6 +129,8 @@ public class WasdMenuPlayer
|
||||||
string endControl = "";
|
string endControl = "";
|
||||||
LinkedListNode<IWasdMenuOption>? option = MenuStart;
|
LinkedListNode<IWasdMenuOption>? option = MenuStart;
|
||||||
|
|
||||||
|
builder.AppendLine("<jRS/>");
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(option?.Value?.Parent?.Title))
|
if (!string.IsNullOrEmpty(option?.Value?.Parent?.Title))
|
||||||
builder.AppendLine(option.Value.Parent?.Title ?? "");
|
builder.AppendLine(option.Value.Parent?.Title ?? "");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,5 @@ public interface IWasdMenuManager
|
||||||
public IWasdMenu CreateMenu(string title, string itemText, string itemHoverText, string ControlText);
|
public IWasdMenu CreateMenu(string title, string itemText, string itemHoverText, string ControlText);
|
||||||
public bool HasMenu(CCSPlayerController? player);
|
public bool HasMenu(CCSPlayerController? player);
|
||||||
public void UpdateActiveMenu(CCSPlayerController? player, Dictionary<string, Action<CCSPlayerController, IWasdMenuOption>> list);
|
public void UpdateActiveMenu(CCSPlayerController? player, Dictionary<string, Action<CCSPlayerController, IWasdMenuOption>> list);
|
||||||
|
public bool SetMenuPaused(CCSPlayerController? player, bool pause);
|
||||||
}
|
}
|
||||||
|
|
@ -47,18 +47,15 @@ public class WASDMenuAPI
|
||||||
{
|
{
|
||||||
foreach (var player in Players.Values.Where(p => p.MainMenu != null && p.Player?.IsValid == true))
|
foreach (var player in Players.Values.Where(p => p.MainMenu != null && p.Player?.IsValid == true))
|
||||||
{
|
{
|
||||||
|
if (player.Paused)
|
||||||
|
return;
|
||||||
|
|
||||||
if ((player.Buttons & PlayerButtons.Forward) == 0 && (player.Player.Buttons & PlayerButtons.Forward) != 0)
|
if ((player.Buttons & PlayerButtons.Forward) == 0 && (player.Player.Buttons & PlayerButtons.Forward) != 0)
|
||||||
{
|
|
||||||
player.ScrollUp();
|
player.ScrollUp();
|
||||||
}
|
|
||||||
else if((player.Buttons & PlayerButtons.Back) == 0 && (player.Player.Buttons & PlayerButtons.Back) != 0)
|
else if((player.Buttons & PlayerButtons.Back) == 0 && (player.Player.Buttons & PlayerButtons.Back) != 0)
|
||||||
{
|
|
||||||
player.ScrollDown();
|
player.ScrollDown();
|
||||||
}
|
|
||||||
else if((player.Buttons & PlayerButtons.Use) == 0 && (player.Player.Buttons & PlayerButtons.Use) != 0)
|
else if((player.Buttons & PlayerButtons.Use) == 0 && (player.Player.Buttons & PlayerButtons.Use) != 0)
|
||||||
{
|
|
||||||
player.Choose();
|
player.Choose();
|
||||||
}
|
|
||||||
|
|
||||||
player.Buttons = player.Player.Buttons;
|
player.Buttons = player.Player.Buttons;
|
||||||
if (!string.IsNullOrEmpty(player.CenterHtml))
|
if (!string.IsNullOrEmpty(player.CenterHtml))
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
|
||||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using src.menu;
|
using src.menu;
|
||||||
|
|
@ -444,7 +443,7 @@ namespace src.command
|
||||||
bool isDisplayHUD = playerInfo.HideHUD < tickCount;
|
bool isDisplayHUD = playerInfo.HideHUD < tickCount;
|
||||||
|
|
||||||
playerInfo.HideHUD = isDisplayHUD ? int.MaxValue : int.MinValue;
|
playerInfo.HideHUD = isDisplayHUD ? int.MaxValue : int.MinValue;
|
||||||
SkillUtils.CloseMenu(player);
|
SkillUtils.SetMenuPaused(player, isDisplayHUD);
|
||||||
player.PrintToChat($" {(!isDisplayHUD ? ChatColors.Green : ChatColors.Red)}{player.GetTranslation(!isDisplayHUD ? "hud_on" : "hud_off")}");
|
player.PrintToChat($" {(!isDisplayHUD ? ChatColors.Green : ChatColors.Red)}{player.GetTranslation(!isDisplayHUD ? "hud_on" : "hud_off")}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ namespace src.player
|
||||||
if (isOtherPlugin && playerInfo.HideHUD != int.MaxValue)
|
if (isOtherPlugin && playerInfo.HideHUD != int.MaxValue)
|
||||||
{
|
{
|
||||||
playerInfo.HideHUD = tickCount + 15;
|
playerInfo.HideHUD = tickCount + 15;
|
||||||
SkillUtils.CloseMenu(player);
|
SkillUtils.SetMenuPaused(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,11 @@ namespace src.player
|
||||||
|
|
||||||
if (player.PawnIsAlive && skillPlayer.SkillHudExpired < now && string.IsNullOrEmpty(skillPlayer.PrintHTML)) return;
|
if (player.PawnIsAlive && skillPlayer.SkillHudExpired < now && string.IsNullOrEmpty(skillPlayer.PrintHTML)) return;
|
||||||
|
|
||||||
if (SkillUtils.HasMenu(player)) return;
|
if (SkillUtils.HasMenu(player))
|
||||||
|
{
|
||||||
|
SkillUtils.SetMenuPaused(player, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string infoLine = string.Empty;
|
string infoLine = string.Empty;
|
||||||
string skillLine = string.Empty;
|
string skillLine = string.Empty;
|
||||||
|
|
|
||||||
|
|
@ -786,6 +786,13 @@ namespace src.utils
|
||||||
return manager.HasMenu(player);
|
return manager.HasMenu(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SetMenuPaused(CCSPlayerController? player, bool pause)
|
||||||
|
{
|
||||||
|
var manager = GetMenuManager();
|
||||||
|
if (manager == null) return false;
|
||||||
|
return manager.SetMenuPaused(player, pause);
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetInvisibleSignature(string id)
|
private static string GetInvisibleSignature(string id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(id)) return "";
|
if (string.IsNullOrEmpty(id)) return "";
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue