Skip to content

Commit

Permalink
Merge branch 'master' into update-libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte authored May 11, 2022
2 parents 3cbd19a + 4531d13 commit a97986d
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2022.1.0-eap10",
"version": "2022.1.1",
"commands": [
"jb"
]
Expand All @@ -27,4 +27,4 @@
]
}
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/inspectcode
key: inspectcode-${{ hashFiles('.config/dotnet-tools.json') }}-${{ hashFiles('.github/workflows/ci.yml' ) }}
key: inspectcode-${{ hashFiles('.config/dotnet-tools.json', '.github/workflows/ci.yml', 'osu.sln*', '.editorconfig', '.globalconfig') }}

- name: Dotnet code style
run: dotnet build -c Debug -warnaserror osu.Desktop.slnf -p:EnforceCodeStyleInBuild=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
Expand Down Expand Up @@ -66,6 +67,13 @@ public override void SetUpSteps()
});
}

[Test]
public void TestPopoverHasFocus()
{
clickDifficultyPiece(0);
velocityPopoverHasFocus();
}

[Test]
public void TestSingleSelection()
{
Expand Down Expand Up @@ -133,6 +141,15 @@ private void clickDifficultyPiece(int objectIndex) => AddStep($"click {objectInd
InputManager.Click(MouseButton.Left);
});

private void velocityPopoverHasFocus() => AddUntilStep("velocity popover textbox focused", () =>
{
var popover = this.ChildrenOfType<DifficultyPointPiece.DifficultyEditPopover>().SingleOrDefault();
var slider = popover?.ChildrenOfType<IndeterminateSliderWithTextBoxInput<double>>().Single();
var textbox = slider?.ChildrenOfType<OsuTextBox>().Single();

return textbox?.HasFocus == true;
});

private void velocityPopoverHasSingleValue(double velocity) => AddUntilStep($"velocity popover has {velocity}", () =>
{
var popover = this.ChildrenOfType<DifficultyPointPiece.DifficultyEditPopover>().SingleOrDefault();
Expand All @@ -151,6 +168,7 @@ private void velocityPopoverHasIndeterminateValue() => AddUntilStep("velocity po

private void dismissPopover()
{
AddStep("unfocus textbox", () => InputManager.Key(Key.Escape));
AddStep("dismiss popover", () => InputManager.Key(Key.Escape));
AddUntilStep("wait for dismiss", () => !this.ChildrenOfType<DifficultyPointPiece.DifficultyEditPopover>().Any(popover => popover.IsPresent));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public override void SetUpSteps()
});
}

[Test]
public void TestPopoverHasFocus()
{
clickSamplePiece(0);
samplePopoverHasFocus();
}

[Test]
public void TestSingleSelection()
{
Expand Down Expand Up @@ -173,14 +180,23 @@ public void TestMultipleSelectionWithDifferentSampleBank()
samplePopoverHasSingleBank("normal");
}

private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} difficulty piece", () =>
private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} sample piece", () =>
{
var difficultyPiece = this.ChildrenOfType<SamplePointPiece>().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex));
var samplePiece = this.ChildrenOfType<SamplePointPiece>().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex));

InputManager.MoveMouseTo(difficultyPiece);
InputManager.MoveMouseTo(samplePiece);
InputManager.Click(MouseButton.Left);
});

private void samplePopoverHasFocus() => AddUntilStep("sample popover textbox focused", () =>
{
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().SingleOrDefault();
var slider = popover?.ChildrenOfType<IndeterminateSliderWithTextBoxInput<int>>().Single();
var textbox = slider?.ChildrenOfType<OsuTextBox>().Single();

return textbox?.HasFocus == true;
});

private void samplePopoverHasSingleVolume(int volume) => AddUntilStep($"sample popover has volume {volume}", () =>
{
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().SingleOrDefault();
Expand Down Expand Up @@ -215,8 +231,9 @@ private void samplePopoverHasIndeterminateBank() => AddUntilStep("sample popover

private void dismissPopover()
{
AddStep("unfocus textbox", () => InputManager.Key(Key.Escape));
AddStep("dismiss popover", () => InputManager.Key(Key.Escape));
AddUntilStep("wait for dismiss", () => !this.ChildrenOfType<DifficultyPointPiece.DifficultyEditPopover>().Any(popover => popover.IsPresent));
AddUntilStep("wait for dismiss", () => !this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().Any(popover => popover.IsPresent));
}

private void setVolumeViaPopover(int volume) => AddStep($"set volume {volume} via popover", () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ private void load()
beatmap.EndChange();
});
}

protected override void LoadComplete()
{
base.LoadComplete();
ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(sliderVelocitySlider));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ private void load()
volume.Current.BindValueChanged(val => updateVolumeFor(relevantObjects, val.NewValue));
}

protected override void LoadComplete()
{
base.LoadComplete();
ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(volume));
}

private static string? getCommonBank(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleBank).Distinct().Count() == 1 ? relevantControlPoints.First().SampleBank : null;
private static int? getCommonVolume(SampleControlPoint[] relevantControlPoints) => relevantControlPoints.Select(point => point.SampleVolume).Distinct().Count() == 1 ? (int?)relevantControlPoints.First().SampleVolume : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,9 @@ private void scrollToTrackTime()
protected override bool OnMouseDown(MouseDownEvent e)
{
if (base.OnMouseDown(e))
{
beginUserDrag();
return true;
}

return false;
return true;
}

protected override void OnMouseUp(MouseUpEvent e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays.Settings;
Expand Down Expand Up @@ -107,6 +108,14 @@ public IndeterminateSliderWithTextBoxInput(LocalisableString labelText, Bindable
Current.BindValueChanged(_ => updateState(), true);
}

public override bool AcceptsFocus => true;

protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);
GetContainingInputManager().ChangeFocus(textBox);
}

private void updateState()
{
if (Current.Value is T nonNullValue)
Expand Down
12 changes: 10 additions & 2 deletions osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class MultiplayerPlayer : RoomSubmittingPlayer

private readonly MultiplayerRoomUser[] users;

private readonly Bindable<bool> leaderboardExpanded = new BindableBool();

private LoadingLayer loadingDisplay;
private FillFlowContainer leaderboardFlow;

Expand Down Expand Up @@ -76,13 +78,16 @@ private void load()
Spacing = new Vector2(5)
});

HUDOverlay.HoldingForHUD.BindValueChanged(_ => updateLeaderboardExpandedState());
LocalUserPlaying.BindValueChanged(_ => updateLeaderboardExpandedState(), true);

// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(GameplayState.Ruleset.RulesetInfo, ScoreProcessor, users), l =>
{
if (!LoadedBeatmapSuccessfully)
return;

((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
leaderboard.Expanded.BindTo(leaderboardExpanded);

leaderboardFlow.Insert(0, l);

Expand All @@ -99,7 +104,7 @@ private void load()

LoadComponentAsync(new GameplayChatDisplay(Room)
{
Expanded = { BindTarget = HUDOverlay.ShowHud },
Expanded = { BindTarget = leaderboardExpanded },
}, chat => leaderboardFlow.Insert(2, chat));

HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
Expand Down Expand Up @@ -152,6 +157,9 @@ protected override void StartGameplay()
}
}

private void updateLeaderboardExpandedState() =>
leaderboardExpanded.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;

private void failAndBail(string message = null)
{
if (!string.IsNullOrEmpty(message))
Expand Down
16 changes: 9 additions & 7 deletions osu.Game/Screens/Play/HUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>

internal readonly IBindable<bool> IsPlaying = new Bindable<bool>();

private bool holdingForHUD;
public IBindable<bool> HoldingForHUD => holdingForHUD;

private readonly BindableBool holdingForHUD = new BindableBool();

private readonly SkinnableTargetContainer mainComponents;

Expand Down Expand Up @@ -144,14 +146,16 @@ private void load(OsuConfigManager config, INotificationOverlay notificationOver
hideTargets.ForEach(d => d.Hide());
}

public override void Hide() => throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");
public override void Hide() =>
throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");

protected override void LoadComplete()
{
base.LoadComplete();

ShowHud.BindValueChanged(visible => hideTargets.ForEach(d => d.FadeTo(visible.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING)));

holdingForHUD.BindValueChanged(_ => updateVisibility());
IsPlaying.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);

Expand Down Expand Up @@ -204,7 +208,7 @@ private void updateVisibility()
if (ShowHud.Disabled)
return;

if (holdingForHUD)
if (holdingForHUD.Value)
{
ShowHud.Value = true;
return;
Expand Down Expand Up @@ -287,8 +291,7 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.HoldForHUD:
holdingForHUD = true;
updateVisibility();
holdingForHUD.Value = true;
return true;

case GlobalAction.ToggleInGameInterface:
Expand Down Expand Up @@ -318,8 +321,7 @@ public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.HoldForHUD:
holdingForHUD = false;
updateVisibility();
holdingForHUD.Value = false;
break;
}
}
Expand Down

0 comments on commit a97986d

Please sign in to comment.