Remove unused fields and parameters.

This commit is contained in:
Matthias Mailänder
2021-10-21 17:39:48 +02:00
committed by abcdefg30
parent 3b5bfb4bf4
commit a3ccc81892
10 changed files with 20 additions and 25 deletions

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Lint
void CheckActorReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, void CheckActorReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, ActorInfo> dict, ActorReferenceAttribute attribute) FieldInfo fieldInfo, IReadOnlyDictionary<string, ActorInfo> dict, ActorReferenceAttribute attribute)
{ {
var values = LintExts.GetFieldValues(traitInfo, fieldInfo, emitError, attribute.DictionaryReference); var values = LintExts.GetFieldValues(traitInfo, fieldInfo, attribute.DictionaryReference);
foreach (var value in values) foreach (var value in values)
{ {
if (value == null) if (value == null)
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Lint
void CheckWeaponReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, void CheckWeaponReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, WeaponInfo> dict) FieldInfo fieldInfo, IReadOnlyDictionary<string, WeaponInfo> dict)
{ {
var values = LintExts.GetFieldValues(traitInfo, fieldInfo, emitError); var values = LintExts.GetFieldValues(traitInfo, fieldInfo);
foreach (var value in values) foreach (var value in values)
{ {
if (value == null) if (value == null)
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Lint
void CheckVoiceReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo, void CheckVoiceReference(Action<string> emitError, ActorInfo actorInfo, TraitInfo traitInfo,
FieldInfo fieldInfo, IReadOnlyDictionary<string, SoundInfo> dict) FieldInfo fieldInfo, IReadOnlyDictionary<string, SoundInfo> dict)
{ {
var values = LintExts.GetFieldValues(traitInfo, fieldInfo, emitError); var values = LintExts.GetFieldValues(traitInfo, fieldInfo);
foreach (var value in values) foreach (var value in values)
{ {
if (value == null) if (value == null)

View File

@@ -40,19 +40,19 @@ namespace OpenRA.Mods.Common.Lint
{ {
var fieldConsumed = trait.GetType().GetFields() var fieldConsumed = trait.GetType().GetFields()
.Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>()) .Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>())
.SelectMany(f => LintExts.GetFieldValues(trait, f, emitError)); .SelectMany(f => LintExts.GetFieldValues(trait, f));
var propertyConsumed = trait.GetType().GetProperties() var propertyConsumed = trait.GetType().GetProperties()
.Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>()) .Where(x => x.HasAttribute<ConsumedConditionReferenceAttribute>())
.SelectMany(p => LintExts.GetPropertyValues(trait, p, emitError)); .SelectMany(p => LintExts.GetPropertyValues(trait, p));
var fieldGranted = trait.GetType().GetFields() var fieldGranted = trait.GetType().GetFields()
.Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>()) .Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>())
.SelectMany(f => LintExts.GetFieldValues(trait, f, emitError)); .SelectMany(f => LintExts.GetFieldValues(trait, f));
var propertyGranted = trait.GetType().GetProperties() var propertyGranted = trait.GetType().GetProperties()
.Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>()) .Where(x => x.HasAttribute<GrantedConditionReferenceAttribute>())
.SelectMany(f => LintExts.GetPropertyValues(trait, f, emitError)); .SelectMany(f => LintExts.GetPropertyValues(trait, f));
foreach (var c in fieldConsumed.Concat(propertyConsumed)) foreach (var c in fieldConsumed.Concat(propertyConsumed))
if (!string.IsNullOrEmpty(c)) if (!string.IsNullOrEmpty(c))

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Lint
if (cursorReference == null) if (cursorReference == null)
continue; continue;
var cursor = LintExts.GetFieldValues(traitInfo, field, emitError, cursorReference.DictionaryReference).FirstOrDefault(); var cursor = LintExts.GetFieldValues(traitInfo, field, cursorReference.DictionaryReference).FirstOrDefault();
if (string.IsNullOrEmpty(cursor)) if (string.IsNullOrEmpty(cursor))
continue; continue;

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Lint
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<LocomotorReferenceAttribute>()); var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<LocomotorReferenceAttribute>());
foreach (var field in fields) foreach (var field in fields)
{ {
var locomotors = LintExts.GetFieldValues(traitInfo, field, emitError); var locomotors = LintExts.GetFieldValues(traitInfo, field);
foreach (var locomotor in locomotors) foreach (var locomotor in locomotors)
{ {
if (string.IsNullOrEmpty(locomotor)) if (string.IsNullOrEmpty(locomotor))

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Lint
else else
type = notificationReference.NotificationType; type = notificationReference.NotificationType;
var notifications = LintExts.GetFieldValues(traitInfo, field, emitError); var notifications = LintExts.GetFieldValues(traitInfo, field);
foreach (var notification in notifications) foreach (var notification in notifications)
{ {
if (string.IsNullOrEmpty(notification)) if (string.IsNullOrEmpty(notification))

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Lint
isPlayerPalette = paletteReference.IsPlayerPalette; isPlayerPalette = paletteReference.IsPlayerPalette;
} }
var references = LintExts.GetFieldValues(traitInfo, field, emitError); var references = LintExts.GetFieldValues(traitInfo, field);
foreach (var reference in references) foreach (var reference in references)
{ {
if (string.IsNullOrEmpty(reference)) if (string.IsNullOrEmpty(reference))
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Lint
isPlayerPalette = paletteReference.IsPlayerPalette; isPlayerPalette = paletteReference.IsPlayerPalette;
} }
var references = LintExts.GetFieldValues(projectileInfo, field, emitError); var references = LintExts.GetFieldValues(projectileInfo, field);
foreach (var reference in references) foreach (var reference in references)
{ {
if (string.IsNullOrEmpty(reference)) if (string.IsNullOrEmpty(reference))
@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var field in fields.Where(x => x.HasAttribute<PaletteDefinitionAttribute>())) foreach (var field in fields.Where(x => x.HasAttribute<PaletteDefinitionAttribute>()))
{ {
var paletteDefinition = field.GetCustomAttributes<PaletteDefinitionAttribute>(true).First(); var paletteDefinition = field.GetCustomAttributes<PaletteDefinitionAttribute>(true).First();
var values = LintExts.GetFieldValues(traitInfo, field, emitError); var values = LintExts.GetFieldValues(traitInfo, field);
foreach (var value in values) foreach (var value in values)
{ {
if (paletteDefinition.IsPlayerPalette) if (paletteDefinition.IsPlayerPalette)

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Lint
sequenceImages = new[] { imageOverride.ToLowerInvariant() }; sequenceImages = new[] { imageOverride.ToLowerInvariant() };
} }
foreach (var sequence in LintExts.GetFieldValues(traitInfo, field, emitError, sequenceReference.DictionaryReference)) foreach (var sequence in LintExts.GetFieldValues(traitInfo, field, sequenceReference.DictionaryReference))
{ {
if (string.IsNullOrEmpty(sequence)) if (string.IsNullOrEmpty(sequence))
continue; continue;
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Lint
} }
image = image.ToLowerInvariant(); image = image.ToLowerInvariant();
foreach (var sequence in LintExts.GetFieldValues(projectileInfo, field, emitError, sequenceReference.DictionaryReference)) foreach (var sequence in LintExts.GetFieldValues(projectileInfo, field, sequenceReference.DictionaryReference))
{ {
if (string.IsNullOrEmpty(sequence)) if (string.IsNullOrEmpty(sequence))
continue; continue;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceSetReferenceAttribute>()); var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceSetReferenceAttribute>());
foreach (var field in fields) foreach (var field in fields)
{ {
var voiceSets = LintExts.GetFieldValues(traitInfo, field, emitError); var voiceSets = LintExts.GetFieldValues(traitInfo, field);
foreach (var voiceSet in voiceSets) foreach (var voiceSet in voiceSets)
{ {
if (string.IsNullOrEmpty(voiceSet)) if (string.IsNullOrEmpty(voiceSet))
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Lint
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceReferenceAttribute>()); var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceReferenceAttribute>());
foreach (var field in fields) foreach (var field in fields)
{ {
var voices = LintExts.GetFieldValues(traitInfo, field, emitError); var voices = LintExts.GetFieldValues(traitInfo, field);
foreach (var voice in voices) foreach (var voice in voices)
{ {
if (string.IsNullOrEmpty(voice)) if (string.IsNullOrEmpty(voice))

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Lint
{ {
public class LintExts public class LintExts
{ {
public static IEnumerable<string> GetFieldValues(object ruleInfo, FieldInfo fieldInfo, Action<string> emitError, public static IEnumerable<string> GetFieldValues(object ruleInfo, FieldInfo fieldInfo,
LintDictionaryReference dictionaryReference = LintDictionaryReference.None) LintDictionaryReference dictionaryReference = LintDictionaryReference.None)
{ {
var type = fieldInfo.FieldType; var type = fieldInfo.FieldType;
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Lint
throw new InvalidOperationException($"Bad type for reference on {ruleInfo.GetType().Name}.{fieldInfo.Name}. Supported types: {supportedTypes.JoinWith(", ")}"); throw new InvalidOperationException($"Bad type for reference on {ruleInfo.GetType().Name}.{fieldInfo.Name}. Supported types: {supportedTypes.JoinWith(", ")}");
} }
public static IEnumerable<string> GetPropertyValues(object ruleInfo, PropertyInfo propertyInfo, Action<string> emitError, public static IEnumerable<string> GetPropertyValues(object ruleInfo, PropertyInfo propertyInfo,
LintDictionaryReference dictionaryReference = LintDictionaryReference.None) LintDictionaryReference dictionaryReference = LintDictionaryReference.None)
{ {
var type = propertyInfo.PropertyType; var type = propertyInfo.PropertyType;

View File

@@ -10,7 +10,6 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -22,13 +21,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world; readonly World world;
readonly Widget worldRoot; readonly Widget worldRoot;
readonly Widget menuRoot; readonly Widget menuRoot;
readonly string clickSound = ChromeMetrics.Get<string>("ClickSound");
bool disableSystemButtons; bool disableSystemButtons;
Widget currentWidget; Widget currentWidget;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MenuButtonsChromeLogic(Widget widget, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs) public MenuButtonsChromeLogic(Widget widget, World world)
{ {
this.world = world; this.world = world;
@@ -82,9 +80,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "initialPanel", IngameInfoPanel.Debug } { "initialPanel", IngameInfoPanel.Debug }
}); });
} }
if (logicArgs.TryGetValue("ClickSound", out var yaml))
clickSound = yaml.Value;
} }
void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null) void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)