/// <summary> /// Was in ItemViewer() moved here to clean up. /// Finds all TextureRenderState and ZbufferEnable used by effects. /// </summary> internal void helperfunc1() { // Group all effectinfo's by their effect type var xxx = from data0 in effectinfo let data = data0.Data as object[] let inf = new { Header = data[0] as object[], Data = data[1] as object[] } group inf by(uint) inf.Header[2]; var xxxlist1 = new Tuple <int, int> [4][]; var xxxlist2 = new object[0]; for (uint i = 0; i < 4; ++i) { var formatter = EffectInfoFormatter.GetFormatter(i); var idx1 = formatter["TextureRenderState"]; var idx2 = formatter["ZbufferEnable"]; var effs = xxx.First(x => x.Key == i); if (idx1 != -1) { xxxlist1[i] = effs.Select(x => Convert.ToInt32(x.Data[idx1])).GroupBy(x => x).Select(x => new Tuple <int, int>(x.Key, x.Count())).ToArray(); } if (idx2 != -1) { xxxlist2 = xxxlist2.Concat(effs.Where(x => !(bool)x.Data[idx2])).ToArray(); } } }
private void dataGridView1_Click(object sender, EventArgs e) { var effname = (((dataGridView1?.CurrentCell?.OwningRow?.DataBoundItem as DataRowView)?.Row as DataRowEx)?["EffectName"] as string)?.Substring(0, 8); if (effname == null) { return; } var data = (Owner as Form1).effects[effname]; var table = EffectInfoFormatter.GetSchema((int)(uint)(data[0] as object[])[2]); table.Rows.Add(data[1] as object[]); dataGridView2.DataSource = table; }
protected override void RecvData() { var effname = (parent.CurrentCell?.OwningRow?.Cells?[1]?.Value as string); if (effname == null || effname.Length < 8) { return; } effname = effname.Substring(0, 8); base.RecvData(); dataGridView.Rows.Clear(); //var effect = Form1.Effects[effname]; var effect = (Owner as ItemViewer).effectinfo.Single(x => x.Name == effname).Data as object[]; var header = effect[0] as object[]; var headerformat = EffectInfoFormatter.HeaderFormatter.Fields; for (int i = 0; i < header.Length; i++) { dataGridView.Rows.Add(headerformat[i].Name, header[i], i); } var type = (uint)header[2]; var data = effect[1] as object[]; var dataformat = EffectInfoFormatter.GetFormat(type); for (int i = 0; i < data.Length; i++) { dataGridView.Rows.Add(dataformat[i].Name, data[i], i); } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { var node = e.Node; var tag = node?.Tag as treeViewTag; if (tag == null) { return; } var type = (int)tag.Operation; var format = tag.Formatter; var data = tag.Data; dataGridView.ReadOnly = true; if (type == 0) { dataGridView.DataSource = format.GetSchema(data as IEnumerable <object[]>); } if (type == 1 && node.Nodes.Count == 0) { foreach (var group in data as IEnumerable <IGrouping <object, object[]> > ) { var child = new TreeNode(group.Key.ToString() + " [" + group.Count() + "]"); child.Tag = new object[] { 2, null, group }; node.Nodes.Add(child); } } if (type == 2) { dataGridView.DataSource = ((node.Parent.Parent.Tag as object[])[1] as Formatter.Struct).GetSchema(data as IEnumerable <object[]>); } if (type == 3 && node.Nodes.Count == 0) { var mapinf = ((CachedInfo)data).Data as object[]; if (mapinf == null) { node.Name = data as string + " [Invalid]"; } else { for (int i = 1; i < 4; ++i) { var formatter = MapFormatter.GetFormatter(i); var child = new TreeNode(formatter.Name + " [" + (mapinf[i] as object[]).Length + "]"); child.Tag = new treeViewTag(0, formatter, mapinf[i], null); node.Nodes.Add(child); } } } if (type == 4 && data != null) { var objinfname = ((CachedInfo)data).Name; var objinf0 = ((CachedInfo)data).Data as object[]; if (objinf0 == null) { return; } var objinf = (objinf0[1] as IEnumerable <object>).Select(x => x as object[]).Select(x => new { data = x[0] as object[], effects = x[1] as object[][] }); if (node.Nodes.Count == 0) { node.Nodes.Add("Name: " + (objinf0[0] as object[])[0] as string); var idx1 = FormatterOmi.GetFormatter("ti_Item")["ItemNum"]; var idx2 = FormatterOmi.GetFormatter("ti_Item")["Kind"]; var idx3 = FormatterOmi.GetFormatter("ti_Item")["ItemName"]; var idx4 = FormatterOmi.GetFormatter("ti_Item")["SourceIndex"]; int sourceindex; if (int.TryParse(objinfname, out sourceindex)) { var usages = from item in omi[0] as object[][] where (uint)item[idx4] == sourceindex || (((byte)item[idx2] == 16 || (byte)item[idx2] == 60) && (uint)item[idx4] == (sourceindex - 4000000)) || (((byte)item[idx2] < 16) && (uint)item[idx4] == (sourceindex - 100000)) || (((byte)item[idx2] == 25) && (uint)item[idx4] == (sourceindex - 500000)) select new { ItemNum = (uint)item[idx1], ItemName = item[idx3] as string }; var usagesnode = new TreeNode("Used by items [" + usages.Count() + "]"); foreach (var usage in usages) { var child = new TreeNode("[" + usage.ItemNum + "] " + usage.ItemName); child.Tag = new treeViewTag(0, FormatterOmi.GetFormatter("ti_Item"), (omi[0] as object[][]).Where(x => (uint)x[idx1] == usage.ItemNum), null); usagesnode.Nodes.Add(child); } node.Nodes.Add(usagesnode); } var effectsnode = new TreeNode("Body Condition Effects"); var idx = format["BodyConditionName"]; foreach (var row in objinf) { var child = new TreeNode(row.data[idx] as string + " [" + row.effects.Length + "]"); child.Tag = new treeViewTag(0, ObjectInfoFormatter.GetFormatter("effects"), row.effects, null); effectsnode.Nodes.Add(child); } node.Nodes.Add(effectsnode); } dataGridView.DataSource = format.GetSchema(objinf.Select(x => x.data)); } if (type == 5 && data != null) { dataGridView.ReadOnly = false; var temp = ((CachedInfo)data).Data as object[]; var idx = EffectInfoFormatter.HeaderFormatter["EffectType"]; var efftype = (uint)(temp[0] as object[])[idx]; var formatter = EffectInfoFormatter.GetFormatter(efftype); dataGridView.DataSource = formatter.GetSchema( new object[][] { temp[1] as object[] }); } }
void SerializeEffectInfo(string name, object value) { using (var dest = File.OpenWrite(@"res-dev\effectinfo\" + name)) EffectInfoFormatter.Write(dest, value as object[]); }
object DeserializeEffectInfo(string name) { using (var source = File.OpenRead(@"res-dev\effectinfo\" + name)) return(EffectInfoFormatter.Read(source)); }