From 59d97b844781f66eb07a481ea03bd7d165d291da Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Tue, 5 Jul 2016 09:35:24 -0500 Subject: [PATCH] WithTextDecoration: Move exception to Info via IRulesetLoaded --- OpenRA.Mods.Common/Traits/Render/WithTextDecoration.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithTextDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithTextDecoration.cs index c6d10790eb..a7d8fcf170 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTextDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTextDecoration.cs @@ -20,7 +20,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render { [Desc("Displays a text overlay relative to the selection box.")] - public class WithTextDecorationInfo : UpgradableTraitInfo + public class WithTextDecorationInfo : UpgradableTraitInfo, IRulesetLoaded { [FieldLoader.Require] [Translate] public readonly string Text = null; @@ -46,6 +46,12 @@ namespace OpenRA.Mods.Common.Traits.Render public readonly bool RequiresSelection = false; public override object Create(ActorInitializer init) { return new WithTextDecoration(init.Self, this); } + + void IRulesetLoaded.RulesetLoaded(Ruleset rules, ActorInfo info) + { + if (!Game.ModData.Manifest.Fonts.ContainsKey(Font)) + throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font)); + } } public class WithTextDecoration : UpgradableTrait, IRender, IPostRenderSelection, INotifyCapture @@ -61,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits.Render this.self = self; if (!Game.Renderer.Fonts.TryGetValue(info.Font, out font)) - throw new YamlException("Could not find font '{0}'".F(info.Font)); + throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(info.Font)); color = Info.UsePlayerColor ? self.Owner.Color.RGB : Info.Color; }