diff --git a/1.5/Assemblies/ShowMeYourHands.dll b/1.5/Assemblies/ShowMeYourHands.dll index bc47d8a..943d0ce 100644 Binary files a/1.5/Assemblies/ShowMeYourHands.dll and b/1.5/Assemblies/ShowMeYourHands.dll differ diff --git a/1.5/Defs/ThingDefs/Core.xml b/1.5/Defs/ThingDefs/Core.xml index 203ddac..1c6786b 100644 --- a/1.5/Defs/ThingDefs/Core.xml +++ b/1.5/Defs/ThingDefs/Core.xml @@ -1,7 +1,7 @@ diff --git a/About/About.xml b/About/About.xml index 0a92265..e461061 100644 --- a/About/About.xml +++ b/About/About.xml @@ -91,5 +91,5 @@ Since modding is just a hobby for me I expect no donations to keep modding. If y [/list] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2475965842][img]https://img.shields.io/github/v/release/emipa606/ShowMeYourHands?label=latest%20version&style=plastic&labelColor=0070cd&color=white[/img][/url] - 1.5.7 + 1.5.8 \ No newline at end of file diff --git a/About/Changelog.txt b/About/Changelog.txt index beaaedc..86daecf 100644 --- a/About/Changelog.txt +++ b/About/Changelog.txt @@ -1,5 +1,9 @@ # Changelog for ShowMeYourHands +1.5.8 - Added rotation support, default enabled when using [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3302328100]Nice Hands Retexture[/url] +Used DeepL to update translations for ChineseSimplified, French, German, Russian + + 1.5.7 - Added settings for the rest of the Guns Galore-mods. Also added copy and paste buttons. Used DeepL to update translations for ChineseSimplified, French, German, Russian diff --git a/About/Manifest.xml b/About/Manifest.xml index 5600568..658bdf5 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@ ShowMeYourHands - 1.5.7 + 1.5.8 diff --git a/About/ModSync.xml b/About/ModSync.xml index 4dcdbdb..1643015 100644 --- a/About/ModSync.xml +++ b/About/ModSync.xml @@ -2,7 +2,7 @@ a5b440f3-8aa2-46ee-8a29-29561bb7087a Show Me Your Hands - 1.5.7 + 1.5.8 False emipa606 diff --git a/Languages/ChineseSimplified/Keyed/Mod_Settings.xml b/Languages/ChineseSimplified/Keyed/Mod_Settings.xml index 55302bb..3fd3fb9 100644 --- a/Languages/ChineseSimplified/Keyed/Mod_Settings.xml +++ b/Languages/ChineseSimplified/Keyed/Mod_Settings.xml @@ -58,4 +58,10 @@ 复制设置 粘贴的设置 复制的设置 + 启用旋转支持 + 允许自定义旋转指针,只有在使用非标准指针纹理时才会生效 + 主手旋转 + 离手旋转 + {0}° + 使用滚轮旋转指针,按住 SHIFT 键可加快旋转速度 diff --git a/Languages/English/Keyed/Mod_Settings.xml b/Languages/English/Keyed/Mod_Settings.xml index a457d04..88a6b04 100644 --- a/Languages/English/Keyed/Mod_Settings.xml +++ b/Languages/English/Keyed/Mod_Settings.xml @@ -21,6 +21,8 @@ Reset selected Enable verbose logging Shows verbose logging, for finding errors + Enable rotation support + Allows defining custom rotation of hands, this will only have effect when using a non-standard hand-texture Try to match replaced hands If the pawns hands are replaced with an artificial hand, it will try to show the color of the artificial limb instead Dont show missing hands @@ -43,9 +45,12 @@ Uses no hands Main hand horizontal Main hand vertical + Main hand rotation Render behind weapon Off hand horizontal Off hand vertical + Off hand rotation + {0}° Reset Undo Save @@ -56,5 +61,6 @@ Uses the default settings Has custom settings included in the mod Has personal settings defined by the player - NOTE: You can also left-click drag to set the main-hand position, right-click drag to set the off-hand position + Left-click drag to set the main-hand position, right-click drag to set the off-hand position. + Use the scroll wheel to rotate the hands, hold SHIFT for faster rotation diff --git a/Languages/French/Keyed/Mod_Settings.xml b/Languages/French/Keyed/Mod_Settings.xml index b18f53d..57cb154 100644 --- a/Languages/French/Keyed/Mod_Settings.xml +++ b/Languages/French/Keyed/Mod_Settings.xml @@ -58,4 +58,10 @@ Paramètres de copie Paramètres collés Paramètres copiés + Activer la prise en charge de la rotation + Permet de définir une rotation personnalisée des mains, qui n'aura d'effet que lors de l'utilisation d'une texture de main non standard. + Rotation de la main principale + Rotation hors main + {0}° + Utilisez la molette de défilement pour faire tourner les aiguilles, maintenez la touche SHIFT enfoncée pour une rotation plus rapide. \ No newline at end of file diff --git a/Languages/German/Keyed/Mod_Settings.xml b/Languages/German/Keyed/Mod_Settings.xml index 795346a..8ca97d8 100644 --- a/Languages/German/Keyed/Mod_Settings.xml +++ b/Languages/German/Keyed/Mod_Settings.xml @@ -58,4 +58,10 @@ Einstellungen kopieren Einstellungen eingefügt Einstellungen kopiert + Unterstützung der Rotation aktivieren + Ermöglicht die Definition einer benutzerdefinierten Drehung der Hände, dies hat nur Auswirkungen, wenn eine Nicht-Standard-Hand-Textur verwendet wird + Rotation der Haupthand + Drehung aus der Hand + {0}° + Verwenden Sie das Scrollrad, um die Zeiger zu drehen, halten Sie SHIFT für eine schnellere Drehung \ No newline at end of file diff --git a/Languages/Russian/Keyed/Mod_Settings.xml b/Languages/Russian/Keyed/Mod_Settings.xml index 29aaddc..74cb24a 100644 --- a/Languages/Russian/Keyed/Mod_Settings.xml +++ b/Languages/Russian/Keyed/Mod_Settings.xml @@ -58,4 +58,10 @@ Настройки копирования Настройки вставлены Копирование настроек + Включите поддержку вращения + Позволяет задать пользовательское вращение рук, это будет иметь эффект только при использовании нестандартной текстуры рук + Вращение основной руки + Вращение без помощи рук + {0}° + Используйте колесо прокрутки для поворота стрелок, удерживайте SHIFT для ускорения вращения. \ No newline at end of file diff --git a/Source/ShowMeYourHands/ClutterHandsTDef.cs b/Source/ShowMeYourHands/ClutterHandsTDef.cs index 38c13f7..28ea62c 100644 --- a/Source/ShowMeYourHands/ClutterHandsTDef.cs +++ b/Source/ShowMeYourHands/ClutterHandsTDef.cs @@ -12,6 +12,8 @@ public class CompTargets { public readonly List ThingTargets = []; public Vector3 MainHand = Vector3.zero; + public float MainRotation = 0f; public Vector3 SecHand = Vector3.zero; + public float SecRotation = 0f; } } \ No newline at end of file diff --git a/Source/ShowMeYourHands/HandDrawer.cs b/Source/ShowMeYourHands/HandDrawer.cs index 03b3439..89eeb36 100644 --- a/Source/ShowMeYourHands/HandDrawer.cs +++ b/Source/ShowMeYourHands/HandDrawer.cs @@ -16,7 +16,9 @@ public class HandDrawer : ThingComp public Vector3 ItemHeldLocation; private int LastDrawn; private Vector3 MainHand; + private float MainHandRotation; private Vector3 OffHand; + private float OffHandRotation; private Color HandColor { @@ -110,11 +112,15 @@ private void DrawHandsOnWeapon(Pawn pawn) { MainHand = compProperties.MainHand; OffHand = compProperties.SecHand; + MainHandRotation = compProperties.MainRotation; + OffHandRotation = compProperties.SecRotation; } else { OffHand = Vector3.zero; MainHand = Vector3.zero; + MainHandRotation = 0f; + OffHandRotation = 0f; } ThingWithComps offhandWeapon = null; @@ -316,8 +322,7 @@ public void DrawHandsOnItem(Pawn pawn) } private void DrawHandsOnWeapon(Thing mainHandWeapon, float aimAngle, Pawn pawn, Thing offHandWeapon = null, - bool idle = false, - bool aiming = false) + bool idle = false, bool aiming = false) { var flipped = false; var skipMainHand = false; @@ -510,7 +515,7 @@ private void DrawHandsOnWeapon(Thing mainHandWeapon, float aimAngle, Pawn pawn, Graphics.DrawMesh(mesh, mainWeaponLocation + new Vector3(x, y + mainMeleeExtra, z).RotatedBy(mainHandAngle), - Quaternion.AngleAxis(mainHandAngle, Vector3.up), y >= 0 ? matSingle : offSingle, 0); + Quaternion.AngleAxis(mainHandAngle + MainHandRotation, Vector3.up), y >= 0 ? matSingle : offSingle, 0); } if (OffHand == Vector3.zero || skipOffHand || ShowMeYourHandsMain.pawnsMissingAHand.ContainsKey(pawn) && @@ -559,7 +564,7 @@ private void DrawHandsOnWeapon(Thing mainHandWeapon, float aimAngle, Pawn pawn, Graphics.DrawMesh(mesh, offhandWeaponLocation + new Vector3(x2, y2 + offMeleeExtra, z2).RotatedBy(offHandAngle), - Quaternion.AngleAxis(offHandAngle, Vector3.up), + Quaternion.AngleAxis(offHandAngle + OffHandRotation, Vector3.up), y2 >= 0 ? matSingle : offSingle, 0); return; } @@ -571,7 +576,7 @@ private void DrawHandsOnWeapon(Thing mainHandWeapon, float aimAngle, Pawn pawn, Graphics.DrawMesh(mesh, mainWeaponLocation + new Vector3(x2, y2 + offMeleeExtra, z2).RotatedBy(mainHandAngle), - Quaternion.AngleAxis(mainHandAngle, Vector3.up), y2 >= 0 ? matSingle : offSingle, 0); + Quaternion.AngleAxis(mainHandAngle + OffHandRotation, Vector3.up), y2 >= 0 ? matSingle : offSingle, 0); } private Vector3 AdjustRenderOffsetFromDir(Pawn pawn, ThingWithComps weapon) diff --git a/Source/ShowMeYourHands/RimWorld_MainMenuDrawer_MainMenuOnGUI.cs b/Source/ShowMeYourHands/RimWorld_MainMenuDrawer_MainMenuOnGUI.cs index a98b064..3c6fbe7 100644 --- a/Source/ShowMeYourHands/RimWorld_MainMenuDrawer_MainMenuOnGUI.cs +++ b/Source/ShowMeYourHands/RimWorld_MainMenuDrawer_MainMenuOnGUI.cs @@ -236,6 +236,7 @@ private static void LoadFromSettings() .ToVector3() : Vector3.zero }; + weapon.comps.Add(compProps); } else @@ -248,6 +249,18 @@ private static void LoadFromSettings() : Vector3.zero; } + if (ShowMeYourHandsMod.instance?.Settings?.ManualMainHandRotations.TryGetValue(keyValuePair.Key, + out var mainHandRotation) == true) + { + compProps.MainRotation = mainHandRotation; + } + + if (ShowMeYourHandsMod.instance?.Settings?.ManualOffHandRotations.TryGetValue(keyValuePair.Key, + out var offHandRotation) == true) + { + compProps.SecRotation = offHandRotation; + } + doneWeapons.Add(weapon); } } @@ -300,7 +313,9 @@ public static void LoadFromDefs(ThingDef specificDef = null) { compClass = typeof(WhandComp), MainHand = weaponSets.MainHand, - SecHand = weaponSets.SecHand + SecHand = weaponSets.SecHand, + MainRotation = weaponSets.MainRotation, + SecRotation = weaponSets.SecRotation }; weapon.comps.Add(compProps); } @@ -308,6 +323,8 @@ public static void LoadFromDefs(ThingDef specificDef = null) { compProps.MainHand = weaponSets.MainHand; compProps.SecHand = weaponSets.SecHand; + compProps.MainRotation = weaponSets.MainRotation; + compProps.SecRotation = weaponSets.SecRotation; } ShowMeYourHandsMod.DefinedByDef.Add(weapon.defName); diff --git a/Source/ShowMeYourHands/ShowMeYourHands.csproj b/Source/ShowMeYourHands/ShowMeYourHands.csproj index 19ee565..def247b 100644 --- a/Source/ShowMeYourHands/ShowMeYourHands.csproj +++ b/Source/ShowMeYourHands/ShowMeYourHands.csproj @@ -6,7 +6,7 @@ false None latest - 1.5.7 + 1.5.8 diff --git a/Source/ShowMeYourHands/ShowMeYourHandsMod.cs b/Source/ShowMeYourHands/ShowMeYourHandsMod.cs index b70d770..c6035bd 100644 --- a/Source/ShowMeYourHands/ShowMeYourHandsMod.cs +++ b/Source/ShowMeYourHands/ShowMeYourHandsMod.cs @@ -79,6 +79,11 @@ internal class ShowMeYourHandsMod : Mod /// public readonly ShowMeYourHandsModSettings Settings; + private float currentMainRotation; + + private float currentOffRotation; + private Rect weaponRect; + /// /// Constructor /// @@ -261,7 +266,8 @@ private static void UpdateWeaponStatistics() } } - private bool DrawIcon(ThingDef thing, Rect rect, Vector3 mainHandPosition, Vector3 offHandPosition) + private bool DrawIcon(ThingDef thing, Rect rect, Vector3 mainHandPosition, Vector3 offHandPosition, + float mainHandRotation, float offHandRotation) { if (thing == null) { @@ -310,12 +316,12 @@ private bool DrawIcon(ThingDef thing, Rect rect, Vector3 mainHandPosition, Vecto { if (currentMainBehind) { - GUI.DrawTexture(mainHandRect, HandTex.MatEast.mainTexture); + DrawTextureRotatedLocal(mainHandRect, HandTex.MatEast.mainTexture, mainHandRotation); } if (currentHasOffHand && currentOffBehind) { - GUI.DrawTexture(offHandRect, HandTex.MatEast.mainTexture); + DrawTextureRotatedLocal(offHandRect, HandTex.MatEast.mainTexture, offHandRotation); } } @@ -336,12 +342,12 @@ private bool DrawIcon(ThingDef thing, Rect rect, Vector3 mainHandPosition, Vecto if (!currentMainBehind) { - GUI.DrawTexture(mainHandRect, HandTex.MatSouth.mainTexture); + DrawTextureRotatedLocal(mainHandRect, HandTex.MatSouth.mainTexture, mainHandRotation); } if (currentHasOffHand && !currentOffBehind) { - GUI.DrawTexture(offHandRect, HandTex.MatSouth.mainTexture); + DrawTextureRotatedLocal(offHandRect, HandTex.MatSouth.mainTexture, offHandRotation); } return true; @@ -422,9 +428,7 @@ private void DrawOptions(Rect rect) case "Settings": { listing_Standard.Begin(frameRect); - Text.Font = GameFont.Medium; listing_Standard.Label("SMYH.settings".Translate()); - Text.Font = GameFont.Small; listing_Standard.Gap(); if (Prefs.UIScale != 1f) { @@ -494,6 +498,8 @@ private void DrawOptions(Rect rect) listing_Standard.CheckboxLabeled("SMYH.logging.label".Translate(), ref Settings.VerboseLogging, "SMYH.logging.tooltip".Translate()); + listing_Standard.CheckboxLabeled("SMYH.rotation.label".Translate(), ref Settings.Rotation, + "SMYH.rotation.tooltip".Translate()); listing_Standard.CheckboxLabeled("SMYH.matcharmor.label".Translate(), ref Settings.MatchArmorColor, "SMYH.matcharmor.tooltip".Translate()); listing_Standard.CheckboxLabeled("SMYH.matchartificiallimb.label".Translate(), @@ -529,8 +535,8 @@ private void DrawOptions(Rect rect) listing_Standard.End(); var tabFrameRect = frameRect; - tabFrameRect.y += 375; - tabFrameRect.height -= 375; + tabFrameRect.y += 400; + tabFrameRect.height -= 400; var tabContentRect = tabFrameRect; tabContentRect.x = 0; tabContentRect.y = 0; @@ -591,10 +597,8 @@ private void DrawOptions(Rect rect) break; } - Text.Font = GameFont.Medium; var labelPoint = listing_Standard.Label(currentDef.label.CapitalizeFirst(), -1F, currentDef.defName); - Text.Font = GameFont.Small; var modName = currentDef.modContentPack?.Name; var modId = currentDef.modContentPack?.PackageId; if (currentDef.modContentPack != null) @@ -619,13 +623,15 @@ private void DrawOptions(Rect rect) listing_Standard.Gap(150); - var weaponRect = new Rect(labelPoint.x + 270, labelPoint.y + 5, weaponSize.x, + weaponRect = new Rect(labelPoint.x + 270, labelPoint.y + 5, weaponSize.x, weaponSize.y); if (currentMainHand == Vector3.zero && !currentNoHands) { currentMainHand = compProperties.MainHand; currentOffHand = compProperties.SecHand; + currentMainRotation = compProperties.MainRotation; + currentOffRotation = compProperties.SecRotation; currentHasOffHand = currentOffHand != Vector3.zero; currentMainBehind = compProperties.MainHand.y < 0; currentOffBehind = compProperties.SecHand.y < 0 || currentOffHand == Vector3.zero; @@ -633,20 +639,16 @@ private void DrawOptions(Rect rect) currentNoHands = currentMainHand == Vector3.zero; - if (!DrawIcon(currentDef, weaponRect, currentMainHand, currentOffHand)) + if (!DrawIcon(currentDef, weaponRect, currentMainHand, currentOffHand, currentMainRotation, + currentOffRotation)) { listing_Standard.Label("SMYH.error.texture".Translate(SelectedDef)); listing_Standard.End(); break; } - - listing_Standard.Gap(20); - listing_Standard.CheckboxLabeled("SMYH.twohands.label".Translate(), ref currentHasOffHand); - if (currentHasOffHand) - { - currentNoHands = false; - } + listing_Standard.GapLine(24); + listing_Standard.ColumnWidth = 230; listing_Standard.CheckboxLabeled("SMYH.nohands.label".Translate(), ref currentNoHands); if (currentNoHands) @@ -656,8 +658,6 @@ private void DrawOptions(Rect rect) currentOffHand = Vector3.zero; } - listing_Standard.GapLine(); - listing_Standard.ColumnWidth = 230; Rect lastMainLabel; if (!currentNoHands) { @@ -669,6 +669,14 @@ private void DrawOptions(Rect rect) currentMainHand.z = Widgets.HorizontalSlider(listing_Standard.GetRect(20), currentMainHand.z, -0.5f, 0.5f, false, currentMainHand.z.ToString(), null, null, 0.001f); + if (Settings.Rotation) + { + lastMainLabel = listing_Standard.Label("SMYH.mainhandrotation.label".Translate()); + currentMainRotation = Widgets.HorizontalSlider(listing_Standard.GetRect(20), + currentMainRotation, -179f, 179, false, + "SMYH.degree".Translate(currentMainRotation), null, null, 1f); + } + listing_Standard.Gap(); listing_Standard.CheckboxLabeled("SMYH.renderbehind.label".Translate(), ref currentMainBehind); @@ -683,13 +691,20 @@ private void DrawOptions(Rect rect) } else { + listing_Standard.Gap(45); lastMainLabel = listing_Standard.Label(""); } + listing_Standard.NewColumn(); + listing_Standard.Gap(217); + listing_Standard.CheckboxLabeled("SMYH.twohands.label".Translate(), ref currentHasOffHand); + if (currentHasOffHand) + { + currentNoHands = false; + } + if (currentHasOffHand) { - listing_Standard.NewColumn(); - listing_Standard.Gap(262); listing_Standard.Label("SMYH.offhandhorizontal.label".Translate()); currentOffHand.x = Widgets.HorizontalSlider(listing_Standard.GetRect(20), currentOffHand.x, -0.5f, 0.5f, false, @@ -698,6 +713,14 @@ private void DrawOptions(Rect rect) currentOffHand.z = Widgets.HorizontalSlider(listing_Standard.GetRect(20), currentOffHand.z, -0.5f, 0.5f, false, currentOffHand.z.ToString(), null, null, 0.001f); + if (Settings.Rotation) + { + listing_Standard.Label("SMYH.offhandrotation.label".Translate()); + currentOffRotation = Widgets.HorizontalSlider(listing_Standard.GetRect(20), + currentOffRotation, -179f, 179, false, + "SMYH.degree".Translate(currentOffRotation), null, null, 1f); + } + listing_Standard.Gap(); listing_Standard.CheckboxLabeled("SMYH.renderbehind.label".Translate(), ref currentOffBehind); if (Event.current.type is EventType.MouseDrag or EventType.MouseDown && @@ -710,10 +733,34 @@ private void DrawOptions(Rect rect) } } - Widgets.Label(new Rect(lastMainLabel.position + new Vector2(0, 100), new Vector2(500, 50)), - "SMYH.draginfo".Translate()); + if (Mouse.IsOver(weaponRect) && Event.current.type == EventType.ScrollWheel) + { + var change = Mathf.Clamp(Event.current.delta.y, -2, 2); + if (Event.current.shift) + { + change *= 5; + } + + switch (getMouseOverHand()) + { + case > 0: + currentMainRotation = Mathf.Clamp(currentMainRotation + change, -179, 179); + break; + case < 0: + currentOffRotation = Mathf.Clamp(currentOffRotation + change, -179, 179); + break; + } + } + + var dragInfo = "SMYH.draginfo".Translate(); + if (Settings.Rotation) + { + dragInfo += $" {"SMYH.rotate".Translate()}"; + } + + Widgets.Label(new Rect(lastMainLabel.position + new Vector2(0, 100), new Vector2(500, 54)), dragInfo); - var savePostition = lastMainLabel.position + new Vector2(0, 170); + var savePostition = lastMainLabel.position + new Vector2(0, 165); var undoPostition = savePostition + new Vector2(buttonSize.x + iconButtonSize.x, 0); var resetPostition = undoPostition + new Vector2(buttonSize.x + iconButtonSize.x, 0); var copyPostition = resetPostition + new Vector2(buttonSize.x + iconButtonSize.x, 0); @@ -724,7 +771,7 @@ private void DrawOptions(Rect rect) if (Widgets.ButtonImageFitted(copyRect, TexButton.Copy)) { GUIUtility.systemCopyBuffer = - $"|HandData|{new SaveableVector3(currentMainHand)}|{new SaveableVector3(currentOffHand)}|{currentHasOffHand}|{currentMainBehind}|{currentOffBehind}"; + $"|HandData|{new SaveableVector3(currentMainHand)}|{new SaveableVector3(currentOffHand)}|{currentHasOffHand}|{currentMainBehind}|{currentOffBehind}|{currentMainRotation}|{currentOffRotation}"; SoundDefOf.Tick_High.PlayOneShotOnCamera(); Messages.Message("SMYH.copy.info".Translate(), MessageTypeDefOf.SituationResolved, false); } @@ -737,13 +784,15 @@ private void DrawOptions(Rect rect) if (Widgets.ButtonImageFitted(pasteRect, TexButton.Paste)) { var data = GUIUtility.systemCopyBuffer.Split('|'); - if (data.Length == 7) + if (data.Length == 9) { currentMainHand = SaveableVector3.FromString(data[2]).ToVector3(); currentOffHand = SaveableVector3.FromString(data[3]).ToVector3(); currentHasOffHand = bool.Parse(data[4]); currentMainBehind = bool.Parse(data[5]); currentOffBehind = bool.Parse(data[6]); + currentMainRotation = float.Parse(data[7]); + currentOffRotation = float.Parse(data[8]); Messages.Message("SMYH.paste.info".Translate(), MessageTypeDefOf.SituationResolved, false); } } @@ -757,6 +806,8 @@ private void DrawOptions(Rect rect) if (currentMainHand != compProperties.MainHand || currentOffHand != compProperties.SecHand || + currentMainRotation != compProperties.MainRotation || + currentOffRotation != compProperties.SecRotation || currentHasOffHand != (currentOffHand != Vector3.zero) || currentMainBehind != compProperties.MainHand.y < 0 || currentOffBehind != compProperties.SecHand.y < 0) @@ -784,10 +835,14 @@ void SaveAction() compProperties.MainHand = currentMainHand; compProperties.SecHand = currentOffHand; + compProperties.MainRotation = currentMainRotation; + compProperties.SecRotation = currentOffRotation; instance.Settings.ManualMainHandPositions[currentDef.defName] = new SaveableVector3(compProperties.MainHand); instance.Settings.ManualOffHandPositions[currentDef.defName] = new SaveableVector3(compProperties.SecHand); + instance.Settings.ManualMainHandRotations[currentDef.defName] = compProperties.MainRotation; + instance.Settings.ManualOffHandRotations[currentDef.defName] = compProperties.SecRotation; } void UndoAction() @@ -795,6 +850,8 @@ void UndoAction() currentNoHands = currentMainHand == Vector3.zero; currentMainHand = compProperties.MainHand; currentOffHand = compProperties.SecHand; + currentMainRotation = compProperties.MainRotation; + currentOffRotation = compProperties.SecRotation; currentHasOffHand = currentOffHand != Vector3.zero; currentMainBehind = compProperties.MainHand.y < 0; currentOffBehind = compProperties.SecHand.y < 0; @@ -808,6 +865,8 @@ void ResetAction() ResetOneWeapon(currentDef, ref compProperties); currentMainHand = compProperties.MainHand; currentOffHand = compProperties.SecHand; + currentMainRotation = compProperties.MainRotation; + currentOffRotation = compProperties.SecRotation; currentHasOffHand = currentOffHand != Vector3.zero; currentMainBehind = compProperties.MainHand.y < 0; currentOffBehind = compProperties.SecHand.y < 0; @@ -817,6 +876,41 @@ void ResetAction() } } + private int getMouseOverHand() + { + if (currentMainHand != Vector3.zero) + { + var mainHandCoords = new Vector2( + (weaponSize.x / 2) + (currentMainHand.x * 200) - (handSize.x / 2), + (weaponSize.x / 2) - (currentMainHand.z * 200) - (handSize.y / 2)); + var mainHandRect = new Rect(weaponRect.x + mainHandCoords.x, weaponRect.y + mainHandCoords.y, + handSize.x, + handSize.y); + if (mainHandRect.Contains(Event.current.mousePosition)) + { + return 1; + } + } + + if (!currentHasOffHand || currentOffHand == Vector3.zero) + { + return 0; + } + + var offHandCoords = new Vector2( + (weaponSize.x / 2) + (currentOffHand.x * 200) - (handSize.x / 2), + (weaponSize.x / 2) - (currentOffHand.z * 200) - (handSize.y / 2)); + var offHandRect = new Rect(weaponRect.x + offHandCoords.x, weaponRect.y + offHandCoords.y, + handSize.x, + handSize.y); + if (offHandRect.Contains(Event.current.mousePosition)) + { + return -1; + } + + return 0; + } + private static void CopyChangedWeapons(bool onlySelected = false) { if (onlySelected && string.IsNullOrEmpty(selectedSubDef)) @@ -874,6 +968,24 @@ where weaponsDefsToSelectFrom.Contains(position.Key) } } + if (instance.Settings.ManualMainHandRotations.TryGetValue(settingsManualMainHandPosition.Key, + out var mainRotation)) + { + if (mainRotation != 0f) + { + stringBuilder.AppendLine($" {mainRotation}"); + } + } + + if (instance.Settings.ManualOffHandRotations.TryGetValue(settingsManualMainHandPosition.Key, + out var offRotation)) + { + if (offRotation != 0f) + { + stringBuilder.AppendLine($" {offRotation}"); + } + } + stringBuilder.AppendLine(" "); stringBuilder.AppendLine( $"
  • {settingsManualMainHandPosition.Key}
  • "); @@ -984,6 +1096,8 @@ private static void ResetOneWeapon(ThingDef currentDef, ref WhandCompProps compP { instance.Settings.ManualMainHandPositions.Remove(currentDef.defName); instance.Settings.ManualOffHandPositions.Remove(currentDef.defName); + instance.Settings.ManualMainHandPositions.Remove(currentDef.defName); + instance.Settings.ManualOffHandRotations.Remove(currentDef.defName); if (compProperties == null) { compProperties = currentDef.GetCompProperties(); @@ -991,6 +1105,8 @@ private static void ResetOneWeapon(ThingDef currentDef, ref WhandCompProps compP compProperties.MainHand = Vector3.zero; compProperties.SecHand = Vector3.zero; + compProperties.MainRotation = 0f; + compProperties.SecRotation = 0f; RimWorld_MainMenuDrawer_MainMenuOnGUI.LoadFromDefs(currentDef); if (compProperties.MainHand == Vector3.zero) { diff --git a/Source/ShowMeYourHands/ShowMeYourHandsModSettings.cs b/Source/ShowMeYourHands/ShowMeYourHandsModSettings.cs index 58c7b76..4d59d42 100644 --- a/Source/ShowMeYourHands/ShowMeYourHandsModSettings.cs +++ b/Source/ShowMeYourHands/ShowMeYourHandsModSettings.cs @@ -13,17 +13,25 @@ internal class ShowMeYourHandsModSettings : ModSettings private List manualMainHandPositionsKeys; private List manualMainHandPositionsValues; + public Dictionary ManualMainHandRotations = new Dictionary(); + private List manualMainHandRotationsKeys; + private List manualMainHandRotationsValues; public Dictionary ManualOffHandPositions = new Dictionary(); private List manualOffHandPositionsKeys; private List manualOffHandPositionsValues; + public Dictionary ManualOffHandRotations = new Dictionary(); + private List manualOffHandRotationsKeys; + private List manualOffHandRotationsValues; + public bool MatchArmorColor; public bool MatchArtificialLimbColor; public bool MatchHandAmounts; public bool RepositionHands = true; public bool ResizeHands = true; + public bool Rotation = ModsConfig.IsActive("andromeda.nicehands"); public bool ShowOtherTmes; public bool ShowWhenCarry; public bool VerboseLogging; @@ -32,6 +40,7 @@ public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref VerboseLogging, "VerboseLogging"); + Scribe_Values.Look(ref Rotation, "Rotation", ModsConfig.IsActive("andromeda.nicehands")); Scribe_Values.Look(ref MatchArmorColor, "MatchArmorColor"); Scribe_Values.Look(ref MatchArtificialLimbColor, "MatchArtificialLimbColor"); Scribe_Values.Look(ref MatchHandAmounts, "MatchHandAmounts"); @@ -45,6 +54,12 @@ public override void ExposeData() Scribe_Collections.Look(ref ManualOffHandPositions, "ManualOffHandPositions", LookMode.Value, LookMode.Value, ref manualOffHandPositionsKeys, ref manualOffHandPositionsValues); + Scribe_Collections.Look(ref ManualMainHandRotations, "ManualMainHandRotations", LookMode.Value, + LookMode.Value, + ref manualMainHandRotationsKeys, ref manualMainHandRotationsValues); + Scribe_Collections.Look(ref ManualOffHandRotations, "ManualOffHandRotations", LookMode.Value, + LookMode.Value, + ref manualOffHandRotationsKeys, ref manualOffHandRotationsValues); } public void ResetManualValues() @@ -55,6 +70,12 @@ public void ResetManualValues() manualOffHandPositionsKeys = []; manualOffHandPositionsValues = []; ManualOffHandPositions = new Dictionary(); + manualMainHandRotationsKeys = []; + manualMainHandRotationsValues = []; + ManualMainHandRotations = new Dictionary(); + manualOffHandRotationsKeys = []; + manualOffHandRotationsValues = []; + ManualOffHandRotations = new Dictionary(); RimWorld_MainMenuDrawer_MainMenuOnGUI.UpdateHandDefinitions(); } } \ No newline at end of file diff --git a/Source/ShowMeYourHands/WhandCompProps.cs b/Source/ShowMeYourHands/WhandCompProps.cs index edb9bb7..cabf8a0 100644 --- a/Source/ShowMeYourHands/WhandCompProps.cs +++ b/Source/ShowMeYourHands/WhandCompProps.cs @@ -6,7 +6,9 @@ namespace ShowMeYourHands; public class WhandCompProps : CompProperties { public Vector3 MainHand = Vector3.zero; + public float MainRotation = 0f; public Vector3 SecHand = Vector3.zero; + public float SecRotation = 0f; public WhandCompProps() {