public SaveForm(HaRepackerMainPanel panel, WzNode wzNode) { InitializeComponent(); this.wzNode = wzNode; this.wzf = (WzFile)wzNode.Tag; this.panel = panel; }
/// <summary> /// /// </summary> /// <param name="otherWzFileToLoadAt"></param> /// <param name="path"></param> /// <param name="encVersion"></param> /// <param name="version"></param> /// <param name="panel"></param> /// <param name="currentDispatcher">Dispatcher thread</param> /// <returns></returns> private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel, Dispatcher currentDispatcher = null) { WzFile newFile; if (!OpenWzFile(path, encVersion, version, out newFile)) { return(null); } WzNode node = new WzNode(newFile); // execute in main thread if (currentDispatcher != null) { currentDispatcher.BeginInvoke((Action)(() => { panel.DataTree.Nodes.Add(node); SortNodesRecursively(node); })); } else { panel.DataTree.Nodes.Add(node); SortNodesRecursively(node); } return(newFile); }
public bool AddObject(WzObject obj, UndoRedoManager undoRedoMan) { if (CanNodeBeInserted(this, obj.Name)) { TryParseImage(); if (addObjInternal(obj)) { WzNode node = new WzNode(obj); Nodes.Add(node); if (node.Tag is WzImageProperty) { ((WzImageProperty)node.Tag).ParentImage.Changed = true; } undoRedoMan.AddUndoBatch(new System.Collections.Generic.List <UndoRedoAction> { UndoRedoManager.ObjectAdded(this, node) }); node.EnsureVisible(); return(true); } else { Warning.Error("Could not insert property, make sure all types are correct"); return(false); } } else { MessageBox.Show("Cannot insert object \"" + obj.Name + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } }
public void InsertWzFileUnsafe(WzFile f, HaRepackerMainPanel panel) { wzFiles.Add(f); WzNode node = new WzNode(f); panel.DataTree.Nodes.Add(node); SortNodesRecursively(node); }
public static WzNode GetChildNode(WzNode parentNode, string name) { foreach (WzNode node in parentNode.Nodes) if (node.Text == name) return node; return null; }
private void SortNodesRecursively(WzNode parent) { if (UserSettings.Sort) { parent.TreeView.Sort(); } }
public static bool CanNodeBeInserted(WzNode parentNode, string name) { IWzObject obj = (IWzObject)parentNode.Tag; if (obj is IPropertyContainer) return ((IPropertyContainer)obj)[name] == null; else if (obj is WzDirectory) return ((WzDirectory)obj)[name] == null; else if (obj is WzFile) return ((WzFile)obj).WzDirectory[name] == null; else return false; }
public SaveForm(HaRepackerMainPanel panel, WzNode wzNode) { InitializeComponent(); encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeGMS); encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeMSEA); encryptionBox.Items.Add(HaRepacker.Properties.Resources.EncTypeNone); this.wzNode = wzNode; this.wzf = (WzFile)wzNode.Tag; this.panel = panel; }
public static WzNode GetChildNode(WzNode parentNode, string name) { foreach (WzNode node in parentNode.Nodes) { if (node.Text == name) { return(node); } } return(null); }
public bool MoveWzObjectInto(WzNode newParent) { if (CanNodeBeInserted(newParent, Text)) { addObjInternal((IWzObject)newParent.Tag); return(true); } else { MessageBox.Show("Cannot insert object \"" + Text + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } }
private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel) { WzFile newFile; if (!OpenWzFile(path, encVersion, version, out newFile)) { return(null); } WzNode node = new WzNode(newFile); panel.DataTree.Nodes.Add(node); SortNodesRecursively(node); return(newFile); }
public bool AddNode(WzNode node) { if (CanNodeBeInserted(this, node.Text)) { TryParseImage(); this.Nodes.Add(node); addObjInternal((IWzObject)node.Tag); return(true); } else { MessageBox.Show("Cannot insert node \"" + node.Text + "\" because a node with the same name already exists. Skipping.", "Skipping Node", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } }
/// <summary> /// Loads the Data.wz file /// </summary> /// <param name="path"></param> /// <param name="encVersion"></param> /// <param name="panel"></param> /// <returns></returns> public WzImage LoadDataWzHotfixFile(string path, WzMapleVersion encVersion, HaRepackerMainPanel panel) { FileStream fs = File.Open(path, FileMode.Open); WzImage img = new WzImage(Path.GetFileName(path), fs, encVersion); img.ParseImage(true); WzNode node = new WzNode(img); panel.DataTree.Nodes.Add(node); if (UserSettings.Sort) { SortNodesRecursively(node); } return(img); }
public static bool CanNodeBeInserted(WzNode parentNode, string name) { IWzObject obj = (IWzObject)parentNode.Tag; if (obj is IPropertyContainer) { return(((IPropertyContainer)obj)[name] == null); } else if (obj is WzDirectory) { return(((WzDirectory)obj)[name] == null); } else if (obj is WzFile) { return(((WzFile)obj).WzDirectory[name] == null); } else { return(false); } }
public ContextMenuStrip CreateMenu(WzNode node, WzObject Tag) { ContextMenuStrip menu = null; if (Tag is WzImage || Tag is IPropertyContainer) { if (Tag is WzSubProperty) { menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove }); } else { menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove }); } } else if (Tag is WzImageProperty) { menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { /*export, import,*/Remove }); } else if (Tag is WzDirectory) { menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, /*export, import,*/Remove }); } else if (Tag is WzFile) { menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, SaveFile, Unload, Reload }); } currNode = node; return menu; }
private void InsertWzNodeCallback(WzNode node, WzNode parent) { WzNode child = WzNode.GetChildNode(parent, node.Text); if (child != null) { if (ShowReplaceDialog(node.Text)) child.Delete(); else return; } parent.AddNode(node); }
public bool AddObject(IWzObject obj, UndoRedoManager undoRedoMan) { if (CanNodeBeInserted(this, obj.Name)) { TryParseImage(); addObjInternal(obj); WzNode node = new WzNode(obj); Nodes.Add(node); if (node.Tag is IWzImageProperty) ((IWzImageProperty)node.Tag).ParentImage.Changed = true; undoRedoMan.AddUndoBatch(new System.Collections.Generic.List<UndoRedoAction> { UndoRedoManager.ObjectAdded(this, node) }); node.EnsureVisible(); return true; } else { MessageBox.Show("Cannot insert object \"" + obj.Name + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } }
public bool AddNode(WzNode node) { if (CanNodeBeInserted(this, node.Text)) { TryParseImage(); this.Nodes.Add(node); addObjInternal((IWzObject)node.Tag); return true; } else { MessageBox.Show("Cannot insert node \"" + node.Text + "\" because a node with the same name already exists. Skipping.", "Skipping Node", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } }
public bool MoveInto(WzNode newParent) { if (CanNodeBeInserted(newParent, Text)) { addObjInternal((IWzObject)newParent.Tag); Parent.Nodes.Remove(this); newParent.Nodes.Add(this); return true; } else { MessageBox.Show("Cannot insert object \"" + Text + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } }
public UndoRedoAction(WzNode item, WzNode parent, UndoRedoType type) { this.item = item; this.parent = parent; this.type = type; }
public static UndoRedoAction ObjectRemoved(WzNode parent, WzNode item) { return(new UndoRedoAction(item, parent, UndoRedoType.ObjectRemoved)); }
private void InsertWzNodeThreadSafe(WzNode node, WzNode parent) { if (MainPanel.InvokeRequired) MainPanel.Invoke(new InsertWzNode(InsertWzNodeCallback), node, parent); else InsertWzNodeCallback(node, parent); }
private void WzImporterThread(object param) { ChangeApplicationState(false); object[] arr = (object[])param; ProgressingWzSerializer deserializer = (ProgressingWzSerializer)arr[0]; string[] files = (string[])arr[1]; WzNode parent = (WzNode)arr[2]; byte[] iv = (byte[])arr[3]; IWzObject parentObj = (IWzObject)parent.Tag; if (parentObj is WzFile) parentObj = ((WzFile)parentObj).WzDirectory; UpdateProgressBar(MainPanel.mainProgressBar, files.Length, true, true); foreach (string file in files) { List<IWzObject> objs; try { if (deserializer is WzXmlDeserializer) objs = ((WzXmlDeserializer)deserializer).ParseXML(file); else objs = new List<IWzObject> { ((WzImgDeserializer)deserializer).WzImageFromIMGFile(file, iv, Path.GetFileName(file)) }; } catch (ThreadAbortException) { return; } catch (Exception e) { Warning.Error("The file \"" + file + "\" is invalid and will be skipped. Error: " + e.Message); UpdateProgressBar(MainPanel.mainProgressBar, 1, false, false); continue; } foreach (IWzObject obj in objs) { if (((obj is WzDirectory || obj is WzImage) && parentObj is WzDirectory) || (obj is IWzImageProperty && parentObj is IPropertyContainer)) { WzNode node = new WzNode(obj); InsertWzNodeThreadSafe(node, parent); } } UpdateProgressBar(MainPanel.mainProgressBar, 1, false, false); } threadDone = true; }
private void SortNodesRecursively(WzNode parent) { parent.TreeView.Sort(); }
private WzFile LoadWzFile(string path, WzMapleVersion encVersion, short version, HaRepackerMainPanel panel) { WzFile newFile; if (!OpenWzFile(path, encVersion, version, out newFile)) return null; WzNode node = new WzNode(newFile); panel.DataTree.Nodes.Add(node); SortNodesRecursively(node); return newFile; }
public static UndoRedoAction ObjectRemoved(WzNode parent, WzNode item) { return new UndoRedoAction(item, parent, UndoRedoType.ObjectRemoved); }