mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 21:47:28 +08:00
Merge pull request #17277 from peppy/skin-editor-sidebars
Update skin editor to use `EditorSidebar`
This commit is contained in:
commit
fa8058e025
@ -2,7 +2,9 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Skinning.Editor;
|
using osu.Game.Skinning.Editor;
|
||||||
@ -11,13 +13,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
public class TestSceneSkinEditorComponentsList : SkinnableTestScene
|
public class TestSceneSkinEditorComponentsList : SkinnableTestScene
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestToggleEditor()
|
public void TestToggleEditor()
|
||||||
{
|
{
|
||||||
AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox(300)
|
AddStep("show available components", () => SetContents(_ => new SkinComponentToolbox
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopRight,
|
||||||
|
Width = 0.6f,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,19 +18,17 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Edit.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Editor
|
namespace osu.Game.Skinning.Editor
|
||||||
{
|
{
|
||||||
public class SkinComponentToolbox : ScrollingToolboxGroup
|
public class SkinComponentToolbox : EditorSidebarSection
|
||||||
{
|
{
|
||||||
public const float WIDTH = 200;
|
|
||||||
|
|
||||||
public Action<Type> RequestPlacement;
|
public Action<Type> RequestPlacement;
|
||||||
|
|
||||||
private const float component_display_scale = 0.8f;
|
private const float component_display_scale = 0.8f;
|
||||||
@ -45,11 +43,9 @@ namespace osu.Game.Skinning.Editor
|
|||||||
[Cached(typeof(HealthProcessor))]
|
[Cached(typeof(HealthProcessor))]
|
||||||
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
||||||
|
|
||||||
public SkinComponentToolbox(float height)
|
public SkinComponentToolbox()
|
||||||
: base("Components", height)
|
: base("Components")
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
|
||||||
Width = WIDTH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -17,7 +17,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Screens.Edit.Components;
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
using osu.Game.Screens.Edit.Components.Menus;
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Editor
|
namespace osu.Game.Skinning.Editor
|
||||||
@ -50,7 +50,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
private EditorToolboxGroup settingsToolbox;
|
private EditorSidebarSection settingsToolbox;
|
||||||
|
|
||||||
public SkinEditor()
|
public SkinEditor()
|
||||||
{
|
{
|
||||||
@ -71,82 +71,111 @@ namespace osu.Game.Skinning.Editor
|
|||||||
InternalChild = new OsuContextMenuContainer
|
InternalChild = new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Child = new GridContainer
|
||||||
{
|
{
|
||||||
new Container
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
{
|
{
|
||||||
Name = "Menu container",
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
RelativeSizeAxes = Axes.X,
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
Depth = float.MinValue,
|
new Dimension(),
|
||||||
Height = menu_height,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new EditorMenuBar
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Items = new[]
|
|
||||||
{
|
|
||||||
new MenuItem("File")
|
|
||||||
{
|
|
||||||
Items = new[]
|
|
||||||
{
|
|
||||||
new EditorMenuItem("Save", MenuItemType.Standard, Save),
|
|
||||||
new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert),
|
|
||||||
new EditorMenuItemSpacer(),
|
|
||||||
new EditorMenuItem("Exit", MenuItemType.Standard, Hide),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
headerText = new OsuTextFlowContainer
|
|
||||||
{
|
|
||||||
TextAnchor = Anchor.TopRight,
|
|
||||||
Padding = new MarginPadding(5),
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new SkinEditorSceneLibrary
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Y = menu_height,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
new GridContainer
|
Content = new[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Drawable[]
|
||||||
ColumnDimensions = new[]
|
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
new Container
|
||||||
new Dimension(),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
},
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
{
|
||||||
new SkinComponentToolbox(600)
|
Name = "Menu container",
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Depth = float.MinValue,
|
||||||
|
Height = menu_height,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
new EditorMenuBar
|
||||||
Origin = Anchor.CentreLeft,
|
{
|
||||||
RequestPlacement = placeComponent
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Items = new[]
|
||||||
|
{
|
||||||
|
new MenuItem("File")
|
||||||
|
{
|
||||||
|
Items = new[]
|
||||||
|
{
|
||||||
|
new EditorMenuItem("Save", MenuItemType.Standard, Save),
|
||||||
|
new EditorMenuItem("Revert to default", MenuItemType.Destructive, revert),
|
||||||
|
new EditorMenuItemSpacer(),
|
||||||
|
new EditorMenuItem("Exit", MenuItemType.Standard, Hide),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headerText = new OsuTextFlowContainer
|
||||||
|
{
|
||||||
|
TextAnchor = Anchor.TopRight,
|
||||||
|
Padding = new MarginPadding(5),
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
content = new Container
|
},
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new SkinEditorSceneLibrary
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
ColumnDimensions = new[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
},
|
},
|
||||||
settingsToolbox = new SkinSettingsToolbox
|
Content = new[]
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
new Drawable[]
|
||||||
Origin = Anchor.CentreRight,
|
{
|
||||||
|
new EditorSidebar
|
||||||
|
{
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new SkinComponentToolbox
|
||||||
|
{
|
||||||
|
RequestPlacement = placeComponent
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content = new Container
|
||||||
|
{
|
||||||
|
Depth = float.MaxValue,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new EditorSidebar
|
||||||
|
{
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
settingsToolbox = new SkinSettingsToolbox
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -180,17 +209,9 @@ namespace osu.Game.Skinning.Editor
|
|||||||
SelectedComponents.Clear();
|
SelectedComponents.Clear();
|
||||||
|
|
||||||
Scheduler.AddOnce(loadBlueprintContainer);
|
Scheduler.AddOnce(loadBlueprintContainer);
|
||||||
|
Scheduler.AddOnce(populateSettings);
|
||||||
|
|
||||||
void loadBlueprintContainer()
|
void loadBlueprintContainer() => content.Child = new SkinBlueprintContainer(targetScreen);
|
||||||
{
|
|
||||||
content.Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SkinBlueprintContainer(targetScreen)
|
|
||||||
{
|
|
||||||
Margin = new MarginPadding { Top = 100 },
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void skinChanged()
|
private void skinChanged()
|
||||||
|
@ -2,22 +2,26 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Screens.Edit.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Editor
|
namespace osu.Game.Skinning.Editor
|
||||||
{
|
{
|
||||||
internal class SkinSettingsToolbox : ScrollingToolboxGroup
|
internal class SkinSettingsToolbox : EditorSidebarSection
|
||||||
{
|
{
|
||||||
public const float WIDTH = 200;
|
protected override Container<Drawable> Content { get; }
|
||||||
|
|
||||||
public SkinSettingsToolbox()
|
public SkinSettingsToolbox()
|
||||||
: base("Settings", 600)
|
: base("Settings")
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None;
|
base.Content.Add(Content = new FillFlowContainer
|
||||||
Width = WIDTH;
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
FillFlow.Spacing = new Vector2(10);
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user