mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
Merge commit 'f942697af5d0a8587d818aaedca654f103f91d50' into mac-ui
This commit is contained in:
commit
527dacc8ec
8 changed files with 58 additions and 16 deletions
|
@ -10,11 +10,15 @@ namespace NBTExplorer
|
|||
public delegate bool EditRestrictedStringAction (RestrictedStringFormData data);
|
||||
public delegate bool EditTagScalarAction (TagScalarFormData data);
|
||||
public delegate bool EditByteArrayAction (ByteArrayFormData data);
|
||||
public delegate bool CreateNodeAction (CreateTagFormData data);
|
||||
|
||||
public static EditStringAction EditString { get; set; }
|
||||
public static EditRestrictedStringAction RenameTag { get; set; }
|
||||
public static EditTagScalarAction EditTagScalar { get; set; }
|
||||
public static EditByteArrayAction EditByteArray { get; set; }
|
||||
public static CreateNodeAction CreateNode { get; set; }
|
||||
|
||||
public static Action<string> MessageBox { get; set; }
|
||||
}
|
||||
|
||||
public class TagScalarFormData
|
||||
|
@ -52,6 +56,21 @@ namespace NBTExplorer
|
|||
}
|
||||
}
|
||||
|
||||
public class CreateTagFormData
|
||||
{
|
||||
public CreateTagFormData ()
|
||||
{
|
||||
RestrictedNames = new List<string>();
|
||||
}
|
||||
|
||||
public TagType TagType { get; set; }
|
||||
public bool HasName { get; set; }
|
||||
public List<String> RestrictedNames { get; private set; }
|
||||
|
||||
public TagNode TagNode { get; set; }
|
||||
public string TagName { get; set; }
|
||||
}
|
||||
|
||||
public class ByteArrayFormData
|
||||
{
|
||||
public string NodeName { get; set; }
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
|
@ -60,7 +59,8 @@ namespace NBTExplorer.Model
|
|||
}
|
||||
}
|
||||
catch {
|
||||
MessageBox.Show("Not a valid cubic region file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
if (FormRegistry.MessageBox != null)
|
||||
FormRegistry.MessageBox("Not a valid cubic region file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Substrate.Core;
|
||||
using Substrate.Nbt;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Substrate.Core;
|
||||
using System.IO;
|
||||
using Substrate.Core;
|
||||
using Substrate.Nbt;
|
||||
using System.IO;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Substrate.Core;
|
||||
using System.Text.RegularExpressions;
|
||||
using Substrate.Core;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
{
|
||||
|
@ -61,7 +60,8 @@ namespace NBTExplorer.Model
|
|||
}
|
||||
}
|
||||
catch {
|
||||
MessageBox.Show("Not a valid region file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
if (FormRegistry.MessageBox != null)
|
||||
FormRegistry.MessageBox("Not a valid region file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using NBTExplorer.Windows;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
|
@ -50,12 +48,16 @@ namespace NBTExplorer.Model
|
|||
if (!CanCreateTag(type))
|
||||
return false;
|
||||
|
||||
CreateNodeForm form = new CreateNodeForm(type, true);
|
||||
form.InvalidNames.AddRange(_container.TagNamesInUse);
|
||||
if (FormRegistry.CreateNode != null) {
|
||||
CreateTagFormData data = new CreateTagFormData() {
|
||||
TagType = type, HasName = true,
|
||||
};
|
||||
data.RestrictedNames.AddRange(_container.TagNamesInUse);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
AddTag(form.TagNode, form.TagName);
|
||||
return true;
|
||||
if (FormRegistry.CreateNode(data)) {
|
||||
AddTag(data.TagNode, data.TagName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
//susing System.Windows.Forms;
|
||||
using Substrate.Nbt;
|
||||
|
||||
namespace NBTExplorer.Model
|
||||
|
|
|
@ -11,6 +11,14 @@ namespace NBTExplorer.Windows
|
|||
FormRegistry.EditString = EditStringHandler;
|
||||
FormRegistry.EditTagScalar = EditTagScalarValueHandler;
|
||||
FormRegistry.RenameTag = RenameTagHandler;
|
||||
FormRegistry.CreateNode = CreateNodeHandler;
|
||||
|
||||
FormRegistry.MessageBox = MessageBoxHandler;
|
||||
}
|
||||
|
||||
public static void MessageBoxHandler (string message)
|
||||
{
|
||||
MessageBox.Show(message);
|
||||
}
|
||||
|
||||
public static bool EditStringHandler (StringFormData data)
|
||||
|
@ -56,5 +64,19 @@ namespace NBTExplorer.Windows
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CreateNodeHandler (CreateTagFormData data)
|
||||
{
|
||||
CreateNodeForm form = new CreateNodeForm(data.TagType, data.HasName);
|
||||
form.InvalidNames.AddRange(data.RestrictedNames);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK) {
|
||||
data.TagNode = form.TagNode;
|
||||
data.TagName = form.TagName;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue