Remove scoped blocks in ReplayBrowserLogic.

This commit is contained in:
Paul Chote
2019-06-07 22:05:18 +01:00
committed by abcdefg30
parent 208b5b9686
commit 9f15754926

View File

@@ -371,10 +371,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void SetupManagement()
{
{
var button = panel.Get<ButtonWidget>("MNG_RENSEL_BUTTON");
button.IsDisabled = () => selectedReplay == null;
button.OnClick = () =>
var renameButton = panel.Get<ButtonWidget>("MNG_RENSEL_BUTTON");
renameButton.IsDisabled = () => selectedReplay == null;
renameButton.OnClick = () =>
{
var r = selectedReplay;
var initialName = Path.GetFileNameWithoutExtension(r.FilePath);
@@ -406,7 +405,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true;
});
};
}
Action<ReplayMetadata, Action> onDeleteReplay = (r, after) =>
{
@@ -423,10 +421,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
onCancel: () => { });
};
{
var button = panel.Get<ButtonWidget>("MNG_DELSEL_BUTTON");
button.IsDisabled = () => selectedReplay == null;
button.OnClick = () =>
var deleteButton = panel.Get<ButtonWidget>("MNG_DELSEL_BUTTON");
deleteButton.IsDisabled = () => selectedReplay == null;
deleteButton.OnClick = () =>
{
onDeleteReplay(selectedReplay, () =>
{
@@ -434,12 +431,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
SelectFirstVisibleReplay();
});
};
}
{
var button = panel.Get<ButtonWidget>("MNG_DELALL_BUTTON");
button.IsDisabled = () => replayState.Count(kvp => kvp.Value.Visible) == 0;
button.OnClick = () =>
var deleteAllButton = panel.Get<ButtonWidget>("MNG_DELALL_BUTTON");
deleteAllButton.IsDisabled = () => replayState.Count(kvp => kvp.Value.Visible) == 0;
deleteAllButton.OnClick = () =>
{
var list = replayState.Where(kvp => kvp.Value.Visible).Select(kvp => kvp.Key).ToList();
if (list.Count == 0)
@@ -464,7 +459,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
onCancel: () => { });
};
}
}
void RenameReplay(ReplayMetadata replay, string newFilenameWithoutExtension)
{