mirror of
https://github.com/ppy/osu
synced 2024-12-17 04:15:37 +00:00
new design
This commit is contained in:
parent
0095fd85ca
commit
54564e0557
@ -296,7 +296,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("clear preset name", () => popover.ChildrenOfType<LabelledTextBox>().First().Current.Value = "");
|
||||
AddStep("attempt preset edit", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().Single());
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().ElementAt(1));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
@ -306,7 +306,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("edit preset name", () => popover.ChildrenOfType<LabelledTextBox>().First().Current.Value = "something new");
|
||||
AddStep("attempt preset edit", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().Single());
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().ElementAt(1));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("popover closed", () => !this.ChildrenOfType<OsuPopover>().Any());
|
||||
@ -345,91 +345,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
OsuPopover? popover = null;
|
||||
AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType<OsuPopover>().FirstOrDefault()) != null);
|
||||
AddStep("enable switch", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Value = true);
|
||||
AddStep("attempt preset edit", () =>
|
||||
AddStep("click use current mods", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().Single());
|
||||
InputManager.MoveMouseTo(popover.ChildrenOfType<ShearedButton>().ElementAt(0));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("popover closed", () => !this.ChildrenOfType<OsuPopover>().Any());
|
||||
AddUntilStep("popover not closed", () => this.ChildrenOfType<OsuPopover>().Any());
|
||||
AddAssert("present mod is changed", () => this.ChildrenOfType<ModPresetPanel>().First().Preset.Value.Mods.Count == 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEditModSwitchDisableWithNoModSelest()
|
||||
{
|
||||
ModPresetColumn modPresetColumn = null!;
|
||||
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddStep("create content", () => Child = modPresetColumn = new ModPresetColumn
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
|
||||
AddUntilStep("items loaded", () => modPresetColumn.IsLoaded && modPresetColumn.ItemsLoaded);
|
||||
AddStep("right click first panel", () =>
|
||||
{
|
||||
var panel = this.ChildrenOfType<ModPresetPanel>().First();
|
||||
InputManager.MoveMouseTo(panel);
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for context menu", () => this.ChildrenOfType<OsuContextMenu>().Any());
|
||||
AddStep("click edit", () =>
|
||||
{
|
||||
var editItem = this.ChildrenOfType<DrawableOsuMenuItem>().ElementAt(0);
|
||||
InputManager.MoveMouseTo(editItem);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
OsuPopover? popover = null;
|
||||
AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType<OsuPopover>().FirstOrDefault()) != null);
|
||||
AddAssert("use current mod is disblaed", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Value == false);
|
||||
AddAssert("use current mod switch cannot be switch", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Disabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEditModSwitchDisableWithPresetSelest()
|
||||
{
|
||||
ModPresetColumn modPresetColumn = null!;
|
||||
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddStep("create content", () => Child = modPresetColumn = new ModPresetColumn
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
|
||||
AddUntilStep("items loaded", () => modPresetColumn.IsLoaded && modPresetColumn.ItemsLoaded);
|
||||
AddStep("select first preset mod", () =>
|
||||
SelectedMods.Value = this.ChildrenOfType<ModPresetPanel>().First().Preset.Value.Mods.ToList());
|
||||
|
||||
AddStep("right click first panel", () =>
|
||||
{
|
||||
var panel = this.ChildrenOfType<ModPresetPanel>().First();
|
||||
InputManager.MoveMouseTo(panel);
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for context menu", () => this.ChildrenOfType<OsuContextMenu>().Any());
|
||||
AddStep("click edit", () =>
|
||||
{
|
||||
var editItem = this.ChildrenOfType<DrawableOsuMenuItem>().ElementAt(0);
|
||||
InputManager.MoveMouseTo(editItem);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
OsuPopover? popover = null;
|
||||
AddUntilStep("wait for popover", () => (popover = this.ChildrenOfType<OsuPopover>().FirstOrDefault()) != null);
|
||||
AddAssert("use current mod is enabled", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Value);
|
||||
AddAssert("use current mod switch cannot be switch", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Disabled);
|
||||
|
||||
AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||
AddAssert("use current mod is disblaed", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Value == false);
|
||||
AddAssert("use current mod switch cannot be switch", () => popover.ChildrenOfType<LabelledSwitchButton>().Single().Current.Disabled);
|
||||
}
|
||||
|
||||
private ICollection<ModPreset> createTestPresets() => new[]
|
||||
{
|
||||
new ModPreset
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private readonly LabelledTextBox nameTextBox;
|
||||
private readonly LabelledTextBox descriptionTextBox;
|
||||
private readonly LabelledSwitchButton useCurrentSwitch;
|
||||
private readonly ShearedButton useCurrentModButton;
|
||||
private readonly ShearedButton createButton;
|
||||
|
||||
[Resolved]
|
||||
@ -42,6 +42,7 @@ namespace osu.Game.Overlays.Mods
|
||||
Width = 300,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(7),
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
nameTextBox = new LabelledTextBox
|
||||
@ -58,18 +59,30 @@ namespace osu.Game.Overlays.Mods
|
||||
Label = CommonStrings.Description,
|
||||
TabbableContentContainer = this
|
||||
},
|
||||
useCurrentSwitch = new LabelledSwitchButton
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Label = "Use Current Mod select",
|
||||
},
|
||||
createButton = new ShearedButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = CommonStrings.MenuBarEdit,
|
||||
Action = tryEditPreset
|
||||
Direction = FillDirection.Horizontal,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(7),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
useCurrentModButton = new ShearedButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = "Use Current Mods",
|
||||
Action = trySaveCurrentMod
|
||||
},
|
||||
createButton = new ShearedButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = Resources.Localisation.Web.CommonStrings.ButtonsSave,
|
||||
Action = tryEditPreset
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -84,28 +97,24 @@ namespace osu.Game.Overlays.Mods
|
||||
nameTextBox.Current.Value = preset.Name;
|
||||
descriptionTextBox.Current.Value = preset.Description;
|
||||
|
||||
selectedMods.BindValueChanged(_ => updateMods(), true);
|
||||
|
||||
createButton.DarkerColour = colours.Orange1;
|
||||
createButton.LighterColour = colours.Orange0;
|
||||
createButton.TextColour = colourProvider.Background6;
|
||||
|
||||
useCurrentModButton.DarkerColour = colours.Blue1;
|
||||
useCurrentModButton.LighterColour = colours.Blue0;
|
||||
useCurrentModButton.TextColour = colourProvider.Background6;
|
||||
}
|
||||
|
||||
private void updateMods()
|
||||
private void trySaveCurrentMod()
|
||||
{
|
||||
useCurrentSwitch.Current.Disabled = false;
|
||||
if (button.Active.Value || !selectedMods.Value.Any())
|
||||
return;
|
||||
|
||||
// disable the switch when mod is equal.
|
||||
if (button.Active.Value)
|
||||
button.Preset.PerformWrite(s =>
|
||||
{
|
||||
useCurrentSwitch.Current.Value = true;
|
||||
useCurrentSwitch.Current.Disabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
useCurrentSwitch.Current.Value = false;
|
||||
useCurrentSwitch.Current.Disabled = !selectedMods.Value.Any();
|
||||
}
|
||||
s.Mods = selectedMods.Value.ToArray();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -127,11 +136,6 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
s.Name = nameTextBox.Current.Value;
|
||||
s.Description = descriptionTextBox.Current.Value;
|
||||
|
||||
if (useCurrentSwitch.Current.Value)
|
||||
{
|
||||
s.Mods = selectedMods.Value.ToArray();
|
||||
}
|
||||
});
|
||||
|
||||
this.HidePopover();
|
||||
|
Loading…
Reference in New Issue
Block a user