Skip to content

Commit

Permalink
Merge branch 'master' into no_dt
Browse files Browse the repository at this point in the history
  • Loading branch information
Givikap120 committed Nov 8, 2024
2 parents 3c8bda0 + 8bd65d9 commit d9d3540
Show file tree
Hide file tree
Showing 79 changed files with 1,758 additions and 569 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
# Attempt to upload results even if test fails.
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#always
- name: Upload Test Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: osu-test-results-${{matrix.os.prettyname}}-${{matrix.threadingMode}}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/diffcalc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
master-environment:
name: Save master environment
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.comment.body, '!diffcalc') }}
outputs:
HEAD: ${{ steps.get-head.outputs.HEAD }}
steps:
Expand Down
3 changes: 1 addition & 2 deletions osu.Android/GameplayScreenRotationLocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game;
using osu.Game.Screens.Play;

namespace osu.Android
Expand All @@ -28,7 +27,7 @@ private void updateLock(ValueChangedEvent<LocalUserPlayingState> userPlaying)
{
gameActivity.RunOnUiThread(() =>
{
gameActivity.RequestedOrientation = userPlaying.NewValue != LocalUserPlayingState.NotPlaying ? ScreenOrientation.Locked : gameActivity.DefaultOrientation;
gameActivity.RequestedOrientation = userPlaying.NewValue == LocalUserPlayingState.Playing ? ScreenOrientation.Locked : gameActivity.DefaultOrientation;
});
}
}
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Catch/Edit/CatchEditorPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace osu.Game.Rulesets.Catch.Edit
{
public partial class CatchEditorPlayfield : CatchPlayfield
{
// TODO fixme: the size of the catcher is not changed when circle size is changed in setup screen.
public CatchEditorPlayfield(IBeatmapDifficultyInfo difficulty)
: base(difficulty)
{
Expand Down
30 changes: 30 additions & 0 deletions osu.Game.Rulesets.Catch/Edit/DrawableCatchEditorRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Catch.Edit
{
public partial class DrawableCatchEditorRuleset : DrawableCatchRuleset
{
[Resolved]
private EditorBeatmap editorBeatmap { get; set; } = null!;

public readonly BindableDouble TimeRangeMultiplier = new BindableDouble(1);

public DrawableCatchEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
Expand All @@ -28,6 +34,30 @@ protected override void Update()
TimeRange.Value = gamePlayTimeRange * TimeRangeMultiplier.Value * playfieldStretch;
}

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

editorBeatmap.BeatmapReprocessed += onBeatmapReprocessed;
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

if (editorBeatmap.IsNotNull())
editorBeatmap.BeatmapReprocessed -= onBeatmapReprocessed;
}

private void onBeatmapReprocessed()
{
if (Playfield is CatchEditorPlayfield catchPlayfield)
{
catchPlayfield.Catcher.ApplyDifficulty(editorBeatmap.Difficulty);
catchPlayfield.CatcherArea.CatcherTrails.UpdateCatcherTrailsScale(catchPlayfield.Catcher.BodyScale);
}
}

protected override Playfield CreatePlayfield() => new CatchEditorPlayfield(Beatmap.Difficulty);

public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new CatchEditorPlayfieldAdjustmentContainer();
Expand Down
18 changes: 13 additions & 5 deletions osu.Game.Rulesets.Catch/UI/Catcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public CatcherAnimationState CurrentState
/// <summary>
/// Width of the area that can be used to attempt catches during gameplay.
/// </summary>
public readonly float CatchWidth;
public float CatchWidth { get; private set; }

private readonly SkinnableCatcher body;

Expand All @@ -142,10 +142,7 @@ public Catcher(DroppedObjectContainer droppedObjectTarget, IBeatmapDifficultyInf

Size = new Vector2(BASE_SIZE);

if (difficulty != null)
Scale = calculateScale(difficulty);

CatchWidth = CalculateCatchWidth(Scale);
ApplyDifficulty(difficulty);

InternalChildren = new Drawable[]
{
Expand Down Expand Up @@ -312,6 +309,17 @@ public void SetHyperDashState(double modifier = 1, float targetPosition = -1)
}
}

/// <summary>
/// Set the scale and catch width.
/// </summary>
public void ApplyDifficulty(IBeatmapDifficultyInfo? difficulty)
{
if (difficulty != null)
Scale = calculateScale(difficulty);

CatchWidth = CalculateCatchWidth(Scale);
}

/// <summary>
/// Drop any fruit off the plate.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Catch/UI/CatcherArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Catcher Catcher

private readonly CatchComboDisplay comboDisplay;

private readonly CatcherTrailDisplay catcherTrails;
public readonly CatcherTrailDisplay CatcherTrails;

private Catcher catcher = null!;

Expand All @@ -55,7 +55,7 @@ public CatcherArea()
Children = new Drawable[]
{
catcherContainer = new Container<Catcher> { RelativeSizeAxes = Axes.Both },
catcherTrails = new CatcherTrailDisplay(),
CatcherTrails = new CatcherTrailDisplay(),
comboDisplay = new CatchComboDisplay
{
RelativeSizeAxes = Axes.None,
Expand Down Expand Up @@ -112,7 +112,7 @@ protected override void UpdateAfterChildren()
{
const double trail_generation_interval = 16;

if (Time.Current - catcherTrails.LastDashTrailTime >= trail_generation_interval)
if (Time.Current - CatcherTrails.LastDashTrailTime >= trail_generation_interval)
displayCatcherTrail(Catcher.HyperDashing ? CatcherTrailAnimation.HyperDashing : CatcherTrailAnimation.Dashing);
}

Expand Down Expand Up @@ -170,6 +170,6 @@ public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
}
}

private void displayCatcherTrail(CatcherTrailAnimation animation) => catcherTrails.Add(new CatcherTrailEntry(Time.Current, Catcher.CurrentState, Catcher.X, Catcher.BodyScale, animation));
private void displayCatcherTrail(CatcherTrailAnimation animation) => CatcherTrails.Add(new CatcherTrailEntry(Time.Current, Catcher.CurrentState, Catcher.X, Catcher.BodyScale, animation));
}
}
21 changes: 21 additions & 0 deletions osu.Game.Rulesets.Catch/UI/CatcherTrailDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
Expand All @@ -10,6 +11,7 @@
using osu.Game.Rulesets.Catch.Skinning;
using osu.Game.Rulesets.Objects.Pooling;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Catch.UI
Expand Down Expand Up @@ -55,6 +57,25 @@ public CatcherTrailDisplay()
};
}

/// <summary>
/// Update the scale of all trails.
/// </summary>
/// <param name="scale">The new body scale of the Catcher</param>
public void UpdateCatcherTrailsScale(Vector2 scale)
{
var oldEntries = Entries.ToList();

Clear();

foreach (var oldEntry in oldEntries)
{
// use magnitude of the new scale while preserving the sign of the old one in the X direction.
// the end effect is preserving the direction in which the trail sprites face, which is important.
var targetScale = new Vector2(Math.Abs(scale.X) * Math.Sign(oldEntry.Scale.X), Math.Abs(scale.Y));
Add(new CatcherTrailEntry(oldEntry.LifetimeStart, oldEntry.CatcherState, oldEntry.Position, targetScale, oldEntry.Animation));
}
}

protected override void LoadComplete()
{
base.LoadComplete();
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo s
countMiss = score.Statistics.GetValueOrDefault(HitResult.Miss);
countSliderEndsDropped = osuAttributes.SliderCount - score.Statistics.GetValueOrDefault(HitResult.SliderTailHit);
countSliderTickMiss = score.Statistics.GetValueOrDefault(HitResult.LargeTickMiss);
effectiveMissCount = countMiss;

if (osuAttributes.SliderCount > 0)
{
Expand Down Expand Up @@ -90,6 +91,7 @@ protected override PerformanceAttributes CreatePerformanceAttributes(ScoreInfo s
}

effectiveMissCount = Math.Max(countMiss, effectiveMissCount);
effectiveMissCount = Math.Min(totalHits, effectiveMissCount);

double multiplier = PERFORMANCE_BASE_MULTIPLIER;

Expand Down
88 changes: 69 additions & 19 deletions osu.Game.Rulesets.Osu/Edit/PreciseRotationPopover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Osu.UI;
Expand All @@ -25,13 +26,17 @@ public partial class PreciseRotationPopover : OsuPopover

private readonly OsuGridToolboxGroup gridToolbox;

private readonly Bindable<PreciseRotationInfo> rotationInfo = new Bindable<PreciseRotationInfo>(new PreciseRotationInfo(0, RotationOrigin.GridCentre));
private readonly Bindable<PreciseRotationInfo> rotationInfo = new Bindable<PreciseRotationInfo>(new PreciseRotationInfo(0, EditorOrigin.GridCentre));

private SliderWithTextBoxInput<float> angleInput = null!;
private EditorRadioButtonCollection rotationOrigin = null!;

private RadioButton gridCentreButton = null!;
private RadioButton playfieldCentreButton = null!;
private RadioButton selectionCentreButton = null!;

private Bindable<EditorOrigin> configRotationOrigin = null!;

public PreciseRotationPopover(SelectionRotationHandler rotationHandler, OsuGridToolboxGroup gridToolbox)
{
this.rotationHandler = rotationHandler;
Expand All @@ -41,8 +46,10 @@ public PreciseRotationPopover(SelectionRotationHandler rotationHandler, OsuGridT
}

[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager config)
{
configRotationOrigin = config.GetBindable<EditorOrigin>(OsuSetting.EditorRotationOrigin);

Child = new FillFlowContainer
{
Width = 220,
Expand All @@ -66,14 +73,14 @@ private void load()
RelativeSizeAxes = Axes.X,
Items = new[]
{
new RadioButton("Grid centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.GridCentre },
gridCentreButton = new RadioButton("Grid centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.GridCentre },
() => new SpriteIcon { Icon = FontAwesome.Regular.PlusSquare }),
new RadioButton("Playfield centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.PlayfieldCentre },
playfieldCentreButton = new RadioButton("Playfield centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.PlayfieldCentre },
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
selectionCentreButton = new RadioButton("Selection centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.SelectionCentre },
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.SelectionCentre },
() => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare })
}
}
Expand All @@ -95,13 +102,63 @@ protected override void LoadComplete()
angleInput.SelectAll();
});
angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue });
rotationOrigin.Items.First().Select();

rotationHandler.CanRotateAroundSelectionOrigin.BindValueChanged(e =>
{
selectionCentreButton.Selected.Disabled = !e.NewValue;
}, true);

bool didSelect = false;

configRotationOrigin.BindValueChanged(val =>
{
switch (configRotationOrigin.Value)
{
case EditorOrigin.GridCentre:
if (!gridCentreButton.Selected.Disabled)
{
gridCentreButton.Select();
didSelect = true;
}
break;
case EditorOrigin.PlayfieldCentre:
if (!playfieldCentreButton.Selected.Disabled)
{
playfieldCentreButton.Select();
didSelect = true;
}
break;
case EditorOrigin.SelectionCentre:
if (!selectionCentreButton.Selected.Disabled)
{
selectionCentreButton.Select();
didSelect = true;
}
break;
}
}, true);

if (!didSelect)
rotationOrigin.Items.First(b => !b.Selected.Disabled).Select();

gridCentreButton.Selected.BindValueChanged(b =>
{
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.GridCentre;
});
playfieldCentreButton.Selected.BindValueChanged(b =>
{
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.PlayfieldCentre;
});
selectionCentreButton.Selected.BindValueChanged(b =>
{
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.SelectionCentre;
});

rotationInfo.BindValueChanged(rotation =>
{
rotationHandler.Update(rotation.NewValue.Degrees, getOriginPosition(rotation.NewValue));
Expand All @@ -111,9 +168,9 @@ protected override void LoadComplete()
private Vector2? getOriginPosition(PreciseRotationInfo rotation) =>
rotation.Origin switch
{
RotationOrigin.GridCentre => gridToolbox.StartPosition.Value,
RotationOrigin.PlayfieldCentre => OsuPlayfield.BASE_SIZE / 2,
RotationOrigin.SelectionCentre => null,
EditorOrigin.GridCentre => gridToolbox.StartPosition.Value,
EditorOrigin.PlayfieldCentre => OsuPlayfield.BASE_SIZE / 2,
EditorOrigin.SelectionCentre => null,
_ => throw new ArgumentOutOfRangeException(nameof(rotation))
};

Expand Down Expand Up @@ -143,12 +200,5 @@ public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
}
}

public enum RotationOrigin
{
GridCentre,
PlayfieldCentre,
SelectionCentre
}

public record PreciseRotationInfo(float Degrees, RotationOrigin Origin);
public record PreciseRotationInfo(float Degrees, EditorOrigin Origin);
}
Loading

0 comments on commit d9d3540

Please sign in to comment.