Skip to content

Commit

Permalink
add autonavigation for autonavigated tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Flutterish committed Apr 18, 2022
1 parent ac66b6b commit cbd6de5
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 60 deletions.
24 changes: 24 additions & 0 deletions osu.Game.Rulesets.RurusettoAddon/API/APIUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ void requestDefault ( Exception? e = null ) {
}
}

public void RequestDarkCover ( Action<Texture> success, Action<Exception?>? failure = null ) {
void requestDefault ( Exception? e = null ) {
if ( API != null ) {
API.RequestImage( StaticAPIResource.DefaultCover, success, failure: e => {
failure?.Invoke( e );
} );
}
}

if ( Source == Source.Web && API != null ) {
RequestDetail( detail => {
if ( !string.IsNullOrWhiteSpace( detail.DarkCover ) ) {
API.RequestImage( detail.DarkCover, success, requestDefault );
}
else {
requestDefault();
}
}, failure: requestDefault );
}
else {
requestDefault();
}
}

public override string ToString ()
=> Source is Source.Web ? $"User with ID = {ID}" : $"Local user";
}
21 changes: 16 additions & 5 deletions osu.Game.Rulesets.RurusettoAddon/API/ListingEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,43 @@
#nullable disable
namespace osu.Game.Rulesets.RurusettoAddon.API;

public record ListingEntry {
public record ShortListingEntry {
/// <summary> The ID of the ruleset in Rūrusetto database. </summary>
[JsonProperty( "id" )]
public int ID { get; init; }

/// <summary> The name of the ruleset. </summary>
[JsonProperty( "name" )]
public string Name { get; init; }

/// <summary> The slug of the ruleset. Use in the URL of the ruleset's wiki page. </summary>
[JsonProperty( "slug" )]
public string Slug { get; init; }

/// <summary> The short description of the rulesets. </summary>
[JsonProperty( "description" )]
public string Description { get; init; }

/// <summary> The URL of the ruleset icon that use in website's default theme (dark theme). </summary>
[JsonProperty( "icon" )]
public string DarkIcon { get; init; }

/// <summary>The URL of the ruleset icon that use in website's light theme. </summary>
[JsonProperty( "light_icon" )]
public string LightIcon { get; init; }

/// <summary> The user_detail of the ruleset's current owner. </summary>
[JsonProperty( "owner_detail" )]
public UserDetail Owner { get; init; }

/// <summary> True if the wiki maintainer has verified that the the owner is the real owner of this ruleset. </summary>
[JsonProperty( "verified" )]
public bool IsVerified { get; init; }

/// <summary> True if the rulesets is stop update or archived by rulesets creator. </summary>
[JsonProperty( "archive" )]
public bool IsArchived { get; init; }

/// <summary> URL for download the latest release of ruleset from GitHub </summary>
[JsonProperty( "direct_download_link" )]
public string Download { get; init; }

/// <summary>
/// True if website can render the direct download link from the source and github_download_filename
/// so user can download directly from direct_download_link.
Expand All @@ -45,4 +50,10 @@ public record ListingEntry {
/// <summary> The status of the ruleset. </summary>
[JsonProperty( "status" )]
public Status Status { get; init; }
}

public record ListingEntry : ShortListingEntry {
/// <summary> The user_detail of the ruleset's current owner. </summary>
[JsonProperty( "owner_detail" )]
public UserDetail Owner { get; init; }
}
32 changes: 32 additions & 0 deletions osu.Game.Rulesets.RurusettoAddon/API/UserProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ public record UserProfile {
/// <summary> The ID of the user. Use in URL path to target user's profile page. </summary>
[JsonProperty( "id" )]
public int? ID { get; init; }

[JsonProperty( "user" )]
private UserInfo info { get; init; }

/// <summary> URL of the user's profile picture. </summary>
[JsonProperty( "image" )]
public string ProfilePicture { get; init; }

/// <summary> URL of the user's cover picture in website's default theme (Dark theme). </summary>
[JsonProperty( "cover" )]
public string DarkCover { get; init; }

/// <summary> URL of the user's cover picture in website's light theme. </summary>
[JsonProperty( "cover_light" )]
public string LightCover { get; init; }

/// <summary> User's introduction text on profile page. </summary>
[JsonProperty( "about_me" )]
public string Bio { get; init; }

/// <summary> osu! account username of target user (Can be blank) </summary>
[JsonProperty( "osu_username" )]
public string OsuUsername { get; init; }
Expand All @@ -30,4 +36,30 @@ public record UserProfile {

/// <inheritdoc cref="UserInfo.Email"/>
public string Email => info?.Email;

/// <summary> List of tag that user has. Will be [] if no tags found in this user. </summary>
[JsonProperty( "tags" )]
public List<UserTag> Tags { get; init; }

/// <summary> List of ruleset that user created. Will be [] if no created rulesets found from this user. </summary>
[JsonProperty( "created_rulesets" )]
public List<ShortListingEntry> CreatedRulesets { get; init; }
}

public record UserTag {
/// <summary> The name of the tag. </summary>
[JsonProperty( "name" )]
public string Text { get; init; }

/// <summary> The background color of the tag pills that show in profile. Will return in hex color (e.g. #FFFFFF). </summary>
[JsonProperty( "pills_color" )]
public string BackgroundColor { get; init; }

/// <summary> The font color of the tag pills that show in profile. Will return in hex color (e.g. #FFFFFF). </summary>
[JsonProperty( "font_color" )]
public string ForegroundColor { get; init; }

/// <summary> The description of the tag. </summary>
[JsonProperty( "description" )]
public string Description { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,47 @@ protected CategorisedTabControlOverlayHeader () {
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new Container {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Depth = -1,
Children = new Drawable[] {
categoryControlBackground = new Box
new Container {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Depth = -1,
Children = new Drawable[] {
categoryControlBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
categoryControlContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = ContentSidePadding },
Child = CategoryControl = CreateCategoryControl().With(control =>
{
RelativeSizeAxes = Axes.Both,
},
categoryControlContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = ContentSidePadding },
Child = CategoryControl = CreateCategoryControl().With(control =>
{
control.Current = CurrentCategory;
})
}
control.Current = CurrentCategory;
})
}
},
new Container {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[] {
controlBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
tabControlContainer = new Container
}
},
new Container {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[] {
controlBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
tabControlContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = ContentSidePadding },
Child = TabControl = CreateTabControl().With(control =>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = ContentSidePadding },
Child = TabControl = CreateTabControl().With(control =>
{
control.Current = Current;
})
}
control.Current = Current;
})
}
}
}
}
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public RurusettoOverlayBackground () {

[BackgroundDependencyLoader]
private void load ( GameHost host, TextureStore textures, RurusettoAddonRuleset ruleset ) {
SetCover( defaultCover = ruleset.GetTexture( host, textures, TextureNames.HeaderBackground ) );
SetCover( defaultCover = ruleset.GetTexture( host, textures, TextureNames.HeaderBackground ), expanded: true );
}

public void SetCover ( Texture? cover ) {
public void SetCover ( Texture? cover, bool expanded ) {
cover ??= defaultCover;

if ( !covers.TryGetValue( cover, out var sprite ) ) {
Expand All @@ -41,7 +41,7 @@ public void SetCover ( Texture? cover ) {

currentCover = sprite;

if ( currentCover.Texture == defaultCover ) {
if ( expanded ) {
this.FadeIn().ResizeHeightTo( 80, 400, Easing.Out );
}
else {
Expand Down
Loading

0 comments on commit cbd6de5

Please sign in to comment.