public void Highlight(bool arrow = true, bool colonistBar = true, bool circleOverlay = false) { for (int i = 0; i < this.targets.Count; i++) { TargetHighlighter.Highlight(this.targets[i], arrow, colonistBar, circleOverlay); } }
//Draw selection and mouseover highlights public static void Postfix(Rect rect, Pawn pawn) { //from DoCell: Rect rowRect = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f)); if (Mod.settings.pawnTableHighlightSelected) if (Find.Selector.IsSelected(pawn)) Widgets.DrawHighlightSelected(rowRect); if (Mod.settings.pawnTableArrowMouseover) if (Mouse.IsOver(rowRect)) { Vector3 center = UI.UIToMapPosition((float)(UI.screenWidth / 2), (float)(UI.screenHeight / 2)); bool arrow = (center - pawn.DrawPos).MagnitudeHorizontalSquared() >= 121f;//Normal arrow is 9^2, using 11^1 seems good too. TargetHighlighter.Highlight(pawn, arrow, true, true); } }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); bool none = true; List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach ((Thing thingCandidate, CompIncludedChildParts compDestination) in this.PossibleThings) { none = false; list.Add(new FloatMenuOption( // name thingCandidate.Label.CapitalizeFirst() + (compDestination != this.comp ? " (to " + compDestination.parent.Label + ")" : ""), () => // click action { compDestination.AddPart(thingCandidate); this.comp.DirtyCacheDeep(compDestination); }, // icon thingCandidate.def, MenuOptionPriority.DisabledOption, () => // mouse over action { if (Current.ProgramState == ProgramState.Playing) { // draw arrow pointing to item TargetHighlighter.Highlight(new GlobalTargetInfo(thingCandidate)); } } )); } // only draw the menu if there are things it can add if (none) { Messages.Message("Could not find a compatible part to add.", MessageTypeDefOf.RejectInput); } else { Find.WindowStack.Add(new FloatMenu(list)); } }
public static bool AlertsReadoutUpdate(AlertsReadout __instance) { if (!Analyzer.Settings.OverrideAlerts && !AnalyzerState.CurrentlyRunning) { return(true); } if (!Active) { return(true); } if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600) { return(false); } if (Find.Storyteller.def.disableAlerts) { __instance.activeAlerts.Clear(); return(false); } __instance.curAlertIndex++; if (__instance.curAlertIndex >= 24) { __instance.curAlertIndex = 0; } for (int i = __instance.curAlertIndex; i < __instance.AllAlerts.Count; i += 24) { __instance.CheckAddOrRemoveAlert(__instance.AllAlerts[i], false); } if (Time.frameCount % 20 == 0) { List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading; for (int j = 0; j < questsListForReading.Count; j++) { List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading; for (int k = 0; k < partsListForReading.Count; k++) { QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable; Alert cachedAlert = questPartActivable?.CachedAlert; if (cachedAlert != null) { bool flag = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled; bool alertDirty = questPartActivable.AlertDirty; __instance.CheckAddOrRemoveAlert(cachedAlert, flag || alertDirty); if (alertDirty) { questPartActivable.ClearCachedAlert(); } } } } } for (int l = __instance.activeAlerts.Count - 1; l >= 0; l--) { Alert alert = __instance.activeAlerts[l]; try { var prof = Analyzer.Start(__instance.activeAlerts[l].GetHashCode().ToString(), () => __instance.activeAlerts[l] + " Update", __instance.activeAlerts[l].GetType()); __instance.activeAlerts[l].AlertActiveUpdate(); prof.Stop(); } catch (Exception ex) { Log.ErrorOnce($"Analyzer: Exception updating alert {alert.ToString()}, errored with the message {ex.ToString()}", 743575, false); __instance.activeAlerts.RemoveAt(l); } } if (__instance.mouseoverAlertIndex >= 0 && __instance.mouseoverAlertIndex < __instance.activeAlerts.Count) { IEnumerable <GlobalTargetInfo> allCulprits = __instance.activeAlerts[__instance.mouseoverAlertIndex].GetReport().AllCulprits; if (allCulprits != null) { foreach (GlobalTargetInfo target in allCulprits) { TargetHighlighter.Highlight(target, true, true, false); } } } __instance.mouseoverAlertIndex = -1; return(false); }
private void DrawObjectiveTab(Rect TabRect, Objective objective, int num) { if (num % 2 == 0) { Widgets.DrawBoxSolid(TabRect, new ColorInt(50, 50, 50).ToColor); } //Setup ObjectiveDef Def = objective.def; TabRect = TabRect.ContractedBy(5f); GUI.BeginGroup(TabRect); //Label string Label = Def.LabelCap; Vector2 LabelSize = Text.CalcSize(Label); Rect LabelRect = new Rect(new Vector2(0f, 0f), LabelSize); Widgets.Label(LabelRect, Label); //Target string TargetLabel = ResolveTargetLabel(Def); Vector2 TargetSize = Text.CalcSize(TargetLabel); Rect TargetRect = new Rect(new Vector2(0f, TabRect.height - TargetSize.y), TargetSize); Rect InfoCardRect = new Rect(TargetLabel.NullOrEmpty() ? -5f : TargetRect.xMax, TargetRect.y, TargetRect.height, TargetRect.height); if (!TargetLabel.NullOrEmpty()) { bool MouseOver = Mouse.IsOver(TargetRect); GUI.color = MouseOver ? new Color(0.8f, 0.8f, 0.8f) : new Color(0.6f, 0.6f, 0.6f); Widgets.Label(TargetRect, TargetLabel); GUI.color = Color.white; } Rect InfoCardAreaRect = new Rect(TargetRect.x, TargetRect.y, TargetRect.width + InfoCardRect.width, TargetRect.height); TooltipHandler.TipRegion(InfoCardAreaRect, "InfoCard_SMO".Translate()); if (Widgets.ButtonInvisible(TargetRect) || Widgets.ButtonImage(InfoCardRect, StoryMats.info2, GUI.color)) { Find.WindowStack.Add(CurObjectiveInfo = new Dialog_ObjectiveInformation(objective)); } UIHighlighter.HighlightOpportunity(InfoCardRect, "InfoCard"); //ProgressBar Vector2 size = new Vector2(90f, 20f); Rect BarRect = new Rect(); Rect BotBarRect = new Rect(); ResolveBarInputs(objective, out float pct, out string label, out Texture2D material); if (material != null) { BarRect = new Rect(new Vector2(TabRect.xMax - (size.x + 5f), 0f), size); DrawProgressBar(BarRect, label, pct, material); if (objective.thingTracker?.ResolveButtonInput(BarRect) ?? false) { TooltipHandler.TipRegion(BarRect, "BarInput_SMO".Translate()); } } if (objective.def.timer.GetTotalTime > 0) { BotBarRect = new Rect(new Vector2(TabRect.xMax - (size.x + 5f), TabRect.height - (size.y + 5f)), size); float timer = objective.GetTimer; pct = timer / objective.def.timer.GetTotalTime; label = StoryUtils.GetTimerText(objective.GetTimer, objective.CurrentState); if (objective.CurrentState == MOState.Finished) { pct = 0f; } DrawProgressBar(BotBarRect, label, pct, StoryMats.grey); } //SkillRequirements Rect SkillRequirementRect = new Rect(); if (objective.def.skillRequirements.Count > 0) { bool check = BarRect.width + BotBarRect.width > 0f; SkillRequirementRect = new Rect(TabRect.xMax - (10f + (check ? 180f : 90f)), 0f, 90f, TabRect.height); bool MouseOver = Mouse.IsOver(SkillRequirementRect); GUI.color = MouseOver ? new Color(0.8f, 0.8f, 0.8f) : new Color(0.6f, 0.6f, 0.6f); Text.Anchor = TextAnchor.UpperCenter; Text.Font = GameFont.Medium; int count = 0; if (cachedPawns.TryGetValue(objective.def, out List <Pawn> pawns)) { if (!pawns.NullOrEmpty()) { count = pawns.Count; } } Widgets.Label(SkillRequirementRect, count.ToString()); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerCenter; Widgets.Label(SkillRequirementRect, count != 1 ? "SkillReqPlural_SMO".Translate() : "SkillReq_SMO".Translate()); Text.Font = GameFont.Small; Text.Anchor = 0; GUI.color = Color.white; StringBuilder sb = new StringBuilder(); if (!pawns.NullOrEmpty()) { foreach (Pawn pawn in pawns) { sb.AppendLine(" - " + pawn.LabelCap); } } StringBuilder sb2 = new StringBuilder(); foreach (SkillRequirement sr in objective.def.skillRequirements) { sb2.AppendLine(" - " + sr.Summary); } TooltipHandler.TipRegion(SkillRequirementRect, pawns.NullOrEmpty() ? "PawnListEmpty_SMO".Translate(sb2) : "PawnList_SMO".Translate(sb)); } GUI.EndGroup(); SkillRequirementRect.x += 5f; SkillRequirementRect.y += 5f + (TabRect.height * num); bool mouseOnSkill = Mouse.IsOver(SkillRequirementRect); if (mouseOnSkill) { List <Pawn> pawns = cachedPawns.TryGetValue(objective.def); foreach (Pawn pawn in pawns) { if (pawn != null) { TargetHighlighter.Highlight(pawn, false, true, false); } } } if (Widgets.ButtonInvisible(TabRect, true)) { if (mouseOnSkill) { Find.Selector.SelectedObjects.Clear(); if (cachedPawns.TryGetValue(objective.def, out List <Pawn> pawns)) { if (!pawns.NullOrEmpty()) { CameraJumper.TryJumpAndSelect(pawns.RandomElement()); this.Close(); } } } SoundDefOf.Click.PlayOneShotOnCamera(null); SelectedObjective = objective; } TabRect = TabRect.ExpandedBy(5f); if (objective.CurrentState == MOState.Failed) { GUI.color = Color.red; Widgets.DrawHighlight(TabRect); GUI.color = Color.white; } bool mouseOver = Mouse.IsOver(TabRect); if (mouseOver || this.SelectedObjective == objective) { GUI.color = mouseOver ? new Color(0.3f, 0.3f, 0.3f) : new Color(0.5f, 0.5f, 0.5f); Widgets.DrawBox(TabRect, 1); GUI.color = Color.white; } }
public static bool AlertsReadoutUpdate(AlertsReadout __instance) { if (runonce && RimThreadedMod.Settings.showModConflictsAlert) { RimThreadedMod.getPotentialModConflicts_2(); //Not sure where to put this, making it run on the main menu without black screen will have been perfect. runonce = false; } if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600) { return(false); } if (Find.Storyteller.def != null && Find.Storyteller.def.disableAlerts) { activeAlerts(__instance).Clear(); return(false); } if (TickManager_Patch.curTimeSpeed(Find.TickManager) == TimeSpeed.Ultrafast && RimThreadedMod.Settings.disablesomealerts) { //this will disable alert checks on ultrafast speed for an added speed boost return(false); } curAlertIndex(__instance)++; if (curAlertIndex(__instance) >= 24) { curAlertIndex(__instance) = 0; } for (int i = curAlertIndex(__instance); i < AllAlerts(__instance).Count; i += 24) { //CheckAddOrRemoveAlert2(__instance, AllAlerts(__instance)[i]); actionCheckAddOrRemoveAlert(__instance, AllAlerts(__instance)[i], false); } if (Time.frameCount % 20 == 0) { List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading; for (int j = 0; j < questsListForReading.Count; j++) { List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading; for (int k = 0; k < partsListForReading.Count; k++) { QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable; if (questPartActivable == null) { continue; } Alert cachedAlert = questPartActivable.CachedAlert; if (cachedAlert != null) { bool flag = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled; bool alertDirty = questPartActivable.AlertDirty; //CheckAddOrRemoveAlert(__instance, cachedAlert, flag || alertDirty); actionCheckAddOrRemoveAlert(__instance, cachedAlert, flag || alertDirty); if (alertDirty) { questPartActivable.ClearCachedAlert(); } } } } } for (int num = activeAlerts(__instance).Count - 1; num >= 0; num--) { Alert alert = activeAlerts(__instance)[num]; try { activeAlerts(__instance)[num].AlertActiveUpdate(); } catch (Exception ex) { Log.ErrorOnce("Exception updating alert " + alert.ToString() + ": " + ex.ToString(), 743575); activeAlerts(__instance).RemoveAt(num); } } if (mouseoverAlertIndex(__instance) >= 0 && mouseoverAlertIndex(__instance) < activeAlerts(__instance).Count) { IEnumerable <GlobalTargetInfo> allCulprits = activeAlerts(__instance)[mouseoverAlertIndex(__instance)].GetReport().AllCulprits; if (allCulprits != null) { foreach (GlobalTargetInfo item in allCulprits) { TargetHighlighter.Highlight(item); } } } mouseoverAlertIndex(__instance) = -1; return(false); }
public static bool AlertsReadoutUpdate(AlertsReadout __instance) { if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600) { return(false); } if (Find.Storyteller.def != null && Find.Storyteller.def.disableAlerts) { activeAlerts(__instance).Clear(); return(false); } curAlertIndex(__instance)++; if (curAlertIndex(__instance) >= 24) { curAlertIndex(__instance) = 0; } for (int i = curAlertIndex(__instance); i < AllAlerts(__instance).Count; i += 24) { CheckAddOrRemoveAlert2(__instance, AllAlerts(__instance)[i]); } if (Time.frameCount % 20 == 0) { List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading; for (int j = 0; j < questsListForReading.Count; j++) { List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading; for (int k = 0; k < partsListForReading.Count; k++) { QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable; if (questPartActivable == null) { continue; } Alert cachedAlert = questPartActivable.CachedAlert; if (cachedAlert != null) { bool flag = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled; bool alertDirty = questPartActivable.AlertDirty; CheckAddOrRemoveAlert2(__instance, cachedAlert, flag || alertDirty); if (alertDirty) { questPartActivable.ClearCachedAlert(); } } } } } for (int num = activeAlerts(__instance).Count - 1; num >= 0; num--) { Alert alert = activeAlerts(__instance)[num]; try { activeAlerts(__instance)[num].AlertActiveUpdate(); } catch (Exception ex) { Log.ErrorOnce("Exception updating alert " + alert.ToString() + ": " + ex.ToString(), 743575); activeAlerts(__instance).RemoveAt(num); } } if (mouseoverAlertIndex(__instance) >= 0 && mouseoverAlertIndex(__instance) < activeAlerts(__instance).Count) { IEnumerable <GlobalTargetInfo> allCulprits = activeAlerts(__instance)[mouseoverAlertIndex(__instance)].GetReport().AllCulprits; if (allCulprits != null) { foreach (GlobalTargetInfo item in allCulprits) { TargetHighlighter.Highlight(item); } } } mouseoverAlertIndex(__instance) = -1; return(false); }
private void DoThingRow(ThingDef thingDef, int count, List <Thing> things, float width, ref float curY, Action <int> discardAction) { Rect rect = new Rect(0f, curY, width, 28f); if (count != 1) { Rect butRect = new Rect(rect.x + rect.width - 24f, rect.y + (rect.height - 24f) / 2f, 24f, 24f); if (Widgets.ButtonImage(butRect, CaravanThingsTabUtility.AbandonSpecificCountButtonTex)) { Find.WindowStack.Add(new Dialog_Slider("RemoveSliderText".Translate(thingDef.label), 1, count, discardAction, int.MinValue)); } } rect.width -= 24f; Rect butRect2 = new Rect(rect.x + rect.width - 24f, rect.y + (rect.height - 24f) / 2f, 24f, 24f); if (Widgets.ButtonImage(butRect2, CaravanThingsTabUtility.AbandonButtonTex)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmRemoveItemDialog".Translate(thingDef.label), delegate { discardAction(count); }, false, null)); } rect.width -= 24f; if (things.Count == 1) { Widgets.InfoCardButton(rect.width - 24f, curY, things[0]); } else { Widgets.InfoCardButton(rect.width - 24f, curY, thingDef); } rect.width -= 24f; if (Mouse.IsOver(rect)) { GUI.color = ITab_PitContents.ThingHighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thingDef.DrawMatSingle != null && thingDef.DrawMatSingle.mainTexture != null) { Rect rect2 = new Rect(4f, curY, 28f, 28f); if (things.Count == 1) { Widgets.ThingIcon(rect2, things[0], 1f); } else { Widgets.ThingIcon(rect2, thingDef); } } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_PitContents.ThingLabelColor; Rect rect3 = new Rect(36f, curY, rect.width - 36f, rect.height); string str; if (things.Count == 1) { str = things[0].LabelCap; } else { str = GenLabel.ThingLabel(thingDef, null, count).CapitalizeFirst(); } Text.WordWrap = false; Widgets.Label(rect3, str.Truncate(rect3.width, null)); Text.WordWrap = true; Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, str); if (Widgets.ButtonInvisible(rect, false)) { this.SelectLater(things); } if (Mouse.IsOver(rect)) { for (int i = 0; i < things.Count; i++) { TargetHighlighter.Highlight(things[i], true, true, false); } } curY += 28f; }