mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 22:13:22 +08:00
Make placeComponent
resilient to missing dependencies
This commit is contained in:
parent
a9c7edd087
commit
b68562b033
@ -353,12 +353,18 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
placeComponent(component);
|
placeComponent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeComponent(ISerialisableDrawable component, bool applyDefaults = true)
|
/// <summary>
|
||||||
|
/// Attempt to place a given component in the current target.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="component">The component to be placed.</param>
|
||||||
|
/// <param name="applyDefaults">Whether to apply default anchor / origin / position values.</param>
|
||||||
|
/// <returns>Whether placement succeeded. Could fail if no target is available, or if the current target has missing dependency requirements for the component.</returns>
|
||||||
|
private bool placeComponent(ISerialisableDrawable component, bool applyDefaults = true)
|
||||||
{
|
{
|
||||||
var targetContainer = getFirstTarget();
|
var targetContainer = getFirstTarget();
|
||||||
|
|
||||||
if (targetContainer == null)
|
if (targetContainer == null)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var drawableComponent = (Drawable)component;
|
var drawableComponent = (Drawable)component;
|
||||||
|
|
||||||
@ -370,10 +376,19 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
targetContainer.Add(component);
|
targetContainer.Add(component);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// May fail if dependencies are not available, for instance.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SelectedComponents.Clear();
|
SelectedComponents.Clear();
|
||||||
SelectedComponents.Add(component);
|
SelectedComponents.Add(component);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateSettings()
|
private void populateSettings()
|
||||||
|
Loading…
Reference in New Issue
Block a user