diff --git a/Main.cs b/Main.cs index 351dd92..f4e3544 100644 --- a/Main.cs +++ b/Main.cs @@ -10,8 +10,12 @@ namespace NLSE public partial class Main : Form { internal static string root; - internal static string[] itemNames = Data.getItemStrings("en"); + internal static string[] itemNames = Data.getIndexStrings("item", "en"); + internal static string[] buildingNames = Data.getIndexStrings("building", "en"); + internal static string[] villagerNames = Data.getStrings("name", "en"); internal static List itemList = Data.getCBItems(itemNames); + internal static List vList = Data.getCBList(villagerNames, null); + internal static List buildingList = Data.getCBItems(buildingNames); internal static ACNLVillager[] villagerList = Data.GetVillagers(); public Main() { diff --git a/Misc/Data.cs b/Misc/Data.cs index 251d89b..4f3a507 100644 --- a/Misc/Data.cs +++ b/Misc/Data.cs @@ -18,10 +18,10 @@ internal static ACNLVillager[] GetVillagers() return vAr; } - internal static string[] getItemStrings(string l) + internal static string[] getIndexStrings(string f, string l) { string[] storage = new string[0x8000]; - object txt = Properties.Resources.ResourceManager.GetObject("item_" + l); // Fetch File, \n to list. + object txt = Properties.Resources.ResourceManager.GetObject(f + "_" + l); // Fetch File, \n to list. List rawlist = ((string)txt).Split(new[] { '\n' }).ToList(); string[] input = rawlist.ToArray(); @@ -41,6 +41,13 @@ internal static string[] getItemStrings(string l) return storage; } + internal static string[] getStrings(string f, string l) + { + object txt = Properties.Resources.ResourceManager.GetObject(f + "_" + l); // Fetch File, \n to list. + List rawlist = ((string) txt).Split(new[] {'\n'}).ToList(); + return rawlist.ToArray(); + } + internal static List getCBItems(string[] storage) { List cbList = new List(); @@ -57,6 +64,32 @@ internal static List getCBItems(string[] storage) catch { } return cbList; } + internal static List getCBList(string[] inStrings, params int[][] allowed) + { + List cbList = new List(); + if (allowed == null) + allowed = new[] { Enumerable.Range(0, inStrings.Length).ToArray() }; + + foreach (int[] list in allowed) + { + // Sort the Rest based on String Name + string[] unsortedChoices = new string[list.Length]; + for (int i = 0; i < list.Length; i++) + unsortedChoices[i] = inStrings[list[i]]; + + string[] sortedChoices = new string[unsortedChoices.Length]; + Array.Copy(unsortedChoices, sortedChoices, unsortedChoices.Length); + Array.Sort(sortedChoices); + + // Add the rest of the items + cbList.AddRange(sortedChoices.Select(t => new cbItem + { + Text = t, + Value = list[Array.IndexOf(unsortedChoices, t)] + })); + } + return cbList; + } } public class cbItem { diff --git a/NLSE.csproj b/NLSE.csproj index 0640364..10be3db 100644 --- a/NLSE.csproj +++ b/NLSE.csproj @@ -1019,6 +1019,12 @@ + + + + + +