diff --git a/Mac/AppDelegate.cs b/Mac/AppDelegate.cs
index 643074c..ab26231 100644
--- a/Mac/AppDelegate.cs
+++ b/Mac/AppDelegate.cs
@@ -81,6 +81,16 @@ namespace NBTExplorer
get { return _menuDelete; }
}
+ public NSMenuItem MenuMoveUp
+ {
+ get { return _menuMoveUp; }
+ }
+
+ public NSMenuItem MenuMoveDown
+ {
+ get { return _menuMoveDown; }
+ }
+
public NSMenuItem MenuFind
{
get { return _menuFind; }
@@ -160,6 +170,71 @@ namespace NBTExplorer
{
mainWindowController.Window.ActionDeleteValue();
}
+
+ partial void ActionMoveUp (NSObject sender)
+ {
+ mainWindowController.Window.ActionMoveNodeUp();
+ }
+
+ partial void ActionMoveDown (NSObject sender)
+ {
+ mainWindowController.Window.ActionMoveNodeDown();
+ }
+
+ partial void ActionInsertByte (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertByteTag();
+ }
+
+ partial void ActionInsertShort (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertShortTag();
+ }
+
+ partial void ActionInsertInt (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertIntTag();
+ }
+
+ partial void ActionInsertLong (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertLongTag();
+ }
+
+ partial void ActionInsertFloat (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertFloatTag();
+ }
+
+ partial void ActionInsertDouble (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertDoubleTag();
+ }
+
+ partial void ActionInsertByteArray (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertByteArrayTag();
+ }
+
+ partial void ActionInsertIntArray (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertIntArrayTag();
+ }
+
+ partial void ActionInsertString (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertStringTag();
+ }
+
+ partial void ActionInsertList (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertListTag();
+ }
+
+ partial void ActionInsertCompound (NSObject sender)
+ {
+ mainWindowController.Window.ActionInsertCompoundTag();
+ }
}
}
diff --git a/Mac/AppDelegate.designer.cs b/Mac/AppDelegate.designer.cs
index 4ad7e8c..a318503 100644
--- a/Mac/AppDelegate.designer.cs
+++ b/Mac/AppDelegate.designer.cs
@@ -47,6 +47,12 @@ namespace NBTExplorer
[Outlet]
MonoMac.AppKit.NSMenuItem _menuDelete { get; set; }
+ [Outlet]
+ MonoMac.AppKit.NSMenuItem _menuMoveUp { get; set; }
+
+ [Outlet]
+ MonoMac.AppKit.NSMenuItem _menuMoveDown { get; set; }
+
[Outlet]
MonoMac.AppKit.NSMenuItem _menuFind { get; set; }
@@ -86,6 +92,27 @@ namespace NBTExplorer
[Outlet]
MonoMac.AppKit.NSMenuItem _menuInsertCompound { get; set; }
+ [Action ("ActionOpen:")]
+ partial void ActionOpen (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionOpenFolder:")]
+ partial void ActionOpenFolder (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionOpenMinecraft:")]
+ partial void ActionOpenMinecraft (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionSave:")]
+ partial void ActionSave (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionCut:")]
+ partial void ActionCut (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionCopy:")]
+ partial void ActionCopy (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionPaste:")]
+ partial void ActionPaste (MonoMac.Foundation.NSObject sender);
+
[Action ("ActionRename:")]
partial void ActionRename (MonoMac.Foundation.NSObject sender);
@@ -94,6 +121,51 @@ namespace NBTExplorer
[Action ("ActionDelete:")]
partial void ActionDelete (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionMoveUp:")]
+ partial void ActionMoveUp (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionMoveDown:")]
+ partial void ActionMoveDown (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionFind:")]
+ partial void ActionFind (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionFindNext:")]
+ partial void ActionFindNext (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertByte:")]
+ partial void ActionInsertByte (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertShort:")]
+ partial void ActionInsertShort (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertInt:")]
+ partial void ActionInsertInt (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertLong:")]
+ partial void ActionInsertLong (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertFloat:")]
+ partial void ActionInsertFloat (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertDouble:")]
+ partial void ActionInsertDouble (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertByteArray:")]
+ partial void ActionInsertByteArray (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertIntArray:")]
+ partial void ActionInsertIntArray (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertString:")]
+ partial void ActionInsertString (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertList:")]
+ partial void ActionInsertList (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionInsertCompound:")]
+ partial void ActionInsertCompound (MonoMac.Foundation.NSObject sender);
void ReleaseDesignerOutlets ()
{
@@ -157,6 +229,16 @@ namespace NBTExplorer
_menuDelete = null;
}
+ if (_menuMoveUp != null) {
+ _menuMoveUp.Dispose ();
+ _menuMoveUp = null;
+ }
+
+ if (_menuMoveDown != null) {
+ _menuMoveDown.Dispose ();
+ _menuMoveDown = null;
+ }
+
if (_menuFind != null) {
_menuFind.Dispose ();
_menuFind = null;
diff --git a/Mac/CreateNodeWindow.cs b/Mac/CreateNodeWindow.cs
new file mode 100644
index 0000000..35db4cf
--- /dev/null
+++ b/Mac/CreateNodeWindow.cs
@@ -0,0 +1,35 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+
+namespace NBTExplorer.Mac
+{
+ public partial class CreateNodeWindow : MonoMac.AppKit.NSWindow
+ {
+ #region Constructors
+
+ // Called when created from unmanaged code
+ public CreateNodeWindow (IntPtr handle) : base (handle)
+ {
+ Initialize ();
+ }
+
+ // Called when created directly from a XIB file
+ [Export ("initWithCoder:")]
+ public CreateNodeWindow (NSCoder coder) : base (coder)
+ {
+ Initialize ();
+ }
+
+ // Shared initialization code
+ void Initialize ()
+ {
+ }
+
+ #endregion
+ }
+}
+
diff --git a/Mac/CreateNodeWindow.designer.cs b/Mac/CreateNodeWindow.designer.cs
new file mode 100644
index 0000000..9c3e400
--- /dev/null
+++ b/Mac/CreateNodeWindow.designer.cs
@@ -0,0 +1,64 @@
+// WARNING
+//
+// This file has been generated automatically by MonoDevelop to store outlets and
+// actions made in the Xcode designer. If it is removed, they will be lost.
+// Manual changes to this file may not be handled correctly.
+//
+using MonoMac.Foundation;
+
+namespace NBTExplorer.Mac
+{
+ [Register ("CreateNodeWindowController")]
+ partial class CreateNodeWindowController
+ {
+ [Outlet]
+ MonoMac.AppKit.NSTextField _nameFieldLabel { get; set; }
+
+ [Outlet]
+ MonoMac.AppKit.NSTextField _sizeFieldLabel { get; set; }
+
+ [Outlet]
+ MonoMac.AppKit.NSTextField _nameField { get; set; }
+
+ [Outlet]
+ MonoMac.AppKit.NSTextField _sizeField { get; set; }
+
+ [Action ("ActionOK:")]
+ partial void ActionOK (MonoMac.Foundation.NSObject sender);
+
+ [Action ("ActionCancel:")]
+ partial void ActionCancel (MonoMac.Foundation.NSObject sender);
+
+ void ReleaseDesignerOutlets ()
+ {
+ if (_nameFieldLabel != null) {
+ _nameFieldLabel.Dispose ();
+ _nameFieldLabel = null;
+ }
+
+ if (_sizeFieldLabel != null) {
+ _sizeFieldLabel.Dispose ();
+ _sizeFieldLabel = null;
+ }
+
+ if (_nameField != null) {
+ _nameField.Dispose ();
+ _nameField = null;
+ }
+
+ if (_sizeField != null) {
+ _sizeField.Dispose ();
+ _sizeField = null;
+ }
+ }
+ }
+
+ [Register ("CreateNodeWindow")]
+ partial class CreateNodeWindow
+ {
+
+ void ReleaseDesignerOutlets ()
+ {
+ }
+ }
+}
diff --git a/Mac/CreateNodeWindow.xib b/Mac/CreateNodeWindow.xib
new file mode 100644
index 0000000..52460fc
--- /dev/null
+++ b/Mac/CreateNodeWindow.xib
@@ -0,0 +1,596 @@
+
+
+
+ 1080
+ 12B2080
+ 2844
+ 1187
+ 624.00
+
+
+
+
+
+
+
+ YES
+
+
+ window
+
+
+
+ 6
+
+
+
+ _nameField
+
+
+
+ 19
+
+
+
+ _sizeField
+
+
+
+ 20
+
+
+
+ ActionOK:
+
+
+
+ 21
+
+
+
+ ActionCancel:
+
+
+
+ 22
+
+
+
+ _nameFieldLabel
+
+
+
+ 23
+
+
+
+ _sizeFieldLabel
+
+
+
+ 24
+
+
+
+
+ YES
+
+ 0
+
+ YES
+
+
+
+
+
+ -2
+
+
+ File's Owner
+
+
+ -1
+
+
+ First Responder
+
+
+ -3
+
+
+ Application
+
+
+ 2
+
+
+ YES
+
+
+
+
+
+ 3
+
+
+ YES
+
+
+
+
+
+
+
+
+
+
+ 7
+
+
+ YES
+
+
+
+
+
+ 8
+
+
+
+
+ 9
+
+
+ YES
+
+
+
+
+
+ 10
+
+
+
+
+ 11
+
+
+ YES
+
+
+
+
+
+ 12
+
+
+
+
+ 13
+
+
+ YES
+
+
+
+
+
+ 14
+
+
+
+
+ 15
+
+
+ YES
+
+
+
+
+
+ 16
+
+
+
+
+ 17
+
+
+ YES
+
+
+
+
+
+ 18
+
+
+
+
+
+
+ YES
+
+ YES
+ -1.IBPluginDependency
+ -2.IBPluginDependency
+ -3.IBPluginDependency
+ 10.IBPluginDependency
+ 11.IBPluginDependency
+ 12.IBPluginDependency
+ 13.IBPluginDependency
+ 14.IBPluginDependency
+ 15.IBPluginDependency
+ 16.IBPluginDependency
+ 17.IBPluginDependency
+ 18.IBPluginDependency
+ 2.IBPluginDependency
+ 2.IBWindowTemplateEditedContentRect
+ 2.NSWindowTemplate.visibleAtLaunch
+ 3.IBPluginDependency
+ 7.IBPluginDependency
+ 8.IBPluginDependency
+ 9.IBPluginDependency
+
+
+ YES
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ {{319, 371}, {606, 354}}
+
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+
+
+
+ YES
+
+
+
+
+
+ YES
+
+
+
+
+ 24
+
+
+
+ YES
+
+ CreateNodeWindow
+ NSWindow
+
+ IBProjectSource
+ ./Classes/CreateNodeWindow.h
+
+
+
+ CreateNodeWindowController
+ NSWindowController
+
+ YES
+
+ YES
+ ActionCancel:
+ ActionOK:
+
+
+ YES
+ id
+ id
+
+
+
+ YES
+
+ YES
+ ActionCancel:
+ ActionOK:
+
+
+ YES
+
+ ActionCancel:
+ id
+
+
+ ActionOK:
+ id
+
+
+
+
+ YES
+
+ YES
+ _nameField
+ _nameFieldLabel
+ _sizeField
+ _sizeFieldLabel
+
+
+ YES
+ NSTextField
+ NSTextField
+ NSTextField
+ NSTextField
+
+
+
+ YES
+
+ YES
+ _nameField
+ _nameFieldLabel
+ _sizeField
+ _sizeFieldLabel
+
+
+ YES
+
+ _nameField
+ NSTextField
+
+
+ _nameFieldLabel
+ NSTextField
+
+
+ _sizeField
+ NSTextField
+
+
+ _sizeFieldLabel
+ NSTextField
+
+
+
+
+ IBProjectSource
+ ./Classes/CreateNodeWindowController.h
+
+
+
+
+ 0
+ IBCocoaFramework
+
+ com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3
+
+
+ YES
+ 3
+
+
diff --git a/Mac/CreateNodeWindowController.cs b/Mac/CreateNodeWindowController.cs
new file mode 100644
index 0000000..51e6fdf
--- /dev/null
+++ b/Mac/CreateNodeWindowController.cs
@@ -0,0 +1,233 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+using Substrate.Nbt;
+
+namespace NBTExplorer.Mac
+{
+ public partial class CreateNodeWindowController : MonoMac.AppKit.NSWindowController
+ {
+ private string _name;
+ private int _size;
+ private TagType _type;
+ private TagNode _tag;
+
+ private bool _hasName;
+
+ private List _invalidNames = new List();
+
+ #region Constructors
+
+ // Called when created from unmanaged code
+ public CreateNodeWindowController (IntPtr handle) : base (handle)
+ {
+ Initialize ();
+ }
+
+ // Called when created directly from a XIB file
+ [Export ("initWithCoder:")]
+ public CreateNodeWindowController (NSCoder coder) : base (coder)
+ {
+ Initialize ();
+ }
+
+ // Call to load from the XIB/NIB file
+ public CreateNodeWindowController () : base ("CreateNodeWindow")
+ {
+ Initialize ();
+ }
+
+ // Shared initialization code
+ void Initialize ()
+ {
+ }
+
+ public override void AwakeFromNib ()
+ {
+ base.AwakeFromNib ();
+ SetNameBoxState();
+ SetSizeBoxState();
+ }
+
+ #endregion
+
+ //strongly typed window accessor
+ public new CreateNodeWindow Window
+ {
+ get {
+ return (CreateNodeWindow)base.Window;
+ }
+ }
+
+ private void SetNameBoxState ()
+ {
+ if (_nameField == null || _nameFieldLabel == null)
+ return;
+
+ if (HasName) {
+ _nameFieldLabel.Enabled = true;
+ _nameFieldLabel.TextColor = NSColor.ControlText;
+ _nameField.Enabled = true;
+ }
+ else {
+ _nameFieldLabel.Enabled = false;
+ _nameFieldLabel.TextColor = NSColor.DisabledControlText;
+ _nameField.Enabled = false;
+ }
+ }
+
+ private void SetSizeBoxState ()
+ {
+ if (_sizeField == null || _sizeFieldLabel == null)
+ return;
+
+ if (IsTagSizedType) {
+ _sizeFieldLabel.Enabled = true;
+ _sizeFieldLabel.TextColor = NSColor.ControlText;
+ _sizeField.Enabled = true;
+ }
+ else {
+ _sizeFieldLabel.Enabled = false;
+ _sizeFieldLabel.TextColor = NSColor.DisabledControlText;
+ _sizeField.Enabled = false;
+ }
+ }
+
+ public TagType TagType
+ {
+ get { return _type; }
+ set {
+ _type = value;
+ SetSizeBoxState();
+ }
+ }
+
+ public string TagName
+ {
+ get { return _name; }
+ }
+
+ public TagNode TagNode
+ {
+ get { return _tag; }
+ }
+
+ public List InvalidNames
+ {
+ get { return _invalidNames; }
+ }
+
+ public bool HasName
+ {
+ get { return _hasName; }
+ set
+ {
+ _hasName = value;
+ SetNameBoxState();
+ }
+ }
+
+ private void Apply ()
+ {
+ if (ValidateInput()) {
+ _tag = CreateTag();
+ NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.OK);
+ return;
+ }
+ }
+
+ private TagNode CreateTag ()
+ {
+ switch (_type) {
+ case TagType.TAG_BYTE:
+ return new TagNodeByte();
+ case TagType.TAG_BYTE_ARRAY:
+ return new TagNodeByteArray(new byte[_size]);
+ case TagType.TAG_COMPOUND:
+ return new TagNodeCompound();
+ case TagType.TAG_DOUBLE:
+ return new TagNodeDouble();
+ case TagType.TAG_FLOAT:
+ return new TagNodeFloat();
+ case TagType.TAG_INT:
+ return new TagNodeInt();
+ case TagType.TAG_INT_ARRAY:
+ return new TagNodeIntArray(new int[_size]);
+ case TagType.TAG_LIST:
+ return new TagNodeList(TagType.TAG_BYTE);
+ case TagType.TAG_LONG:
+ return new TagNodeLong();
+ case TagType.TAG_SHORT:
+ return new TagNodeShort();
+ case TagType.TAG_STRING:
+ return new TagNodeString();
+ default:
+ return new TagNodeByte();
+ }
+ }
+
+ private bool ValidateInput ()
+ {
+ return ValidateNameInput()
+ && ValidateSizeInput();
+ }
+
+ private bool ValidateNameInput ()
+ {
+ if (!HasName)
+ return true;
+
+ string text = _nameField.StringValue.Trim();
+
+ if (_invalidNames.Contains(text)) {
+ NSAlert.WithMessage("Duplicate name.", "OK", null, null, "You cannot specify a name already in use by another tag within the same container.").RunModal();
+ return false;
+ }
+
+ _name = _nameField.StringValue.Trim();
+ return true;
+ }
+
+ private bool ValidateSizeInput ()
+ {
+ if (!IsTagSizedType)
+ return true;
+
+ if (!Int32.TryParse(_sizeField.StringValue.Trim(), out _size)) {
+ NSAlert.WithMessage("Invalid size.", "OK", null, null, "The size field must be a valid integer value.").RunModal();
+ return false;
+ }
+
+ _size = Math.Max(0, _size);
+ return true;
+ }
+
+ private bool IsTagSizedType
+ {
+ get
+ {
+ switch (_type) {
+ case TagType.TAG_BYTE_ARRAY:
+ case TagType.TAG_INT_ARRAY:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ partial void ActionOK (NSObject sender)
+ {
+ Apply ();
+ }
+
+ partial void ActionCancel (NSObject sender)
+ {
+ NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
+ }
+ }
+}
+
diff --git a/Mac/EditNameWindow.xib b/Mac/EditNameWindow.xib
index 830a66f..407c815 100644
--- a/Mac/EditNameWindow.xib
+++ b/Mac/EditNameWindow.xib
@@ -40,7 +40,7 @@
NSApplication
- 3
+ 1
2
{{131, 74}, {271, 91}}
611844096
diff --git a/Mac/EditStringWindow.xib b/Mac/EditStringWindow.xib
index feea0c6..e33900f 100644
--- a/Mac/EditStringWindow.xib
+++ b/Mac/EditStringWindow.xib
@@ -41,7 +41,7 @@
NSApplication
- 3
+ 1
2
{{131, 74}, {380, 190}}
611844096
diff --git a/Mac/EditValueWindow.cs b/Mac/EditValueWindow.cs
new file mode 100644
index 0000000..341f90c
--- /dev/null
+++ b/Mac/EditValueWindow.cs
@@ -0,0 +1,35 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoMac.Foundation;
+using MonoMac.AppKit;
+
+namespace NBTExplorer.Mac
+{
+ public partial class EditValueWindow : MonoMac.AppKit.NSWindow
+ {
+ #region Constructors
+
+ // Called when created from unmanaged code
+ public EditValueWindow (IntPtr handle) : base (handle)
+ {
+ Initialize ();
+ }
+
+ // Called when created directly from a XIB file
+ [Export ("initWithCoder:")]
+ public EditValueWindow (NSCoder coder) : base (coder)
+ {
+ Initialize ();
+ }
+
+ // Shared initialization code
+ void Initialize ()
+ {
+ }
+
+ #endregion
+ }
+}
+
diff --git a/Mac/EditValue.designer.cs b/Mac/EditValueWindow.designer.cs
similarity index 77%
rename from Mac/EditValue.designer.cs
rename to Mac/EditValueWindow.designer.cs
index 1644bfa..71a5fe2 100644
--- a/Mac/EditValue.designer.cs
+++ b/Mac/EditValueWindow.designer.cs
@@ -8,8 +8,8 @@ using MonoMac.Foundation;
namespace NBTExplorer.Mac
{
- [Register ("EditValue")]
- partial class EditValue
+ [Register ("EditValueWindowController")]
+ partial class EditValueWindowController
{
[Outlet]
MonoMac.AppKit.NSTextField _valueField { get; set; }
@@ -28,4 +28,13 @@ namespace NBTExplorer.Mac
}
}
}
+
+ [Register ("EditValueWindow")]
+ partial class EditValueWindow
+ {
+
+ void ReleaseDesignerOutlets ()
+ {
+ }
+ }
}
diff --git a/Mac/EditValue.xib b/Mac/EditValueWindow.xib
similarity index 74%
rename from Mac/EditValue.xib
rename to Mac/EditValueWindow.xib
index 76a7cc7..8ed3e53 100644
--- a/Mac/EditValue.xib
+++ b/Mac/EditValueWindow.xib
@@ -31,7 +31,7 @@
YES
- EditValue
+ EditValueWindowController
FirstResponder
@@ -39,39 +39,39 @@
NSApplication
-
- 3
+
+ 1
2
- {{131, 86}, {262, 91}}
+ {{131, 74}, {231, 96}}
611844096
Edit Value...
- EditValue
+ EditValueWindow
-
+
256
YES
-
-
- 266
- {{20, 49}, {222, 22}}
-
+
+
+ 268
+ {{20, 54}, {191, 22}}
+
_NS:9
YES
-
+
-1804599231
- 272630848
+ 272630784
-
+
LucidaGrande
13
1044
_NS:9
-
+
YES
6
@@ -94,21 +94,21 @@
NO
-
-
+
+
268
- {{166, 13}, {82, 32}}
-
+ {{135, 13}, {82, 32}}
+
_NS:9
YES
-
+
67108864
134217728
OK
-
+
_NS:9
-
+
-2038284288
129
@@ -118,21 +118,21 @@
NO
-
-
+
+
268
- {{84, 13}, {82, 32}}
-
+ {{53, 13}, {82, 32}}
+
_NS:9
YES
-
+
67108864
134217728
Cancel
-
+
_NS:9
-
+
-2038284288
129
@@ -143,11 +143,11 @@
NO
- {262, 91}
+ {231, 96}
- {{0, 0}, {1600, 1178}}
+ {{0, 0}, {1280, 778}}
{10000000000000, 10000000000000}
YES
@@ -155,29 +155,37 @@
YES
+
+
+ window
+
+
+
+ 6
+
_valueField
-
+
- 9
+ 13
ActionOK:
-
+
- 10
+ 14
ActionCancel:
-
+
- 11
+ 15
@@ -210,66 +218,66 @@
Application
- 1
-
+ 2
+
YES
-
+
-
- 2
-
-
- YES
-
-
-
-
-
-
3
-
+
YES
-
+
+
+
-
-
-
- 4
-
-
-
-
- 5
-
-
- YES
-
-
-
-
-
- 6
-
-
+
7
-
+
YES
-
+
-
+
8
-
-
+
+
+
+
+ 9
+
+
+ YES
+
+
+
+
+
+ 10
+
+
+
+
+ 11
+
+
+ YES
+
+
+
+
+
+ 12
+
+
@@ -280,16 +288,16 @@
-1.IBPluginDependency
-2.IBPluginDependency
-3.IBPluginDependency
- 1.IBPluginDependency
- 1.IBWindowTemplateEditedContentRect
- 1.NSWindowTemplate.visibleAtLaunch
+ 10.IBPluginDependency
+ 11.IBPluginDependency
+ 12.IBPluginDependency
2.IBPluginDependency
+ 2.IBWindowTemplateEditedContentRect
+ 2.NSWindowTemplate.visibleAtLaunch
3.IBPluginDependency
- 4.IBPluginDependency
- 5.IBPluginDependency
- 6.IBPluginDependency
7.IBPluginDependency
8.IBPluginDependency
+ 9.IBPluginDependency
YES
@@ -297,15 +305,15 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{361, 348}, {602, 342}}
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ {{319, 371}, {606, 354}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
@@ -320,14 +328,22 @@
- 11
+ 15
YES
- EditValue
+ EditValueWindow
NSWindow
+
+ IBProjectSource
+ ./Classes/EditValueWindow.h
+
+
+
+ EditValueWindowController
+ NSWindowController
YES
@@ -373,7 +389,7 @@
IBProjectSource
- ./Classes/EditValue.h
+ ./Classes/EditValueWindowController.h
diff --git a/Mac/EditValue.cs b/Mac/EditValueWindowController.cs
similarity index 57%
rename from Mac/EditValue.cs
rename to Mac/EditValueWindowController.cs
index 76f213c..e20d36a 100644
--- a/Mac/EditValue.cs
+++ b/Mac/EditValueWindowController.cs
@@ -8,93 +8,69 @@ using Substrate.Nbt;
namespace NBTExplorer.Mac
{
- public partial class EditValue : MonoMac.AppKit.NSWindow
+ public partial class EditValueWindowController : MonoMac.AppKit.NSWindowController
{
private TagNode _tag;
#region Constructors
// Called when created from unmanaged code
- public EditValue (IntPtr handle) : base (handle)
+ public EditValueWindowController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
- public EditValue (NSCoder coder) : base (coder)
+ public EditValueWindowController (NSCoder coder) : base (coder)
{
Initialize ();
}
-
- public EditValue (TagNode tag)
+
+ // Call to load from the XIB/NIB file
+ public EditValueWindowController () : base ("EditValueWindow")
{
Initialize ();
-
- _tag = tag;
-
- if (tag == null) {
- NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
- return;
- }
}
// Shared initialization code
void Initialize ()
{
}
+
+ #endregion
+
+ //strongly typed window accessor
+ public new EditValueWindow Window
+ {
+ get {
+ return (EditValueWindow)base.Window;
+ }
+ }
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
+
if (_tag != null)
_valueField.StringValue = _tag.ToString();
}
- #endregion
-
public TagNode NodeTag
{
get { return _tag; }
- }
-
- partial void ActionOK (MonoMac.Foundation.NSObject sender)
- {
- NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.OK);
- }
-
- partial void ActionCancel (MonoMac.Foundation.NSObject sender)
- {
- NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
- }
-
- /*private TagNode _tag;
-
- public EditValue (TagNode tag)
- {
- InitializeComponent();
-
- _tag = tag;
-
- if (tag == null) {
- DialogResult = DialogResult.Abort;
- Close();
- return;
+ set {
+ _tag = value;
+ if (_valueField != null)
+ _valueField.StringValue = _tag.ToString();
}
-
- textBox1.Text = _tag.ToString();
- }
-
- public TagNode NodeTag
- {
- get { return _tag; }
}
private void Apply ()
{
if (ValidateInput()) {
- DialogResult = DialogResult.OK;
- Close();
+ NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.OK);
+ return;
}
}
@@ -108,40 +84,40 @@ namespace NBTExplorer.Mac
try {
switch (_tag.GetTagType()) {
case TagType.TAG_BYTE:
- _tag.ToTagByte().Data = unchecked((byte)sbyte.Parse(textBox1.Text));
+ _tag.ToTagByte().Data = unchecked((byte)sbyte.Parse(_valueField.StringValue));
break;
case TagType.TAG_SHORT:
- _tag.ToTagShort().Data = short.Parse(textBox1.Text);
+ _tag.ToTagShort().Data = short.Parse(_valueField.StringValue);
break;
case TagType.TAG_INT:
- _tag.ToTagInt().Data = int.Parse(textBox1.Text);
+ _tag.ToTagInt().Data = int.Parse(_valueField.StringValue);
break;
case TagType.TAG_LONG:
- _tag.ToTagLong().Data = long.Parse(textBox1.Text);
+ _tag.ToTagLong().Data = long.Parse(_valueField.StringValue);
break;
case TagType.TAG_FLOAT:
- _tag.ToTagFloat().Data = float.Parse(textBox1.Text);
+ _tag.ToTagFloat().Data = float.Parse(_valueField.StringValue);
break;
case TagType.TAG_DOUBLE:
- _tag.ToTagDouble().Data = double.Parse(textBox1.Text);
+ _tag.ToTagDouble().Data = double.Parse(_valueField.StringValue);
break;
case TagType.TAG_STRING:
- _tag.ToTagString().Data = textBox1.Text;
+ _tag.ToTagString().Data = _valueField.StringValue;
break;
}
}
catch (FormatException) {
- MessageBox.Show("The value is formatted incorrectly for the given type.");
+ NSAlert.WithMessage("Invalid Format", "OK", null, null, "The value is formatted incorrectly for the given type.").RunModal();
return false;
}
catch (OverflowException) {
- MessageBox.Show("The value is outside the acceptable range for the given type.");
+ NSAlert.WithMessage("Invalid Range", "OK", null, null, "The value is outside the acceptable range for the given type.").RunModal();
return false;
}
catch {
@@ -150,11 +126,16 @@ namespace NBTExplorer.Mac
return true;
}
-
- private void _buttonOK_Click (object sender, EventArgs e)
+
+ partial void ActionOK (MonoMac.Foundation.NSObject sender)
{
- Apply();
- }*/
+ Apply ();
+ }
+
+ partial void ActionCancel (MonoMac.Foundation.NSObject sender)
+ {
+ NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
+ }
}
}
diff --git a/Mac/FormHandlers.cs b/Mac/FormHandlers.cs
index 6c6a6a7..a7e35a5 100644
--- a/Mac/FormHandlers.cs
+++ b/Mac/FormHandlers.cs
@@ -7,21 +7,21 @@ namespace NBTExplorer.Mac
{
public static void Register ()
{
- //FormRegistry.EditByteArray = EditByteArrayHandler;
+ FormRegistry.EditByteArray = EditByteArrayHandler;
FormRegistry.EditString = EditStringHandler;
FormRegistry.EditTagScalar = EditTagScalarValueHandler;
FormRegistry.RenameTag = RenameTagHandler;
- //FormRegistry.CreateNode = CreateNodeHandler;
+ FormRegistry.CreateNode = CreateNodeHandler;
FormRegistry.MessageBox = MessageBoxHandler;
}
private static ModalResult RunWindow (NSWindowController controller)
{
- NSApplication.SharedApplication.BeginSheet (controller.Window, NSApplication.SharedApplication.MainWindow);
+ //NSApplication.SharedApplication.BeginSheet (controller.Window, NSApplication.SharedApplication.MainWindow);
int response = NSApplication.SharedApplication.RunModalForWindow (controller.Window);
- NSApplication.SharedApplication.EndSheet(controller.Window);
+ //NSApplication.SharedApplication.EndSheet(controller.Window);
controller.Window.Close();
controller.Window.OrderOut(null);
@@ -33,7 +33,7 @@ namespace NBTExplorer.Mac
public static void MessageBoxHandler (string message)
{
- NSAlert.WithMessage(message, "OK", null, null, null).RunModal();
+ NSAlert.WithMessage(message, "OK", null, null, "").RunModal();
}
public static bool EditStringHandler (StringFormData data)
@@ -65,45 +65,46 @@ namespace NBTExplorer.Mac
public static bool EditTagScalarValueHandler (TagScalarFormData data)
{
- EditValue form = new EditValue(data.Tag);
+ EditValueWindowController form = new EditValueWindowController () {
+ NodeTag = data.Tag,
+ };
- NSApplication.SharedApplication.BeginSheet(form, NSApplication.SharedApplication.MainWindow);
- NSApplication.SharedApplication.RunModalForWindow(form);
- NSApplication.SharedApplication.EndSheet(form);
-
- form.Close ();
- form.OrderOut(null);
-
- //if (form.ShowDialog() == DialogResult.OK)
- // return true;
- //else
+ if (RunWindow (form) == ModalResult.OK)
+ return true;
+ else
return false;
}
- /*public static bool EditByteArrayHandler (ByteArrayFormData data)
+ public static bool EditByteArrayHandler (ByteArrayFormData data)
{
- HexEditor form = new HexEditor(data.NodeName, data.Data, data.BytesPerElement);
+ NSAlert.WithMessage("Not supported.", "OK", null, null, "Array editing is currently not supported in the Mac version of NBTExplorer.").RunModal();
+ return false;
+
+ /*HexEditor form = new HexEditor(data.NodeName, data.Data, data.BytesPerElement);
if (form.ShowDialog() == DialogResult.OK && form.Modified) {
Array.Copy(form.Data, data.Data, data.Data.Length);
return true;
}
else
- return false;
+ 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) {
+ CreateNodeWindowController form = new CreateNodeWindowController () {
+ TagType = data.TagType,
+ HasName = data.HasName,
+ };
+ form.InvalidNames.AddRange (data.RestrictedNames);
+
+ if (RunWindow (form) == ModalResult.OK) {
data.TagNode = form.TagNode;
data.TagName = form.TagName;
return true;
}
else
return false;
- }*/
+ }
}
}
diff --git a/Mac/MainMenu.xib b/Mac/MainMenu.xib
index 84f1bf7..3c7e7e5 100644
--- a/Mac/MainMenu.xib
+++ b/Mac/MainMenu.xib
@@ -88,6 +88,7 @@
_NSAppleMenu
+ YES
+ YES
+
+
+
+ YES
+ YES
+ YES
@@ -549,38 +582,6 @@
534
-
-
- copy:
-
-
-
- 224
-
-
-
- paste:
-
-
-
- 226
-
-
-
- cut:
-
-
-
- 228
-
-
-
- saveDocument:
-
-
-
- 362
-
runToolbarCustomizationPalette:
@@ -597,14 +598,6 @@
366
-
-
- openDocument:
-
-
-
- 374
-
ActionEditValue:
@@ -821,13 +814,205 @@
594
+
+
+ _menuMoveUp
+
+
+
+ 599
+
+
+
+ _menuMoveDown
+
+
+
+ 600
+
+
+
+ ActionMoveUp:
+
+
+
+ 601
+
+
+
+ ActionMoveDown:
+
+
+
+ 602
+
+
+
+ ActionFind:
+
+
+
+ 603
+
+
+
+ ActionFindNext:
+
+
+
+ 604
+
+
+
+ ActionPaste:
+
+
+
+ 605
+
+
+
+ ActionCopy:
+
+
+
+ 606
+
+
+
+ ActionCut:
+
+
+
+ 607
+
+
+
+ ActionOpen:
+
+
+
+ 608
+
+
+
+ ActionOpenFolder:
+
+
+
+ 609
+
+
+
+ ActionOpenMinecraft:
+
+
+
+ 610
+
+
+
+ ActionSave:
+
+
+
+ 611
+
+
+
+ ActionInsertByte:
+
+
+
+ 612
+
+
+
+ ActionInsertShort:
+
+
+
+ 613
+
+
+
+ ActionInsertInt:
+
+
+
+ 614
+
+
+
+ ActionInsertLong:
+
+
+
+ 615
+
+
+
+ ActionInsertFloat:
+
+
+
+ 616
+
+
+
+ ActionInsertDouble:
+
+
+
+ 617
+
+
+
+ ActionInsertByteArray:
+
+
+
+ 618
+
+
+
+ ActionInsertIntArray:
+
+
+
+ 619
+
+
+
+ ActionInsertString:
+
+
+
+ 620
+
+
+
+ ActionInsertList:
+
+
+
+ 621
+
+
+
+ ActionInsertCompound:
+
+
+
+ 623
+
_menuInsertCompound
- 595
+ 624
@@ -962,6 +1147,9 @@
+
+
+
@@ -1213,6 +1401,21 @@
+
+ 596
+
+
+
+
+ 597
+
+
+
+
+ 598
+
+
+
@@ -1269,6 +1472,9 @@
572.IBPluginDependency
573.IBPluginDependency
58.IBPluginDependency
+ 596.IBPluginDependency
+ 597.IBPluginDependency
+ 598.IBPluginDependency
72.IBPluginDependency
75.IBPluginDependency
79.IBPluginDependency
@@ -1332,6 +1538,9 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
@@ -1346,7 +1555,7 @@
- 595
+ 624
@@ -1358,27 +1567,101 @@
YES
YES
+ ActionCopy:
+ ActionCut:
ActionDelete:
ActionEditValue:
+ ActionFind:
+ ActionFindNext:
+ ActionInsertByte:
+ ActionInsertByteArray:
+ ActionInsertCompound:
+ ActionInsertDouble:
+ ActionInsertFloat:
+ ActionInsertInt:
+ ActionInsertIntArray:
+ ActionInsertList:
+ ActionInsertLong:
+ ActionInsertShort:
+ ActionInsertString:
+ ActionMoveDown:
+ ActionMoveUp:
+ ActionOpen:
+ ActionOpenFolder:
+ ActionOpenMinecraft:
+ ActionPaste:
ActionRename:
+ ActionSave:
YES
id
id
id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
+ id
YES
YES
+ ActionCopy:
+ ActionCut:
ActionDelete:
ActionEditValue:
+ ActionFind:
+ ActionFindNext:
+ ActionInsertByte:
+ ActionInsertByteArray:
+ ActionInsertCompound:
+ ActionInsertDouble:
+ ActionInsertFloat:
+ ActionInsertInt:
+ ActionInsertIntArray:
+ ActionInsertList:
+ ActionInsertLong:
+ ActionInsertShort:
+ ActionInsertString:
+ ActionMoveDown:
+ ActionMoveUp:
+ ActionOpen:
+ ActionOpenFolder:
+ ActionOpenMinecraft:
+ ActionPaste:
ActionRename:
+ ActionSave:
YES
+
+ ActionCopy:
+ id
+
+
+ ActionCut:
+ id
+
ActionDelete:
id
@@ -1387,10 +1670,90 @@
ActionEditValue:
id
+
+ ActionFind:
+ id
+
+
+ ActionFindNext:
+ id
+
+
+ ActionInsertByte:
+ id
+
+
+ ActionInsertByteArray:
+ id
+
+
+ ActionInsertCompound:
+ id
+
+
+ ActionInsertDouble:
+ id
+
+
+ ActionInsertFloat:
+ id
+
+
+ ActionInsertInt:
+ id
+
+
+ ActionInsertIntArray:
+ id
+
+
+ ActionInsertList:
+ id
+
+
+ ActionInsertLong:
+ id
+
+
+ ActionInsertShort:
+ id
+
+
+ ActionInsertString:
+ id
+
+
+ ActionMoveDown:
+ id
+
+
+ ActionMoveUp:
+ id
+
+
+ ActionOpen:
+ id
+
+
+ ActionOpenFolder:
+ id
+
+
+ ActionOpenMinecraft:
+ id
+
+
+ ActionPaste:
+ id
+
ActionRename:
id
+
+ ActionSave:
+ id
+
@@ -1415,6 +1778,8 @@
_menuInsertLong
_menuInsertShort
_menuInsertString
+ _menuMoveDown
+ _menuMoveUp
_menuOpen
_menuOpenFolder
_menuOpenMinecraft
@@ -1450,6 +1815,8 @@
NSMenuItem
NSMenuItem
NSMenuItem
+ NSMenuItem
+ NSMenuItem
@@ -1474,6 +1841,8 @@
_menuInsertLong
_menuInsertShort
_menuInsertString
+ _menuMoveDown
+ _menuMoveUp
_menuOpen
_menuOpenFolder
_menuOpenMinecraft
@@ -1556,6 +1925,14 @@
_menuInsertString
NSMenuItem
+
+ _menuMoveDown
+ NSMenuItem
+
+
+ _menuMoveUp
+ NSMenuItem
+
_menuOpen
NSMenuItem
diff --git a/Mac/MainWindow.cs b/Mac/MainWindow.cs
index 996ae3d..d01db7e 100644
--- a/Mac/MainWindow.cs
+++ b/Mac/MainWindow.cs
@@ -65,7 +65,11 @@ namespace NBTExplorer
public AppDelegate AppDelegate
{
get { return _appDelegate; }
- set { _appDelegate = value; }
+ set
+ {
+ _appDelegate = value;
+ UpdateUI ();
+ }
}
#endregion
@@ -76,6 +80,8 @@ namespace NBTExplorer
{
base.AwakeFromNib ();
+ NSApplication.SharedApplication.MainMenu.AutoEnablesItems = false;
+
_dataSource = new TreeDataSource();
_mainOutlineView.DataSource = _dataSource;
_mainOutlineView.Delegate = new MyDelegate(this);
@@ -100,6 +106,13 @@ namespace NBTExplorer
_main = main;
}
+ public override void SelectionDidChange (NSNotification notification)
+ {
+ TreeDataNode node = _main.SelectedNode;
+ if (node != null)
+ _main.UpdateUI(node.Data);
+ }
+
public override void ItemWillExpand (NSNotification notification)
{
TreeDataNode node = notification.UserInfo ["NSObject"] as TreeDataNode;
@@ -300,25 +313,131 @@ namespace NBTExplorer
node.Nodes.Clear();*/
}
+ private void RefreshChildNodes (TreeDataNode node, DataNode dataNode)
+ {
+ Dictionary currentNodes = new Dictionary();
+ foreach (TreeDataNode child in node.Nodes) {
+ currentNodes.Add(child.Data, child);
+ }
+
+ node.Nodes.Clear();
+ foreach (DataNode child in dataNode.Nodes) {
+ if (!currentNodes.ContainsKey(child))
+ node.Nodes.Add(new TreeDataNode(child));
+ else
+ node.Nodes.Add(currentNodes[child]);
+ }
+
+ //foreach (TreeDataNode child in node.Nodes)
+ // child.ContextMenuStrip = BuildNodeContextMenu(child.Tag as DataNode);
+
+ if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) {
+ ExpandNode(node);
+ _mainOutlineView.ExpandItem(node);
+ //node.Expand();
+ }
+
+ _mainOutlineView.ReloadItem(node, true);
+ }
+
+ private void CreateNode (TreeDataNode node, TagType type)
+ {
+ if (node == null)
+ return;
+
+ if (!node.Data.CanCreateTag(type))
+ return;
+
+ if (node.Data.CreateNode(type)) {
+ //node.Text = dataNode.NodeDisplay;
+ RefreshChildNodes(node, node.Data);
+ UpdateUI(node.Data);
+ }
+ }
+
+ private TreeDataNode SelectedNode
+ {
+ get { return _mainOutlineView.ItemAtRow (_mainOutlineView.SelectedRow) as TreeDataNode; }
+ }
+
public void ActionEditValue ()
{
- TreeDataNode node = _mainOutlineView.ItemAtRow(_mainOutlineView.SelectedRow) as TreeDataNode;
- if (node != null)
- EditNode(node);
+ EditNode(SelectedNode);
}
public void ActionRenameValue ()
{
- TreeDataNode node = _mainOutlineView.ItemAtRow(_mainOutlineView.SelectedRow) as TreeDataNode;
- if (node != null)
- RenameNode(node);
+ RenameNode(SelectedNode);
}
public void ActionDeleteValue ()
{
- TreeDataNode node = _mainOutlineView.ItemAtRow(_mainOutlineView.SelectedRow) as TreeDataNode;
- if (node != null)
- DeleteNode(node);
+ DeleteNode(SelectedNode);
+ }
+
+ public void ActionMoveNodeUp ()
+ {
+ MoveNodeUp(SelectedNode);
+ }
+
+ public void ActionMoveNodeDown ()
+ {
+ MoveNodeDown (SelectedNode);
+ }
+
+ public void ActionInsertByteTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_BYTE);
+ }
+
+ public void ActionInsertShortTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_SHORT);
+ }
+
+ public void ActionInsertIntTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_INT);
+ }
+
+ public void ActionInsertLongTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_LONG);
+ }
+
+ public void ActionInsertFloatTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_FLOAT);
+ }
+
+ public void ActionInsertDoubleTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_DOUBLE);
+ }
+
+ public void ActionInsertByteArrayTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_BYTE_ARRAY);
+ }
+
+ public void ActionInsertIntArrayTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_INT_ARRAY);
+ }
+
+ public void ActionInsertStringTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_STRING);
+ }
+
+ public void ActionInsertListTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_LIST);
+ }
+
+ public void ActionInsertCompoundTag ()
+ {
+ CreateNode (SelectedNode, TagType.TAG_COMPOUND);
}
private void EditNode (TreeDataNode node)
@@ -367,6 +486,104 @@ namespace NBTExplorer
}
}
+ private void MoveNodeUp (TreeDataNode node)
+ {
+ if (node == null)
+ return;
+
+ if (!node.Data.CanMoveNodeUp)
+ return;
+
+ node.Data.ChangeRelativePosition(-1);
+ RefreshChildNodes(node.Parent, node.Data.Parent);
+ }
+
+ private void MoveNodeDown (TreeDataNode node)
+ {
+ if (node == null)
+ return;
+
+ if (!node.Data.CanMoveNodeDown)
+ return;
+
+ node.Data.ChangeRelativePosition(1);
+ RefreshChildNodes(node.Parent, node.Data.Parent);
+ }
+
+ /*private void CopyNode (TreeNode node)
+ {
+ if (node == null || !(node.Tag is DataNode))
+ return;
+
+ DataNode dataNode = node.Tag as DataNode;
+ if (!dataNode.CanCopyNode)
+ return;
+
+ dataNode.CopyNode();
+ }
+
+ private void CutNode (TreeNode node)
+ {
+ if (node == null || !(node.Tag is DataNode))
+ return;
+
+ DataNode dataNode = node.Tag as DataNode;
+ if (!dataNode.CanCutNode)
+ return;
+
+ if (dataNode.CutNode()) {
+ UpdateUI(node.Parent.Tag as DataNode);
+ UpdateNodeText(node.Parent);
+ node.Remove();
+ }
+ }
+
+ private void PasteNode (TreeNode node)
+ {
+ if (node == null || !(node.Tag is DataNode))
+ return;
+
+ DataNode dataNode = node.Tag as DataNode;
+ if (!dataNode.CanPasteIntoNode)
+ return;
+
+ if (dataNode.PasteNode()) {
+ node.Text = dataNode.NodeDisplay;
+ RefreshChildNodes(node, dataNode);
+ UpdateUI(dataNode);
+ }
+ }*/
+
+ private void Save ()
+ {
+ foreach (TreeDataNode node in _dataSource.Nodes) {
+ if (node.Data != null)
+ node.Data.Save();
+ }
+
+ UpdateUI();
+ }
+
+ /*private bool ConfirmExit ()
+ {
+ if (CheckModifications()) {
+ if (MessageBox.Show("You currently have unsaved changes. Close anyway?", "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
+ return false;
+ }
+
+ return true;
+ }*/
+
+ private bool CheckModifications ()
+ {
+ foreach (TreeDataNode node in _dataSource.Nodes) {
+ if (node.Data != null && node.Data.IsModified)
+ return true;
+ }
+
+ return false;
+ }
+
private void UpdateUI ()
{
if (_appDelegate == null)
@@ -377,9 +594,13 @@ namespace NBTExplorer
UpdateUI(selected.Data);
}
else {
- //_appDelegate.MenuSave.Enabled = CheckModifications();
+ UpdateUI(new DataNode());
+
+ _appDelegate.MenuSave.Enabled = CheckModifications();
_appDelegate.MenuFind.Enabled = false;
//_appDelegate.MenuFindNext.Enabled = _searchState != null;
+
+ _toolbarSave.Enabled = _appDelegate.MenuSave.Enabled;
}
}
@@ -400,16 +621,68 @@ namespace NBTExplorer
_appDelegate.MenuInsertList.Enabled = node.CanCreateTag(TagType.TAG_LIST);
_appDelegate.MenuInsertCompound.Enabled = node.CanCreateTag(TagType.TAG_COMPOUND);
- //_appDelegate.MenuSave.Enabled = CheckModifications();
+ _appDelegate.MenuSave.Enabled = CheckModifications();
_appDelegate.MenuCopy.Enabled = node.CanCopyNode;
_appDelegate.MenuCut.Enabled = node.CanCutNode;
_appDelegate.MenuPaste.Enabled = node.CanPasteIntoNode;
_appDelegate.MenuDelete.Enabled = node.CanDeleteNode;
_appDelegate.MenuEditValue.Enabled = node.CanEditNode;
_appDelegate.MenuRename.Enabled = node.CanRenameNode;
+ _appDelegate.MenuMoveUp.Enabled = node.CanMoveNodeUp;
+ _appDelegate.MenuMoveDown.Enabled = node.CanMoveNodeDown;
_appDelegate.MenuFind.Enabled = node.CanSearchNode;
//_appDelegate.MenuFindNext.Enabled = _searchState != null;
+
+ _toolbarSave.Enabled = _appDelegate.MenuSave.Enabled;
}
+
+ /*private void UpdateOpenMenu ()
+ {
+ try {
+ if (Settings.Default.RecentDirectories == null)
+ Settings.Default.RecentDirectories = new StringCollection();
+ if (Settings.Default.RecentFiles == null)
+ Settings.Default.RecentFiles = new StringCollection();
+ }
+ catch {
+ return;
+ }
+
+ _menuItemRecentFolders.DropDown = BuildRecentEntriesDropDown(Settings.Default.RecentDirectories);
+ _menuItemRecentFiles.DropDown = BuildRecentEntriesDropDown(Settings.Default.RecentFiles);
+ }
+
+ private ToolStripDropDown BuildRecentEntriesDropDown (StringCollection list)
+ {
+ if (list == null || list.Count == 0)
+ return new ToolStripDropDown();
+
+ ToolStripDropDown menu = new ToolStripDropDown();
+ foreach (string entry in list) {
+ ToolStripMenuItem item = new ToolStripMenuItem("&" + (menu.Items.Count + 1) + " " + entry);
+ item.Tag = entry;
+ item.Click += _menuItemRecentPaths_Click;
+
+ menu.Items.Add(item);
+ }
+
+ return menu;
+ }
+
+ private void AddPathToHistory (StringCollection list, string entry)
+ {
+ foreach (string item in list) {
+ if (item == entry) {
+ list.Remove(item);
+ break;
+ }
+ }
+
+ while (list.Count >= 5)
+ list.RemoveAt(list.Count - 1);
+
+ list.Insert(0, entry);
+ }*/
}
}
diff --git a/Mac/MainWindow.xib b/Mac/MainWindow.xib
index 3860231..234f7aa 100644
--- a/Mac/MainWindow.xib
+++ b/Mac/MainWindow.xib
@@ -14,6 +14,8 @@
YES
IBCustomCell
NSCustomObject
+ NSMenu
+ NSMenuItem
NSOutlineView
NSScrollView
NSScroller
@@ -320,7 +322,7 @@
-2147483392
- {{224, 17}, {15, 102}}
+ {{762, 1}, {15, 543}}
@@ -328,12 +330,12 @@
NO
_doScroller:
- 0.99821109123434704
+ 0.9731182795698925
-2147483392
- {{1, 544}, {776, 15}}
+ {{1, 544}, {761, 15}}
_NS:60
@@ -341,7 +343,7 @@
1
_doScroller:
- 0.99871299871299868
+ 0.98067010309278346
{{-1, -1}, {778, 560}}
@@ -368,6 +370,28 @@
{10000000000000, 10000000000000}
YES
+
YES
@@ -439,6 +463,14 @@
42
+
+
+ menu
+
+
+
+ 77
+
@@ -567,6 +599,26 @@
+
+ 72
+
+
+ YES
+
+
+
+
+
+
+ 73
+
+
+
+
+ 74
+
+
+
@@ -595,6 +647,9 @@
44.IBPluginDependency
71.CustomClassName
71.IBPluginDependency
+ 72.IBPluginDependency
+ 73.IBPluginDependency
+ 74.IBPluginDependency
YES
@@ -620,6 +675,9 @@
com.apple.InterfaceBuilder.CocoaPlugin
ImageAndTextCell
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
@@ -634,7 +692,7 @@
- 71
+ 77
diff --git a/NBTExplorerMac.csproj b/NBTExplorerMac.csproj
index 603f387..48955bc 100644
--- a/NBTExplorerMac.csproj
+++ b/NBTExplorerMac.csproj
@@ -158,10 +158,6 @@
-
-
- EditValue.cs
-
@@ -177,6 +173,16 @@
EditNameWindow.cs
+
+
+
+ CreateNodeWindow.cs
+
+
+
+
+ EditValueWindow.cs
+
@@ -233,8 +239,9 @@
-
+
+
\ No newline at end of file