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

Move and use shared components

This commit is contained in:
Dean Herbert 2018-08-26 01:24:19 +09:00
parent 40b01ec35a
commit 3d3a7f714d
12 changed files with 35 additions and 62 deletions

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Drawings;
using osu.Game.Tournament.Screens.Drawings.Components;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Screens.Drawings.Components;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Ladder.Components;
namespace osu.Game.Tournament.Tests

View File

@ -7,9 +7,8 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Screens.Drawings.Components;
namespace osu.Game.Tournament.Screens.Ladder.Components
namespace osu.Game.Tournament.Components
{
public abstract class DrawableTournamentTeam : CompositeDrawable
{

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Tournament.Screens.Drawings.Components
namespace osu.Game.Tournament.Components
{
public class TournamentTeam
{

View File

@ -4,13 +4,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Components;
using OpenTK;
using OpenTK.Graphics;
@ -119,21 +117,26 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
return sb.ToString();
}
private class GroupTeam : Container
private class GroupTeam : DrawableTournamentTeam
{
public readonly TournamentTeam Team;
private readonly FillFlowContainer innerContainer;
private readonly Sprite flagSprite;
public GroupTeam(TournamentTeam team)
public GroupTeam(TournamentTeam team) : base(team)
{
Team = team;
Width = 36;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
Flag.Anchor = Anchor.TopCentre;
Flag.Origin = Anchor.TopCentre;
AcronymText.Anchor = Anchor.TopCentre;
AcronymText.Origin = Anchor.TopCentre;
AcronymText.Text = team.Acronym.ToUpperInvariant();
AcronymText.TextSize = 10f;
AcronymText.Font = @"Exo2.0-Bold";
InternalChildren = new Drawable[]
{
innerContainer = new FillFlowContainer
{
@ -148,22 +151,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
Children = new Drawable[]
{
flagSprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
FillMode = FillMode.Fit
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = team.Acronym.ToUpperInvariant(),
TextSize = 10f,
Font = @"Exo2.0-Bold"
}
Flag,
AcronymText
}
}
};
@ -175,12 +164,6 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
innerContainer.ScaleTo(1.5f);
innerContainer.ScaleTo(1f, 200);
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
}
}
}
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Tournament.Components;
using OpenTK;
namespace osu.Game.Tournament.Screens.Drawings.Components

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Screens.Drawings.Components
{

View File

@ -5,14 +5,12 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Threading;
using osu.Game.Tournament.Components;
using OpenTK;
using OpenTK.Graphics;
@ -315,14 +313,11 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
Scrolling
}
public class ScrollingTeam : Container
public class ScrollingTeam : DrawableTournamentTeam
{
public const float WIDTH = 58;
public const float HEIGHT = 41;
public TournamentTeam Team;
private readonly Sprite flagSprite;
private readonly Box outline;
private bool selected;
@ -343,9 +338,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
}
public ScrollingTeam(TournamentTeam team)
: base(team)
{
Team = team;
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
@ -355,28 +349,20 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
Alpha = 0;
Children = new Drawable[]
Flag.Anchor = Anchor.Centre;
Flag.Origin = Anchor.Centre;
Flag.Scale = new Vector2(0.9f);
InternalChildren = new Drawable[]
{
outline = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0
},
flagSprite = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(WIDTH, HEIGHT) - new Vector2(8)
}
Flag
};
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
}
}
}
}

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Screens.Drawings.Components
{

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens;
using osu.Game.Screens.Backgrounds;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Drawings.Components;
using OpenTK;
using OpenTK.Graphics;

View File

@ -9,7 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Tournament.Screens.Drawings.Components;
using osu.Game.Tournament.Components;
using OpenTK;
using OpenTK.Graphics;

View File

@ -2,7 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Configuration;
using osu.Game.Tournament.Screens.Drawings.Components;
using osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Screens.Ladder.Components
{