public static void BindOrderButton <T>(World world, ButtonWidget w, string icon) where T : IOrderGenerator, new() { w.OnClick = () => world.ToggleInputMode <T>(); w.IsHighlighted = () => world.OrderGenerator is T; w.Get <ImageWidget>("ICON").GetImageName = () => world.OrderGenerator is T ? icon + "-active" : icon; }
void BindButtonIcon(ButtonWidget button) { var icon = button.Get <ImageWidget>("ICON"); var hasDisabled = ChromeProvider.GetImage(icon.ImageCollection, icon.ImageName + "-disabled") != null; var hasActive = ChromeProvider.GetImage(icon.ImageCollection, icon.ImageName + "-active") != null; icon.GetImageName = () => hasActive && button.IsHighlighted() ? icon.ImageName + "-active" : hasDisabled && button.IsDisabled() ? icon.ImageName + "-disabled" : icon.ImageName; }