mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:53:21 +08:00
Add date entry for groupings
This commit is contained in:
parent
c1e3c4d435
commit
2ee77670ee
@ -4,8 +4,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Tournament.Screens.Ladder.Components;
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||||
@ -18,24 +21,36 @@ namespace osu.Game.Tournament.Screens.Groupings
|
|||||||
|
|
||||||
public GroupingsEditorScreen()
|
public GroupingsEditorScreen()
|
||||||
{
|
{
|
||||||
Add(new FillFlowContainer
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
new Box
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
items = new FillFlowContainer<GroupingRow>
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.Gray(0.2f),
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0.9f,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
items = new FillFlowContainer<GroupingRow>
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
AutoSizeAxes = Axes.Y,
|
Direction = FillDirection.Vertical,
|
||||||
},
|
RelativeSizeAxes = Axes.X,
|
||||||
new TriangleButton
|
AutoSizeAxes = Axes.Y,
|
||||||
{
|
},
|
||||||
Width = 100,
|
new TriangleButton
|
||||||
Text = "Add",
|
{
|
||||||
Action = addNew
|
Margin = new MarginPadding(20),
|
||||||
},
|
Width = 100,
|
||||||
|
Text = "Add",
|
||||||
|
Action = addNew
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -55,11 +70,11 @@ namespace osu.Game.Tournament.Screens.Groupings
|
|||||||
|
|
||||||
private void addNew()
|
private void addNew()
|
||||||
{
|
{
|
||||||
items.Add(new GroupingRow(new TournamentGrouping(), updateGroupings));
|
items.Add(new GroupingRow(new TournamentGrouping { StartDate = { Value = DateTimeOffset.UtcNow } }, updateGroupings));
|
||||||
updateGroupings();
|
updateGroupings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGroupings()
|
private void updateGroupings()
|
||||||
{
|
{
|
||||||
LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList();
|
LadderInfo.Groupings = items.Children.Select(c => c.Grouping).ToList();
|
||||||
}
|
}
|
||||||
@ -75,8 +90,9 @@ namespace osu.Game.Tournament.Screens.Groupings
|
|||||||
{
|
{
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Full,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsTextBox { Width = 0.3f, Bindable = Grouping.Name },
|
new SettingsTextBox { Width = 0.3f, Bindable = Grouping.Name },
|
||||||
@ -92,12 +108,45 @@ namespace osu.Game.Tournament.Screens.Groupings
|
|||||||
onDelete();
|
onDelete();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
new DateTextBox { Width = 0.3f, Bindable = Grouping.StartDate },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 40;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DateTextBox : SettingsTextBox
|
||||||
|
{
|
||||||
|
public DateTextBox()
|
||||||
|
{
|
||||||
|
base.Bindable = new Bindable<string>();
|
||||||
|
((OsuTextBox)Control).OnCommit = (sender, newText) => {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bindable.Value = DateTimeOffset.Parse(sender.Text);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
bindable.TriggerChange();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// hold a reference to the provided bindable so we don't have to in every settings section.
|
||||||
|
private Bindable<DateTimeOffset> bindable;
|
||||||
|
|
||||||
|
public new Bindable<DateTimeOffset> Bindable
|
||||||
|
{
|
||||||
|
get { return bindable; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bindable = value;
|
||||||
|
bindable.BindValueChanged(dto => base.Bindable.Value = dto.ToUniversalTime().ToString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user