void objectHovered(NSMBObject obj) { if (obj == hover) { return; } hover = obj; if (obj == null) { toolTip1.Hide(this); } else { int x = Width - 16; int y = obj.Y * 16 - 8 + obj.Height * 8 - vScrollBar1.Value; toolTip1.ToolTipTitle = LanguageManager.Get("ObjectPickerControl", "Object") + obj.ObjNum; string text = ""; if (gfx.Tilesets[tileset].UseNotes && obj.ObjNum < gfx.Tilesets[tileset].ObjNotes.Length) { text = gfx.Tilesets[tileset].ObjNotes[obj.ObjNum]; } toolTip1.Show(text + " ", this, x, y); } }
private void objFindNext_Click(object sender, EventArgs e) { if (EdControl.Level.Objects.Count != 0) { int startInd = -1; if (foundObj != null && EdControl.Level.Objects.Contains(foundObj)) { startInd = EdControl.Level.Objects.IndexOf(foundObj); } int ind = (startInd + 1) % EdControl.Level.Objects.Count; bool found = false; while (ind != startInd && !found) { if (EdControl.Level.Objects[ind].Tileset == nudFindTileset.Value && EdControl.Level.Objects[ind].ObjNum == nudFindObjNum.Value) { foundObj = EdControl.Level.Objects[ind]; found = true; } ind = (ind + 1) % EdControl.Level.Objects.Count; } if (found) { EdControl.SelectObject(foundObj); EdControl.EnsureBlockVisible(foundObj.X, foundObj.Y); } //else //MessageBox.Show(LanguageManager.Get("ToolsForm", "NotFound"), LanguageManager.Get("General", "Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
protected Rectangle getObjectRectangle() { bool found = false; Rectangle r = new Rectangle(0, 0, 0, 0); foreach (LevelItem i in objs) { NSMBObject o = i as NSMBObject; if (o == null) { continue; } if (found) { r = Rectangle.Union(r, o.getRectangle()); } else { r = o.getRectangle(); } found = true; } return(r); }
public void load(NSMBGraphics g, int TilesetNumber) { this.tnum = TilesetNumber; this.tls = g.Tilesets[tnum]; tilePicker1.init(new Bitmap[] { tls.map16.buffer }, 16); previewObject = new NSMBObject(0, tnum, 0, 0, 6, 6, g); }
LevelItem FromString(String[] strs, ref int idx) { switch (strs[idx]) { case "OBJ": return(NSMBObject.FromString(strs, ref idx, EdControl.Level.GFX)); case "SPR": return(NSMBSprite.FromString(strs, ref idx, EdControl.Level)); case "ENT": return(NSMBEntrance.FromString(strs, ref idx, EdControl.Level)); case "VIW": case "ZON": return(NSMBView.FromString(strs, ref idx, EdControl.Level)); // TODO: copy and paste with paths/path points //case "PTH": // break; default: idx++; return(null); } }
private void CreateObject_Click(object sender, EventArgs e) { Rectangle ViewableArea = EdControl.ViewableBlocks; NSMBObject no = new NSMBObject(10, 0, ViewableArea.X + ViewableArea.Width / 2, ViewableArea.Y + ViewableArea.Height / 2, 1, 1, EdControl.GFX); EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(no))); EdControl.mode.SelectObject(no); }
public NSMBObject(NSMBObject o) // clone constructor: returns an identical object { this.ObjNum = o.ObjNum; this.Tileset = o.Tileset; this.GFX = o.GFX; this.X = o.X; this.Y = o.Y; this.Width = o.Width; this.Height = o.Height; CachedObj = new int[Width, Height]; UpdateObjCache(); }
private void LoadObjects() { TilesetObjects = new NSMBObject[][] { null, null, null }; TilesetObjects[0] = new NSMBObject[256]; TilesetObjects[1] = new NSMBObject[256]; TilesetObjects[2] = new NSMBObject[256]; for (int TSIdx = 0; TSIdx < 3; TSIdx++) { for (int ObjIdx = 0; ObjIdx < 256; ObjIdx++) { TilesetObjects[TSIdx][ObjIdx] = new NSMBObject(ObjIdx, TSIdx, 0, 0, 5, 3, GFX); } } }
public static NSMBObject FromString(String[] strs, ref int idx, NSMBGraphics gfx) { NSMBObject o = new NSMBObject( int.Parse(strs[6 + idx]), int.Parse(strs[5 + idx]), int.Parse(strs[1 + idx]), int.Parse(strs[2 + idx]), int.Parse(strs[3 + idx]), int.Parse(strs[4 + idx]), gfx); idx += 7; return(o); }
public void selectObjectNumber(int objectNum) { SelectedObject = -1; selected = null; foreach (NSMBObject o in objects) { if (o.ObjNum == objectNum) { selected = o; SelectedObject = objectNum; } } if (selected != null && !selecting) { vScrollBar1.Value = Math.Max(vScrollBar1.Minimum, Math.Min(vScrollBar1.Maximum - vScrollBar1.LargeChange + 1, selected.Y * 16 - Height / 2)); } Invalidate(); }
public override void MouseUp() { foreach (LevelItem obj in CurSelectedObjs) { if (!SelectedObjects.Contains(obj)) { SelectedObjects.Add(obj); } } CurSelectedObjs.Clear(); if (CreateObj) { SelectObject(null); } CreateObj = false; newObj = null; SelectMode = false; EdControl.UndoManager.merge = false; EdControl.repaint(); tabs.SelectObjects(SelectedObjects); }
public void UpdateInfo() { if (SelectedObjects == null || SelectedObjects.Count == 0) { return; } NSMBObject o = SelectedObjects[0] as NSMBObject; DataUpdateFlag = true; if (o.Tileset != 0) { tileset0picker.selectObjectNumber(-1); } if (o.Tileset != 1) { tileset1picker.selectObjectNumber(-1); } if (o.Tileset != 2) { tileset2picker.selectObjectNumber(-1); } if (o.Tileset == 0) { tileset0picker.selectObjectNumber(o.ObjNum); } if (o.Tileset == 1) { tileset1picker.selectObjectNumber(o.ObjNum); } if (o.Tileset == 2) { tileset2picker.selectObjectNumber(o.ObjNum); } tabControl1.SelectedIndex = o.Tileset; DataUpdateFlag = false; }
private void ObjectPickerControlNew_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int x = e.X; int y = e.Y + vScrollBar1.Value; int oldSel = SelectedObject; foreach (NSMBObject obj in objects) { Rectangle or = new Rectangle(obj.X * 16 + 8, obj.Y * 16 + 8, obj.Width * 16, obj.Height * 16); or.Inflate(8, 8); if (or.Contains(x, y)) { selected = obj; SelectedObject = obj.ObjNum; } } if (oldSel != SelectedObject) { Invalidate(); selecting = true; if (ObjectSelected != null) { ObjectSelected(); } selecting = false; } } else { yDown = e.Y; yScr = vScrollBar1.Value; } }
private void LoadObjects() { int nw = (Width - 40) / 16; if (nw < 5) { nw = 5; } if (tileWidth == nw) { return; } if (!inited) { return; } objects.Clear(); tileWidth = nw; int x = 0; int y = 0; int rowheight = 1; for (int i = 0; i < 256; i++) { if (gfx.Tilesets[tileset].Objects[i] == null) { continue; } int ow = gfx.Tilesets[tileset].Objects[i].getWidth(); int oh = gfx.Tilesets[tileset].Objects[i].getHeight(); if (ow > tileWidth) { ow = tileWidth; } if (oh > 5) { oh = 5; } if (x + ow > tileWidth) { //New line x = 0; y += rowheight + 1; rowheight = 1; } NSMBObject o = new NSMBObject(i, tileset, x, y, ow, oh, gfx); if (i == SelectedObject) { selected = o; } x += ow + 1; if (oh > rowheight) { rowheight = oh; } if (!o.badObject) { objects.Add(o); } } if (x != 0) { y += rowheight + 1; } int scrollheight = y * 16 - Height + 16; if (this.Height > 0) { vScrollBar1.LargeChange = this.Height; } vScrollBar1.Maximum = scrollheight + this.Height; vScrollBar1.Enabled = vScrollBar1.LargeChange < vScrollBar1.Maximum; Invalidate(); }
public override void MouseDown(int x, int y, MouseButtons buttons) { //Right clicking creates a new object if (buttons == MouseButtons.Right) { dx = x / 16; dy = y / 16; lx = x; ly = y; CreateObj = true; if (tabs.SelectedTab == 2) //The sprite tab { NSMBSprite newSprite = new NSMBSprite(Level); newSprite.Type = tabs.sprites.getSelectedType(); if (newSprite.Type == -1) { return; } newSprite.Data = new byte[6]; newSprite.x = x; newSprite.y = y; EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newSprite))); SelectObject(newSprite); return; } newObj = new NSMBObject(tabs.objects.getObjectType(), tabs.objects.getTilesetNum(), dx, dy, 1, 1, Level.GFX); EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newObj))); SelectObject(newObj); return; } lx = x; ly = y; dx = x; dy = y; mouseAct = getActionAtPos(x, y); // Resize with the shift key if (mouseAct.nodeType != CreateNode.None) { NSMBPathPoint pp = new NSMBPathPoint(mouseAct.node); int zIndex = pp.parent.points.IndexOf(mouseAct.node); if (mouseAct.nodeType == CreateNode.After) { pp.x += 16; zIndex++; } else { pp.x -= 16; } EdControl.UndoManager.Do(new AddPathNodeAction(UndoManager.ObjToList(pp), zIndex)); SelectObject(pp); } else { if (Control.ModifierKeys == Keys.Shift && mouseAct.drag && mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone) { mouseAct.vert = ResizeType.ResizeEnd; mouseAct.hor = ResizeType.ResizeEnd; } if (!mouseAct.drag) { // Select an object if (Control.ModifierKeys != Keys.Shift) { SelectedObjects.Clear(); } findSelectedObjects(x, y, x, y, true, true); SelectMode = CurSelectedObjs.Count == 0; if (!SelectMode) { SelectedObjects.Add(CurSelectedObjs[0]); } } else if (mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone) { List <LevelItem> selectedObjectsBack = new List <LevelItem>(); selectedObjectsBack.AddRange(SelectedObjects); // Select an object findSelectedObjects(x, y, x, y, true, true); if (SelectedObjects.Count == 0) { SelectMode = true; } else { if (selectedObjectsBack.Contains(SelectedObjects[0])) { SelectedObjects = selectedObjectsBack; } } UpdateSelectionBounds(); EdControl.repaint(); } if (!SelectMode) { CloneMode = Control.ModifierKeys == Keys.Control; lx -= selectionSnap / 2; ly -= selectionSnap / 2; } } EdControl.repaint(); tabs.SelectObjects(SelectedObjects); UpdatePanel(); }