2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-02 19:30:27 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2016-09-02 19:30:27 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using System;
|
2017-05-03 18:38:15 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-12-28 22:15:12 +08:00
|
|
|
|
using System.Linq;
|
2017-08-23 19:50:03 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-12-28 22:15:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-09-12 16:37:37 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2018-01-03 21:58:08 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2017-12-28 22:15:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-01-04 18:22:15 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2016-09-02 19:30:27 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI
|
2016-09-02 19:30:27 +08:00
|
|
|
|
{
|
2017-09-12 17:19:28 +08:00
|
|
|
|
public class ManiaPlayfield : ScrollingPlayfield
|
2016-09-02 19:30:27 +08:00
|
|
|
|
{
|
2017-05-03 18:38:15 +08:00
|
|
|
|
/// <summary>
|
2018-01-14 10:49:23 +08:00
|
|
|
|
/// <see cref="ManiaStage"/>s contained by this <see cref="ManiaPlayfield"/>.
|
2017-05-03 18:38:15 +08:00
|
|
|
|
/// </summary>
|
2018-01-14 10:49:23 +08:00
|
|
|
|
private readonly FillFlowContainer<ManiaStage> stages;
|
2017-05-03 18:38:15 +08:00
|
|
|
|
|
2017-08-23 19:50:03 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this playfield should be inverted. This flips everything inside the playfield.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly Bindable<bool> Inverted = new Bindable<bool>(true);
|
|
|
|
|
|
2017-12-28 22:40:02 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The style to use for the special column.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public SpecialColumnPosition SpecialColumnPosition
|
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
get => stages.FirstOrDefault()?.SpecialColumnPosition ?? SpecialColumnPosition.Normal;
|
2017-12-28 22:40:02 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
foreach (var singleStage in stages)
|
2017-12-28 22:40:02 +08:00
|
|
|
|
{
|
2018-01-03 22:04:51 +08:00
|
|
|
|
singleStage.SpecialColumnPosition = value;
|
2017-12-28 22:40:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
public List<Column> Columns => stages.SelectMany(x => x.Columns).ToList();
|
2017-09-11 16:53:27 +08:00
|
|
|
|
|
2017-05-03 18:38:15 +08:00
|
|
|
|
private readonly int columnCount;
|
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
public ManiaPlayfield(List<StageDefinition> stageDefinition)
|
2018-01-04 21:05:20 +08:00
|
|
|
|
: base(ScrollingDirection.Up)
|
2016-09-02 19:30:27 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
if (stageDefinition ==null)
|
|
|
|
|
throw new ArgumentNullException();
|
|
|
|
|
|
|
|
|
|
if (stageDefinition.Count <= 0)
|
2017-05-03 11:58:46 +08:00
|
|
|
|
throw new ArgumentException("Can't have zero or fewer columns.");
|
2016-09-02 19:30:27 +08:00
|
|
|
|
|
2017-08-23 19:50:03 +08:00
|
|
|
|
Inverted.Value = true;
|
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
var stageSpacing = 300 / stageDefinition.Count;
|
2018-01-10 22:47:38 +08:00
|
|
|
|
|
2017-08-07 13:56:26 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
this.stages = new FillFlowContainer<ManiaStage>
|
2016-09-02 19:30:27 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
Name = "Stages",
|
2017-12-28 22:15:12 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2017-09-11 09:46:54 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2017-12-28 22:15:12 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-01-10 22:47:38 +08:00
|
|
|
|
Spacing = new Vector2(stageSpacing),
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-03 21:58:08 +08:00
|
|
|
|
var currentAction = ManiaAction.Key1;
|
2017-12-28 21:40:23 +08:00
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
foreach (var stage in stageDefinition)
|
2017-12-28 21:40:23 +08:00
|
|
|
|
{
|
2018-01-14 10:41:52 +08:00
|
|
|
|
var drawableStage = new ManiaStage();
|
2018-01-03 22:04:51 +08:00
|
|
|
|
drawableStage.VisibleTimeRange.BindTo(VisibleTimeRange);
|
2017-12-28 21:40:23 +08:00
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
this.stages.Add(drawableStage);
|
2018-01-03 22:04:51 +08:00
|
|
|
|
AddNested(drawableStage);
|
2017-12-28 21:40:23 +08:00
|
|
|
|
|
2018-01-03 21:58:08 +08:00
|
|
|
|
for (int i = 0; i < stage.Columns; i++)
|
2017-12-28 22:40:02 +08:00
|
|
|
|
{
|
2018-01-03 21:58:08 +08:00
|
|
|
|
var c = new Column
|
|
|
|
|
{
|
|
|
|
|
//c.Action = c.IsSpecial ? ManiaAction.Special : currentAction++;
|
|
|
|
|
Action = currentAction++
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-03 22:04:51 +08:00
|
|
|
|
drawableStage.AddColumn(c);
|
2018-01-03 21:58:08 +08:00
|
|
|
|
AddNested(c);
|
|
|
|
|
}
|
2017-08-07 13:56:26 +08:00
|
|
|
|
}
|
2017-08-23 19:50:03 +08:00
|
|
|
|
|
|
|
|
|
Inverted.ValueChanged += invertedChanged;
|
|
|
|
|
Inverted.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void invertedChanged(bool newValue)
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(1, newValue ? -1 : 1);
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
foreach (var single in stages)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-12-28 21:40:23 +08:00
|
|
|
|
single.Judgements.Scale = Scale;
|
2017-05-03 18:38:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-03 11:37:47 +08:00
|
|
|
|
|
2017-09-12 16:37:37 +08:00
|
|
|
|
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
2017-09-11 16:53:27 +08:00
|
|
|
|
{
|
2017-09-12 16:37:37 +08:00
|
|
|
|
var maniaObject = (ManiaHitObject)judgedObject.HitObject;
|
2017-12-28 21:40:23 +08:00
|
|
|
|
int column = maniaObject.Column;
|
2018-01-03 21:58:08 +08:00
|
|
|
|
Columns[column].OnJudgement(judgedObject, judgement);
|
2017-09-11 16:53:27 +08:00
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
getStageByColumn(column).AddJudgement(judgement);
|
2017-09-11 16:53:27 +08:00
|
|
|
|
}
|
2017-09-11 11:57:10 +08:00
|
|
|
|
|
2017-12-28 21:40:23 +08:00
|
|
|
|
public override void Add(DrawableHitObject h) => Columns.ElementAt(((ManiaHitObject)h.HitObject).Column).Add(h);
|
|
|
|
|
|
|
|
|
|
public void Add(BarLine barline)
|
2017-05-03 18:38:15 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
foreach (var single in stages)
|
2017-05-03 11:37:47 +08:00
|
|
|
|
{
|
2017-12-28 21:40:23 +08:00
|
|
|
|
single.HitObjects.Add(new DrawableBarLine(barline));
|
2017-05-03 11:37:47 +08:00
|
|
|
|
}
|
2017-12-28 22:15:12 +08:00
|
|
|
|
}
|
2017-09-12 17:19:28 +08:00
|
|
|
|
|
2018-01-14 10:49:23 +08:00
|
|
|
|
private ManiaStage getStageByColumn(int column)
|
2017-05-29 13:44:42 +08:00
|
|
|
|
{
|
2017-12-28 21:40:23 +08:00
|
|
|
|
int sum = 0;
|
2018-01-14 10:49:23 +08:00
|
|
|
|
foreach (var stage in stages)
|
2017-12-28 21:40:23 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
sum = sum + stage.Columns.Count();
|
|
|
|
|
if (sum > column)
|
2017-12-28 21:40:23 +08:00
|
|
|
|
{
|
2018-01-14 10:49:23 +08:00
|
|
|
|
return stage;
|
2017-12-28 21:40:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2017-05-29 13:44:42 +08:00
|
|
|
|
}
|
2016-09-02 19:30:27 +08:00
|
|
|
|
}
|
2017-05-03 12:03:46 +08:00
|
|
|
|
}
|