private void RenderEntry(EntityEntry entry) { int xoffset = BitConv.FromInt32(entry.Unknown2, 0); int yoffset = BitConv.FromInt32(entry.Unknown2, 4); int zoffset = BitConv.FromInt32(entry.Unknown2, 8); GL.PushMatrix(); GL.Translate(xoffset, yoffset, zoffset); GL.Scale(4, 4, 4); foreach (Entity entity in entry.Entities) { if (entity.Name != null) { RenderEntity(entity); } } GL.PopMatrix(); }
protected override Control CreateEditor() { int linkedsceneryentrycount = BitConv.FromInt32(entityentry.Unknown1, 0); SceneryEntry[] linkedsceneryentries = new SceneryEntry [linkedsceneryentrycount]; for (int i = 0; i < linkedsceneryentrycount; i++) { linkedsceneryentries[i] = FindEID <SceneryEntry>(BitConv.FromInt32(entityentry.Unknown1, 4 + i * 48)); } int linkedentityentrycount = BitConv.FromInt32(entityentry.Unknown1, 400); EntityEntry[] linkedentityentries = new EntityEntry [linkedentityentrycount]; for (int i = 0; i < linkedentityentrycount; i++) { linkedentityentries[i] = FindEID <EntityEntry>(BitConv.FromInt32(entityentry.Unknown1, 404 + i * 4)); } return(new UndockableControl(new EntityEntryViewer(entityentry, linkedsceneryentries, linkedentityentries))); }
private void Menu_Duplicate() { if (!entity.ID.HasValue) { throw new GUIException("Only entities with ID's can be duplicated."); } int maxid = 1; List <EntityPropertyRow <int> > drawlists = new List <EntityPropertyRow <int> >(); foreach (Chunk chunk in entityentrycontroller.EntryChunkController.NSFController.NSF.Chunks) { if (chunk is EntryChunk) { foreach (Entry entry in ((EntryChunk)chunk).Entries) { if (entry is EntityEntry) { foreach (Entity otherentity in ((EntityEntry)entry).Entities) { if (otherentity.ID.HasValue) { if (otherentity.ID.Value > maxid) { maxid = otherentity.ID.Value; } if (otherentity.AlternateID.HasValue && otherentity.AlternateID.Value > maxid) { maxid = otherentity.AlternateID.Value; } } if (otherentity.DrawListA != null) { drawlists.AddRange(otherentity.DrawListA.Rows); } if (otherentity.DrawListB != null) { drawlists.AddRange(otherentity.DrawListB.Rows); } } } } } } maxid++; int newindex = entityentrycontroller.EntityEntry.Entities.Count; newindex -= BitConv.FromInt32(entityentrycontroller.EntityEntry.Unknown1, 0x188); int entitycount = BitConv.FromInt32(entityentrycontroller.EntityEntry.Unknown1, 0x18C); BitConv.ToInt32(entityentrycontroller.EntityEntry.Unknown1, 0x18C, entitycount + 1); Entity newentity = Entity.Load(entity.Save()); newentity.ID = maxid; newentity.AlternateID = null; entityentrycontroller.EntityEntry.Entities.Add(newentity); entityentrycontroller.AddNode(new EntityController(entityentrycontroller, newentity)); foreach (EntityPropertyRow <int> drawlist in drawlists) { foreach (int value in drawlist.Values) { if ((value & 0xFFFF00) >> 8 == entity.ID.Value) { unchecked { drawlist.Values.Add((value & 0xFF) | (maxid << 8) | (newindex << 24)); } break; } } if (drawlist.Values.Contains(entity.ID.Value)) { drawlist.Values.Add(maxid); } } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Brush borderbrush = Brushes.Black; Brush brush = Brushes.Navy; Brush backbrush = Brushes.White; Brush hibackbrush = Brushes.LightGreen; Brush bithibackbrush = Brushes.LightCoral; Brush selbrush = Brushes.White; Brush selbackbrush = Brushes.Navy; Brush deadselbackbrush = Brushes.DarkGray; Brush inputselbackbrush = Brushes.Red; Brush eidbackbrush = Brushes.Chocolate; Brush voidbrush = Brushes.DarkMagenta; Font font = new Font(FontFamily.GenericMonospace, 8); Font selfont = new Font(FontFamily.GenericMonospace, 10); StringFormat format = new StringFormat(); StringFormat selformat = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; selformat.Alignment = StringAlignment.Center; selformat.LineAlignment = StringAlignment.Center; int hstep = (Width - 1) / 16; int vstep = (Height - 1) / 16; int width = hstep * 16; int height = vstep * 16; int xsel = position % 16; int ysel = position / 16; e.Graphics.FillRectangle(borderbrush, 0, 0, width + 1, height + 1); for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { int i = x + (offset + y) * 16; Font curfont; Brush curbrush; Brush curbackbrush; StringFormat curformat; Rectangle rect = new Rectangle(); rect.X = hstep * x + 1; rect.Y = vstep * y + 1; rect.Width = hstep - 1; rect.Height = vstep - 1; string text; if (eidview && x % 4 == 0 && i + 3 < data.Length && (data[i] & 1) != 0 && (data[i + 3] & 128) == 0) { curfont = font; curbrush = selbrush; curbackbrush = eidbackbrush; curformat = format; rect.Width = hstep * 4 - 1; int eid = BitConv.FromInt32(data, i); e.Graphics.FillRectangle(curbackbrush, rect); e.Graphics.DrawString(Entry.EIDToString(eid), curfont, curbrush, rect, curformat); x += 3; continue; } if (x == xsel && y + offset == ysel && x + y * 16 < data.Length) { curfont = selfont; curbrush = selbrush; curformat = selformat; if (input == null) { curbackbrush = Focused ? selbackbrush : deadselbackbrush; text = data[x + (offset + y) * 16].ToString("X2"); } else { curbackbrush = Focused ? inputselbackbrush : deadselbackbrush; text = ((int)input).ToString("X"); } } else if (x + (offset + y) * 16 < data.Length) { curfont = font; curbrush = brush; if (viewbit != 8) { curbackbrush = ((data[x + (offset + y) * 16] & 1 << viewbit) != 0) ? bithibackbrush : backbrush; } else { curbackbrush = (data[x + (offset + y) * 16] != 0) ? hibackbrush : backbrush; } curformat = format; text = data[x + (offset + y) * 16].ToString("X2"); } else { curfont = null; curbrush = null; curbackbrush = voidbrush; curformat = null; text = ""; } e.Graphics.FillRectangle(curbackbrush, rect); if (x + (offset + y) * 16 < data.Length) { e.Graphics.DrawString(text, curfont, curbrush, rect, curformat); } } } /*for (int i = 0;i < 17;i += eidview ? 4 : 1) * { * e.Graphics.DrawLine(borderpen,hstep * i,0,hstep * i,height); * } * for (int i = 0;i < 17;i++) * { * e.Graphics.DrawLine(borderpen,0,vstep * i,width,vstep * i); * }*/ }