UI/TutorialModal.razor

A Razor UI component for a tutorial modal. It renders a modal with an optional title, a rich-text Label for the tutorial body, and a dismiss button that invokes a provided OnClose action. BuildHash combines Text and Title for change detection.

File Access
@namespace CardGames
@using Sandbox
@using Sandbox.UI
@using System
@inherits Panel

@*
	A read-only "How to play" overlay. Renders a game's rich-text Tutorial in a scrollable modal,
	reusing the cg-modal scrim + dialog pattern from the HUD. Shown by the table-setup screen and the
	in-game HUD; the parent owns the open/close state and passes the text in.
*@

<root class="cg-modal">
	<div class="head">
		<div class="cg-eyebrow">How to play</div>
		@if ( !string.IsNullOrEmpty( Title ) )
		{
			<div class="title">@Title</div>
		}
	</div>

	<div class="dialog cg-panel">
		<div class="scroller">
			<Label class="tutorial-body" IsRich=@true Text=@Text />
		</div>
		<div class="row">
			<button class="cg-btn primary" onclick=@(() => OnClose?.Invoke())>Got it</button>
		</div>
	</div>
</root>

@code
{
	[Parameter] public string Text { get; set; } = "";
	[Parameter] public string Title { get; set; } = "";
	[Parameter] public Action OnClose { get; set; }

	protected override int BuildHash() => HashCode.Combine( Text, Title );
}