mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 22:08:34 -04:00
55 lines
990 B
Plaintext
55 lines
990 B
Plaintext
@using Sandbox;
|
|
@using Sandbox.UI;
|
|
@inherits Panel
|
|
|
|
<root onclick=@(() => Action?.Invoke())>
|
|
@if(!string.IsNullOrEmpty(Image))
|
|
{
|
|
<img src="@Image" />
|
|
}
|
|
<div class="contents">
|
|
<label>@Text</label>
|
|
<div class="progress-bar">
|
|
<div class="fill" style="width: @(100f - ((timeSinceCreated / Duration) * 100f))%;" />
|
|
</div>
|
|
</div>
|
|
</root>
|
|
|
|
@code
|
|
{
|
|
public string Text { get; set; } = "Hello World!";
|
|
public float Duration { get; set; } = 5.0f;
|
|
public string Image { get; set; }
|
|
public Action Action { get; set; }
|
|
|
|
TimeSince timeSinceCreated = 0f;
|
|
float hoverTime = 0f;
|
|
|
|
public override void Tick ()
|
|
{
|
|
base.Tick();
|
|
|
|
if ( HasHovered || LoadingScreen.IsVisible )
|
|
{
|
|
if (hoverTime == 0)
|
|
hoverTime = timeSinceCreated;
|
|
else
|
|
timeSinceCreated = hoverTime;
|
|
}
|
|
else
|
|
{
|
|
hoverTime = 0;
|
|
}
|
|
|
|
if(timeSinceCreated > Duration)
|
|
{
|
|
Delete();
|
|
}
|
|
}
|
|
|
|
protected override int BuildHash ()
|
|
{
|
|
return System.HashCode.Combine( timeSinceCreated.ToString() );
|
|
}
|
|
}
|