Add bulk spawner for field items

Closes #235
This commit is contained in:
Kurt
2020-05-20 13:22:50 -07:00
parent 641f82f1f5
commit a1cc4de611
6 changed files with 552 additions and 16 deletions

View File

@@ -43,6 +43,9 @@
<Compile Update="Subforms\Map\BuildingHelp.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Map\BulkSpawn.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Map\MuseumEditor.cs">
<SubType>Form</SubType>
</Compile>

View File

@@ -0,0 +1,251 @@
namespace NHSE.WinForms
{
partial class BulkSpawn
{
/// <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.B_Apply = new System.Windows.Forms.Button();
this.NUD_SpawnX = new System.Windows.Forms.NumericUpDown();
this.NUD_SpawnY = new System.Windows.Forms.NumericUpDown();
this.L_X = new System.Windows.Forms.Label();
this.L_Y = new System.Windows.Forms.Label();
this.CB_SpawnType = new System.Windows.Forms.ComboBox();
this.L_SpawnCount = new System.Windows.Forms.Label();
this.NUD_SpawnCount = new System.Windows.Forms.NumericUpDown();
this.L_DIYStart = new System.Windows.Forms.Label();
this.NUD_DIYStart = new System.Windows.Forms.NumericUpDown();
this.L_DIYStop = new System.Windows.Forms.Label();
this.NUD_DIYStop = new System.Windows.Forms.NumericUpDown();
this.CB_SpawnArrange = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnCount)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_DIYStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_DIYStop)).BeginInit();
this.SuspendLayout();
//
// B_Apply
//
this.B_Apply.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.B_Apply.Location = new System.Drawing.Point(12, 200);
this.B_Apply.Name = "B_Apply";
this.B_Apply.Size = new System.Drawing.Size(112, 23);
this.B_Apply.TabIndex = 6;
this.B_Apply.Text = "Spawn";
this.B_Apply.UseVisualStyleBackColor = true;
this.B_Apply.Click += new System.EventHandler(this.B_Apply_Click);
//
// NUD_SpawnX
//
this.NUD_SpawnX.Location = new System.Drawing.Point(61, 63);
this.NUD_SpawnX.Maximum = new decimal(new int[] {
9999,
0,
0,
0});
this.NUD_SpawnX.Name = "NUD_SpawnX";
this.NUD_SpawnX.Size = new System.Drawing.Size(45, 20);
this.NUD_SpawnX.TabIndex = 12;
//
// NUD_SpawnY
//
this.NUD_SpawnY.Location = new System.Drawing.Point(61, 89);
this.NUD_SpawnY.Maximum = new decimal(new int[] {
9999,
0,
0,
0});
this.NUD_SpawnY.Name = "NUD_SpawnY";
this.NUD_SpawnY.Size = new System.Drawing.Size(45, 20);
this.NUD_SpawnY.TabIndex = 13;
//
// L_X
//
this.L_X.Location = new System.Drawing.Point(14, 63);
this.L_X.Name = "L_X";
this.L_X.Size = new System.Drawing.Size(41, 20);
this.L_X.TabIndex = 14;
this.L_X.Text = "X:";
this.L_X.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_Y
//
this.L_Y.Location = new System.Drawing.Point(14, 89);
this.L_Y.Name = "L_Y";
this.L_Y.Size = new System.Drawing.Size(41, 20);
this.L_Y.TabIndex = 15;
this.L_Y.Text = "Y:";
this.L_Y.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_SpawnType
//
this.CB_SpawnType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_SpawnType.FormattingEnabled = true;
this.CB_SpawnType.Location = new System.Drawing.Point(15, 9);
this.CB_SpawnType.Name = "CB_SpawnType";
this.CB_SpawnType.Size = new System.Drawing.Size(108, 21);
this.CB_SpawnType.TabIndex = 16;
this.CB_SpawnType.SelectedIndexChanged += new System.EventHandler(this.CB_SpawnType_SelectedIndexChanged);
//
// L_SpawnCount
//
this.L_SpawnCount.Location = new System.Drawing.Point(14, 115);
this.L_SpawnCount.Name = "L_SpawnCount";
this.L_SpawnCount.Size = new System.Drawing.Size(51, 20);
this.L_SpawnCount.TabIndex = 18;
this.L_SpawnCount.Text = "Count:";
this.L_SpawnCount.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_SpawnCount
//
this.NUD_SpawnCount.Location = new System.Drawing.Point(71, 117);
this.NUD_SpawnCount.Maximum = new decimal(new int[] {
9999,
0,
0,
0});
this.NUD_SpawnCount.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NUD_SpawnCount.Name = "NUD_SpawnCount";
this.NUD_SpawnCount.Size = new System.Drawing.Size(45, 20);
this.NUD_SpawnCount.TabIndex = 17;
this.NUD_SpawnCount.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// L_DIYStart
//
this.L_DIYStart.Location = new System.Drawing.Point(14, 141);
this.L_DIYStart.Name = "L_DIYStart";
this.L_DIYStart.Size = new System.Drawing.Size(51, 20);
this.L_DIYStart.TabIndex = 20;
this.L_DIYStart.Text = "Start:";
this.L_DIYStart.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_DIYStart
//
this.NUD_DIYStart.Location = new System.Drawing.Point(71, 143);
this.NUD_DIYStart.Maximum = new decimal(new int[] {
9999,
0,
0,
0});
this.NUD_DIYStart.Name = "NUD_DIYStart";
this.NUD_DIYStart.Size = new System.Drawing.Size(45, 20);
this.NUD_DIYStart.TabIndex = 19;
//
// L_DIYStop
//
this.L_DIYStop.Location = new System.Drawing.Point(14, 167);
this.L_DIYStop.Name = "L_DIYStop";
this.L_DIYStop.Size = new System.Drawing.Size(51, 20);
this.L_DIYStop.TabIndex = 22;
this.L_DIYStop.Text = "Stop:";
this.L_DIYStop.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_DIYStop
//
this.NUD_DIYStop.Location = new System.Drawing.Point(71, 169);
this.NUD_DIYStop.Maximum = new decimal(new int[] {
9999,
0,
0,
0});
this.NUD_DIYStop.Name = "NUD_DIYStop";
this.NUD_DIYStop.Size = new System.Drawing.Size(45, 20);
this.NUD_DIYStop.TabIndex = 21;
this.NUD_DIYStop.Value = new decimal(new int[] {
9999,
0,
0,
0});
//
// CB_SpawnArrange
//
this.CB_SpawnArrange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_SpawnArrange.FormattingEnabled = true;
this.CB_SpawnArrange.Location = new System.Drawing.Point(16, 36);
this.CB_SpawnArrange.Name = "CB_SpawnArrange";
this.CB_SpawnArrange.Size = new System.Drawing.Size(108, 21);
this.CB_SpawnArrange.TabIndex = 23;
//
// BulkSpawn
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(136, 235);
this.Controls.Add(this.CB_SpawnArrange);
this.Controls.Add(this.L_DIYStop);
this.Controls.Add(this.NUD_DIYStop);
this.Controls.Add(this.L_DIYStart);
this.Controls.Add(this.NUD_DIYStart);
this.Controls.Add(this.L_SpawnCount);
this.Controls.Add(this.NUD_SpawnCount);
this.Controls.Add(this.CB_SpawnType);
this.Controls.Add(this.L_Y);
this.Controls.Add(this.L_X);
this.Controls.Add(this.NUD_SpawnY);
this.Controls.Add(this.NUD_SpawnX);
this.Controls.Add(this.B_Apply);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::NHSE.WinForms.Properties.Resources.icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BulkSpawn";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Bulk Spawn";
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnX)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_SpawnCount)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_DIYStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_DIYStop)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button B_Apply;
private System.Windows.Forms.NumericUpDown NUD_SpawnX;
private System.Windows.Forms.NumericUpDown NUD_SpawnY;
private System.Windows.Forms.Label L_X;
private System.Windows.Forms.Label L_Y;
private System.Windows.Forms.ComboBox CB_SpawnType;
private System.Windows.Forms.Label L_SpawnCount;
private System.Windows.Forms.NumericUpDown NUD_SpawnCount;
private System.Windows.Forms.Label L_DIYStart;
private System.Windows.Forms.NumericUpDown NUD_DIYStart;
private System.Windows.Forms.Label L_DIYStop;
private System.Windows.Forms.NumericUpDown NUD_DIYStop;
private System.Windows.Forms.ComboBox CB_SpawnArrange;
}
}

View File

@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using NHSE.Core;
namespace NHSE.WinForms
{
public partial class BulkSpawn : Form
{
private readonly IItemLayerEditor Editor;
public BulkSpawn(IItemLayerEditor editor, int x = 0, int y = 0)
{
InitializeComponent();
this.TranslateInterface(GameInfo.CurrentLanguage);
Editor = editor;
CB_SpawnType.Items.AddRange(Enum.GetNames(typeof(SpawnType)));
CB_SpawnArrange.Items.AddRange(Enum.GetNames(typeof(SpawnArrangement)));
CB_SpawnType.SelectedIndex = 0;
CB_SpawnArrange.SelectedIndex = 0;
NUD_SpawnX.Value = x;
NUD_SpawnY.Value = y;
}
private void B_Apply_Click(object sender, EventArgs e)
{
var type = (SpawnType)CB_SpawnType.SelectedIndex;
var arrange = (SpawnArrangement)CB_SpawnArrange.SelectedIndex;
var x = (int)NUD_SpawnX.Value;
var y = (int)NUD_SpawnY.Value;
var count = (int)NUD_SpawnCount.Value;
IEnumerable<Item> items;
int sizeX;
int sizeY;
if (type == SpawnType.SequentialDIY)
{
var min = (ushort)NUD_DIYStart.Value;
var max = (ushort)NUD_DIYStop.Value;
var diy = RecipeList.Recipes
.Where(z => min <= z.Key && z.Key <= max)
.Select(z => z.Key)
.Select(z => new Item(Item.DIYRecipe) {FreeParam = z});
items = Enumerable.Repeat(diy, count).SelectMany(z => z);
sizeX = sizeY = 2;
}
else
{
var item = Editor.ItemProvider.SetItem(new Item());
items = Enumerable.Repeat(item, count);
var size = ItemInfo.GetItemSize(item);
sizeX = size.GetWidth();
sizeY = size.GetHeight();
}
if (sizeX % 2 == 1)
sizeX++;
if (sizeY % 2 == 1)
sizeY++;
var ctr = SpawnItems(Editor.SpawnLayer, items.ToArray(), x, y, arrange, sizeX, sizeY, true);
if (ctr == 0)
{
WinFormsUtil.Alert(MessageStrings.MsgFieldItemModifyNone);
return;
}
Editor.ReloadItems();
WinFormsUtil.Alert(string.Format(MessageStrings.MsgFieldItemModifyCount, count));
}
private static int SpawnItems(ItemLayer layer, IReadOnlyList<Item> items, int x, int y, SpawnArrangement arrange, int sizeX, int sizeY, bool noOverwrite)
{
int x0 = x;
var newline = arrange == SpawnArrangement.Square ? (int)Math.Sqrt(items.Count * sizeX * sizeY) : items.Count;
int ctr = 0;
for (var i = 0; i < items.Count; i++)
{
var item = items[i];
var permission = layer.IsOccupied(item, x, y);
switch (permission)
{
case PlacedItemPermission.OutOfBounds when y >= layer.MaxHeight:
return ctr;
case PlacedItemPermission.OutOfBounds:
case PlacedItemPermission.Collision when noOverwrite:
i--;
break;
default:
var exist = layer.GetTile(x, y);
layer.DeleteExtensionTiles(exist, x, y);
// Set new placed data
layer.SetExtensionTiles(item, x, y);
exist.CopyFrom(item);
ctr++;
break;
}
x += sizeX;
if (x - x0 >= newline)
{
y += sizeY;
x = x0;
}
}
return ctr;
}
private void CB_SpawnType_SelectedIndexChanged(object sender, EventArgs e)
{
var index = (SpawnType)CB_SpawnType.SelectedIndex;
L_DIYStart.Visible = L_DIYStop.Visible = NUD_DIYStart.Visible = NUD_DIYStop.Visible = index == SpawnType.SequentialDIY;
NUD_SpawnCount.Value = index switch
{
SpawnType.SequentialDIY => 1,
_ => 8,
};
}
private enum SpawnType
{
ItemFromEditor,
SequentialDIY,
}
private enum SpawnArrangement
{
Square,
Horizontal,
}
}
}

View File

@@ -0,0 +1,120 @@
<?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>

View File

@@ -143,6 +143,7 @@ private void InitializeComponent()
this.L_TileMode = new System.Windows.Forms.Label();
this.CHK_RedirectExtensionLoad = new System.Windows.Forms.CheckBox();
this.CHK_FieldItemSnap = new System.Windows.Forms.CheckBox();
this.Menu_Spawn = new System.Windows.Forms.ToolStripMenuItem();
this.CM_Click.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
this.CM_Picture.SuspendLayout();
@@ -466,90 +467,91 @@ private void InitializeComponent()
this.B_FillHoles,
this.B_RemoveAll,
this.toolStripSeparator1,
this.B_WaterFlowers});
this.B_WaterFlowers,
this.Menu_Spawn});
this.CM_Remove.Name = "CM_Picture";
this.CM_Remove.ShowImageMargin = false;
this.CM_Remove.Size = new System.Drawing.Size(124, 252);
this.CM_Remove.Size = new System.Drawing.Size(156, 296);
//
// B_RemoveAllWeeds
//
this.B_RemoveAllWeeds.Name = "B_RemoveAllWeeds";
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(123, 22);
this.B_RemoveAllWeeds.Size = new System.Drawing.Size(155, 22);
this.B_RemoveAllWeeds.Text = "Weeds";
this.B_RemoveAllWeeds.Click += new System.EventHandler(this.B_RemoveAllWeeds_Click);
//
// B_RemovePlants
//
this.B_RemovePlants.Name = "B_RemovePlants";
this.B_RemovePlants.Size = new System.Drawing.Size(123, 22);
this.B_RemovePlants.Size = new System.Drawing.Size(155, 22);
this.B_RemovePlants.Text = "Plants";
this.B_RemovePlants.Click += new System.EventHandler(this.B_RemovePlants_Click);
//
// B_RemoveObjects
//
this.B_RemoveObjects.Name = "B_RemoveObjects";
this.B_RemoveObjects.Size = new System.Drawing.Size(123, 22);
this.B_RemoveObjects.Size = new System.Drawing.Size(155, 22);
this.B_RemoveObjects.Text = "Objects";
this.B_RemoveObjects.Click += new System.EventHandler(this.B_RemoveObjects_Click);
//
// B_RemovePlacedItems
//
this.B_RemovePlacedItems.Name = "B_RemovePlacedItems";
this.B_RemovePlacedItems.Size = new System.Drawing.Size(123, 22);
this.B_RemovePlacedItems.Size = new System.Drawing.Size(155, 22);
this.B_RemovePlacedItems.Text = "Placed Items";
this.B_RemovePlacedItems.Click += new System.EventHandler(this.B_RemovePlacedItems_Click);
//
// B_RemoveFences
//
this.B_RemoveFences.Name = "B_RemoveFences";
this.B_RemoveFences.Size = new System.Drawing.Size(123, 22);
this.B_RemoveFences.Size = new System.Drawing.Size(155, 22);
this.B_RemoveFences.Text = "Fences";
this.B_RemoveFences.Click += new System.EventHandler(this.B_RemoveFences_Click);
//
// B_RemoveBranches
//
this.B_RemoveBranches.Name = "B_RemoveBranches";
this.B_RemoveBranches.Size = new System.Drawing.Size(123, 22);
this.B_RemoveBranches.Size = new System.Drawing.Size(155, 22);
this.B_RemoveBranches.Text = "Branches";
this.B_RemoveBranches.Click += new System.EventHandler(this.B_RemoveBranches_Click);
//
// B_RemoveShells
//
this.B_RemoveShells.Name = "B_RemoveShells";
this.B_RemoveShells.Size = new System.Drawing.Size(123, 22);
this.B_RemoveShells.Size = new System.Drawing.Size(155, 22);
this.B_RemoveShells.Text = "Shells";
this.B_RemoveShells.Click += new System.EventHandler(this.B_RemoveShells_Click);
//
// B_RemoveFlowers
//
this.B_RemoveFlowers.Name = "B_RemoveFlowers";
this.B_RemoveFlowers.Size = new System.Drawing.Size(123, 22);
this.B_RemoveFlowers.Size = new System.Drawing.Size(155, 22);
this.B_RemoveFlowers.Text = "Flowers";
this.B_RemoveFlowers.Click += new System.EventHandler(this.B_RemoveFlowers_Click);
//
// B_FillHoles
//
this.B_FillHoles.Name = "B_FillHoles";
this.B_FillHoles.Size = new System.Drawing.Size(123, 22);
this.B_FillHoles.Size = new System.Drawing.Size(155, 22);
this.B_FillHoles.Text = "Holes";
this.B_FillHoles.Click += new System.EventHandler(this.B_FillHoles_Click);
//
// B_RemoveAll
//
this.B_RemoveAll.Name = "B_RemoveAll";
this.B_RemoveAll.Size = new System.Drawing.Size(123, 22);
this.B_RemoveAll.Size = new System.Drawing.Size(155, 22);
this.B_RemoveAll.Text = "All";
this.B_RemoveAll.Click += new System.EventHandler(this.B_RemoveAll_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(120, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(152, 6);
//
// B_WaterFlowers
//
this.B_WaterFlowers.Name = "B_WaterFlowers";
this.B_WaterFlowers.Size = new System.Drawing.Size(123, 22);
this.B_WaterFlowers.Size = new System.Drawing.Size(155, 22);
this.B_WaterFlowers.Text = "Water Flowers";
this.B_WaterFlowers.Click += new System.EventHandler(this.B_WaterFlowers_Click);
//
@@ -1327,6 +1329,13 @@ private void InitializeComponent()
this.CHK_FieldItemSnap.Text = "Snap Field Items to Grid on Set";
this.CHK_FieldItemSnap.UseVisualStyleBackColor = true;
//
// Menu_Spawn
//
this.Menu_Spawn.Name = "Menu_Spawn";
this.Menu_Spawn.Size = new System.Drawing.Size(155, 22);
this.Menu_Spawn.Text = "Spawn...";
this.Menu_Spawn.Click += new System.EventHandler(this.Menu_Spawn_Click);
//
// FieldItemEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -1514,5 +1523,6 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem B_WaterFlowers;
private System.Windows.Forms.CheckBox CHK_FieldItemSnap;
private System.Windows.Forms.ToolStripMenuItem Menu_Spawn;
}
}

View File

@@ -8,7 +8,7 @@
namespace NHSE.WinForms
{
public sealed partial class FieldItemEditor : Form
public sealed partial class FieldItemEditor : Form, IItemLayerEditor
{
private readonly MainSave SAV;
@@ -24,6 +24,9 @@ public sealed partial class FieldItemEditor : Form
private int DragY = -1;
private bool Dragging;
public ItemEditor ItemProvider => ItemEdit;
public ItemLayer SpawnLayer => Map.CurrentLayer;
public FieldItemEditor(MainSave sav)
{
InitializeComponent();
@@ -117,7 +120,7 @@ private void ReloadAcreBackground()
private void ReloadMapItemGrid() => PB_Map.Image = View.GetMapWithReticle(GetItemTransparency());
private void ReloadAcreItemGrid() => PB_Acre.Image = View.GetLayerAcre(GetItemTransparency());
private void ReloadItems()
public void ReloadItems()
{
ReloadAcreItemGrid();
ReloadMapItemGrid();
@@ -885,5 +888,14 @@ private void B_ClearPlacedDesigns_Click(object sender, EventArgs e)
MapManager.ClearDesignTiles(SAV);
System.Media.SystemSounds.Asterisk.Play();
}
private void Menu_Spawn_Click(object sender, EventArgs e) => new BulkSpawn(this, View.X, View.Y).ShowDialog();
}
public interface IItemLayerEditor
{
void ReloadItems();
ItemEditor ItemProvider { get; }
ItemLayer SpawnLayer { get; }
}
}