Simplify text building

This commit is contained in:
Andrei Zavatski 2019-08-27 15:30:41 +03:00
parent 7f0a4fbef9
commit f49b58c102

View File

@ -55,83 +55,67 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
switch (historyItem.Action) switch (historyItem.Action)
{ {
case KudosuAction.VoteGive: case KudosuAction.VoteGive:
linkFlowContainer.AddText(@"Received "); addKudosuPart(@"Received");
addKudosuPart();
addMainPart(@" from obtaining votes in modding post of "); addMainPart(@" from obtaining votes in modding post of ");
addPostPart();
break; break;
case KudosuAction.Give: case KudosuAction.Give:
linkFlowContainer.AddText(@"Received "); addKudosuPart(@"Received");
addKudosuPart();
addMainPart($@" from {userLinkTemplate()} for a post at "); addMainPart($@" from {userLinkTemplate()} for a post at ");
addPostPart();
break; break;
case KudosuAction.Reset: case KudosuAction.Reset:
addMainPart($@"Kudosu reset by {userLinkTemplate()} for the post "); addMainPart($@"Kudosu reset by {userLinkTemplate()} for the post ");
addPostPart();
break; break;
case KudosuAction.VoteReset: case KudosuAction.VoteReset:
linkFlowContainer.AddText(@"Lost "); addKudosuPart(@"Lost");
addKudosuPart();
addMainPart(@" from losing votes in modding post of "); addMainPart(@" from losing votes in modding post of ");
addPostPart();
break; break;
case KudosuAction.DenyKudosuReset: case KudosuAction.DenyKudosuReset:
linkFlowContainer.AddText(@"Denied "); addKudosuPart(@"Denied");
addKudosuPart();
addMainPart(@" from modding post "); addMainPart(@" from modding post ");
addPostPart();
break; break;
case KudosuAction.Revoke: case KudosuAction.Revoke:
addMainPart($@"Denied kudosu by {userLinkTemplate()} for the post "); addMainPart($@"Denied kudosu by {userLinkTemplate()} for the post ");
addPostPart();
break; break;
case KudosuAction.AllowKudosuGive: case KudosuAction.AllowKudosuGive:
linkFlowContainer.AddText(@"Received "); addKudosuPart(@"Received");
addKudosuPart();
addMainPart(@" from kudosu deny repeal of modding post "); addMainPart(@" from kudosu deny repeal of modding post ");
addPostPart();
break; break;
case KudosuAction.DeleteReset: case KudosuAction.DeleteReset:
linkFlowContainer.AddText(@"Lost "); addKudosuPart(@"Lost");
addKudosuPart();
addMainPart(@" from modding post deletion of "); addMainPart(@" from modding post deletion of ");
addPostPart();
break; break;
case KudosuAction.RestoreGive: case KudosuAction.RestoreGive:
linkFlowContainer.AddText(@"Received "); addKudosuPart(@"Received");
addKudosuPart();
addMainPart(@" from modding post restoration of "); addMainPart(@" from modding post restoration of ");
addPostPart();
break; break;
case KudosuAction.RecalculateGive: case KudosuAction.RecalculateGive:
linkFlowContainer.AddText(@"Received "); addKudosuPart(@"Received");
addKudosuPart();
addMainPart(@" from votes recalculation in modding post of "); addMainPart(@" from votes recalculation in modding post of ");
addPostPart();
break; break;
case KudosuAction.RecalculateReset: case KudosuAction.RecalculateReset:
linkFlowContainer.AddText(@"Lost "); addKudosuPart(@"Lost");
addKudosuPart();
addMainPart(@" from votes recalculation in modding post of "); addMainPart(@" from votes recalculation in modding post of ");
addPostPart();
break; break;
} }
addPostPart();
} }
private void addKudosuPart() private void addKudosuPart(string prefix)
{ {
linkFlowContainer.AddText($@"{historyItem.Amount} kudosu", t => linkFlowContainer.AddText(prefix);
linkFlowContainer.AddText($@" {historyItem.Amount} kudosu", t =>
{ {
t.Font = t.Font.With(italics: true); t.Font = t.Font.With(italics: true);
t.Colour = colours.Blue; t.Colour = colours.Blue;