private void btnCreate_Click(object sender, EventArgs e) { var mapObj = new MapObject { Name = "New Object", SpriteInfo = new SpriteInfo() { Name = (string)lbxSprites.SelectedItem } }; Editor.Project.MapObjects.Add(mapObj); LoadObjects(); lbxObjects.SelectedIndex = lbxObjects.Items.Count - 1; }
public LotuzForm() { var constructorLog = new TimeLog(); InitializeComponent(); splitContainer1.Enabled = false; editorToolbar.Enabled = false; itmOptions.Enabled = false; objectSelectionControl1.Editor = this; enemySelectionControl1.Editor = this; textureSelectionControl.Editor = this; npcSelectionControl1.Editor = this; mapControl.Editor = this; mapControl.Content = new ContentManager(mapControl.Services, "Content"); UpdateTileTextureSelectionControlSize(); pnlMap.MouseWheel += pnlMap_MouseWheel; LoadConfig(); CheckContentFolder(); CurrentMapIndex = -1; CurrentObject = new MapObject(); Objects = new List<GameObject>(); deletedMapLayers = new List<Guid>(); CurrentLayerType = LayerType.MapLayer; cbbLayerType.SelectedIndex = 0; cbbZoom.SelectedIndex = 3; AddButtonsToList(); mapControl.ControlLoaded += MapControl_ControlLoaded; constructorLog.Log("editor constructor"); }
private void lbxObjects_SelectedIndexChanged(object sender, EventArgs e) { lbxSprites.Enabled = lbxObjects.SelectedIndex != -1; pnlObjectDetails.Enabled = lbxObjects.SelectedIndex != -1; if (lbxObjects.SelectedIndex != -1) { currentObject = MapObjects[lbxObjects.SelectedIndex]; currentObject.Position = new Vector2(0, 0); txtCollisionRadius.Text = currentObject.CollisionRadius.ToString(); txtObjectName.Text = currentObject.Name; txtOriginX.Text = currentObject.Origin.X.ToString(); txtOriginY.Text = currentObject.Origin.Y.ToString(); objectPreviewControl1.Origin = currentObject.Origin; if (currentObject?.Animation?.Texture != null) { lblObjectInfo.Text = string.Format("Largura: {0} Altura: {1}", currentObject.Animation.Texture.Width, currentObject.Animation.Texture.Height); } if (!string.IsNullOrEmpty(currentObject?.SpriteInfo?.Name)) { lbxSprites.SelectedItem = currentObject.SpriteInfo.Name; } UpdateTilesetPreviewSize(); } }
private void objectSelectionControl1_MouseHover(object sender, EventArgs e) { if (Project.MapObjects.Count > objectSelectionControl1.MouseIndex) { var objectId = Project.MapObjects[objectSelectionControl1.MouseIndex].Id; var obj = new MapObject(); obj = Project.MapObjects.FirstOrDefault(o => o.Id == objectId); toolTip1.ToolTipTitle = "Map Object"; toolTip1.SetToolTip(objectSelectionControl1, obj.Name); } }
private void objectSelectionControl1_Click(object sender, EventArgs e) { if (Project.MapObjects.Count > objectSelectionControl1.MouseIndex) { cbbLayerType.SelectedIndex = (int)LayerType.ObjectLayer; textureSelectionControl.SelectedTile = -1; enemySelectionControl1.SelectedIndex = -1; objectSelectionControl1.SelectedIndex = objectSelectionControl1.MouseIndex; CurrentObjectId = Project.MapObjects[objectSelectionControl1.SelectedIndex].Id; CurrentObject = new MapObject(); CurrentObject = Project.MapObjects.Find(delegate(MapObject o) { return o.Id == CurrentObjectId; }); ; if (CurrentObject != null && CurrentObject.Animation != null) { mapControl.SelectedObjectPreview = new SpriteAnimation(CurrentObject.Animation.Texture, CurrentObject.Origin, 100, 1); } } }