Minor clean

This commit is contained in:
Kurt
2020-09-05 20:15:17 -07:00
parent 4f4483a810
commit 0203eb4017
5 changed files with 31 additions and 33 deletions

View File

@@ -56,7 +56,6 @@ void DumpU(string fn, ushort[] ushorts, string dir = "bin")
Console.WriteLine($"Created {fn}");
}
DumpS("bcsv_map.txt", BCSV.EnumLookup.Dump());
DumpS("lifeSupportAchievement.txt", GetLifeSupportAchievementList(pathBCSV));
DumpS("recipeDictionary.txt", GetRecipeList(pathBCSV));

View File

@@ -70,7 +70,7 @@ private static bool TryGetMenuIconSprite(ushort id, out Image? img)
// the 1 stops the original "leaf" being overwritten
var name = iconType == ItemMenuIconType.Leaf ? $"{iconType}1" : iconType.ToString();
img = (Image?)Resources.ResourceManager.GetObject(name);
img = (Image?)Resources.ResourceManager.GetObject(name);
return img != null;
}
@@ -83,10 +83,7 @@ private static bool TryGetItemImageSprite(ushort id, out string path, ushort cou
return true;
name = $"{id:00000}_0"; // fallback to no variation
if (SpriteFileExists(name, out path))
return true;
return false;
return SpriteFileExists(name, out path);
}
private static bool SpriteFileExists(string filename, out string path)

View File

@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using NHSE.Core;
using NHSE.Sprites;
@@ -227,7 +224,6 @@ public void LoadItems()
private static void ShowContextMenuBelow(ToolStripDropDown c, Control n) => c.Show(n.PointToScreen(new Point(0, n.Height)));
private void B_Clear_Click(object sender, EventArgs e) => ShowContextMenuBelow(CM_Remove, B_Clear);
private void ClearItemIf(Func<Item, bool> criteria)
{
bool all = ModifierKeys == Keys.Shift;
@@ -248,41 +244,48 @@ private void ClearItemIf(Func<Item, bool> criteria)
}
private void B_Sort_Click(object sender, EventArgs e) => ShowContextMenuBelow(CM_Sort, B_Sort);
private void B_SortAlpha_Click(object sender, EventArgs e) {
IEnumerable<Item> sortedItems = Items.Where(item => item.ItemId != Item.NONE).OrderBy(item => GetItemText(item).ToLower());
IList<Item> sortedItemsCopy = new List<Item>(); // to prevent object reference issues
private void B_SortAlpha_Click(object sender, EventArgs e)
{
var sortedItems = Items.Where(item => item.ItemId != Item.NONE)
.OrderBy(item => GetItemText(item).ToLower());
var sortedItemsCopy = new List<Item>(); // to prevent object reference issues
foreach(Item item in sortedItems) {
Item itemCopy = new Item();
foreach(var item in sortedItems)
{
var itemCopy = new Item();
itemCopy.CopyFrom(item);
sortedItemsCopy.Add(itemCopy);
}
SetEditorItems(sortedItemsCopy);
}
private void B_SortType_Click(object sender, EventArgs e) {
IEnumerable<Item> sortedItems = Items.Where(item => item.ItemId != Item.NONE).OrderBy(item => GetItemText(item).ToLower()).OrderBy(item => ItemInfo.GetItemKind(item));
IList<Item> sortedItemsCopy = new List<Item>(); // to prevent object reference issues
foreach(Item item in sortedItems) {
Item itemCopy = new Item();
private void B_SortType_Click(object sender, EventArgs e)
{
var sortedItems = Items.Where(item => item.ItemId != Item.NONE)
.OrderBy(item => GetItemText(item).ToLower())
.ThenBy(ItemInfo.GetItemKind);
var sortedItemsCopy = new List<Item>(); // to prevent object reference issues
foreach (var item in sortedItems)
{
var itemCopy = new Item();
itemCopy.CopyFrom(item);
sortedItemsCopy.Add(itemCopy);
}
SetEditorItems(sortedItemsCopy);
}
private void SetEditorItems(IList<Item> items) {
private void SetEditorItems(IReadOnlyList<Item> items)
{
if (items.Count > Items.Count)
return;
for (int i = 0; i < Items.Count; i++) {
if (i < items.Count) {
GetItem(i).CopyFrom(items[i]);
}
else {
GetItem(i).CopyFrom(Item.NO_ITEM);
}
for (int i = 0; i < Items.Count; i++)
{
var src = i < items.Count ? items[i] : Item.NO_ITEM;
GetItem(i).CopyFrom(src);
ItemUpdated();
}

View File

@@ -251,7 +251,6 @@ private void B_MoveOutAllVillagers_Click(object sender, EventArgs e)
CHK_VillagerMovingOut.Checked = true;
System.Media.SystemSounds.Asterisk.Play();
return;
}
private void B_SetPhraseOriginal_Click(object sender, EventArgs e)

View File

@@ -70,7 +70,7 @@ private void B_Download_Click(object sender, EventArgs e)
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) => PBar_MultiUse.Value = e.ProgressPercentage;
private void Completed(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
@@ -80,7 +80,7 @@ private void Completed(object sender, AsyncCompletedEventArgs e)
return;
}
PBar_MultiUse.Value = 100;
PBar_MultiUse.Value = 100;
L_Status.Text = "Unzipping...";
UnzipFile();
}
@@ -96,7 +96,7 @@ private async void UnzipFile()
Directory.CreateDirectory(outputFolderPath);
await Task.Run(() => ZipFile.ExtractToDirectory(ZipFilePath, outputFolderPath));
await Task.Run(() => ZipFile.ExtractToDirectory(ZipFilePath, outputFolderPath)).ConfigureAwait(false);
SetUIDownloadState(true, true);
}
@@ -137,7 +137,7 @@ private async void CheckNetworkFileSizeAsync()
try
{
using var webClient = new WebClient();
await webClient.OpenReadTaskAsync(new Uri(AllHosts[CB_HostSelect.SelectedIndex], UriKind.Absolute));
await webClient.OpenReadTaskAsync(new Uri(AllHosts[CB_HostSelect.SelectedIndex], UriKind.Absolute)).ConfigureAwait(false);
var totalSizeBytes = Convert.ToInt64(webClient.ResponseHeaders["Content-Length"]);
var totalSizeMb = totalSizeBytes / 1e+6;