1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Merge branch 'master' into abstract-update-manager

This commit is contained in:
Dan Balasescu 2019-09-25 15:41:45 +09:00 committed by GitHub
commit 213488a25e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 166 additions and 176 deletions

View File

@ -62,6 +62,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.913.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.921.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.924.0" />
</ItemGroup>
</Project>

View File

@ -15,7 +15,6 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
using osuTK;
@ -67,6 +66,8 @@ namespace osu.Game.Rulesets.Mania.Tests
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre));
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.TopCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.BottomCentre));
AddStep("flip direction", () =>
{
@ -76,10 +77,14 @@ namespace osu.Game.Rulesets.Mania.Tests
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.BottomCentre));
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.TopCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.BottomCentre));
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.TopCentre));
}
private bool notesInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor);
private bool barsInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.AllHitObjects.Where(obj => obj is DrawableBarLine).All(o => o.Anchor == anchor);
private void createNote()
{
foreach (var stage in stages)

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mania.Objects
{
public class BarLine : ManiaHitObject, IBarLine
{
public bool Major { get; set; }
}
}

View File

@ -4,7 +4,6 @@
using osuTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;
@ -14,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
/// Visualises a <see cref="BarLine"/>. Although this derives DrawableManiaHitObject,
/// this does not handle input/sound like a normal hit object.
/// </summary>
public class DrawableBarLine : DrawableHitObject<BarLine>
public class DrawableBarLine : DrawableManiaHitObject<BarLine>
{
/// <summary>
/// Height of major bar line triangles.

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.UI
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods)
{
BarLines = new BarLineGenerator(Beatmap).BarLines;
BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
}
[BackgroundDependencyLoader]

View File

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;

View File

@ -12,7 +12,6 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;

View File

@ -53,6 +53,11 @@ namespace osu.Game.Rulesets.Taiko.Tests
AddStep("Strong Rim", () => addRimHit(true));
AddStep("Add bar line", () => addBarLine(false));
AddStep("Add major bar line", () => addBarLine(true));
AddStep("Add centre w/ bar line", () =>
{
addCentreHit(false);
addBarLine(true);
});
AddStep("Height test 1", () => changePlayfieldSize(1));
AddStep("Height test 2", () => changePlayfieldSize(2));
AddStep("Height test 3", () => changePlayfieldSize(3));

View File

@ -0,0 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Objects
{
public class BarLine : TaikoHitObject, IBarLine
{
public bool Major { get; set; }
}
}

View File

@ -5,7 +5,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{

View File

@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Taiko.UI
[BackgroundDependencyLoader]
private void load()
{
new BarLineGenerator(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
}
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Skinning;
using osu.Game.Tests.Visual;
@ -17,6 +18,7 @@ using osuTK.Graphics;
namespace osu.Game.Tests.Skins
{
[TestFixture]
[HeadlessTest]
public class TestSceneSkinConfigurationLookup : OsuTestScene
{
private LegacySkin source1;

View File

@ -6,7 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("create component", () =>
{
LabelledComponent component;
LabelledComponent<Drawable> component;
Child = new Container
{
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = padded ? (LabelledComponent)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
Child = component = padded ? (LabelledComponent<Drawable>)new PaddedLabelledComponent() : new NonPaddedLabelledComponent(),
};
component.Label = "a sample component";
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface
});
}
private class PaddedLabelledComponent : LabelledComponent
private class PaddedLabelledComponent : LabelledComponent<Drawable>
{
public PaddedLabelledComponent()
: base(true)
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.UserInterface
};
}
private class NonPaddedLabelledComponent : LabelledComponent
private class NonPaddedLabelledComponent : LabelledComponent<Drawable>
{
public NonPaddedLabelledComponent()
: base(false)

View File

@ -7,7 +7,8 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Tests.Visual.UserInterface
{
@ -19,6 +20,36 @@ namespace osu.Game.Tests.Visual.UserInterface
typeof(LabelledTextBox),
};
[TestCase(false)]
[TestCase(true)]
public void TestTextBox(bool hasDescription) => createTextBox(hasDescription);
private void createTextBox(bool hasDescription = false)
{
AddStep("create component", () =>
{
LabelledComponent<OsuTextBox> component;
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 500,
AutoSizeAxes = Axes.Y,
Child = component = new LabelledTextBox
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Label = "Testing text",
PlaceholderText = "This is definitely working as intended",
}
};
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
});
}
[BackgroundDependencyLoader]
private void load()
{
@ -32,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
LabelText = "Testing text",
Label = "Testing text",
PlaceholderText = "This is definitely working as intended",
}
};

View File

@ -7,9 +7,9 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
using osu.Game.Tournament.IPC;
using osuTK;
using osuTK.Graphics;
@ -89,7 +89,7 @@ namespace osu.Game.Tournament.Screens
};
}
private class ActionableInfo : LabelledComponent
private class ActionableInfo : LabelledComponent<Drawable>
{
private OsuButton button;

View File

@ -5,13 +5,13 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osuTK;
namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents
namespace osu.Game.Graphics.UserInterfaceV2
{
public abstract class LabelledComponent : CompositeDrawable
public abstract class LabelledComponent<T> : CompositeDrawable
where T : Drawable
{
protected const float CONTENT_PADDING_VERTICAL = 10;
protected const float CONTENT_PADDING_HORIZONTAL = 15;
@ -20,15 +20,15 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents
/// <summary>
/// The component that is being displayed.
/// </summary>
protected readonly Drawable Component;
protected readonly T Component;
private readonly OsuTextFlowContainer labelText;
private readonly OsuTextFlowContainer descriptionText;
/// <summary>
/// Creates a new <see cref="LabelledComponent"/>.
/// Creates a new <see cref="LabelledComponent{T}"/>.
/// </summary>
/// <param name="padded">Whether the component should be padded or should be expanded to the bounds of this <see cref="LabelledComponent"/>.</param>
/// <param name="padded">Whether the component should be padded or should be expanded to the bounds of this <see cref="LabelledComponent{T}"/>.</param>
protected LabelledComponent(bool padded)
{
RelativeSizeAxes = Axes.X;
@ -127,6 +127,6 @@ namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents
/// Creates the component that should be displayed.
/// </summary>
/// <returns>The component.</returns>
protected abstract Drawable CreateComponent();
protected abstract T CreateComponent();
}
}

View File

@ -0,0 +1,49 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterfaceV2
{
public class LabelledTextBox : LabelledComponent<OsuTextBox>
{
public event TextBox.OnCommitHandler OnCommit;
public LabelledTextBox()
: base(false)
{
}
public bool ReadOnly
{
set => Component.ReadOnly = value;
}
public string PlaceholderText
{
set => Component.PlaceholderText = value;
}
public string Text
{
set => Component.Text = value;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Component.BorderColour = colours.Blue;
}
protected override OsuTextBox CreateComponent() => new OsuTextBox
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
CornerRadius = CORNER_RADIUS,
}.With(t => t.OnCommit += (sender, newText) => OnCommit?.Invoke(sender, newText));
}
}

View File

@ -1,16 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Rulesets.Objects
{
/// <summary>
/// A hit object representing the end of a bar.
/// </summary>
public class BarLine : HitObject
{
/// <summary>
/// Whether this barline is a prominent beat (based on time signature of beatmap).
/// </summary>
public bool Major;
}
}

View File

@ -10,12 +10,13 @@ using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects
{
public class BarLineGenerator
public class BarLineGenerator<TBarLine>
where TBarLine : class, IBarLine, new()
{
/// <summary>
/// The generated bar lines.
/// </summary>
public readonly List<BarLine> BarLines = new List<BarLine>();
public readonly List<TBarLine> BarLines = new List<TBarLine>();
/// <summary>
/// Constructs and generates bar lines for provided beatmap.
@ -46,7 +47,7 @@ namespace osu.Game.Rulesets.Objects
for (double t = currentTimingPoint.Time; Precision.DefinitelyBigger(endTime, t); t += barLength, currentBeat++)
{
BarLines.Add(new BarLine
BarLines.Add(new TBarLine
{
StartTime = t,
Major = currentBeat % (int)currentTimingPoint.TimeSignature == 0

View File

@ -0,0 +1,22 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Rulesets.Objects
{
/// <summary>
/// Interface for bar line hitobjects.
/// Used to decouple bar line generation from ruleset-specific rendering/drawing hierarchies.
/// </summary>
public interface IBarLine
{
/// <summary>
/// The time position of the bar.
/// </summary>
double StartTime { set; }
/// <summary>
/// Whether this bar line is a prominent beat (based on time signature of beatmap).
/// </summary>
bool Major { set; }
}
}

View File

@ -1,129 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
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.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Setup.Components.LabelledComponents
{
public class LabelledTextBox : CompositeDrawable
{
private const float label_container_width = 150;
private const float corner_radius = 15;
private const float default_height = 40;
private const float default_label_left_padding = 15;
private const float default_label_top_padding = 12;
private const float default_label_text_size = 16;
public event TextBox.OnCommitHandler OnCommit;
public bool ReadOnly
{
get => textBox.ReadOnly;
set => textBox.ReadOnly = value;
}
public string LabelText
{
get => label.Text;
set => label.Text = value;
}
public float LabelTextSize
{
get => label.Font.Size;
set => label.Font = label.Font.With(size: value);
}
public string PlaceholderText
{
get => textBox.PlaceholderText;
set => textBox.PlaceholderText = value;
}
public string Text
{
get => textBox.Text;
set => textBox.Text = value;
}
public Color4 LabelTextColour
{
get => label.Colour;
set => label.Colour = value;
}
private readonly OsuTextBox textBox;
private readonly OsuSpriteText label;
public LabelledTextBox()
{
RelativeSizeAxes = Axes.X;
Height = default_height;
CornerRadius = corner_radius;
Masking = true;
InternalChild = new Container
{
RelativeSizeAxes = Axes.Both,
CornerRadius = corner_radius,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex("1c2125"),
},
new GridContainer
{
RelativeSizeAxes = Axes.X,
Height = default_height,
Content = new[]
{
new Drawable[]
{
label = new OsuSpriteText
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Padding = new MarginPadding { Left = default_label_left_padding, Top = default_label_top_padding },
Colour = Color4.White,
Font = OsuFont.GetFont(size: default_label_text_size, weight: FontWeight.Bold),
},
textBox = new OsuTextBox
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both,
Height = 1,
CornerRadius = corner_radius,
},
},
},
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, label_container_width),
new Dimension()
}
}
}
};
textBox.OnCommit += OnCommit;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
textBox.BorderColour = colours.Blue;
}
}
}

View File

@ -26,7 +26,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.913.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.921.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.924.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -118,8 +118,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.913.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.921.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.921.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.924.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.924.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />