Rename IsValid to Visible

This commit is contained in:
Cootz 2023-06-02 11:33:38 +03:00
parent d400387329
commit 4c7cca101e
10 changed files with 33 additions and 33 deletions

View File

@ -203,7 +203,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("mod select contains only double time mod",
() => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay
.ChildrenOfType<ModPanel>()
.SingleOrDefault(panel => panel.IsValid)?.Mod is OsuModDoubleTime);
.SingleOrDefault(panel => panel.Visible)?.Mod is OsuModDoubleTime);
}
[Test]

View File

@ -106,26 +106,26 @@ namespace osu.Game.Tests.Visual.UserInterface
});
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.IsValid) == 2);
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.Visible) == 2);
clickToggle();
AddUntilStep("wait for animation", () => !column.SelectionAnimationRunning);
AddAssert("only visible items selected", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Active.Value).All(panel => panel.IsValid));
AddAssert("only visible items selected", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Active.Value).All(panel => panel.Visible));
AddStep("unset filter", () => setFilter(null));
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.IsValid));
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.Visible));
AddAssert("checkbox not selected", () => !column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.IsValid) == 2);
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.Visible) == 2);
AddAssert("checkbox selected", () => column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
AddStep("filter out everything", () => setFilter(_ => false));
AddUntilStep("no panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.IsValid));
AddUntilStep("no panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.Visible));
AddUntilStep("checkbox hidden", () => !column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
AddStep("inset filter", () => setFilter(null));
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.IsValid));
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.Visible));
AddUntilStep("checkbox visible", () => column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
void clickToggle() => AddStep("click toggle", () =>
@ -320,14 +320,14 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("search by mod name", () => column.SearchTerm = searchTerm);
AddAssert("only hidden is visible", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.IsValid).All(panel => panel.Mod is ModHidden));
AddAssert("only hidden is visible", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Visible).All(panel => panel.Mod is ModHidden));
}
void clearSearch()
{
AddStep("clear search", () => column.SearchTerm = string.Empty);
AddAssert("all mods are visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.IsValid));
AddAssert("all mods are visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.Visible));
}
}

View File

@ -490,15 +490,15 @@ namespace osu.Game.Tests.Visual.UserInterface
createScreen();
changeRuleset(0);
AddAssert("double time visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).Any(panel => panel.IsValid));
AddAssert("double time visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).Any(panel => panel.Visible));
AddStep("make double time invalid", () => modSelectOverlay.IsValidMod = m => !(m is OsuModDoubleTime));
AddUntilStep("double time not visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).All(panel => !panel.IsValid));
AddAssert("nightcore still visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModNightcore).Any(panel => panel.IsValid));
AddUntilStep("double time not visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).All(panel => !panel.Visible));
AddAssert("nightcore still visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModNightcore).Any(panel => panel.Visible));
AddStep("make double time valid again", () => modSelectOverlay.IsValidMod = _ => true);
AddUntilStep("double time visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).Any(panel => panel.IsValid));
AddAssert("nightcore still visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(b => b.Mod is OsuModNightcore).Any(panel => panel.IsValid));
AddUntilStep("double time visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(panel => panel.Mod is OsuModDoubleTime).Any(panel => panel.Visible));
AddAssert("nightcore still visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(b => b.Mod is OsuModNightcore).Any(panel => panel.Visible));
}
[Test]
@ -524,7 +524,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("set ruleset", () => Ruleset.Value = testRuleset.RulesetInfo);
waitForColumnLoad();
AddAssert("unimplemented mod panel is filtered", () => !getPanelForMod(typeof(TestUnimplementedMod)).IsValid);
AddAssert("unimplemented mod panel is filtered", () => !getPanelForMod(typeof(TestUnimplementedMod)).Visible);
}
[Test]
@ -585,7 +585,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("select DT + HD", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden() });
AddStep("focus on search", () => modSelectOverlay.SearchTextBox.TakeFocus());
AddStep("apply search", () => modSelectOverlay.SearchTerm = "Easy");
AddAssert("DT + HD selected and hidden", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => !panel.IsValid && panel.Active.Value) == 2);
AddAssert("DT + HD selected and hidden", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => !panel.Visible && panel.Active.Value) == 2);
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
AddAssert("DT + HD still selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
@ -630,7 +630,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("deselect all button enabled", () => this.ChildrenOfType<DeselectAllModsButton>().Single().Enabled.Value);
AddStep("apply search", () => modSelectOverlay.SearchTerm = "Easy");
AddAssert("DT + HD + RD are hidden and selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => !panel.IsValid && panel.Active.Value) == 3);
AddAssert("DT + HD + RD are hidden and selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => !panel.Visible && panel.Active.Value) == 3);
AddAssert("deselect all button enabled", () => this.ChildrenOfType<DeselectAllModsButton>().Single().Enabled.Value);
AddStep("click deselect all button", () =>

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Mods.Input
if (!mod_type_lookup.TryGetValue(e.Key, out var typesToMatch))
return false;
var matchingMods = availableMods.Where(modState => matches(modState, typesToMatch) && modState.IsValid).ToArray();
var matchingMods = availableMods.Where(modState => matches(modState, typesToMatch) && modState.Visible).ToArray();
if (matchingMods.Length == 0)
return false;

View File

@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Mods.Input
if (index < 0)
return false;
var modState = availableMods.Where(modState => modState.IsValid).ElementAtOrDefault(index);
var modState = availableMods.Where(modState => modState.Visible).ElementAtOrDefault(index);
if (modState == null)
return false;

View File

@ -146,15 +146,15 @@ namespace osu.Game.Overlays.Mods
private void updateState()
{
Alpha = availableMods.All(mod => !mod.IsValid) ? 0 : 1;
Alpha = availableMods.All(mod => !mod.Visible) ? 0 : 1;
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
{
toggleAllCheckbox.Alpha = availableMods.Any(panel => panel.IsValid) ? 1 : 0;
toggleAllCheckbox.Alpha = availableMods.Any(panel => panel.Visible) ? 1 : 0;
//Prevent checkbox from checking when column have on valid panels
if (availableMods.Any(panel => panel.IsValid))
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.IsValid).All(panel => panel.Active.Value);
if (availableMods.Any(panel => panel.Visible))
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.Visible).All(panel => panel.Active.Value);
}
}
@ -199,7 +199,7 @@ namespace osu.Game.Overlays.Mods
{
pendingSelectionOperations.Clear();
foreach (var button in availableMods.Where(b => !b.Active.Value && b.IsValid))
foreach (var button in availableMods.Where(b => !b.Active.Value && b.Visible))
pendingSelectionOperations.Enqueue(() => button.Active.Value = true);
}

View File

@ -73,9 +73,9 @@ namespace osu.Game.Overlays.Mods
}
/// <summary>
/// Determine if <see cref="ModPanel"/> is valid and can be shown
/// Whether the <see cref="ModPanel"/> is passing all filters and visible for user
/// </summary>
public bool IsValid => modState.IsValid;
public bool Visible => modState.Visible;
public bool ValidForSelection
{
@ -112,7 +112,7 @@ namespace osu.Game.Overlays.Mods
private void updateFilterState()
{
this.FadeTo(IsValid ? 1 : 0);
this.FadeTo(Visible ? 1 : 0);
}
#endregion

View File

@ -511,7 +511,7 @@ namespace osu.Game.Overlays.Mods
{
var column = columnFlow[i].Column;
bool allFiltered = column is ModColumn modColumn && modColumn.AvailableMods.All(modState => !modState.IsValid);
bool allFiltered = column is ModColumn modColumn && modColumn.AvailableMods.All(modState => !modState.Visible);
double delay = allFiltered ? 0 : nonFilteredColumnCount * 30;
double duration = allFiltered ? 0 : fade_in_duration;
@ -573,7 +573,7 @@ namespace osu.Game.Overlays.Mods
if (column is ModColumn modColumn)
{
allFiltered = modColumn.AvailableMods.All(modState => !modState.IsValid);
allFiltered = modColumn.AvailableMods.All(modState => !modState.Visible);
modColumn.FlushPendingSelections();
}
@ -623,7 +623,7 @@ namespace osu.Game.Overlays.Mods
return true;
}
ModState? firstMod = columnFlow.Columns.OfType<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.IsValid);
ModState? firstMod = columnFlow.Columns.OfType<ModColumn>().FirstOrDefault(m => m.IsPresent)?.AvailableMods.FirstOrDefault(x => x.Visible);
if (firstMod is not null)
firstMod.Active.Value = !firstMod.Active.Value;

View File

@ -39,9 +39,9 @@ namespace osu.Game.Overlays.Mods
public BindableBool ValidForSelection { get; } = new BindableBool(true);
/// <summary>
/// Determine if <see cref="Mod"/> is valid and can be shown
/// Whether the <see cref="Mod"/> is passing all filters and visible for user
/// </summary>
public bool IsValid => MatchingFilter.Value && ValidForSelection.Value;
public bool Visible => MatchingFilter.Value && ValidForSelection.Value;
/// <summary>
/// Whether the mod is matching the current filter, i.e. it is available for user selection.

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods
{
Enabled.Value = availableMods.Value
.SelectMany(pair => pair.Value)
.Any(modState => !modState.Active.Value && modState.IsValid);
.Any(modState => !modState.Active.Value && modState.Visible);
}
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)