public void Update(Game game) { if (Rectangle.Value.Contains(game.Input.MousePosition) && !Rectangle.Value.Contains(game.Input.PreviousMousePosition)) { int height = 15 + 12 + 4; foreach (string s in Entries) { if (s == SPACING) { height += 8; } else { height += 15 + 4; } } Rectangle.TweenTo(new Rectangle(Rectangle.TargetValue.X, Rectangle.TargetValue.Y, Rectangle.TargetValue.Width, height), TweenEaseType.EaseOutQuad, 0.1f); } else if (!Rectangle.Value.Contains(game.Input.MousePosition) && Rectangle.Value.Contains(game.Input.PreviousMousePosition)) { Rectangle.TweenTo(new Rectangle(Rectangle.TargetValue.X, Rectangle.TargetValue.Y, Rectangle.TargetValue.Width, 15 + 12), TweenEaseType.EaseOutQuad, 0.1f); } int y = Rectangle.Value.Y + 15 + 12; foreach (string s in Entries) { if (s == SPACING) { y += 8; } else { Vector2 measure = game.DefaultFonts.Bold.Measure(15, s); Rectangle rectangle = new Rectangle(Rectangle.Value.X, y, Rectangle.Value.Width, (int)measure.Y); if (SelectedValue != s && Rectangle.Value.Contains(game.Input.MousePosition) && rectangle.Contains(game.Input.MousePosition) && game.Input.MousePressed(MouseButton.Left)) { Selected = Entries.IndexOf(s); if (SelectionChanged != null) { SelectionChanged(this, Selected); } } y += 15 + 4; } } }
private void Recreate() { Categories.Clear(); Categories.Add(new Category(_environment == Map.Environment.Inside ? "General" : "Water", _environment == Map.Environment.Inside ? "editor/tilemenu/general.png" : "editor/tilemenu/water.png")); Categories.Last().Objects.Add(WaterTiles.DeepWaterOrVoid); Categories.Last().Objects.Add(WaterTiles.ShallowWater); Categories.Add(new Category("Ground", "editor/tilemenu/ground.png")); Categories.Last().Objects.Add(GroundTiles.Grass); Categories.Last().Objects.Add(GroundTiles.Dirt); Categories.Last().Objects.Add(GroundTiles.Stone); Categories.Last().Objects.Add(GroundTiles.StoneDarker); Categories.Last().Objects.Add(GroundTiles.Gravel); Categories.Add(new Category("Foliage", "editor/tilemenu/foliage.png")); Categories.Last().Objects.Add(FoliageTiles.Tree); Categories.Last().Objects.Add(FoliageTiles.Birch); Categories.Last().Objects.Add(FoliageTiles.Bush); Categories.Last().Objects.Add(FoliageTiles.TallGrass); Categories.Last().Objects.Add(FoliageTiles.Rock); Categories.Add(new Category("City", "editor/tilemenu/city.png")); Category walls = new Category("Wall", ""); walls.Objects.Add(CityTiles.Wall); walls.Objects.Add(CityTiles.WallOak); walls.Objects.Add(CityTiles.WallRed); walls.Objects.Add(CityTiles.WallEbony); walls.Objects.Add(CityTiles.Bricks); walls.Objects.Add(CityTiles.StoneBricks); walls.Objects.Add(Separator); walls.Objects.Add(CityTiles.WallBeam); Categories.Last().Objects.Add(walls); Category roofs = new Category("Roof", ""); roofs.Objects.Add(CityTiles.RoofBlue); roofs.Objects.Add(CityTiles.RoofOrange); roofs.Objects.Add(CityTiles.RoofRed); roofs.Objects.Add(CityTiles.RoofPurple); roofs.Objects.Add(Separator); roofs.Objects.Add(CityTiles.RoofPurpleTip); roofs.Objects.Add(CityTiles.RoofBeam); Categories.Last().Objects.Add(roofs); Category windows = new Category("Window", ""); windows.Objects.Add(CityTiles.WindowBlue); windows.Objects.Add(CityTiles.WindowOrange); windows.Objects.Add(CityTiles.WindowRed); windows.Objects.Add(CityTiles.WindowPurple); windows.Objects.Add(Separator); windows.Objects.Add(CityTiles.WindowBlinds); windows.Objects.Add(CityTiles.WindowStone); Categories.Last().Objects.Add(windows); Categories.Last().Objects.Add(CityTiles.HouseStairs); Categories.Last().Objects.Add(CityTiles.Door); Categories.Last().Objects.Add(CityTiles.DoorStone); Categories.Last().Objects.Add(Separator); Categories.Last().Objects.Add(CityTiles.Road); Categories.Last().Objects.Add(CityTiles.Sign); Categories.Last().Objects.Add(CityTiles.Waterwheel); Categories.Add(new Category("Inside", "editor/tilemenu/inside.png")); Categories.Last().Objects.Add(InsideTiles.Floor); Categories.Last().Objects.Add(InsideTiles.Wall); Categories.Last().Objects.Add(InsideTiles.Panel); Categories.Last().Objects.Add(Separator); Categories.Last().Objects.Add(InsideTiles.Door); Categories.Last().Objects.Add(InsideTiles.Doormat); Categories.Last().Objects.Add(Separator); Categories.Last().Objects.Add(InsideTiles.Bookshelf); Categories.Last().Objects.Add(InsideTiles.Chair); Categories.Last().Objects.Add(InsideTiles.Table); Categories.Add(new Category("Control", "editor/tilemenu/control.png")); Categories.Last().Objects.Add(ControlTiles.Spawnpoint); Categories.Last().Objects.Add(ControlTiles.MapPortal); Categories.Last().Objects.Add(Separator); Categories.Last().Objects.Add(ControlTiles.TextBox); Categories.Last().Objects.Add(Separator); Categories.Last().Objects.Add(ControlTiles.Barrier); Categories.Last().Objects.Add(ControlTiles.InvertedBarrier); Categories.Add(new Category("NPCs", "editor/tilemenu/npcs.png")); Category animals = new Category("Animals", ""); animals.Objects.Add(NPCs.Pig.TileTemplate); animals.Objects.Add(NPCs.GreenPig.TileTemplate); Categories.Last().Objects.Add(animals); SelectedTile = WaterTiles.DeepWaterOrVoid; TotalArea = new Vector2(0, 0); // icons TotalArea.X += 18 + 10; foreach (Category category in Categories) { Point measure = CalculateCategorySize(category, true); TotalArea.X = Math.Max(18 + 10 + measure.X + 40, TotalArea.X); TotalArea.Y += measure.Y; } TotalArea.X += 16; Rectangle.TweenTo(new Rectangle(Rectangle.TargetValue.X, Rectangle.TargetValue.Y, (int)TotalArea.X, Rectangle.TargetValue.Height), TweenEaseType.Linear, 0); }