private List <GameComponent> BodySelector_LeftReleased() { if (MultiContextMenu != null) { MultiContextMenu.Close(); MultiContextMenu = null; } if (CurrentToolMode != "SelectUnits") { return(null); } SelectedObjects.RemoveAll(b => !ContextCommands.Any(c => c.CanBeAppliedTo(b, World))); var bodiesClicked = SelectedObjects; if (bodiesClicked.Count > 0) { var availableCommands = ContextCommands.Where(c => bodiesClicked.Any(b => c.CanBeAppliedTo(b, World))); if (availableCommands.Count() > 0) { // Show context menu. MultiContextMenu = Gui.ConstructWidget(new HorizontalContextMenu { Commands = availableCommands.ToList(), MultiBody = bodiesClicked, World = World, ClickAction = () => { BodySelector_LeftReleased(); } }); MultiContextMenu.Rect = new Rectangle(MinimapFrame.Rect.Right + 2, MinimapFrame.Rect.Bottom - MultiContextMenu.Rect.Height, MultiContextMenu.Rect.Width, MultiContextMenu.Rect.Height); MultiContextMenu.Layout(); Gui.ShowDialog(MultiContextMenu); Gui.RootItem.SendToBefore(MultiContextMenu, BottomBackground); } } else if (MultiContextMenu != null) { MultiContextMenu.Close(); MultiContextMenu = null; } return(null); }
public void ChangeTool(String Mode, Object Arguments = null) { if (MultiContextMenu != null) { MultiContextMenu.Close(); MultiContextMenu = null; } if (Mode != "SelectUnits") { SelectedObjects = new List <GameComponent>(); } CurrentTool.OnEnd(); CurrentToolMode = Mode; CurrentTool.OnBegin(Arguments); }