public override void Draw(SpriteBatch spriteBatch) { // we don't want to draw if conditions aren't // right to do so if (!drawPreview || World.IsDragging) { return; } // draw a selection preview if (SelectedLayer == CollisionLayer) { spriteBatch.Draw(colorTexture, brushRect, collisionTileColor); return; } WorldTileset tileset = World.GetTileset(TilesetSelectionIndex); if (tileset == null) { return; } spriteBatch.Draw(tileset.Texture, brushRect, TilesetSelection, tilesetTint); spriteBatch.Draw(colorTexture, brushRect, previewOverlayColor); }
void refreshTileset(object sender, EventArgs e) { try { int index = tilesetsList.SelectedIndex; WorldTileset refresh = new WorldTileset(world.Tilesets[index].Filename, world.CanvasGraphicsDevice); world.Tilesets[index] = refresh; world.InvalidateCanvas(); world.UpdateTilesetIndexes(); selector.Tileset = refresh.Image; selector.Selection = Rectangle.Empty; selector.Invalidate(); } catch (Exception exception) { MessageBox.Show("An error occured while refreshing the tileset\n" + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Adds a tileset to the world /// </summary> /// <param name="tileset"> New tileset </param> public void AddTileset(WorldTileset tileset) { tilesets.Add(tileset); UpdateTilesetIndexes(); }