A UI Razor component that renders the level-up choice modal. It lists the player's LevelUpChoices as selectable buttons with icon, title, description and optional level badge, shows current level and a reroll button, and invokes Player.AddStatus or Player.UseReroll when buttons are clicked.
@using Sandbox;
@using Sandbox.UI;
@namespace SS1
@inherits Panel
@attribute [StyleSheet("ChoicePanel.razor.scss")]
<root>
<div class="choice_modal">
@{
Color labelColor = Player.IsLevelCursed( Player.Level ) ? new Color(0.8f, 0f, 0f) : new Color(1f, 1f, 1f, 0.9f);
}
<div class="choice_lvl_label" style="color: @(labelColor.Rgba);">
@($"Level {Player.Level}")
</div>
<div class="choice_button_container">
@for(int i = 0; i < Player.LevelUpChoices.Count; i++)
{
var status = Player.LevelUpChoices[i];
<div class="choice_button" onclick=@(() => ChoiceButtonClicked(TypeLibrary.GetType( status.GetType() )))>
<div class="choice_icon" style="background-image: url(@(status.IconPath));">
@if(status.Level > 1)
{
<div class="status_level_label" style="color:@((status.Level == status.MaxLevel ? new Color(0.75f, 0.75f, 0f) : new Color(1f, 1f, 1f)).Rgba);">
@status.Level
</div>
}
</div>
<div class="choice_title">
@if(Input.UsingController && i < Player.NUM_CHOICE_HOTKEYS) { <InputHint Button=@($"Slot{i + 1}") /> }
@(Input.UsingController ? status.Title : $"[{i + 1}] {status.Title}")
</div>
<div class="choice_description">
@status.GetUpgradeDescription(status.Level)
</div>
</div>
}
</div>
<div class="reroll_button @(Player.NumRerollAvailable <= 0 ? "disabled" : "")" onclick=@(() => RerollButtonClicked())>
@if(Input.UsingController) { <InputHint Button="reload" style="opacity:@(Player.NumRerollAvailable <= 0 ? 0.15f : 1f);" /> }
<div class="reroll_button_label @(Player.NumRerollAvailable <= 0 ? "disabled_text" : "")">
@(Input.UsingController ? $"Reroll - {Player.NumRerollAvailable}" : $"[R]eroll - {Player.NumRerollAvailable}")
</div>
</div>
</div>
</root>
@code
{
public Player Player { get; set; }
protected override int BuildHash()
{
return HashCode.Combine(
Player.ChoiceHash,
Player.NumRerollAvailable,
Input.UsingController
);
}
void ChoiceButtonClicked(TypeDescription type)
{
if (!Manager.Instance.ShouldUpdatePlayer)
return;
Player.AddStatus(type);
}
void RerollButtonClicked()
{
if(!Manager.Instance.ShouldUpdatePlayer)
return;
Player.UseReroll();
}
}