private void spawnHeaderComboBox_IndexChanged(object sender, EventArgs e) { ushort headerNumber = ushort.Parse(spawnHeaderComboBox.SelectedItem.ToString().Split()[0]); MapHeader currentHeader = MapHeader.LoadFromARM9(headerNumber); Matrix headerMatrix = new Matrix(currentHeader.matrixID); matrixxUpDown.Maximum = headerMatrix.maps.GetLength(1) - 1; matrixyUpDown.Maximum = headerMatrix.maps.GetLength(0) - 1; switch (RomInfo.gameVersion) { case "D": case "P": locationNameLBL.Text = locations.messages[((HeaderDP)currentHeader).locationName]; break; case "Plat": locationNameLBL.Text = locations.messages[((HeaderPt)currentHeader).locationName]; break; case "HG": case "SS": locationNameLBL.Text = locations.messages[((HeaderHGSS)currentHeader).locationName]; break; } }
public static List <string> advancedSearch(ushort startID, ushort finalID, List <string> intNames, string fieldToSearch, string oper, string valToSearch) { if (fieldToSearch == "" || oper == "" || valToSearch == "") { return(null); } List <string> result = new List <string>(); switch (fieldToSearch) { case "Internal Name": for (ushort i = startID; i < finalID; i++) { if (oper.Equals("Is Exactly")) { if (intNames[i].Equals(valToSearch)) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.Equals("Is Not")) { if (!intNames[i].Equals(valToSearch)) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.Equals("Contains")) { if (intNames[i].IndexOf(valToSearch, StringComparison.InvariantCultureIgnoreCase) >= 0) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.Equals("Does not contain")) { if (intNames[i].IndexOf(valToSearch, StringComparison.InvariantCultureIgnoreCase) < 0) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } } break; case "Music Day (Name)": //Maybe in the future break; case "Music Night (Name)": //Maybe in the future break; default: string[] fieldSplit = fieldToSearch.Split(); fieldSplit[0] = fieldSplit[0].ToLower(); fieldSplit[fieldSplit.Length - 1] = fieldSplit[fieldSplit.Length - 1].Replace("(", ""); //Remove ( from string fieldSplit[fieldSplit.Length - 1] = fieldSplit[fieldSplit.Length - 1].Replace(")", ""); //Remove ) from string string property = String.Join("", fieldSplit); ushort numToSearch = 0; try { numToSearch = ushort.Parse(valToSearch); } catch (OverflowException) { MessageBox.Show("Your input exceeds the range of 16-bit integers (" + ushort.MinValue + " - " + ushort.MaxValue + ").", "Overflow Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } for (ushort i = startID; i < finalID; i++) { var headerFieldEntry = typeof(MapHeader).GetProperty(property).GetValue(MapHeader.LoadFromARM9(i), null); int headerField = int.Parse(headerFieldEntry.ToString()); if (oper.Equals("Is Less than")) { if (headerField < numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.Equals("Equals")) { if (headerField == numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.StartsWith("Is Greater")) { if (headerField > numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.StartsWith("Is Less than or Equal")) { if (headerField <= numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.StartsWith("Is Greater than or Equal")) { if (headerField >= numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else if (oper.StartsWith("Is Different")) { if (headerField != numToSearch) { result.Add(i.ToString("D3") + MapHeader.nameSeparator + intNames[i]); } } else { Console.WriteLine("Unrecognized operand!!!"); break; } } break; } return(result); }