mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
Basic direct panel, minor cleanups
This commit is contained in:
parent
9ba356f2c6
commit
5fb445e3fe
@ -136,7 +136,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
|
||||
public OsuDropdownHeader()
|
||||
{
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(4);
|
||||
|
||||
AutoSizeAxes = Axes.None;
|
||||
|
240
osu.Game/Overlays/Direct/DirectPanel.cs
Normal file
240
osu.Game/Overlays/Direct/DirectPanel.cs
Normal file
@ -0,0 +1,240 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Direct
|
||||
{
|
||||
public class DirectPanel : Container
|
||||
{
|
||||
private readonly float horizontal_padding = 10;
|
||||
private readonly float vertical_padding = 5;
|
||||
|
||||
private readonly Sprite background;
|
||||
private readonly OsuSpriteText title, artist, mapperPrefix, mapper, source;
|
||||
private readonly Statistic playCount, favouriteCount;
|
||||
private readonly FillFlowContainer difficultyIcons;
|
||||
|
||||
private DirectPanelStyle style;
|
||||
public DirectPanelStyle Style
|
||||
{
|
||||
get { return style; }
|
||||
set
|
||||
{
|
||||
if (value == style) return;
|
||||
style = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DirectPanel()
|
||||
{
|
||||
Height = 135 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image)
|
||||
CornerRadius = 4;
|
||||
Masking = true;
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 3f,
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
};
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
background = new Sprite
|
||||
{
|
||||
FillMode = FillMode.Fill,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(0.5f),
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0f, vertical_padding),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Left = horizontal_padding, Right = horizontal_padding },
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new[]
|
||||
{
|
||||
title = new OsuSpriteText
|
||||
{
|
||||
TextSize = 18,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
artist = new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = horizontal_padding },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
mapperPrefix = new OsuSpriteText
|
||||
{
|
||||
Text = @"mapped by ",
|
||||
TextSize = 14,
|
||||
Shadow = false,
|
||||
},
|
||||
mapper = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-SemiBoldItalic",
|
||||
Shadow = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
source = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Shadow = false,
|
||||
},
|
||||
difficultyIcons = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = vertical_padding },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
new Box //todo: placeholder
|
||||
{
|
||||
Size = new Vector2(16f),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding },
|
||||
Children = new[]
|
||||
{
|
||||
playCount = new Statistic(FontAwesome.fa_play_circle)
|
||||
{
|
||||
Margin = new MarginPadding { Right = 1 },
|
||||
},
|
||||
favouriteCount = new Statistic(FontAwesome.fa_heart),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
title.Text = @"Platina";
|
||||
artist.Text = @"Maaya Sakamoto";
|
||||
mapper.Text = @"TicClick";
|
||||
source.Text = @"from Cardcaptor Sakura";
|
||||
playCount.Value = 4579492;
|
||||
favouriteCount.Value = 2659;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures, OsuColour colours)
|
||||
{
|
||||
background.Texture = textures.Get(@"Backgrounds/bg4");
|
||||
|
||||
mapperPrefix.Colour = colours.Gray5;
|
||||
mapper.Colour = colours.BlueDark;
|
||||
source.Colour = colours.Gray5;
|
||||
}
|
||||
|
||||
private class Statistic : FillFlowContainer
|
||||
{
|
||||
private readonly SpriteText text;
|
||||
|
||||
private int value;
|
||||
public int Value
|
||||
{
|
||||
get { return value; }
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
text.Text = string.Format("{0:n0}", Value);
|
||||
}
|
||||
}
|
||||
|
||||
public Statistic(FontAwesome icon, int value = 0)
|
||||
{
|
||||
Anchor = Anchor.TopRight;
|
||||
Origin = Anchor.TopRight;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Horizontal;
|
||||
Spacing = new Vector2(5f, 0f);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-SemiBoldItalic",
|
||||
},
|
||||
new TextAwesome
|
||||
{
|
||||
Icon = icon,
|
||||
Shadow = true,
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Top = 1 },
|
||||
},
|
||||
};
|
||||
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DirectPanelStyle
|
||||
{
|
||||
Grid,
|
||||
List,
|
||||
}
|
||||
}
|
@ -47,8 +47,7 @@ namespace osu.Game.Overlays.Direct
|
||||
public FilterControl()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
//AutoSizeAxes = Axes.Y;
|
||||
Height = 127;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -90,10 +89,10 @@ namespace osu.Game.Overlays.Direct
|
||||
},
|
||||
rankStatusDropdown = new SlimEnumDropdown<RankStatus>
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Margin = new MarginPadding { Top = 93, Bottom = 5, Right = DirectOverlay.WIDTH_PADDING }, //todo: sort of hacky positioning
|
||||
Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING },
|
||||
Width = 160f,
|
||||
},
|
||||
};
|
||||
@ -115,8 +114,16 @@ namespace osu.Game.Overlays.Direct
|
||||
|
||||
private class DirectSearchTextBox : SearchTextBox
|
||||
{
|
||||
protected override Color4 BackgroundUnfocused => OsuColour.FromHex(@"222222");
|
||||
protected override Color4 BackgroundFocused => OsuColour.FromHex(@"222222");
|
||||
protected override Color4 BackgroundUnfocused => backgroundColour;
|
||||
protected override Color4 BackgroundFocused => backgroundColour;
|
||||
|
||||
private Color4 backgroundColour;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
backgroundColour = colours.Gray2;
|
||||
}
|
||||
}
|
||||
|
||||
private class ModeToggleButton : ClickableContainer
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -66,6 +67,13 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
},
|
||||
},
|
||||
new DirectPanel
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Style = DirectPanelStyle.Grid,
|
||||
Width = 300,
|
||||
}
|
||||
};
|
||||
|
||||
filter.Search.Exit = Hide;
|
||||
|
@ -433,6 +433,7 @@
|
||||
<Compile Include="Overlays\Direct\Header.cs" />
|
||||
<Compile Include="Overlays\Direct\SortTabControl.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuEnumDropdown.cs" />
|
||||
<Compile Include="Overlays\Direct\DirectPanel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user