Merge remote-tracking branch 'upstream/master' into tournament-tools

This commit is contained in:
Dean Herbert
2018-12-01 10:03:31 +09:00
222 changed files with 4227 additions and 909 deletions

View File

@ -13,6 +13,7 @@ using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Components
{
@ -63,6 +64,18 @@ namespace osu.Game.Screens.Edit.Components
tabs.Current.ValueChanged += newValue => Beatmap.Value.Track.Tempo.Value = newValue;
}
protected override bool OnKeyDown(KeyDownEvent e)
{
switch (e.Key)
{
case Key.Space:
togglePause();
return true;
}
return base.OnKeyDown(e);
}
private void togglePause()
{
if (adjustableClock.IsRunning)

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private Container<PlacementBlueprint> placementBlueprintContainer;
private PlacementBlueprint currentPlacement;
private SelectionBox selectionBox;
private SelectionHandler selectionHandler;
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
@ -37,16 +37,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
[BackgroundDependencyLoader]
private void load()
{
selectionBox = composer.CreateSelectionBox();
selectionBox.DeselectAll = deselectAll;
selectionHandler = composer.CreateSelectionHandler();
selectionHandler.DeselectAll = deselectAll;
var dragBox = new DragBox(select);
dragBox.DragEnd += () => selectionBox.UpdateVisibility();
dragBox.DragEnd += () => selectionHandler.UpdateVisibility();
InternalChildren = new[]
{
dragBox,
selectionBox,
selectionHandler,
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
placementBlueprintContainer = new Container<PlacementBlueprint> { RelativeSizeAxes = Axes.Both },
dragBox.CreateProxy()
@ -168,19 +168,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void onBlueprintSelected(SelectionBlueprint blueprint)
{
selectionBox.HandleSelected(blueprint);
selectionHandler.HandleSelected(blueprint);
selectionBlueprints.ChangeChildDepth(blueprint, 1);
}
private void onBlueprintDeselected(SelectionBlueprint blueprint)
{
selectionBox.HandleDeselected(blueprint);
selectionHandler.HandleDeselected(blueprint);
selectionBlueprints.ChangeChildDepth(blueprint, 0);
}
private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionBox.HandleSelectionRequested(blueprint, state);
private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionHandler.HandleSelectionRequested(blueprint, state);
private void onDragRequested(DragEvent dragEvent) => selectionBox.HandleDrag(dragEvent);
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent) => selectionHandler.HandleDrag(blueprint, dragEvent);
private class SelectionBlueprintContainer : Container<SelectionBlueprint>
{

View File

@ -46,7 +46,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
Masking = true,
BorderColour = Color4.White,
BorderThickness = SelectionBox.BORDER_RADIUS,
BorderThickness = SelectionHandler.BORDER_RADIUS,
Child = new Box
{
RelativeSizeAxes = Axes.Both,

View File

@ -12,26 +12,31 @@ using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
/// <summary>
/// A box which surrounds <see cref="SelectionBlueprint"/>s and provides interactive handles, context menus etc.
/// A component which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
/// </summary>
public class SelectionBox : CompositeDrawable
public class SelectionHandler : CompositeDrawable
{
public const float BORDER_RADIUS = 2;
protected IEnumerable<SelectionBlueprint> SelectedBlueprints => selectedBlueprints;
private readonly List<SelectionBlueprint> selectedBlueprints;
protected IEnumerable<HitObject> SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject.HitObject);
private Drawable outline;
[Resolved]
private IPlacementHandler placementHandler { get; set; }
public SelectionBox()
public SelectionHandler()
{
selectedBlueprints = new List<SelectionBlueprint>();
@ -59,12 +64,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
#region User Input Handling
public void HandleDrag(DragEvent dragEvent)
/// <summary>
/// Handles the selected <see cref="DrawableHitObject"/>s being dragged.
/// </summary>
/// <param name="blueprint">The <see cref="SelectionBlueprint"/> that received the drag event.</param>
/// <param name="dragEvent">The drag event.</param>
public virtual void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
{
// Todo: Various forms of snapping
foreach (var blueprint in selectedBlueprints)
blueprint.AdjustPosition(dragEvent);
}
protected override bool OnKeyDown(KeyDownEvent e)
@ -90,19 +96,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// Bind an action to deselect all selected blueprints.
/// </summary>
public Action DeselectAll { private get; set; }
internal Action DeselectAll { private get; set; }
/// <summary>
/// Handle a blueprint becoming selected.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
public void HandleSelected(SelectionBlueprint blueprint) => selectedBlueprints.Add(blueprint);
internal void HandleSelected(SelectionBlueprint blueprint) => selectedBlueprints.Add(blueprint);
/// <summary>
/// Handle a blueprint becoming deselected.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
public void HandleDeselected(SelectionBlueprint blueprint)
internal void HandleDeselected(SelectionBlueprint blueprint)
{
selectedBlueprints.Remove(blueprint);
@ -115,7 +121,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Handle a blueprint requesting selection.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
public void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{
if (state.Keyboard.ControlPressed)
{
@ -139,7 +145,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
#endregion
/// <summary>
/// Updates whether this <see cref="SelectionBox"/> is visible.
/// Updates whether this <see cref="SelectionHandler"/> is visible.
/// </summary>
internal void UpdateVisibility()
{

View File

@ -20,6 +20,7 @@ using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Edit.Components.Menus;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Design;
using osuTK.Input;
namespace osu.Game.Screens.Edit
{
@ -157,29 +158,19 @@ namespace osu.Game.Screens.Edit
bottomBackground.Colour = colours.Gray2;
}
private void exportBeatmap()
protected override bool OnKeyDown(KeyDownEvent e)
{
host.OpenFileExternally(Beatmap.Value.Save());
}
private void onModeChanged(EditorScreenMode mode)
{
currentScreen?.Exit();
switch (mode)
switch (e.Key)
{
case EditorScreenMode.Compose:
currentScreen = new ComposeScreen();
break;
case EditorScreenMode.Design:
currentScreen = new DesignScreen();
break;
default:
currentScreen = new EditorScreen();
break;
case Key.Left:
seek(e, -1);
return true;
case Key.Right:
seek(e, 1);
return true;
}
LoadComponentAsync(currentScreen, screenContainer.Add);
return base.OnKeyDown(e);
}
private double scrollAccumulation;
@ -193,9 +184,9 @@ namespace osu.Game.Screens.Edit
while (Math.Abs(scrollAccumulation) > precision)
{
if (scrollAccumulation > 0)
clock.SeekBackward(!clock.IsRunning);
seek(e, -1);
else
clock.SeekForward(!clock.IsRunning);
seek(e, 1);
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);
}
@ -224,7 +215,40 @@ namespace osu.Game.Screens.Edit
Beatmap.Value.Track.Tempo.Value = 1;
Beatmap.Value.Track.Start();
}
return base.OnExiting(next);
}
private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());
private void onModeChanged(EditorScreenMode mode)
{
currentScreen?.Exit();
switch (mode)
{
case EditorScreenMode.Compose:
currentScreen = new ComposeScreen();
break;
case EditorScreenMode.Design:
currentScreen = new DesignScreen();
break;
default:
currentScreen = new EditorScreen();
break;
}
LoadComponentAsync(currentScreen, screenContainer.Add);
}
private void seek(UIEvent e, int direction)
{
double amount = e.ShiftPressed ? 2 : 1;
if (direction < 1)
clock.SeekBackward(!clock.IsRunning, amount);
else
clock.SeekForward(!clock.IsRunning, amount);
}
}
}

View File

@ -68,16 +68,20 @@ namespace osu.Game.Screens.Edit
/// Seeks backwards by one beat length.
/// </summary>
/// <param name="snapped">Whether to snap to the closest beat after seeking.</param>
public void SeekBackward(bool snapped = false) => seek(-1, snapped);
/// <param name="amount">The relative amount (magnitude) which should be seeked.</param>
public void SeekBackward(bool snapped = false, double amount = 1) => seek(-1, snapped, amount);
/// <summary>
/// Seeks forwards by one beat length.
/// </summary>
/// <param name="snapped">Whether to snap to the closest beat after seeking.</param>
public void SeekForward(bool snapped = false) => seek(1, snapped);
/// <param name="amount">The relative amount (magnitude) which should be seeked.</param>
public void SeekForward(bool snapped = false, double amount = 1) => seek(1, snapped, amount);
private void seek(int direction, bool snapped)
private void seek(int direction, bool snapped, double amount = 1)
{
if (amount <= 0) throw new ArgumentException("Value should be greater than zero", nameof(amount));
var timingPoint = ControlPointInfo.TimingPointAt(CurrentTime);
if (direction < 0 && timingPoint.Time == CurrentTime)
{
@ -87,7 +91,7 @@ namespace osu.Game.Screens.Edit
timingPoint = ControlPointInfo.TimingPoints[--activeIndex];
}
double seekAmount = timingPoint.BeatLength / beatDivisor;
double seekAmount = timingPoint.BeatLength / beatDivisor * amount;
double seekTime = CurrentTime + seekAmount * direction;
if (!snapped || ControlPointInfo.TimingPoints.Count == 0)

View File

@ -8,12 +8,14 @@ using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Logging;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osuTK;
@ -26,6 +28,8 @@ namespace osu.Game.Screens.Menu
{
public event Action<ButtonSystemState> StateChanged;
private readonly IBindable<bool> isIdle = new BindableBool();
public Action OnEdit;
public Action OnExit;
public Action OnDirect;
@ -102,12 +106,22 @@ namespace osu.Game.Screens.Menu
private OsuGame game;
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuGame game)
private void load(AudioManager audio, OsuGame game, IdleTracker idleTracker)
{
this.game = game;
isIdle.ValueChanged += updateIdleState;
if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle);
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
}
private void updateIdleState(bool isIdle)
{
if (isIdle && State != ButtonSystemState.Exit)
State = ButtonSystemState.Initial;
}
public bool OnPressed(GlobalAction action)
{
switch (action)
@ -266,9 +280,6 @@ namespace osu.Game.Screens.Menu
protected override void Update()
{
//if (OsuGame.IdleTime > 6000 && State != MenuState.Exit)
// State = MenuState.Initial;
base.Update();
if (logo != null)

View File

@ -26,6 +26,8 @@ namespace osu.Game.Screens.Menu
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial;
public override bool AllowExternalScreenChange => true;
private readonly BackgroundScreenDefault background;
private Screen songSelect;

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Screens.Match.Settings;
using osu.Game.Screens.Select;
using osu.Game.Users;
@ -34,11 +35,15 @@ namespace osu.Game.Screens.Multi.Screens.Match
{
this.room = room;
Header header;
RoomSettingsOverlay settings;
Info info;
Children = new Drawable[]
{
header = new Header(),
header = new Header
{
Depth = -1,
},
info = new Info
{
Margin = new MarginPadding { Top = Header.HEIGHT },
@ -48,6 +53,16 @@ namespace osu.Game.Screens.Multi.Screens.Match
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT + Info.HEIGHT },
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = settings = new RoomSettingsOverlay(room)
{
RelativeSizeAxes = Axes.Both,
Height = 0.9f,
},
},
};
header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect());
@ -59,6 +74,20 @@ namespace osu.Game.Screens.Multi.Screens.Match
info.Beatmap = b;
}, true);
header.Tabs.Current.ValueChanged += t =>
{
if (t == MatchHeaderPage.Settings)
settings.Show();
else
settings.Hide();
};
settings.StateChanged += s =>
{
if (s == Visibility.Hidden)
header.Tabs.Current.Value = MatchHeaderPage.Room;
};
nameBind.BindTo(room.Name);
nameBind.BindValueChanged(n => info.Name = n, true);

View File

@ -0,0 +1,110 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components;
using osuTK;
namespace osu.Game.Screens.Multi.Screens.Match.Settings
{
public class GameTypePicker : TabControl<GameType>
{
private const float height = 40;
private const float selection_width = 3;
protected override TabItem<GameType> CreateTabItem(GameType value) => new GameTypePickerItem(value);
protected override Dropdown<GameType> CreateDropdown() => null;
public GameTypePicker()
{
Height = height + selection_width * 2;
TabContainer.Spacing = new Vector2(10 - selection_width * 2);
AddItem(new GameTypeTag());
AddItem(new GameTypeVersus());
AddItem(new GameTypeTagTeam());
AddItem(new GameTypeTeamVersus());
}
private class GameTypePickerItem : TabItem<GameType>
{
private const float transition_duration = 200;
private readonly CircularContainer hover, selection;
public GameTypePickerItem(GameType value) : base(value)
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
selection = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Alpha = 0,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
},
},
new DrawableGameType(Value)
{
Size = new Vector2(height),
Margin = new MarginPadding(selection_width),
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(selection_width),
Child = hover = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Alpha = 0,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
selection.Colour = colours.Yellow;
}
protected override bool OnHover(HoverEvent e)
{
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
hover.FadeOut(transition_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
protected override void OnActivated()
{
selection.FadeIn(transition_duration, Easing.OutQuint);
}
protected override void OnDeactivated()
{
selection.FadeOut(transition_duration, Easing.OutQuint);
}
}
}
}

View File

@ -0,0 +1,105 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Multi.Screens.Match.Settings
{
public class RoomAvailabilityPicker : TabControl<RoomAvailability>
{
protected override TabItem<RoomAvailability> CreateTabItem(RoomAvailability value) => new RoomAvailabilityPickerItem(value);
protected override Dropdown<RoomAvailability> CreateDropdown() => null;
public RoomAvailabilityPicker()
{
RelativeSizeAxes = Axes.X;
Height = 35;
TabContainer.Spacing = new Vector2(10);
AddItem(RoomAvailability.Public);
AddItem(RoomAvailability.FriendsOnly);
AddItem(RoomAvailability.InviteOnly);
}
private class RoomAvailabilityPickerItem : TabItem<RoomAvailability>
{
private const float transition_duration = 200;
private readonly Box hover, selection;
public RoomAvailabilityPickerItem(RoomAvailability value) : base(value)
{
RelativeSizeAxes = Axes.Y;
Width = 120;
Masking = true;
CornerRadius = 5;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"3d3943"),
},
selection = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
hover = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
Alpha = 0,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = @"Exo2.0-Bold",
Text = value.GetDescription(),
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
selection.Colour = colours.GreenLight;
}
protected override bool OnHover(HoverEvent e)
{
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
hover.FadeOut(transition_duration, Easing.OutQuint);
base.OnHoverLost(e);
}
protected override void OnActivated()
{
selection.FadeIn(transition_duration, Easing.OutQuint);
}
protected override void OnDeactivated()
{
selection.FadeOut(transition_duration, Easing.OutQuint);
}
}
}
}

View File

@ -0,0 +1,270 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Multi.Screens.Match.Settings
{
public class RoomSettingsOverlay : FocusedOverlayContainer
{
private const float transition_duration = 350;
private const float field_padding = 45;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Container content;
private readonly OsuSpriteText typeLabel;
protected readonly OsuTextBox NameField, MaxParticipantsField;
protected readonly RoomAvailabilityPicker AvailabilityPicker;
protected readonly GameTypePicker TypePicker;
protected readonly TriangleButton ApplyButton;
public RoomSettingsOverlay(Room room)
{
Masking = true;
Child = content = new Container
{
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Y,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"28242d"),
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 35, Bottom = 75, Horizontal = SearchableListOverlay.WIDTH_PADDING },
Children = new[]
{
new SectionContainer
{
Padding = new MarginPadding { Right = field_padding / 2 },
Children = new[]
{
new Section("ROOM NAME")
{
Child = NameField = new SettingsTextBox
{
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
OnCommit = (sender, text) => apply(),
},
},
new Section("ROOM VISIBILITY")
{
Child = AvailabilityPicker = new RoomAvailabilityPicker(),
},
new Section("GAME TYPE")
{
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(7),
Children = new Drawable[]
{
TypePicker = new GameTypePicker
{
RelativeSizeAxes = Axes.X,
},
typeLabel = new OsuSpriteText
{
TextSize = 14,
},
},
},
},
},
},
new SectionContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Padding = new MarginPadding { Left = field_padding / 2 },
Children = new[]
{
new Section("MAX PARTICIPANTS")
{
Child = MaxParticipantsField = new SettingsNumberTextBox
{
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
OnCommit = (sender, text) => apply(),
},
},
new Section("PASSWORD (OPTIONAL)")
{
Child = new SettingsPasswordTextBox
{
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
OnCommit = (sender, text) => apply(),
},
},
},
},
},
},
ApplyButton = new ApplySettingsButton
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Size = new Vector2(230, 35),
Margin = new MarginPadding { Bottom = 20 },
Action = apply,
},
},
};
TypePicker.Current.ValueChanged += t => typeLabel.Text = t.Name;
nameBind.ValueChanged += n => NameField.Text = n;
availabilityBind.ValueChanged += a => AvailabilityPicker.Current.Value = a;
typeBind.ValueChanged += t => TypePicker.Current.Value = t;
maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString();
nameBind.BindTo(room.Name);
availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type);
maxParticipantsBind.BindTo(room.MaxParticipants);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
typeLabel.Colour = colours.Yellow;
}
protected override void PopIn()
{
// reapply the rooms values if the overlay was completely closed
if (content.Y == -1)
{
nameBind.TriggerChange();
availabilityBind.TriggerChange();
typeBind.TriggerChange();
maxParticipantsBind.TriggerChange();
}
content.MoveToY(0, transition_duration, Easing.OutQuint);
}
protected override void PopOut()
{
content.MoveToY(-1, transition_duration, Easing.InSine);
}
private void apply()
{
nameBind.Value = NameField.Text;
availabilityBind.Value = AvailabilityPicker.Current.Value;
typeBind.Value = TypePicker.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max))
maxParticipantsBind.Value = max;
else
maxParticipantsBind.Value = null;
Hide();
}
private class SettingsTextBox : OsuTextBox
{
protected override Color4 BackgroundUnfocused => Color4.Black;
protected override Color4 BackgroundFocused => Color4.Black;
}
private class SettingsNumberTextBox : SettingsTextBox
{
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
}
private class SettingsPasswordTextBox : OsuPasswordTextBox
{
protected override Color4 BackgroundUnfocused => Color4.Black;
protected override Color4 BackgroundFocused => Color4.Black;
}
private class SectionContainer : FillFlowContainer<Section>
{
public SectionContainer()
{
RelativeSizeAxes = Axes.Both;
Width = 0.5f;
Direction = FillDirection.Vertical;
Spacing = new Vector2(field_padding);
}
}
private class Section : Container
{
private readonly Container content;
protected override Container<Drawable> Content => content;
public Section(string title)
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Children = new Drawable[]
{
new OsuSpriteText
{
TextSize = 12,
Font = @"Exo2.0-Bold",
Text = title.ToUpper(),
},
content = new Container
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
},
};
}
}
private class ApplySettingsButton : TriangleButton
{
public ApplySettingsButton()
{
Text = "Apply";
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = colours.Yellow;
Triangles.ColourLight = colours.YellowLight;
Triangles.ColourDark = colours.YellowDark;
}
}
}
}

View File

@ -34,6 +34,8 @@ namespace osu.Game.Screens
protected virtual bool AllowBackButton => true;
public virtual bool AllowExternalScreenChange => false;
/// <summary>
/// Override to create a BackgroundMode for the current screen.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.

View File

@ -4,7 +4,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Screens.Play.Break

View File

@ -27,6 +27,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Skinning;
using osu.Game.Storyboards.Drawables;
@ -66,6 +67,9 @@ namespace osu.Game.Screens.Play
/// </summary>
private DecoupleableInterpolatingFramedClock adjustableClock;
[Resolved]
private ScoreManager scoreManager { get; set; }
private PauseContainer pauseContainer;
private RulesetInfo ruleset;
@ -272,13 +276,10 @@ namespace osu.Game.Screens.Play
{
if (!IsCurrentScreen) return;
var score = new Score
{
Beatmap = Beatmap.Value.BeatmapInfo,
Ruleset = ruleset
};
ScoreProcessor.PopulateScore(score);
score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value;
var score = CreateScore();
if (RulesetContainer.Replay == null)
scoreManager.Import(score, true);
Push(new Results(score));
onCompletionEvent = null;
@ -286,6 +287,20 @@ namespace osu.Game.Screens.Play
}
}
protected virtual ScoreInfo CreateScore()
{
var score = new ScoreInfo
{
Beatmap = Beatmap.Value.BeatmapInfo,
Ruleset = ruleset,
User = api.LocalUser.Value
};
ScoreProcessor.PopulateScore(score);
return score;
}
private bool onFail()
{
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))

View File

@ -1,23 +1,25 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Replays;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
{
public class ReplayPlayer : Player
{
public Replay Replay;
private readonly Score score;
public ReplayPlayer(Replay replay)
public ReplayPlayer(Score score)
{
Replay = replay;
this.score = score;
}
protected override void LoadComplete()
{
base.LoadComplete();
RulesetContainer.SetReplay(Replay);
RulesetContainer.SetReplay(score.Replay);
}
protected override ScoreInfo CreateScore() => score.ScoreInfo;
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Scoring;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
@ -18,12 +17,13 @@ using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking
{
public class Results : OsuScreen
{
private readonly Score score;
private readonly ScoreInfo score;
private Container circleOuterBackground;
private Container circleOuter;
private Container circleInner;
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Ranking
private const float circle_outer_scale = 0.96f;
public Results(Score score)
public Results(ScoreInfo score)
{
this.score = score;
}

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osuTK;
using osuTK.Graphics;
@ -16,14 +16,14 @@ namespace osu.Game.Screens.Ranking
{
public class ResultsPage : Container
{
protected readonly Score Score;
protected readonly ScoreInfo Score;
protected readonly WorkingBeatmap Beatmap;
private CircularContainer content;
private Box fill;
protected override Container<Drawable> Content => content;
public ResultsPage(Score score, WorkingBeatmap beatmap)
public ResultsPage(ScoreInfo score, WorkingBeatmap beatmap)
{
Score = score;
Beatmap = beatmap;

View File

@ -5,16 +5,16 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Select.Leaderboards;
using osuTK;
using osu.Framework.Graphics.Shapes;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking
{
public class ResultsPageRanking : ResultsPage
{
public ResultsPageRanking(Score score, WorkingBeatmap beatmap = null) : base(score, beatmap)
public ResultsPageRanking(ScoreInfo score, WorkingBeatmap beatmap = null) : base(score, beatmap)
{
}

View File

@ -24,6 +24,7 @@ using osu.Game.Users;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions;
using osu.Framework.Localisation;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking
{
@ -32,7 +33,7 @@ namespace osu.Game.Screens.Ranking
private Container scoreContainer;
private ScoreCounter scoreCounter;
public ResultsPageScore(Score score, WorkingBeatmap beatmap) : base(score, beatmap) { }
public ResultsPageScore(ScoreInfo score, WorkingBeatmap beatmap) : base(score, beatmap) { }
private FillFlowContainer<DrawableScoreStatistic> statisticsContainer;

View File

@ -7,7 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Screens.Select.Leaderboards
{

View File

@ -14,12 +14,12 @@ using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Scoring;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using System.Linq;
using osu.Framework.Configuration;
using osu.Game.Rulesets;
using osu.Game.Scoring;
namespace osu.Game.Screens.Select.Leaderboards
{
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public Action<Score> ScoreSelected;
public Action<ScoreInfo> ScoreSelected;
private readonly LoadingAnimation loading;
@ -42,9 +42,9 @@ namespace osu.Game.Screens.Select.Leaderboards
private bool scoresLoadedOnce;
private IEnumerable<Score> scores;
private IEnumerable<ScoreInfo> scores;
public IEnumerable<Score> Scores
public IEnumerable<ScoreInfo> Scores
{
get { return scores; }
set
@ -179,6 +179,9 @@ namespace osu.Game.Screens.Select.Leaderboards
private APIAccess api;
private BeatmapInfo beatmap;
[Resolved]
private ScoreManager scoreManager { get; set; }
private ScheduledDelegate pendingUpdateScores;
public BeatmapInfo Beatmap
@ -216,6 +219,8 @@ namespace osu.Game.Screens.Select.Leaderboards
api.OnStateChange -= handleApiStateChange;
}
public void RefreshScores() => updateScores();
private GetScoresRequest getScoresRequest;
private void handleApiStateChange(APIState oldState, APIState newState)
@ -242,8 +247,8 @@ namespace osu.Game.Screens.Select.Leaderboards
{
if (Scope == LeaderboardScope.Local)
{
// TODO: get local scores from wherever here.
PlaceholderState = PlaceholderState.NoScores;
Scores = scoreManager.QueryScores(s => s.Beatmap.ID == Beatmap.ID).ToArray();
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
return;
}

View File

@ -14,8 +14,8 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Users;
namespace osu.Game.Screens.Select.Leaderboards
@ -25,7 +25,7 @@ namespace osu.Game.Screens.Select.Leaderboards
public static readonly float HEIGHT = 60;
public readonly int RankPosition;
public readonly Score Score;
public readonly ScoreInfo Score;
private const float corner_radius = 5;
private const float edge_margin = 5;
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private Container flagBadgeContainer;
private FillFlowContainer<ModIcon> modsContainer;
public LeaderboardScore(Score score, int rank)
public LeaderboardScore(ScoreInfo score, int rank)
{
Score = score;
RankPosition = rank;

View File

@ -108,6 +108,8 @@ namespace osu.Game.Screens.Select
removeAutoModOnResume = false;
}
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
base.OnResuming(last);

View File

@ -40,6 +40,8 @@ namespace osu.Game.Screens.Select
protected virtual bool ShowFooter => true;
public override bool AllowExternalScreenChange => true;
/// <summary>
/// Can be null if <see cref="ShowFooter"/> is false.
/// </summary>
@ -503,7 +505,7 @@ namespace osu.Game.Screens.Select
}
}
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetAdded(BeatmapSetInfo s, bool existing, bool silent) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));