Skip to content

Commit

Permalink
Merge pull request #39 from ISOR3X/main2
Browse files Browse the repository at this point in the history
Main2 into main
  • Loading branch information
ISOR3X authored Dec 10, 2023
2 parents 45b10c5 + 3319fe0 commit 15aaa5a
Show file tree
Hide file tree
Showing 65 changed files with 2,633 additions and 1,191 deletions.
Binary file modified Assemblies/PawnEditor.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Languages/English/Keyed/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<PawnEditor.UseSilver.Desc>Point limit will be amount of silver in the current colony, and usage of points will deduct silver.</PawnEditor.UseSilver.Desc>
<PawnEditor.CountNPCs>Count NPC pawns in points</PawnEditor.CountNPCs>
<PawnEditor.CountNPCs.Desc>If enabled, then NPC pawns will also impact your point limit.</PawnEditor.CountNPCs.Desc>
<PawnEditor.ShowEditButton>Show edit gizmo</PawnEditor.ShowEditButton>
<PawnEditor.ShowEditButton.Desc>Show a button in the bar of buttons on the bottom to open the pawn editor to a selected pawn.</PawnEditor.ShowEditButton.Desc>
<PawnEditor.ResetConfirmation>Reset all confirmation messages</PawnEditor.ResetConfirmation>
</LanguageData>
22 changes: 16 additions & 6 deletions Languages/English/Keyed/UI.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
<PawnEditor.WorkDisablesDesc>Hide backstories that have disabled work types.</PawnEditor.WorkDisablesDesc>
<PawnEditor.SkillLose>Hide backstories with negative skill gains</PawnEditor.SkillLose>
<PawnEditor.SkillLoseDesc>Hide backstories that have disabled work types.</PawnEditor.SkillLoseDesc>
<PawnEditor.MinAbilityLevel>Min. level</PawnEditor.MinAbilityLevel>
<PawnEditor.MinAbilityLevelDesc>Set the minimum level the psycast should be.</PawnEditor.MinAbilityLevelDesc>
<PawnEditor.MinAbilityLevel>Level</PawnEditor.MinAbilityLevel>
<PawnEditor.MinAbilityLevelDesc>The level range of psycasts to show.</PawnEditor.MinAbilityLevelDesc>
<PawnEditor.HasStyle>Has style</PawnEditor.HasStyle>
<PawnEditor.HasStuff>Has stuff</PawnEditor.HasStuff>
<PawnEditor.WornOnBodyPart>Worn on body part</PawnEditor.WornOnBodyPart>
Expand All @@ -154,6 +154,8 @@
<PawnEditor.IsImplant>Is implant</PawnEditor.IsImplant>
<PawnEditor.IsDisease>Is disease</PawnEditor.IsDisease>
<PawnEditor.OccupiesLayer>Occupies layer</PawnEditor.OccupiesLayer>
<PawnEditor.IsHuman>Is human</PawnEditor.IsHuman>
<PawnEditor.IsColonist>Is colonist</PawnEditor.IsColonist>

<!-- Options -->
<PawnEditor.Tainted>Tainted</PawnEditor.Tainted>
Expand All @@ -163,16 +165,13 @@
<PawnEditor.IsPermanent>Is permanent</PawnEditor.IsPermanent>
<PawnEditor.BodyPart>Body part</PawnEditor.BodyPart>


<!-- Unsorted -->
<PawnEditor.ScatteredLoot>scattered loot</PawnEditor.ScatteredLoot>
<PawnEditor.EquipmentLootDesc>Equipment is spawned in the vicinity of colonists, scattered loot (or structures), are randomly spread around the map.</PawnEditor.EquipmentLootDesc>
<PawnEditor.FactionRep>Faction reputation</PawnEditor.FactionRep>
<PawnEditor.Settlements>Settlements</PawnEditor.Settlements>
<PawnEditor.DistanceFromColony>Distance from colony</PawnEditor.DistanceFromColony>
<PawnEditor.DistanceFromColony.Calculate>Calculate distance from colony</PawnEditor.DistanceFromColony.Calculate>
<!-- <PawnEditor.Hediff>hediff</PawnEditor.Hediff> -->
<PawnEditor.Hediffs>hediffs</PawnEditor.Hediffs>
<PawnEditor.TraitDisallowedByKind>Trait {0} is not allowed on {1}.</PawnEditor.TraitDisallowedByKind>
<PawnEditor.TraitConflicts>Trait {0} conflicts with trait {1}.</PawnEditor.TraitConflicts>
<PawnEditor.TraitWorkDisabled>{0} can't do {1}, which is required by {2}.</PawnEditor.TraitWorkDisabled>
Expand All @@ -183,10 +182,21 @@
<PawnEditor.HediffDuplicate>Are you sure you want to add duplicate hediff {0}?</PawnEditor.HediffDuplicate>
<PawnEditor.Teleport.Specific>Teleport to exact location</PawnEditor.Teleport.Specific>
<PawnEditor.AdditionalInfo>Additional info</PawnEditor.AdditionalInfo>
<PawnEditor.NotEnoughPoints>Not enough points. Need {0}.</PawnEditor.NotEnoughPoints>
<PawnEditor.NotEnoughPoints>Not enough points. Need {0}, have {1}.</PawnEditor.NotEnoughPoints>
<PawnEditor.ExportImage>Export portrait</PawnEditor.ExportImage>
<PawnEditor.ImageExported>Exported portrait of {0} to {1}.</PawnEditor.ImageExported>
<PawnEditor.NegativePoints>Remaining points is negative.</PawnEditor.NegativePoints>
<PawnEditor.ClickToOpen>Click to view infocard</PawnEditor.ClickToOpen>
<PawnEditor.MustBeOneEachGender>Pawns must be one male and one female.</PawnEditor.MustBeOneEachGender>
<PawnEditor.WouldMakeOverCapacity>Adding {0} would {1} over their carrying capacity.</PawnEditor.WouldMakeOverCapacity>
<PawnEditor.Edit>Edit</PawnEditor.Edit>
<PawnEditor.Edit.Desc>Open the pawn editor to this pawn.</PawnEditor.Edit.Desc>
<PawnEditor.RelationExists>{0} already has an existing relation of type {1}. Do you still want to add this relation?</PawnEditor.RelationExists>
<PawnEditor.DontShowAgain>Don't show again</PawnEditor.DontShowAgain>
<PawnEditor.ThoughtDuplicate>Thought of same type already exists. Do you still want to add this?</PawnEditor.ThoughtDuplicate>
<PawnEditor.CannotGetThought>{0} can't get the thought {1}.</PawnEditor.CannotGetThought>
<PawnEditor.AddThoughNullified>Add {0} anyway?</PawnEditor.AddThoughNullified>
<PawnEditor.MoodOffset>Mood offset</PawnEditor.MoodOffset>

<!-- Quick Actions -->
<PawnEditor.RepairAll>Repair all</PawnEditor.RepairAll>
Expand Down
51 changes: 42 additions & 9 deletions Source/PawnEditor/Dialogs/Dialog_AppearanceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public Dialog_AppearanceEditor(Pawn pawn)
closeOnAccept = false;
closeOnCancel = true;
forceCatchAcceptAndCancelEventEvenIfUnfocused = true;

if (HARCompat.Active)
HARCompat.Notify_AppearanceEditorOpen(pawn);
}

public override float Margin => 8;
Expand Down Expand Up @@ -148,6 +151,8 @@ public override void DoWindowContents(Rect inRect)
mainTabs.Add(new("Tattoos".Translate(), () => mainTab = MainTab.Tattoos, mainTab == MainTab.Tattoos));
if (ModsConfig.BiotechActive)
mainTabs.Add(new("Xenotype".Translate(), () => mainTab = MainTab.Xenotype, mainTab == MainTab.Xenotype));
if (HARCompat.Active)
mainTabs.Add(new("HAR.RaceFeatures".Translate(), () => mainTab = MainTab.HAR, mainTab == MainTab.HAR));

Widgets.DrawMenuSection(inRect);
TabDrawer.DrawTabs(inRect, mainTabs, 400f);
Expand All @@ -164,7 +169,23 @@ public override void DoWindowContents(Rect inRect)
switch (shapeTab)
{
case ShapeTab.Body:
DoIconOptions(inRect.ContractedBy(5), DefDatabase<BodyTypeDef>.AllDefsListForReading, def =>
var bodyTypes = DefDatabase<BodyTypeDef>.AllDefs.Where(bodyType =>
pawn.DevelopmentalStage switch
{
DevelopmentalStage.Baby or DevelopmentalStage.Newborn => bodyType == BodyTypeDefOf.Baby,
DevelopmentalStage.Child => bodyType == BodyTypeDefOf.Child,
DevelopmentalStage.Adult => bodyType != BodyTypeDefOf.Baby && bodyType != BodyTypeDefOf.Child,
_ => true
});

if (HARCompat.Active)
{
var allowedBodyTypes = HARCompat.AllowedBodyTypes(pawn);
if (!allowedBodyTypes.NullOrEmpty()) bodyTypes = bodyTypes.Intersect(allowedBodyTypes);
}

DoIconOptions(inRect.ContractedBy(5), bodyTypes
.ToList(), def =>
{
pawn.story.bodyType = def;
TabWorker_Bio_Humanlike.RecacheGraphics(pawn);
Expand All @@ -173,7 +194,15 @@ public override void DoWindowContents(Rect inRect)
DefDatabase<ColorDef>.AllDefs.Select(def => def.color).ToList());
break;
case ShapeTab.Head:
DoIconOptions(inRect.ContractedBy(5), DefDatabase<HeadTypeDef>.AllDefsListForReading, def =>
var headTypes = DefDatabase<HeadTypeDef>.AllDefs;
if (HARCompat.Active)
{
headTypes = HARCompat.FilterHeadTypes(headTypes, pawn);
// HAR doesn't like head types not matching genders
headTypes = headTypes.Where(type => type.gender == Gender.None || type.gender == pawn.gender);
}

DoIconOptions(inRect.ContractedBy(5), headTypes.ToList(), def =>
{
pawn.story.headType = def;
TabWorker_Bio_Humanlike.RecacheGraphics(pawn);
Expand Down Expand Up @@ -208,7 +237,7 @@ public override void DoWindowContents(Rect inRect)
{
case ShapeTab.Body:
DoIconOptions(inRect.ContractedBy(5),
DefDatabase<TattooDef>.AllDefsListForReading.Where(td => td.tattooType == TattooType.Body).ToList(), def =>
DefDatabase<TattooDef>.AllDefs.Where(td => td.tattooType == TattooType.Body).ToList(), def =>
{
pawn.style.BodyTattoo = def;
TabWorker_Bio_Humanlike.RecacheGraphics(pawn);
Expand All @@ -217,7 +246,7 @@ public override void DoWindowContents(Rect inRect)
break;
case ShapeTab.Head:
DoIconOptions(inRect.ContractedBy(5),
DefDatabase<TattooDef>.AllDefsListForReading.Where(td => td.tattooType == TattooType.Face).ToList(), def =>
DefDatabase<TattooDef>.AllDefs.Where(td => td.tattooType == TattooType.Face).ToList(), def =>
{
pawn.style.FaceTattoo = def;
TabWorker_Bio_Humanlike.RecacheGraphics(pawn);
Expand All @@ -233,6 +262,11 @@ public override void DoWindowContents(Rect inRect)
inRect.yMin -= TabDrawer.TabHeight;
DoXenotypeOptions(inRect.ContractedBy(5));
break;
case MainTab.HAR:
HARCompat.DoRaceTabs(inRect.ContractedBy(5));
if (Event.current.type is EventType.MouseDown or EventType.Used)
TabWorker_Bio_Humanlike.RecacheGraphics(pawn);
break;
default:
throw new ArgumentOutOfRangeException();
}
Expand Down Expand Up @@ -289,13 +323,11 @@ private void DoIconOptions<T>(Rect inRect, List<T> options, Action<T> onSelected
Widgets.DrawHighlight(rect);

if (option is Def def)
{
if (Mouse.IsOver(rect))
{
Widgets.DrawLightHighlight(rect);
if (def.LabelCap != null) TooltipHandler.TipRegion(rect, def.LabelCap);
}
}

if (isSelected(option)) Widgets.DrawBox(rect);
if (Widgets.ButtonInvisible(rect)) onSelected(option);
Expand Down Expand Up @@ -361,7 +393,7 @@ private void DoGeneOptions(ref Rect inRect, string label, List<GeneDef> options)
}
}

GUI.color = enabled ? Color.gray : Color.white;
GUI.color = enabled ? Color.white : Color.gray;
// ToDo: Apply correct gene background texture according to gene category.
GUI.DrawTexture(rect.ContractedBy(4), GeneUIUtility.GeneBackground_Endogene.Texture);
GUI.color *= option.IconColor;
Expand Down Expand Up @@ -468,7 +500,7 @@ private void DoLeftSection(Rect inRect)
{
if (Widgets.ButtonImage(new(r.x, r.y + (r.height - r.width) / 2f, r.width, r.width), TexButton.DeleteX, GUI.color))
{
Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(customInner.name.CapitalizeFirst()),
Find.WindowStack.Add(new Dialog_Confirm("ConfirmDelete".Translate(customInner.name.CapitalizeFirst()), "ConfirmDeleteXenotype",
delegate
{
var path = GenFilePaths.AbsFilePathForXenotype(customInner.name);
Expand Down Expand Up @@ -559,7 +591,8 @@ private enum MainTab
Shape,
Hair,
Tattoos,
Xenotype
Xenotype,
HAR
}

private enum ShapeTab
Expand Down
43 changes: 43 additions & 0 deletions Source/PawnEditor/Dialogs/Dialog_Confirm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using UnityEngine;
using Verse;

namespace PawnEditor;

[HotSwappable]
public class Dialog_Confirm : Dialog_MessageBox
{
private readonly string confirmationKey;
private bool dontShowAgain;

public Dialog_Confirm(TaggedString text, string key, Action confirmedAct, bool destructive = false, string title = null,
WindowLayer layer = WindowLayer.Dialog) :
base(text, "Confirm".Translate(), confirmedAct, "GoBack".Translate(), null, title, destructive, confirmedAct, delegate { }, layer) =>
confirmationKey = key;

public override void PreOpen()
{
if (PawnEditorMod.Settings.DontShowAgain.Contains(confirmationKey))
{
acceptAction();
Close(false);
}

base.PreOpen();
buttonAAction += CheckAddHide;
acceptAction += CheckAddHide;
}

private void CheckAddHide()
{
if (dontShowAgain) PawnEditorMod.Settings.DontShowAgain.Add(confirmationKey);
}

public override void DoWindowContents(Rect inRect)
{
var text = "PawnEditor.DontShowAgain".Translate();
var width = Text.CalcSize(text).x + 24 + 10;
Widgets.CheckboxLabeled(new(inRect.width - width, inRect.height - 80, width, 30), text, ref dontShowAgain, placeCheckboxNearText: true);
base.DoWindowContents(inRect);
}
}
Loading

0 comments on commit 15aaa5a

Please sign in to comment.