public override void OnGUI(LocalTargetInfo target) { bool flag = ability.EffectComps.Any((CompAbilityEffect e) => e.Props.psychic); Texture2D texture2D = UIIcon; if (!Psycast.CanApplyPsycastTo(target)) { texture2D = TexCommand.CannotShoot; DrawIneffectiveWarning(target); } if (target.IsValid && CanHitTarget(target) && IsApplicableTo(target)) { if (flag) { foreach (LocalTargetInfo affectedTarget in ability.GetAffectedTargets(target)) { if (Psycast.CanApplyPsycastTo(affectedTarget)) { DrawSensitivityStat(affectedTarget); } else { DrawIneffectiveWarning(affectedTarget); } } } if (ability.EffectComps.Any((CompAbilityEffect e) => !e.Valid(target))) { texture2D = TexCommand.CannotShoot; } } else { texture2D = TexCommand.CannotShoot; } if (ThingRequiringRoyalPermissionUtility.IsViolatingRulesOfAnyFaction_NewTemp(HediffDefOf.PsychicAmplifier, CasterPawn, Psycast.def.level, ignoreSilencer: true) && Psycast.def.DetectionChance > 0f) { TaggedString taggedString = ((string)"Illegal".Translate()).ToUpper() + "\n" + Psycast.def.DetectionChance.ToStringPercent() + " " + "DetectionChance".Translate(); Text.Font = GameFont.Small; GenUI.DrawMouseAttachment(texture2D, taggedString, 0f, default(Vector2), null, drawTextBackground: true, new Color(0.25f, 0f, 0f)); } else { GenUI.DrawMouseAttachment(texture2D); } DrawAttachmentExtraLabel(target); }
private void DrawSkill(Rect rect, Pawn ownerPawn) { if (ownerPawn.RaceProps.IsMechanoid) { return; } if (ownerPawn.RaceProps.Animal) { return; } SkillRecord skill = ownerPawn.skills.GetSkill((SkillDef)displayObject); GUI.BeginGroup(rect); Rect position = new Rect(3f, 3f, 24f, 24f); if (skill.passion > Passion.None) { Texture2D image = (skill.passion != Passion.Major) ? passionMinorIcon : passionMajorIcon; GUI.DrawTexture(position, image); } if (!skill.TotallyDisabled) { Rect rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, (float)skill.Level / 20f, SkillBarFillTex, SkillBarBgTex, false); } Rect rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); rect4.yMin += 3f; string label; if (skill.TotallyDisabled) { GUI.color = DisabledSkillColor; label = "-"; } else { label = skill.Level.ToStringCached(); } GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); TooltipHandler.TipRegion(rect, new TipSignal((string)mGetSkillDescription.Invoke(null, new[] { skill }), skill.def.GetHashCode() * 397945)); }
private static bool Prefix_AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo localTargetInfo3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { LocalTargetInfo localTargetInfo4 = localTargetInfo3; var victim = (Pawn)localTargetInfo4.Thing; MutagenDef mutagen = MutagenDefOf.MergeMutagen; if (mutagen.CanTransform(victim) && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_MutagenChamber.FindCryptosleepCasketFor(victim, pawn, true) != null) { string text4 = "CarryToChamber".Translate(localTargetInfo4.Thing.LabelCap, localTargetInfo4.Thing); JobDef jDef = Mutagen_JobDefOf.CarryToMutagenChamber; Action action3 = delegate { Building_MutagenChamber building_chamber = Building_MutagenChamber.FindCryptosleepCasketFor(victim, pawn); if (building_chamber == null) { building_chamber = Building_MutagenChamber.FindCryptosleepCasketFor(victim, pawn, true); } if (building_chamber == null) { Messages.Message("CannotCarryToChamber".Translate() + ": " + "NoChamber".Translate(), victim, MessageTypeDefOf.RejectInput, false); return; } var job = new Job(jDef, victim, building_chamber); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; string label = text4; Action action2 = action3; Pawn revalidateClickTarget = victim; opts.Add(FloatMenuUtility .DecoratePrioritizedTask(new FloatMenuOption(label, action2, MenuOptionPriority.Default, null, revalidateClickTarget), pawn, victim)); } } } return(true); }
private void DrawOutfitApparel(float x, int y, float width, float height) { #if TRACE && CUSTOM_OUTFIT_UI Log.Warning("Begin CustomOutfitUI.DrawOutfitApparel " + x + " " + y); #endif if (pawn != null && this.outfitTracker != null && this.customOutfit != null) { Widgets.Label(new Rect(x, y, 150, 30), "ChangeDresser.CustomOutfitApparel".Translate()); y += HEIGHT + Y_BUFFER; Rect apparelListRect = new Rect(x, y, width - 10, height); Rect apparelScrollRect = new Rect(0f, 0f, apparelListRect.width - 16f, this.customOutfit.Apparel.Count * CELL_HEIGHT); GUI.BeginGroup(apparelListRect); this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect); for (int i = 0; i < this.customOutfit.Apparel.Count; ++i) { Apparel apparel = this.customOutfit.Apparel[i]; Rect rowRect = new Rect(0, 2f + i * CELL_HEIGHT, apparelListRect.width, CELL_HEIGHT); GUI.BeginGroup(rowRect); if (Widgets.ButtonImage(new Rect(5, 10, 20, 20), WidgetUtil.previousTexture)) { this.RemoveApparelFromOutfit(apparel); break; } Widgets.ThingIcon(new Rect(35f, 0f, CELL_HEIGHT, CELL_HEIGHT), apparel); if (Widgets.InfoCardButton(75, 0, apparel)) { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); } Widgets.Label(new Rect(30 + CELL_HEIGHT + 45f, 0f, rowRect.width - CELL_HEIGHT - 45f, CELL_HEIGHT), apparel.Label); this.UpdateAvailableApparel(); GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } #if TRACE && CUSTOM_OUTFIT_UI Log.Warning("End CustomOutfitUI.DrawOutfitApparel " + x + " " + y); #endif }
protected override void FillTab() { Building_SecurityCamera bpm = this.SelThing as Building_SecurityCamera; Text.Font = GameFont.Small; Rect innerRect1 = GenUI.GetInnerRect(new Rect(10.0f, 10.0f, this.size.x - 10, this.size.y - 10)); GUI.BeginGroup(innerRect1); Widgets.Label(new Rect(0, 5, this.size.x / 2, 30), "Area Name:"); bpm.markerName = Widgets.TextField(new Rect(90, 0, this.size.x / 2, 30), bpm.markerName.Substring(0, Math.Min(bpm.markerName.Length, 20))); GenUI.AbsorbClicksInRect(innerRect1); GUI.EndGroup(); }
//public static Rect DrawElementStack<T>(Rect rect, float rowHeight, List<T> elements, StackElementDrawer<T> drawer, StackElementWidthGetter<T> widthGetter, float rowMargin = 4f, float elementMargin = 5f, bool allowOrderOptimization = true) public static Rect DrawElementStack2(Rect rect, float rowHeight, List <GenUI.AnonymousStackElement> elements, GenUI.StackElementDrawer <GenUI.AnonymousStackElement> drawer, GenUI.StackElementWidthGetter <GenUI.AnonymousStackElement> widthGetter, float rowMargin, float elementMargin, bool allowOrderOptimization, Hediff hediff) { if (PriorityCareComp.Get().TryGetValue(hediff, out MedicalCareCategory heCare)) { elements.Add(new GenUI.AnonymousStackElement { drawer = delegate(Rect r) { Texture2D tex = ((Texture2D[])careTexturesField.GetValue(null))[(int)heCare]; r = new Rect(2 * rect.x + rect.width - r.x - 20f, r.y, 20f, 20f); GUI.DrawTexture(r, tex); }, width = 20f }); } return(GenUI.DrawElementStack(rect, rowHeight, elements, drawer, widthGetter, rowMargin, elementMargin, allowOrderOptimization)); }
static List <FloatMenuOption> AddPrioritizingPartPowerOption(List <FloatMenuOption> __result, Vector3 clickPos, Pawn pawn) { if (pawn.Downed || !PartEnergyNeed.HasNeed(pawn)) { return(__result); } foreach (var target in GenUI.TargetsAt(clickPos, ForChargers, false)) { if (ChargeSourceUtility.FindSources(target.Thing).Any(charger => charger.Available)) { __result.Add(CreateMenuOption(target.Thing, pawn, target)); } } return(__result); }
public void ResourceReadoutOnGUI() { if (Event.current.type == EventType.Layout) { return; } if (Current.ProgramState != ProgramState.Playing) { return; } if (Find.MainTabsRoot.OpenTab == MainButtonDefOf.Menu) { return; } GenUI.DrawTextWinterShadow(new Rect(256f, 512f, -256f, -512f)); Text.Font = GameFont.Small; Rect rect = (!Prefs.ResourceReadoutCategorized) ? new Rect(7f, 7f, 110f, (float)(UI.screenHeight - 7) - 200f) : new Rect(2f, 7f, 124f, (float)(UI.screenHeight - 7) - 200f); Rect rect2 = new Rect(0f, 0f, rect.width, this.lastDrawnHeight); bool flag = rect2.height > rect.height; if (flag) { Widgets.BeginScrollView(rect, ref this.scrollPosition, rect2, false); } else { this.scrollPosition = Vector2.zero; GUI.BeginGroup(rect); } if (!Prefs.ResourceReadoutCategorized) { this.DoReadoutSimple(rect2, rect.height); } else { this.DoReadoutCategorized(rect2); } if (flag) { Widgets.EndScrollView(); } else { GUI.EndGroup(); } }
/// <summary> /// Initializes static members of the <see cref="Dialog_StuffAndQuality"/> class. /// </summary> static Dialog_StuffAndQuality() { // Set size. float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(12)); _initialSize = new Vector2(width, Verse.UI.screenHeight / 3f + GenUI.ListSpacing); _initialSizeForWeapon = new Vector2(_initialSize.x * 1.1f, _initialSize.y); _initialSizeForNoStuff = new Vector2(_initialSize.x * 0.5f, _initialSize.y); _armorStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.ArmorRating_Sharp, StatDefOf.ArmorRating_Blunt, StatDefOf.ArmorRating_Heat, StatDefOf.Insulation_Cold, StatDefOf.Insulation_Heat, StatDefOf.Mass, }; _baseWeaponStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.MeleeWeapon_AverageDPS, StatDefOf.MeleeWeapon_AverageArmorPenetration, StatDefOf.Mass, }; _meleeWeaponStats = new List <StatDef>() { StatDefOf.MeleeWeapon_CooldownMultiplier, }; _rangedWeaponStats = new List <string>() { RangedWeaponStatsString.ArmorPenetration, RangedWeaponStatsString.Damage, }.Select(s => ToStatDef(s)).ToList(); _generalItemStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.MarketValue, StatDefOf.Mass, }; }
public async Task <int> AddNewUI(GenUIModel model) { var newUI = new GenUI() { Width = model.Width, Height = model.Height, CreatedAt = DateTime.UtcNow, Tags = model.Tags, Regions = model.Regions, }; await _context.GenUIs.AddAsync(newUI); await _context.SaveChangesAsync(); return(newUI.GenUIId); }
public static void SelectedUpdate(this Designator_Place @this) { GenDraw.DrawNoBuildEdgeLines(); if (!ArchitectCategoryTab.InfoRect.Contains(UI.MousePositionOnUIInverted)) { IntVec3 intVec = UI.MouseCell(); if (@this.PlacingDef is TerrainDef) { GenUI.RenderMouseoverBracket(); return; } Color ghostCol; if (@this.CanDesignateCell(intVec).Accepted) { ghostCol = new Color(0.5f, 1f, 0.6f, 0.4f); } else { ghostCol = new Color(1f, 0f, 0f, 0.4f); } DrawGhost(@this, ghostCol); if (@this.CanDesignateCell(intVec).Accepted&& @this.PlacingDef.specialDisplayRadius > 0.01f) { GenDraw.DrawRadiusRing(UI.MouseCell(), @this.PlacingDef.specialDisplayRadius); if ((@this.PlacingDef as ThingDef)?.building?.turretGunDef?.Verbs?.FirstOrDefault()?.requireLineOfSight == true) { var map = Find.VisibleMap; float range = ((ThingDef)@this.PlacingDef).building.turretGunDef.Verbs[0].range; foreach (var cell in GenRadial.RadialCellsAround(intVec, range, false)) { if (GenSight.LineOfSight(intVec, cell, map, true) != GenSight.LineOfSight(cell, intVec, map, true)) { CellRenderer.RenderCell(cell, 0f); } if (GenSight.LineOfSight(intVec, cell, map, true)) { CellRenderer.RenderCell(cell, 0.6f); continue; } } } } GenDraw.DrawInteractionCell((ThingDef)@this.PlacingDef, intVec, placingRotGet(@this)); } }
public static void TickManagerUi(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); DrawSlider(rect); if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); }
private LocalTargetInfo CurrentTargetUnderMouse() { if (!this.IsTargeting) { return(LocalTargetInfo.Invalid); } LocalTargetInfo localTarget = LocalTargetInfo.Invalid; using (IEnumerator <LocalTargetInfo> enumerator = GenUI.TargetsAtMouse(this.targetParams, false).GetEnumerator()) { if (enumerator.MoveNext()) { LocalTargetInfo localTarget2 = enumerator.Current; localTarget = localTarget2; } } return(localTarget); }
protected virtual void UpdateBaseColor() { if (!Selected && !HasActiveParent) { baseColor = Color.white; Rect r = new Rect(0f, 0f, backgroundTexture.width, backgroundTexture.height).ContractedBy(-5f); if (!r.Contains(Event.current.mousePosition)) { float num = GenUI.DistFromRect(r, Event.current.mousePosition); baseColor = new Color(1f, 1f, 1f, 1f - num / 95f); if (num > 95f) { Close(doCloseSound: false); Cancel(); } } } }
private static LocalTargetInfo CurrentTargetUnderMouse(Targeter targeter, bool mustBeHittableNowIfNotMelee) { if (!targeter.IsTargeting) { return(LocalTargetInfo.Invalid); } var targetParams = Traverse.Create(targeter).Field("targetParams").GetValue <TargetingParameters>(); TargetingParameters clickParams = (targeter.targetingSource == null) ? targetParams : targeter.targetingSource.GetVerb.verbProps.targetParams; LocalTargetInfo localTargetInfo = LocalTargetInfo.Invalid; using (IEnumerator <LocalTargetInfo> enumerator = GenUI.TargetsAtMouse(clickParams, false).GetEnumerator()) { if (enumerator.MoveNext()) { LocalTargetInfo localTargetInfo2 = enumerator.Current; localTargetInfo = localTargetInfo2; } } if (localTargetInfo.IsValid && mustBeHittableNowIfNotMelee && !(localTargetInfo.Thing is Pawn) && targeter.targetingSource != null && !targeter.targetingSource.GetVerb.verbProps.IsMeleeAttack) { if (targeter.targetingSourceAdditionalPawns != null && targeter.targetingSourceAdditionalPawns.Any <Pawn>()) { bool flag = false; for (int i = 0; i < targeter.targetingSourceAdditionalPawns.Count; i++) { Verb verb = GetTargetingVerb(targeter, targeter.targetingSourceAdditionalPawns[i]); if (verb != null && verb.CanHitTarget(localTargetInfo)) { flag = true; break; } } if (!flag) { localTargetInfo = LocalTargetInfo.Invalid; } } else if (!targeter.targetingSource.CanHitTarget(localTargetInfo)) { localTargetInfo = LocalTargetInfo.Invalid; } } return(localTargetInfo); }
// RimWorld.SkillUI// public static void DrawTier(CosmicEntity entity, Vector2 topLeft) { if (entity == null) { return; } _ = entity.PlayerTier.ToString(); string standingLabel = "Standing".Translate() + ":"; var tierLabelWidth = Text.CalcSize(standingLabel).x; var tierCurrentVal = entity.PlayerFavor; var tierCurrentMax = entity.currentTierMax; var tierPrevMax = entity.prevTierMax; var rect = new Rect(topLeft.x, topLeft.y, 150f, 24f); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } GUI.BeginGroup(rect); Text.Anchor = TextAnchor.MiddleLeft; var rect2 = new Rect(0f, 0f, tierLabelWidth + 5f, rect.height); Widgets.Label(rect2, standingLabel); var position = new Rect(rect2.xMax, 0f, 10f, 24f); var rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, (tierCurrentVal - tierPrevMax) / (tierCurrentMax - tierPrevMax), Buttons.TierBarFillTex, null, false); var rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); //rect4.yMin += 10f; rect4.yMax += 18f; var label = entity.TierString; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); TooltipHandler.TipRegion(rect, new TipSignal(GetFavorDescription(entity), entity.def.GetHashCode() * 397945)); }
public void GlobalControlsOnGUI() { if (Event.current.type != EventType.Layout) { float num = (float)UI.screenWidth - 200f; float num2 = (float)UI.screenHeight; num2 -= 35f; GenUI.DrawTextWinterShadow(new Rect((float)(UI.screenWidth - 270), (float)(UI.screenHeight - 450), 270f, 450f)); num2 -= 4f; GlobalControlsUtility.DoPlaySettings(rowVisibility, worldView: false, ref num2); num2 -= 4f; GlobalControlsUtility.DoTimespeedControls(num, 200f, ref num2); num2 -= 4f; GlobalControlsUtility.DoDate(num, 200f, ref num2); Rect rect = new Rect(num - 30f, num2 - 26f, 230f, 26f); Find.CurrentMap.weatherManager.DoWeatherGUI(rect); num2 -= rect.height; Rect rect2 = new Rect(num - 100f, num2 - 26f, 293f, 26f); Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(rect2, TemperatureString()); Text.Anchor = TextAnchor.UpperLeft; num2 -= 26f; float num3 = 230f; float num4 = Find.CurrentMap.gameConditionManager.TotalHeightAt(num3 - 15f); Rect rect3 = new Rect(num - 30f, num2 - num4, num3, num4); Find.CurrentMap.gameConditionManager.DoConditionsUI(rect3); num2 -= rect3.height; if (Prefs.ShowRealtimeClock) { GlobalControlsUtility.DoRealtimeClock(num, 200f, ref num2); } TimedForcedExit component = Find.CurrentMap.Parent.GetComponent <TimedForcedExit>(); if (component != null && component.ForceExitAndRemoveMapCountdownActive) { Rect rect4 = new Rect(num, num2 - 26f, 193f, 26f); Text.Anchor = TextAnchor.MiddleRight; DoCountdownTimer(rect4, component); Text.Anchor = TextAnchor.UpperLeft; num2 -= 26f; } num2 -= 10f; Find.LetterStack.LettersOnGUI(num2); } }
private IEnumerable <object> SelectableObjectsUnderMouse() { Vector2 mousePositionOnUIInverted = UI.MousePositionOnUIInverted; Thing thing = Find.ColonistBar.ColonistOrCorpseAt(mousePositionOnUIInverted); if (thing != null && thing.Spawned) { yield return(thing); } else { if (!UI.MouseCell().InBounds(Find.CurrentMap)) { yield break; } TargetingParameters targetingParameters = new TargetingParameters(); targetingParameters.mustBeSelectable = true; targetingParameters.canTargetPawns = true; targetingParameters.canTargetBuildings = true; targetingParameters.canTargetItems = true; targetingParameters.mapObjectTargetsMustBeAutoAttackable = false; List <Thing> selectableList = GenUI.ThingsUnderMouse(UI.MouseMapPosition(), 1f, targetingParameters); if (selectableList.Count > 0 && selectableList[0] is Pawn && (selectableList[0].DrawPos - UI.MouseMapPosition()).MagnitudeHorizontal() < 0.4f) { for (int num = selectableList.Count - 1; num >= 0; num--) { Thing thing2 = selectableList[num]; if (thing2.def.category == ThingCategory.Pawn && (thing2.DrawPos - UI.MouseMapPosition()).MagnitudeHorizontal() > 0.4f) { selectableList.Remove(thing2); } } } for (int i = 0; i < selectableList.Count; i++) { yield return(selectableList[i]); } Zone zone = Find.CurrentMap.zoneManager.ZoneAt(UI.MouseCell()); if (zone != null) { yield return(zone); } } }
/// <summary> /// Draws the mouse attachment for the colonist at the given index. Original private method: <see cref="ColonistBar.DrawColonistMouseAttachment"/>. /// </summary> /// <param name="index">The index of the colonist.</param> /// <param name="dragStartPos">The starting drag position.</param> /// <param name="entryGroup">The group of the entry.</param> /// <param name="cachedEntries">The cached entries of the colonist bar.</param> public static void DrawColonistMouseAttachment(int index, Vector2 dragStartPos, int entryGroup, List <ColonistBar.Entry> cachedEntries) { GetPawnAtIndex(index, entryGroup, cachedEntries, out Pawn pawn, out Vector2 vector); if (pawn != null) { RenderTexture renderTexture = PortraitsCache.Get( pawn, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f); var size = Find.ColonistBar.Size; Rect rect = new Rect(vector.x, vector.y, size.x, size.y); Rect pawnTextureRect = Find.ColonistBar.drawer.GetPawnTextureRect(rect.position); pawnTextureRect.position += Event.current.mousePosition - dragStartPos; RenderTexture iconTex = renderTexture; Rect? customRect = new Rect?(pawnTextureRect); GenUI.DrawMouseAttachment(iconTex, string.Empty, 0f, default(Vector2), customRect); } }
private LocalTargetInfo CurrentTargetUnderMouse(bool mustBeHittableNowIfNotMelee) { if (!IsTargeting) { return(LocalTargetInfo.Invalid); } TargetingParameters clickParams = (targetingVerb == null) ? targetParams : targetingVerb.verbProps.targetParams; LocalTargetInfo localTargetInfo = LocalTargetInfo.Invalid; using (IEnumerator <LocalTargetInfo> enumerator = GenUI.TargetsAtMouse(clickParams).GetEnumerator()) { if (enumerator.MoveNext()) { LocalTargetInfo current = enumerator.Current; localTargetInfo = current; } } if (localTargetInfo.IsValid && mustBeHittableNowIfNotMelee && !(localTargetInfo.Thing is Pawn) && targetingVerb != null && !targetingVerb.verbProps.IsMeleeAttack) { if (targetingVerbAdditionalPawns != null && targetingVerbAdditionalPawns.Any()) { bool flag = false; for (int i = 0; i < targetingVerbAdditionalPawns.Count; i++) { Verb verb = GetTargetingVerb(targetingVerbAdditionalPawns[i]); if (verb != null && verb.CanHitTarget(localTargetInfo)) { flag = true; break; } } if (!flag) { localTargetInfo = LocalTargetInfo.Invalid; } } else if (!targetingVerb.CanHitTarget(localTargetInfo)) { localTargetInfo = LocalTargetInfo.Invalid; } } return(localTargetInfo); }
private void DoTileTooltips() { if (Mouse.IsInputBlockedNow) { return; } int num = GenWorld.MouseTile(snapToExpandableWorldObjects: true); if (num == -1) { return; } int num2 = 0; while (true) { if (num2 < paths.Count) { if (paths[num2].NodesReversed.Contains(num)) { break; } num2++; continue; } return; } string str = GetTileTip(num, num2); Text.Font = GameFont.Small; Vector2 size = Text.CalcSize(str); size.x += 20f; size.y += 20f; Vector2 mouseAttachedWindowPos = GenUI.GetMouseAttachedWindowPos(size.x, size.y); Rect rect = new Rect(mouseAttachedWindowPos, size); Find.WindowStack.ImmediateWindow(1859615246, rect, WindowLayer.Super, delegate { Text.Font = GameFont.Small; Widgets.Label(rect.AtZero().ContractedBy(10f), str); }); }
//FloatMenuMakerMap public static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { foreach (var localTargetInfo4 in GenUI.TargetsAt(clickPos, ForQuest(), true)) { var dest = localTargetInfo4; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("RQ_CannotQuest".Translate() + " (" + "NoPath".Translate() + ")", null)); } else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(new object[] { SkillDefOf.Social.LabelCap }), null)); } else { var pTarg = (Pawn)dest.Thing; void Action4() { var job = new Job(RimQuestDefOf.RQ_QuestWithPawn, pTarg); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); } var str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } var label = "RQ_QuestWith".Translate(new object[] { pTarg.LabelShort }) + str; var action = (Action)Action4; var priority2 = MenuOptionPriority.InitiateSocial; var thing = dest.Thing; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, thing), pawn, pTarg)); } } }
public static void Save() { try { XDocument xDocument = new XDocument(); XElement content = DirectXmlSaver.XElementFromObject(PlayerKnowledgeDatabase.data, typeof(PlayerKnowledgeDatabase.ConceptKnowledge)); xDocument.Add(content); xDocument.Save(GenFilePaths.ConceptKnowledgeFilePath); } catch (Exception ex) { GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[] { GenFilePaths.ConceptKnowledgeFilePath, ex.ToString() })); Log.Error("Exception saving knowledge database: " + ex, false); } }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { if (!caravan.Spawned) { return(new GizmoResult(GizmoState.Clear)); } Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f); Widgets.DrawWindowBackground(rect); GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); int? ticksToArrive = (caravan.pather.Moving ? new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(caravan, allowCaching: true)) : null); StringBuilder stringBuilder = new StringBuilder(); CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(tilesPerDay: TilesPerDayCalculator.ApproxTilesPerDay(caravan, stringBuilder), massUsage: caravan.MassUsage, massCapacity: caravan.MassCapacity, massCapacityExplanation: caravan.MassCapacityExplanation, tilesPerDayExplanation: stringBuilder.ToString(), daysWorthOfFood: caravan.DaysWorthOfFood, foragedFoodPerDay: caravan.forage.ForagedFoodPerDay, foragedFoodPerDayExplanation: caravan.forage.ForagedFoodPerDayExplanation, visibility: caravan.Visibility, visibilityExplanation: caravan.VisibilityExplanation), null, caravan.Tile, ticksToArrive, -9999f, rect2, lerpMassColor: true, null, multiline: true); GUI.EndGroup(); GenUI.AbsorbClicksInRect(rect); return(new GizmoResult(GizmoState.Clear)); }
/// <summary> /// Initializes a new instance of the <see cref="Dialog_ManageLoadouts"/> class. /// </summary> /// <param name="loadout"> Selected loadout. </param> /// <param name="pawn"> Selected pawn. </param> public Dialog_ManageLoadouts(AwesomeInventoryLoadout loadout, Pawn pawn) { ValidateArg.NotNull(loadout, nameof(loadout)); _pawn = pawn ?? throw new ArgumentNullException(nameof(pawn)); float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(11)); _initialSize = new Vector2(width, Verse.UI.screenHeight / 2f); _currentLoadout = loadout; _resettables.Add(this); _resettables.Add(new WhiteBlacklistView()); doCloseX = true; forcePause = true; absorbInputAroundWindow = false; closeOnClickedOutside = false; closeOnAccept = false; }
private void DrawEntryTitle(FeatureEntry entry, float width, ref float curY, bool skipDrawing) { if (!skipDrawing) { const float toggleSize = Widgets.CheckboxSize; var togglePos = new Vector2(EntryTitleLabelPadding, curY + (EntryTitleLabelHeight / 2f - toggleSize / 2f)); DoIgnoreNewsProviderToggle(togglePos, entry); var labelRect = new Rect(togglePos.x + toggleSize, curY, width - EntryTitleLinkWidth, EntryTitleLabelHeight).ContractedBy(EntryTitleLabelPadding); Text.Font = GameFont.Medium; var titleText = entry.def.titleOverride ?? "HugsLib_features_update".Translate(entry.def.modNameReadable, entry.def.assemblyVersion); Widgets.Label(labelRect, string.Format("<size={0}>{1}</size>", EntryTitleFontSize, titleText)); Text.Font = GameFont.Small; if (entry.def.linkUrl != null) { Text.Anchor = TextAnchor.MiddleCenter; var linkRect = new Rect(width - EntryTitleLinkWidth, curY, EntryTitleLinkWidth, EntryTitleLabelHeight); var prevColor = GUI.color; GUI.color = LinkTextColor; Widgets.Label(linkRect, "HugsLib_features_link".Translate()); GUI.color = prevColor; GenUI.ResetLabelAlign(); if (Widgets.ButtonInvisible(linkRect, true)) { Application.OpenURL(entry.def.linkUrl); } if (Mouse.IsOver(linkRect)) { Widgets.DrawHighlight(linkRect); TooltipHandler.TipRegion(linkRect, "HugsLib_features_linkDesc".Translate(entry.def.linkUrl)); } } } curY += EntryTitleLabelHeight; if (!skipDrawing) { var color = GUI.color; GUI.color = TitleLineColor; Widgets.DrawLineHorizontal(0f, curY, width); GUI.color = color; } curY += EntryTitleLabelPadding; }
private LocalTargetInfo CurrentTargetUnderMouse(bool mustBeHittableNowIfNotMelee) { if (!IsTargeting) { return(LocalTargetInfo.Invalid); } TargetingParameters targetingParameters = (targetingSource != null) ? targetingSource.targetParams : targetParams; LocalTargetInfo localTargetInfo = GenUI.TargetsAtMouse_NewTemp(targetingParameters, thingsOnly: false, targetingSource).FirstOrFallback(LocalTargetInfo.Invalid); if (localTargetInfo.IsValid && targetingSource != null) { if (mustBeHittableNowIfNotMelee && !(localTargetInfo.Thing is Pawn) && !targetingSource.IsMeleeAttack) { if (targetingSourceAdditionalPawns != null && targetingSourceAdditionalPawns.Any()) { bool flag = false; for (int i = 0; i < targetingSourceAdditionalPawns.Count; i++) { Verb targetingVerb = GetTargetingVerb(targetingSourceAdditionalPawns[i]); if (targetingVerb != null && targetingVerb.CanHitTarget(localTargetInfo)) { flag = true; break; } } if (!flag) { localTargetInfo = LocalTargetInfo.Invalid; } } else if (!targetingSource.CanHitTarget(localTargetInfo)) { localTargetInfo = LocalTargetInfo.Invalid; } } if (localTargetInfo == targetingSource.Caster && !targetingParameters.canTargetSelf) { localTargetInfo = LocalTargetInfo.Invalid; } } return(localTargetInfo); }
private static void FloatMenuMakerMap_AddHumanlikeOrdersToDismissTraders_PostFix(ref Vector3 clickPos, ref Pawn pawn, ref List <FloatMenuOption> opts) { foreach (var target in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { var localpawn = pawn; var dest = target; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly)) { return; } if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { return; } var pTarg = (Pawn)dest.Thing; void Action() { var job = new Job(TraderDismissalJobDefs.DismissTrader, pTarg) { playerForced = true }; localpawn.jobs.TryTakeOrderedJob(job); } var str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } string label = "GETOUT".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + str; opts.Add(FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption(label, Action, MenuOptionPriority.InitiateSocial, null, dest.Thing), pawn, pTarg)); } }
public static void Draw(Rect rect, Thing thing, Color color) { rect = new Rect(rect.center.x - 17, rect.center.y - 17, 38, 38); GUI.color = color; // EdB: Inline copy of static Widgets.ThingIcon(Rect, Thing) with graphics switched to show a side view // instead of a front view. GUI.color = thing.DrawColor; Texture resolvedIcon; if (!thing.def.uiIconPath.NullOrEmpty()) { resolvedIcon = thing.def.uiIcon; } else if (thing is Pawn) { Pawn pawn = (Pawn)thing; if (!pawn.Drawer.renderer.graphics.AllResolved) { pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSide; resolvedIcon = matSingle.mainTexture; GUI.color = matSingle.color; } else { resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatSide.mainTexture; } // EdB: Inline copy of static private method. //Widgets.ThingIconWorker(rect, thing.def, resolvedIcon); float num = GenUI.IconDrawScale(thing.def); if (num != 1f) { Vector2 center = rect.center; rect.width *= num; rect.height *= num; rect.center = center; } GUI.DrawTexture(rect, resolvedIcon); GUI.color = Color.white; }
static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { foreach (var localTargetInfo in GenUI.TargetsAt(clickPos, TargetParms(), true)) { if (!pawn.CanReach(localTargetInfo, PathEndMode.Touch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotGoNoPath".Translate().ToString(), null)); } else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap).ToString(), null)); } else { Pawn target = (Pawn)localTargetInfo.Thing; if (pawn != target) { if (target.GetQuestPawn(out QuestPawn questPawn)) { if (questPawn.Quests.Count > 0) { opts.Add(new FloatMenuOption("TryStartQuestDialog".Translate().ToString(), delegate { Job job = new Job(JobDefOfLocal.SpeakWithQuester, localTargetInfo.Thing); pawn.jobs.TryTakeOrderedJob(job); })); } foreach (var dialog in questPawn.Dialogs) { opts.Add(new FloatMenuOption(dialog.CardLabel, delegate { Job job = new Job(JobDefOfLocal.SpeakWithPawn, localTargetInfo.Thing); job.count = questPawn.Dialogs.IndexOf(dialog); pawn.jobs.TryTakeOrderedJob(job); })); } } } } } }