// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Logging; using osu.Framework.Platform; using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Input; using osu.Game.Input.Bindings; using osu.Game.Online.API; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; using osuTK; using osuTK.Graphics; using osuTK.Input; namespace osu.Game.Screens.Menu { public class ButtonSystem : Container, IStateful, IKeyBindingHandler { public event Action StateChanged; private readonly IBindable isIdle = new BindableBool(); public Action OnEdit; public Action OnExit; public Action OnBeatmapListing; public Action OnSolo; public Action OnSettings; public Action OnMultiplayer; public Action OnTimeshift; public const float BUTTON_WIDTH = 140f; public const float WEDGE_WIDTH = 20; private OsuLogo logo; /// /// Assign the that this ButtonSystem should manage the position of. /// /// The instance of the logo to be assigned. If null, we are suspending from the screen that uses this ButtonSystem. public void SetOsuLogo(OsuLogo logo) { this.logo = logo; if (this.logo != null) { this.logo.Action = onOsuLogo; // osuLogo.SizeForFlow relies on loading to be complete. buttonArea.Flow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0); updateLogoState(); } else { // We should stop tracking as the facade is now out of scope. logoTrackingContainer.StopTracking(); } } private readonly ButtonArea buttonArea; private readonly Button backButton; private readonly List