mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Move editing functionality to its own screen
This commit is contained in:
@ -30,8 +30,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
Pairing = pairing;
|
||||
|
||||
Position = new Vector2(pairing.Position.X, pairing.Position.Y);
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Margin = new MarginPadding(5);
|
||||
@ -69,6 +67,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
Spacing = new Vector2(2)
|
||||
}
|
||||
};
|
||||
|
||||
pairing.Team1.BindValueChanged(_ => updateTeams());
|
||||
pairing.Team2.BindValueChanged(_ => updateTeams());
|
||||
pairing.Team1Score.BindValueChanged(_ => updateWinConditions());
|
||||
@ -79,6 +78,11 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
pairing.LosersProgression.BindValueChanged(_ => updateProgression());
|
||||
pairing.Losers.BindValueChanged(_ => updateTeams());
|
||||
pairing.Current.BindValueChanged(_ => updateCurrentMatch(), true);
|
||||
pairing.Position.BindValueChanged(pos =>
|
||||
{
|
||||
if (IsDragged) return;
|
||||
Position = new Vector2(pos.X, pos.Y);
|
||||
}, true);
|
||||
|
||||
updateTeams();
|
||||
}
|
||||
@ -205,13 +209,13 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
updateWinConditions();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => e.Button == MouseButton.Left && editorInfo.EditingEnabled;
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => e.Button == MouseButton.Left && editorInfo != null;
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e) => editorInfo.EditingEnabled;
|
||||
protected override bool OnDragStart(DragStartEvent e) => editorInfo != null;
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (Selected && editorInfo.EditingEnabled && e.Key == Key.Delete)
|
||||
if (Selected && editorInfo != null && e.Key == Key.Delete)
|
||||
{
|
||||
Remove();
|
||||
return true;
|
||||
@ -222,7 +226,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!editorInfo.EditingEnabled)
|
||||
if (editorInfo == null)
|
||||
return false;
|
||||
|
||||
Selected = true;
|
||||
@ -237,7 +241,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
this.MoveToOffset(e.Delta);
|
||||
|
||||
var pos = Position;
|
||||
Pairing.Position = new Point((int)pos.X, (int)pos.Y);
|
||||
Pairing.Position.Value = new Point((int)pos.X, (int)pos.Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
private Color4 colourNormal;
|
||||
|
||||
private readonly Func<bool> isWinner;
|
||||
private LadderManager manager;
|
||||
private LadderEditorScreen ladderEditor;
|
||||
|
||||
[Resolved]
|
||||
private LadderInfo ladderInfo { get; set; }
|
||||
@ -80,9 +80,9 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colours, LadderManager manager)
|
||||
private void load(OsuColour colours, LadderEditorScreen ladderEditor)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.ladderEditor = ladderEditor;
|
||||
|
||||
colourWinner = losers ? colours.YellowDarker : colours.BlueDarker;
|
||||
colourNormal = OsuColour.Gray(0.2f);
|
||||
@ -141,7 +141,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
//TODO: use OnClick instead once we have per-button clicks.
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Team == null || editorInfo.EditingEnabled) return false;
|
||||
if (Team == null || editorInfo != null) return false;
|
||||
|
||||
if (!pairing.Current.Value)
|
||||
{
|
||||
@ -190,15 +190,15 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!editorInfo.EditingEnabled)
|
||||
if (editorInfo == null)
|
||||
return new MenuItem[0];
|
||||
|
||||
return new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem("Set as current", MenuItemType.Standard, setCurrent),
|
||||
new OsuMenuItem("Join with", MenuItemType.Standard, () => manager.RequestJoin(pairing, false)),
|
||||
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => manager.RequestJoin(pairing, true)),
|
||||
new OsuMenuItem("Remove", MenuItemType.Destructive, () => manager.Remove(pairing)),
|
||||
new OsuMenuItem("Join with", MenuItemType.Standard, () => ladderEditor.RequestJoin(pairing, false)),
|
||||
new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => ladderEditor.RequestJoin(pairing, true)),
|
||||
new OsuMenuItem("Remove", MenuItemType.Destructive, () => ladderEditor.Remove(pairing)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class LadderEditorInfo
|
||||
{
|
||||
public readonly BindableBool EditingEnabled = new BindableBool();
|
||||
public readonly Bindable<MatchPairing> Selected = new Bindable<MatchPairing>();
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PlayerCheckbox
|
||||
{
|
||||
Bindable = editorInfo.EditingEnabled,
|
||||
LabelText = "Enable editing"
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -119,16 +114,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
if (editorInfo.Selected.Value != null)
|
||||
editorInfo.Selected.Value.Losers.Value = losers;
|
||||
};
|
||||
|
||||
// sliderBestOf.Bindable.ValueChanged += val =>
|
||||
// {
|
||||
// if (editorInfo.Selected.Value != null) editorInfo.Selected.Value.BestOf.Value = (int)val;
|
||||
// };
|
||||
|
||||
editorInfo.EditingEnabled.ValueChanged += enabled =>
|
||||
{
|
||||
if (!enabled) editorInfo.Selected.Value = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
|
||||
public readonly Bindable<DateTimeOffset> Date = new Bindable<DateTimeOffset>();
|
||||
|
||||
public Point Position;
|
||||
public readonly Bindable<Point> Position = new Bindable<Point>();
|
||||
|
||||
public MatchPairing()
|
||||
{
|
||||
|
Reference in New Issue
Block a user