@@ -35,29 +35,6 @@ namespace PlayEveryWare.EpicOnlineServices.Extensions
3535 /// </summary>
3636 public static class InputStateButtonFlagsExtensions
3737 {
38- /// <summary>
39- /// Returns the internal custom mappings.
40- /// </summary>
41- public static Dictionary < string , InputStateButtonFlags > CustomMappings { get ; } = new ( )
42- {
43- { "DPadDown" , InputStateButtonFlags . DPadDown } ,
44- { "DPadLeft" , InputStateButtonFlags . DPadLeft } ,
45- { "DPadRight" , InputStateButtonFlags . DPadRight } ,
46- { "DPadUp" , InputStateButtonFlags . DPadUp } ,
47- { "FaceButtonBottom" , InputStateButtonFlags . FaceButtonBottom } ,
48- { "FaceButtonLeft" , InputStateButtonFlags . FaceButtonLeft } ,
49- { "FaceButtonRight" , InputStateButtonFlags . FaceButtonRight } ,
50- { "FaceButtonTop" , InputStateButtonFlags . FaceButtonTop } ,
51- { "LeftShoulder" , InputStateButtonFlags . LeftShoulder } ,
52- { "LeftThumbstick" , InputStateButtonFlags . LeftThumbstick } ,
53- { "LeftTrigger" , InputStateButtonFlags . LeftTrigger } ,
54- { "RightShoulder" , InputStateButtonFlags . RightShoulder } ,
55- { "RightThumbstick" , InputStateButtonFlags . RightThumbstick } ,
56- { "RightTrigger" , InputStateButtonFlags . RightTrigger } ,
57- { "SpecialLeft" , InputStateButtonFlags . SpecialLeft } ,
58- { "SpecialRight" , InputStateButtonFlags . SpecialRight }
59- } ;
60-
6138 /// <summary>
6239 /// Tries to parse the given list of strings representing individual
6340 /// InputStateButtonFlags enum values, and performing a
@@ -76,54 +53,7 @@ public static class InputStateButtonFlagsExtensions
7653 /// </returns>
7754 public static bool TryParse ( IList < string > stringFlags , out InputStateButtonFlags result )
7855 {
79- return EnumUtility < InputStateButtonFlags > . TryParse ( stringFlags , CustomMappings , out result ) ;
80- }
81-
82- /// <summary>
83- /// Parses an InputStateButtonFlags value in to its component strings.
84- /// These strings can then be safely stored in a configuration value.
85- /// </summary>
86- /// <param name="flags">Enum to separate into parts.</param>
87- /// <returns>A list of strings representing these flags.</returns>
88- public static List < string > FlagsToStrings ( this InputStateButtonFlags flags )
89- {
90- List < string > flagStrings = new List < string > ( ) ;
91-
92- // Iterate over all possible flag values
93- foreach ( InputStateButtonFlags flagOption in Enum . GetValues ( typeof ( InputStateButtonFlags ) ) )
94- {
95- // If the passed in Enum doesn't have this flag, skip it
96- if ( ! flags . HasFlag ( flagOption ) )
97- {
98- continue ;
99- }
100-
101- // Look up this flag's name in the custom mappings dictionary
102- // The dictionary is keyed by string value and valued by enum,
103- // so it must be entirely traversed to find its matching string
104- bool foundMapping = false ;
105- foreach ( KeyValuePair < string , InputStateButtonFlags > mapping in CustomMappings )
106- {
107- // Continue if this isn't the flag that matches the current option
108- if ( mapping . Value != flagOption )
109- {
110- continue ;
111- }
112-
113- // This is the value needed, so use it
114- flagStrings . Add ( mapping . Key ) ;
115- foundMapping = true ;
116- continue ;
117- }
118-
119- // If no custom mapping was found, use ToString instead
120- if ( ! foundMapping )
121- {
122- flagStrings . Add ( flagOption . ToString ( ) ) ;
123- }
124- }
125-
126- return flagStrings ;
56+ return EnumUtility < InputStateButtonFlags > . TryParse ( stringFlags , null , out result ) ;
12757 }
12858 }
12959}
0 commit comments