mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 00:07:15 +00:00
Use tuples and ComboItem, not anonymous class
Little more explicit
This commit is contained in:
parent
9deafa851a
commit
be9c947dd6
4 changed files with 19 additions and 10 deletions
|
@ -45,7 +45,10 @@ namespace PKHeX.Core
|
|||
this[i] = value[i];
|
||||
}
|
||||
|
||||
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => GetAllEntities().Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index));
|
||||
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => GetAllEntities()
|
||||
.Select((z, i) => (Entry: z, Index: i))
|
||||
.Where(z => z.Entry.Species > 0)
|
||||
.Select(z => z.Entry.Dump(speciesNames, z.Index));
|
||||
|
||||
public IEnumerator<GP1> GetEnumerator() => (IEnumerator<GP1>)GetAllEntities().GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetAllEntities().GetEnumerator();
|
||||
|
|
|
@ -315,7 +315,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
else
|
||||
{
|
||||
PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } };
|
||||
PrevRegions[index].DataSource = new[] { new ComboItem("", 0) };
|
||||
PrevRegions[index].Enabled = false;
|
||||
PrevRegions[index].SelectedValue = 0;
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ namespace PKHeX.WinForms
|
|||
PrevCountries[index].SelectedValue = 0;
|
||||
|
||||
PrevRegions[index].InitializeBinding();
|
||||
PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } };
|
||||
PrevRegions[index].DataSource = new[] { new ComboItem("", 0) };
|
||||
PrevRegions[index].SelectedValue = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#if DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
@ -123,9 +124,15 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
LocalizationUtil.SetLocalization(t, lang);
|
||||
var entries = LocalizationUtil.GetLocalization(t);
|
||||
var export = entries.Select(z => new {Variable = z.Split('=')[0], Line = z})
|
||||
.OrderBy(z => z.Variable) // sort by length (V1 = 2, V100 = 4)
|
||||
.Select(z => z.Line); // sorted lines
|
||||
IEnumerable<string> export = entries.OrderBy(GetName); // sorted lines
|
||||
|
||||
static string GetName(string line)
|
||||
{
|
||||
var index = line.IndexOf('=');
|
||||
if (index == -1)
|
||||
return line;
|
||||
return line[..index];
|
||||
}
|
||||
|
||||
if (!sorted)
|
||||
export = entries;
|
||||
|
|
|
@ -173,12 +173,11 @@ namespace PKHeX.WinForms
|
|||
|
||||
public static void DumpAll(params string[] banlist)
|
||||
{
|
||||
var results = Context.Select(z => new {Lang = z.Key, Lines = z.Value.Write()});
|
||||
foreach (var c in results)
|
||||
foreach (var c in Context)
|
||||
{
|
||||
var lang = c.Lang;
|
||||
var lang = c.Key;
|
||||
var fn = GetTranslationFileNameExternal(lang);
|
||||
var lines = c.Lines;
|
||||
var lines = c.Value.Write();
|
||||
var result = lines.Where(z => !banlist.Any(z.Contains));
|
||||
File.WriteAllLines(fn, result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue