// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Input.Events; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Edit.Compose; using OpenTK; namespace osu.Game.Rulesets.Edit { /// /// A blueprint which governs the creation of a new to actualisation. /// public abstract class PlacementBlueprint : CompositeDrawable, IRequireHighFrequencyMousePosition { /// /// The that is being placed. /// protected readonly HitObject HitObject; protected IClock EditorClock { get; private set; } private readonly IBindable beatmap = new Bindable(); [Resolved] private IPlacementHandler placementHandler { get; set; } protected PlacementBlueprint(HitObject hitObject) { HitObject = hitObject; RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] private void load(IBindableBeatmap beatmap, IAdjustableClock clock) { this.beatmap.BindTo(beatmap); EditorClock = clock; ApplyDefaultsToHitObject(); } private bool placementBegun; /// /// Signals that the placement of has started. /// protected void BeginPlacement() { placementHandler.BeginPlacement(HitObject); placementBegun = true; } /// /// Signals that the placement of has finished. /// This will destroy this , and add the to the . /// protected void EndPlacement() { if (!placementBegun) BeginPlacement(); placementHandler.EndPlacement(HitObject); } /// /// Invokes , refreshing and parameters for the . /// protected void ApplyDefaultsToHitObject() => HitObject.ApplyDefaults(beatmap.Value.Beatmap.ControlPointInfo, beatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; protected override bool Handle(UIEvent e) { base.Handle(e); switch (e) { case ScrollEvent _: return false; case MouseEvent _: return true; default: return false; } } } }