mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 22:08:34 -04:00
45 lines
838 B
Plaintext
45 lines
838 B
Plaintext
@using MenuProject.MenuUI.Toasts
|
|
@using Sandbox;
|
|
@using Sandbox.UI;
|
|
@namespace Menu
|
|
@inherits Panel
|
|
|
|
<root>
|
|
</root>
|
|
|
|
@code
|
|
{
|
|
public static Toasts Instance { get; private set; }
|
|
|
|
protected override void OnAfterTreeRender ( bool firstTime )
|
|
{
|
|
base.OnAfterTreeRender( firstTime );
|
|
|
|
if ( firstTime )
|
|
{
|
|
Instance = this;
|
|
}
|
|
}
|
|
|
|
public void AddToast ( string message, Action action, float duration = 10f )
|
|
{
|
|
var entry = new ToastEntry();
|
|
entry.Text = message;
|
|
entry.Duration = duration * Scene.TimeScale;
|
|
entry.Action = action;
|
|
|
|
AddChild( entry );
|
|
}
|
|
|
|
public void AddToast(string message, string image, Action action, float duration = 10f)
|
|
{
|
|
var entry = new ToastEntry();
|
|
entry.Text = message;
|
|
entry.Duration = duration * Scene.TimeScale;
|
|
entry.Image = image;
|
|
entry.Action = action;
|
|
|
|
AddChild(entry);
|
|
}
|
|
}
|