mirror of
https://github.com/osukey/osukey.git
synced 2025-06-18 01:37:57 +09:00
Disallow removing items from SelectionCycleFillFlowContainer
This commit is contained in:
parent
ddb1da5a66
commit
8b1876bc2a
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -21,8 +20,6 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private int? selectedIndex;
|
private int? selectedIndex;
|
||||||
|
|
||||||
private readonly Dictionary<T, Action<SelectionState>> handlerMap = new Dictionary<T, Action<SelectionState>>();
|
|
||||||
|
|
||||||
public void SelectNext()
|
public void SelectNext()
|
||||||
{
|
{
|
||||||
if (!selectedIndex.HasValue || selectedIndex == Count - 1)
|
if (!selectedIndex.HasValue || selectedIndex == Count - 1)
|
||||||
@ -57,28 +54,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
Debug.Assert(drawable != null);
|
Debug.Assert(drawable != null);
|
||||||
|
|
||||||
// This event is used to update selection state when modified within the drawable itself.
|
drawable.StateChanged += state => selectionChanged(drawable, state);
|
||||||
// It is added to a dictionary so that we can unsubscribe if the drawable is removed from this container
|
|
||||||
handlerMap[drawable] = state => selectionChanged(drawable, state);
|
|
||||||
|
|
||||||
drawable.StateChanged += handlerMap[drawable];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Remove(T drawable)
|
public override bool Remove(T drawable)
|
||||||
{
|
=> throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}");
|
||||||
if (!base.Remove(drawable))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Debug.Assert(drawable != null);
|
|
||||||
|
|
||||||
if (handlerMap.TryGetValue(drawable, out var action))
|
|
||||||
{
|
|
||||||
drawable.StateChanged -= action;
|
|
||||||
handlerMap.Remove(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSelected(int? value)
|
private void setSelected(int? value)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user