public void LoadData(byte[] b, HSDStruct reference) { Data = b; Reference = reference; PointerBox.SelectedItem = AllActions.Find(e => e._struct == Reference); Bitreader r = new Bitreader(Data); var sa = SubactionManager.GetSubaction((byte)r.Read(6)); comboBox1.SelectedItem = sa.Name; for (int i = 0; i < sa.Parameters.Length; i++) { var p = sa.Parameters[i]; if (p.Name.Contains("None")) { continue; } var value = r.Read(p.BitCount); if (p.IsPointer) { continue; } (panel1.Controls[sa.Parameters.Length - 1 - i].Controls[0] as SubactionValueEditor).SetValue(value); } CenterToScreen(); }
/// <summary> /// /// </summary> /// <param name="data"></param> private List <Command> GetCommands(HSDStruct str, HashSet <HSDStruct> references = null) { if (references == null) { references = new HashSet <HSDStruct>(); } if (references.Contains(str)) { return(new List <Command>()); } var data = str.GetData(); references.Add(str); var Commands = new List <Command>(); for (int i = 0; i < data.Length;) { var sa = SubactionManager.GetSubaction((byte)(data[i] >> 2)); var cmd = new Command(); foreach (var r in str.References) { if (r.Key >= i && r.Key < i + sa.ByteSize) { if (cmd.Reference != null) { throw new NotSupportedException("Multiple References not supported"); } else { cmd.Reference = r.Value; cmd.ReferenceCommands = GetCommands(cmd.Reference, references); } } } var sub = new byte[sa.ByteSize]; for (int j = 0; j < sub.Length; j++) { sub[j] = data[i + j]; } cmd.Parameters = sa.GetParameters(sub); cmd.Action = sa; Commands.Add(cmd); i += sa.ByteSize; } return(Commands); }
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { CreateParamEditor(SubactionManager.GetSubaction(comboBox1.SelectedItem as string)); }
/// <summary> /// /// </summary> /// <param name="data"></param> private List <Command> GetCommands(HSDStruct str, SubactionGroup subGroup, Dictionary <HSDStruct, List <Command> > structToComman = null) { if (subGroup != SubactionGroup.Fighter) { return(new List <Command>()); } if (structToComman == null) { structToComman = new Dictionary <HSDStruct, List <Command> >(); } if (structToComman.ContainsKey(str)) { return(structToComman[str]); } var data = str.GetData(); var Commands = new List <Command>(); structToComman.Add(str, Commands); for (int i = 0; i < data.Length;) { var sa = SubactionManager.GetSubaction(data[i], subGroup); var cmd = new Command(); foreach (var r in str.References) { if (r.Key >= i && r.Key < i + sa.ByteSize) { if (cmd.Reference != null) { throw new NotSupportedException("Multiple References not supported"); } else { if (r.Value != str) // prevent self reference { cmd.Reference = r.Value; cmd.ReferenceCommands = GetCommands(cmd.Reference, subGroup, structToComman); } } } } var sub = new byte[sa.ByteSize]; if (i + sub.Length > data.Length) { break; } for (int j = 0; j < sub.Length; j++) { sub[j] = data[i + j]; } cmd.Parameters = sa.GetParameters(sub); cmd.Action = sa; Commands.Add(cmd); i += sa.ByteSize; if (sa.Code == 0) { break; } } return(Commands); }