mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Fix potential resource leak
This commit is contained in:
parent
49427fe8b7
commit
502bfa950e
@ -83,17 +83,18 @@ namespace osu.Game.Skinning.Components
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Type.BindValueChanged(update, true);
|
Type.BindValueChanged(_ => updateBeatmapContent());
|
||||||
ShowLabel.BindValueChanged(ignored => updateLabel());
|
beatmap.BindValueChanged(_ => updateBeatmapContent(), true);
|
||||||
ValueBeforeLabel.BindValueChanged(ignored => updateLabel());
|
ShowLabel.BindValueChanged(_ => updateLabel());
|
||||||
LabelPrefix.BindValueChanged(ignored => updateLabel());
|
ValueBeforeLabel.BindValueChanged(_ => updateLabel());
|
||||||
ShowLabelPrefix.BindValueChanged(ignored => updateLabel());
|
LabelPrefix.BindValueChanged(_ => updateLabel());
|
||||||
LabelSuffix.BindValueChanged(ignored => updateLabel());
|
ShowLabelPrefix.BindValueChanged(_ => updateLabel());
|
||||||
ShowLabelSuffix.BindValueChanged(ignored => updateLabel());
|
LabelSuffix.BindValueChanged(_ => updateLabel());
|
||||||
ValuePrefix.BindValueChanged(ignored => updateLabel());
|
ShowLabelSuffix.BindValueChanged(_ => updateLabel());
|
||||||
ShowValuePrefix.BindValueChanged(ignored => updateLabel());
|
ValuePrefix.BindValueChanged(_ => updateLabel());
|
||||||
ValueSuffix.BindValueChanged(ignored => updateLabel());
|
ShowValuePrefix.BindValueChanged(_ => updateLabel());
|
||||||
ShowValueSuffix.BindValueChanged(ignored => updateLabel());
|
ValueSuffix.BindValueChanged(_ => updateLabel());
|
||||||
|
ShowValueSuffix.BindValueChanged(_ => updateLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalisableString getLabelText()
|
private LocalisableString getLabelText()
|
||||||
@ -125,174 +126,124 @@ namespace osu.Game.Skinning.Components
|
|||||||
Height = text.Height;
|
Height = text.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(ValueChangedEvent<BeatmapInfo> type)
|
private void updateBeatmapContent()
|
||||||
{
|
{
|
||||||
switch (type.NewValue)
|
switch (Type.Value)
|
||||||
{
|
{
|
||||||
case BeatmapInfo.CircleSize:
|
case BeatmapInfo.CircleSize:
|
||||||
beatmap.BindValueChanged(bm =>
|
double cs = beatmap.Value.BeatmapInfo.Difficulty.CircleSize;
|
||||||
{
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsCs;
|
||||||
double cs = bm.NewValue.BeatmapInfo.Difficulty.CircleSize;
|
value = cs.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsCs;
|
|
||||||
value = cs.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.HPDrain:
|
case BeatmapInfo.HPDrain:
|
||||||
beatmap.BindValueChanged(bm =>
|
double hp = beatmap.Value.BeatmapInfo.Difficulty.DrainRate;
|
||||||
{
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsDrain;
|
||||||
double hp = bm.NewValue.BeatmapInfo.Difficulty.DrainRate;
|
value = hp.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsDrain;
|
|
||||||
value = hp.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Accuracy:
|
case BeatmapInfo.Accuracy:
|
||||||
beatmap.BindValueChanged(bm =>
|
double od = beatmap.Value.BeatmapInfo.Difficulty.OverallDifficulty;
|
||||||
{
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsAccuracy;
|
||||||
double od = bm.NewValue.BeatmapInfo.Difficulty.OverallDifficulty;
|
value = od.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsAccuracy;
|
|
||||||
value = od.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.ApproachRate:
|
case BeatmapInfo.ApproachRate:
|
||||||
beatmap.BindValueChanged(bm =>
|
double ar = beatmap.Value.BeatmapInfo.Difficulty.ApproachRate;
|
||||||
{
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsAr;
|
||||||
double ar = bm.NewValue.BeatmapInfo.Difficulty.ApproachRate;
|
value = ar.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsAr;
|
|
||||||
value = ar.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.StarRating:
|
case BeatmapInfo.StarRating:
|
||||||
beatmap.BindValueChanged(bm =>
|
double sr = beatmap.Value.BeatmapInfo.StarRating;
|
||||||
{
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsStars;
|
||||||
double sr = bm.NewValue.BeatmapInfo.StarRating;
|
value = sr.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsStars;
|
|
||||||
value = sr.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Song:
|
case BeatmapInfo.Song:
|
||||||
beatmap.BindValueChanged(bm =>
|
string title = beatmap.Value.BeatmapInfo.Metadata.Title;
|
||||||
{
|
labelText = TooltipText = EditorSetupStrings.Title;
|
||||||
string title = bm.NewValue.BeatmapInfo.Metadata.Title;
|
value = title;
|
||||||
//todo: no Song Title localisation?
|
|
||||||
labelText = TooltipText = EditorSetupStrings.Title;
|
|
||||||
value = title;
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Artist:
|
case BeatmapInfo.Artist:
|
||||||
beatmap.BindValueChanged(bm =>
|
string artist = beatmap.Value.BeatmapInfo.Metadata.Artist;
|
||||||
{
|
labelText = EditorSetupStrings.Artist;
|
||||||
string artist = bm.NewValue.BeatmapInfo.Metadata.Artist;
|
TooltipText = BeatmapsetsStrings.ShowDetailsByArtist(artist);
|
||||||
labelText = EditorSetupStrings.Artist;
|
value = artist;
|
||||||
TooltipText = BeatmapsetsStrings.ShowDetailsByArtist(artist);
|
|
||||||
value = artist;
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Difficulty:
|
case BeatmapInfo.Difficulty:
|
||||||
beatmap.BindValueChanged(bm =>
|
string diff = beatmap.Value.BeatmapInfo.DifficultyName;
|
||||||
{
|
labelText = TooltipText = EditorSetupStrings.DifficultyHeader;
|
||||||
string diff = bm.NewValue.BeatmapInfo.DifficultyName;
|
text.Current.Value = diff;
|
||||||
labelText = TooltipText = EditorSetupStrings.DifficultyHeader;
|
|
||||||
text.Current.Value = diff;
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Mapper:
|
case BeatmapInfo.Mapper:
|
||||||
beatmap.BindValueChanged(bm =>
|
string mapper = beatmap.Value.BeatmapInfo.Metadata.Author.Username;
|
||||||
{
|
//todo: is there a good alternative, to NotificationsOptionsMapping?
|
||||||
string mapper = bm.NewValue.BeatmapInfo.Metadata.Author.Username;
|
labelText = AccountsStrings.NotificationsOptionsMapping;
|
||||||
//todo: is there a good alternative, to ShowDetailsMappedBy?
|
TooltipText = BeatmapsetsStrings.ShowDetailsMappedBy(mapper);
|
||||||
labelText = AccountsStrings.NotificationsOptionsMapping;
|
value = mapper;
|
||||||
TooltipText = BeatmapsetsStrings.ShowDetailsMappedBy(mapper);
|
|
||||||
value = mapper;
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Length:
|
case BeatmapInfo.Length:
|
||||||
beatmap.BindValueChanged(bm =>
|
labelText = TooltipText = ArtistStrings.TracklistLength;
|
||||||
{
|
value = TimeSpan.FromMilliseconds(beatmap.Value.BeatmapInfo.Length).ToFormattedDuration();
|
||||||
labelText = TooltipText = ArtistStrings.TracklistLength;
|
|
||||||
value = TimeSpan.FromMilliseconds(bm.NewValue.BeatmapInfo.Length).ToFormattedDuration();
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.Status:
|
case BeatmapInfo.Status:
|
||||||
beatmap.BindValueChanged(bm =>
|
BeatmapOnlineStatus status = beatmap.Value.BeatmapInfo.Status;
|
||||||
|
TooltipText = labelText = BeatmapDiscussionsStrings.IndexFormBeatmapsetStatusDefault;
|
||||||
|
|
||||||
|
switch (status)
|
||||||
{
|
{
|
||||||
BeatmapOnlineStatus status = bm.NewValue.BeatmapInfo.Status;
|
case BeatmapOnlineStatus.Approved:
|
||||||
//todo: no Localizasion for None Beatmap Online Status
|
value = BeatmapsetsStrings.ShowStatusApproved;
|
||||||
labelText = BeatmapDiscussionsStrings.IndexFormBeatmapsetStatusDefault;
|
break;
|
||||||
|
|
||||||
switch (status)
|
case BeatmapOnlineStatus.Graveyard:
|
||||||
{
|
value = BeatmapsetsStrings.ShowStatusGraveyard;
|
||||||
case BeatmapOnlineStatus.Approved:
|
break;
|
||||||
value = BeatmapsetsStrings.ShowStatusApproved;
|
|
||||||
//todo: is this correct?
|
|
||||||
TooltipText = BeatmapsetsStrings.ShowDetailsDateApproved(bm.NewValue.BeatmapSetInfo.DateRanked.ToString());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BeatmapOnlineStatus.Graveyard:
|
case BeatmapOnlineStatus.Loved:
|
||||||
value = BeatmapsetsStrings.ShowStatusGraveyard;
|
value = BeatmapsetsStrings.ShowStatusLoved;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.Loved:
|
case BeatmapOnlineStatus.None:
|
||||||
value = BeatmapsetsStrings.ShowStatusLoved;
|
value = "None";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.None:
|
case BeatmapOnlineStatus.Pending:
|
||||||
value = "None";
|
value = BeatmapsetsStrings.ShowStatusPending;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.Pending:
|
case BeatmapOnlineStatus.Qualified:
|
||||||
value = BeatmapsetsStrings.ShowStatusPending;
|
value = BeatmapsetsStrings.ShowStatusQualified;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.Qualified:
|
case BeatmapOnlineStatus.Ranked:
|
||||||
value = BeatmapsetsStrings.ShowStatusQualified;
|
value = BeatmapsetsStrings.ShowStatusRanked;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.Ranked:
|
case BeatmapOnlineStatus.LocallyModified:
|
||||||
value = BeatmapsetsStrings.ShowStatusRanked;
|
value = SongSelectStrings.LocallyModified;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapOnlineStatus.LocallyModified:
|
case BeatmapOnlineStatus.WIP:
|
||||||
value = SongSelectStrings.LocallyModified;
|
value = BeatmapsetsStrings.ShowStatusWip;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BeatmapOnlineStatus.WIP:
|
|
||||||
value = BeatmapsetsStrings.ShowStatusWip;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BeatmapInfo.BPM:
|
case BeatmapInfo.BPM:
|
||||||
beatmap.BindValueChanged(bm =>
|
labelText = TooltipText = BeatmapsetsStrings.ShowStatsBpm;
|
||||||
{
|
value = beatmap.Value.BeatmapInfo.BPM.ToString("F2");
|
||||||
labelText = TooltipText = BeatmapsetsStrings.ShowStatsBpm;
|
|
||||||
value = bm.NewValue.BeatmapInfo.BPM.ToString("F2");
|
|
||||||
updateLabel();
|
|
||||||
}, true);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user