The pause menu UI for Horizon RP. Shows resume, keybind editor, settings, disconnect and quit buttons, plus the local player's name and job.
@using Sandbox;
@using Sandbox.UI;
@namespace HorizonRP
@inherits Panel
@*
Le menu pause d'Horizon RP, à la place de celui de s&box : Échap l'ouvre quand
aucun autre menu n'est ouvert (le HUD intercepte la touche). Reprendre,
réglages du jeu (la fenêtre de s&box), rappel des touches, quitter le serveur
ou le jeu.
*@
<root>
<div class="pause-backdrop">
<div class="pause @(ShowKeys ? "wide" : "")">
<div class="pause-brand">
<div class="pause-logo"></div>
<div class="pause-title">
<div class="pause-name">HORIZON</div>
<div class="pause-sub">ROLEPLAY</div>
</div>
</div>
@if ( Me is not null && !Me.NeedsCharacter && !ShowKeys )
{
<div class="pause-who">
<div class="who-name">@Me.RpName</div>
<div class="who-job" style="color: @Me.Job.Color">@Me.Job.Name</div>
</div>
}
@if ( ShowKeys )
{
@* Un encadré par famille, comme la liste du HUD, sur trois colonnes. Cliquer une touche la change. *@
<div class="pause-keys-scroll">
@foreach ( var group in Binds.GroupBy( x => x.Group ) )
{
<div class="pause-keys">
<div class="pause-keys-head"><i>@GroupIcon( group.Key )</i> @group.Key</div>
<div class="pause-keys-grid">
@foreach ( var bind in group )
{
var shown = Keybinds.DisplayOf( bind.Action );
var waiting = Keybinds.Capturing == bind.Action;
<div class="pause-key @(waiting ? "waiting" : "") @(Keybinds.IsChanged( bind.Action ) ? "changed" : "")" onclick=@(() => Keybinds.StartCapture( bind.Action ))>
@if ( waiting )
{
<div class="cap"><i>more_horiz</i></div>
}
else if ( Keybinds.ArrowIcon( shown ) is { } arrow )
{
<div class="cap"><i>@arrow</i></div>
}
else
{
<div class="cap">@shown</div>
}
<div class="cap-label">@bind.Label</div>
</div>
}
</div>
</div>
}
</div>
<div class="pause-note @(Keybinds.Capturing is not null ? "live" : "")">@Note</div>
<div class="pause-row">
<div class="pause-btn" onclick=@(() => Keybinds.ResetAll())><i>restart_alt</i> Touches d'origine</div>
<div class="pause-btn primary" onclick=@(() => { Keybinds.CancelCapture(); ShowKeys = false; })><i>check</i> Terminé</div>
</div>
}
else
{
<div class="pause-btn primary" onclick=@(() => OnResume?.Invoke())><i>play_arrow</i> Reprendre</div>
<div class="pause-btn" onclick=@(() => ShowKeys = true)><i>keyboard</i> Touches</div>
<div class="pause-btn" onclick=@(() => Game.Overlay.ShowSettingsModal())><i>settings</i> Réglages</div>
<div class="pause-sep"></div>
<div class="pause-btn" onclick=@(() => Game.Disconnect())><i>logout</i> Quitter le serveur</div>
<div class="pause-btn danger" onclick=@(() => Game.Close())><i>power_settings_new</i> Quitter le jeu</div>
}
<div class="pause-foot">@($"{(RoleplayPlayer.All.Count())} citoyen{(RoleplayPlayer.All.Count() > 1 ? "s" : "")} en ville · Échap pour reprendre")</div>
</div>
</div>
</root>
@code
{
public Action OnResume { get; set; }
/// <summary>Les actions réglables ; celles du staff pour le staff seulement.</summary>
IEnumerable<Keybinds.Bind> Binds => Keybinds.All.Where( x => !x.StaffOnly || Me?.IsStaff == true );
string Note => Keybinds.Capturing is not null
? "Appuyez sur la nouvelle touche · Échap pour annuler"
: Keybinds.Message ?? "Cliquez sur une action pour lui donner une autre touche. Vos choix sont gardés sur cet ordinateur.";
static string GroupIcon( string group ) => group switch
{
"Déplacements" => "directions_run",
"Actions" => "touch_app",
"Menus" => "apps",
_ => "shield",
};
bool ShowKeys { get; set; }
RoleplayPlayer Me => RoleplayPlayer.Local;
protected override int BuildHash() => HashCode.Combine( ShowKeys, Me?.RpName, Me?.JobId, RoleplayPlayer.All.Count(), Keybinds.Capturing, Keybinds.Message, string.Join( ",", Keybinds.All.Select( x => Keybinds.KeyOf( x.Action ) ) ) );
}