Added Materials Editor to Tools menu

This commit is contained in:
MattNL
2023-06-16 08:43:09 -04:00
parent e7b843b48d
commit 3b1be0d570
4 changed files with 77 additions and 17 deletions

View File

@@ -65,6 +65,17 @@ namespace PckStudio.Forms.Editor
SetUpTree();
}
public MaterialsEditor()
{
InitializeComponent();
treeView1.ImageList = new ImageList();
ApplicationScope.EntityImages.ToList().ForEach(treeView1.ImageList.Images.Add);
treeView1.ImageList.ColorDepth = ColorDepth.Depth32Bit;
openToolStripMenuItem_Click(null, null);
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node == null) return;
@@ -125,9 +136,32 @@ namespace PckStudio.Forms.Editor
}
}
var writer = new MaterialFileWriter(materialFile);
writer.WriteToStream(stream);
_file.SetData(stream.ToArray());
if (_file is null) // if external file is being edited
{
using (var sfd = new SaveFileDialog())
{
sfd.Filter = "behaviours.bin (Minecraft Behaviour File)|*.bin";
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
var writer = new MaterialFileWriter(materialFile);
writer.WriteToFile(sfd.FileName);
}
catch (Exception ex)
{
MessageBox.Show(this, $"Failed to save the selected file\nError: {ex.Message}", "Failed to save materials file");
}
}
else return;
}
}
else
{
var writer = new MaterialFileWriter(materialFile);
writer.WriteToStream(stream);
_file.SetData(stream.ToArray());
}
}
DialogResult = DialogResult.OK;
}

View File

@@ -147,9 +147,10 @@
this.label11 = new MetroFramework.Controls.MetroLabel();
this.treeViewMain = new System.Windows.Forms.TreeView();
this.imageList = new System.Windows.Forms.ImageList(this.components);
this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode();
this.LittleEndianCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.behavioursEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode();
this.entityMaterialsEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuPCKEntries.SuspendLayout();
this.menuStrip.SuspendLayout();
this.contextMenuMetaTree.SuspendLayout();
@@ -597,7 +598,8 @@
//
this.fileEditorsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.behavioursEditorToolStripMenuItem,
this.cOLEditorToolStripMenuItem});
this.cOLEditorToolStripMenuItem,
this.entityMaterialsEditorToolStripMenuItem});
this.fileEditorsToolStripMenuItem.Name = "fileEditorsToolStripMenuItem";
resources.ApplyResources(this.fileEditorsToolStripMenuItem, "fileEditorsToolStripMenuItem");
//
@@ -1101,14 +1103,6 @@
resources.ApplyResources(this.imageList, "imageList");
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
//
// pictureBoxImagePreview
//
resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview");
this.pictureBoxImagePreview.BackColor = System.Drawing.Color.Transparent;
this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.pictureBoxImagePreview.Name = "pictureBoxImagePreview";
this.pictureBoxImagePreview.TabStop = false;
//
// LittleEndianCheckBox
//
resources.ApplyResources(this.LittleEndianCheckBox, "LittleEndianCheckBox");
@@ -1124,6 +1118,20 @@
resources.ApplyResources(this.behavioursEditorToolStripMenuItem, "behavioursEditorToolStripMenuItem");
this.behavioursEditorToolStripMenuItem.Click += new System.EventHandler(this.behavioursEditorToolStripMenuItem_Click);
//
// pictureBoxImagePreview
//
resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview");
this.pictureBoxImagePreview.BackColor = System.Drawing.Color.Transparent;
this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.pictureBoxImagePreview.Name = "pictureBoxImagePreview";
this.pictureBoxImagePreview.TabStop = false;
//
// entityMaterialsEditorToolStripMenuItem
//
this.entityMaterialsEditorToolStripMenuItem.Name = "entityMaterialsEditorToolStripMenuItem";
resources.ApplyResources(this.entityMaterialsEditorToolStripMenuItem, "entityMaterialsEditorToolStripMenuItem");
this.entityMaterialsEditorToolStripMenuItem.Click += new System.EventHandler(this.entityMaterialsEditorToolStripMenuItem_Click);
//
// MainForm
//
this.ApplyImageInvert = true;
@@ -1282,6 +1290,7 @@
private System.Windows.Forms.ToolStripMenuItem fileEditorsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cOLEditorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem behavioursEditorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem entityMaterialsEditorToolStripMenuItem;
}
}

View File

@@ -2404,5 +2404,10 @@ namespace PckStudio
{
new BehaviourEditor().ShowDialog(this);
}
private void entityMaterialsEditorToolStripMenuItem_Click(object sender, EventArgs e)
{
new MaterialsEditor().ShowDialog(this);
}
}
}

View File

@@ -686,13 +686,13 @@
<value>Open Pck Manager</value>
</data>
<data name="wavBinkaToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>145, 22</value>
</data>
<data name="wavBinkaToolStripMenuItem.Text" xml:space="preserve">
<value>Wav -&gt; Binka</value>
</data>
<data name="binkaWavToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>145, 22</value>
</data>
<data name="binkaWavToolStripMenuItem.Text" xml:space="preserve">
<value>Binka -&gt; Wav</value>
@@ -704,17 +704,23 @@
<value>Convert Music Files</value>
</data>
<data name="behavioursEditorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>189, 22</value>
</data>
<data name="behavioursEditorToolStripMenuItem.Text" xml:space="preserve">
<value>Behaviours Editor</value>
</data>
<data name="cOLEditorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>189, 22</value>
</data>
<data name="cOLEditorToolStripMenuItem.Text" xml:space="preserve">
<value>Colours Editor</value>
</data>
<data name="entityMaterialsEditorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>189, 22</value>
</data>
<data name="entityMaterialsEditorToolStripMenuItem.Text" xml:space="preserve">
<value>Entity Materials Editor</value>
</data>
<data name="fileEditorsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
@@ -29689,6 +29695,12 @@
<data name="&gt;&gt;behavioursEditorToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;entityMaterialsEditorToolStripMenuItem.Name" xml:space="preserve">
<value>entityMaterialsEditorToolStripMenuItem</value>
</data>
<data name="&gt;&gt;entityMaterialsEditorToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainForm</value>
</data>