From 28da60cc3853491b737014362ab9eebce00e1ab2 Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Thu, 28 Dec 2017 22:40:23 +0900 Subject: [PATCH 1/9] https://github.com/ppy/osu/issues/716 1. split the playfield columns by ManiaModKeyCoop 2. can chaneg the key number by ManiaKeyMod --- .../Mods/ManiaModGravity.cs | 6 +- .../Tests/TestCaseManiaPlayfield.cs | 6 +- osu.Game.Rulesets.Mania/UI/Column.cs | 4 +- .../UI/ManiaColumnGroup.cs | 213 ++++++++++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 230 ++++++------------ .../UI/ManiaRulesetContainer.cs | 30 ++- .../osu.Game.Rulesets.Mania.csproj | 1 + 7 files changed, 325 insertions(+), 165 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index 70270af6c9..dc80cea562 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -35,9 +35,9 @@ namespace osu.Game.Rulesets.Mania.Mods } // Like with hit objects, we need to generate one speed adjustment per bar line - foreach (DrawableBarLine barLine in rulesetContainer.BarLines) + foreach (BarLine barLine in rulesetContainer.BarLines) { - var controlPoint = rulesetContainer.CreateControlPointAt(barLine.HitObject.StartTime); + var controlPoint = rulesetContainer.CreateControlPointAt(barLine.StartTime); // Beat length has too large of an effect for gravity, so we'll force it to a constant value for now controlPoint.TimingPoint.BeatLength = 1000; @@ -45,4 +45,4 @@ namespace osu.Game.Rulesets.Mania.Mods } } } -} \ No newline at end of file +} diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs index 1932038411..88727df405 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs @@ -83,11 +83,11 @@ namespace osu.Game.Rulesets.Mania.Tests Add(inputManager); ManiaPlayfield playfield; - inputManager.Add(playfield = new ManiaPlayfield(cols) + inputManager.Add(playfield = new ManiaPlayfield(cols, false) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - SpecialColumnPosition = specialPos + //SpecialColumnPosition = specialPos }); playfield.Inverted.Value = inverted; @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Tests Add(inputManager); ManiaPlayfield playfield; - inputManager.Add(playfield = new ManiaPlayfield(4) + inputManager.Add(playfield = new ManiaPlayfield(4,false) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 2d553f8639..6140452bb3 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Hit target + hit objects", RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = ManiaPlayfield.HIT_TARGET_POSITION }, + Padding = new MarginPadding { Top = ManiaColumnGroup.HIT_TARGET_POSITION }, Children = new Drawable[] { new Container @@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Key", RelativeSizeAxes = Axes.X, - Height = ManiaPlayfield.HIT_TARGET_POSITION, + Height = ManiaColumnGroup.HIT_TARGET_POSITION, Children = new Drawable[] { new Box diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs new file mode 100644 index 0000000000..a37fa913bc --- /dev/null +++ b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Game.Graphics; +using osu.Framework.Allocation; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.Timing; + +namespace osu.Game.Rulesets.Mania.UI +{ + /// + /// controls that from up to down + /// + internal class ManiaColumnGroup : ScrollingPlayfield + { + public const float HIT_TARGET_POSITION = 50; + + private SpecialColumnPosition specialColumnPosition; + + /// + /// The style to use for the special column. + /// + public SpecialColumnPosition SpecialColumnPosition + { + get { return specialColumnPosition; } + set + { + if (IsLoaded) + throw new InvalidOperationException($"Setting {nameof(SpecialColumnPosition)} after the playfield is loaded requires re-creating the playfield."); + specialColumnPosition = value; + } + } + + private readonly FillFlowContainer columns; + public IEnumerable Columns => columns.Children; + + protected override Container Content => content; + private readonly Container content; + + private readonly Container judgements; + public Container Judgements => judgements; + + private readonly Container topLevelContainer; + public Container TopLevelContainer => topLevelContainer; + + private List normalColumnColours = new List(); + private Color4 specialColumnColour; + + public int ColumnCount { get; protected set; } + + public ManiaColumnGroup(int columnCount) : base(Axes.Y) + { + ColumnCount = columnCount; + Name = "Playfield elements"; + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + //RelativeSizeAxes = Axes.Y; + //AutoSizeAxes = Axes.X; + InternalChildren = new Drawable[] + { + new Container + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Children = new Drawable[] + { + new Container + { + Name = "Columns mask", + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Masking = true, + Children = new Drawable[] + { + new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + Colour = new Color4(0,0,0,0.8f) + }, + columns = new FillFlowContainer + { + Name = "Columns", + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + }, + } + }, + new Container + { + Name = "Barlines mask", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y, + Width = 1366, // Bar lines should only be masked on the vertical axis + BypassAutoSizeAxes = Axes.Both, + Masking = true, + Child = content = new Container + { + Name = "Bar lines", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y, + Padding = new MarginPadding { Top = HIT_TARGET_POSITION } + } + }, + judgements = new Container + { + Anchor = Anchor.TopCentre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Y = HIT_TARGET_POSITION + 150, + BypassAutoSizeAxes = Axes.Both + }, + topLevelContainer = new Container { RelativeSizeAxes = Axes.Both } + } + } + + }; + } + + /// + /// Whether the column index is a special column for this playfield. + /// + /// The 0-based column index. + /// Whether the column is a special column. + private bool isSpecialColumn(int column) + { + switch (SpecialColumnPosition) + { + default: + case SpecialColumnPosition.Normal: + return ColumnCount % 2 == 1 && column == ColumnCount / 2; + case SpecialColumnPosition.Left: + return column == 0; + case SpecialColumnPosition.Right: + return column == ColumnCount - 1; + } + } + + public void AddColumn(Column c) + { + c.VisibleTimeRange.BindTo(VisibleTimeRange); + topLevelContainer.Add(c.TopLevelContainer.CreateProxy()); + columns.Add(c); + } + + public void AddJudgement(Judgement judgement) + { + judgements.Clear(); + judgements.Add(new DrawableManiaJudgement(judgement) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + normalColumnColours = new List + { + colours.RedDark, + colours.GreenDark + }; + + specialColumnColour = colours.BlueDark; + + // Set the special column + colour + key + foreach (var column in Columns) + { + if (!column.IsSpecial) + continue; + + column.AccentColour = specialColumnColour; + } + + var nonSpecialColumns = Columns.Where(c => !c.IsSpecial).ToList(); + + // We'll set the colours of the non-special columns in a separate loop, because the non-special + // column colours are mirrored across their centre and special styles mess with this + for (int i = 0; i < Math.Ceiling(nonSpecialColumns.Count / 2f); i++) + { + Color4 colour = normalColumnColours[i % normalColumnColours.Count]; + nonSpecialColumns[i].AccentColour = colour; + nonSpecialColumns[nonSpecialColumns.Count - 1 - i].AccentColour = colour; + } + } + + + protected override void Update() + { + // Due to masking differences, it is not possible to get the width of the columns container automatically + // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually + content.Width = columns.Width; + } + } +} diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 6c164a34f0..ffa74b6ba9 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -17,48 +17,43 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Judgements; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.MathUtils; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.UI { public class ManiaPlayfield : ScrollingPlayfield { - public const float HIT_TARGET_POSITION = 50; - private SpecialColumnPosition specialColumnPosition; /// - /// The style to use for the special column. + /// list mania column group /// - public SpecialColumnPosition SpecialColumnPosition - { - get { return specialColumnPosition; } - set - { - if (IsLoaded) - throw new InvalidOperationException($"Setting {nameof(SpecialColumnPosition)} after the playfield is loaded requires re-creating the playfield."); - specialColumnPosition = value; - } - } + FillFlowContainer ListColumnGroup = new FillFlowContainer(); /// /// Whether this playfield should be inverted. This flips everything inside the playfield. /// public readonly Bindable Inverted = new Bindable(true); - private readonly FlowContainer columns; - public IEnumerable Columns => columns.Children; - - protected override Container Content => content; - private readonly Container content; - - private List normalColumnColours = new List(); - private Color4 specialColumnColour; - - private readonly Container judgements; + public List Columns + { + get + { + var list = new List(); + foreach (var single in ListColumnGroup) + { + list.AddRange(single.Columns); + } + return list; + } + } private readonly int columnCount; - public ManiaPlayfield(int columnCount) - : base(Axes.Y) + public ManiaPlayfield(int columnCount,bool coop): base(Axes.Y) { this.columnCount = columnCount; @@ -67,172 +62,103 @@ namespace osu.Game.Rulesets.Mania.UI Inverted.Value = true; - Container topLevelContainer; InternalChildren = new Drawable[] { - new Container + ListColumnGroup=new FillFlowContainer() { - Name = "Playfield elements", - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + Direction= FillDirection.Horizontal, RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Children = new Drawable[] - { - new Container - { - Name = "Columns mask", - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Masking = true, - Children = new Drawable[] - { - new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - columns = new FillFlowContainer - { - Name = "Columns", - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) - }, - } - }, - new Container - { - Name = "Barlines mask", - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - Width = 1366, // Bar lines should only be masked on the vertical axis - BypassAutoSizeAxes = Axes.Both, - Masking = true, - Child = content = new Container - { - Name = "Bar lines", - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - Padding = new MarginPadding { Top = HIT_TARGET_POSITION } - } - }, - judgements = new Container - { - Anchor = Anchor.TopCentre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Y = HIT_TARGET_POSITION + 150, - BypassAutoSizeAxes = Axes.Both - }, - topLevelContainer = new Container { RelativeSizeAxes = Axes.Both } - } + Anchor= Anchor.Centre, + Origin= Anchor.Centre, + Spacing=new Vector2(400), } }; + int numberOfGroup = 1; + if (coop) + numberOfGroup = 2; + + for (int i = 0; i < numberOfGroup; i ++) + { + var group = new ManiaColumnGroup(columnCount / numberOfGroup) + { + + }; + ListColumnGroup.Add(group); + } + + + foreach (var single in ListColumnGroup) + { + single.VisibleTimeRange.BindTo(this.VisibleTimeRange); + AddNested(single); + } + var currentAction = ManiaAction.Key1; for (int i = 0; i < columnCount; i++) { var c = new Column(); - c.VisibleTimeRange.BindTo(VisibleTimeRange); + //c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; + c.Action = currentAction++; + /* c.IsSpecial = isSpecialColumn(i); - c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; - topLevelContainer.Add(c.TopLevelContainer.CreateProxy()); - columns.Add(c); + */ + getFallDownControlContainerByActualColumn(i).AddColumn(c); AddNested(c); } Inverted.ValueChanged += invertedChanged; Inverted.TriggerChange(); + } private void invertedChanged(bool newValue) { Scale = new Vector2(1, newValue ? -1 : 1); - judgements.Scale = Scale; - } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - normalColumnColours = new List + //judgements.Scale = Scale; + foreach (var single in ListColumnGroup) { - colours.RedDark, - colours.GreenDark - }; - - specialColumnColour = colours.BlueDark; - - // Set the special column + colour + key - foreach (var column in Columns) - { - if (!column.IsSpecial) - continue; - - column.AccentColour = specialColumnColour; - } - - var nonSpecialColumns = Columns.Where(c => !c.IsSpecial).ToList(); - - // We'll set the colours of the non-special columns in a separate loop, because the non-special - // column colours are mirrored across their centre and special styles mess with this - for (int i = 0; i < Math.Ceiling(nonSpecialColumns.Count / 2f); i++) - { - Color4 colour = normalColumnColours[i % normalColumnColours.Count]; - nonSpecialColumns[i].AccentColour = colour; - nonSpecialColumns[nonSpecialColumns.Count - 1 - i].AccentColour = colour; + single.Judgements.Scale = Scale; } } public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { var maniaObject = (ManiaHitObject)judgedObject.HitObject; - columns[maniaObject.Column].OnJudgement(judgedObject, judgement); + int column = maniaObject.Column; + Columns[maniaObject.Column].OnJudgement(judgedObject, judgement); - judgements.Clear(); - judgements.Add(new DrawableManiaJudgement(judgement) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }); - } - - /// - /// Whether the column index is a special column for this playfield. - /// - /// The 0-based column index. - /// Whether the column is a special column. - private bool isSpecialColumn(int column) - { - switch (SpecialColumnPosition) - { - default: - case SpecialColumnPosition.Normal: - return columnCount % 2 == 1 && column == columnCount / 2; - case SpecialColumnPosition.Left: - return column == 0; - case SpecialColumnPosition.Right: - return column == columnCount - 1; - } + getFallDownControlContainerByActualColumn(column).AddJudgement(judgement); } public override void Add(DrawableHitObject h) => Columns.ElementAt(((ManiaHitObject)h.HitObject).Column).Add(h); - public void Add(DrawableBarLine barline) => HitObjects.Add(barline); - - protected override void Update() + public void Add(BarLine barline) { - // Due to masking differences, it is not possible to get the width of the columns container automatically - // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually - content.Width = columns.Width; + //HitObjects.Add(new DrawableBarLine(barline)); + foreach (var single in ListColumnGroup) + { + single.HitObjects.Add(new DrawableBarLine(barline)); + } + } + + private ManiaColumnGroup getFallDownControlContainerByActualColumn(int actualColumn) + { + int sum = 0; + foreach (var single in ListColumnGroup) + { + sum = sum + single.ColumnCount; + if (sum > actualColumn) + { + return single; + } + } + + return null; } } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 61446a31b6..7ea9382314 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -24,6 +24,7 @@ using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.Mania.Mods; namespace osu.Game.Rulesets.Mania.UI { @@ -35,7 +36,12 @@ namespace osu.Game.Rulesets.Mania.UI /// public int AvailableColumns { get; private set; } - public IEnumerable BarLines; + /// + /// Co-op + /// + public bool Coop { get; set; } = false; + + public IEnumerable BarLines; public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(ruleset, beatmap, isForCurrentRuleset) @@ -44,7 +50,7 @@ namespace osu.Game.Rulesets.Mania.UI double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; var timingPoints = Beatmap.ControlPointInfo.TimingPoints; - var barLines = new List(); + var barLines = new List(); for (int i = 0; i < timingPoints.Count; i++) { @@ -56,12 +62,12 @@ namespace osu.Game.Rulesets.Mania.UI int index = 0; for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) { - barLines.Add(new DrawableBarLine(new BarLine + barLines.Add(new BarLine { StartTime = t, ControlPoint = point, BeatIndex = index - })); + }); } } @@ -74,7 +80,7 @@ namespace osu.Game.Rulesets.Mania.UI BarLines.ForEach(Playfield.Add); } - protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(AvailableColumns) + protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(AvailableColumns, Coop) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -101,6 +107,20 @@ namespace osu.Game.Rulesets.Mania.UI AvailableColumns = Math.Max(4, Math.Min((int)Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty) + 1, 7)); } + //get mods to change column and coop + foreach (var single in this.WorkingBeatmap.Mods.Value) + { + if (single is ManiaKeyMod maniaKeyMod) + { + AvailableColumns = maniaKeyMod.KeyCount; + } + if (single is ManiaModKeyCoop) + { + Coop = true; + AvailableColumns = AvailableColumns * 2; + } + } + return new ManiaBeatmapConverter(IsForCurrentRuleset, AvailableColumns); } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index bdd6656ed9..564af6e454 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -92,6 +92,7 @@ + From cfc4c39255e6e4c475691ba01cee0c121aa8a74b Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Thu, 28 Dec 2017 22:57:41 +0900 Subject: [PATCH 2/9] Fixed the alert from AppVeyor. maybe. --- osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs | 9 ++++++--- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 5 +---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs index a37fa913bc..fa4820f996 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Collections.Generic; using OpenTK; using OpenTK.Graphics; @@ -41,14 +44,14 @@ namespace osu.Game.Rulesets.Mania.UI } } - private readonly FillFlowContainer columns; public IEnumerable Columns => columns.Children; + private readonly FillFlowContainer columns; protected override Container Content => content; private readonly Container content; - private readonly Container judgements; public Container Judgements => judgements; + private readonly Container judgements; private readonly Container topLevelContainer; public Container TopLevelContainer => topLevelContainer; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ffa74b6ba9..7658638b5a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -80,10 +80,7 @@ namespace osu.Game.Rulesets.Mania.UI for (int i = 0; i < numberOfGroup; i ++) { - var group = new ManiaColumnGroup(columnCount / numberOfGroup) - { - - }; + var group = new ManiaColumnGroup(columnCount / numberOfGroup); ListColumnGroup.Add(group); } From a322c15bbd5dac9bff9f89e86eda797e709f2c53 Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Thu, 28 Dec 2017 23:15:12 +0900 Subject: [PATCH 3/9] =?UTF-8?q?after=20resharper=20:=20(=20.=20=E8=A3=9D?= =?UTF-8?q?=E4=B8=8AResharper=EF=BC=8C=E5=BE=9E=E6=AD=A4VS=E7=9A=84?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E4=B8=80=E7=89=87=E9=BB=91=E6=9A=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/DrawableManiaJudgement.cs | 2 +- .../UI/ManiaColumnGroup.cs | 19 +++----- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 46 ++++++++----------- .../UI/ManiaRulesetContainer.cs | 6 +-- 4 files changed, 29 insertions(+), 44 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs index 08478cef33..6a8e904537 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mania.UI internal class DrawableManiaJudgement : DrawableJudgement { public DrawableManiaJudgement(Judgement judgement) - : base(judgement) + : base(judgement) { JudgementText.TextSize = 25; } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs index fa4820f996..952deef6e8 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs @@ -3,21 +3,16 @@ using System; using System.Collections.Generic; -using OpenTK; -using OpenTK.Graphics; +using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Game.Graphics; -using osu.Framework.Allocation; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.UI; -using osu.Game.Rulesets.Timing; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Rulesets.Mania.UI { @@ -61,7 +56,8 @@ namespace osu.Game.Rulesets.Mania.UI public int ColumnCount { get; protected set; } - public ManiaColumnGroup(int columnCount) : base(Axes.Y) + public ManiaColumnGroup(int columnCount) + : base(Axes.Y) { ColumnCount = columnCount; Name = "Playfield elements"; @@ -91,7 +87,7 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Background", RelativeSizeAxes = Axes.Both, - Colour = new Color4(0,0,0,0.8f) + Colour = new Color4(0, 0, 0, 0.8f) }, columns = new FillFlowContainer { @@ -133,7 +129,6 @@ namespace osu.Game.Rulesets.Mania.UI topLevelContainer = new Container { RelativeSizeAxes = Axes.Both } } } - }; } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 7658638b5a..d47d3b4299 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -1,33 +1,23 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Graphics.Containers; -using System; -using osu.Game.Graphics; -using osu.Framework.Allocation; -using System.Linq; -using System.Collections.Generic; -using osu.Framework.Configuration; -using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Mania.Objects.Drawables; -using osu.Framework.Graphics.Shapes; -using osu.Game.Rulesets.Judgements; -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Objects.Types; -using osu.Game.Beatmaps.ControlPoints; -using osu.Framework.MathUtils; -using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.UI { public class ManiaPlayfield : ScrollingPlayfield { - /// /// list mania column group /// @@ -53,7 +43,8 @@ namespace osu.Game.Rulesets.Mania.UI private readonly int columnCount; - public ManiaPlayfield(int columnCount,bool coop): base(Axes.Y) + public ManiaPlayfield(int columnCount, bool coop) + : base(Axes.Y) { this.columnCount = columnCount; @@ -64,13 +55,13 @@ namespace osu.Game.Rulesets.Mania.UI InternalChildren = new Drawable[] { - ListColumnGroup=new FillFlowContainer() + ListColumnGroup = new FillFlowContainer() { - Direction= FillDirection.Horizontal, + Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Y, - Anchor= Anchor.Centre, - Origin= Anchor.Centre, - Spacing=new Vector2(400), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Spacing = new Vector2(400), } }; @@ -78,7 +69,7 @@ namespace osu.Game.Rulesets.Mania.UI if (coop) numberOfGroup = 2; - for (int i = 0; i < numberOfGroup; i ++) + for (int i = 0; i < numberOfGroup; i++) { var group = new ManiaColumnGroup(columnCount / numberOfGroup); ListColumnGroup.Add(group); @@ -87,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.UI foreach (var single in ListColumnGroup) { - single.VisibleTimeRange.BindTo(this.VisibleTimeRange); + single.VisibleTimeRange.BindTo(VisibleTimeRange); AddNested(single); } @@ -109,7 +100,6 @@ namespace osu.Game.Rulesets.Mania.UI Inverted.ValueChanged += invertedChanged; Inverted.TriggerChange(); - } private void invertedChanged(bool newValue) @@ -141,7 +131,7 @@ namespace osu.Game.Rulesets.Mania.UI { single.HitObjects.Add(new DrawableBarLine(barline)); } - } + } private ManiaColumnGroup getFallDownControlContainerByActualColumn(int actualColumn) { diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 7ea9382314..4bed527cbc 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; @@ -13,6 +12,7 @@ using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Replays; @@ -24,7 +24,7 @@ using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI; -using osu.Game.Rulesets.Mania.Mods; +using OpenTK; namespace osu.Game.Rulesets.Mania.UI { @@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Mania.UI } //get mods to change column and coop - foreach (var single in this.WorkingBeatmap.Mods.Value) + foreach (var single in WorkingBeatmap.Mods.Value) { if (single is ManiaKeyMod maniaKeyMod) { From 9faa5fb199f1209d5c91927b8209cf23f497f1cd Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Thu, 28 Dec 2017 23:40:02 +0900 Subject: [PATCH 4/9] pray --- .../Mods/ManiaModGravity.cs | 1 - .../Tests/TestCaseManiaPlayfield.cs | 3 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 43 ++++++++++++------- .../UI/ManiaRulesetContainer.cs | 2 +- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs index dc80cea562..6e5290e277 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModGravity.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Mods; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Timing; using osu.Game.Rulesets.Timing; -using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Mods { diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs index 88727df405..7b13f1f7fc 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Timing; using osu.Game.Rulesets.Mania.Judgements; @@ -87,7 +86,7 @@ namespace osu.Game.Rulesets.Mania.Tests { Anchor = Anchor.Centre, Origin = Anchor.Centre, - //SpecialColumnPosition = specialPos + SpecialColumnPosition = specialPos }); playfield.Inverted.Value = inverted; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d47d3b4299..e9b5b835ef 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -21,19 +21,34 @@ namespace osu.Game.Rulesets.Mania.UI /// /// list mania column group /// - FillFlowContainer ListColumnGroup = new FillFlowContainer(); + private FillFlowContainer listColumnGroup; /// /// Whether this playfield should be inverted. This flips everything inside the playfield. /// public readonly Bindable Inverted = new Bindable(true); + /// + /// The style to use for the special column. + /// + public SpecialColumnPosition SpecialColumnPosition + { + get => listColumnGroup.FirstOrDefault()?.SpecialColumnPosition ?? SpecialColumnPosition.Normal; + set + { + foreach (var singleGroup in listColumnGroup) + { + singleGroup.SpecialColumnPosition = value; + } + } + } + public List Columns { get { var list = new List(); - foreach (var single in ListColumnGroup) + foreach (var single in listColumnGroup) { list.AddRange(single.Columns); } @@ -41,13 +56,9 @@ namespace osu.Game.Rulesets.Mania.UI } } - private readonly int columnCount; - public ManiaPlayfield(int columnCount, bool coop) : base(Axes.Y) { - this.columnCount = columnCount; - if (columnCount <= 0) throw new ArgumentException("Can't have zero or fewer columns."); @@ -55,7 +66,7 @@ namespace osu.Game.Rulesets.Mania.UI InternalChildren = new Drawable[] { - ListColumnGroup = new FillFlowContainer() + listColumnGroup = new FillFlowContainer { Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Y, @@ -72,11 +83,11 @@ namespace osu.Game.Rulesets.Mania.UI for (int i = 0; i < numberOfGroup; i++) { var group = new ManiaColumnGroup(columnCount / numberOfGroup); - ListColumnGroup.Add(group); + listColumnGroup.Add(group); } - foreach (var single in ListColumnGroup) + foreach (var single in listColumnGroup) { single.VisibleTimeRange.BindTo(VisibleTimeRange); AddNested(single); @@ -85,9 +96,11 @@ namespace osu.Game.Rulesets.Mania.UI var currentAction = ManiaAction.Key1; for (int i = 0; i < columnCount; i++) { - var c = new Column(); - //c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; - c.Action = currentAction++; + var c = new Column + { + //c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; + Action = currentAction++ + }; /* c.IsSpecial = isSpecialColumn(i); @@ -107,7 +120,7 @@ namespace osu.Game.Rulesets.Mania.UI Scale = new Vector2(1, newValue ? -1 : 1); //judgements.Scale = Scale; - foreach (var single in ListColumnGroup) + foreach (var single in listColumnGroup) { single.Judgements.Scale = Scale; } @@ -127,7 +140,7 @@ namespace osu.Game.Rulesets.Mania.UI public void Add(BarLine barline) { //HitObjects.Add(new DrawableBarLine(barline)); - foreach (var single in ListColumnGroup) + foreach (var single in listColumnGroup) { single.HitObjects.Add(new DrawableBarLine(barline)); } @@ -136,7 +149,7 @@ namespace osu.Game.Rulesets.Mania.UI private ManiaColumnGroup getFallDownControlContainerByActualColumn(int actualColumn) { int sum = 0; - foreach (var single in ListColumnGroup) + foreach (var single in listColumnGroup) { sum = sum + single.ColumnCount; if (sum > actualColumn) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 4bed527cbc..ccaed69312 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.UI /// /// Co-op /// - public bool Coop { get; set; } = false; + public bool Coop { get; set; } public IEnumerable BarLines; From 7b94a710e3bb9d3221c7c900e44971293ff6e73f Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Thu, 28 Dec 2017 23:55:06 +0900 Subject: [PATCH 5/9] Appveyor Chan, Please --- osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs | 3 +-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs index 952deef6e8..1e88b240b5 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs @@ -49,12 +49,11 @@ namespace osu.Game.Rulesets.Mania.UI private readonly Container judgements; private readonly Container topLevelContainer; - public Container TopLevelContainer => topLevelContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; - public int ColumnCount { get; protected set; } + public readonly int ColumnCount; public ManiaColumnGroup(int columnCount) : base(Axes.Y) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index e9b5b835ef..a5c5979057 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.UI /// /// list mania column group /// - private FillFlowContainer listColumnGroup; + private readonly FillFlowContainer listColumnGroup; /// /// Whether this playfield should be inverted. This flips everything inside the playfield. From 5326f71ed9b776a6ab152aac5670628367102720 Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Wed, 3 Jan 2018 22:58:08 +0900 Subject: [PATCH 6/9] fix some error that smoogipoo says --- .../Tests/TestCaseManiaPlayfield.cs | 14 +++- osu.Game.Rulesets.Mania/UI/Column.cs | 4 +- ...aniaColumnGroup.cs => ManiaColumnStage.cs} | 6 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 78 ++++++++----------- .../UI/ManiaRulesetContainer.cs | 7 +- .../osu.Game.Rulesets.Mania.csproj | 2 +- 6 files changed, 52 insertions(+), 59 deletions(-) rename osu.Game.Rulesets.Mania/UI/{ManiaColumnGroup.cs => ManiaColumnStage.cs} (95%) diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs index e9e5d98fb8..defe1a6ba6 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs @@ -2,11 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Timing; +using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; @@ -82,7 +84,11 @@ namespace osu.Game.Rulesets.Mania.Tests Add(inputManager); ManiaPlayfield playfield; - inputManager.Add(playfield = new ManiaPlayfield(cols, false) + var stages = new List() + { + new StageDefinition() { Columns = cols }, + }; + inputManager.Add(playfield = new ManiaPlayfield(stages) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -104,7 +110,11 @@ namespace osu.Game.Rulesets.Mania.Tests Add(inputManager); ManiaPlayfield playfield; - inputManager.Add(playfield = new ManiaPlayfield(4,false) + var stages = new List() + { + new StageDefinition() { Columns = 4 }, + }; + inputManager.Add(playfield = new ManiaPlayfield(stages) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 6140452bb3..f9535bd58c 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Hit target + hit objects", RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = ManiaColumnGroup.HIT_TARGET_POSITION }, + Padding = new MarginPadding { Top = ManiaColumnStage.HIT_TARGET_POSITION }, Children = new Drawable[] { new Container @@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Key", RelativeSizeAxes = Axes.X, - Height = ManiaColumnGroup.HIT_TARGET_POSITION, + Height = ManiaColumnStage.HIT_TARGET_POSITION, Children = new Drawable[] { new Box diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs b/osu.Game.Rulesets.Mania/UI/ManiaColumnStage.cs similarity index 95% rename from osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs rename to osu.Game.Rulesets.Mania/UI/ManiaColumnStage.cs index 1e88b240b5..c0ee3536ff 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaColumnGroup.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaColumnStage.cs @@ -17,9 +17,9 @@ using OpenTK.Graphics; namespace osu.Game.Rulesets.Mania.UI { /// - /// controls that from up to down + /// A collection of s. /// - internal class ManiaColumnGroup : ScrollingPlayfield + internal class ManiaColumnStage : ScrollingPlayfield { public const float HIT_TARGET_POSITION = 50; @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly int ColumnCount; - public ManiaColumnGroup(int columnCount) + public ManiaColumnStage(int columnCount) : base(Axes.Y) { ColumnCount = columnCount; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index a5c5979057..8003738562 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -8,6 +8,7 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; 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.Drawables; @@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Mania.UI /// /// list mania column group /// - private readonly FillFlowContainer listColumnGroup; + private readonly FillFlowContainer listColumnStages; /// /// Whether this playfield should be inverted. This flips everything inside the playfield. @@ -33,10 +34,10 @@ namespace osu.Game.Rulesets.Mania.UI /// public SpecialColumnPosition SpecialColumnPosition { - get => listColumnGroup.FirstOrDefault()?.SpecialColumnPosition ?? SpecialColumnPosition.Normal; + get => listColumnStages.FirstOrDefault()?.SpecialColumnPosition ?? SpecialColumnPosition.Normal; set { - foreach (var singleGroup in listColumnGroup) + foreach (var singleGroup in listColumnStages) { singleGroup.SpecialColumnPosition = value; } @@ -48,25 +49,25 @@ namespace osu.Game.Rulesets.Mania.UI get { var list = new List(); - foreach (var single in listColumnGroup) + foreach (var stage in listColumnStages) { - list.AddRange(single.Columns); + list.AddRange(stage.Columns); } return list; } } - public ManiaPlayfield(int columnCount, bool coop) + public ManiaPlayfield(List stages) : base(Axes.Y) { - if (columnCount <= 0) + if (stages.Count <= 0) throw new ArgumentException("Can't have zero or fewer columns."); Inverted.Value = true; InternalChildren = new Drawable[] { - listColumnGroup = new FillFlowContainer + listColumnStages = new FillFlowContainer { Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Y, @@ -76,39 +77,27 @@ namespace osu.Game.Rulesets.Mania.UI } }; - int numberOfGroup = 1; - if (coop) - numberOfGroup = 2; - - for (int i = 0; i < numberOfGroup; i++) - { - var group = new ManiaColumnGroup(columnCount / numberOfGroup); - listColumnGroup.Add(group); - } - - - foreach (var single in listColumnGroup) - { - single.VisibleTimeRange.BindTo(VisibleTimeRange); - AddNested(single); - } - var currentAction = ManiaAction.Key1; - for (int i = 0; i < columnCount; i++) - { - var c = new Column - { - //c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; - Action = currentAction++ - }; - /* - c.IsSpecial = isSpecialColumn(i); - topLevelContainer.Add(c.TopLevelContainer.CreateProxy()); - columns.Add(c); - */ - getFallDownControlContainerByActualColumn(i).AddColumn(c); - AddNested(c); + foreach (var stage in stages) + { + var group = new ManiaColumnStage(stage.Columns); + group.VisibleTimeRange.BindTo(VisibleTimeRange); + + listColumnStages.Add(group); + AddNested(group); + + for (int i = 0; i < stage.Columns; i++) + { + var c = new Column + { + //c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++; + Action = currentAction++ + }; + + group.AddColumn(c); + AddNested(c); + } } Inverted.ValueChanged += invertedChanged; @@ -120,7 +109,7 @@ namespace osu.Game.Rulesets.Mania.UI Scale = new Vector2(1, newValue ? -1 : 1); //judgements.Scale = Scale; - foreach (var single in listColumnGroup) + foreach (var single in listColumnStages) { single.Judgements.Scale = Scale; } @@ -130,7 +119,7 @@ namespace osu.Game.Rulesets.Mania.UI { var maniaObject = (ManiaHitObject)judgedObject.HitObject; int column = maniaObject.Column; - Columns[maniaObject.Column].OnJudgement(judgedObject, judgement); + Columns[column].OnJudgement(judgedObject, judgement); getFallDownControlContainerByActualColumn(column).AddJudgement(judgement); } @@ -139,17 +128,16 @@ namespace osu.Game.Rulesets.Mania.UI public void Add(BarLine barline) { - //HitObjects.Add(new DrawableBarLine(barline)); - foreach (var single in listColumnGroup) + foreach (var single in listColumnStages) { single.HitObjects.Add(new DrawableBarLine(barline)); } } - private ManiaColumnGroup getFallDownControlContainerByActualColumn(int actualColumn) + private ManiaColumnStage getFallDownControlContainerByActualColumn(int actualColumn) { int sum = 0; - foreach (var single in listColumnGroup) + foreach (var single in listColumnStages) { sum = sum + single.ColumnCount; if (sum > actualColumn) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 53fd60b58f..ef611bb591 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -31,11 +31,6 @@ namespace osu.Game.Rulesets.Mania.UI { public new ManiaBeatmap Beatmap => (ManiaBeatmap)base.Beatmap; - /// - /// Co-op - /// - public bool Coop { get; set; } - public IEnumerable BarLines; public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset) @@ -75,7 +70,7 @@ namespace osu.Game.Rulesets.Mania.UI BarLines.ForEach(Playfield.Add); } - protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.TotalColumns) + protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index ca94a9eb7e..1a8211b719 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -94,7 +94,7 @@ - + From a855a21ccbf6a054911b337e12243b1e63ca2f90 Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Wed, 3 Jan 2018 23:04:51 +0900 Subject: [PATCH 7/9] group -> stage --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 8003738562..66e866af38 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mania.UI public class ManiaPlayfield : ScrollingPlayfield { /// - /// list mania column group + /// list mania column stages /// private readonly FillFlowContainer listColumnStages; @@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Mania.UI get => listColumnStages.FirstOrDefault()?.SpecialColumnPosition ?? SpecialColumnPosition.Normal; set { - foreach (var singleGroup in listColumnStages) + foreach (var singleStage in listColumnStages) { - singleGroup.SpecialColumnPosition = value; + singleStage.SpecialColumnPosition = value; } } } @@ -81,11 +81,11 @@ namespace osu.Game.Rulesets.Mania.UI foreach (var stage in stages) { - var group = new ManiaColumnStage(stage.Columns); - group.VisibleTimeRange.BindTo(VisibleTimeRange); + var drawableStage = new ManiaColumnStage(stage.Columns); + drawableStage.VisibleTimeRange.BindTo(VisibleTimeRange); - listColumnStages.Add(group); - AddNested(group); + listColumnStages.Add(drawableStage); + AddNested(drawableStage); for (int i = 0; i < stage.Columns; i++) { @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.UI Action = currentAction++ }; - group.AddColumn(c); + drawableStage.AddColumn(c); AddNested(c); } } @@ -108,7 +108,6 @@ namespace osu.Game.Rulesets.Mania.UI { Scale = new Vector2(1, newValue ? -1 : 1); - //judgements.Scale = Scale; foreach (var single in listColumnStages) { single.Judgements.Scale = Scale; From aadafae8cbc4f4403d2d732b970f968e52659aee Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Wed, 3 Jan 2018 23:47:05 +0900 Subject: [PATCH 8/9] 1. fix TestCaseManiaHitObjects broken 2. add (4+4) (2+4+2) (1+8+1) column stages step in TestCaseManiaPlayfield --- .../Tests/TestCaseManiaHitObjects.cs | 2 +- .../Tests/TestCaseManiaPlayfield.cs | 48 ++++++++++++++++--- .../UI/ManiaRulesetContainer.cs | 1 - 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaHitObjects.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaHitObjects.cs index 03886f5784..48974b4bb8 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaHitObjects.cs @@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.Tests RelativeChildSize = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote(), ManiaAction.Key1) + new DrawableHoldNote(new HoldNote(){Duration = 1000}, ManiaAction.Key1) { Y = 5000, Height = 1000, diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs index defe1a6ba6..c77a0cd2a9 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs @@ -41,6 +41,36 @@ namespace osu.Game.Rulesets.Mania.Tests AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); + AddStep("4 + 4 columns", () => + { + var stages = new List() + { + new StageDefinition() { Columns = 4 }, + new StageDefinition() { Columns = 4 }, + }; + createPlayfield(stages, SpecialColumnPosition.Normal); + }); + AddStep("2 + 4 + 2 columns", () => + { + var stages = new List() + { + new StageDefinition() { Columns = 2 }, + new StageDefinition() { Columns = 4 }, + new StageDefinition() { Columns = 2 }, + }; + createPlayfield(stages, SpecialColumnPosition.Normal); + }); + AddStep("1 + 1 + 8 columns", () => + { + var stages = new List() + { + new StageDefinition() { Columns = 1 }, + new StageDefinition() { Columns = 8 }, + new StageDefinition() { Columns = 1 }, + }; + createPlayfield(stages, SpecialColumnPosition.Normal); + }); + AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); AddStep("Reversed", () => createPlayfield(4, SpecialColumnPosition.Normal, true)); @@ -78,16 +108,22 @@ namespace osu.Game.Rulesets.Mania.Tests private ManiaPlayfield createPlayfield(int cols, SpecialColumnPosition specialPos, bool inverted = false) { - Clear(); - - var inputManager = new ManiaInputManager(maniaRuleset, cols) { RelativeSizeAxes = Axes.Both }; - Add(inputManager); - - ManiaPlayfield playfield; var stages = new List() { new StageDefinition() { Columns = cols }, }; + return createPlayfield(stages, specialPos, inverted); + } + + private ManiaPlayfield createPlayfield(List stages, SpecialColumnPosition specialPos, bool inverted = false) + { + Clear(); + + var inputManager = new ManiaInputManager(maniaRuleset, stages.Sum(g => g.Columns)) { RelativeSizeAxes = Axes.Both }; + Add(inputManager); + + ManiaPlayfield playfield; + inputManager.Add(playfield = new ManiaPlayfield(stages) { Anchor = Anchor.Centre, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index ef611bb591..26db5aa5b0 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -11,7 +11,6 @@ using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mania.Beatmaps; -using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Replays; From 409664e4dc99887ff72fe6ec63ef89b4b770985b Mon Sep 17 00:00:00 2001 From: "ANDY840119-PC\\andy840119" Date: Wed, 3 Jan 2018 23:50:52 +0900 Subject: [PATCH 9/9] White space needs to be trimmed --- osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs index c77a0cd2a9..37161a7d3d 100644 --- a/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/Tests/TestCaseManiaPlayfield.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.Tests AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); - AddStep("4 + 4 columns", () => + AddStep("4 + 4 columns", () => { var stages = new List() {