From 8de2f1c9bb28ab679c6d581e5d9289cfdeddbd60 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 8 Jun 2018 14:55:17 -0700 Subject: [PATCH] Add helper function to make list of systems --- Utilities.cs | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Utilities.cs b/Utilities.cs index aafbe076..2896783c 100644 --- a/Utilities.cs +++ b/Utilities.cs @@ -517,5 +517,67 @@ namespace DICUI return parameters; } + + /// + /// Create a list of systems matched to their respective enums + /// + /// + /// + /// This returns a List of Tuples whose structure is as follows: + /// Item 1: Printable name + /// Item 2: KnownSystem mapping + /// Item 3: DiscType mapping + /// If something has a "string, null, null" value, it should be assumed that it is a separator + /// + public static List> CreateListOfSystems() + { + List> mapping = new List>(); + + foreach (KnownSystem system in Enum.GetValues(typeof(KnownSystem))) + { + // In the special cases of breaks, we want to add the proper mappings for sections + switch (system) + { + // Consoles section + case KnownSystem.BandaiPlaydiaQuickInteractiveSystem: + mapping.Add(new Tuple("---------- Consoles ----------", null, null)); + break; + + // Computers section + case KnownSystem.AcornArchimedes: + mapping.Add(new Tuple("---------- Computers ----------", null, null)); + break; + + // Arcade section + case KnownSystem.NamcoSegaNintendoTriforce: + mapping.Add(new Tuple("---------- Arcade ----------", null, null)); + break; + + // Other section + case KnownSystem.AudioCD: + mapping.Add(new Tuple("---------- Others ----------", null, null)); + break; + } + + // First, get a list of all DiscTypes for a given KnownSystem + List types = GetValidDiscTypes(system); + + // If we have a single type, we don't want to postfix the system name with it + if (types.Count == 0) + { + mapping.Add(new Tuple(KnownSystemToString(system), system, types[0])); + } + // Otherwise, postfix the system name properly + else + { + foreach (DiscType type in types) + { + mapping.Add(new Tuple(KnownSystemToString(system) + "(" + DiscTypeToString(type) + ")", system, type)); + } + } + } + + return mapping; + } } }