mirror of
https://github.com/ppy/osu.git
synced 2025-01-29 05:52:56 +08:00
Throw again to ensure correct available state is set
Also standardises handling between `RulesetStore` and `RealmRulesetStore`.
This commit is contained in:
parent
57c333b472
commit
4bca96d548
15
osu.Game/Rulesets/RulesetLoadException.cs
Normal file
15
osu.Game/Rulesets/RulesetLoadException.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets
|
||||||
|
{
|
||||||
|
public class RulesetLoadException : Exception
|
||||||
|
{
|
||||||
|
public RulesetLoadException(string message)
|
||||||
|
: base(@$"Ruleset could not be loaded ({message})")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -128,18 +128,16 @@ namespace osu.Game.Rulesets
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var resolvedType = Type.GetType(r.InstantiationInfo);
|
var resolvedType = Type.GetType(r.InstantiationInfo)
|
||||||
|
?? throw new RulesetLoadException(@"Type could not be resolved");
|
||||||
|
|
||||||
if (resolvedType != null)
|
var instanceInfo = (Activator.CreateInstance(resolvedType) as Ruleset)?.RulesetInfo
|
||||||
{
|
?? throw new RulesetLoadException(@"Instantiation failure");
|
||||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(resolvedType)).RulesetInfo;
|
|
||||||
|
|
||||||
r.Name = instanceInfo.Name;
|
r.Name = instanceInfo.Name;
|
||||||
r.ShortName = instanceInfo.ShortName;
|
r.ShortName = instanceInfo.ShortName;
|
||||||
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
||||||
|
r.Available = true;
|
||||||
r.Available = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -147,19 +147,15 @@ namespace osu.Game.Stores
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var type = Type.GetType(r.InstantiationInfo);
|
var resolvedType = Type.GetType(r.InstantiationInfo)
|
||||||
|
?? throw new RulesetLoadException(@"Type could not be resolved");
|
||||||
|
|
||||||
if (type == null)
|
var instanceInfo = (Activator.CreateInstance(resolvedType) as Ruleset)?.RulesetInfo
|
||||||
throw new InvalidOperationException(@"Type resolution failure.");
|
?? throw new RulesetLoadException(@"Instantiation failure");
|
||||||
|
|
||||||
var rInstance = (Activator.CreateInstance(type) as Ruleset)?.RulesetInfo;
|
r.Name = instanceInfo.Name;
|
||||||
|
r.ShortName = instanceInfo.ShortName;
|
||||||
if (rInstance == null)
|
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
||||||
throw new InvalidOperationException(@"Instantiation failure.");
|
|
||||||
|
|
||||||
r.Name = rInstance.Name;
|
|
||||||
r.ShortName = rInstance.ShortName;
|
|
||||||
r.InstantiationInfo = rInstance.InstantiationInfo;
|
|
||||||
r.Available = true;
|
r.Available = true;
|
||||||
|
|
||||||
detachedRulesets.Add(r.Clone());
|
detachedRulesets.Add(r.Clone());
|
||||||
|
Loading…
Reference in New Issue
Block a user