diff --git a/.gitignore b/.gitignore index f5aefd6a..f412cb09 100644 --- a/.gitignore +++ b/.gitignore @@ -385,4 +385,5 @@ packages/HarmonyX.2.3.1/lib/net45/0Harmony.xml packages/HarmonyX.2.3.1/lib/net35/0Harmony.xml # include libraries folder -!libraries/* \ No newline at end of file +!libraries/* +/ValheimPlus/AssemblyPublicizer.exe diff --git a/README.md b/README.md index 90934c1e..8f7a3dd6 100644 --- a/README.md +++ b/README.md @@ -445,3 +445,4 @@ Please see [CONTRIBUTING.md](/CONTRIBUTING.md) for details on compiling V+ for d * Nick 'baconparticles' P. - https://github.com/baconparticles * An 'Hachidan' N. - https://github.com/ahnguyen09 * Abra - https://github.com/Abrackadabra +* Increddibelly - https://github.com/increddibelly diff --git a/ValheimPlus/GameClasses/Player.cs b/ValheimPlus/GameClasses/Player.cs index 2f682402..6deb3b41 100644 --- a/ValheimPlus/GameClasses/Player.cs +++ b/ValheimPlus/GameClasses/Player.cs @@ -53,9 +53,8 @@ private static void Postfix(ref Player __instance) [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_Patch { - private static GameObject timeObj = null; - private static double savedEnvSeconds = -1; + private static double savedEnvMinutes = -1; private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref Vector3 ___m_lookDir, ref GameObject ___m_placementGhost, Transform ___m_eye) { if ((Configuration.Current.Player.IsEnabled && Configuration.Current.Player.queueWeaponChanges) && (ZInput.GetButtonDown("Hide") || ZInput.GetButtonDown("JoyHide"))) @@ -85,11 +84,8 @@ private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref ApplyDodgeHotkeys(ref __instance, ref ___m_moveDir, ref ___m_lookDir); } - if (Configuration.Current.GameClock.IsEnabled) { - String hours_str = ""; - String minutes_str = ""; String amPM_str = ""; Hud hud = Hud.instance; @@ -120,8 +116,11 @@ private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref else timeText = timeObj.GetComponent(); EnvMan env = EnvMan.instance; - if (savedEnvSeconds != env.m_totalSeconds) + // only update the time at most once per minute + if (savedEnvMinutes != env.m_totalSeconds/60) { + int day = env.GetCurrentDay(); + float minuteFrac = Mathf.Lerp(0, 24, env.GetDayFraction()); float hr24 = Mathf.Floor(minuteFrac); minuteFrac = minuteFrac - hr24; @@ -136,17 +135,17 @@ private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref if (hours_int > 12) hours_int -= 12; } - if (hours_int < 10) hours_str = "0" + hours_int; - if (minutes_int < 10) minutes_str = "0" + minutes_int; - if (hours_int >= 10) hours_str = hours_int.ToString(); - if (minutes_int >= 10) minutes_str = minutes_int.ToString(); + // always show hours and minutes as double digits. + // combine all values into a single notification + timeText.text = $"Day {day}, {hours_int:00}:{minutes_int:00} {amPM_str}"; - timeText.text = hours_str + ":" + minutes_str + amPM_str; - var staminaBarRec = hud.m_staminaBar2Root.transform as RectTransform; - var statusEffictBarRec = hud.m_statusEffectListRoot.transform as RectTransform; - timeObj.GetComponent().position = new Vector2(staminaBarRec.position.x, statusEffictBarRec.position.y); + // place the time directly below the stamina bar + var staminaBarRect = hud.m_staminaBar2Root.transform as RectTransform; + var statusEffectBarRect = hud.m_statusEffectListRoot.transform as RectTransform; + timeObj.GetComponent().position = new Vector2(staminaBarRect.position.x, statusEffectBarRect.position.y); timeObj.SetActive(true); - savedEnvSeconds = env.m_totalSeconds; + + savedEnvMinutes = env.m_totalSeconds/60; } } }