public void Draw(ref Vector2 cur, float width, IHelpDefView window = null) { // Draw section header, if any if (!Label.NullOrEmpty()) { var labelRect = new Rect(cur.x, cur.y, width, 20f); Widgets.Label(labelRect, Label); cur.y += 20f - MainTabWindow_ModHelp.LineHeigthOffset; } // respect tabs! cur.x += Inset; // make sure column widths have been calculated if (!WidthsSet) { SetColumnWidths(width - Inset); } // draw lines one by one if (!StringDescs.NullOrEmpty()) { foreach (var triplet in StringDescs) { triplet.Draw(ref cur, ColumnWidths); } } if (!KeyDefs.NullOrEmpty()) { foreach (var triplet in KeyDefs) { triplet.Draw(ref cur, ColumnWidths, window); } } // add some extra space, reset inset cur.y += MainTabWindow_ModHelp.ParagraphMargin; cur.x -= Inset; // done! }
public void Draw(ref Vector2 cur, Vector3 colWidths, IHelpDefView window = null) { // calculate height of row, or fetch from cache if (!_heightSet) { List <float> heights = new List <float>(); if (!Prefix.NullOrEmpty()) { heights.Add(Text.CalcHeight(Prefix, colWidths.x)); } heights.Add(Text.CalcHeight(Def.LabelStyled(), colWidths.y)); if (!Suffix.NullOrEmpty()) { heights.Add(Text.CalcHeight(Suffix, colWidths.z)); } _height = heights.Max(); _heightSet = true; } // draw text if (!Prefix.NullOrEmpty()) { Rect prefixRect = new Rect(cur.x, cur.y, colWidths.x, _height); Widgets.Label(prefixRect, Prefix); } if (!Suffix.NullOrEmpty()) { Rect suffixRect = new Rect(cur.x + colWidths.x + colWidths.y + 2 * HelpDetailSection._columnMargin, cur.y, colWidths.z, _height); Widgets.Label(suffixRect, Suffix); } Rect labelRect; if (Def.IconTexture() != null) { Rect iconRect = new Rect(cur.x + colWidths.x + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y + 2f, 16f, 16f); labelRect = new Rect(cur.x + colWidths.x + 20f + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y, colWidths.y - 20f, _height); Def.DrawColouredIcon(iconRect); Widgets.Label(labelRect, Def.LabelStyled()); } else { labelRect = new Rect(cur.x + colWidths.x + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y, colWidths.y, _height); Widgets.Label(labelRect, Def.LabelStyled()); } // def interactions (if any) // if we have a window set up to catch jumps, and there is a helpdef available, draw a button on the def text. HelpDef helpDef = Def.GetHelpDef(); if ( (window != null) && (helpDef != null) ) { TooltipHandler.TipRegion(labelRect, Def.description + (Def.description.NullOrEmpty() ? "" : "\n\n") + "JumpToTopic".Translate()); if (Widgets.InvisibleButton(labelRect)) { if (window.Accept(helpDef)) { window.JumpTo(helpDef); } else { window.SecondaryView(helpDef).JumpTo(helpDef); } } } if ( (helpDef == null) && (!Def.description.NullOrEmpty()) ) { TooltipHandler.TipRegion(labelRect, Def.description); } cur.y += _height - MainTabWindow_ModHelp.LineHeigthOffset; }
public void Draw( ref Vector2 cur, float width, IHelpDefView window = null ) { // Draw section header, if any if ( !Label.NullOrEmpty() ) { Rect labelRect = new Rect( cur.x, cur.y, width, 20f ); Widgets.Label( labelRect, Label ); cur.y += 20f - MainTabWindow_ModHelp.LineHeigthOffset; } // respect tabs! cur.x += Inset; // make sure column widths have been calculated if ( !WidthsSet ) { SetColumnWidths( width - Inset ); } // draw lines one by one if( !StringDescs.NullOrEmpty() ) { foreach( StringDescTriplet triplet in StringDescs ) { triplet.Draw( ref cur, ColumnWidths ); } } if( !KeyDefs.NullOrEmpty() ) { foreach( DefStringTriplet triplet in KeyDefs ) { triplet.Draw( ref cur, ColumnWidths, window ); } } // add some extra space, reset inset cur.y += MainTabWindow_ModHelp.ParagraphMargin; cur.x -= Inset; // done! }