public override bool HandleMouseInput(MouseInput mi) { if (mi.Event == MouseInputEvent.Move) { var icon = icons.Where(i => i.Key.Contains(mi.Location)) .Select(i => i.Value).FirstOrDefault(); TooltipIcon = icon; return(false); } if (mi.Event != MouseInputEvent.Down) { return(false); } var clicked = icons.Where(i => i.Key.Contains(mi.Location)) .Select(i => i.Value).FirstOrDefault(); if (clicked != null) { ClickIcon(clicked); } return(true); }
public void RefreshIcons() { icons = new Dictionary <Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled); var oldIconCount = IconCount; IconCount = 0; var rb = RenderBounds; foreach (var p in powers) { var rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); icon.Play(p.Info.Icon); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image }; icons.Add(rect, power); IconCount++; } eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty; if (oldIconCount != IconCount) { OnIconCountChanged(oldIconCount, IconCount); } }
public void RefreshIcons() { icons = new Dictionary <Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled); var i = 0; var rb = RenderBounds; foreach (var p in powers) { var rect = new Rectangle(rb.X + 1, rb.Y + i * (48 + Spacing) + 1, 64, 48); icon.Play(p.Info.Icon); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image }; icons.Add(rect, power); i++; } eventBounds = (icons.Count == 0) ? Rectangle.Empty : icons.Keys.Aggregate(Rectangle.Union); }
protected void ClickIcon(SupportPowerIcon clicked) { if (!clicked.Power.Active) { Game.Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound); } else { clicked.Power.Target(); } }
public void RefreshIcons() { icons = new Dictionary <Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled) .OrderBy(p => p.Info.SupportPowerPaletteOrder); var oldIconCount = IconCount; IconCount = 0; var rb = RenderBounds; foreach (var p in powers) { Rectangle rect; if (Horizontal) { rect = new Rectangle(rb.X + IconCount * (IconSize.X + IconMargin), rb.Y, IconSize.X, IconSize.Y); } else { rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); } var level = p.GetLevel(); if (level == 0) { continue; } icon = new Animation(worldRenderer.World, p.Info.IconImage); icon.Play(p.Info.Icons.First(i => i.Key == level).Value); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image, Palette = worldRenderer.Palette(p.Info.IconPalette), IconClockPalette = worldRenderer.Palette(ClockPalette), Hotkey = IconCount < HotkeyCount ? hotkeys[IconCount] : null, }; icons.Add(rect, power); IconCount++; } eventBounds = icons.Keys.Union(); if (oldIconCount != IconCount) { OnIconCountChanged(oldIconCount, IconCount); } }
protected void ClickIcon(SupportPowerIcon clicked) { if (!clicked.Power.Active) { Game.Sound.PlayToPlayer(SoundType.UI, spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound); Game.Sound.PlayNotification(spm.Self.World.Map.Rules, spm.Self.Owner, "Speech", clicked.Power.Info.InsufficientPowerSpeechNotification, spm.Self.Owner.Faction.InternalName); } else { clicked.Power.Target(); } }
public void RefreshIcons() { icons = new Dictionary <Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled); var oldIconCount = IconCount; IconCount = 0; var rb = RenderBounds; foreach (var p in powers) { Rectangle rect; if (Horizontal) { rect = new Rectangle(rb.X + IconCount * (IconSize.X + IconMargin), rb.Y, IconSize.X, IconSize.Y); } else { rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); } icon.Play(p.Info.Icon); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image, Palette = worldRenderer.Palette(p.Info.IconPalette), IconClockPalette = worldRenderer.Palette(ClockPalette), Hotkey = IconCount < HotkeyCount ? hotkeys[IconCount] : null, }; icons.Add(rect, power); IconCount++; } eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty; if (oldIconCount != IconCount) { OnIconCountChanged(oldIconCount, IconCount); } }
public void RefreshIcons() { icons = new Dictionary<Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled); var i = 0; var rb = RenderBounds; foreach (var p in powers) { var rect = new Rectangle(rb.X + 1, rb.Y + i * (48 + Spacing) + 1, 64, 48); icon.Play(p.Info.Icon); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image }; icons.Add(rect, power); i++; } eventBounds = (icons.Count == 0) ? Rectangle.Empty : icons.Keys.Aggregate(Rectangle.Union); }
public void RefreshIcons() { icons = new Dictionary<Rectangle, SupportPowerIcon>(); var powers = spm.Powers.Values.Where(p => !p.Disabled); var oldIconCount = IconCount; IconCount = 0; var rb = RenderBounds; var ks = Game.Settings.Keys; foreach (var p in powers) { var rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); icon.Play(p.Info.Icon); var power = new SupportPowerIcon() { Power = p, Pos = new float2(rect.Location), Sprite = icon.Image, Palette = worldRenderer.Palette(p.Info.IconPalette), IconClockPalette = worldRenderer.Palette(ClockPalette), Hotkey = ks.GetSupportPowerHotkey(IconCount) }; icons.Add(rect, power); IconCount++; } eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty; if (oldIconCount != IconCount) OnIconCountChanged(oldIconCount, IconCount); }
protected void ClickIcon(SupportPowerIcon clicked) { if (!clicked.Power.Active) { Game.Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound); Game.Sound.PlayNotification(spm.Self.World.Map.Rules, spm.Self.Owner, "Speech", clicked.Power.Info.InsufficientPowerSpeechNotification, spm.Self.Owner.Faction.InternalName); } else clicked.Power.Target(); }
protected void ClickIcon(SupportPowerIcon clicked) { if (!clicked.Power.Active) Game.Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound); else clicked.Power.Target(); }