private void DrawAvailableApparel(float x, float y, float width, float height) { #if TRACE && CUSTOM_OUTFIT_UI Log.Warning("Begin CustomOutfitUI.DrawAvailableApparel " + x + " " + y); #endif // Apparel Selection Titles Widgets.Label(new Rect(x, y, 150, 30), "ChangeDresser.AvailableApparel".Translate()); searchText = Widgets.TextArea(new Rect(x + 160, y, 100, 30), searchText).ToLower(); y += HEIGHT + Y_BUFFER; Rect apparelListRect = new Rect(x, y, width - 10, height); Rect apparelScrollRect = new Rect(0f, 0f, apparelListRect.width - 16f, this.availableApparel.Count * CELL_HEIGHT); GUI.BeginGroup(apparelListRect); this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect); for (int i = 0, count = 0; i < this.availableApparel.Count; ++i) { Apparel apparel = this.availableApparel[i]; if (searchText.Trim().Length == 0 || apparel.Label.ToLower().Contains(searchText)) { Rect rowRect = new Rect(0, 2f + count * CELL_HEIGHT, apparelListRect.width, CELL_HEIGHT); ++count; GUI.BeginGroup(rowRect); Widgets.ThingIcon(new Rect(0f, 0f, CELL_HEIGHT, CELL_HEIGHT), apparel); if (Widgets.InfoCardButton(40, 0, apparel)) { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); } Widgets.Label(new Rect(30 + CELL_HEIGHT + 5f, 0f, rowRect.width - 40f - CELL_HEIGHT, CELL_HEIGHT), apparel.Label); if (this.customOutfit != null) { Rect buttonRect = new Rect(rowRect.width - 35f, 10, 20, 20); if (this.CanWear(apparel)) { if (Widgets.ButtonImage(buttonRect, WidgetUtil.nextTexture)) { this.AddApparelToOutfit(apparel); break; } } else { Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture); } } GUI.EndGroup(); } } GUI.EndScrollView(); GUI.EndGroup(); #if TRACE && CUSTOM_OUTFIT_UI Log.Warning("End CustomOutfitUI.DrawAvailableApparel " + x + " " + y); #endif }
private static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing) { Pawn p = ___thing as Pawn; if (p == null) { return(true); } PortraitData portraitData = PortraitLoader.Portraits.Find((PortraitData x) => x.DefinitionKey == p.kindDef.defName); if (portraitData != null) { if (PortraitLoader.CurPortrait != portraitData) { PortraitLoader.CurPortrait = portraitData; PortraitLoader.CurTexture = ContentFinder <Texture2D> .Get(PortraitLoader.CurPortrait.TexturePath, false); if (PortraitLoader.CurTexture == null) { Log.Message("Texture missing " + PortraitLoader.CurPortrait.TexturePath, false); PortraitLoader.CurTexture = ContentFinder <Texture2D> .Get(BaseContent.BadTexPath, true); } } Rect rect = GenUI.AtZero(cardRect); rect.width = 440f; rect.height = 540f; rect.x = cardRect.width - rect.width; rect.y = cardRect.center.y - rect.height / 2f; GUI.DrawTexture(rect, PortraitLoader.CurTexture, (ScaleMode)1, true); } 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 }
// Token: 0x06000002 RID: 2 RVA: 0x00002080 File Offset: 0x00000280 public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Rect overRect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f); Find.WindowStack.ImmediateWindow(942612547, overRect, 0, delegate() { Rect rect = GenUI.ContractedBy(GenUI.AtZero(overRect), 6f); Rect rect2 = rect; rect2.height = overRect.height / 2f; Text.Font = 0; Widgets.Label(rect2, this.shield.def.LabelCap); Rect rect3 = rect; rect3.yMin = overRect.height / 2f; float num = this.shield.Severity / this.shield.def.maxSeverity; Widgets.FillableBar(rect3, num, Gizmo_ShieldHediff.FullShieldBarTex, Gizmo_ShieldHediff.EmptyShieldBarTex, false); Text.Font = (GameFont)1; Text.Anchor = (TextAnchor)4; Widgets.Label(rect3, (int)this.shield.Severity + " \\ " + (int)this.shield.def.maxSeverity); Text.Anchor = 0; }, true, false, 1f); return(new GizmoResult(0)); }
public virtual GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Rect overRect = new Rect((float)topLeft.x, (float)topLeft.y, base.GetWidth(maxWidth), 75f); Find.get_WindowStack().ImmediateWindow(942612547, overRect, (WindowLayer)0, (Action)(() => { Rect rect1 = GenUI.ContractedBy(GenUI.AtZero(overRect), 6f); Rect rect2 = rect1; ((Rect) ref rect2).set_height(((Rect) ref overRect).get_height() / 2f); Text.set_Font((GameFont)0); Widgets.Label(rect2, ((Def)((Hediff)this.shield).def).get_LabelCap()); Rect rect3 = rect1; ((Rect) ref rect3).set_yMin(((Rect) ref overRect).get_height() / 2f); float num = ((Hediff)this.shield).get_Severity() / (float)((HediffDef)((Hediff)this.shield).def).maxSeverity; Widgets.FillableBar(rect3, num, Gizmo_ShieldHediff.FullShieldBarTex, Gizmo_ShieldHediff.EmptyShieldBarTex, false); Text.set_Font((GameFont)1); Text.set_Anchor((TextAnchor)4); Widgets.Label(rect3, ((int)((Hediff)this.shield).get_Severity()).ToString() + " \\ " + (object)(int)((HediffDef)((Hediff)this.shield).def).maxSeverity); Text.set_Anchor((TextAnchor)0); }), true, false, 1f); return(new GizmoResult((GizmoState)0)); }
// Token: 0x06000005 RID: 5 RVA: 0x00002098 File Offset: 0x00000298 public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Rect overRect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f); Find.WindowStack.ImmediateWindow(1523289473, overRect, 0, delegate() { Rect rect = GenUI.ContractedBy(GenUI.AtZero(overRect), 6f); Rect rect2 = rect; rect2.height = overRect.height / 2f; Text.Font = 0; Widgets.Label(rect2, Translator.Translate("HealthShardUses")); Rect rect3 = rect; rect3.yMin = overRect.height / 2f; float num = (float)this.kit.uses / (float)this.kit.kitComp.Props.Uses; Widgets.FillableBar(rect3, num, Gizmo_InjectorStatus.FullBarTex, Gizmo_InjectorStatus.EmptyBarTex, false); Text.Font = (GameFont)1; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect3, this.kit.uses.ToString("F0") + " / " + this.kit.kitComp.Props.Uses.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; }, true, false, 1f); return(new GizmoResult(0)); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Rect overRect = new Rect(topLeft.x, topLeft.y, this.Width, 75f); Find.WindowStack.ImmediateWindow(984688, overRect, WindowLayer.GameUI, delegate() { Rect rect = GenUI.ContractedBy(GenUI.AtZero(overRect), 6f); Rect rect2 = rect; rect2.height = overRect.height / 2f; Text.Font = GameFont.Tiny; Widgets.Label(rect2, this.shield.LabelCap); Rect rect3 = rect; rect3.yMin = overRect.height / 2f; float num = this.shield.Energy / Mathf.Max(1f, this.shield.GetStatValue(StatDefOf.EnergyShieldEnergyMax, true)); Widgets.FillableBar(rect3, num, Gizmo_Vanya_EnergyShieldStatus.FullShieldBarTex, Gizmo_Vanya_EnergyShieldStatus.EmptyShieldBarTex, false); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect3, (this.shield.Energy * 100f).ToString("F0") + " / " + (this.shield.GetStatValue(StatDefOf.EnergyShieldEnergyMax, true) * 100f).ToString("F0")); Text.Anchor = 0; }, true, false, 1f); return(new GizmoResult(GizmoState.Clear)); }
public override void DoWindowContents(Rect inRect) { try { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.ApparelGroupLabel".Translate()); Text.Font = GameFont.Small; if (!this.FromGizmo) { Widgets.Label(new Rect(250, 0, 200, 50), "ChangeDresser.ApparelGroupOwner".Translate() + ": " + this.Pawn.Name.ToStringShort); } else if (this.FromGizmo && this.isRestricted) { string label; if (this.set.HasOwner) { label = this.set.OwnerName; } else { label = "ChangeDresser.ApparelGroupOwner".Translate(); } if (Widgets.ButtonText(new Rect(275, 10, 150, 30), label)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (Pawn p in this.PlayerPawns) { options.Add(new FloatMenuOption(p.Name.ToStringShort, delegate { StoredApparelSet tempSet; if (this.set.SwitchForBattle && p != this.set.Owner && StoredApparelContainer.TryGetBattleApparelSet(p, out tempSet)) { Messages.Message(p.Name.ToStringShort + " " + "ChangeDresser.AlreadyHasCombatApparel".Translate(), MessageSound.Negative); } else { this.set.SetOwner(p); } }, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(options)); } } Rect rect = new Rect(0, 50, inRect.width, 30); Text.Font = GameFont.Small; GUI.BeginGroup(rect); GUI.Label(new Rect(0, 0, 100, rect.height), "ChangeDresser.ApparelGroupName".Translate() + ":", WidgetUtil.MiddleCenter); this.set.Name = Widgets.TextField(new Rect(110, 0, 150, rect.height), this.set.Name); GUI.Label(new Rect(280, 0, 120, rect.height), "ChangeDresser.ApparelGroupRestrictToPawnCheckBox".Translate() + ":", WidgetUtil.MiddleCenter); bool temp = this.set.HasOwner || (this.FromGizmo && this.isRestricted); temp = GUI.Toggle(new Rect(410, 7, rect.height, rect.height), temp, ""); if (this.isRestricted != temp) { this.isRestricted = temp; if (this.isRestricted && !this.FromGizmo) { this.set.SetOwner(this.Pawn); } else { this.set.SetOwner(null); this.set.SwitchForBattle = false; } } if (!this.FromGizmo || (this.FromGizmo && this.set.HasOwner)) { GUI.Label(new Rect(440, 0, 150, rect.height), "ChangeDresser.ForceSwitchCombat".Translate() + ":", WidgetUtil.MiddleCenter); bool forceSwitch = GUI.Toggle(new Rect(600, 7, rect.height, rect.height), this.set.SwitchForBattle, ""); if (forceSwitch != this.set.SwitchForBattle) { if (forceSwitch) { StoredApparelSet tempSet; if (this.Pawn != null && StoredApparelContainer.TryGetBattleApparelSet(this.Pawn, out tempSet)) { Messages.Message(this.Pawn.Name.ToStringShort + " " + "ChangeDresser.AlreadyHasCombatApparel".Translate(), MessageSound.Negative); } else { this.set.SwitchForBattle = forceSwitch; if (!this.set.HasOwner) { this.set.SetOwner(this.Pawn); } } } } } GUI.EndGroup(); List <Apparel> possibleApparel = (this.ApparelFrom == ApparelFromEnum.Pawn && this.Pawn != null) ? this.Pawn.apparel.WornApparel : this.Dresser.StoredApparel; List <Apparel> groupApparel = this.set.Apparel; List <string> forcedApparelIds = this.set.ForcedApparelIds; GUI.BeginGroup(new Rect(0, 90, inRect.width, 30)); GUI.Label(new Rect(0, 0, 100, 30), ((string)((this.ApparelFrom == ApparelFromEnum.Pawn) ? "ChangeDresser.Worn" : "ChangeDresser.Storage")).Translate(), WidgetUtil.MiddleCenter); GUI.Label(new Rect(inRect.width * 0.5f, 0, 100, 30), "ChangeDresser.ApparelGroup".Translate(), WidgetUtil.MiddleCenter); GUI.EndGroup(); const float cellHeight = 40f; float apparelListWidth = inRect.width * 0.5f - 10f; Rect apparelListRect = new Rect(0, 120, apparelListWidth, inRect.height - 150); Rect apparelScrollRect = new Rect(0f, 0f, apparelListRect.width - 16f, possibleApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; Pawn pawnToUse = this.Pawn; if (pawnToUse == null && this.FromGizmo && this.set.HasOwner) { pawnToUse = set.Owner; } for (int i = 0; i < possibleApparel.Count; ++i) { Apparel apparel = possibleApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight); GUI.BeginGroup(rowRect); Widgets.ThingIcon(new Rect(0f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Widgets.Label(new Rect(cellHeight + 5f, 0f, rowRect.width - 40f - cellHeight, cellHeight), apparel.Label); GUI.color = Color.white; Rect buttonRect = new Rect(rowRect.width - 35f, 10, 20, 20); if (pawnToUse != null && this.CanWear(groupApparel, apparel)) { if (Widgets.ButtonImage(buttonRect, WidgetUtil.nextTexture)) { this.RemoveApparelFromSender(apparel); pawnToUse.apparel.Remove(apparel); groupApparel.Add(apparel); GUI.EndGroup(); break; } } else { Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture); } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); apparelListRect = new Rect(inRect.width * 0.5f + 10f, 120, apparelListWidth, inRect.height - 150); apparelScrollRect = new Rect(0f, 0f, apparelListRect.width - 16f, groupApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < groupApparel.Count; ++i) { Apparel apparel = groupApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight); GUI.BeginGroup(rowRect); if (Widgets.ButtonImage(new Rect(5, 10, 20, 20), WidgetUtil.previousTexture)) { this.AddApparelToSender(apparel, forcedApparelIds.Contains(apparel.ThingID)); groupApparel.RemoveAt(i); GUI.EndGroup(); break; } Widgets.ThingIcon(new Rect(35f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; string label = apparel.Label; if (forcedApparelIds.Contains(apparel.ThingID)) { label += "(" + "ApparelForcedLower".Translate() + ")"; } Widgets.Label(new Rect(cellHeight + 45f, 0f, rowRect.width - cellHeight - 45f, cellHeight), label); GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); Text.Font = GameFont.Small; GUI.BeginGroup(new Rect(0, inRect.height - 35, inRect.width, 30)); float middle = inRect.width / 2; if (Widgets.ButtonText(new Rect(middle - 110, 0, 100, 30), "ChangeDresser.Save".Translate(), true, false, this.set.HasName)) { this.set.ClearWornBy(); if (IsNew) { StoredApparelContainer.AddApparelSet(this.set); } this.Close(); } Rect rightButton = new Rect(middle + 10, 0, 100, 30); if (IsNew && this.Pawn != null && Widgets.ButtonText(rightButton, "ChangeDresser.Cancel".Translate())) { for (int i = 0; i < this.set.Apparel.Count; ++i) { Apparel apparel = this.set.Apparel[i]; this.AddApparelToSender(apparel, this.set.ForcedApparelIds.Contains(apparel.ThingID)); } this.Close(); } if (!IsNew) { if (this.set.Apparel.Count > 0) { Text.Font = GameFont.Small; rightButton.width = 300; GUI.Label(rightButton, "ChangeDresser.RemoveToEnableDelete".Translate(), WidgetUtil.MiddleCenter); } else if (Widgets.ButtonText(rightButton, "ChangeDresser.Delete".Translate(), true, false, this.set.Apparel.Count == 0)) { StoredApparelContainer.RemoveApparelSet(this.set); this.Close(); } } GUI.EndGroup(); } catch (Exception e) { Log.Error(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message); Messages.Message(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message, MessageSound.Negative); base.Close(); } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } }
public override void DoWindowContents(Rect inRect) { try { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.ApparelStorageLabel".Translate()); Text.Font = GameFont.Small; List <Apparel> wornApparel = (this.Pawn != null) ? this.Pawn.apparel.WornApparel : null; const float cellHeight = 40f; float apparelListWidth = inRect.width * 0.5f - 10f; Rect apparelListRect; Rect apparelScrollRect; if (wornApparel != null) { GUI.Label(new Rect(0, 60, 100, 30), ("ChangeDresser.Worn").Translate(), WidgetUtil.MiddleCenter); apparelListRect = new Rect(0, 90, apparelListWidth, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, apparelListWidth - 16f, wornApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < wornApparel.Count; ++i) { Apparel apparel = wornApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight); GUI.BeginGroup(rowRect); Widgets.ThingIcon(new Rect(0f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Widgets.Label(new Rect(cellHeight + 5f, 0f, rowRect.width - 40f - cellHeight, cellHeight), apparel.Label); GUI.color = Color.white; if (Widgets.ButtonImage(new Rect(rowRect.width - 35f, 10, 20, 20), WidgetUtil.nextTexture)) { this.Pawn.apparel.Remove(apparel); this.Dresser.AddApparel(apparel); this.cachedApparel.Clear(); this.cachedApparel = null; GUI.EndGroup(); break; } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } GUI.Label(new Rect((wornApparel == null) ? 0 : inRect.width * 0.5f, 60, (wornApparel == null) ? inRect.width : 100, 30), ("ChangeDresser.Storage").Translate(), WidgetUtil.MiddleCenter); float left = (wornApparel == null) ? 0 : inRect.width - apparelListWidth; float width = (wornApparel == null) ? inRect.width : apparelListWidth; apparelListRect = new Rect(left, 90, width, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, width - 16f, this.Dresser.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < this.CachedApparel.Count; ++i) { Apparel apparel = this.cachedApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelScrollRect.width, cellHeight); GUI.BeginGroup(rowRect); if (this.Pawn != null) { Rect buttonRect = new Rect(5, 10, 20, 20); bool canWear = this.Pawn.apparel.CanWearWithoutDroppingAnything(apparel.def); if (canWear) { if (Widgets.ButtonImage(buttonRect, WidgetUtil.previousTexture)) { if (this.Dresser.TryRemove(apparel, false)) { this.cachedApparel.Clear(); this.cachedApparel = null; PawnOutfitTracker outfits; if (WorldComp.PawnOutfits.TryGetValue(this.Pawn, out outfits)) { outfits.ApplyApparelColor(apparel); } this.Pawn.apparel.Wear(apparel); GUI.EndGroup(); break; } else { Log.Error("Problem dropping " + apparel.Label); } } } else { Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture); } } Widgets.ThingIcon(new Rect(35f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(cellHeight + 45f, 0f, rowRect.width - cellHeight - 90f, cellHeight), apparel.Label); if (Widgets.ButtonImage(new Rect(rowRect.width - 45f, 0f, cellHeight, cellHeight), WidgetUtil.dropTexture)) { if (this.Dresser.TryRemove(apparel, false)) { this.cachedApparel.Clear(); this.cachedApparel = null; GUI.EndGroup(); break; } else { Log.Error("Problem dropping " + apparel.Label); } } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } catch (Exception e) { Log.Error(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message); Messages.Message(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message, MessageTypeDefOf.RejectInput); base.Close(); } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } }
public static void AddAppararelColorByLayerSelectionWidget( float left, float top, float width, Pawn pawn, ApparelLayerSelectionsContainer layerSelectionsContainer, ClearColorLayers clearColorLayers) { Text.Anchor = TextAnchor.MiddleCenter; if (layerSelectionsContainer.Count == 0) { GUI.Label(new Rect(left, top, width, SelectionRowHeight), "ChangeMirror.NoClothingIsWorn".Translate(), MiddleCenter); } else { const float cellHeight = 38f; float colorSampleHeight = (cellHeight - LayerColor.height) * 0.5f; Rect apparelListRect = new Rect(left, top, width, 250f); Rect apparelScrollRect = new Rect(0f, 0f, width - 16f, layerSelectionsContainer.Count * cellHeight + SelectionRowHeight); GUI.BeginGroup(apparelListRect); scrollPos = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), scrollPos, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(10, 0, 100, SelectionRowHeight), "ChangeMirror.SelectAll".Translate())) { layerSelectionsContainer.SelectAll(); } if (Widgets.ButtonText(new Rect(apparelScrollRect.width - 140, 0, 100, SelectionRowHeight), "ChangeMirror.DeselectAll".Translate())) { layerSelectionsContainer.DeselectAll(); } if (clearColorLayers != null && Widgets.ButtonText(new Rect(apparelScrollRect.width - SelectionRowHeight, 0, SelectionRowHeight, SelectionRowHeight), "X")) { clearColorLayers(); } Text.Font = GameFont.Medium; for (int i = 0; i < layerSelectionsContainer.Count; ++i) { ApparelLayerColorSelectionDTO dto = layerSelectionsContainer[i]; ApparelLayerDef layer = dto.ApparelLayerDef; GUI.BeginGroup(new Rect(0, SelectionRowHeight + 3f + i * cellHeight, apparelListRect.width, cellHeight)); GUI.color = GetLayerColor(dto.ApparelLayerDef, pawn); Rect rect = new Rect(0f, colorSampleHeight, LayerColor.width, LayerColor.height); GUI.Label(rect, new GUIContent(LayerColor)); GUI.color = Color.white; //Widgets.DrawBox(rect, 1); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Rect textRect = new Rect(rect.width + 5f, 0f, apparelScrollRect.width - 90f, cellHeight); if (layerSelectionsContainer.IsSelected(dto)) { GUI.color = Color.white; } else { GUI.color = Color.gray; } Widgets.Label(textRect, new GUIContent(dto.ApparelLayerDef.ToString().Translate(), "ChangeMirror.SelectMultipleApparel".Translate())); if (Widgets.ButtonInvisible(textRect, false)) { layerSelectionsContainer.Select(dto, Event.current.shift); } GUI.color = Color.white; if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 0, 32f, 16f), copyIconTexture)) { layerSelectionsContainer.CopyColor = GetLayerColor(dto.ApparelLayerDef, pawn); } if (layerSelectionsContainer.CopyColorSelected) { if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 16f, 32f, 16f), pasteIconTexture)) { dto.SelectedColor = layerSelectionsContainer.CopyColor; } } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); /*if (Settings.UseColorPickerV2) * { * AddColorSelectorV2Widget(left, top + apparelListRect.height + 10f, width, apparelSelectionsContainer.SelectedApparel, apparelSelectionsContainer.ColorPresetsDTO); * } * else * {*/ AddColorSelectorWidget(left, top + apparelListRect.height + 10f, width, layerSelectionsContainer.SelectedApparel, layerSelectionsContainer.ColorPresetsDTO); //} } Text.Anchor = TextAnchor.UpperLeft; }
public static void AddListBoxWidget(float left, float top, float width, float height, string label, HairStyleSelectionDTO hairStyleSelectionDto) { Rect rect = new Rect(left, top, width, height); GUI.BeginGroup(rect); GUI.color = Color.white; Text.Font = GameFont.Medium; left = 0; if (label != null) { //Text.Anchor = TextAnchor.MiddleLeft; GUI.Label(new Rect(left, 0, 75, SelectionRowHeight), label, MiddleCenter); left = 80; } const float cellHeight = 30f; Rect listRect = new Rect(left, 0f, width - 100f, height); Rect scrollRect = new Rect(0f, 0f, width - 116f, hairStyleSelectionDto.Count * cellHeight); GUI.BeginGroup(listRect); hairScrollPos = GUI.BeginScrollView(new Rect(GenUI.AtZero(listRect)), hairScrollPos, scrollRect); GUI.color = Color.white; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; bool isMouseOverAnything = false; for (int i = 0; i < hairStyleSelectionDto.Count; ++i) { HairDef hairDef = hairStyleSelectionDto[i]; Rect textRect = new Rect(45f, cellHeight * i, scrollRect.width - 90f, cellHeight); bool drawMouseOver = false; Widgets.Label(textRect, new GUIContent(hairDef.label)); if (Widgets.ButtonInvisible(textRect, false)) { isMouseOverAnything = true; hairStyleSelectionDto.Index = i; } else if (Mouse.IsOver(textRect)) { drawMouseOver = true; Vector3 pos = GUIUtility.ScreenToGUIPoint(Input.mousePosition); pos.y = pos.y - hairScrollPos.y; if (pos.y > 200 && pos.y < 440) { isMouseOverAnything = true; hairStyleSelectionDto.MouseOverSelection = hairDef; } } if (hairStyleSelectionDto.Index == i) { Widgets.DrawHighlight(textRect); } else if (drawMouseOver) { Widgets.DrawHighlightIfMouseover(textRect); } } if (!isMouseOverAnything) { hairStyleSelectionDto.MouseOverSelection = null; } GUI.EndScrollView(); GUI.EndGroup(); GUI.EndGroup(); GUI.color = Color.white; Text.Font = GameFont.Small; }
public static void AddAppararelColorSelectionWidget(float left, float top, float width, ApparelSelectionsContainer apparelSelectionsContainer) { Text.Anchor = TextAnchor.MiddleCenter; if (apparelSelectionsContainer.Count == 0) { GUI.Label(new Rect(left, top, width, SelectionRowHeight), "ChangeMirror.NoClothingIsWorn".Translate(), MiddleCenter); } else { const float cellHeight = 40f; Rect apparelListRect = new Rect(left, top, width, 250f); Rect apparelScrollRect = new Rect(0f, 0f, width - 16f, apparelSelectionsContainer.Count * cellHeight + SelectionRowHeight); GUI.BeginGroup(apparelListRect); scrollPos = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), scrollPos, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(20, 0, 100, SelectionRowHeight), "ChangeMirror.SelectAll".Translate())) { apparelSelectionsContainer.SelectAll(); } if (Widgets.ButtonText(new Rect(apparelScrollRect.width - 120, 0, 100, SelectionRowHeight), "ChangeMirror.DeselectAll".Translate())) { apparelSelectionsContainer.DeselectAll(); } Text.Font = GameFont.Medium; for (int i = 0; i < apparelSelectionsContainer.Count; ++i) { ApparelColorSelectionDTO dto = apparelSelectionsContainer[i]; Apparel apparel = dto.Apparel; GUI.BeginGroup(new Rect(0, SelectionRowHeight + 5f + i * cellHeight, apparelListRect.width, cellHeight)); Widgets.ThingIcon(new Rect(0f, 0f, 40f, cellHeight), apparel); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Rect textRect = new Rect(45f, 0f, apparelScrollRect.width - 90f, cellHeight); if (apparelSelectionsContainer.IsSelected(dto)) { GUI.color = Color.white; } else { GUI.color = Color.gray; } Widgets.Label(textRect, new GUIContent(apparel.Label, "ChangeMirror.SelectMultipleApparel".Translate())); if (Widgets.ButtonInvisible(textRect, false)) { apparelSelectionsContainer.Select(dto, Event.current.shift); } GUI.color = Color.white; if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 0, 32f, 16f), copyIconTexture)) { apparelSelectionsContainer.CopyColor = apparel.DrawColor; } if (apparelSelectionsContainer.CopyColorSelected) { if (Widgets.ButtonImage(new Rect(apparelScrollRect.width - 40f, 16f, 32f, 16f), pasteIconTexture)) { dto.SelectedColor = apparelSelectionsContainer.CopyColor; } } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); /*if (Settings.UseColorPickerV2) * { * AddColorSelectorV2Widget(left, top + apparelListRect.height + 10f, width, apparelSelectionsContainer.SelectedApparel, apparelSelectionsContainer.ColorPresetsDTO); * } * else * {*/ AddColorSelectorWidget(left, top + apparelListRect.height + 10f, width, apparelSelectionsContainer.SelectedApparel, apparelSelectionsContainer.ColorPresetsDTO); //} } Text.Anchor = TextAnchor.UpperLeft; }
public override void DoWindowContents(Rect inRect) { try { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.ApparelStorageLabel".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; this.Filter = Widgets.TextArea(new Rect(250, 0, 150, 32), this.Filter); Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonText(new Rect(425, 0, 250, 32), ((this.Dresser == null) ? (string)"ChangeDresser".Translate() : this.Dresser.Label))) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (Building_Dresser cd in WorldComp.GetDressers(null)) { options.Add(new FloatMenuOption(cd.Label, delegate() { this.Dresser = cd; })); } Find.WindowStack.Add(new FloatMenu(options)); } if (this.Dresser == null) { return; } Text.Font = GameFont.Small; List <Apparel> wornApparel = (this.Pawn != null) ? this.Pawn.apparel.WornApparel : null; const float cellHeight = 40f; float apparelListWidth = inRect.width * 0.5f - 10f; Rect apparelListRect; Rect apparelScrollRect; if (wornApparel != null) { GUI.Label(new Rect(0, 60, 100, 30), ("ChangeDresser.Worn").Translate(), WidgetUtil.MiddleCenter); apparelListRect = new Rect(0, 90, apparelListWidth, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, apparelListWidth - 16f, wornApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < wornApparel.Count; ++i) { Apparel apparel = wornApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight); GUI.BeginGroup(rowRect); Widgets.ThingIcon(new Rect(0f, 0f, cellHeight, cellHeight), apparel); if (Widgets.InfoCardButton(40, 0, apparel)) { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); } Text.Font = GameFont.Small; Widgets.Label(new Rect(35f + cellHeight, 0f, rowRect.width - 110f, cellHeight), apparel.Label); GUI.color = Color.white; if (Widgets.ButtonImage(new Rect(rowRect.width - 35f, 10, 20, 20), WidgetUtil.nextTexture)) { this.Pawn.apparel.Remove(apparel); this.Dresser.AddApparel(apparel); this.cachedApparel.Clear(); this.cachedApparel = null; GUI.EndGroup(); break; } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } GUI.Label(new Rect((wornApparel == null) ? 0 : inRect.width * 0.5f, 60, (wornApparel == null) ? inRect.width : 100, 30), ("ChangeDresser.Storage").Translate(), WidgetUtil.MiddleCenter); float left = (wornApparel == null) ? 0 : inRect.width - apparelListWidth; float width = (wornApparel == null) ? inRect.width : apparelListWidth; apparelListRect = new Rect(left, 90, width, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, width - 16f, this.height); this.height = 2f; GUI.BeginGroup(apparelListRect); this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect); string filter = this.Filter.Trim().ToLower(); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < this.CachedApparel.Count; ++i) { Apparel apparel = this.cachedApparel[i]; if (filter != "" && apparel.Label.ToLower().IndexOf(filter) == -1) { continue; } Rect rowRect = new Rect(0, this.height, apparelScrollRect.width, cellHeight); this.height += cellHeight; GUI.BeginGroup(rowRect); if (this.Pawn != null) { Rect buttonRect = new Rect(5, 10, 20, 20); bool canWear = this.Pawn.apparel.CanWearWithoutDroppingAnything(apparel.def); if (canWear) { if (Widgets.ButtonImage(buttonRect, WidgetUtil.previousTexture)) { if (this.Dresser.TryRemove(apparel, false)) { this.cachedApparel.Clear(); this.cachedApparel = null; PawnOutfitTracker outfits; if (WorldComp.PawnOutfits.TryGetValue(this.Pawn, out outfits)) { outfits.ApplyApparelColor(apparel); } this.Pawn.apparel.Wear(apparel); GUI.EndGroup(); break; } else { Log.Error("Problem dropping " + apparel.Label); } } } else { Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture); } } Widgets.ThingIcon(new Rect(35f, 0f, cellHeight, cellHeight), apparel); if (Widgets.InfoCardButton(75, 0, apparel)) { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(30 + cellHeight + 15f, 0f, rowRect.width - 110f, cellHeight), apparel.Label); if (Widgets.ButtonImage(new Rect(rowRect.width - 45f, 0f, 20, 20), WidgetUtil.dropTexture)) { if (this.Dresser.TryRemove(apparel, false)) { this.cachedApparel.Clear(); this.cachedApparel = null; GUI.EndGroup(); break; } else { Log.Error("Problem dropping " + apparel.Label); } } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } catch (Exception e) { Log.Error(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message); Messages.Message(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message, MessageTypeDefOf.RejectInput); base.Close(); } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } }
public override void DoWindowContents(Rect inRect) { try { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 0, 200, 50), "ChangeDresser.ApparelStorageLabel".Translate()); Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(inRect.width * 0.5f, 10, 200, 30), "ChangeDresser.ApparelGroup".Translate())) { List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!this.FromGizmo) { list.Add(new FloatMenuOption("ChangeDresser.CreateFromWorn".Translate(), delegate { StoredApparelSet set = new StoredApparelSet(this.Dresser); Find.WindowStack.Add(new StorageGroupUI(set, ApparelFromEnum.Pawn, this.Dresser, this.Pawn, true, this.FromGizmo)); })); } list.Add(new FloatMenuOption("ChangeDresser.CreateFromStorage".Translate(), delegate { StoredApparelSet set = new StoredApparelSet(this.Dresser); Find.WindowStack.Add(new StorageGroupUI(set, ApparelFromEnum.Storage, this.Dresser, this.Pawn, true, this.FromGizmo)); })); if (this.FromGizmo) { this.CreateOptionsForUser(list); } else { this.CreateOptionsForPawn(list); } Find.WindowStack.Add(new FloatMenu(list, null, false)); } /*if (this.storageGroupDto.IsPawnRestricted) * { * Widgets.Label(new Rect(250, 0, 200, 50), "Owner: " + this.storageGroupDto.RestrictToPawnName); * } * * Rect rect = new Rect(0, 50, inRect.width, 30); * Text.Font = GameFont.Small; * GUI.BeginGroup(rect); * GUI.Label(new Rect(0, 0, 100, rect.height), "Group Name:", WidgetUtil.MiddleCenter); * this.storageGroupDto.GroupName = Widgets.TextField(new Rect(110, 0, 150, rect.height), this.storageGroupDto.GroupName); * * GUI.Label(new Rect(280, 0, 100, rect.height), "Restrict to Pawn:", WidgetUtil.MiddleCenter); * this.storageGroupDto.IsPawnRestricted = GUI.Toggle(new Rect(390, 7, rect.height, rect.height), this.storageGroupDto.IsPawnRestricted, ""); * * GUI.Label(new Rect(440, 0, 150, rect.height), "Force Switch Combat:", WidgetUtil.MiddleCenter); * this.storageGroupDto.ForceSwitchBattle = GUI.Toggle(new Rect(600, 7, rect.height, rect.height), this.storageGroupDto.ForceSwitchBattle, ""); * GUI.EndGroup();*/ List <Apparel> wornApparel = (!this.FromGizmo) ? this.Pawn.apparel.WornApparel : null; List <Apparel> storedApparel = this.Dresser.StoredApparel; const float cellHeight = 40f; float apparelListWidth = inRect.width * 0.5f - 10f; Rect apparelListRect; Rect apparelScrollRect; if (!this.FromGizmo) { apparelListRect = new Rect(0, 90, apparelListWidth, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, apparelListWidth - 16f, wornApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosLeft = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosLeft, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < wornApparel.Count; ++i) { Apparel apparel = wornApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelListRect.width, cellHeight); GUI.BeginGroup(rowRect); Widgets.ThingIcon(new Rect(0f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Widgets.Label(new Rect(cellHeight + 5f, 0f, rowRect.width - 40f - cellHeight, cellHeight), apparel.Label); GUI.color = Color.white; if (Widgets.ButtonImage(new Rect(rowRect.width - 35f, 10, 20, 20), WidgetUtil.nextTexture)) { this.Pawn.apparel.Remove(apparel); storedApparel.Add(apparel); GUI.EndGroup(); break; } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } apparelListRect = new Rect(inRect.width - apparelListWidth, 90, apparelListWidth, inRect.height - 130); apparelScrollRect = new Rect(0f, 0f, apparelListWidth - 16f, storedApparel.Count * cellHeight); GUI.BeginGroup(apparelListRect); this.scrollPosRight = GUI.BeginScrollView(new Rect(GenUI.AtZero(apparelListRect)), this.scrollPosRight, apparelScrollRect); GUI.color = Color.white; Text.Font = GameFont.Medium; for (int i = 0; i < storedApparel.Count; ++i) { Apparel apparel = storedApparel[i]; Rect rowRect = new Rect(0, 2f + i * cellHeight, apparelScrollRect.width, cellHeight); GUI.BeginGroup(rowRect); if (!this.FromGizmo) { Rect buttonRect = new Rect(5, 10, 20, 20); bool canWear = this.Pawn.apparel.CanWearWithoutDroppingAnything(apparel.def); if (canWear) { if (Widgets.ButtonImage(buttonRect, WidgetUtil.previousTexture)) { storedApparel.Remove(apparel); this.Pawn.apparel.Wear(apparel); GUI.EndGroup(); break; } } else { Widgets.ButtonImage(buttonRect, WidgetUtil.cantTexture); } } Widgets.ThingIcon(new Rect(35f, 0f, cellHeight, cellHeight), apparel); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(cellHeight + 45f, 0f, rowRect.width - cellHeight - 90f, cellHeight), apparel.Label); if (Widgets.ButtonImage(new Rect(rowRect.width - 45f, 0f, cellHeight, cellHeight), WidgetUtil.dropTexture)) { this.Dresser.Remove(apparel, false); GUI.EndGroup(); break; } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); } catch (Exception e) { Log.Error(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message); Messages.Message(this.GetType().Name + " closed due to: " + e.GetType().Name + " " + e.Message, MessageSound.Negative); base.Close(); } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } }