diff --git a/Assemblies/0Harmony.dll b/Assemblies/0Harmony.dll index a95b6df..6c0dd94 100644 Binary files a/Assemblies/0Harmony.dll and b/Assemblies/0Harmony.dll differ diff --git a/Assemblies/ClassLibrary.dll b/Assemblies/ClassLibrary.dll deleted file mode 100644 index 4e5aed7..0000000 Binary files a/Assemblies/ClassLibrary.dll and /dev/null differ diff --git a/Assemblies/ColoredMoodBar.dll b/Assemblies/ColoredMoodBar.dll new file mode 100644 index 0000000..f2e92fd Binary files /dev/null and b/Assemblies/ColoredMoodBar.dll differ diff --git a/README.md b/README.md index b1bd05a..1e09d48 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,27 @@ # ColorCodedMoodBar A RimWorld mod to color code each pawn's mood bar within the colonist bar based on their current mood. A red mood bar indicates the pawn is at or under their extreme mental break threshold, orange indicates the major mental break threshold, yellow indicates the minor mental break threshold, and blue indicates the pawn is not under any mental break threshold. +The bar will turn green if the pawn is particularly happy. ## Known Bugs/Limitations/Requirements: -- None +- Mod incompatibilities: +- "Advanced biomes" and "Rimstory" should be loaded after this mod. Otherwise there might be some conflicts (Thx 2 Xerberus86) ## Updates - Sep 16 2017: Initial release on GitHub and closed release on Steam - Sep 17 2017: Open release on Steam - Nov 18 2017: Updated for RimWord version 0.18.1722, and added content and happy colors. +- Sep 03 2018: Update for Rimworld version 0.19.* and doing some bugfixes. ## Author/Mod Team -- PorqueNoLosDos -- fyarn +- semTex (Update B19) +- PorqueNoLosDos (Update B18) +- fyarn (Original Author) ## Download -- Github (with Source): https://github.com/bcooper94/ColorCodedMoodBar -- Direct: https://github.com/bcooper94/ColorCodedMoodBar/archive/master.zip -- Steam: https://steamcommunity.com/sharedfiles/filedetails/?id=1136819681 +- Github (with Source): https://github.com/resTive2k12/ColorCodedMoodBar +- Direct: https://github.com/resTive2k12/ColorCodedMoodBar/archive/master.zip +- Steam: https://steamcommunity.com/sharedfiles/filedetails/?id=1501832876 ## How to install (non-Steam users): - Unzip the contents and place them in your RimWorld/Mods folder. diff --git a/Source/ColoredMoodBar/ColoredMoodBar.csproj b/Source/ColoredMoodBar/ColoredMoodBar.csproj index 1561e53..0881e7b 100644 --- a/Source/ColoredMoodBar/ColoredMoodBar.csproj +++ b/Source/ColoredMoodBar/ColoredMoodBar.csproj @@ -5,7 +5,7 @@ {2EABFAFA-B6E5-43EB-948F-62FCECCBCCC0} Library false - ClassLibrary + ColoredMoodBar v3.5 512 @@ -35,7 +35,7 @@ D:\dev\RimWorld Libs\Release\0Harmony.dll - ..\..\..\..\RimWorldWin_Data\Managed\Assembly-CSharp.dll + G:\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll False @@ -45,12 +45,13 @@ - ..\..\..\..\RimWorldWin_Data\Managed\UnityEngine.dll + G:\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll False + @@ -65,6 +66,7 @@ - ..\..\..\RimWorldWin -quicktest + copy /Y "$(TargetDir)$(TargetName).dll" "E:\Steam Bibliothek\steamapps\common\RimWorld\Mods\ColorCodedMoodBar\Assemblies\$(TargetName).dll" +"E:\Steam Bibliothek\steamapps\common\RimWorld\RimworldWin64.exe" -quicktest \ No newline at end of file diff --git a/Source/ColoredMoodBar/HarmonyPatch.cs b/Source/ColoredMoodBar/HarmonyPatch.cs index d662eb6..948c1fd 100644 --- a/Source/ColoredMoodBar/HarmonyPatch.cs +++ b/Source/ColoredMoodBar/HarmonyPatch.cs @@ -26,14 +26,16 @@ public class Main { public static Texture2D happyTex; static Main() { - var harmony = HarmonyInstance.Create("com.github.bc.rimworld.mod.moodbar"); + var harmony = HarmonyInstance.Create("com.github.restive2k12.rimworld.mod.moodbar"); harmony.PatchAll(Assembly.GetExecutingAssembly()); + drawSelectionOverlayOnGUIMethod = typeof(ColonistBarColonistDrawer).GetMethod("DrawSelectionOverlayOnGUI", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(Pawn), typeof(Rect) }, null); drawCaravanSelectionOverlayOnGUIMethod = typeof(ColonistBarColonistDrawer).GetMethod("DrawCaravanSelectionOverlayOnGUI", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(Caravan), typeof(Rect) }, null); getPawnTextureRectMethod = typeof(ColonistBarColonistDrawer).GetMethod("GetPawnTextureRect", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(float), typeof(float) }, null); + drawIconsMethod = typeof(ColonistBarColonistDrawer).GetMethod("DrawIcons", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(Rect), typeof(Pawn) }, null); pawnTextureCameraOffsetField = typeof(ColonistBarColonistDrawer).GetField("PawnTextureCameraOffset", @@ -42,11 +44,11 @@ static Main() { BindingFlags.Static | BindingFlags.NonPublic); pawnLabelsCacheField = typeof(ColonistBarColonistDrawer).GetField("pawnLabelsCache", BindingFlags.Instance | BindingFlags.NonPublic); - float colorAlpha = 0.44f; + float colorAlpha = 0.6f; Color red = Color.red; Color orange = new Color(1f, 0.5f, 0.31f, colorAlpha); Color yellow = Color.yellow; - Color neutralColor = new Color(0.87f, 0.96f, 0.79f, colorAlpha); + Color neutralColor = new Color(0.77f, 0.96f, 0.69f, colorAlpha); Color cyan = Color.cyan; Color happyColor = new Color(0.1f, 0.75f, 0.2f, colorAlpha); red.a = orange.a = yellow.a = cyan.a = colorAlpha; @@ -57,7 +59,7 @@ static Main() { neutralTex = SolidColorMaterials.NewSolidColorTexture(neutralColor); contentTex = SolidColorMaterials.NewSolidColorTexture(cyan); happyTex = SolidColorMaterials.NewSolidColorTexture(happyColor); - LogMessage("ColorCodedMoodBar initialized"); + LogMessage("initialized"); } public static void LogMessage(string text) { @@ -65,39 +67,49 @@ public static void LogMessage(string text) { } } - [HarmonyPatch(typeof(ColonistBarColonistDrawer), "DrawColonist")] + [HarmonyPatch(typeof(ColonistBarColonistDrawer))] + [HarmonyPatch("DrawColonist")] + [HarmonyPatch(new Type[ ] { typeof(Rect) , typeof(Pawn) , typeof(Map) , typeof(bool) , typeof(bool) } )] public class MoodPatch { private static float ApplyEntryInAnotherMapAlphaFactor(Map map, float alpha) { + if (map == null) { if (!WorldRendererUtility.WorldRenderedNow) { alpha = Mathf.Min(alpha, 0.4f); } } - else if (map != Find.VisibleMap || WorldRendererUtility.WorldRenderedNow) { + + else if (map != Find.CurrentMap || WorldRendererUtility.WorldRenderedNow) { alpha = Mathf.Min(alpha, 0.4f); } return alpha; } - public static bool Prefix(ColonistBarColonistDrawer __instance, ref Rect rect, ref Pawn colonist, ref Map pawnMap) { + public static bool Prefix(ColonistBarColonistDrawer __instance, ref Rect rect, ref Pawn colonist, ref Map pawnMap, ref bool highlight, ref bool reordering) { ColonistBar colonistBar = Find.ColonistBar; - float entryRectAlpha = colonistBar.GetEntryRectAlpha(rect); - entryRectAlpha = ApplyEntryInAnotherMapAlphaFactor(pawnMap, entryRectAlpha); - bool flag = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse); - Color color = new Color(1f, 1f, 1f, entryRectAlpha); + float alpha = ApplyEntryInAnotherMapAlphaFactor(pawnMap, colonistBar.GetEntryRectAlpha(rect)); + + Rect pawnBackgroundSize = rect.ExpandedBy(2.5f); + + if (reordering) { + alpha *= 0.5f; + } + Color color = new Color(1f, 1f, 1f, alpha); GUI.color = color; GUI.DrawTexture(rect, ColonistBar.BGTex); - if (colonist.needs != null && colonist.needs.mood != null) { - Rect position = rect.ContractedBy(2f); - float num = position.height * colonist.needs.mood.CurLevelPercentage; - position.yMin = position.yMax - num; - position.height = num; + Rect position = pawnBackgroundSize.ContractedBy(2f); + float value = position.height * colonist.needs.mood.CurLevelPercentage; + position.yMin = position.yMax - value; + position.height = value; + float statValue = colonist.GetStatValue(StatDefOf.MentalBreakThreshold, true); + float currentMoodLevel = colonist.needs.mood.CurLevel; + // Extreme break threshold if (currentMoodLevel <= statValue) { GUI.DrawTexture(position, Main.extremeBreakTex); @@ -123,36 +135,32 @@ public static bool Prefix(ColonistBarColonistDrawer __instance, ref Rect rect, r else { GUI.DrawTexture(position, Main.happyTex); } - } + } + if (highlight) { + int thickness = (rect.width > 22f) ? 3 : 2; + GUI.color = Color.white; + Widgets.DrawBox(rect, thickness); + GUI.color = color; + } Rect rect2 = rect.ContractedBy(-2f * colonistBar.Scale); - - if (flag && !WorldRendererUtility.WorldRenderedNow) { + bool notdeadandselected = (!colonist.Dead) ? Find.Selector.SelectedObjects.Contains(colonist) : Find.Selector.SelectedObjects.Contains(colonist.Corpse); + if (notdeadandselected && !WorldRendererUtility.WorldRenderedNow) { Main.drawSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist, rect2 }); - } - else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan())) { + } else if (WorldRendererUtility.WorldRenderedNow && colonist.IsCaravanMember() && Find.WorldSelector.IsSelected(colonist.GetCaravan())) { Main.drawCaravanSelectionOverlayOnGUIMethod.Invoke(__instance, new object[] { colonist.GetCaravan(), rect2 }); } + GUI.DrawTexture(__instance.GetPawnTextureRect(rect.position), PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, ColonistBarColonistDrawer.PawnTextureCameraOffset, 1.28205f)); - Rect pawnTexturePosition = (Rect) Main.getPawnTextureRectMethod.Invoke(__instance, new object[] { rect.x, rect.y }); - - GUI.DrawTexture(pawnTexturePosition, PortraitsCache.Get(colonist, ColonistBarColonistDrawer.PawnTextureSize, - (Vector3) Main.pawnTextureCameraOffsetField.GetValue(null), - 1.28205f)); - GUI.color = new Color(1f, 1f, 1f, entryRectAlpha * 0.8f); + GUI.color = new Color(1f, 1f, 1f, alpha * 0.8f); Main.drawIconsMethod.Invoke(__instance, new object[] { rect, colonist }); GUI.color = color; - if (colonist.Dead) { - GUI.DrawTexture(rect, (Texture) Main.deadColonistTexField.GetValue(null)); + GUI.DrawTexture(rect, (Texture)Main.deadColonistTexField.GetValue(__instance)); } - - float num2 = 4f * colonistBar.Scale; - Vector2 pos = new Vector2(rect.center.x, rect.yMax - num2); - GenMapUI.DrawPawnLabel(colonist, pos, entryRectAlpha, - rect.width + colonistBar.SpaceBetweenColonistsHorizontal - 2f, - (Dictionary)Main.pawnLabelsCacheField.GetValue(__instance), - GameFont.Tiny, true, true); + float num3 = 4f * colonistBar.Scale; + Vector2 pos = new Vector2(rect.center.x, rect.yMax - num3); + GenMapUI.DrawPawnLabel(colonist, pos, alpha, rect.width + colonistBar.SpaceBetweenColonistsHorizontal - 2f, (Dictionary)Main.pawnLabelsCacheField.GetValue(__instance), GameFont.Tiny, true, true); Text.Font = GameFont.Small; GUI.color = Color.white; diff --git a/Source/ColoredMoodBar/Properties/AssemblyInfo.cs b/Source/ColoredMoodBar/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e311b4c --- /dev/null +++ b/Source/ColoredMoodBar/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("ColoredMoodBar")] +[assembly: AssemblyDescription("Color code each pawn's mood bar within the colonist bar based on their current mood.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ColoredMoodBar.Properties")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("d7feaa9a-a2c4-46d7-81de-fccf6944661e")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]