mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-23 11:06:02 -05:00
Minor clean
no functional change
This commit is contained in:
@@ -125,14 +125,14 @@ private static IEnumerable<T> GetAll<T>(this TypeInfo typeInfo, Func<TypeInfo, I
|
||||
return GetAllTypeInfo(typeInfo).SelectMany(_ => accessor(typeInfo));
|
||||
}
|
||||
|
||||
public static Dictionary<T, string> GetAllConstantsOfType<T>(this Type type)
|
||||
public static Dictionary<T, string> GetAllConstantsOfType<T>(this Type type) where T : struct
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy);
|
||||
var consts = fields.Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(T));
|
||||
return consts.ToDictionary(x => (T)x.GetRawConstantValue(), z => z.Name);
|
||||
}
|
||||
|
||||
public static Dictionary<T, string> GetAllPropertiesOfType<T>(this Type type, object obj)
|
||||
public static Dictionary<T, string> GetAllPropertiesOfType<T>(this Type type, object obj) where T : class
|
||||
{
|
||||
var props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
||||
var ofType = props.Where(fi => typeof(T).IsAssignableFrom(fi.PropertyType));
|
||||
|
||||
@@ -12,18 +12,16 @@ public static string[] GetItemListResource(string msgPath)
|
||||
{
|
||||
var list = GetItemList(msgPath);
|
||||
var max = list.Max(z => z.Key);
|
||||
var result = new string[max + 1];
|
||||
var result = new string?[max + 1];
|
||||
|
||||
foreach (var item in list)
|
||||
result[item.Key] = item.Value;
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
if (result[i] == null)
|
||||
result[i] = string.Empty;
|
||||
}
|
||||
result[i] ??= string.Empty;
|
||||
|
||||
result[0] = "(None)";
|
||||
result[5794] = "DIY recipe";
|
||||
return result;
|
||||
return result!;
|
||||
}
|
||||
|
||||
public static string[] GetArtList(string msgPath)
|
||||
|
||||
@@ -65,11 +65,11 @@ private static void DumpItem(string corePath, string langID, string msbtFolder,
|
||||
|
||||
private static void DumpRemake(string corePath, string langID, string msbtFolder, string langFolderCode)
|
||||
{
|
||||
Dump("body_color", "STR_Remake_BodyColor.msbt");
|
||||
Dump("body_parts", "STR_Remake_BodyParts.msbt");
|
||||
Dump("fabric_color", "STR_Remake_FabricColor.msbt");
|
||||
Dump("fabric_parts", "STR_Remake_FabricParts.msbt");
|
||||
void Dump(string name, string msbt)
|
||||
DumpMSBT("body_color", "STR_Remake_BodyColor.msbt");
|
||||
DumpMSBT("body_parts", "STR_Remake_BodyParts.msbt");
|
||||
DumpMSBT("fabric_color", "STR_Remake_FabricColor.msbt");
|
||||
DumpMSBT("fabric_parts", "STR_Remake_FabricParts.msbt");
|
||||
void DumpMSBT(string name, string msbt)
|
||||
{
|
||||
var dest = Path.Combine(corePath, langID, $"text_{name}_{langID}.txt");
|
||||
var folder = string.Format(msbtFolder, langFolderCode);
|
||||
|
||||
@@ -57,7 +57,7 @@ private void Main_DragEnter(object sender, DragEventArgs e)
|
||||
|
||||
private void Main_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
var files = (string[]?)e.Data.GetData(DataFormats.FileDrop);
|
||||
if (files == null || files.Length == 0)
|
||||
return;
|
||||
Open(files[0]);
|
||||
|
||||
@@ -64,7 +64,7 @@ internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines
|
||||
/// Gets the selected value of the input <see cref="cb"/>. If no value is selected, will return 0.
|
||||
/// </summary>
|
||||
/// <param name="cb">ComboBox to retrieve value for.</param>
|
||||
internal static int GetIndex(ListControl cb) => (int)(cb?.SelectedValue ?? 0);
|
||||
internal static int GetIndex(ListControl cb) => (int)(cb.SelectedValue ?? 0);
|
||||
|
||||
public static T? FirstFormOfType<T>() where T : Form => (T?)Application.OpenForms.Cast<Form>().FirstOrDefault(form => form is T);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user