From 739a4cbfe631beb6e30b97bc2cca0d2c8a93f5bb Mon Sep 17 00:00:00 2001 From: librarianmage Date: Tue, 5 Jul 2022 16:55:21 +0000 Subject: [PATCH 1/5] Add stub Pronoun provider patch FossilOrigin-Name: 983b24a6d1eaf458bf1d30491f9a8912492329bcab70261f1728c32ad0f56b6a --- patches.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patches.cs b/patches.cs index 4553348..6fd58d3 100644 --- a/patches.cs +++ b/patches.cs @@ -1,6 +1,8 @@ using HarmonyLib; +using System; using System.Collections.Generic; using System.Reflection; +using System.Text; using XRL; using XRL.World; using XRL.CharacterBuilds.Qud.UI; @@ -47,4 +49,14 @@ public static IEnumerable Transpiler(IEnumerable Date: Tue, 5 Jul 2022 17:00:33 +0000 Subject: [PATCH 2/5] Add =name= pronoun replacer FossilOrigin-Name: a16cb565ff57b231ab023d2071863a98af65efa1d49913be6b2221a776051e43 --- patches.cs | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/patches.cs b/patches.cs index 6fd58d3..aaa5443 100644 --- a/patches.cs +++ b/patches.cs @@ -1,11 +1,11 @@ using HarmonyLib; -using System; using System.Collections.Generic; using System.Reflection; -using System.Text; using XRL; using XRL.World; using XRL.CharacterBuilds.Qud.UI; +using ConsoleLib.Console; +using XRL.Language; namespace QudGendersUnleashed.HarmonyPatches { @@ -39,7 +39,8 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions) @@ -54,9 +55,106 @@ public static IEnumerable Transpiler(IEnumerable ReplaceWithName(BasePronouns.Name); + + public string CapitalizedName => ReplaceWithName(BasePronouns.CapitalizedName, true); + + public bool Generic => BasePronouns.Generic; + + public bool Generated => BasePronouns.Generated; + + public bool Plural => BasePronouns.Plural; + + public bool PseudoPlural => BasePronouns.PseudoPlural; + + public string Subjective => ReplaceWithName(BasePronouns.Subjective); + + public string CapitalizedSubjective => ReplaceWithName(BasePronouns.CapitalizedSubjective, true); + + public string Objective => ReplaceWithName(BasePronouns.Objective); + + public string CapitalizedObjective => ReplaceWithName(BasePronouns.CapitalizedObjective, true); + + public string PossessiveAdjective => ReplaceWithName(BasePronouns.PossessiveAdjective); + + public string CapitalizedPossessiveAdjective => ReplaceWithName(BasePronouns.CapitalizedPossessiveAdjective, true); + + public string SubstantivePossessive => ReplaceWithName(BasePronouns.SubstantivePossessive); + + public string CapitalizedSubstantivePossessive => ReplaceWithName(BasePronouns.CapitalizedSubstantivePossessive); + + public string Reflexive => ReplaceWithName(BasePronouns.Reflexive); + + public string CapitalizedReflexive => ReplaceWithName(BasePronouns.CapitalizedReflexive, true); + + // Consider: The methods below here are unlikely to contain =name=/=name's=, remove wrap? + public string PersonTerm => ReplaceWithName(BasePronouns.PersonTerm); + + public string CapitalizedPersonTerm => ReplaceWithName(BasePronouns.CapitalizedPersonTerm, true); + + public string ImmaturePersonTerm => ReplaceWithName(BasePronouns.ImmaturePersonTerm); + + public string CapitalizedImmaturePersonTerm => ReplaceWithName(BasePronouns.CapitalizedImmaturePersonTerm, true); + + public string FormalAddressTerm => ReplaceWithName(BasePronouns.FormalAddressTerm); + + public string CapitalizedFormalAddressTerm => ReplaceWithName(BasePronouns.CapitalizedFormalAddressTerm, true); + + public string OffspringTerm => ReplaceWithName(BasePronouns.OffspringTerm); + + public string CapitalizedOffspringTerm => ReplaceWithName(BasePronouns.CapitalizedOffspringTerm, true); + + public string SiblingTerm => ReplaceWithName(BasePronouns.SiblingTerm); + + public string CapitalizedSiblingTerm => ReplaceWithName(BasePronouns.CapitalizedSiblingTerm, true); + + public string ParentTerm => ReplaceWithName(BasePronouns.ParentTerm); + + public string CapitalizedParentTerm => ReplaceWithName(BasePronouns.CapitalizedParentTerm, true); + + public string IndicativeProximal => ReplaceWithName(BasePronouns.IndicativeProximal); + + public string CapitalizedIndicativeProximal => ReplaceWithName(BasePronouns.CapitalizedIndicativeProximal, true); + + public string IndicativeDistal => ReplaceWithName(BasePronouns.IndicativeDistal); + + public string CapitalizedIndicativeDistal => ReplaceWithName(BasePronouns.CapitalizedIndicativeDistal, true); + + public bool UseBareIndicative => BasePronouns.UseBareIndicative; + } } From 90cf66ae54e1a03a5368bfd90dd2ac302c87056e Mon Sep 17 00:00:00 2001 From: librarianmage Date: Tue, 5 Jul 2022 23:12:14 +0000 Subject: [PATCH 3/5] Split patches into two files FossilOrigin-Name: fb0ec7db1260fe802ee8c385764267a01e520fcc82d8eee75242ea76a2fe915d --- patches.cs => namepronoun.cs | 50 ++------------------------------ selectors.cs | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 48 deletions(-) rename patches.cs => namepronoun.cs (67%) create mode 100644 selectors.cs diff --git a/patches.cs b/namepronoun.cs similarity index 67% rename from patches.cs rename to namepronoun.cs index aaa5443..c10cbc9 100644 --- a/patches.cs +++ b/namepronoun.cs @@ -1,56 +1,10 @@ using HarmonyLib; -using System.Collections.Generic; -using System.Reflection; -using XRL; using XRL.World; -using XRL.CharacterBuilds.Qud.UI; -using ConsoleLib.Console; using XRL.Language; +using ConsoleLib.Console; -namespace QudGendersUnleashed.HarmonyPatches +namespace QudGendersUnleashed.NamePronoun { - [HarmonyPatch] - public static class CharacterCreationGenderPatch - { - public static MethodInfo TargetMethod() - { - return AccessTools.DeclaredMethod(AccessTools.Inner(typeof(QudCustomizeCharacterModuleWindow), "d__5"), "MoveNext"); - } - public static IEnumerable Transpiler(IEnumerable instructions) - { - MethodInfo oldMethod = AccessTools.Method(typeof(Gender), nameof(Gender.GetAllGenericPersonalSingular)); - MethodInfo newMethod = AccessTools.Method(typeof(Gender), nameof(Gender.GetAllPersonal)); - return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); - } - } - - [HarmonyPatch] - public static class CharacterCreationPronounPatch - { - public static MethodBase TargetMethod() - { - return AccessTools.DeclaredMethod(AccessTools.Inner(typeof(QudCustomizeCharacterModuleWindow), "d__7"), "MoveNext"); - } - public static IEnumerable Transpiler(IEnumerable instructions) - { - MethodInfo oldMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllGenericPersonalSingular)); - MethodInfo newMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllPersonal)); - return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); - } - } - - [HarmonyPatch(typeof(PronounAndGenderSets))] - [HarmonyPatch(nameof(PronounAndGenderSets.ShowChangePronounSet))] - public static class PlaytimePronounPatch - { - public static IEnumerable Transpiler(IEnumerable instructions) - { - MethodInfo oldMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllGenericPersonal)); - MethodInfo newMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllPersonal)); - return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); - } - } - [HarmonyPatch(typeof(GameObject))] [HarmonyPatch(nameof(GameObject.GetPronounProvider))] public static class NameOnlyPronounPatch diff --git a/selectors.cs b/selectors.cs new file mode 100644 index 0000000..85a77ab --- /dev/null +++ b/selectors.cs @@ -0,0 +1,55 @@ +using HarmonyLib; +using System.Collections.Generic; +using System.Reflection; +using XRL; +using XRL.World; +using XRL.CharacterBuilds.Qud.UI; + +namespace QudGendersUnleashed.PronounAndGenderSelectorPatches +{ + [HarmonyPatch] + public static class CharacterCreationGenderPatch + { + public static MethodInfo TargetMethod() + { + return AccessTools.DeclaredMethod(AccessTools.Inner(typeof(QudCustomizeCharacterModuleWindow), "d__5"), "MoveNext"); + } + public static IEnumerable Transpiler(IEnumerable instructions) + { + MethodInfo oldMethod = AccessTools.Method(typeof(Gender), nameof(Gender.GetAllGenericPersonalSingular)); + MethodInfo newMethod = AccessTools.Method(typeof(Gender), nameof(Gender.GetAllPersonal)); + return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); + } + } + + [HarmonyPatch] + public static class CharacterCreationPronounPatch + { + public static MethodBase TargetMethod() + { + return AccessTools.DeclaredMethod(AccessTools.Inner(typeof(QudCustomizeCharacterModuleWindow), "d__7"), "MoveNext"); + } + public static IEnumerable Transpiler(IEnumerable instructions) + { + MethodInfo oldMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllGenericPersonalSingular)); + MethodInfo newMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllPersonal)); + return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); + } + } + + [HarmonyPatch(typeof(PronounAndGenderSets))] + [HarmonyPatch(nameof(PronounAndGenderSets.ShowChangePronounSet))] + public static class PlaytimePronounPatch + { + public static IEnumerable Transpiler(IEnumerable instructions) + { + MethodInfo oldMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllGenericPersonal)); + MethodInfo newMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllPersonal)); + return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); + } + } + + + + +} From 5cc5e2cb647593e9d2493d392998db9452254695 Mon Sep 17 00:00:00 2001 From: librarianmage Date: Wed, 6 Jul 2022 04:57:58 +0000 Subject: [PATCH 4/5] Update play time pronoun selector to modern UI FossilOrigin-Name: 727190bd9cc03ab506d94ad52be5fbe69215b3fcb43bed3ac664af393e56e469 --- selectors.cs | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/selectors.cs b/selectors.cs index 85a77ab..83fdc92 100644 --- a/selectors.cs +++ b/selectors.cs @@ -1,9 +1,11 @@ using HarmonyLib; using System.Collections.Generic; +using System.Linq; using System.Reflection; using XRL; using XRL.World; using XRL.CharacterBuilds.Qud.UI; +using XRL.UI; namespace QudGendersUnleashed.PronounAndGenderSelectorPatches { @@ -31,12 +33,14 @@ public static MethodBase TargetMethod() } public static IEnumerable Transpiler(IEnumerable instructions) { + MethodInfo oldMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllGenericPersonalSingular)); MethodInfo newMethod = AccessTools.Method(typeof(PronounSet), nameof(PronounSet.GetAllPersonal)); return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); } } + // Technically unused [HarmonyPatch(typeof(PronounAndGenderSets))] [HarmonyPatch(nameof(PronounAndGenderSets.ShowChangePronounSet))] public static class PlaytimePronounPatch @@ -50,6 +54,60 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions) + { + MethodInfo oldMethod = AccessTools.Method(typeof(PronounAndGenderSets), nameof(PronounAndGenderSets.ShowChangePronounSet)); + MethodInfo newMethod = AccessTools.Method(typeof(StatusScreenPatch), nameof(StatusScreenPatch.ChangePronounSet)); + return HarmonyLib.Transpilers.MethodReplacer(instructions, oldMethod, newMethod); + } + + public static void ChangePronounSet(GameObject Player) + { + List availablePronounSets = PronounSet.GetAllPersonal(); + PronounSet currentPronounSet = Player.GetPronounSet(); + int indexCurrentPronounSet = availablePronounSets.FindIndex(p => p.Name == currentPronounSet.Name); + + List options = new List(); + options.Add(""); + options.AddRange(availablePronounSets.Select((PronounSet pronounSet) => pronounSet.Name)); + // options.Add(""); + + var index = Popup.ShowOptionList( + Title: "Change Pronoun Set", + Options: options.ToArray(), + AllowEscape: true, + defaultSelected: indexCurrentPronounSet + 1); + + if (index > -1) + { + // Option was selected + if (options[index] != "") + { + // Option was not + PronounSet selected; + if (index == 0) + { + Gender playerGender = Player.GetGender(); + selected = new PronounSet(playerGender); + } + else + { + selected = availablePronounSets[index - 1]; + } + Player.SetPronounSet(selected.Register()); + + } + else + { + // Currently unimplemented because the current customization process uses async stuff and this is in the old UI + } + } + } + } } From 1aa37dcf8c9fcb3d95f4a7bd505522ce925e729e Mon Sep 17 00:00:00 2001 From: librarianmage Date: Wed, 6 Jul 2022 06:05:50 +0000 Subject: [PATCH 5/5] Add pronoun set option FossilOrigin-Name: c11b794d2337b39dbab248c5442d96264d6d6e1bf5aff922e5b6c6293aae3c5b --- selectors.cs | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/selectors.cs b/selectors.cs index 83fdc92..454d0f5 100644 --- a/selectors.cs +++ b/selectors.cs @@ -6,6 +6,7 @@ using XRL.World; using XRL.CharacterBuilds.Qud.UI; using XRL.UI; +using System.Threading.Tasks; namespace QudGendersUnleashed.PronounAndGenderSelectorPatches { @@ -66,17 +67,31 @@ public static IEnumerable Transpiler(IEnumerable newPronounTask = OnChoosePronounSetAsync(Player); + newPronounTask.Wait(); + PronounSet newPronoun = newPronounTask.Result; + + if (newPronoun != null) + { + Player.SetPronounSet(newPronoun.Register()); + } + } + + public static async Task OnChoosePronounSetAsync(GameObject Player) { List availablePronounSets = PronounSet.GetAllPersonal(); + IEnumerable pronounNames = availablePronounSets.Select((PronounSet pronounSet) => pronounSet.Name); + PronounSet currentPronounSet = Player.GetPronounSet(); - int indexCurrentPronounSet = availablePronounSets.FindIndex(p => p.Name == currentPronounSet.Name); + int indexCurrentPronounSet = availablePronounSets.FindIndex(p => p == currentPronounSet); List options = new List(); options.Add(""); - options.AddRange(availablePronounSets.Select((PronounSet pronounSet) => pronounSet.Name)); - // options.Add(""); + options.AddRange(pronounNames); + options.Add(""); - var index = Popup.ShowOptionList( + int index = await Popup.AsyncShowOptionsList( Title: "Change Pronoun Set", Options: options.ToArray(), AllowEscape: true, @@ -84,30 +99,37 @@ public static void ChangePronounSet(GameObject Player) if (index > -1) { - // Option was selected if (options[index] != "") { - // Option was not - - PronounSet selected; if (index == 0) { + // Selected Gender playerGender = Player.GetGender(); - selected = new PronounSet(playerGender); + return new PronounSet(playerGender); } else { - selected = availablePronounSets[index - 1]; + return availablePronounSets[index - 1]; } + } - Player.SetPronounSet(selected.Register()); + int basePronounIndex = await Popup.AsyncShowOptionsList( + Title: "Select Base Set", + Options: pronounNames.ToArray(), + RespectOptionNewlines: false, + AllowEscape: true); - } - else + if (basePronounIndex > -1) { - // Currently unimplemented because the current customization process uses async stuff and this is in the old UI + PronounSet original = availablePronounSets[basePronounIndex]; + PronounSet newPronounSet = new PronounSet(original); + if (await newPronounSet.CustomizeAsync()) + { + return newPronounSet; + } } } + return null; } } }