public override void Draw() { var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; if (CurrentQueue == null) { return; } var buildableItems = CurrentQueue.BuildableItems(); var pios = currentQueue.Actor.Owner.PlayerActor.TraitsImplementing <IProductionIconOverlay>(); // Icons foreach (var icon in icons.Values) { WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, icon.Palette); // Draw the ProductionIconOverlay's sprite var pio = pios.FirstOrDefault(p => p.IsOverlayActive(icon.Actor)); if (pio != null) { WidgetUtils.DrawSHPCentered(pio.Sprite, icon.Pos + iconOffset + pio.Offset(IconSize), worldRenderer.Palette(pio.Palette), 1f); } if (!buildableItems.Any(a => a.Name == icon.Name)) { WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette); } } // TODO: Selection overlay }
void DrawSpeed(DungeonsAndDragonsStats ddtrait) { var speed = new Animation(actorActions.BamUi.World, "basic_ui"); if (ddtrait.Speed > 0) { var methode = ddtrait.ModifiedSpeed > ddtrait.Speed ? true : false; for (int i = 0; i < (ddtrait.ModifiedSpeed > ddtrait.Speed ? ddtrait.ModifiedSpeed : ddtrait.Speed); i++) { if (i + 1 > ddtrait.Speed && methode) { speed.PlayFetchIndex("speed_extra", () => 0); } else if (i + 1 > ddtrait.ModifiedSpeed && !methode) { speed.PlayFetchIndex("speed_disabled", () => 0); } else { speed.PlayFetchIndex("speed", () => 0); } WidgetUtils.DrawSHPCentered(speed.Image, new float2(RenderBounds.X + 30 + i * 10, RenderBounds.Y + 2 + 30), actorActions.BamUi.Palette); } actorActions.BamUi.Font.DrawTextWithShadow(ddtrait.ModifiedSpeed + "", new float2(RenderBounds.X + 2, RenderBounds.Y + 32), Color.Azure, Color.DarkSlateGray, 1); } else { speed.PlayFetchIndex("speed_none", () => 0); WidgetUtils.DrawSHPCentered(speed.Image, new float2(RenderBounds.X + 2, RenderBounds.Y + 32), actorActions.BamUi.Palette); } }
public override void Draw() { //120.0-1 76x24 var animation = new Animation(ActorActions.BamUi.World, "basic_ui"); animation.PlayFetchIndex(pressed ? "resbutton_pressed" : "resbutton", () => 0); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X, RenderBounds.Y), ActorActions.BamUi.Palette); animation.PlayFetchIndex("resbutton_pressed", () => 0); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X - 76, RenderBounds.Y), ActorActions.BamUi.Palette); var text = "Research"; ActorActions.BamUi.Font.DrawTextWithShadow(text, new float2(RenderBounds.X + RenderBounds.Width / 2 - ActorActions.BamUi.Font.Measure(text).X / 2, RenderBounds.Y + RenderBounds.Height / 2 - ActorActions.BamUi.Font.Measure(text).Y / 2), Color.White, Color.DarkSlateGray, 1); var text2 = ActorActions.BamUi.World.LocalPlayer.PlayerActor.Info.HasTraitInfo <DungeonsAndDragonsExperienceInfo>() ? ActorActions.BamUi.World.LocalPlayer.PlayerActor.Trait <DungeonsAndDragonsExperience>().Experience.ToString() : "0"; ActorActions.BamUi.Font.DrawTextWithShadow(text2, new float2(RenderBounds.X - 76 + RenderBounds.Width / 2 - ActorActions.BamUi.Font.Measure(text2).X / 2, RenderBounds.Y + RenderBounds.Height / 2 - ActorActions.BamUi.Font.Measure(text2).Y / 2), Color.White, Color.DarkSlateGray, 1); if (Researching) { var progress = Math.Min(6 * currentResearchTime / MaxResearchTime, 5); animation.PlayFetchIndex("ui_research_bar", () => progress); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X - 76 + 20, RenderBounds.Y + 316), ActorActions.BamUi.Palette); //Game.AddChatLine(Color.White, currentResearchTime + "", "" + progress); } }
void DrawArmor(DungeonsAndDragonsStats ddtrait) { var armor = new Animation(actorActions.BamUi.World, "basic_ui"); if (ddtrait.Armor > 0) { var methode = ddtrait.ModifiedArmor > ddtrait.Armor ? true : false; for (int i = 0; i < (ddtrait.ModifiedArmor > ddtrait.Armor ? ddtrait.ModifiedArmor : ddtrait.Armor); i++) { if (i + 1 > ddtrait.Armor && methode) { armor.PlayFetchIndex("armor_extra", () => 0); } else if (i + 1 > ddtrait.ModifiedArmor && !methode) { armor.PlayFetchIndex("armor_disabled", () => 0); } else { armor.PlayFetchIndex("armor", () => 0); } WidgetUtils.DrawSHPCentered(armor.Image, new float2(RenderBounds.X + 30 + i * 10, RenderBounds.Y + 2 + 15), actorActions.BamUi.Palette); } actorActions.BamUi.Font.DrawTextWithShadow(ddtrait.ModifiedArmor + "", new float2(RenderBounds.X + 2, RenderBounds.Y + 16), Color.Azure, Color.DarkSlateGray, 1); } else { armor.PlayFetchIndex("armor_none", () => 0); WidgetUtils.DrawSHPCentered(armor.Image, new float2(RenderBounds.X + 2, RenderBounds.Y + 16), actorActions.BamUi.Palette); } }
void DrawDamage(DungeonsAndDragonsStats ddtrait) { var damage = new Animation(actorActions.BamUi.World, "basic_ui"); if (ddtrait.Damage > 0) { var methode = ddtrait.ModifiedDamage > ddtrait.Damage ? true : false; for (int i = 0; i < (ddtrait.ModifiedDamage > ddtrait.Damage ? ddtrait.ModifiedDamage : ddtrait.Damage); i++) { if (i + 1 > ddtrait.Damage && methode) { damage.PlayFetchIndex("damage_extra", () => 0); } else if (i + 1 > ddtrait.ModifiedDamage && !methode) { damage.PlayFetchIndex("damage_disabled", () => 0); } else { damage.PlayFetchIndex("damage", () => 0); } WidgetUtils.DrawSHPCentered(damage.Image, new float2(RenderBounds.X + 30 + i * 10, RenderBounds.Y + 2), actorActions.BamUi.Palette); } actorActions.BamUi.Font.DrawTextWithShadow(ddtrait.ModifiedDamage + "", new float2(RenderBounds.X + 2, RenderBounds.Y), Color.Azure, Color.DarkSlateGray, 1); } else { damage.PlayFetchIndex("damage_none", () => 0); WidgetUtils.DrawSHPCentered(damage.Image, new float2(RenderBounds.X + 2, RenderBounds.Y), actorActions.BamUi.Palette); } }
public override void Draw() { base.Draw(); if (Progress != null) { var progress = Progress(); if (progress != -1) { progress = progress * (Size - 10) / 100; var o = Size - 10 - progress; WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 2, RenderBounds.Y + 4, 7, Size - 6), Color.Black); WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 3, RenderBounds.Y + 5, 5, Size - 8), sidebar.IngameUi.Palette.Palette.GetColor(10)); WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 4, RenderBounds.Y + 6, 3, Size - 10), sidebar.IngameUi.Palette.Palette.GetColor(8)); WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X + 4, RenderBounds.Y + 6 + o, 3, progress), sidebar.IngameUi.Palette.Palette.GetColor(12)); var amount = Amount(); if (amount == -1) { sidebar.Font.PlayFetchIndex("production", () => 10); WidgetUtils.DrawSHPCentered(sidebar.Font.Image, new int2(RenderBounds.X + 14 + 4, RenderBounds.Y + 40), sidebar.IngameUi.Palette); } else if (amount > 1) { var numberString = amount.ToString(); for (var i = 0; i < numberString.Length; i++) { sidebar.Font.PlayFetchIndex("production", () => numberString[i] - 0x30); WidgetUtils.DrawSHPCentered(sidebar.Font.Image, new int2(RenderBounds.X + 14 + i * 8, RenderBounds.Y + 40), sidebar.IngameUi.Palette); } } } } }
protected override void DrawContents() { if (IsFocused()) { WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(25, 255, 255, 255)); } if (image != null) { WidgetUtils.DrawSHPCentered(image, center + new int2(0, Active ? 1 : 0), sidebar.IngameUi.Palette); } else { actorPreviewWidget.Bounds = RenderBounds; Game.Renderer.EnableScissor(new Rectangle( RenderBounds.X + sidebar.ButtonArea.X, RenderBounds.Y + sidebar.ButtonArea.Y, sidebar.ButtonArea.Width, sidebar.ButtonArea.Height)); actorPreviewWidget.Draw(); Game.Renderer.DisableScissor(); } }
public override void Draw() { for (var y = 0; y < Bounds.Height; y += ButtonWidget.Size) { Buttons.PlayFetchIndex("button", () => 0); WidgetUtils.DrawSHPCentered(Buttons.Image, new float2(RenderBounds.X + ButtonWidget.Size / 2, y + ButtonWidget.Size / 2), IngameUi.Palette); } }
public override void Draw() { if (animation != null) { animation.PlayFetchIndex(disabled ? "disabled-icon" : "icon", () => 0); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X, RenderBounds.Y), showResearch.ActorActions.BamUi.Palette); } }
protected override void DrawContents() { if (autoResearchEnabled) { WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(25, 255, 255, 255)); } sidebar.Buttons.PlayFetchIndex("research", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, center + new int2(0, Active ? 1 : 0), sidebar.IngameUi.Palette); }
public override void Draw() { if (actorActions.AllActor != null) { var palette = actorActions.BamUi.WorldRenderer.Palette("BamPlayer" + actorActions.AllActor.Owner.InternalName); var animation = new Animation(actorActions.BamUi.World, actorActions.AllActor.Trait <RenderSprites>().GetImage(actorActions.AllActor)); animation.PlayFetchIndex("icon", () => 0); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X, RenderBounds.Y), palette); } }
public override void Draw() { var player = GetPlayer(); if (player == null) { return; } var queues = world.ActorsWithTrait <ProductionQueue>() .Where(a => a.Actor.Owner == player) .Select((a, i) => new { a.Trait, i }); foreach (var queue in queues) { if (!clocks.ContainsKey(queue.Trait)) { clocks.Add(queue.Trait, new Animation(world, "clock")); } } var iconSize = new float2(IconWidth, IconHeight); foreach (var queue in queues) { var current = queue.Trait.CurrentItem(); if (current == null) { continue; } var actor = queue.Trait.AllItems().FirstOrDefault(a => a.Name == current.Item); if (actor == null) { continue; } var icon = new Animation(world, RenderSimple.GetImage(actor)); icon.Play(actor.Traits.Get <TooltipInfo>().Icon); var location = new float2(RenderBounds.Location) + new float2(queue.i * (IconWidth + IconSpacing), 0); WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer, 0.5f); var clock = clocks[queue.Trait]; clock.PlayFetchIndex("idle", () => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime) * (clock.CurrentSequence.Length - 1) / current.TotalTime)); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer, 0.5f); var tiny = Game.Renderer.Fonts["Tiny"]; var text = GetOverlayForItem(current); tiny.DrawTextWithContrast(text, location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0), Color.White, Color.Black, 1); } }
public override void Draw() { var iconSize = new float2(64, 48); var iconOffset = 0.5f * iconSize; overlayFont = Game.Renderer.Fonts["TinyBold"]; holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; // Background foreach (var rect in icons.Keys) { WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1)); } // Icons foreach (var p in icons.Values) { WidgetUtils.DrawSHPCentered(p.Sprite, p.Pos + iconOffset, worldRenderer); // Charge progress clock.PlayFetchIndex("idle", () => (p.Power.TotalTime - p.Power.RemainingTime) * (clock.CurrentSequence.Length - 1) / p.Power.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, worldRenderer); } // Overlay foreach (var p in icons.Values) { if (p.Power.Ready) { overlayFont.DrawTextWithContrast(ReadyText, p.Pos + readyOffset, Color.White, Color.Black, 1); } else if (!p.Power.Active) { overlayFont.DrawTextWithContrast(HoldText, p.Pos + holdOffset, Color.White, Color.Black, 1); } else { overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime), p.Pos + timeOffset, Color.White, Color.Black, 1); } } }
public override void Draw() { if (actorActions.Actor == null) { return; } if (animation != null) { animation.PlayFetchIndex("icon", () => 0); WidgetUtils.DrawSHPCentered(animation.Image, new float2(RenderBounds.X, RenderBounds.Y), actorActions.BamUi.Palette); } }
public override void Draw() { if (Sprite == null) { return; } var pos = new float2(RenderBounds.Location); var f = Scale / 2.0f; var center = new float2(Sprite.Size.X * f, Sprite.Size.Y * f); WidgetUtils.DrawSHPCentered(Sprite, pos + center + Offset, Palette, Scale); }
public override void Draw() { if (text == null) { return; } var disabled = !(actorActions.Actor.Trait <HealTargetAbility>().CurrentDelay >= actorActions.Actor.Info.TraitInfoOrDefault <HealTargetAbilityInfo>().Delay); anim.PlayFetchIndex(disabled ? "ui_Ability_button_disabled" : "ui_Ability_button", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y), actorActions.BamUi.Palette); actorActions.BamUi.Font.DrawTextWithShadow(text, new float2(RenderBounds.X + RenderBounds.Width / 4 - actorActions.BamUi.Font.Measure(text).X / 2, RenderBounds.Y - 2), Color.White, Color.Gray, 1); }
public override void Draw() { var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; overlayFont = Game.Renderer.Fonts["TinyBold"]; holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; // Icons foreach (var p in icons.Values) { WidgetUtils.DrawSHPCentered(p.Sprite, p.Pos + iconOffset, worldRenderer); // Charge progress var sp = p.Power; clock.PlayFetchIndex("idle", () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime) * (clock.CurrentSequence.Length - 1) / sp.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, worldRenderer); } // Overlay foreach (var p in icons.Values) { if (p.Power.Ready) { overlayFont.DrawTextWithContrast(ReadyText, p.Pos + readyOffset, Color.White, Color.Black, 1); } else if (!p.Power.Active) { overlayFont.DrawTextWithContrast(HoldText, p.Pos + holdOffset, Color.White, Color.Black, 1); } else { overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime), p.Pos + timeOffset, Color.White, Color.Black, 1); } } }
public override void Draw() { var player = GetPlayer(); if (player == null) { return; } var powers = player.PlayerActor.Trait <SupportPowerManager>().Powers .Select((a, i) => new { a, i }); foreach (var power in powers) { if (!clocks.ContainsKey(power.a.Key)) { clocks.Add(power.a.Key, new Animation("clock")); } } var iconSize = new float2(IconWidth, IconHeight); foreach (var power in powers) { var item = power.a.Value; if (item == null || item.Info == null || item.Info.Icon == null) { continue; } icon.Play(item.Info.Icon); var location = new float2(RenderBounds.Location) + new float2(power.i * (IconWidth + IconSpacing), 0); WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer, 0.5f); var clock = clocks[power.a.Key]; clock.PlayFetchIndex("idle", () => item.TotalTime == 0 ? 0 : ((item.TotalTime - item.RemainingTime) * (clock.CurrentSequence.Length - 1) / item.TotalTime)); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer, 0.5f); var tiny = Game.Renderer.Fonts["Tiny"]; var text = GetOverlayForItem(item); tiny.DrawTextWithContrast(text, location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0), Color.White, Color.Black, 1); } }
public override void Draw() { center = new int2(RenderBounds.X + Size / 2, RenderBounds.Y + Size / 2); WidgetUtils.FillRectWithColor(new Rectangle(RenderBounds.X, RenderBounds.Y, Size, Size), Color.FromArgb(255, 0, 0, 0)); sidebar.Buttons.PlayFetchIndex(Active && IsUsable() ? type + "-down" : type, () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, center, sidebar.IngameUi.Palette); if (IsUsable()) { DrawContents(); } if (Active && IsUsable()) { WidgetUtils.FillRectWithColor(RenderBounds, Color.FromArgb(128, 0, 0, 0)); } }
public override void Draw() { var iconOffset = 0.5f * IconSize.ToVector2() + IconSpriteOffset; overlayFont = WarGame.Renderer.Fonts["TinyBold"]; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2; queuedOffset = new Vector2(4, 2); holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; if (CurrentQueue == null) { return; } var buildableItems = CurrentQueue.BuildableItems(); var pios = currentQueue.Actor.Owner.PlayerActor.TraitsImplementing <IProductionIconOverlay>(); //Icons foreach (var icon in icons.Values) { WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, icon.Palette); //Build progress if (icon.Queued.Count > 0) { var first = icon.Queued[0]; clock.PlayFetchIndex(ClockSequence, () => (first.TotalTime - first.RemainingTime) * (clock.CurrentSequence.Length - 1) / first.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.IconClockPalette); } else if (!buildableItems.Any(a => a.Name == icon.Name)) { WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette); } } }
public override void Draw() { // TODO this whole block can be removed when arrows are widgets! if (visibleIcons < buildableItems.Length) { var position = new int2(RenderBounds.X + ButtonWidget.Size / 4, RenderBounds.Y + ButtonWidget.Size / 4 + visibleIcons * ButtonWidget.Size); sidebar.Buttons.PlayFetchIndex("button-small", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position, sidebar.IngameUi.Palette); sidebar.Buttons.PlayFetchIndex("button-small-down", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position, sidebar.IngameUi.Palette); if (scrollOffset + visibleIcons == buildableItems.Length) { WidgetUtils.FillRectWithColor(new Rectangle( RenderBounds.X, RenderBounds.Y + visibleIcons * ButtonWidget.Size, ButtonWidget.Size / 2, ButtonWidget.Size / 2), Color.FromArgb(128, 0, 0, 0)); } sidebar.Buttons.PlayFetchIndex("button-small", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position + new int2(ButtonWidget.Size / 2, 0), sidebar.IngameUi.Palette); sidebar.Buttons.PlayFetchIndex("button-small-up", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, position + new int2(ButtonWidget.Size / 2, 0), sidebar.IngameUi.Palette); if (scrollOffset == 0) { WidgetUtils.FillRectWithColor(new Rectangle( RenderBounds.X + ButtonWidget.Size / 2, RenderBounds.Y + visibleIcons * ButtonWidget.Size, ButtonWidget.Size / 2, ButtonWidget.Size / 2), Color.FromArgb(128, 0, 0, 0)); } } }
protected override void DrawContents() { sidebar.Buttons.PlayFetchIndex("repair", () => 0); WidgetUtils.DrawSHPCentered(sidebar.Buttons.Image, center + new int2(0, Active ? 1 : 0), sidebar.IngameUi.Palette); }
public override void Draw() { anim.PlayFetchIndex("ui_tooltipbar", () => 0); var x = anim.Image.Bounds.Width; var y = anim.Image.Bounds.Height; WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y), actorActions.BamUi.Palette); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y + y), actorActions.BamUi.Palette); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y + y * 2), actorActions.BamUi.Palette); if (showStats) { anim.PlayFetchIndex("ui_tooltipbar", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y + y * 3), actorActions.BamUi.Palette); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y + y * 4), actorActions.BamUi.Palette); for (int i = 0; i < attack; i++) { anim.PlayFetchIndex("damage", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X + 5 + i * 12, RenderBounds.Y + y * 2), actorActions.BamUi.Palette); } for (int i = 0; i < armor; i++) { anim.PlayFetchIndex("armor", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X + 5 + i * 12, RenderBounds.Y + y * 3), actorActions.BamUi.Palette); } for (int i = 0; i < speed; i++) { anim.PlayFetchIndex("speed", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X + 5 + i * 12, RenderBounds.Y + y * 4), actorActions.BamUi.Palette); } var text = cost.ToString(); actorActions.BamUi.Font.DrawTextWithShadow(text, new float2(RenderBounds.X + RenderBounds.Width - actorActions.BamUi.Font.Measure(text).X - 2, RenderBounds.Y + 2), Color.YellowGreen, Color.DarkSlateGray, 1); } if (showRes) { anim.PlayFetchIndex("ui_tooltipbar", () => 0); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X, RenderBounds.Y + y * 3), actorActions.BamUi.Palette); anim.PlayFetchIndex("ui_research_bar", () => 5); WidgetUtils.DrawSHPCentered(anim.Image, new float2(RenderBounds.X + 5, RenderBounds.Y + y * 3 - 5), actorActions.BamUi.Palette); var text = researcost.ToString(); actorActions.BamUi.Font.DrawTextWithShadow(text, new float2(RenderBounds.X + RenderBounds.Width - actorActions.BamUi.Font.Measure(text).X - 2, RenderBounds.Y + 2), Color.YellowGreen, Color.DarkSlateGray, 1); var text2 = researchtime / 25 + " Seconds"; actorActions.BamUi.Font.DrawTextWithShadow(text2, new float2(RenderBounds.X + RenderBounds.Width / 2 - actorActions.BamUi.Font.Measure(text2).X, RenderBounds.Y + y * 2), Color.YellowGreen, Color.DarkSlateGray, 1); } actorActions.BamUi.FontLarge.DrawTextWithShadow(name, new float2(RenderBounds.X + 2, RenderBounds.Y + 2), Color.YellowGreen, Color.DarkSlateGray, 1); }
public override void Draw() { buttons.Clear(); if (world.LocalPlayer == null) { return; } var manager = world.LocalPlayer.PlayerActor.Trait <SupportPowerManager>(); var powers = manager.Powers.Where(p => !p.Value.Disabled); var numPowers = powers.Count(); if (numPowers == 0) { return; } var rectBounds = RenderBounds; WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"), new float2(rectBounds.X, rectBounds.Y)); for (var i = 1; i < numPowers; i++) { WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51)); } WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51)); // HACK: Hack Hack Hack rectBounds.Width = IconWidth + 5; rectBounds.Height = 31 + numPowers * (IconHeight + 3); var y = rectBounds.Y + 10; var iconSize = new float2(IconWidth, IconHeight); foreach (var kv in powers) { var sp = kv.Value; icon.Play(sp.Info.Icon); var drawPos = new float2(rectBounds.X + 5, y); var rect = new Rectangle(rectBounds.X + 5, y, 64, 48); if (rect.Contains(Viewport.LastMousePos)) { var pos = drawPos.ToInt2(); var tl = new int2(pos.X - 3, pos.Y - 3); var m = new int2(pos.X + 64 + 3, pos.Y + 48 + 3); var br = tl + new int2(64 + 3 + 20, 40); if (sp.TotalTime > 0) { br += new int2(0, 20); } if (sp.Info.LongDesc != null) { br += Game.Renderer.Fonts["Regular"].Measure(sp.Info.LongDesc.Replace("\\n", "\n")); } else { br += new int2(300, 0); } var border = WidgetUtils.GetBorderSizes("dialog4"); WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(tl.X, tl.Y, m.X + border[3], m.Y), PanelSides.Left | PanelSides.Top | PanelSides.Bottom | PanelSides.Center); WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]), PanelSides.Top | PanelSides.Right | PanelSides.Center); WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y), PanelSides.Left | PanelSides.Right | PanelSides.Bottom | PanelSides.Center); pos += new int2(77, 5); Game.Renderer.Fonts["Bold"].DrawText(sp.Info.Description, pos, Color.White); if (sp.TotalTime > 0) { pos += new int2(0, 20); Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime), pos, Color.White); Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45, 0), Color.White); } if (sp.Info.LongDesc != null) { pos += new int2(0, 20); Game.Renderer.Fonts["Regular"].DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White); } } WidgetUtils.DrawSHPCentered(icon.Image, drawPos + 0.5f * iconSize, worldRenderer); clock.PlayFetchIndex("idle", () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime) * (clock.CurrentSequence.Length - 1) / sp.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, drawPos + 0.5f * iconSize, worldRenderer); var overlay = sp.Ready ? ReadyText : sp.Active ? null : HoldText; var font = Game.Renderer.Fonts["TinyBold"]; if (overlay != null) { var size = font.Measure(overlay); var overlayPos = drawPos + new float2(32, 16); font.DrawTextWithContrast(overlay, overlayPos - new float2(size.X / 2, 0), Color.White, Color.Black, 1); } buttons.Add(Pair.New(rect, HandleSupportPower(kv.Key, manager))); y += 51; } }
public override void Draw() { var iconSize = new float2(64, 48); var iconOffset = 0.5f * iconSize; overlayFont = Game.Renderer.Fonts["TinyBold"]; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; queuedOffset = new float2(4, 2); holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; if (CurrentQueue == null) { return; } var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder); // Background foreach (var rect in icons.Keys) { WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1)); } // Icons foreach (var icon in icons.Values) { WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, worldRenderer); // Build progress if (icon.Queued.Count > 0) { var first = icon.Queued[0]; clock.PlayFetchIndex("idle", () => (first.TotalTime - first.RemainingTime) * (clock.CurrentSequence.Length - 1) / first.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, worldRenderer); } else if (!buildableItems.Any(a => a.Name == icon.Name)) { WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, worldRenderer); } } // Overlays foreach (var icon in icons.Values) { var total = icon.Queued.Count; if (total > 0) { var first = icon.Queued[0]; var waiting = first != CurrentQueue.CurrentItem() && !first.Done; if (first.Done) { overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1); } else if (first.Paused) { overlayFont.DrawTextWithContrast(HoldText, icon.Pos + holdOffset, Color.White, Color.Black, 1); } else if (!waiting) { overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual), icon.Pos + timeOffset, Color.White, Color.Black, 1); } if (total > 1 || waiting) { overlayFont.DrawTextWithContrast(total.ToString(), icon.Pos + queuedOffset, Color.White, Color.Black, 1); } } } }
int DrawPalette(ProductionQueue queue) { buttons.Clear(); var paletteCollection = "palette-" + world.LocalPlayer.Country.Race; var origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9); var iconOffset = 0.5f * new float2(IconWidth, IconHeight); var x = 0; var y = 0; if (queue != null) { var buildableItems = queue.BuildableItems().ToArray(); var allBuildables = queue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder).ToArray(); var overlayBits = new List <Pair <Sprite, float2> >(); var textBits = new List <Pair <float2, string> >(); numActualRows = Math.Max((allBuildables.Count() + Columns - 1) / Columns, Rows); // Palette Background WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "top"), new float2(origin.X - 9, origin.Y - 9)); for (var w = 0; w < numActualRows; w++) { WidgetUtils.DrawRGBA( ChromeProvider.GetImage(paletteCollection, "bg-" + (w % 4)), new float2(origin.X - 9, origin.Y + IconHeight * w)); } WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"), new float2(origin.X - 9, origin.Y - 1 + IconHeight * numActualRows)); // Icons string tooltipItem = null; var tooltipHotkey = Hotkey.Invalid; var i = 0; foreach (var item in allBuildables) { var rect = new RectangleF(origin.X + x * IconWidth, origin.Y + IconHeight * y, IconWidth, IconHeight); var drawPos = new float2(rect.Location); var icon = new Animation(world, RenderSimple.GetImage(item)); icon.Play(item.Traits.Get <TooltipInfo>().Icon); WidgetUtils.DrawSHPCentered(icon.Image, drawPos + iconOffset, worldRenderer); var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name); if (rect.Contains(Viewport.LastMousePos)) { tooltipItem = item.Name; tooltipHotkey = Game.Settings.Keys.GetProductionHotkey(i); } var overlayPos = drawPos + new float2(32, 16); if (firstOfThis != null) { clock.PlayFetchIndex("idle", () => (firstOfThis.TotalTime - firstOfThis.RemainingTime) * (clock.CurrentSequence.Length - 1) / firstOfThis.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, drawPos + iconOffset, worldRenderer); if (queue.CurrentItem() == firstOfThis) { textBits.Add(Pair.New(overlayPos, GetOverlayForItem(firstOfThis))); } var repeats = queue.AllQueued().Count(a => a.Item == item.Name); if (repeats > 1 || queue.CurrentItem() != firstOfThis) { textBits.Add(Pair.New(overlayPos + new float2(-24, -14), repeats.ToString())); } } else if (buildableItems.All(a => a.Name != item.Name)) { overlayBits.Add(Pair.New(cantBuild.Image, drawPos)); } var closureName = buildableItems.Any(a => a.Name == item.Name) ? item.Name : null; buttons.Add(Pair.New(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), HandleClick(closureName, world))); if (++x == Columns) { x = 0; y++; } i++; } if (x != 0) { y++; } foreach (var ob in overlayBits) { WidgetUtils.DrawSHPCentered(ob.First, ob.Second + iconOffset, worldRenderer); } var font = Game.Renderer.Fonts["TinyBold"]; foreach (var tb in textBits) { var size = font.Measure(tb.Second); if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0 || tb.Second != ReadyText) { font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), Color.White, Color.Black, 1); } else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) { font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), ReadyTextAltColor, Color.Black, 1); } } // Tooltip if (tooltipItem != null && !paletteAnimating && paletteOpen) { DrawProductionTooltip(world, tooltipItem, tooltipHotkey, new float2(Game.Renderer.Resolution.Width, origin.Y + numActualRows * IconHeight + 9).ToInt2()); } } // Palette Dock WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"), new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23)); for (var i = 0; i < numActualRows; i++) { WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)), new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i)); } WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"), new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 1 + IconHeight * numActualRows)); return(IconHeight * y + 9); }
public override void Draw() { var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; overlayFont = Game.Renderer.Fonts["TinyBold"]; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; queuedOffset = new float2(4, 2); holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; if (CurrentQueue == null) { return; } var buildableItems = CurrentQueue.BuildableItems(); // Icons foreach (var icon in icons.Values) { WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, worldRenderer); // Build progress if (icon.Queued.Count > 0) { var first = icon.Queued[0]; clock.PlayFetchIndex("idle", () => (first.TotalTime - first.RemainingTime) * (clock.CurrentSequence.Length - 1) / first.TotalTime); clock.Tick(); WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, worldRenderer); } else if (!buildableItems.Any(a => a.Name == icon.Name)) { WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, worldRenderer); } } // Overlays foreach (var icon in icons.Values) { var total = icon.Queued.Count; if (total > 0) { var first = icon.Queued[0]; var waiting = first != CurrentQueue.CurrentItem() && !first.Done; if (first.Done) { if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0) { overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1); } else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) { overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1); } } else if (first.Paused) { overlayFont.DrawTextWithContrast(HoldText, icon.Pos + holdOffset, Color.White, Color.Black, 1); } else if (!waiting) { overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual), icon.Pos + timeOffset, Color.White, Color.Black, 1); } if (total > 1 || waiting) { overlayFont.DrawTextWithContrast(total.ToString(), icon.Pos + queuedOffset, Color.White, Color.Black, 1); } } } }