private static string ParseCommandFD(ActionCommand command) { string[] vars = new string[16]; switch (command.Param1) { case 0x0F: vars[0] = command.Param2.ToString(); break; case 0x9E: vars[0] = Lists.Numerize(Lists.SPCEventSounds, command.Param2); break; case 0xB0: case 0xB1: case 0xB2: vars[0] = Bits.GetShort(command.Data, 2).ToString(); break; case 0xB3: case 0xB4: case 0xB5: vars[0] = ((command.Param2 * 2) + 0x7000).ToString("X4"); break; case 0xB6: vars[0] = ((command.Param2 * 2) + 0x7000).ToString("X4"); vars[1] = ((command.Param3 ^ 0xFF) + 1).ToString(); break; default: break; } string text = ActionCommandsFD[command.Param1]; if (text == "") { text = "{{" + BitConverter.ToString(command.Data) + "}}"; } return(string.Format(text, vars)); }
/// <summary> /// Removes the selected node in the TreeView control. /// </summary> public void Remove() { try { this.treeView.BeginUpdate(); int delta, index; TreeNode node; TreeNode parent, child; for (int i = treeView.Nodes.Count - 1; i >= 0; i--) { parent = treeView.Nodes[i]; for (int a = parent.Nodes.Count - 1; a >= 0; a--) { child = parent.Nodes[a]; if (!child.Checked) { continue; } delta = -((ActionCommand)child.Tag).Data.Length; node = child; if (node == null) { return; } index = child.Index; node = node.Parent; // Decrease queue length option byte EventCommand esc = Script.Commands[node.Index]; ActionCommand aqc = esc.Queue.Commands[index]; if (esc.Param1 < 0xF0) { esc.Param1 -= (byte)aqc.Length; } else { esc.Param2 -= (byte)aqc.Length; } // Remove action command child.Remove(); this.Script.RemoveAt(parent.Index, child.Index); this.ScriptDelta += delta; } if (!parent.Checked) { continue; } if (!ActionScript) { delta = -((EventCommand)parent.Tag).Data.Length; } else { delta = -((ActionCommand)parent.Tag).Data.Length; } node = parent; if (node == null) { return; } index = parent.Index; // Remove event command parent.Remove(); if (!ActionScript) { this.Script.RemoveAt(parent.Index); } else { this.Action.RemoveAt(parent.Index); } this.ScriptDelta += delta; } } finally { // Update offsets and descriptions RefreshScript(); this.treeView.EndUpdate(); } }
/// <summary> /// Inserts an action command after the selected node in the TreeView. /// </summary> /// <param name="command">The command to insert into the TreeView.</param> public void Insert(ActionCommand command) { try { if (ActionScript) { foreach (var acc in Action.Commands) { acc.Modified = false; } } else { foreach (var evc in Script.Commands) { evc.Modified = false; if (evc.Queue == null) { continue; } foreach (var aqc in evc.Queue.Commands) { aqc.Modified = false; } } } this.treeView.BeginUpdate(); int index; TreeNode node = treeView.SelectedNode; // embedded action queue if (!ActionScript) { if (node == null) { return; } // Get index to insert at index = treeView.SelectedNode.Index + 1; if (node.Parent == null) { if ((Script.Commands[treeView.SelectedNode.Index]).QueueTrigger) { index = 0; } else { MessageBox.Show( "Cannot insert an action command outside of an action queue.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { node = node.Parent; } // int maxLength; EventCommand esc = (Script.Commands[node.Index]); if (esc.Param1 < 0xF0) { maxLength = (esc.Param1 & 0x80) == 0x80 ? 111 : 127; if ((esc.Length - 2 + command.Length) > maxLength) { MessageBox.Show( "Could not add any more action commands to the queue.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } esc.Param1 += (byte)command.Length; } else { maxLength = (esc.Param2 & 0x80) == 0x80 ? 111 : 127; if ((esc.Length - 3 + command.Length) > maxLength) { MessageBox.Show( "Could not add any more action commands to the queue.", "LAZY SHELL", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } esc.Param2 += (byte)command.Length; } // Insert into treeview SelectedNode = command.Node; node.Nodes.Insert(index, SelectedNode); // Insert into action queue at same index command.Modified = true; this.Script.Insert(node.Index, index, command); this.ScriptDelta += command.Length; // treeView.ExpandAll(); } // Insert action script command else { // Get index to insert at if (node == null) { index = 0; } else { index = treeView.SelectedNode.Index + 1; } // ActionScript Command if (node == null || IsRootNode(node)) { // Insert into treeview SelectedNode = command.Node; treeView.Nodes.Insert(index, SelectedNode); // Insert into script at same index command.Modified = true; this.Action.Insert(index, command); this.ScriptDelta += command.Length; } } } finally { // Update offsets and descriptions RefreshScript(); this.treeView.EndUpdate(); } }
/// <summary> /// Adds a command to the end of the TreeView. /// </summary> /// <param name="command">The command to add.</param> private void Add(ActionCommand command) { // Add command this.treeView.Nodes.Add(command.Node); }
public static string ParseCommand(ActionCommand command) { string[] vars = new string[16]; switch (command.Opcode) { case 0x08: vars[0] = (command.Param1 & 0x08) == 0x08 ? "Mold" : "Sequence"; vars[1] = (command.Param2 & 0x07).ToString(); vars[2] = (command.Param1 & 0x03).ToString(); vars[3] = (command.Param1 & 0x10) == 0x10 ? "looping off" : "looping on"; vars[4] = (command.Param2 & 0x80) == 0x80 ? "mirrored" : "..."; break; case 0x0A: case 0x0B: case 0x0C: case 0x11: case 0x12: case 0x14: case 0x15: vars[0] = Bits.GetString(command.Param1, Bits.BitNames, 8); break; case 0x13: case 0xD4: vars[0] = command.Param1.ToString(); break; case 0x0D: case 0x0E: vars[0] = (command.Param1 & 0x0F).ToString(); break; case 0x10: if ((command.Param1 & 0x40) == 0x40 && (command.Param1 & 0x80) == 0x80) { vars[0] = "Total"; } else if ((command.Param1 & 0x40) == 0x40) { vars[0] = "Walking"; } else if ((command.Param1 & 0x80) == 0x80) { vars[0] = "Sequence"; } vars[1] = ObjectSpeeds[command.Param1 & 0x07]; break; case 0x26: case 0x27: case 0x28: vars[0] = BitConverter.ToString(command.Data, 1); break; case 0x3E: vars[0] = Lists.NPCPackets[command.Param1]; vars[1] = ObjectNames[command.Param2]; vars[2] = Bits.GetShort(command.Data, 3).ToString("X4"); break; case 0x3F: vars[0] = Lists.NPCPackets[command.Param1]; vars[1] = Bits.GetShort(command.Data, 2).ToString("X4"); break; case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: case 0x58: case 0x5A: case 0x5B: case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67: case 0x68: case 0x6A: case 0x6B: case 0x7B: vars[0] = command.Param1.ToString(); break; case 0xF0: vars[0] = (command.Param1 + 1).ToString(); break; case 0x9C: vars[0] = Lists.Numerize(Lists.SPCEventSounds, Math.Min(command.Param1, (byte)0xA2)); break; case 0x7E: case 0x7F: vars[0] = Bits.GetShort(command.Data, 1).ToString(); break; case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: if (command.Opcode != 0x80 || command.Opcode != 0x82) { vars[0] = ((sbyte)command.Param1).ToString(); vars[1] = ((sbyte)command.Param2).ToString(); } else { vars[0] = command.Param1.ToString(); vars[1] = command.Param2.ToString(); } break; case 0x87: vars[0] = ObjectNames[command.Param1]; break; case 0x90: case 0x91: if (command.Opcode != 0x90) { vars[0] = ((sbyte)command.Param1).ToString(); vars[1] = ((sbyte)command.Param2).ToString(); } else { vars[0] = command.Param1.ToString(); vars[1] = command.Param2.ToString(); } vars[2] = command.Param3.ToString(); break; case 0x92: case 0x93: case 0x94: if (command.Opcode != 0x92) { vars[0] = ((sbyte)command.Param1).ToString(); vars[1] = ((sbyte)command.Param2).ToString(); } else { vars[0] = command.Param1.ToString(); vars[1] = command.Param2.ToString(); } vars[2] = (command.Param3 & 0x1F).ToString(); vars[3] = DirectionNames[((command.Param3 & 0xE0) >> 5)]; break; case 0x95: vars[0] = ObjectNames[command.Param1]; break; case 0x9D: vars[0] = Lists.Numerize(Lists.SPCEventSounds, command.Param1); vars[1] = command.Param2.ToString(); break; case 0x9E: vars[0] = command.Param1.ToString(); vars[1] = command.Param2.ToString(); break; case 0xA0: case 0xA1: case 0xA2: vars[0] = (((((command.Opcode * 0x100) + command.Param1) - 0xA000) / 8) + 0x7040).ToString("X4"); vars[1] = (command.Param1 & 0x07).ToString(); break; case 0xA4: case 0xA5: case 0xA6: vars[0] = (((((command.Opcode * 0x100) + command.Param1) - 0xA400) / 8) + 0x7040).ToString("X4"); vars[1] = (command.Param1 & 0x07).ToString(); break; case 0xA8: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); vars[1] = command.Param2.ToString(); break; case 0xA9: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); vars[1] = command.Param2.ToString(); break; case 0xAA: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); break; case 0xAB: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); break; case 0xAC: case 0xAD: case 0xC0: case 0xD0: vars[0] = Bits.GetShort(command.Data, 1).ToString(); break; case 0xF1: vars[0] = (Bits.GetShort(command.Data, 1) + 1).ToString(); break; case 0xB0: case 0xB1: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); vars[1] = Bits.GetShort(command.Data, 2).ToString(); break; case 0xB2: case 0xB3: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); break; case 0xB4: case 0xB5: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); break; case 0xB6: vars[0] = Bits.GetShort(command.Data, 1).ToString(); break; case 0xB7: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); vars[1] = Bits.GetShort(command.Data, 2).ToString(); break; case 0xB8: case 0xB9: case 0xBA: case 0xBB: case 0xC1: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); break; case 0xC2: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); vars[1] = Bits.GetShort(command.Data, 2).ToString(); break; case 0xBC: case 0xBD: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); vars[1] = ((command.Param2 * 2) + 0x7000).ToString("X4"); break; case 0xC4: case 0xC5: case 0xC6: vars[0] = ObjectNames[command.Param1 & 0x3F]; vars[1] = (command.Param1 & 0x40) == 0x40 ? "isometric" : "pixel"; break; case 0xD6: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); break; case 0xD2: case 0xD3: case 0xDB: case 0xDF: vars[0] = (Bits.GetShort(command.Data, 1)).ToString("X4"); break; case 0xD8: case 0xD9: case 0xDA: vars[0] = (((((command.Opcode * 0x100) + command.Param1) - 0xD800) / 8) + 0x7040).ToString("X4"); vars[1] = (command.Param1 & 0x07).ToString(); vars[2] = Bits.GetShort(command.Data, 2).ToString("X4"); break; case 0xDC: case 0xDD: case 0xDE: vars[0] = (((((command.Opcode * 0x100) + command.Param1) - 0xDC00) / 8) + 0x7040).ToString("X4"); vars[1] = (command.Param1 & 0x07).ToString(); vars[2] = Bits.GetShort(command.Data, 2).ToString("X4"); break; case 0xE0: case 0xE1: vars[0] = (command.Param1 + 0x70A0).ToString("X4"); vars[1] = command.Param2.ToString(); vars[2] = Bits.GetShort(command.Data, 3).ToString("X4"); break; case 0xE2: case 0xE3: vars[0] = (Bits.GetShort(command.Data, 1)).ToString(); vars[1] = Bits.GetShort(command.Data, 3).ToString("X4"); break; case 0xE4: case 0xE5: vars[0] = ((command.Param1 * 2) + 0x7000).ToString("X4"); vars[1] = Bits.GetShort(command.Data, 2).ToString(); vars[2] = Bits.GetShort(command.Data, 4).ToString("X4"); break; case 0xE6: case 0xE7: vars[0] = Bits.GetString(Bits.GetShort(command.Data, 1), Bits.BitNames, 16); vars[1] = (Bits.GetShort(command.Data, 3)).ToString("X4"); break; case 0x3D: case 0xE8: case 0xEA: case 0xEB: case 0xEC: case 0xED: case 0xEE: case 0xEF: vars[0] = Bits.GetShort(command.Data, 1).ToString("X4"); break; case 0xE9: vars[0] = Bits.GetShort(command.Data, 1).ToString("X4"); vars[1] = Bits.GetShort(command.Data, 3).ToString("X4"); break; case 0xF2: case 0xF3: vars[0] = ObjectNames[((command.Param2 >> 1) & 0x3F)]; vars[1] = Lists.Numerize(Lists.Areas, (Bits.GetShort(command.Data, 1) & 0x1FF)); vars[2] = (command.Param2 & 0x80) == 0x80 ? "true" : "false"; break; case 0xF8: vars[0] = ObjectNames[((command.Param2 >> 1) & 0x3F)]; vars[1] = Lists.Numerize(Lists.Areas, (Bits.GetShort(command.Data, 1) & 0x1FF)); vars[2] = Bits.GetShort(command.Data, 3).ToString("X4"); break; case 0xFD: return(ParseCommandFD(command)); default: break; } string text = ActionCommands[command.Opcode]; if (text == "") { text = "{{" + BitConverter.ToString(command.Data) + "}}"; } return(string.Format(text, vars)); }
// Collection editing public void Add(ActionCommand asc) { Commands.Add(asc); }