Skip to content

Commit

Permalink
Expand name replacers
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Nov 19, 2023
1 parent f1f2f5e commit ed53c05
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 87 deletions.
4 changes: 4 additions & 0 deletions Skyrim/Data/SKSE/Plugins/ImmersiveActivate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ Instruments = Instrument
Jewelry = Jewel
;Replace Key name
Keys = Key
;Replace Ore veins name
Veins = Ore
;Replace Ore and Ingots name
Metals = Metal
;Replace names of the rest of the non-specified items. Mostly clutter.
Expand All @@ -142,6 +144,8 @@ Papers = Document
Remains = Remains
;Replace Flora and Harvestable resources name
Resources = Resource
;Replace Coin Purses name
Purses = Purse
;Replace Hand Jewelry name
Rings = Ring
;Replace Septims name (Coin Purse)
Expand Down
97 changes: 10 additions & 87 deletions src/Renamer.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "Renamer.h"
#include "Settings.h"

// Object Names have 2 or lines. Replacing the whole name leads to plain white text.
// Action: Talk, Sleep with optional color formatting
// Name: Camilla Carlotta, Bed (Owned)
// Embedded Images: empty tag triangle, or locked
std::string ReplaceRefText(const std::string& original, const std::string& replacement)
{
std::vector<std::string> lines;
Expand Down Expand Up @@ -41,86 +37,6 @@ std::string DecideSkip(std::string a_setting_value, std::string a_text)
return ReplaceRefText(a_text, a_setting_value);
}

struct Weapons
{
const std::vector<std::string> blades = { "WeapTypeSword", "WeapTypeGreatsword", "WeapTypeDagger" };
const std::vector<std::string> axes = { "WeapTypeWarAxe", "WeapTypeBattleaxe" };
const std::vector<std::string> bludgeons = { "WeapTypeMace", "WeapTypeWarhammer" };
const std::vector<std::string> staffs = { "VendorItemStaff", "WeapTypeStaff" };
const std::vector<std::string> ranged = { "WeapTypeBow" };
};

struct Armors
{
const std::vector<std::string> head = { "ArmorHelmet" };
const std::vector<std::string> chest = { "ArmorCuirass" };
const std::vector<std::string> hands = { "ArmorGauntlets" };
const std::vector<std::string> feet = { "ArmorBoots" };
const std::vector<std::string> shield = { "ArmorShield" };
const std::vector<std::string> cloth = { "ArmorClothing" };
};

struct Flasks
{
const std::vector<std::string> flasks = { "VendorItemPotion", "VendorItemPoison" };
};

struct Jewels
{
const std::vector<std::string> finger = { "ClothingRing" };
const std::vector<std::string> neck = { "ClothingNecklace" };
const std::vector<std::string> head = { "ClothingCirclet" };
};

struct Books
{
const std::uint32_t bookBurnt = 0x000E3CB7;
};
struct Provisions
{
const std::vector<std::string> treats = { "OCF_AlchFood_Treat", "OCF_AlchFood_Baked" };
const std::vector<std::string> organs = { "OCF_IngrRemains_Organ" };
const std::vector<std::string> cheeses = { "OCF_AlchFood_Cheese" };
const std::vector<std::string> breads = { "OCF_AlchFood_Bread" };
const std::vector<std::string> meats = { "OCF_AlchFood_Seafood", "OCF_AlchFood_Meat" };
const std::vector<std::string> produces = { "OCF_AlchFood_Vegetable", "OCF_AlchFood_Fruit" };
};

struct Shapes
{
const std::vector<std::string> claws = { "OCF_RelicNordic_DragonClaw" };
const std::vector<std::string> strip = { "OCF_AnimalHideStrip" };
const std::vector<std::string> bottles = { "OCF_VesselBottle" };
const std::vector<std::string> bowls = { "OCF_VesselBowl" };
const std::vector<std::string> pots = { "OCF_VesselPot" };
const std::vector<std::string> baskets = { "OCF_VesselBasket" };
const std::vector<std::string> buckets = { "OCF_VesselBucket" };
const std::vector<std::string> plates = { "OCF_VesselPlate" };
const std::vector<std::string> jars = { "OCF_VesselTankard" };
const std::vector<std::string> jugs = { "OCF_VesselJug" };
const std::vector<std::string> cups = { "OCF_VesselCup" };
const std::vector<std::string> waterskins = { "OCF_VesselWaterskin" };
const std::vector<std::string> brooms = { "OCF_ToolBroom" };
const std::vector<std::string> shovels = { "OCF_ToolShovel" };
const std::vector<std::string> lanterns = { "OCF_ToolLantern" };
};
struct Materials
{
const std::vector<std::string> bone = { "OCF_IngrRemains_Bone" };
const std::vector<std::string> shell = { "OCF_IngrRemains_Plate" };
const std::vector<std::string> metal = { "VendorItemOreIngot" };
const std::vector<std::string> wood = { "VendorItemFirewood" };
const std::vector<std::string> leather = { "VendorItemAnimalHide" };
};

struct Misc
{
const std::vector<std::string> gems = { "VendorItemGem", "VendorItemSoulGem" };
const std::vector<std::string> remains = { "VendorItemAnimalPart" };
const std::vector<std::string> instruments = { "VendorItemBardInstrument" };
const std::vector<std::string> utensils = { "OCF_WeapTypeCutlery1H" };
};

std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::string a_text, const Settings* s)
{
const auto a_baseObject = a_object->GetBaseObject();
Expand All @@ -143,8 +59,10 @@ std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::strin
logger::debug("{}", a_text);
logger::debug("------------- Original Name End ---------------------");
#endif

Shapes shapes;

// TODO: Make everything skippable
switch (a_formType) {
case RE::FormType::NPC:
case RE::FormType::LeveledNPC:
Expand All @@ -171,7 +89,6 @@ std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::strin
case RE::FormType::Tree:
if (a_object->NameIncludes("Purse"))
return ReplaceRefText(a_text, s->rMoneyPurse.text);

return ReplaceRefText(a_text, s->rResource.text);
case RE::FormType::Ingredient:
return ReplaceRefText(a_text, s->rIngredient.text);
Expand Down Expand Up @@ -210,7 +127,9 @@ std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::strin
{
Weapons weapons;

if (a_baseObject->HasAnyKeywordByEditorID(weapons.blades)) {
if (a_baseObject->HasAnyKeywordByEditorID(weapons.rods)) {
return ReplaceRefText(a_text, "Rod");
} else if (a_baseObject->HasAnyKeywordByEditorID(weapons.blades)) {
return ReplaceRefText(a_text, s->rWeaponBlade.text);
} else if (a_baseObject->HasAnyKeywordByEditorID(weapons.axes)) {
return ReplaceRefText(a_text, s->rWeaponAxe.text);
Expand Down Expand Up @@ -261,6 +180,10 @@ std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::strin
}
case RE::FormType::Scroll:
case RE::FormType::Note:
// TODO: Notes have the Type: Book/Tome set in the Form record. Workarounds
// YNAM - ITMNoteUp
// INAM - HighPolynote - unreliable
// MODL - Note.nif - unreliable
return ReplaceRefText(a_text, s->rPaper.text);
case RE::FormType::Book:
return ReplaceRefText(a_text, s->rBook.text);
Expand Down Expand Up @@ -310,7 +233,7 @@ std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::strin
return ReplaceRefText(a_text, "Utensil");
} else if (a_baseObject->HasAnyKeywordByEditorID(misc.gems)) {
return ReplaceRefText(a_text, s->rMiscGem.text);
} else if (a_baseFormID == books.bookBurnt) {
} else if (books.contains(a_baseFormID)) {
return ReplaceRefText(a_text, s->rBook.text);
} else if (a_baseObject->HasAnyKeywordByEditorID(misc.instruments)) {
return ReplaceRefText(a_text, s->rMiscBard.text);
Expand Down
96 changes: 96 additions & 0 deletions src/Renamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,99 @@
#include "Settings.h"

std::string ReplaceFormTypeText(const RE::TESObjectREFRPtr& a_object, std::string a_text, const Settings* s);

struct Weapons
{
const std::vector<std::string> blades = { "WeapTypeSword", "WeapTypeGreatsword", "WeapTypeDagger" };
const std::vector<std::string> axes = { "WeapTypeWarAxe", "WeapTypeBattleaxe" };
const std::vector<std::string> bludgeons = { "WeapTypeMace", "WeapTypeWarhammer" };
const std::vector<std::string> staffs = { "VendorItemStaff", "WeapTypeStaff" };
const std::vector<std::string> ranged = { "WeapTypeBow" };
const std::vector<std::string> rods = { "ccBGSSSE001_FishingPoleKW" };
};

struct Armors
{
const std::vector<std::string> head = { "ArmorHelmet" };
const std::vector<std::string> chest = { "ArmorCuirass" };
const std::vector<std::string> hands = { "ArmorGauntlets" };
const std::vector<std::string> feet = { "ArmorBoots" };
const std::vector<std::string> shield = { "ArmorShield" };
const std::vector<std::string> cloth = { "ArmorClothing" };
};

struct Flasks
{
const std::vector<std::string> flasks = { "VendorItemPotion", "VendorItemPoison" };
};

struct Jewels
{
const std::vector<std::string> finger = { "ClothingRing" };
const std::vector<std::string> neck = { "ClothingNecklace" };
const std::vector<std::string> head = { "ClothingCirclet" };
};

struct Provisions
{
const std::vector<std::string> treats = { "OCF_AlchFood_Treat", "OCF_AlchFood_Baked" };
const std::vector<std::string> organs = { "OCF_IngrRemains_Organ" };
const std::vector<std::string> cheeses = { "OCF_AlchFood_Cheese" };
const std::vector<std::string> breads = { "OCF_AlchFood_Bread" };
const std::vector<std::string> meats = { "OCF_AlchFood_Seafood", "OCF_AlchFood_Meat" };
const std::vector<std::string> produces = { "OCF_AlchFood_Vegetable", "OCF_AlchFood_Fruit" };
};

struct Shapes
{
const std::vector<std::string> claws = { "OCF_RelicNordic_DragonClaw" };
const std::vector<std::string> strip = { "OCF_AnimalHideStrip" };
const std::vector<std::string> bottles = { "OCF_VesselBottle" };
const std::vector<std::string> bowls = { "OCF_VesselBowl" };
const std::vector<std::string> pots = { "OCF_VesselPot" };
const std::vector<std::string> baskets = { "OCF_VesselBasket" };
const std::vector<std::string> buckets = { "OCF_VesselBucket" };
const std::vector<std::string> plates = { "OCF_VesselPlate" };
const std::vector<std::string> jars = { "OCF_VesselTankard" };
const std::vector<std::string> jugs = { "OCF_VesselJug" };
const std::vector<std::string> cups = { "OCF_VesselCup" };
const std::vector<std::string> waterskins = { "OCF_VesselWaterskin" };
const std::vector<std::string> brooms = { "OCF_ToolBroom" };
const std::vector<std::string> shovels = { "OCF_ToolShovel" };
const std::vector<std::string> lanterns = { "OCF_ToolLantern" };
};
struct Materials
{
const std::vector<std::string> bone = { "OCF_IngrRemains_Bone" };
const std::vector<std::string> shell = { "OCF_IngrRemains_Plate" };
const std::vector<std::string> metal = { "VendorItemOreIngot" };
const std::vector<std::string> wood = { "VendorItemFirewood" };
const std::vector<std::string> leather = { "VendorItemAnimalHide" };
};

struct Misc
{
const std::vector<std::string> gems = { "VendorItemGem", "VendorItemSoulGem" };
const std::vector<std::string> remains = { "VendorItemAnimalPart" };
const std::vector<std::string> instruments = { "VendorItemBardInstrument" };
const std::vector<std::string> utensils = { "OCF_WeapTypeCutlery1H" };
};

struct Books
{
const std::uint32_t bookBurnt = 0x000E3CB7;
const std::uint32_t bookRuined = 0x000CE70B;
const std::uint32_t bookRuined2 = 0x000E4897;

std::array<std::uint32_t, 3> allBooks = { bookBurnt, bookRuined, bookRuined2 };

bool contains(std::uint32_t baseFormID)
{
for (const auto& bookID : allBooks) {
if (baseFormID == bookID) {
return true;
}
}
return false;
}
};
2 changes: 2 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ bool Settings::LoadSettings()
get_value(rNPCDragon.text, section, "NPCsDragons");
get_value(rPaper.text, section, "Papers");
get_value(rResource.text, section, "Resources");
get_value(rResourcePurse.text, section, "Purses");
get_value(rResourceVein.text, section, "Veins");
get_value(rWeapon.text, section, "Weapons");
get_value(rWeaponAxe.text, section, "WeaponsAxe");
get_value(rWeaponBlade.text, section, "WeaponsBlade");
Expand Down
2 changes: 2 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class Settings
Replacer rNPCDragon{ "Dragon" };
Replacer rPaper{ "Document" };
Replacer rResource{ "Resource" };
Replacer rResourcePurse{ "Purse" };
Replacer rResourceVein{ "Ore" };
Replacer rWeapon{ "Weapon" };
Replacer rWeaponAxe{ "Axe" };
Replacer rWeaponBlade{ "Blade" };
Expand Down

0 comments on commit ed53c05

Please sign in to comment.