public void UpdateNPC(LevelNPCNode npcNode, string code, string image, string desc) { var npc = npcNode.NPC; // Nothing has changed here var npcDesc = npc.Headers.GetValueOrDefault("DESC", string.Empty); if (npc.Code == code && npc.Image == image && npcDesc == desc) { return; } // Copy changes over var levelNode = (LevelNode)npcNode.Parent; npc.Code = code; npc.Image = image; npc.Headers["DESC"] = desc; // If we have a new description, update the tree node to reflect it // NOTE: if you're doing mass-changes to many npcs, you should be using begin/endupdate on the treeview // otherwise it will be rendering after every change. if (npcDesc != desc) { npcNode.UpdateDescription(); } npcChangeList.Add(npcNode); levelChangeList.Add(levelNode); }
public bool UpdateNPC(LevelNPCNode npcNode, string code, string image, string desc, bool?markComplete) { var npc = npcNode.NPC; bool changed = false; if (code != null && npc.Code != code) { npc.Code = code; changed = true; } if (image != null && npc.Image != image) { npc.Image = image; changed = true; } if (desc != null) { if (npc.Headers.GetValueOrDefault("DESC", string.Empty) != desc) { npc.Headers["DESC"] = desc; changed = true; } } if (markComplete != null) { bool npcMarkComplete = (npc.Headers.GetValueOrDefault("MARKED", string.Empty) == "true"); if (markComplete != npcMarkComplete) { if (markComplete == true) { npcNode.NPC.Headers["MARKED"] = "true"; } else { npcNode.NPC.Headers.Remove("MARKED"); } changed = true; } } if (changed) { npcChangeList.Add(npcNode); levelChangeList.Add(npc.Level); } return(changed); }
private void ShowContextMenu(LevelNPCNode node, MouseEventArgs e) { var contextMenuStrip = new ContextMenuStrip(); /////////// { var marked = node.NPC.Headers.ContainsKey("MARKED"); ToolStripMenuItem markLabel = new ToolStripMenuItem(); markLabel.Text = (marked ? "Unmark Complete" : "Mark Complete"); markLabel.Click += new EventHandler((s, e) => { node.NPC.ToggleHeader("MARKED"); RedrawLevelNode((LevelNode)node.Parent); }); contextMenuStrip.Items.Add(markLabel); } { ToolStripMenuItem replaceLabel = new ToolStripMenuItem(); replaceLabel.Text = "Replace similar scripts"; replaceLabel.Click += new EventHandler((s, e) => { using (var diag = new ReplaceScriptsForm(state, node)) { var result = diag.ShowDialog(); if (result == DialogResult.OK) { // clear the current node to prevent overwriting changes activeNode = null; SetActiveNode(node); treeView1.BeginUpdate(); foreach (var item in state.npcChangeList) { item.UpdateDescription(); } treeView1.EndUpdate(); RedrawNodes(); } } }); contextMenuStrip.Items.Add(replaceLabel); } contextMenuStrip.Show(treeView1, e.Location); }
public ReplaceScriptsForm(GlobalState state, LevelNPCNode npcNode) { this.state = state; InitializeComponent(); var npc = npcNode.NPC; originalCode = npc.Code; origDescTextBox.Text = newDescTextBox.Text = npc.Headers.GetValueOrDefault("DESC", string.Empty); origImageTextBox.Text = newImageTextBox.Text = npc.Image; origScriptTextBox.Text = newScriptTextBox.Text = originalCode.Replace("\n", "\r\n"); GetIdenticalScripts(); }
public ReplaceScriptsForm(GlobalState state, LevelNPCNode npcNode) { this.state = state; this.matchImages = state.matchImageNames; InitializeComponent(); var npc = npcNode.NPC; originalCode = npc.Code; markScriptsCheckBox.Checked = (npc.Headers.GetValueOrDefault("MARKED", string.Empty) == "true"); origDescTextBox.Text = newDescTextBox.Text = npc.Headers.GetValueOrDefault("DESC", string.Empty); origImageTextBox.Text = newImageTextBox.Text = npc.Image; origScriptTextBox.Text = newScriptTextBox.Text = originalCode.Replace("\n", "\r\n"); GetIdenticalScripts(); }
private void SetActiveNode(LevelNPCNode node) { // Save current node changes if (activeNode != null) { UpdateActiveNode(); } // Clear fields npcDescTextBox.Clear(); npcImageTextBox.Clear(); npcScriptTextBox.Clear(); // Set new node activeNode = node; if (node != null) { npcDescTextBox.Text = node.NPC.Headers.GetValueOrDefault("DESC", string.Empty); npcImageTextBox.Text = node.NPC.Image; npcScriptTextBox.Text = node.NPC.Code.Replace("\n", "\r\n"); } }