Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Color4.Gray.Opacity(0.4f) instead of hoverbox #120

Merged
merged 4 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Circle.Game.Tests/Visual/Objects/TestScenePlanet.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Circle.Game.Rulesets.Objects;
using Circle.Game.Rulesets.Extensions;
using Circle.Game.Rulesets.Extensions;
using Circle.Game.Rulesets.Objects;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
Expand Down
6 changes: 3 additions & 3 deletions Circle.Game/Configuration/CircleConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public override TrackedSettings CreateTrackedSettings()
value: $"{blur}"
)
),
new TrackedSetting<bool>(CircleSetting.Parallax, papallax => new SettingDescription(
rawValue: papallax,
new TrackedSetting<bool>(CircleSetting.Parallax, parallax => new SettingDescription(
rawValue: parallax,
name: "Parallax",
value: $"{papallax}"
value: $"{parallax}"
)
)
};
Expand Down
2 changes: 1 addition & 1 deletion Circle.Game/Graphics/Containers/ParallaxContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ParallaxContainer : Container, IRequireHighFrequencyMousePosition

private Bindable<bool> parallaxEnabled;

private const float parallax_duration = 100;
private const float parallax_duration = 1000;

private bool firstUpdate = true;

Expand Down
25 changes: 9 additions & 16 deletions Circle.Game/Graphics/UserInterface/CircleButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ namespace Circle.Game.Graphics.UserInterface
{
public class CircleButton : ClickableContainer
{
private readonly Box hover;
private readonly Box box;
private Sample hoverSample;
private Sample clickSample;

private readonly bool useBackground;

protected new Container Content;

public new float CornerRadius
Expand All @@ -26,27 +28,18 @@ public class CircleButton : ClickableContainer

public CircleButton(bool useBackground = true)
{
this.useBackground = useBackground;
Child = Content = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 5,
Children = new Drawable[]
Child = box = new Box
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.4f),
Alpha = useBackground ? 1 : 0
},
hover = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Alpha = 0
}
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(useBackground ? 0.4f : 0),
}
};
}
Expand All @@ -62,7 +55,7 @@ private void load(AudioManager audio)
protected override bool OnHover(HoverEvent e)
{
hoverSample?.Play();
hover.FadeTo(0.25f, 250, Easing.OutQuint);
box.FadeColour(Color4.Gray.Opacity(0.4f), 250, Easing.OutQuint);

return base.OnHover(e);
}
Expand All @@ -71,7 +64,7 @@ protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);

hover.FadeTo(0, 500, Easing.OutQuint);
box.FadeColour(Color4.Black.Opacity(useBackground ? 0.4f : 0), 500, Easing.OutQuint);
}

protected override bool OnMouseDown(MouseDownEvent e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace Circle.Game.Graphics.UserInterface
{
internal class CircleDirectorySelectorDirectory : DirectorySelectorDirectory
{
private Box hover;

public CircleDirectorySelectorDirectory(DirectoryInfo directory, string displayName = null)
: base(directory, displayName)
{
Expand All @@ -32,13 +30,6 @@ private void load()
{
new Background
{
Depth = 2
},
hover = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Depth = 1
}
});
Expand All @@ -50,32 +41,34 @@ private void load()
? FontAwesome.Solid.Database
: FontAwesome.Regular.Folder;

protected override bool OnHover(HoverEvent e)
{
hover.FadeTo(0.25f, 250, Easing.OutQuint);

return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);

hover.FadeTo(0, 500, Easing.OutQuint);
}

internal class Background : CompositeDrawable
{
private Box box;

[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
InternalChild = new Box
InternalChild = box = new Box
{
Colour = Color4.Black.Opacity(0.4f),
RelativeSizeAxes = Axes.Both,
};
}

protected override bool OnHover(HoverEvent e)
{
box.FadeColour(Color4.Gray.Opacity(0.4f), 250, Easing.OutQuint);

return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);

box.FadeColour(Color4.Black.Opacity(0.4f), 250, Easing.OutQuint);
}
}
}
}
8 changes: 4 additions & 4 deletions Circle.Game/Graphics/UserInterface/CircleDropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ protected class CircleDropdownMenu : DropdownMenu
private Sample? sampleOpen;
private Sample? sampleClose;

// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
// todo: this uses the same styling as CircleMenu. hopefully we can just use CircleMenu in the future with some refactoring
public CircleDropdownMenu()
{
CornerRadius = corner_radius;

MaskingContainer.CornerRadius = corner_radius;
Alpha = 0;

// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
// todo: this uses the same styling as CircleMenu. hopefully we can just use CircleMenu in the future with some refactoring
ItemsContainer.Padding = new MarginPadding(5);
}

Expand All @@ -76,8 +76,8 @@ private void load(AudioManager audio)
HoverColour = Color4.DeepSkyBlue.Opacity(0.6f);
SelectionColour = Color4.DeepSkyBlue.Opacity(0.8f);

sampleOpen = audio.Samples.Get(@"overlay-pop-in");
sampleClose = audio.Samples.Get(@"overlay-pop-out");
sampleOpen = audio.Samples.Get(@"dropdown-open");
sampleClose = audio.Samples.Get(@"dropdown-close");
}

// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
Expand Down
26 changes: 0 additions & 26 deletions Circle.Game/Graphics/UserInterface/CircleFileSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
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.UserInterface;
using osu.Framework.Input.Events;
using osuTK.Graphics;

namespace Circle.Game.Graphics.UserInterface
{
Expand Down Expand Up @@ -38,8 +35,6 @@ private void load()

protected class CircleDirectoryListingFile : DirectoryListingFile
{
private Box hover;

public CircleDirectoryListingFile(FileInfo file)
: base(file)
{
Expand All @@ -57,32 +52,11 @@ private void load()
{
new CircleDirectorySelectorDirectory.Background
{
Depth = 2
},
hover = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Depth = 1
}
});
}

protected override bool OnHover(HoverEvent e)
{
hover.FadeTo(0.25f, 250, Easing.OutQuint);

return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);

hover.FadeTo(0, 500, Easing.OutQuint);
}

protected override IconUsage? Icon
{
get
Expand Down
10 changes: 5 additions & 5 deletions Circle.Game/Rulesets/Objects/Planet.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using osu.Framework.Graphics;
using Circle.Game.Utils;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using Shape = osu.Framework.Graphics.Shapes;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Bindables;
using Circle.Game.Utils;
using osu.Framework.Allocation;
using Shape = osu.Framework.Graphics.Shapes;

namespace Circle.Game.Rulesets.Objects
{
Expand Down
Binary file modified Circle.Resources/Samples/button-click.wav
Binary file not shown.
Binary file modified Circle.Resources/Samples/button-hover.wav
Binary file not shown.
Binary file added Circle.Resources/Samples/dropdown-close.wav
Binary file not shown.
Binary file added Circle.Resources/Samples/dropdown-open.wav
Binary file not shown.