public static void Indent(this Listing_Standard obj, float distance = 24f) { if (_curX == null) { _curX = typeof(Listing_Standard).GetField("curX", BindingFlags.Instance | BindingFlags.NonPublic); } var curX = (float)_curX.GetValue(obj); var newX = curX + distance; var curW = obj.ColumnWidth(); var newW = curW - distance; _curX.SetValue(obj, newX); obj.OverrideColumnWidth = newW; }
/// <summary> /// Draws the mod configuration window contents. /// </summary> /// <returns>The final height of the window rect.</returns> /// <param name="rect">Rect</param> public override float DoWindowContents(Rect rect) { var listing = new Listing_Standard(rect); { listing.OverrideColumnWidth = rect.width - 4f; #region Main Toggle var toggleLabel = "MiniMap.MCMToggleMain".Translate(); listing.DoLabelCheckbox(toggleLabel, ref MiniMap.MiniMapController.visible); listing.DoGap(); #endregion #region Handle all MiniMaps and Overlays foreach (var minimap in Controller.Data.MiniMaps) { if (minimap.IsOrHasIConfigurable) { var iMinimap = minimap as IConfigurable; #region Minimap Header MinimapHeader(listing, minimap); #endregion #region Handle MiniMap IConfigurable if (iMinimap != null) { #region Minimap IConfigurable var iMinimapRect = new Rect(listing.Indentation(), listing.CurHeight, listing.ColumnWidth(), 9999f); GUI.BeginGroup(iMinimapRect); var iMinimapHeight = iMinimap.DrawMCMRegion(iMinimapRect.AtZero()); GUI.EndGroup(); listing.DoGap(iMinimapHeight + 6f); #endregion } #endregion #region Handle all MiniMap Overlays foreach (var overlay in minimap.overlayWorkers) { var iOverlay = overlay as IConfigurable; #region Handle Overlay IConfigurable if (iOverlay != null) { #region Overlay Header OverlayHeader(listing, overlay); #endregion #region Overlay IConfigurable var iOverlayRect = new Rect(listing.Indentation(), listing.CurHeight, listing.ColumnWidth(), 9999f); GUI.BeginGroup(iOverlayRect); var iOverlayHeight = iOverlay.DrawMCMRegion(iOverlayRect.AtZero()); GUI.EndGroup(); listing.DoGap(iOverlayHeight + 6f); listing.Undent(); #endregion } #endregion } #endregion #region Final Undentation listing.DoGap(); listing.Undent(); #endregion } } #endregion } listing.End(); return(listing.CurHeight); }