public static void DrawSkillBoxFor(float x, float y, Pawn p, SkillDef skillDef, bool incapableBecauseOfCapacities) { Rect rect = new Rect(x, y, 50f, 25f); if (incapableBecauseOfCapacities) { GUI.color = new Color(1f, 0.3f, 0.3f); } DrawWorkBoxBackground(rect, p, skillDef); GUI.color = Color.white; int skillLevel = p.skills.GetSkill(skillDef).Level; if (skillLevel > 0) { Text.Anchor = TextAnchor.MiddleCenter; GUI.color = WidgetsWork.ColorOfPriority((int)(((float)skillLevel) / 5.0f)); Widgets.Label(rect.ContractedBy(-3f), skillLevel.ToStringCached()); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } if (Event.current.type != 0 || !Mouse.IsOver(rect)) { return; } if (Event.current.button == 0) { p.skills.GetSkill(skillDef).Level++; } if (Event.current.button == 1) { p.skills.GetSkill(skillDef).Level--; } Event.current.Use(); }
private void DrawPawnWorkPriority(ref float curY, float width, WorkTypeDef workTypeDef, Priority priority) { try { if (PawnForWork.Dead || PawnForWork.workSettings == null || !PawnForWork.workSettings.EverWork) { return; } int p = priority.ToGamePriority(); if (!Prefs.DevMode && this.PawnForWork.GetDisabledWorkTypes(true).Contains(workTypeDef)) { return; } GUI.color = Color.white; Text.Font = GameFont.Small; string t = priority.GetTip(); Func <string> textGetter = delegate() { return(t); }; Rect rect = new Rect(10f, curY, width - 10f, 20f); if (Mouse.IsOver(rect)) { GUI.color = highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); TooltipHandler.TipRegion(rect, new TipSignal(textGetter, PawnForWork.thingIDNumber ^ (int)workTypeDef.index)); } GUI.color = WidgetsWork.ColorOfPriority(p); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect, workTypeDef.pawnLabel); if (p == 0) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.center.y, rect.width); } } catch { Logger.Message("could not draw pawn work priority"); } curY += 20f; }
protected virtual void DrawPawnRow(Rect r, Droid p) { float num = 175f; Text.Font = GameFont.Medium; for (int i = 0; i < OTab_Droid_Work.VisibleWorkTypeDefsInPriorityOrder.Count; i++) { WorkTypeDef workTypeDef = OTab_Droid_Work.VisibleWorkTypeDefsInPriorityOrder[i]; Vector2 topLeft = new Vector2(num, r.y + 2.5f); if (p.story != null && p.work.Contains(workTypeDef)) { WidgetsWork.DrawWorkBoxFor(topLeft, p, workTypeDef); } Rect rect2 = new Rect(topLeft.x, topLeft.y, 25f, 25f); TooltipHandler.TipRegion(rect2, WidgetsWork.TipForPawnWorker(p, workTypeDef)); num += this.workColumnSpacing; } }
public static string TipForPawnWorker(Pawn pawn, WorkTypeDef worktype, bool incapableBecauseOfCapacities) { string tip = WidgetsWork.TipForPawnWorker(pawn, worktype, incapableBecauseOfCapacities); var tracker = PriorityManager.Get[pawn]; if (tracker.EverScheduled(worktype)) { tip += "\n\n" + "WorkTab.XIsAssignedToY".Translate(pawn.Name.ToStringShort, worktype.gerundLabel); } if (tracker.TimeScheduled(worktype)) { tip += tracker.TimeScheduledTip(worktype); } return(tip); }
public string GetTip() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(workTypeDef.description); if (!this.disabled) { int p = this.ToGamePriority(); string str = string.Format("Priority{0}", p).Translate(); string text = str.Colorize(WidgetsWork.ColorOfPriority(p)); stringBuilder.AppendLine(text); stringBuilder.AppendLine("------------------------------"); } foreach (string adj in this.adjustmentStrings) { stringBuilder.AppendLine(adj); } return(stringBuilder.ToString()); }
private void DrawPawnOverviewRow(Pawn pawn, Rect rect) { // column width float colWidth = rect.width / 4 - Margin; // cell rects var nameRect = new Rect(colWidth * 0, rect.yMin, colWidth, RowHeightPawnOverview); var activityRect = new Rect(colWidth * 1, rect.yMin, colWidth * 2.5f, RowHeightPawnOverview); var priorityRect = new Rect(colWidth * 3.5f, rect.yMin, colWidth * .5f, RowHeightPawnOverview); // name Widgets.DrawHighlightIfMouseover(nameRect); // on click select and jump to location if (Widgets.ButtonInvisible(nameRect)) { Find.MainTabsRoot.EscapeCurrentTab(); Find.CameraDriver.JumpTo(pawn.PositionHeld); Find.Selector.ClearSelection(); if (pawn.Spawned) { Find.Selector.Select(pawn); } } Utilities.Label(nameRect, pawn.NameStringShort, "FM.ClickToJumpTo".Translate(pawn.LabelCap), TextAnchor.MiddleLeft, Margin); // current activity (if curDriver != null) string activityString = pawn.jobs.curDriver?.GetReport() ?? "FM.NoCurJob".Translate(); Utilities.Label(activityRect, activityString, pawn.jobs.curDriver?.GetReport(), TextAnchor.MiddleCenter, Margin, font: GameFont.Tiny); // priority button Rect priorityPosition = new Rect(0f, 0f, 24f, 24f).CenteredOnXIn(priorityRect) .CenteredOnYIn(priorityRect); Text.Font = GameFont.Medium; WidgetsWork.DrawWorkBoxFor(priorityPosition.xMin, priorityPosition.yMin, pawn, WorkTypeDef, false); Text.Font = GameFont.Small; }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (pawn is Droid) { Droid droid = pawn as Droid; if (!pawn.Dead && pawn.workSettings != null && pawn.workSettings.EverWork) { Text.Font = GameFont.Medium; float x = rect.x + (rect.width - 25f) / 2f; float y = rect.y + 2.5f; bool incapable = false;// IsIncapableOfWholeWorkType(pawn, def.workType); if (droid.aiPackages.CapableOfWorkType(def.workType)) { WidgetsWork.DrawWorkBoxFor(x, y, pawn, def.workType, incapable); } Rect rect2 = new Rect(x, y, 25f, 25f); TooltipHandler.TipRegion(rect2, () => WidgetsWork.TipForPawnWorker(pawn, def.workType, incapable), pawn.thingIDNumber ^ def.workType.GetHashCode()); Text.Font = GameFont.Small; } } }
private static Color ColorOfPriority(int priority) { return(WidgetsWork.ColorOfPriority(priority)); }