Skip to content

Commit

Permalink
Release: Version 1.1
Browse files Browse the repository at this point in the history
FossilOrigin-Name: ed012044991efd8d5ad16094bd9c349c50a32341d8e961afe27a501b78af1f6f
  • Loading branch information
librarianmage committed Jul 6, 2022
2 parents 6e94af3 + 2f7eae8 commit 5abd127
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 53 deletions.
9 changes: 9 additions & 0 deletions PronounSets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,13 @@
SubstantivePossessive="thon's"
Reflexive="thonself"
/>

<!-- name -->
<pronounset
Subjective="=name="
Objective="=name="
PossessiveAdjective="=name's="
SubstantivePossessive="=name's="
Reflexive="=name="
/>
</pronounsets>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

A mod that works in conjunction with the [Gender and Pronoun Sets](https://steamcommunity.com/sharedfiles/filedetails/?id=1735379738) mod to allow your delver to wreathe themselves in the gender identity and pronouns they feel most comfortable in.

Specifically, this mod allows you to pick from all personal genders and pronouns defined in the game, with some additions.
Specifically, this mod allows you to pick from all personal genders and pronouns defined in game, with some additions.

[Workshop Page](https://steamcommunity.com/sharedfiles/filedetails/?id=2815078000)
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "QudGendersUnleashed",
"title": "{{m-Y-g alternation|Qud: Genders Unleashed}}",
"description": "Adds gendeers and pronounce",
"version": "1.0",
"version": "1.1",
"author": "librarianmage",
"previewImage": "icon.png"
}
114 changes: 114 additions & 0 deletions namepronoun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using HarmonyLib;
using XRL.World;
using XRL.Language;
using ConsoleLib.Console;

namespace QudGendersUnleashed.NamePronoun
{
[HarmonyPatch(typeof(GameObject))]
[HarmonyPatch(nameof(GameObject.GetPronounProvider))]
public static class NameOnlyPronounPatch
{
static IPronounProvider Postfix(IPronounProvider PronounSet, GameObject __instance)
{
return new NamePronounWrapper(PronounSet, __instance);
}
}

// Wraps a IPronounProvider to replace =name=/=name's= with the holder's name
public class NamePronounWrapper : IPronounProvider
{
private IPronounProvider BasePronouns;
private GameObject Referrant;

public NamePronounWrapper(IPronounProvider BasePronouns, GameObject Referrant)
{
this.BasePronouns = BasePronouns;
this.Referrant = Referrant;
// Consider: caching if replacing is needed
}

string ReplaceWithName(string Pronoun, bool capitalize = false)
{
if (Pronoun.Contains("=name"))
{
string DisplayName = Referrant.BaseDisplayNameStripped;
if (capitalize) { DisplayName = ColorUtility.CapitalizeExceptFormatting(DisplayName); }
string DisplayNamePosessive = Grammar.MakePossessive(DisplayName);
return Pronoun.Replace("=name=", DisplayName)
.Replace("=name's=", DisplayNamePosessive);
}
else
{
return Pronoun;
}
}

public string Name => 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;
}
}
50 changes: 0 additions & 50 deletions patches.cs

This file was deleted.

135 changes: 135 additions & 0 deletions selectors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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;
using System.Threading.Tasks;

namespace QudGendersUnleashed.PronounAndGenderSelectorPatches
{
[HarmonyPatch]
public static class CharacterCreationGenderPatch
{
public static MethodInfo TargetMethod()
{
return AccessTools.DeclaredMethod(AccessTools.Inner(typeof(QudCustomizeCharacterModuleWindow), "<OnChooseGenderAsync>d__5"), "MoveNext");
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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), "<OnChoosePronounSetAsync>d__7"), "MoveNext");
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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(StatusScreen))]
[HarmonyPatch(nameof(StatusScreen.Show))]
public static class StatusScreenPatch
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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)
{
Task<PronounSet> newPronounTask = OnChoosePronounSetAsync(Player);
newPronounTask.Wait();
PronounSet newPronoun = newPronounTask.Result;

if (newPronoun != null)
{
Player.SetPronounSet(newPronoun.Register());
}
}

public static async Task<PronounSet> OnChoosePronounSetAsync(GameObject Player)
{
List<PronounSet> availablePronounSets = PronounSet.GetAllPersonal();
IEnumerable<string> pronounNames = availablePronounSets.Select((PronounSet pronounSet) => pronounSet.Name);

PronounSet currentPronounSet = Player.GetPronounSet();
int indexCurrentPronounSet = availablePronounSets.FindIndex(p => p == currentPronounSet);

List<string> options = new List<string>();
options.Add("<from gender>");
options.AddRange(pronounNames);
options.Add("<create new>");

int index = await Popup.AsyncShowOptionsList(
Title: "Change Pronoun Set",
Options: options.ToArray(),
AllowEscape: true,
defaultSelected: indexCurrentPronounSet + 1);

if (index > -1)
{
if (options[index] != "<create new>")
{
if (index == 0)
{
// Selected <from gender>
Gender playerGender = Player.GetGender();
return new PronounSet(playerGender);
}
else
{
return availablePronounSets[index - 1];
}
}

int basePronounIndex = await Popup.AsyncShowOptionsList(
Title: "Select Base Set",
Options: pronounNames.ToArray(),
RespectOptionNewlines: false,
AllowEscape: true);

if (basePronounIndex > -1)
{
PronounSet original = availablePronounSets[basePronounIndex];
PronounSet newPronounSet = new PronounSet(original);
if (await newPronounSet.CustomizeAsync())
{
return newPronounSet;
}
}
}
return null;
}
}
}
2 changes: 1 addition & 1 deletion workshop.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"WorkshopId": 2815078000,
"Title": "Qud: Genders Unleashed",
"Description": "A mod that works in conjunction with the Gender and Pronoun Sets ( https://steamcommunity.com/sharedfiles/filedetails/?id=1735379738 ) mod to allow your delver to wreathe themselves in the gender identity and pronouns they feel most comfortable in.\n\nSpecifically, this mod allows you to pick from all personal genders and pronouns defined in the game, with some additions.\n\nTested on game version 203.39\n\nGithub link: https://github.com/librarianmage/QudGendersUnleashed",
"Description": "A mod that works in conjunction with the Gender and Pronoun Sets ( https://steamcommunity.com/sharedfiles/filedetails/?id=1735379738 ) mod to allow your delver to wreathe themselves in the gender identity and pronouns they feel most comfortable in.\n\nSpecifically, this mod allows you to pick from all personal genders and pronouns defined in game, with some additions.\n\nTested on game version 203.51\n\nGithub link: https://github.com/librarianmage/QudGendersUnleashed",
"Tags": "Stable,Beta,Script,Gender,Pronouns",
"Visibility": "2",
"ImagePath": "icon.png"
Expand Down

0 comments on commit 5abd127

Please sign in to comment.