Merge pull request #3469 from peppy/fix-import-buttons

Fix import buttons having incorrect mappings when setting disabled states
This commit is contained in:
ekrctb 2018-09-21 21:18:26 +09:00 committed by GitHub
commit 5e51a50658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,57 +13,59 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{ {
public class GeneralSettings : SettingsSubsection public class GeneralSettings : SettingsSubsection
{ {
private TriangleButton importButton; protected override string Header => "General";
private TriangleButton deleteButton;
private TriangleButton importBeatmapsButton;
private TriangleButton importSkinsButton;
private TriangleButton deleteSkinsButton;
private TriangleButton deleteBeatmapsButton;
private TriangleButton restoreButton; private TriangleButton restoreButton;
private TriangleButton undeleteButton; private TriangleButton undeleteButton;
protected override string Header => "General";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay) private void load(BeatmapManager beatmaps, SkinManager skins, DialogOverlay dialogOverlay)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
importButton = new SettingsButton importBeatmapsButton = new SettingsButton
{ {
Text = "Import beatmaps from stable", Text = "Import beatmaps from stable",
Action = () => Action = () =>
{ {
importButton.Enabled.Value = false; importBeatmapsButton.Enabled.Value = false;
beatmaps.ImportFromStableAsync().ContinueWith(t => Schedule(() => importButton.Enabled.Value = true)); beatmaps.ImportFromStableAsync().ContinueWith(t => Schedule(() => importBeatmapsButton.Enabled.Value = true));
} }
}, },
deleteButton = new DangerousSettingsButton deleteBeatmapsButton = new DangerousSettingsButton
{ {
Text = "Delete ALL beatmaps", Text = "Delete ALL beatmaps",
Action = () => Action = () =>
{ {
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
{ {
deleteButton.Enabled.Value = false; deleteBeatmapsButton.Enabled.Value = false;
Task.Run(() => beatmaps.Delete(beatmaps.GetAllUsableBeatmapSets())).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); Task.Run(() => beatmaps.Delete(beatmaps.GetAllUsableBeatmapSets())).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
})); }));
} }
}, },
importButton = new SettingsButton importSkinsButton = new SettingsButton
{ {
Text = "Import skins from stable", Text = "Import skins from stable",
Action = () => Action = () =>
{ {
importButton.Enabled.Value = false; importSkinsButton.Enabled.Value = false;
skins.ImportFromStableAsync().ContinueWith(t => Schedule(() => importButton.Enabled.Value = true)); skins.ImportFromStableAsync().ContinueWith(t => Schedule(() => importSkinsButton.Enabled.Value = true));
} }
}, },
deleteButton = new DangerousSettingsButton deleteSkinsButton = new DangerousSettingsButton
{ {
Text = "Delete ALL skins", Text = "Delete ALL skins",
Action = () => Action = () =>
{ {
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
{ {
deleteButton.Enabled.Value = false; deleteSkinsButton.Enabled.Value = false;
Task.Run(() => skins.Delete(skins.GetAllUserSkins())).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); Task.Run(() => skins.Delete(skins.GetAllUserSkins())).ContinueWith(t => Schedule(() => deleteSkinsButton.Enabled.Value = true));
})); }));
} }
}, },