mirror of
https://github.com/ppy/osu
synced 2025-02-01 10:51:53 +00:00
Make chevrons updateable
This commit is contained in:
parent
02a8fb2154
commit
c50c946b35
@ -14,6 +14,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
private APIChangelog currentBuild;
|
||||
private APIAccess api;
|
||||
private ChangelogContentGroup changelogContentGroup;
|
||||
|
||||
public ChangelogContent()
|
||||
{
|
||||
@ -27,20 +28,19 @@ namespace osu.Game.Overlays.Changelog
|
||||
};
|
||||
}
|
||||
|
||||
public override void Add(ChangelogContentGroup changelogContentGroup)
|
||||
private void add(APIChangelog changelogBuild)
|
||||
{
|
||||
if (changelogContentGroup != null)
|
||||
{
|
||||
changelogContentGroup.PreviousRequested = showPrevious;
|
||||
changelogContentGroup.NextRequested = showNext;
|
||||
}
|
||||
base.Add(changelogContentGroup);
|
||||
Add(changelogContentGroup = new ChangelogContentGroup(changelogBuild)
|
||||
{
|
||||
PreviousRequested = showPrevious,
|
||||
NextRequested = showNext,
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowBuild(APIChangelog changelog)
|
||||
{
|
||||
Clear();
|
||||
Add(new ChangelogContentGroup(changelog));
|
||||
add(changelog);
|
||||
//fetchChangelogBuild(changelog);
|
||||
fetchChangelogBuild();
|
||||
}
|
||||
@ -48,23 +48,19 @@ namespace osu.Game.Overlays.Changelog
|
||||
private void showNext()
|
||||
{
|
||||
if (currentBuild.Versions.Next != null)
|
||||
{
|
||||
Clear();
|
||||
Add(new ChangelogContentGroup(currentBuild.Versions.Next));
|
||||
//fetchChangelogBuild(currentBuild.Versions.Next);
|
||||
fetchChangelogBuild();
|
||||
}
|
||||
ShowBuild(currentBuild.Versions.Next);
|
||||
}
|
||||
|
||||
private void showPrevious()
|
||||
{
|
||||
if (currentBuild.Versions.Previous != null)
|
||||
{
|
||||
Clear();
|
||||
Add(new ChangelogContentGroup(currentBuild.Versions.Previous));
|
||||
//fetchChangelogBuild(currentBuild.Versions.Previous);
|
||||
fetchChangelogBuild();
|
||||
}
|
||||
ShowBuild(currentBuild.Versions.Previous);
|
||||
}
|
||||
|
||||
private void updateChevronTooltips()
|
||||
{
|
||||
changelogContentGroup.UpdateChevronTooltips(currentBuild.Versions.Previous?.DisplayVersion,
|
||||
currentBuild.Versions.Next?.DisplayVersion);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -78,7 +74,11 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
//var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
|
||||
var req = new GetChangelogBuildRequest();
|
||||
req.Success += res => currentBuild = res;
|
||||
req.Success += res =>
|
||||
{
|
||||
currentBuild = res;
|
||||
updateChevronTooltips();
|
||||
};
|
||||
api.Queue(req);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
public class ChangelogContentGroup : FillFlowContainer
|
||||
{
|
||||
private readonly TooltipIconButton chevronPrevious, chevronNext;
|
||||
|
||||
public Action NextRequested, PreviousRequested;
|
||||
public ChangelogContentGroup(APIChangelog build)
|
||||
{
|
||||
@ -40,7 +42,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TooltipIconButton
|
||||
chevronPrevious = new TooltipIconButton
|
||||
{
|
||||
Icon = FontAwesome.fa_chevron_left,
|
||||
Size = new Vector2(24),
|
||||
@ -77,7 +79,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
},
|
||||
}
|
||||
},
|
||||
new TooltipIconButton
|
||||
chevronNext = new TooltipIconButton
|
||||
{
|
||||
Icon = FontAwesome.fa_chevron_right,
|
||||
Size = new Vector2(24),
|
||||
@ -103,6 +105,24 @@ namespace osu.Game.Overlays.Changelog
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateChevronTooltips(string previousVersion, string nextVersion)
|
||||
{
|
||||
if (string.IsNullOrEmpty(previousVersion))
|
||||
chevronPrevious.IsEnabled = false;
|
||||
else
|
||||
{
|
||||
chevronPrevious.TooltipText = previousVersion;
|
||||
chevronPrevious.IsEnabled = true;
|
||||
}
|
||||
if (string.IsNullOrEmpty(nextVersion))
|
||||
chevronNext.IsEnabled = false;
|
||||
else
|
||||
{
|
||||
chevronNext.TooltipText = nextVersion;
|
||||
chevronNext.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
//public ChangelogContentGroup() { } // for listing
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user