Skip to content

Commit

Permalink
Implement club overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Jul 24, 2024
1 parent 6073c09 commit d6d15a2
Show file tree
Hide file tree
Showing 14 changed files with 881 additions and 3 deletions.
18 changes: 18 additions & 0 deletions fluXis.Game.Tests/Overlay/TestClubOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using fluXis.Game.Overlay.Club;
using osu.Framework.Allocation;

namespace fluXis.Game.Tests.Overlay;

public partial class TestClubOverlay : FluXisTestScene
{
[BackgroundDependencyLoader]
private void load()
{
var overlay = new ClubOverlay();
Add(overlay);

AddStep("Show Club 1", () => overlay.ShowClub(1));
AddStep("Show Club 2", () => overlay.ShowClub(2));
AddStep("Hide", overlay.Hide);
}
}
2 changes: 2 additions & 0 deletions fluXis.Game/FluXisGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using fluXis.Game.Overlay.Achievements;
using fluXis.Game.Overlay.Auth;
using fluXis.Game.Overlay.Chat;
using fluXis.Game.Overlay.Club;
using fluXis.Game.Overlay.Exit;
using fluXis.Game.Overlay.FPS;
using fluXis.Game.Overlay.Music;
Expand Down Expand Up @@ -121,6 +122,7 @@ private void load()
loadComponent(dashboard = new Dashboard(), overlayContainer.Add, true);
loadComponent(new ChatOverlay(), overlayContainer.Add, true);
loadComponent(userProfileOverlay = new UserProfileOverlay(), overlayContainer.Add, true);
loadComponent(new ClubOverlay(), overlayContainer.Add, true);
loadComponent(new MusicPlayer(), overlayContainer.Add, true);
loadComponent(new SettingsMenu(), overlayContainer.Add, true);

Expand Down
2 changes: 2 additions & 0 deletions fluXis.Game/Graphics/Sprites/FontAwesome6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static class Solid
public static IconUsage ArrowPointer => getSolid(0xf245);
public static IconUsage ArrowRight => getSolid(0xf061);
public static IconUsage ArrowRightArrowLeft => getSolid(0xf0ec);
public static IconUsage ArrowTrendUp => getSolid(0xe098);
public static IconUsage ArrowsRotate => getSolid(0xf021);
public static IconUsage BackwardStep => getSolid(0xf048);
public static IconUsage Bars => getSolid(0xf0c9);
Expand All @@ -37,6 +38,7 @@ public static class Solid
public static IconUsage Clone => getSolid(0xf24d);
public static IconUsage ComputerMouse => getSolid(0xf8cc);
public static IconUsage Copy => getSolid(0xf0c5);
public static IconUsage Crown => getSolid(0xf521);
public static IconUsage Cube => getSolid(0xf1b2);
public static IconUsage Cubes => getSolid(0xf1b3);
public static IconUsage Cut => getSolid(0xf0c4);
Expand Down
17 changes: 17 additions & 0 deletions fluXis.Game/Graphics/UserInterface/Tabs/TabContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;

namespace fluXis.Game.Graphics.UserInterface.Tabs;

public abstract partial class TabContainer : Container
{
public abstract IconUsage Icon { get; }
public abstract string Title { get; }

protected TabContainer()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
}
132 changes: 132 additions & 0 deletions fluXis.Game/Graphics/UserInterface/Tabs/TabControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using System;
using System.Linq;
using fluXis.Game.Graphics.Sprites;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osuTK;

namespace fluXis.Game.Graphics.UserInterface.Tabs;

public partial class TabControl : CompositeDrawable
{
public TabContainer[] Tabs { get; init; } = Array.Empty<TabContainer>();

private Bindable<TabContainer> current;

[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

if (Tabs.Length <= 0)
throw new ArgumentException($"{nameof(Tabs)} must have 1 or more children.");

current = new Bindable<TabContainer>(Tabs.First());

InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(16),
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(24),
ChildrenEnumerable = Tabs.Select(t => new TabControlItem(t, current))
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = Tabs
}
}
};
}

protected override void LoadComplete()
{
base.LoadComplete();

current.BindValueChanged(currentChanged, true);
FinishTransforms(true);
}

private void currentChanged(ValueChangedEvent<TabContainer> e)
{
foreach (var tab in Tabs)
{
if (tab != e.NewValue)
tab.FadeOut(150);
}

e.NewValue.Delay(100).FadeIn(150);
}

private partial class TabControlItem : FillFlowContainer
{
private TabContainer container { get; }
private Bindable<TabContainer> current { get; }

public TabControlItem(TabContainer container, Bindable<TabContainer> current)
{
this.container = container;
this.current = current;
}

[BackgroundDependencyLoader]
private void load()
{
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(8);

InternalChildren = new Drawable[]
{
new SpriteIcon
{
Size = new Vector2(20),
Icon = container.Icon,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
new FluXisSpriteText
{
Text = container.Title,
WebFontSize = 14,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
}
};
}

protected override void LoadComplete()
{
base.LoadComplete();

current.BindValueChanged(currentChanged, true);
FinishTransforms();
}

private void currentChanged(ValueChangedEvent<TabContainer> e)
{
this.FadeTo(e.NewValue == container ? 1 : .6f, 150);
}

protected override bool OnClick(ClickEvent e)
{
current.Value = container;
return true;
}
}
}
15 changes: 15 additions & 0 deletions fluXis.Game/Online/API/Requests/Clubs/ClubRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using fluXis.Shared.Components.Clubs;

namespace fluXis.Game.Online.API.Requests.Clubs;

public class ClubRequest : APIRequest<APIClub>
{
protected override string Path => $"/club/{id}";

private long id { get; }

public ClubRequest(long id)
{
this.id = id;
}
}
Loading

0 comments on commit d6d15a2

Please sign in to comment.