private void setupStartSelector_SelectedIndexChanged(object sender, EventArgs e) { if (setupStartSelector.SelectedItem == null) { return; } var start = (setupStartSelector.SelectedItem as Tag <StartingConditions>).Value; if (start != null) { var sb = new StringBuilder(); var formatter = new ThousandsFormatter(start.Population, start.Infrastructure); sb.AppendLine("Colonies: " + start.Colonies); sb.AppendLine("Population: " + formatter.Format(start.Population)); sb.Append("Infrastructure: " + formatter.Format(start.Infrastructure)); startingDescription.Text = sb.ToString(); controller.SelectedStart = start; } else { using (var form = new FormStartingConditions()) { form.Initialize(controller.CustomStart); if (form.ShowDialog() == DialogResult.OK && form.IsValid) { controller.CustomStart = form.GetResult(); setupStartSelector.Items[customStartIndex] = new Tag <StartingConditions>(controller.CustomStart, controller.CustomStart.Name); setupStartSelector.SelectedIndex = customStartIndex; controller.SelectedStart = controller.CustomStart; } } } }
public void SetView(CombatantInfo unit, SpaceBattleController controller) { this.unit = unit; this.controller = controller; var context = LocalizationManifest.Get.CurrentLanguage["FormMain"]; var formatter = new ThousandsFormatter(); var decimalFormat = new DecimalsFormatter(0, 0); shipCount.Text = context["ShipCount"].Text() + ": " + formatter.Format(unit.Count); armorInfo.Text = hpText("ArmorLabel", unit.ArmorHp, unit.ArmorHpMax); shieldsInfo.Text = hpText("ShieldLabel", unit.ShieldHp, unit.ShieldHpMax); if (unit.MovementEta > 0) { movementInfo.Text = context["MovementEta"].Text( new Var("eta", unit.MovementEta).Get, new TextVar("eta", unit.MovementEta.ToString()).Get ); } else { movementInfo.Text = context["MovementPoints"].Text() + " (" + decimalFormat.Format(unit.MovementPoints * 100) + " %)"; } }
private void updateInfos() { var percentFormat = new DecimalsFormatter(0, 1); var thousandsFormat = new ThousandsFormatter(); double powerGenerated = this.controller.Reactor.Power; double powerUsed = this.controller.PowerUsed; this.armorInfo.Text = this.context["armor"].Text( new TextVar("totalHp", thousandsFormat.Format(this.controller.HitPoints)).Get ); this.mobilityInfo.Text = this.context["mobility"].Text( new TextVar("mobility", thousandsFormat.Format(this.controller.Evasion)).Get ); this.powerInfo.Text = this.context["power"].Text( new TextVar("powerPercent", percentFormat.Format(Methods.Clamp(1 - powerUsed / powerGenerated, 0, 1) * 100)).Get ); this.sensorInfo.Text = this.context["sensors"].Text( new TextVar("detection", this.controller.Detection.ToString("0.#")).Get ); this.stealthInfo.Text = this.context["stealth"].Text( new TextVar("jamming", this.controller.Jamming.ToString("0.#")). And("cloaking", this.controller.Cloaking.ToString("0.#")).Get ); this.costInfo.Text = this.context["cost"].Text( new TextVar("cost", thousandsFormat.Format(this.controller.Cost)).Get ); this.spaceInfo.SetSpace(this.controller.SpaceUsed, this.controller.SpaceTotal); }
private IEnumerable <PolygonData> projectileSpriteData(IGrouping <Vector2D, ProjectileInfo> hex) { var hexTransform = Matrix4.CreateTranslation(hexX(hex.Key), hexY(hex.Key), 0); var shownProjectile = hex.Aggregate((a, b) => a.Count > b.Count ? a : b); var unitSprite = GalaxyTextures.Get.Sprite(shownProjectile.ImagePath); yield return(new PolygonData( ProjectileZ, new SpriteData(Matrix4.CreateScale(ProjectileScale, ProjectileScale, 1) * hexTransform, unitSprite.Id, shownProjectile.Owner.Color, null), SpriteHelpers.UnitRect(unitSprite).ToList() )); var formatter = new ThousandsFormatter(); foreach (var layer in TextRenderUtil.Get.BufferText(formatter.Format(shownProjectile.Count), -1, 0, ProjectileZ, 1 / Layers)) { //TODO(v0.9) text as sprite data? should be SDF yield return(new PolygonData( layer.Key, new SpriteData( Matrix4.CreateScale(0.2f, 0.2f, 1) * Matrix4.CreateTranslation(0.5f, -0.5f * ProjectileScale, 0) * hexTransform, TextRenderUtil.Get.TextureId, Color.Gray, null ), layer.Value.ToList() )); } }
private void design_OnMouseEnter(object sender, EventArgs e) { var design = (sender as DesignItem).Data; var formatter = new ThousandsFormatter(); var sb = new StringBuilder(); var context = LocalizationManifest.Get.CurrentLanguage["FormDesign"]; sb.AppendLine(design.IsDrive != null ? design.IsDrive.Name : context["noIsDrive"].Text()); sb.AppendLine(design.Shield != null ? design.Shield.Name : context["noShield"].Text()); sb.AppendLine(); foreach (var equip in design.Equipment) { sb.AppendLine(formatter.Format(equip.Value) + " x " + equip.Key.Name); } if (design.Equipment.Any()) { sb.AppendLine(); } foreach (var equip in design.SpecialEquipment) { sb.AppendLine(formatter.Format(equip.Value) + " x " + equip.Key.Name); } designThumbnail.Image = ImageCache.Get[design.ImagePath]; designName.Text = design.Name; hullName.Text = design.Hull.Name; equipmentInfo.Text = sb.ToString(); }
public static long?DecodeQuantity(string text) { long result = -1; text = text.Trim(); double?prefixedValue = ThousandsFormatter.TryParse(text); if (prefixedValue.HasValue) { result = (long)prefixedValue.Value; } else if (text.ToLower().Contains("e")) { double resultScientific; if (double.TryParse(text, out resultScientific)) { result = (long)resultScientific; } else { return(null); } } else if (!long.TryParse(text, out result)) { return(null); } return((result < 0) ? null : new long?(result)); }
public FormDevelopment(PlayerController controller) : this() { this.Font = SettingsWinforms.Get.FormFont; this.controller = controller; this.topics = controller.DevelopmentTopics().ToList(); updateList(); if (topics.Count > 0) { topicList.SelectedIndex = controller.ResearchFocus; } updateDescription(topicList.SelectedItem); if (controller.IsReadOnly) { reorderBottomAction.Enabled = false; reorderDownAction.Enabled = false; reorderTopAction.Enabled = false; reorderUpAction.Enabled = false; focusSlider.Enabled = false; } Context context = LocalizationManifest.Get.CurrentLanguage["FormTech"]; this.Text = context["DevelopmentTitle"].Text(); var formatter = new ThousandsFormatter(); pointsInfo.Text = context["developmentPoints"].Text() + ": " + formatter.Format(controller.DevelopmentPoints); focusSlider.Maximum = controller.DevelopmentFocusOptions().Length - 1; focusSlider.Value = controller.DevelopmentFocusIndex; }
private void actionButton_Click(object sender, EventArgs e) { var context = LocalizationManifest.Get.CurrentLanguage["FormDesign"]; Action <DesignInfo> disbandDesign = x => this.controller.DisbandDesign(this.data); Action <DesignInfo> keepDesign = x => this.controller.KeepDesign(this.data); Action <DesignInfo> refitDesign = x => this.controller.RefitDesign(this.data, x); var formatter = new ThousandsFormatter(); var refitOptions = new IShipComponentType[] { new ShipComponentType <DesignInfo>(context["disbandDesign"].Text(), global::Stareater.Properties.Resources.cancel, null, disbandDesign), new ShipComponentType <DesignInfo>(context["keepDesign"].Text(), global::Stareater.Properties.Resources.start, null, keepDesign) }.Concat( this.controller.RefitCandidates(this.data).Where(x => x.Constructable).Select(x => new ShipComponentType <DesignInfo>( x.Name + Environment.NewLine + context["refitCost"].Text() + ": " + formatter.Format(this.controller.RefitCost(this.data, x)), ImageCache.Get[x.ImagePath], x, refitDesign ))); using (var form = new FormPickComponent(context["refitTitle"].Text(), refitOptions)) form.ShowDialog(); this.makeNameText(); }
public void SetSpace(double current, double maximum) { var formatter = new ThousandsFormatter(maximum); this.infoText.Text = formatter.Format(current) + " / " + formatter.Format(maximum); this.freePortion = (float)Methods.Clamp(current / maximum, 0, maximum); this.Refresh(); }
public FormSelectQuantity(long max, long current) : this() { this.maximum = max; var formatter = new ThousandsFormatter(); this.quantitySlider.Maximum = max > this.quantitySlider.Maximum ? this.quantitySlider.Maximum : (int)max; this.quantityInput.Text = formatter.Format(current); }
private void setupFuelInfo() { var formatter = new ThousandsFormatter(this.currentPlayer.FuelAvailable); this.fuelInfo.Text = LocalizationManifest.Get.CurrentLanguage["GalaxyScene"]["FuelInfo"].Text( new TextVar("fuelLeft", formatter.Format(this.currentPlayer.FuelAvailable - this.currentPlayer.FuelUsage)). And("fuelAvailable", formatter.Format(this.currentPlayer.FuelAvailable)).Get ); }
public void PartialSelect(long quantity) { this.selectedQuantity = quantity; var thousandsFormat = new ThousandsFormatter(this.Data.Quantity); this.quantityLabel.Text = this.Data.Design.Name + Environment.NewLine + thousandsFormat.Format(quantity) + " / " + thousandsFormat.Format(this.Data.Quantity); }
public void Initialize(StartingConditions condition) { coloniesSelector.Maximum = StartingConditions.MaxColonies; coloniesSelector.Value = condition.Colonies; var numberFormat = new ThousandsFormatter(condition.Population, condition.Infrastructure); populationInput.Text = numberFormat.Format(condition.Population); infrastructureInput.Text = numberFormat.Format(condition.Infrastructure); }
public void SetData(ShipGroupInfo groupInfo, PlayerInfo owner) { this.Data = groupInfo; var thousandsFormat = new ThousandsFormatter(); this.hullThumbnail.Image = ImageCache.Get[groupInfo.Design.ImagePath]; this.hullThumbnail.BackColor = owner.Color; this.quantityLabel.Text = this.Data.Design.Name + Environment.NewLine + thousandsFormat.Format(groupInfo.Quantity); }
public void Initialize(StartingConditions condition) { coloniesSelector.Maximum = StartingConditions.MaxColonies; coloniesSelector.Value = condition.Colonies; var numberFormat = new ThousandsFormatter(condition.Population); populationInput.Text = numberFormat.Format(condition.Population); //TODO(v0.9) faked number of total infrastructure infrastructureInput.Text = condition.Buildings.Any() ? numberFormat.Format(condition.Buildings.Max(x => x.Amount)) : "0"; }
private void shipGroupSplit(ShipSelectableItem shipItem) { using (var form = new FormSelectQuantity(shipItem.Data.Quantity, 1)) { form.ShowDialog(); var thousandsFormat = new ThousandsFormatter(shipItem.Data.Quantity); shipItem.IsSelected = form.SelectedValue > 0; shipItem.Text = shipItem.Data.Design.Name + Environment.NewLine + thousandsFormat.Format(form.SelectedValue) + " / " + thousandsFormat.Format(shipItem.Data.Quantity); this.selectedFleetControl.SelectGroup(shipItem.Data, form.SelectedValue); } }
private string shipGroupText(ShipGroupInfo group) { var selected = this.selectedFleetControl.SelectionCount(group); if (selected == 0 || selected == group.Quantity) { return(group.Design.Name + Environment.NewLine + new ThousandsFormatter().Format(group.Quantity)); } var thousandsFormat = new ThousandsFormatter(group.Quantity); return(group.Design.Name + Environment.NewLine + thousandsFormat.Format(selected) + " / " + thousandsFormat.Format(group.Quantity)); }
private void setupUi() { foreach (var element in planetElements) { this.RemoveElement(element); } this.planetElements = new List <AGuiElement>(); foreach (var planet in this.controller.Planets) { var planetImage = new GuiImage { Image = GalaxyTextures.Get.PlanetSprite(planet.Type), }; planetImage.Position.FixedSize(100, 100).RelativeTo(this.planetAnchor(planet.Planet)); this.addPlanetElement(planetImage); if (planet.Owner == null) { continue; } var colony = planet.Colony; var formatter = new ThousandsFormatter(); var popInfo = new GuiText { Margins = new Vector2(0, 20), TextHeight = 20, Text = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax), TextColor = colony.Owner.Color }; popInfo.Position.WrapContent().Then.RelativeTo(planetImage, 0, -1, 0, 1).UseMargins(); this.addPlanetElement(popInfo); if (this.controller.Targets.Contains(planet)) { var bombButton = new GuiButton { BackgroundHover = new BackgroundTexture(GalaxyTextures.Get.BombButton, 6), BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.BombButton, 6), ClickCallback = () => this.controller.Bombard(planet.OrdinalPosition), Margins = new Vector2(0, 20) }; bombButton.Position.FixedSize(80, 80).RelativeTo(popInfo, 0, -1, 0, 1).UseMargins(); this.addPlanetElement(bombButton); } } }
private void setupUi() { var formatter = new ThousandsFormatter(); var colonies = this.controller.Planets.Where(x => x.Owner != null).ToList(); this.UpdateScene( ref this.colonyInfos, colonies.Select( planet => { var xOffset = planet.OrdinalPosition * OrbitStep + OrbitOffset; return(new SceneObject(new PolygonData( PopCountZ, new SpriteData(Matrix4.Identity, TextRenderUtil.Get.TextureId, Color.White), TextRenderUtil.Get.BufferText( LocalizationManifest.Get.CurrentLanguage["FormMain"]["Population"].Text() + ": " + formatter.Format(planet.Population), -0.5f, Matrix4.CreateScale(TextScale) * Matrix4.CreateTranslation(xOffset, -PlanetScale / 2 - PopCountTopMargin, 0) ).ToList() ))); } ).ToList() ); const float yOffset = -PlanetScale / 2 - PopCountTopMargin - TextScale - ButtonTopMargin - ButtonSize / 2; //TODO(v0.6) buttons for only hostile colonies this.UpdateScene( ref this.bombButtons, colonies.Select( colony => { var xOffset = colony.OrdinalPosition * OrbitStep + OrbitOffset; //TODO(v0.6) Use scene object physical shape return(new SceneObject(new PolygonData( PopCountZ, new SpriteData(Matrix4.CreateScale(ButtonSize) * Matrix4.CreateTranslation(xOffset, yOffset, 0), GalaxyTextures.Get.BombButton.Id, Color.White), SpriteHelpers.UnitRectVertexData(GalaxyTextures.Get.BombButton) ))); }).ToList() ); }
public void OnUnitTurn(CombatantInfo unitInfo) { this.currentUnit = unitInfo; this.unitControls.SetView(unitInfo, this.Controller); var context = LocalizationManifest.Get.CurrentLanguage["FormMain"]; var moveButton = new OptionItem <AbilityInfo>(null) { Text = context["MoveAction"].Text(), OnSelect = x => { this.SelectedAbility = null; } }; var formatter = new ThousandsFormatter(); var buttons = new[] { moveButton }. Concat(unitInfo.Abilities.Select( ability => new OptionItem <AbilityInfo>(ability) { Image = GalaxyTextures.Get.Sprite(ability.ImagePath), Text = ability.Name + " x" + formatter.Format(ability.Quantity), OnSelect = x => { this.SelectedAbility = x; } } )).ToList(); foreach (var button in buttons) { button.GroupWith(moveButton); } this.abilityList.Children = buttons; buttons[buttons.Count > 1 ? 1 : 0].Select(); var unitCenter = new Vector2(hexX(unitInfo.Position), hexY(unitInfo.Position)); if (!this.isVisible(unitCenter)) { this.originOffset = unitCenter; this.setupPerspective(); } this.setupBodies(); this.setupUnits(); this.setupProjectiles(); }
private void quantitySlider_Scroll(object sender, EventArgs e) { if (ignoreEvents) { return; } ignoreEvents = true; if (this.maximum == this.quantitySlider.Maximum) { this.quantityInput.Text = this.quantitySlider.Value.ToString(); } else { var formatter = new ThousandsFormatter(); this.quantityInput.Text = formatter.Format(Math.Round(this.maximum * (this.quantitySlider.Value / (double)this.quantitySlider.Maximum))); } ignoreEvents = false; }
public void SetData(DevelopmentTopicInfo topicInfo) { this.Data = topicInfo; ThousandsFormatter thousandsFormat = new ThousandsFormatter(topicInfo.Cost); thumbnailImage.Image = ImageCache.Get[topicInfo.ImagePath]; nameLabel.Text = topicInfo.Name; levelLabel.Text = TopicLevelText; costLabel.Text = thousandsFormat.Format(topicInfo.InvestedPoints) + " / " + thousandsFormat.Format(topicInfo.Cost); if (topicInfo.Investment > 0) { investmentLabel.Text = "+" + thousandsFormat.Format(topicInfo.Investment); } else { investmentLabel.Text = ""; } }
private IEnumerable <PolygonData> planetSpriteData(CombatPlanetInfo planet) { var planetTransform = Matrix4.CreateTranslation(hexX(planet.Position), hexY(planet.Position), 0); var sprite = new TextureInfo(); switch (planet.Type) { case PlanetType.Asteriod: sprite = GalaxyTextures.Get.Asteroids; break; case PlanetType.GasGiant: sprite = GalaxyTextures.Get.GasGiant; break; case PlanetType.Rock: sprite = GalaxyTextures.Get.RockPlanet; break; } yield return(new PolygonData( PlanetColorZ, new SpriteData(planetTransform, sprite.Id, Color.White, null), SpriteHelpers.UnitRect(sprite).ToList() )); var formatter = new ThousandsFormatter(); if (planet.Population > 0) { foreach (var layer in TextRenderUtil.Get.BufferText(formatter.Format(planet.Population), -1, 0, MoreCombatantsZ, 1 / Layers)) { //TODO(v0.9) text as sprite data? should be SDF yield return(new PolygonData( layer.Key, new SpriteData(PopulationTransform * planetTransform, TextRenderUtil.Get.TextureId, planet.Owner != null ? planet.Owner.Color : Color.Gray, null), layer.Value.ToList() )); } } }
public FormStellarisDetails(StellarisAdminController controller) : this() { this.controller = controller; this.setStarImage(); Context context = LocalizationManifest.Get.CurrentLanguage["FormStellaris"]; this.Text = this.controller.HostStar.Name.ToText(LocalizationManifest.Get.CurrentLanguage); this.Font = SettingsWinforms.Get.FormFont; buildingsGroup.Text = context["buildingsGroup"].Text(); coloniesInfoGroup.Text = context["coloniesGroup"].Text(); outputInfoGroup.Text = context["outputGroup"].Text(); var prefixFormat = new ThousandsFormatter(); var percentFormat = new DecimalsFormatter(0, 1); Func <string, double, string> totalText = (label, x) => context[label].Text() + ": " + prefixFormat.Format(x); populationInfo.Text = totalText("populationInfo", controller.PopulationTotal); infrastructureInfo.Text = context["infrastructureInfo"].Text() + ": " + percentFormat.Format(controller.OrganisationAverage * 100) + " %"; industryInfo.Text = totalText("industryInfo", controller.IndustryTotal); developmentInfo.Text = totalText("developmentInfo", controller.DevelopmentTotal); foreach (var trait in controller.Traits) { var thumbnail = new PictureBox(); thumbnail.Size = new Size(32, 32); thumbnail.SizeMode = PictureBoxSizeMode.Zoom; thumbnail.Image = ImageCache.Get[trait.ImagePath]; this.traitList.Controls.Add(thumbnail); } foreach (var data in controller.Buildings) { var itemView = new BuildingItem(); itemView.Data = data; buildingsList.Controls.Add(itemView); } }
public ColonizationTargetView(ColonizationController controller, PlayerController gameController) : this() { this.controller = controller; this.gameController = gameController; var context = LocalizationManifest.Get.CurrentLanguage["FormColonization"]; var infoFormatter = new ThousandsFormatter(controller.PopulationMax); var infoVars = new TextVar("pop", infoFormatter.Format(controller.Population)). And("max", infoFormatter.Format(controller.PopulationMax)); this.targetName.Text = LocalizationMethods.PlanetName(controller.PlanetBody); this.targetInfo.Text = context["population"].Text(infoVars.Get); var enrouteShips = gameController.EnrouteColonizers(controller.PlanetBody).SelectMany(x => x.Ships).ToArray(); var enroutePopulation = enrouteShips.Length > 0 ? enrouteShips.Sum(x => x.Quantity * x.Design.ColonizerPopulation) : 0; this.enrouteInfo.Text = context["enroute"].Text( new TextVar("count", new ThousandsFormatter().Format(enroutePopulation)).Get ); }
private void setupUi() { var formatter = new ThousandsFormatter(); this.UpdateScene( ref this.colonyInfos, this.controller.Planets.Where(x => x.Owner != null).Select( planet => new SceneObject(new PolygonData( PopCountZ, new SpriteData(Matrix4.Identity, TextRenderUtil.Get.TextureId, Color.White, null, true), TextRenderUtil.Get.BufferRaster( LocalizationManifest.Get.CurrentLanguage["FormMain"]["Population"].Text() + ": " + formatter.Format(planet.Population), -0.5f, Matrix4.CreateScale(TextScale) * Matrix4.CreateTranslation(planet.OrdinalPosition * OrbitStep + OrbitOffset, -PlanetScale / 2 - PopCountTopMargin, 0) ).ToList() )) ).ToList() ); this.UpdateScene( ref this.bombButtons, this.controller.Targets.Select( colony => { var xOffset = colony.OrdinalPosition * OrbitStep + OrbitOffset; return(new SceneObject( new PolygonData( PopCountZ, new SpriteData(Matrix4.CreateScale(ButtonSize) * Matrix4.CreateTranslation(xOffset, ButtonY, 0), GalaxyTextures.Get.BombButton.Id, Color.White, null, true), SpriteHelpers.UnitRect(GalaxyTextures.Get.BombButton).ToList() ), new PhysicalData(new Vector2(xOffset, ButtonY), new Vector2(ButtonSize, ButtonSize)), colony.OrdinalPosition )); }).ToList() ); }
public void RefreshData() { var thousandsFormat = new ThousandsFormatter(this.Data.Cost); var focused = this.controller.ResearchFocus == this.Data; this.thumbnailImage.Image = ImageCache.Get[this.Data.ImagePath]; this.nameLabel.Text = this.Data.Name; this.levelLabel.Text = this.TopicLevelText; this.costLabel.Text = thousandsFormat.Format(this.Data.InvestedPoints) + " / " + thousandsFormat.Format(this.Data.Cost); this.focusImage.Image = focused ? Stareater.Properties.Resources.center : null; if (this.Data.Investment > 0) { this.investmentLabel.Text = "+" + thousandsFormat.Format(this.Data.Investment); } else { this.investmentLabel.Text = ""; } this.unlocksLabel.Text = LocalizationManifest.Get.CurrentLanguage[LanguageContext]["unlockPriorities"].Text() + ":" + Environment.NewLine + string.Join(Environment.NewLine, this.controller.ResearchUnlockPriorities(this.Data).Select((x, i) => (i + 1) + ") " + x.Name)); }
public void SetStarSystem(StarSystemController controller, PlayerController playerController) { this.controller = controller; this.currentPlayer = playerController; this.maxOffset = (controller.Planets.Count() + 1) * OrbitStep + OrbitOffset; var bestColony = controller.Planets. Select(x => controller.PlanetsColony(x)). Aggregate( (ColonyInfo)null, (prev, next) => next == null || (prev != null && prev.Population >= next.Population) ? prev : next ); this.originOffset = bestColony != null ? bestColony.Location.Position * OrbitStep + OrbitOffset : 0.5f; this.lastMousePosition = null; this.starSelector.ForgroundImageColor = controller.HostStar.Color; this.starSelector.Select(); foreach (var anchor in this.planetAnchors) { this.RemoveAnchor(anchor); } this.planetAnchors.Clear(); foreach (var element in this.planetSelectors.Values.Concat(this.colonizationMarkers.Values).Concat(this.otherPlanetElements)) { this.RemoveElement(element); } this.planetSelectors.Clear(); this.colonizationMarkers.Clear(); this.otherPlanetElements.Clear(); var traitGridBuilder = new GridPositionBuilder(2, 20, 20, 3); foreach (var trait in controller.HostStar.Traits) { var traitImage = new GuiImage { Below = this.starSelector, Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(this.starSelector, 0.8f, -0.8f, -1, 1).WithMargins(3, 0); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } foreach (var planet in this.controller.Planets) { var anchor = new GuiAnchor(planet.Position * OrbitStep + OrbitOffset, 0); this.AddAnchor(anchor); this.planetAnchors.Add(anchor); var planetSelector = new SelectableImage <int>(planet.Position) { ForgroundImage = GalaxyTextures.Get.PlanetSprite(planet.Type), SelectorImage = GalaxyTextures.Get.SelectedStar, SelectCallback = select, Padding = 16, }; planetSelector.Position.FixedSize(100, 100).RelativeTo(anchor); planetSelector.GroupWith(starSelector); this.planetSelectors[planet.Position] = planetSelector; this.AddElement(planetSelector); var popInfo = new GuiText { TextHeight = 20 }; popInfo.Position.WrapContent().Then.RelativeTo(planetSelector, 0, -1, 0, 1).WithMargins(0, 20); var formatter = new ThousandsFormatter(); var colony = this.controller.PlanetsColony(planet); if (colony != null) { popInfo.Text = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax); popInfo.TextColor = colony.Owner.Color; } else { popInfo.Text = formatter.Format(planet.PopulationMax); popInfo.TextColor = Color.Gray; } this.addPlanetElement(popInfo); traitGridBuilder = new GridPositionBuilder(4, 20, 20, 3); foreach (var trait in planet.Traits) { var traitImage = new GuiImage { Image = GalaxyTextures.Get.Sprite(trait.ImagePath), Tooltip = new SimpleTooltip("Traits", trait.LangCode) }; traitImage.Position.FixedSize(20, 20).RelativeTo(popInfo, 0, -1, 0, 1).WithMargins(0, 10).Offset(-40, 0); traitGridBuilder.Add(traitImage.Position); this.addPlanetElement(traitImage); } } this.setupColonizationMarkers(); }
public void PlayUnit(CombatantInfo unitInfo) { if (this.InvokeRequired) { this.BeginInvoke(new Action <CombatantInfo>(PlayUnit), unitInfo); return; } this.combatRenderer.OnUnitTurn(unitInfo); var context = LocalizationManifest.Get.CurrentLanguage["FormMain"]; var formatter = new ThousandsFormatter(); var decimalFormat = new DecimalsFormatter(0, 0); Func <string, double, double, string> hpText = (label, x, max) => { var hpFormat = ThousandsFormatter.MaxMagnitudeFormat(x, max); return(context[label].Text() + ": " + hpFormat.Format(x) + " / " + hpFormat.Format(max)); }; shipCount.Text = context["ShipCount"].Text() + ": " + formatter.Format(unitInfo.Count); armorInfo.Text = hpText("ArmorLabel", unitInfo.ArmorHp, unitInfo.ArmorHpMax); shieldInfo.Text = hpText("ShieldLabel", unitInfo.ShieldHp, unitInfo.ShieldHpMax); if (unitInfo.MovementEta > 0) { movementInfo.Text = context["MovementEta"].Text( new Var("eta", unitInfo.MovementEta).Get, new TextVar("eta", unitInfo.MovementEta.ToString()).Get ); } else { movementInfo.Text = context["MovementPoints"].Text() + " (" + decimalFormat.Format(unitInfo.MovementPoints * 100) + " %)"; } this.abilityList.Controls.Clear(); Func <Image, string, object, Button> buttonMaker = (image, text, tag) => { var button = new Button { Image = image, ImageAlign = ContentAlignment.MiddleLeft, Margin = new Padding(3, 3, 3, 0), Size = new Size(80, 32), Text = text, TextImageRelation = TextImageRelation.ImageBeforeText, UseVisualStyleBackColor = true, Tag = tag }; button.Click += selectAbility_Click; return(button); }; this.abilityList.Controls.Add(buttonMaker( null, context["MoveAction"].Text(), null )); foreach (var ability in unitInfo.Abilities) { this.abilityList.Controls.Add(buttonMaker( ImageCache.Get.Resized(ability.ImagePath, new Size(24, 24)), "x " + formatter.Format(ability.Quantity), ability )); } }
private string hpText(string label, double x, double max) { var hpFormat = ThousandsFormatter.MaxMagnitudeFormat(x, max); return($"{textFor(label).Text()}: {hpFormat.Format(x)} / {hpFormat.Format(max)}"); }