6
2025-08-05 10:00:54 +03:00

50 lines
1.3 KiB
C#

using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Audio;
using Robust.Shared.Input;
namespace Content.Client._Horizon.MediaPlayer;
[GenerateTypedNameReferences]
public sealed partial class MediaFile : PanelContainer
{
public bool TitlePressed;
public string? SongId;
public SoundPathSpecifier? SongPath;
public string? FullSongName;
public event Action<MediaFile>? OnPanelClicked;
public MediaFile()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
MusicTitle.OnMouseEntered += OnEntered;
MusicTitle.OnMouseExited += OnExited;
MusicTitle.OnKeyBindDown += OnBindDown;
}
private void OnEntered(GUIMouseHoverEventArgs args)
{
if (!TitlePressed)
MusicTitle.Modulate = Color.Gray;
}
private void OnExited(GUIMouseHoverEventArgs args)
{
if (!TitlePressed)
MusicTitle.Modulate = Color.White;
}
private void OnBindDown(GUIBoundKeyEventArgs args)
{
if (args.Function != EngineKeyFunctions.UIClick)
return;
TitlePressed = !TitlePressed;
OnPanelClicked?.Invoke(this);
MusicTitle.Modulate = TitlePressed ? Color.Green : Color.White;
}
}