2018-04-13 09:19:50 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-05-20 10:22:42 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Configuration;
|
2018-05-20 10:22:42 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-09-21 06:08:43 +00:00
|
|
|
|
using OpenTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI
|
|
|
|
|
{
|
2018-06-11 05:36:19 +00:00
|
|
|
|
public class ManiaPlayfield : ManiaScrollingPlayfield
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
|
|
|
|
|
2018-07-17 06:14:03 +00:00
|
|
|
|
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (stageDefinitions == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(stageDefinitions));
|
|
|
|
|
|
|
|
|
|
if (stageDefinitions.Count <= 0)
|
|
|
|
|
throw new ArgumentException("Can't have zero or fewer stages.");
|
|
|
|
|
|
2018-09-21 06:08:43 +00:00
|
|
|
|
Size = new Vector2(1, 0.8f);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
GridContainer playfieldGrid;
|
2018-08-30 04:30:23 +00:00
|
|
|
|
AddInternal(playfieldGrid = new GridContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[] { new Drawable[stageDefinitions.Count] }
|
2018-08-30 04:30:23 +00:00
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
var normalColumnAction = ManiaAction.Key1;
|
|
|
|
|
var specialColumnAction = ManiaAction.Special1;
|
|
|
|
|
int firstColumnIndex = 0;
|
|
|
|
|
for (int i = 0; i < stageDefinitions.Count; i++)
|
|
|
|
|
{
|
2018-07-19 08:04:51 +00:00
|
|
|
|
var newStage = new ManiaStage(firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
newStage.VisibleTimeRange.BindTo(VisibleTimeRange);
|
|
|
|
|
|
|
|
|
|
playfieldGrid.Content[0][i] = newStage;
|
|
|
|
|
|
|
|
|
|
stages.Add(newStage);
|
|
|
|
|
AddNested(newStage);
|
|
|
|
|
|
|
|
|
|
firstColumnIndex += newStage.Columns.Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-19 08:04:51 +00:00
|
|
|
|
public override void Add(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Add(h);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public void Add(BarLine barline) => stages.ForEach(s => s.Add(barline));
|
|
|
|
|
|
|
|
|
|
private ManiaStage getStageByColumn(int column)
|
|
|
|
|
{
|
|
|
|
|
int sum = 0;
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
|
|
|
|
sum = sum + stage.Columns.Count;
|
|
|
|
|
if (sum > column)
|
|
|
|
|
return stage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(ManiaConfigManager maniaConfig)
|
|
|
|
|
{
|
|
|
|
|
maniaConfig.BindWith(ManiaSetting.ScrollTime, VisibleTimeRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|