airspec = "航空戦 " + (int)(normal * 0.8) + "/" + (int)(normal * 1.5);\r
}\r
}\r
+\r
equips.Add(new EquipColumn\r
{\r
- Equip = item.Spec.Name +\r
- (item.Alv == 0 ? "" : "+" + item.Alv) +\r
- (item.Level == 0 ? "" : "★" + item.Level) +\r
- (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max),\r
+ Equip = GenEquipString(item, onslot, max),\r
AircraftSpec = airspec,\r
Color = item.Spec.Color\r
});\r
_equipList = list.ToArray();\r
}\r
\r
+ private string GenEquipString(ItemStatus item, int onslot, int max)\r
+ {\r
+ var name = item.Spec.Name;\r
+ var attr = (item.Alv == 0 ? "" : "+" + item.Alv) +\r
+ (item.Level == 0 ? "" : "★" + item.Level) +\r
+ (!item.Spec.IsAircraft ? "" : " " + onslot + "/" + max);\r
+ var proposed = new Size(int.MaxValue, int.MaxValue);\r
+ const int maxWidth = 180;\r
+ var result = name + attr;\r
+ if (TextRenderer.MeasureText(result, Font, proposed).Width <= maxWidth)\r
+ return result;\r
+ attr = " " + attr;\r
+ var truncated = "";\r
+ foreach (var ch in name)\r
+ {\r
+ var tmp = truncated + ch;\r
+ if (TextRenderer.MeasureText(tmp + attr, Font, proposed).Width > maxWidth)\r
+ break;\r
+ truncated = tmp;\r
+ }\r
+ return truncated + attr;\r
+ }\r
+\r
private void CreateEquipLabels()\r
{\r
for (var i = _labelList.Count; i < _equipList.Length; i++)\r
{\r
new ShipLabel {Location = new Point(1, 2), AutoSize = true},\r
new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(40, 2), AutoSize = true},\r
- new ShipLabel {Location = new Point(37, 2), Size = new Size(4, LabelHeight - 2)},\r
+ new ShipLabel {Location = new Point(38, 2), AutoSize = true},\r
+ new ShipLabel {Location = new Point(35, 2), Size = new Size(4, LabelHeight - 2)},\r
new ShipLabel {Location = new Point(217, 2), AutoSize = true, AnchorRight = true}\r
};\r
_labelList.Add(labels);\r