Remove some unused stuff

bloat--
This commit is contained in:
Kurt 2020-03-31 17:44:20 -07:00
parent 7b24142014
commit 7bcfe788a2
14 changed files with 20 additions and 588 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
namespace NHSE.Core

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace NHSE.Core
{

View File

@ -20,10 +20,10 @@ public abstract class PersonalOffsets
public abstract int Recipes { get; }
public abstract int ReceivedItems { get; }
public virtual int Pockets1Count { get; } = 20;
public virtual int Pockets2Count { get; } = 20;
public virtual int StorageCount { get; } = 5000;
public virtual int MaxRecipeID { get; } = 0x2A0;
public int Pockets1Count { get; } = 20;
public int Pockets2Count { get; } = 20;
public int StorageCount { get; } = 5000;
public int MaxRecipeID { get; } = 0x2A0;
public static PersonalOffsets GetOffsets(FileHeaderInfo Info)
{

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace NHSE.Core
namespace NHSE.Core
{
/// <summary>
/// Global repository for game strings; initialized to a specified language.
@ -10,8 +8,6 @@ public static class GameInfo
private static readonly GameStrings[] Languages = new GameStrings[GameLanguage.LanguageCount];
public static string CurrentLanguage { get; set; } = GameLanguage.DefaultLanguage;
public static readonly IReadOnlyList<string> GenderSymbolUnicode = new[] { "♂", "♀", "-" };
public static readonly IReadOnlyList<string> GenderSymbolASCII = new[] { "M", "F", "-" };
public static GameStrings Strings { get; set; } = GetStrings(CurrentLanguage);
/// <summary>

View File

@ -1,16 +0,0 @@
using System.Collections.Generic;
namespace NHSE.Core
{
public class InventorySet
{
public readonly InventoryType Type;
public readonly IReadOnlyList<Item> Items;
public InventorySet(InventoryType type, IReadOnlyList<Item> items)
{
Type = type;
Items = items;
}
}
}

View File

@ -1,9 +0,0 @@
namespace NHSE.Core
{
public enum InventoryType
{
Pocket1,
Pocket2,
Storage,
}
}

View File

@ -8,19 +8,6 @@ namespace NHSE.Core
/// </summary>
public static class ArrayUtil
{
public static bool IsRangeAll<T>(this T[] data, T value, int offset, int length) where T : IEquatable<T>
{
int start = offset + length - 1;
int end = offset;
for (int i = start; i >= end; i--)
{
if (!data[i].Equals(value))
return false;
}
return true;
}
public static byte[] Slice(this byte[] src, int offset, int length)
{
byte[] data = new byte[length];
@ -186,7 +173,7 @@ internal static T[] ConcatAll<T>(params T[][] arr)
/// <param name="pattern">Pattern to look for</param>
/// <param name="startIndex">Starting offset to look from</param>
/// <param name="length">Amount of entries to look through</param>
/// <returns>Index the pattern occurrs at; if not found, returns -1.</returns>
/// <returns>Index the pattern occurs at; if not found, returns -1.</returns>
public static int IndexOfBytes(byte[] array, byte[] pattern, int startIndex = 0, int length = -1)
{
int len = pattern.Length;

View File

@ -9,7 +9,7 @@ namespace NHSE.Core
/// </summary>
public static class RandUtil
{
// Multithread safe rand, ha
// Multi-thread safe rand, ha
public static Random Rand => _local.Value;
private static readonly ThreadLocal<Random> _local = new ThreadLocal<Random>(() => new Random());

View File

@ -11,16 +11,16 @@ public class BCSV
public readonly byte[] Data;
public uint EntryCount { get; set; }
public uint EntryLength { get; set; }
public ushort FieldCount { get; set; }
public bool HasBCSVHeader { get; set; }
public bool Flag2 { get; set; }
public readonly uint EntryCount;
public readonly uint EntryLength;
public readonly ushort FieldCount;
public readonly bool HasBCSVHeader;
public readonly bool Flag2;
public uint Magic { get; set; }
public int Unknown { get; set; }
public int Unknown1 { get; set; }
public int Unknown2 { get; set; }
public readonly uint Magic;
public readonly int Unknown;
public readonly int Unknown1;
public readonly int Unknown2;
private readonly int FieldTableStart;
public readonly IReadOnlyList<BCSVFieldParam> FieldOffsets;

View File

@ -7,10 +7,10 @@ namespace NHSE.Sprites
{
public class ItemSpriteDrawer : IGridItem
{
public int Width { get; set; } = 32;
public int Height { get; set; } = 32;
public int Width { get; } = 32;
public int Height { get; } = 32;
public Image HoverBackground = Resources.itemHover;
public readonly Image HoverBackground = Resources.itemHover;
public Image? GetImage(Item item, Font font)
{

View File

@ -110,12 +110,6 @@ private void LoadMain()
private void B_EditPlayerItems_Click(object sender, EventArgs e)
{
var player = SAV.Players[PlayerIndex];
if (ModifierKeys == Keys.Control)
{
using var editor = new InventoryEditor(player);
editor.ShowDialog();
}
else
{
var pers = player.Personal;
var p1 = pers.Pocket1;

View File

@ -1,130 +0,0 @@
namespace NHSE.WinForms
{
partial class InventoryEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.TC_Groups = new System.Windows.Forms.TabControl();
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.B_Copy = new System.Windows.Forms.Button();
this.NUD_Copy = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.NUD_Copy)).BeginInit();
this.SuspendLayout();
//
// TC_Groups
//
this.TC_Groups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TC_Groups.Location = new System.Drawing.Point(9, 9);
this.TC_Groups.Name = "TC_Groups";
this.TC_Groups.SelectedIndex = 0;
this.TC_Groups.Size = new System.Drawing.Size(398, 336);
this.TC_Groups.TabIndex = 0;
//
// B_Save
//
this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Save.Location = new System.Drawing.Point(329, 349);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(75, 40);
this.B_Save.TabIndex = 1;
this.B_Save.Text = "Save";
this.B_Save.UseVisualStyleBackColor = true;
this.B_Save.Click += new System.EventHandler(this.B_Save_Click);
//
// B_Cancel
//
this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Cancel.Location = new System.Drawing.Point(248, 349);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(75, 40);
this.B_Cancel.TabIndex = 2;
this.B_Cancel.Text = "Cancel";
this.B_Cancel.UseVisualStyleBackColor = true;
this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click);
//
// B_Copy
//
this.B_Copy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.B_Copy.Location = new System.Drawing.Point(9, 349);
this.B_Copy.Name = "B_Copy";
this.B_Copy.Size = new System.Drawing.Size(75, 40);
this.B_Copy.TabIndex = 3;
this.B_Copy.Text = "Copy First to next N...";
this.B_Copy.UseVisualStyleBackColor = true;
this.B_Copy.Click += new System.EventHandler(this.B_Copy_Click);
//
// NUD_Copy
//
this.NUD_Copy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.NUD_Copy.Location = new System.Drawing.Point(90, 351);
this.NUD_Copy.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_Copy.Name = "NUD_Copy";
this.NUD_Copy.Size = new System.Drawing.Size(56, 20);
this.NUD_Copy.TabIndex = 4;
this.NUD_Copy.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// InventoryEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(416, 393);
this.Controls.Add(this.NUD_Copy);
this.Controls.Add(this.B_Copy);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.TC_Groups);
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InventoryEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Inventory Editor";
((System.ComponentModel.ISupportInitialize)(this.NUD_Copy)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl TC_Groups;
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.Button B_Copy;
private System.Windows.Forms.NumericUpDown NUD_Copy;
}
}

View File

@ -1,268 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NHSE.Core;
namespace NHSE.WinForms
{
public partial class InventoryEditor : Form
{
private readonly Player Player;
private readonly InventorySet[] Inventory;
private readonly string[] DisplayItems;
// assume that all pouches have the same amount of columns
private int ColumnItem;
private int ColumnCount;
private int ColumnUse;
private int ColumnFlag1;
private int ColumnFlag2;
private int ColumnFlag3;
public InventoryEditor(Player player)
{
InitializeComponent();
Player = player;
Inventory = GetInventory(player);
DisplayItems = GameInfo.Strings.itemlistdisplay;
CreateViews();
LoadItems();
}
private static InventorySet[] GetInventory(Player player)
{
return new[]
{
new InventorySet(InventoryType.Pocket1, player.Personal.Pocket2),
new InventorySet(InventoryType.Pocket2, player.Personal.Pocket1),
new InventorySet(InventoryType.Storage, player.Personal.Storage),
};
}
private void SetInventory(Player player)
{
player.Personal.Pocket2 = Inventory[0].Items;
player.Personal.Pocket1 = Inventory[1].Items;
player.Personal.Storage = Inventory[2].Items;
}
private void CreateViews()
{
foreach (var p in Inventory)
{
var tab = new TabPage {Name = $"Tab_{p.Type}", Text = p.Type.ToString()};
var dgv = GetDGV(p);
ControlGrids.Add(p.Type, dgv);
tab.Controls.Add(dgv);
TC_Groups.TabPages.Add(tab);
TC_Groups.ShowToolTips = true;
tab.ToolTipText = p.Type.ToString();
}
}
private DataGridView GetDGV(InventorySet pouch)
{
// Add DataGrid
var dgv = GetBaseDataGrid(pouch);
// Get Columns
var item = GetItemColumn(ColumnItem = 0);
var count = GetCountColumn(ColumnCount = 1);
var use = GetUseColumn(ColumnUse = 2);
var flag1 = GetFlagColumn(ColumnFlag1 = 3, nameof(Item.Flags0));
var flag2 = GetFlagColumn(ColumnFlag2 = 4, nameof(Item.Flags1));
var flag3 = GetFlagColumn(ColumnFlag3 = 5, nameof(Item.Flags2));
dgv.Columns.Add(item);
dgv.Columns.Add(count);
dgv.Columns.Add(use);
dgv.Columns.Add(flag1);
dgv.Columns.Add(flag2);
dgv.Columns.Add(flag3);
// Populate with rows
item.Items.AddRange(DisplayItems);
dgv.Rows.Add(pouch.Items.Count);
dgv.CancelEdit();
return dgv;
}
private static DataGridView GetBaseDataGrid(InventorySet pouch)
{
return new DataGridView
{
Dock = DockStyle.Fill,
Text = pouch.Type.ToString(),
Name = "DGV_" + pouch.Type,
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
AllowUserToResizeRows = false,
AllowUserToResizeColumns = false,
RowHeadersVisible = false,
MultiSelect = false,
ShowEditingIcon = false,
EditMode = DataGridViewEditMode.EditOnEnter,
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single,
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize,
SelectionMode = DataGridViewSelectionMode.CellSelect,
CellBorderStyle = DataGridViewCellBorderStyle.None,
};
}
private static DataGridViewComboBoxColumn GetItemColumn(int c)
{
return new DataGridViewComboBoxColumn
{
HeaderText = "Item",
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
DisplayIndex = c,
Width = 135,
FlatStyle = FlatStyle.Flat,
};
}
private static DataGridViewColumn GetCountColumn(int c)
{
return new DataGridViewTextBoxColumn
{
HeaderText = "Count",
DisplayIndex = c,
Width = 45,
DefaultCellStyle = {Alignment = DataGridViewContentAlignment.MiddleCenter},
MaxInputLength = 3,
};
}
private static DataGridViewColumn GetUseColumn(int c)
{
return new DataGridViewTextBoxColumn
{
HeaderText = "Uses",
DisplayIndex = c,
Width = 45,
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
MaxInputLength = 3,
};
}
private static DataGridViewColumn GetFlagColumn(int c, string name)
{
return new DataGridViewTextBoxColumn
{
HeaderText = name,
DisplayIndex = c,
Width = 45,
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
MaxInputLength = 3,
};
}
private void LoadItems()
{
foreach (var list in Inventory)
{
var dgv = GetGrid(list.Type);
GetList(dgv, list);
}
}
private readonly Dictionary<InventoryType, DataGridView> ControlGrids = new Dictionary<InventoryType, DataGridView>();
private DataGridView GetGrid(InventoryType type) => ControlGrids[type];
private DataGridView GetGrid(int group) => ControlGrids[Inventory[group].Type];
private void SetInventory()
{
foreach (var pouch in Inventory)
{
var dgv = GetGrid(pouch.Type);
SetList(dgv, pouch);
}
}
private void GetList(DataGridView dgv, InventorySet pouch)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
var cells = dgv.Rows[i].Cells;
var item = pouch.Items[i];
// Treat NONE as 0
var id = item.ItemId;
if (id == Item.NONE)
id = 0;
cells[ColumnItem].Value = DisplayItems[id];
cells[ColumnCount].Value = item.Count;
cells[ColumnUse].Value = item.UseCount;
cells[ColumnFlag1].Value = item.Flags0;
cells[ColumnFlag2].Value = item.Flags1;
cells[ColumnFlag3].Value = item.Flags2;
}
}
private void SetList(DataGridView dgv, InventorySet pouch)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
var cells = dgv.Rows[i].Cells;
var str = cells[ColumnItem].Value.ToString();
var itemindex = Array.IndexOf(DisplayItems, str);
int.TryParse(cells[ColumnCount].Value?.ToString(), out int itemcnt);
int.TryParse(cells[ColumnUse].Value?.ToString(), out int uses);
int.TryParse(cells[ColumnFlag1].Value?.ToString(), out int flags1);
int.TryParse(cells[ColumnFlag2].Value?.ToString(), out int flags2);
int.TryParse(cells[ColumnFlag3].Value?.ToString(), out int flags3);
var item = pouch.Items[i];
// Undo our handling of NONE
if (itemindex <= 0)
itemindex = Item.NONE;
item.ItemId = (ushort)itemindex;
item.Count = (byte)itemcnt;
item.UseCount = (ushort)uses;
item.Flags0 = (byte)flags1;
item.Flags1 = (byte)flags2;
item.Flags1 = (byte)flags3;
}
}
private void B_Cancel_Click(object sender, EventArgs e) => Close();
private void B_Save_Click(object sender, EventArgs e)
{
SetInventory();
SetInventory(Player);
Close();
}
private void B_Copy_Click(object sender, EventArgs e)
{
var dgv = GetGrid(TC_Groups.SelectedIndex);
int max = (int)NUD_Copy.Value;
var first = dgv.Rows[0].Cells;
for (int i = 1; i < max; i++)
{
var cells = dgv.Rows[i].Cells;
cells[ColumnItem].Value = first[ColumnItem].Value;
cells[ColumnCount].Value = first[ColumnCount].Value;
cells[ColumnUse].Value = first[ColumnUse].Value;
cells[ColumnFlag1].Value = first[ColumnFlag1].Value;
cells[ColumnFlag2].Value = first[ColumnFlag2].Value;
cells[ColumnFlag3].Value = first[ColumnFlag3].Value;
}
System.Media.SystemSounds.Asterisk.Play();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>