protected override void DrawPanelContent(State state) { /* * // Test code for adjusting the size and position of the portrait. * if (Event.current.type == EventType.KeyDown) { * if (Event.current.shift) { * if (Event.current.keyCode == KeyCode.LeftArrow) { * float portraitWidth = RectPortrait.width; * portraitWidth -= 1f; * float portraitHeight = Mathf.Floor(portraitWidth * 1.4f); * RectPortrait = new Rect(RectPortrait.x, RectPortrait.y, portraitWidth, portraitHeight); * Log.Message("RectPortrait = " + RectPortrait); * } * else if (Event.current.keyCode == KeyCode.RightArrow) { * float portraitWidth = RectPortrait.width; * portraitWidth += 1f; * float portraitHeight = Mathf.Floor(portraitWidth * 1.4f); * RectPortrait = new Rect(RectPortrait.x, RectPortrait.y, portraitWidth, portraitHeight); * Log.Message("RectPortrait = " + RectPortrait); * } * } * else { * if (Event.current.keyCode == KeyCode.LeftArrow) { * RectPortrait = RectPortrait.OffsetBy(new Vector2(-1, 0)); * Log.Message("RectPortrait = " + RectPortrait); * } * else if (Event.current.keyCode == KeyCode.RightArrow) { * RectPortrait = RectPortrait.OffsetBy(new Vector2(1, 0)); * Log.Message("RectPortrait = " + RectPortrait); * } * else if (Event.current.keyCode == KeyCode.UpArrow) { * RectPortrait = RectPortrait.OffsetBy(new Vector2(0, -1)); * Log.Message("RectPortrait = " + RectPortrait); * } * else if (Event.current.keyCode == KeyCode.DownArrow) { * RectPortrait = RectPortrait.OffsetBy(new Vector2(0, 1)); * Log.Message("RectPortrait = " + RectPortrait); * } * } * } */ base.DrawPanelContent(state); CustomPawn currentPawn = state.CurrentPawn; CustomPawn pawnToSelect = null; CustomPawn pawnToSwap = null; CustomPawn pawnToDelete = null; List <CustomPawn> pawns = GetPawnListFromState(state); int colonistCount = pawns.Count(); if (IsMinimized(state)) { // Count label. Text.Font = GameFont.Medium; float headerWidth = Text.CalcSize(PanelHeader).x; Rect countRect = new Rect(10 + headerWidth + 3, 3, 50, 27); GUI.color = Style.ColorTextPanelHeader; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.LowerLeft; Widgets.Label(countRect, "EdB.PC.Panel.PawnList.PawnCount".Translate(colonistCount)); GUI.color = Color.white; // Maximize button. if (RectHeader.Contains(Event.current.mousePosition)) { GUI.color = Style.ColorButtonHighlight; } else { GUI.color = Style.ColorButton; } GUI.DrawTexture(RectMaximize, IsTopPanel() ? Textures.TextureMaximizeDown : Textures.TextureMaximizeUp); if (Widgets.ButtonInvisible(RectHeader, false)) { SoundDefOf.ThingSelected.PlayOneShotOnCamera(); Maximize(); } return; } float cursor = 0; GUI.BeginGroup(RectScrollFrame); scrollView.Begin(RectScrollView); try { LabelTrimmer nameTrimmer = scrollView.ScrollbarsVisible ? nameTrimmerWithScrollbar : nameTrimmerNoScrollbar; LabelTrimmer descriptionTrimmer = scrollView.ScrollbarsVisible ? descriptionTrimmerWithScrollbar : descriptionTrimmerNoScrollbar; foreach (var pawn in pawns) { bool selected = pawn == currentPawn; Rect rect = RectEntry; rect.y += cursor; rect.width -= (scrollView.ScrollbarsVisible ? 16 : 0); GUI.color = Style.ColorPanelBackground; GUI.DrawTexture(rect, BaseContent.WhiteTex); GUI.color = Color.white; if (selected || rect.Contains(Event.current.mousePosition)) { if (selected) { GUI.color = new Color(66f / 255f, 66f / 255f, 66f / 255f); Widgets.DrawBox(rect, 1); } GUI.color = Color.white; Rect deleteRect = RectButtonDelete.OffsetBy(rect.position); deleteRect.x = deleteRect.x - (scrollView.ScrollbarsVisible ? 16 : 0); if (CanDeleteLastPawn || colonistCount > 1) { Style.SetGUIColorForButton(deleteRect); GUI.DrawTexture(deleteRect, Textures.TextureButtonDelete); // For some reason, this GUI.Button call is causing weirdness with text field focus (select // text in one of the name fields and hover over the pawns in the pawn list to see what I mean). // Replacing it with a mousedown event check fixes it for some reason. //if (GUI.Button(deleteRect, string.Empty, Widgets.EmptyStyle)) { if (Event.current.type == EventType.MouseDown && deleteRect.Contains(Event.current.mousePosition)) { // Shift-click skips the confirmation dialog if (Event.current.shift) { // Delete after we've iterated and drawn everything pawnToDelete = pawn; } else { CustomPawn localPawn = pawn; Find.WindowStack.Add( new Dialog_Confirm("EdB.PC.Panel.PawnList.Delete.Confirm".Translate(), delegate { PawnDeleted(localPawn); }, true, null, true) ); } } GUI.color = Color.white; } if (rect.Contains(Event.current.mousePosition)) { Rect swapRect = RectButtonSwap.OffsetBy(rect.position); swapRect.x -= (scrollView.ScrollbarsVisible ? 16 : 0); if (CanDeleteLastPawn || colonistCount > 1) { Style.SetGUIColorForButton(swapRect); GUI.DrawTexture(swapRect, pawn.Type == CustomPawnType.Colonist ? Textures.TextureButtonWorldPawn : Textures.TextureButtonColonyPawn); if (Event.current.type == EventType.MouseDown && swapRect.Contains(Event.current.mousePosition)) { pawnToSwap = pawn; } GUI.color = Color.white; } } } Rect pawnRect = RectPortrait.OffsetBy(rect.position); GUI.color = Color.white; RenderTexture pawnTexture = pawn.GetPortrait(pawnRect.size); Rect clipRect = RectEntry.OffsetBy(rect.position); try { GUI.BeginClip(clipRect); GUI.DrawTexture(RectPortrait, (Texture)pawnTexture); } finally { GUI.EndClip(); } GUI.color = new Color(238f / 255f, 238f / 255f, 238f / 255f); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.LowerLeft; Rect nameRect = RectName.OffsetBy(rect.position); nameRect.width = nameRect.width - (scrollView.ScrollbarsVisible ? 16 : 0); Vector2 nameSize = Text.CalcSize(pawn.Pawn.LabelShort); Widgets.Label(nameRect, nameTrimmer.TrimLabelIfNeeded(pawn.Pawn.LabelShort)); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(184f / 255f, 184f / 255f, 184f / 255f); Rect professionRect = RectDescription.OffsetBy(rect.position); professionRect.width = professionRect.width - (scrollView.ScrollbarsVisible ? 16 : 0); string description = null; if (pawn.IsAdult) { if (pawn.Adulthood != null) { description = pawn.Adulthood.TitleShortCapFor(pawn.Gender); } } else { description = pawn.Childhood.TitleShortCapFor(pawn.Gender); } if (!description.NullOrEmpty()) { Widgets.Label(professionRect, descriptionTrimmer.TrimLabelIfNeeded(description)); } if (pawn != state.CurrentPawn && Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && pawnToSwap == null) { pawnToSelect = pawn; } cursor += rect.height + SizeEntrySpacing; } cursor -= SizeEntrySpacing; } finally { scrollView.End(cursor); GUI.EndGroup(); } GUI.color = Color.white; Text.Font = GameFont.Tiny; if (Widgets.ButtonText(RectButtonAdd, "EdB.PC.Common.Add".Translate(), true, false, true)) { SoundDefOf.SelectDesignator.PlayOneShotOnCamera(); AddingPawn(StartingPawns); } if (Widgets.ButtonText(RectButtonAdvancedAdd, "...", true, false, true)) { ShowPawnKindDialog(); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; if (pawnToDelete != null) { PawnDeleted(pawnToDelete); } else if (pawnToSwap != null) { PawnSwapped(pawnToSwap); } else if (pawnToSelect != null) { PawnSelected(pawnToSelect); } }