private static double[] CreateColumn(string head, double[] margins, int unitID, Unit unit, ref bool notFirstColumn, ref double lastColumnMaxWidth) { if ((head == "MAGIC ITEMS") && Army.Data.NoMagicItemsColumn) { return(margins); } if (notFirstColumn) { margins[1] += 10; } margins = CheckColumn(margins, ref lastColumnMaxWidth, header: true, newColumn: notFirstColumn); margins[1] += AddLabel(head, margins, 25, ref lastColumnMaxWidth, bold: true, addLine: GetMagicPointsString(unitID, head), fixPadding: 10); int mountAlreadyOn = (unit.MountOn > 0 ? unit.GetMountOption() : 0); Option.OnlyForType mountTypeAlreadyFixed = unit.GetMountTypeAlreadyFixed(); if (head == "SPECIAL RULES") { foreach (string rule in unit.GetSpecialRules()) { margins = CheckColumn(margins, ref lastColumnMaxWidth, sizeCollapse: NotEnoughColumnForThis(rule, 15, margins)); margins[1] += AddLabel((rule == "FC" ? "Full command" : rule), margins, 15, ref lastColumnMaxWidth, fixPadding: 5); } notFirstColumn = true; } else { if ((!unit.ExistsMagicItems() && (head == "MAGIC ITEMS")) || (!unit.ExistsMagicPowers() && (head == Army.Params.MagicPowersName()))) { margins = CheckColumn(margins, ref lastColumnMaxWidth); margins[1] += AddLabel("empty yet", margins, 15, ref lastColumnMaxWidth, fixPadding: 5); notFirstColumn = true; } else { foreach (Option option in unit.Options) { if (head == "OPTION" || head == "COMMAND" || head == "MAGIC ITEMS" || head == Army.Params.MagicPowersName()) { if (head == "OPTION" && (!option.IsOption() || option.FullCommand)) { continue; } if (head == "COMMAND" && !option.FullCommand) { continue; } if (head == "MAGIC ITEMS" && (!option.IsMagicItem() || ((option.Points <= 0) && !option.Honours))) { continue; } if (head == Army.Params.MagicPowersName() && !option.IsPowers()) { continue; } margins = CheckColumn(margins, ref lastColumnMaxWidth); bool canBeUsed = true; if (option.OnlyOneInArmy || option.OnlyOneForSuchUnits) { canBeUsed = (Army.Checks.IsOptionAlreadyUsed(option.Name, unitID, unit.Name, option.OnlyOneForSuchUnits) == 0); } margins[1] += AddButton(option.FullName(), margins, 25, ref lastColumnMaxWidth, String.Format("{0}|{1}", unitID, option.ID), option, mountAlreadyOn: mountAlreadyOn, mountTypeAlreadyFixed: mountTypeAlreadyFixed, unit: unit, mustBeEnabled: canBeUsed); margins[1] += 20; } else { bool thisIsStandartEquipment = !option.IsMagicItem() || (option.Points != 0) || option.Honours || String.IsNullOrEmpty(option.Name); bool thisIsSpecialRuleOrMount = option.Realised && !option.Mount && !option.FullCommand && option.SpecialRuleDescription.Length == 0; if (head == "WEAPONS & ARMOUR" && thisIsStandartEquipment && !thisIsSpecialRuleOrMount) { continue; } if (option.NativeArmour && unit.IsArmourOptionAdded()) { continue; } margins = CheckColumn(margins, ref lastColumnMaxWidth); margins[1] += AddLabel(option.Name, margins, 15, ref lastColumnMaxWidth, fixPadding: 5); } notFirstColumn = true; } } } return(margins); }
private static double AddButton(string caption, double[] margins, double height, ref double lastColumnMaxWidth, string id, Option option, int mountAlreadyOn = 0, Option.OnlyForType mountTypeAlreadyFixed = Option.OnlyForType.All, Unit unit = null, bool mustBeEnabled = true) { bool optionIsEnabled = unit.IsOptionEnabled(option, mountAlreadyOn, mountTypeAlreadyFixed); if (!mustBeEnabled) { optionIsEnabled = false; } if ((unit != null) && unit.IsAnotherOptionIsIncompatible(option)) { optionIsEnabled = false; } AddLabel(caption, margins, height, ref lastColumnMaxWidth, option.Realised, option.Points, option.PerModel, enabled: optionIsEnabled); if (option.IsMagicItem() || option.IsPowers()) { AddButtonPart("drop " + (option.IsPowers() ? "power" : "artefact"), margins, 0, id, ArmyBook.Data.MainColor, 154); return(height); } if (option.Countable != null) { AddButtonsCountable(caption: option.Countable.Value.ToString(), backFirst: ArmyBook.Data.AdditionalColor, backSecond: ArmyBook.Data.MainColor, option: option, unit: unit, margins: margins, id: id, enabled: optionIsEnabled); } else if (!optionIsEnabled) { AddButtonAllParts(captionFirst: String.Empty, captionSecond: String.Empty, backgroundFirst: Brushes.WhiteSmoke, backgroundSecond: Brushes.Gainsboro, margins: margins, id: id, enabled: false); } else if (option.Realised) { AddButtonAllParts(captionFirst: "drop", captionSecond: String.Empty, backgroundFirst: ArmyBook.Data.AdditionalColor, backgroundSecond: ArmyBook.Data.MainColor, margins: margins, id: id); } else { AddButtonAllParts(captionFirst: String.Empty, captionSecond: "add", backgroundFirst: Brushes.LightGray, backgroundSecond: Brushes.Silver, margins: margins, id: id); } return(height); }