From 9c1b3553fa9d5ce5471b61c88699736db773ed77 Mon Sep 17 00:00:00 2001
From: kotae4 <83557652+kotae4@users.noreply.github.com>
Date: Mon, 22 Nov 2021 11:55:46 -0500
Subject: [PATCH] smaller rolename & optional abbrv setting

---
 appdata/il2cpp-types.h  | 38 ++++++++++++++++++++++++++++++++++++++
 gui/tabs/self_tab.cpp   |  6 ++++++
 hooks/MeetingHud.cpp    |  5 +++++
 hooks/PlayerControl.cpp |  3 ++-
 user/gitparams.h        |  2 +-
 user/state.cpp          |  2 ++
 user/state.hpp          |  1 +
 user/utility.cpp        | 18 +++++++++---------
 user/utility.h          |  2 +-
 9 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/appdata/il2cpp-types.h b/appdata/il2cpp-types.h
index 73e03309..f92dc9ed 100644
--- a/appdata/il2cpp-types.h
+++ b/appdata/il2cpp-types.h
@@ -9853,6 +9853,44 @@ namespace app
     };
 #pragma endregion
 
+#pragma region HatManager_c
+
+    struct HatManager_c
+    {
+        struct HatManager_c__Class* klass;
+        void* monitor;
+    };
+
+    struct HatManager_c__VTable
+    {
+        VirtualInvokeData Equals;
+        VirtualInvokeData Finalize;
+        VirtualInvokeData GetHashCode;
+        VirtualInvokeData ToString;
+    };
+
+    struct HatManager_c__StaticFields
+    {
+        struct HatManager_c* __9;
+        void* __9__9_0;
+        void* __9__11_0;
+        void* __9__12_0;
+        void* __9__15_0;
+        void* __9__17_0;
+    };
+
+    struct HatManager_c__Class
+    {
+        Il2CppClass_0 _0;
+        Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets;
+        struct HatManager_c__StaticFields* static_fields;
+        const Il2CppRGCTXData* rgctx_data;
+        Il2CppClass_1 _1;
+        struct HatManager_c__VTable vtable;
+    };
+
+#pragma endregion
+
 #pragma region ScriptableObject
     struct ScriptableObject__Fields
     {
diff --git a/gui/tabs/self_tab.cpp b/gui/tabs/self_tab.cpp
index d09b5789..c069f106 100644
--- a/gui/tabs/self_tab.cpp
+++ b/gui/tabs/self_tab.cpp
@@ -54,6 +54,12 @@ namespace SelfTab {
             if (ImGui::Checkbox("Reveal Roles", &State.RevealRoles)) {
                 State.Save();
             }
+            ImGui::SameLine();
+            if (ImGui::Checkbox("Abbrv. Role", &State.AbbreviatedRoleNames))
+            {
+                State.Save();
+            }
+
             if (ImGui::Checkbox("See Ghosts", &State.ShowGhosts)) {
                 State.Save();
             }
diff --git a/hooks/MeetingHud.cpp b/hooks/MeetingHud.cpp
index 1c5a2665..c3800e9f 100644
--- a/hooks/MeetingHud.cpp
+++ b/hooks/MeetingHud.cpp
@@ -30,6 +30,11 @@ void dMeetingHud_Update(MeetingHud* __this, MethodInfo* method) {
 			Color32 faceColor = app::Color32_op_Implicit(Palette__TypeInfo->static_fields->Black, NULL);
 			if (State.RevealRoles || PlayerIsImpostor(localData)) {
 
+				std::string playerName = convert_from_string(GetPlayerOutfit(playerData)->fields._playerName);
+				playerName += "\n<size=50%>(" + GetRoleName(playerData->fields.Role) + ")";
+				String* playerNameStr = convert_to_string(playerName);
+				app::TMP_Text_set_text((app::TMP_Text*)playerNameTMP, playerNameStr, NULL);
+
 				Color32 c = app::Color32_op_Implicit(GetRoleColor(playerData->fields.Role), NULL);
 
 				app::TextMeshPro_SetFaceColor(playerNameTMP, c, NULL);
diff --git a/hooks/PlayerControl.cpp b/hooks/PlayerControl.cpp
index 31a9c226..6bf97930 100644
--- a/hooks/PlayerControl.cpp
+++ b/hooks/PlayerControl.cpp
@@ -48,7 +48,8 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
 			Color32 c = app::Color32_op_Implicit(GetRoleColor(playerData->fields.Role), NULL);
 
 			std::string playerName = convert_from_string(GetPlayerOutfit(playerData)->fields._playerName);
-			playerName += "\n(" + GetRoleName(playerData->fields.Role) + ")";
+			std::string roleName = GetRoleName(playerData->fields.Role, State.AbbreviatedRoleNames);
+			playerName += "\n<size=50%>(" + roleName + ")";
 			String* playerNameStr = convert_to_string(playerName);
 			app::TMP_Text_set_text((app::TMP_Text*)nameTextTMP, playerNameStr, NULL);
 
diff --git a/user/gitparams.h b/user/gitparams.h
index 467d2a62..d4ad6aa9 100644
--- a/user/gitparams.h
+++ b/user/gitparams.h
@@ -1,2 +1,2 @@
-#define GIT_CUR_COMMIT cb1b462045b8585d8e3c4dbe6cfaf778d3bb208f
+#define GIT_CUR_COMMIT e22fe71ce90ee66eaa1db5214991f244b3962409
 #define GIT_BRANCH 2021.11.9.5e
diff --git a/user/state.cpp b/user/state.cpp
index ff58af3d..4b21b4c4 100644
--- a/user/state.cpp
+++ b/user/state.cpp
@@ -48,6 +48,7 @@ void Settings::Load() {
         j.at("Wallhack").get_to(this->Wallhack);
         j.at("UnlockVents").get_to(this->UnlockVents);
         j.at("RevealRoles").get_to(this->RevealRoles);
+        j.at("AbbreviatedRoleNames").get_to(this->AbbreviatedRoleNames);
         j.at("ChatAlwaysActive").get_to(this->ChatAlwaysActive);
         j.at("ReadGhostMessages").get_to(this->ReadGhostMessages);
         j.at("AutoOpenDoors").get_to(this->AutoOpenDoors);
@@ -97,6 +98,7 @@ void Settings::Save() {
             {"Wallhack", this->Wallhack},
             {"UnlockVents", this->UnlockVents},
             {"RevealRoles", this->RevealRoles},
+            {"AbbreviatedRoleNames", this->AbbreviatedRoleNames},
             {"ChatAlwaysActive", this->ChatAlwaysActive},
             {"ReadGhostMessages", this->ReadGhostMessages},
             {"AutoOpenDoors", this->AutoOpenDoors},
diff --git a/user/state.hpp b/user/state.hpp
index 814f06f9..b8fd7b7f 100644
--- a/user/state.hpp
+++ b/user/state.hpp
@@ -36,6 +36,7 @@ class Settings {
     bool ShowGhosts = false;
 
     bool RevealRoles = false;
+    bool AbbreviatedRoleNames = false;
     int PrevKillDistance = 0;
     int KillDistance = 0;
     int PrevTaskBarUpdates = 0;
diff --git a/user/utility.cpp b/user/utility.cpp
index 6b86f66f..5d596a66 100644
--- a/user/utility.cpp
+++ b/user/utility.cpp
@@ -642,25 +642,25 @@ Color GetRoleColor(RoleBehaviour* roleBehaviour) {
 	return c;
 }
 
-std::string GetRoleName(RoleBehaviour* roleBehaviour)
+std::string GetRoleName(RoleBehaviour* roleBehaviour, bool abbreviated /* = false */)
 {
-	if (roleBehaviour == nullptr) return "Unknown";
+	if (roleBehaviour == nullptr) return (abbreviated ? "Unk" : "Unknown");
 
 	switch (roleBehaviour->fields.Role)
 	{
 		case RoleTypes__Enum::Engineer:
-			return "Engineer";
+			return (abbreviated ? "Eng" : "Engineer");
 		case RoleTypes__Enum::GuardianAngel:
-			return "GuardianAngel";
+			return (abbreviated ? "GA" : "GuardianAngel");
 		case RoleTypes__Enum::Impostor:
-			return "Impostor";
+			return (abbreviated ? "I" : "Impostor");
 		case RoleTypes__Enum::Scientist:
-			return "Scientist";
+			return (abbreviated ? "Sci" : "Scientist");
 		case RoleTypes__Enum::Shapeshifter:
-			return "Shapeshifter";
+			return (abbreviated ? "Sh" : "Shapeshifter");
 		case RoleTypes__Enum::Crewmate:
-			return "Crewmate";
+			return (abbreviated ? "C" : "Crewmate");
 		default:
-			return "Unknown";
+			return (abbreviated ? "Unk" : "Unknown");
 	}
 }
\ No newline at end of file
diff --git a/user/utility.h b/user/utility.h
index d168348a..934271ca 100644
--- a/user/utility.h
+++ b/user/utility.h
@@ -124,4 +124,4 @@ void ResetOriginalAppearance();
 bool PlayerIsImpostor(GameData_PlayerInfo* player);
 GameData_PlayerOutfit* GetPlayerOutfit(GameData_PlayerInfo* player);
 Color GetRoleColor(RoleBehaviour* roleBehaviour);
-std::string GetRoleName(RoleBehaviour* roleBehaviour);
\ No newline at end of file
+std::string GetRoleName(RoleBehaviour* roleBehaviour, bool abbreviated = false);
\ No newline at end of file