private static void DoActionContent(Rect rect, ref LevelingAction selectedAction) { Rect rowRect = new Rect(rect) { height = 24f }; Rect cooldownCheckbox = new Rect(rowRect) { xMin = rowRect.xMax - rowRect.height }; string cooldownLabel = I18n.CooldownLabel; Vector2 cooldownLabelSize = Text.CalcSize(cooldownLabel); Rect cooldownLabelRect = new Rect(cooldownCheckbox.xMin - cooldownLabelSize.x, rowRect.y, cooldownLabelSize.x, rowRect.height); Widgets.Label(cooldownLabelRect, cooldownLabel); TooltipHandler.TipRegion(cooldownLabelRect, I18n.CooldownOnActionDescription); bool hasCooldown = selectedAction.Cooldown; Widgets.Checkbox(cooldownCheckbox.x, cooldownCheckbox.y, ref hasCooldown); selectedAction.Cooldown = hasCooldown; string actionLabel = selectedAction.ActionDef.label; Vector2 actionLabelSize = Text.CalcSize(actionLabel); actionLabelSize.x += 15f; Rect actionLabelRect = new Rect(rowRect) { width = actionLabelSize.x }; Widgets.Label(actionLabelRect, selectedAction.ActionDef.label.Bolded()); TooltipHandler.TipRegion(actionLabelRect, selectedAction.ActionDef.description); rect.y = rowRect.yMax; Widgets.DrawLineHorizontal(rect.x, rect.y, rect.width); rect.y += 10f; selectedAction.Draw(rect); }
public void Draw(Rect rect, ref IDrawer selectedAction) { float listHeight = actions.Count * 24f; Rect viewRect = new Rect(rect) { xMax = rect.xMax - 15f, height = listHeight }; Widgets.BeginScrollView(rect, ref scrollPosition, viewRect); Rect rowRect = new Rect(viewRect) { height = 24f }; for (int i = 0; i < actions.Count; i++) { LevelingAction action = actions[i]; Rect checkboxRect = new Rect(rowRect) { xMin = rowRect.xMax - rowRect.height, width = rowRect.height }; bool isActive = action.Active; Widgets.Checkbox(checkboxRect.x, checkboxRect.y, ref isActive); action.Active = isActive; Rect labelRect = new Rect(rowRect) { xMax = checkboxRect.xMin }; Widgets.Label(labelRect, action.ActionDef.label); if (Widgets.ButtonInvisible(labelRect)) { SoundDefOf.Click.PlayOneShotOnCamera(); if (selectedAction == action) { selectedAction = Drawer.Empty; } else { selectedAction = action; } } if (selectedAction == action) { Widgets.DrawHighlightSelected(rowRect); } else if (Mouse.IsOver(rowRect)) { Widgets.DrawHighlight(rowRect); } else if (i % 2 != 0) { Widgets.DrawLightHighlight(rowRect); } rowRect.y = rowRect.yMax; } Widgets.EndScrollView(); }