void DrawDisplayArea(Rect rect) { Widgets.DrawMenuSection(rect); if (SelectedItemDef == null) { return; } Text.Font = GameFont.Medium; Text.WordWrap = false; float titleWidth = Text.CalcSize(SelectedItemDef.label).x; var titleRect = new Rect(rect.xMin + WindowMargin, rect.yMin + WindowMargin, titleWidth, 60f); if ((SelectedItemDef.keyObject != null) && (SelectedItemDef.keyObject is Def keyDef) && (keyDef.IconTexture() != null)) { var iconRect = new Rect(titleRect.xMin + WindowMargin, rect.yMin + WindowMargin, 60f - 2 * WindowMargin, 60f - 2 * WindowMargin); titleRect.x += 60f; keyDef.DrawColouredIcon(iconRect); } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(titleRect, SelectedItemDef.label); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; Rect outRect = rect.ContractedBy(WindowMargin); outRect.yMin += 60f; Rect viewRect = outRect; viewRect.width = ContentWidth - 16f; viewRect.height = ContentHeight; GUI.BeginGroup(outRect); Widgets.BeginScrollView(outRect.AtZero(), ref DisplayScrollPos, viewRect.AtZero()); Vector3 cur = Vector3.zero; DetailSectionHelper.DrawText(ref cur, viewRect.width, SelectedItemDef.description); cur.y += ParagraphMargin; foreach (DetailWrapper section in SelectedItemDef.HelpDetailWrappers) { section.Draw(ref cur, outRect.width, this); } ContentHeight = cur.y; ContentWidth = cur.z + 20f; if (ContentWidth < outRect.width) { ContentWidth = outRect.width; } Widgets.EndScrollView(); GUI.EndGroup(); }
public void Initialize() { FieldDescs = rawFields != null?DetailSectionHelper.BuildFieldDescList(parentObject, rawFields, parentDesc) : null; }