mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 03:22:55 +08:00
Rename IsValid
to Visible
This commit is contained in:
parent
d400387329
commit
4c7cca101e
@ -203,7 +203,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddUntilStep("mod select contains only double time mod",
|
AddUntilStep("mod select contains only double time mod",
|
||||||
() => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay
|
() => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay
|
||||||
.ChildrenOfType<ModPanel>()
|
.ChildrenOfType<ModPanel>()
|
||||||
.SingleOrDefault(panel => panel.IsValid)?.Mod is OsuModDoubleTime);
|
.SingleOrDefault(panel => panel.Visible)?.Mod is OsuModDoubleTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -106,26 +106,26 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
|
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();
|
clickToggle();
|
||||||
AddUntilStep("wait for animation", () => !column.SelectionAnimationRunning);
|
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));
|
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);
|
AddAssert("checkbox not selected", () => !column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
|
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);
|
AddAssert("checkbox selected", () => column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||||
|
|
||||||
AddStep("filter out everything", () => setFilter(_ => false));
|
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);
|
AddUntilStep("checkbox hidden", () => !column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||||
|
|
||||||
AddStep("inset filter", () => setFilter(null));
|
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);
|
AddUntilStep("checkbox visible", () => column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||||
|
|
||||||
void clickToggle() => AddStep("click toggle", () =>
|
void clickToggle() => AddStep("click toggle", () =>
|
||||||
@ -320,14 +320,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep("search by mod name", () => column.SearchTerm = searchTerm);
|
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()
|
void clearSearch()
|
||||||
{
|
{
|
||||||
AddStep("clear search", () => column.SearchTerm = string.Empty);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,15 +490,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
createScreen();
|
createScreen();
|
||||||
changeRuleset(0);
|
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));
|
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));
|
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.IsValid));
|
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);
|
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));
|
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.IsValid));
|
AddAssert("nightcore still visible", () => modSelectOverlay.ChildrenOfType<ModPanel>().Where(b => b.Mod is OsuModNightcore).Any(panel => panel.Visible));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -524,7 +524,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("set ruleset", () => Ruleset.Value = testRuleset.RulesetInfo);
|
AddStep("set ruleset", () => Ruleset.Value = testRuleset.RulesetInfo);
|
||||||
waitForColumnLoad();
|
waitForColumnLoad();
|
||||||
|
|
||||||
AddAssert("unimplemented mod panel is filtered", () => !getPanelForMod(typeof(TestUnimplementedMod)).IsValid);
|
AddAssert("unimplemented mod panel is filtered", () => !getPanelForMod(typeof(TestUnimplementedMod)).Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -585,7 +585,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("select DT + HD", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden() });
|
AddStep("select DT + HD", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden() });
|
||||||
AddStep("focus on search", () => modSelectOverlay.SearchTextBox.TakeFocus());
|
AddStep("focus on search", () => modSelectOverlay.SearchTextBox.TakeFocus());
|
||||||
AddStep("apply search", () => modSelectOverlay.SearchTerm = "Easy");
|
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));
|
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
|
||||||
AddAssert("DT + HD still selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
|
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);
|
AddAssert("deselect all button enabled", () => this.ChildrenOfType<DeselectAllModsButton>().Single().Enabled.Value);
|
||||||
|
|
||||||
AddStep("apply search", () => modSelectOverlay.SearchTerm = "Easy");
|
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);
|
AddAssert("deselect all button enabled", () => this.ChildrenOfType<DeselectAllModsButton>().Single().Enabled.Value);
|
||||||
|
|
||||||
AddStep("click deselect all button", () =>
|
AddStep("click deselect all button", () =>
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Mods.Input
|
|||||||
if (!mod_type_lookup.TryGetValue(e.Key, out var typesToMatch))
|
if (!mod_type_lookup.TryGetValue(e.Key, out var typesToMatch))
|
||||||
return false;
|
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)
|
if (matchingMods.Length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Mods.Input
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var modState = availableMods.Where(modState => modState.IsValid).ElementAtOrDefault(index);
|
var modState = availableMods.Where(modState => modState.Visible).ElementAtOrDefault(index);
|
||||||
if (modState == null)
|
if (modState == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -146,15 +146,15 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
Alpha = availableMods.All(mod => !mod.IsValid) ? 0 : 1;
|
Alpha = availableMods.All(mod => !mod.Visible) ? 0 : 1;
|
||||||
|
|
||||||
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
|
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
|
//Prevent checkbox from checking when column have on valid panels
|
||||||
if (availableMods.Any(panel => panel.IsValid))
|
if (availableMods.Any(panel => panel.Visible))
|
||||||
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.IsValid).All(panel => panel.Active.Value);
|
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.Visible).All(panel => panel.Active.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
pendingSelectionOperations.Clear();
|
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);
|
pendingSelectionOperations.Enqueue(() => button.Active.Value = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool IsValid => modState.IsValid;
|
public bool Visible => modState.Visible;
|
||||||
|
|
||||||
public bool ValidForSelection
|
public bool ValidForSelection
|
||||||
{
|
{
|
||||||
@ -112,7 +112,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateFilterState()
|
private void updateFilterState()
|
||||||
{
|
{
|
||||||
this.FadeTo(IsValid ? 1 : 0);
|
this.FadeTo(Visible ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -511,7 +511,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
var column = columnFlow[i].Column;
|
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 delay = allFiltered ? 0 : nonFilteredColumnCount * 30;
|
||||||
double duration = allFiltered ? 0 : fade_in_duration;
|
double duration = allFiltered ? 0 : fade_in_duration;
|
||||||
@ -573,7 +573,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
if (column is ModColumn modColumn)
|
if (column is ModColumn modColumn)
|
||||||
{
|
{
|
||||||
allFiltered = modColumn.AvailableMods.All(modState => !modState.IsValid);
|
allFiltered = modColumn.AvailableMods.All(modState => !modState.Visible);
|
||||||
modColumn.FlushPendingSelections();
|
modColumn.FlushPendingSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
return true;
|
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)
|
if (firstMod is not null)
|
||||||
firstMod.Active.Value = !firstMod.Active.Value;
|
firstMod.Active.Value = !firstMod.Active.Value;
|
||||||
|
@ -39,9 +39,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
public BindableBool ValidForSelection { get; } = new BindableBool(true);
|
public BindableBool ValidForSelection { get; } = new BindableBool(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public bool IsValid => MatchingFilter.Value && ValidForSelection.Value;
|
public bool Visible => MatchingFilter.Value && ValidForSelection.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the mod is matching the current filter, i.e. it is available for user selection.
|
/// Whether the mod is matching the current filter, i.e. it is available for user selection.
|
||||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
Enabled.Value = availableMods.Value
|
Enabled.Value = availableMods.Value
|
||||||
.SelectMany(pair => pair.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)
|
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||||
|
Loading…
Reference in New Issue
Block a user