private void AddShipToCompare(Ship findShip, ShipBuild build = null) { CompareShip childForm = new CompareShip(); if (this.MdiChildren.Length == 0) { childForm.IsFirstChild = true; FirstChild = childForm; } childForm.MdiParent = this; string selection = findShip.Name; TableLayoutPanel tl = childForm.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel; MetricsExctractor Extractor = new MetricsExctractor(findShip); MetricsDrawer Drawer = new MetricsDrawer(tl); MetricsTableComposer.DrawTable(Extractor, Drawer); if (build != null) { selection += "**PB**"; BuildManagerHandler bmHandler = new BuildManagerHandler(tl, Extractor.GetMetrics()); bmHandler.PerformAnimation(false); bmHandler.KeepBackgroundTransparent(true); bmHandler.ApplyAll(build.Flags); bmHandler.ApplyAll(build.Skills); bmHandler.ApplyAll(build.Upgrades); } childForm.Text = selection; childForm.StartPosition = FormStartPosition.Manual; int positionX = (this.MdiChildren.Length - 1) * 252; Point point = new Point(positionX, 0); childForm.Location = point; if (childForm.IsFirstChild == false) { MetricsCompare.DoCompare(childForm.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel, FirstChild.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel); } childForm.Show(); toolStripStatusLabel.Text = "Added '" + selection + "' to compare."; statusStrip.Refresh(); }
private void LoadShipMetrics() { if (RandomizedShip == null) { return; } LOG.Debug("Loading ship metrics"); MetricsExctractor Extractor = new MetricsExctractor(RandomizedShip); MetricsDrawer Drawer = new MetricsDrawer(ShipMetricsTable); MetricsTableComposer.DrawTable(Extractor, Drawer); try { Settings settings = Commons.GetSettings(); string fileName = settings.SaveLocation; if (!fileName.EndsWith("\\")) { fileName += @"\"; } fileName += RandomizedShip.Name + ".bld"; ShipBuild build = null; if (File.Exists(fileName)) { build = BinarySerialize.ReadFromBinaryFile <ShipBuild>(fileName); } if (build != null) { BuildManagerHandler bmHandler = new BuildManagerHandler(ShipMetricsTable, Extractor.GetMetrics()); bmHandler.PerformAnimation(false); bmHandler.KeepBackgroundTransparent(false); bmHandler.ApplyAll(build.Flags); bmHandler.ApplyAll(build.Skills); bmHandler.ApplyAll(build.Upgrades); } } catch (Exception) { } }
public void LoadBuild(ShipBuild build) { LOG.Debug("LoadBuild(" + build.ID + ")"); Ship findShip = Program.AllShips.Find(x => x.ID == build.ID); SelectShip(findShip); foreach (string flag in build.Flags) { foreach (Control ctrl in panelFlags.Controls) { if (ctrl is PictureBox box) { if (box.AccessibleName != null && box.AccessibleName.ToString().Equals(flag)) { int count = int.Parse(combatFlagsCount.Text); if (box.AccessibleRole == AccessibleRole.Alert) { count++; combatFlagsCount.Text = count.ToString(); } box.AccessibleDescription = "X"; box.Refresh(); bmHandler.PerformAnimation(false); bmHandler.ApplyValue(box.AccessibleName); } } } } foreach (string skill in build.Skills) { if (skill.Equals("Camoflage")) { cbCamoflage.Checked = true; } else { foreach (Control ctrl in panelCaptainSkills.Controls) { if (ctrl is PictureBox box) { if (box.AccessibleName != null && box.AccessibleName.ToString().Equals(skill)) { AddSkillPoints(skill); box.AccessibleDescription = "X"; bmHandler.PerformAnimation(false); Skill currentSkill = FindSkillByAccessibleName(box.AccessibleName); if (currentSkill != null) { foreach (Perk perk in currentSkill.Perks) { bmHandler.ApplyValue(perk.ID, perk.Value); } } box.Refresh(); } } } } } foreach (long upgradeId in build.Upgrades) { Consumable consumable = Program.Upgrades.Find(x => x.ID == upgradeId); PictureBox box = new PictureBox(); box.Name = "Upgrade"; box.AccessibleName = consumable.Name; box.Tag = consumable.ID; box.Load(consumable.ImageUrl); box.SizeMode = PictureBoxSizeMode.AutoSize; box.Location = new System.Drawing.Point(20, 15); box.Click += upgradeSlot1_Click; ToolTip ttip = new ToolTip(); ttip.SetToolTip(box, consumable.Name); if (consumable.GetSlotNumber() == 1) { upgradeSlot1.Controls.Add(box); ttip.SetToolTip(upgradeSlot1, consumable.Name); } else if (consumable.GetSlotNumber() == 2) { upgradeSlot2.Controls.Add(box); ttip.SetToolTip(upgradeSlot2, consumable.Name); } else if (consumable.GetSlotNumber() == 3) { upgradeSlot3.Controls.Add(box); ttip.SetToolTip(upgradeSlot3, consumable.Name); } else if (consumable.GetSlotNumber() == 4) { upgradeSlot4.Controls.Add(box); ttip.SetToolTip(upgradeSlot4, consumable.Name); } else if (consumable.GetSlotNumber() == 5) { upgradeSlot5.Controls.Add(box); ttip.SetToolTip(upgradeSlot5, consumable.Name); } else if (consumable.GetSlotNumber() == 6) { upgradeSlot6.Controls.Add(box); ttip.SetToolTip(upgradeSlot6, consumable.Name); } applyUpgradeValues(consumable.ID.ToString(), false); } if (cbCamoflage.Checked) { bmHandler.ApplyValue("Camoflage"); } bmHandler.PerformAnimation(true); }