DialogueCensorshipSettings.razor

Settings panel that lets the player choose how profanity in dialogue is handled, either clean or masked. Shows a live preview of the filter and persists the choice through GamePreferences.

@using Sandbox
@using Sandbox.UI
@using Socer
@using System
@inherits Panel

<div class="settings-section censorship-section localized-text">
    <div><label class="settings-label">@T("Цензура реплик","Dialogue censorship")</label><label class="settings-help">@T("Меняет мат в репликах сразу. Шутки и характер футболистов остаются.","Changes strong language immediately. Jokes and player personalities remain.")</label></div>
    <div class="censorship-choices">@foreach(var mode in new[]{DialogueCensorship.Clean,DialogueCensorship.Masked}){var choice=mode;<button class="censorship-@((int)choice) @(GamePreferences.Censorship==choice?"chosen":"")" onclick=@(()=>{GamePreferences.SetCensorship(choice);GameAudio.Tap();})>@Name(choice)</button>}</div>
    <div class="censorship-preview"><label>@T("Пример","Preview")</label><label>@DialogueFilter.Format(T("Бля, я же открыт!","Fuck, I'm open!"),T("Я же открыт!","I'm open!"),GamePreferences.Censorship)</label></div>
</div>

@code {
    static string T(string ru,string en)=>GamePreferences.Russian?ru:en;
    static string Name(DialogueCensorship mode)=>mode==DialogueCensorship.Clean?T("Без мата","Clean"):T("Скрывать мат","Mask profanity");
    protected override int BuildHash()=>GamePreferences.Revision;
}