using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Globalization; using System.Linq; using System.Windows.Forms; using A; using VibranceHud.Controls; using VibranceHud.Crosshair; using VibranceHud.Design; using VibranceHud.Display; using VibranceHud.Licensing; using VibranceHud.Presets; namespace VibranceHud.Pages; public sealed class LibraryPage : GlowPage { private sealed record Fact(string Name, string Author, string Blurb, string Summary, string Glyph, Action Apply, string? CommunityId); internal sealed class StatusLine : Label { private readonly bool _link; private bool _hovered; private readonly OutsideFocusRing _focusRing; internal StatusLine(bool link = false) { _link = link; _focusRing = new OutsideFocusRing(this, () => ControlInk.PxF(ControlInk.Dpi(this), 4f)); if (link) { SetStyle(ControlStyles.Selectable, value: true); } TabStop = link; } protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); AccessibleName = Text; } protected override void OnParentChanged(EventArgs e) { base.OnParentChanged(e); _focusRing?.Rehook(); } protected override void Dispose(bool disposing) { if (disposing) { _focusRing.Release(); } base.Dispose(disposing); } protected override bool IsInputKey(Keys keyData) { if (!_link || (keyData & Keys.KeyCode) != Keys.Return) { return base.IsInputKey(keyData); } return true; } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); _hovered = true; Invalidate(); } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); _hovered = false; Invalidate(); } protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); Invalidate(); } protected override void OnLostFocus(EventArgs e) { base.OnLostFocus(e); Invalidate(); } protected override void OnPaint(PaintEventArgs e) { _focusRing.Show(_link && Focused && ShowFocusCues); using Font font = ((_link && (_hovered || Focused)) ? new Font(Font, Font.Style | FontStyle.Underline) : null); Font font2 = font ?? Font; if (SlateSurface.Active && Text.Length > 0) { TextFormatFlags flags = TextFormatFlags.NoPrefix | TextFormatFlags.WordBreak | TextFormatFlags.NoPadding; int num = Tokens.Scale(8); int width = Math.Max(1, Width - 2 * num); Size size = TextRenderer.MeasureText(e.Graphics, Text, font2, new Size(width, int.MaxValue), flags); RectangleF rect = new RectangleF(0f, 0f, Math.Min(Width, size.Width + 2 * num), Math.Min(Height, size.Height + 2)); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; Glass.PaintPanel(e.Graphics, rect, Tokens.Scale(4), Glass.BackdropOffsetOf(this)); TextRenderer.DrawText(e.Graphics, Text, font2, new Rectangle(num, 1, width, Math.Max(1, Height - 1)), ForeColor, flags); } else if (_link) { TextRenderer.DrawText(e.Graphics, Text, font2, ClientRectangle, ForeColor, TextFormatFlags.NoPrefix | TextFormatFlags.WordBreak); } else { base.OnPaint(e); } } } private const int Pad = 16; private const int CardW = 932; private const int RightInset = 15; private new const int Gutter = 0; private const int CardGap = 16; private const int RowGap = 16; private const int WallTop = 0; private const int RowHeight = 32; private readonly AppSettings _settings; private readonly SettingsStore _store; private readonly Func _onApply; private readonly Func _nvidiaDriverAvailable; internal const string ColourKind = "Colour looks"; internal const string CrosshairKind = "Crosshairs"; internal const string DisplayKind = "Resolutions"; internal const string ConfigKind = "Setups"; internal const string AllGamesLabel = "All games"; internal static readonly string[] Kinds = new string[4] { "Colour looks", "Crosshairs", "Resolutions", "Setups" }; private const int TabStripW = 369; private const int GamePickerW = 128; private const int SortSlotW = 112; private const int FilterGap = 8; private const int WallHeight = 424; private const int DesignCardH = 204; private readonly SegmentStrip _kindTabs; private readonly GlassTextBox _search; private readonly Panel _toolbar; private readonly GlassDropdown _gamePicker; private readonly List _crosshairChips = new List(); private readonly Action? _onApplyCrosshair; private readonly Func? _onApplyMode; private string _kind = "Colour looks"; private readonly QuietScrollPanel _wall; private readonly Label _status; private readonly List _chips = new List(); private readonly GlassButton _upload; private readonly GlassButton _retry; private readonly Action? _onOpenPage; private bool _fetchFailed; private readonly LibraryToast _toast; private LibraryPreset? _currentApply; private LibraryPreset? _previousApply; private readonly List