Skip to content

Commit

Permalink
Merge pull request #51 from bizzehdee/main
Browse files Browse the repository at this point in the history
Fix for date-time's in the save/load menu not respecting machine culture
  • Loading branch information
jan-bures authored Aug 10, 2024
2 parents 2523a2d + 2c6087c commit aca4784
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CommunityFixes/Fix/SaveLoadDateTimeFix/SaveLoadDateTimeFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CommunityFixes.Fix.STFUFix;

[Fix("Save/Load Date/Time Fix")]
public class SaveLoadDateTimeFix : BaseFix
{
public override void OnInitialized()
{
HarmonyInstance.PatchAll(typeof(SaveLoadDateTimeFix_Patch));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using HarmonyLib;
using KSP.Game;
using System.Globalization;
using UnityEngine.UI;

namespace CommunityFixes.Fix.STFUFix;

internal class SaveLoadDateTimeFix_Patch
{
[HarmonyPatch(typeof(SaveLoadDialogFileEntry), nameof(SaveLoadDialogFileEntry.Initialize), new Type[] { typeof(ExtendedSaveFileInfo), typeof(bool), typeof(bool) })]
[HarmonyPrefix]
public static void SaveLoadDialogFileEntry_Initialize(SaveLoadDialogFileEntry __instance, ExtendedSaveFileInfo fileInfo, bool loading, bool isLastPlayed)
{
CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentUICulture;
}

[HarmonyPatch(typeof(SaveLoadDialog), nameof(SaveLoadDialog.UpdateLoadMenuGameInformation), new Type[] { typeof(ExtendedSaveFileInfo), typeof(Image) })]
[HarmonyPrefix]
public static void SaveLoadDialog_UpdateLoadMenuGameInformation(SaveLoadDialog __instance, ExtendedSaveFileInfo fileInfo, Image thumnailScreenshot)
{
CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentUICulture;
}

[HarmonyPatch(typeof(CampaignLoadMenu), nameof(CampaignLoadMenu.UpdateLoadMenuGameInformation), new Type[] { typeof(ExtendedSaveFileInfo), typeof(Image) })]
[HarmonyPrefix]
public static void CampaignLoadMenu_UpdateLoadMenuGameInformation(CampaignLoadMenu __instance, ExtendedSaveFileInfo fileInfo, Image thumnailScreenshot)
{
CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentUICulture;
}

[HarmonyPatch(typeof(CampaignTileEntry), nameof(CampaignTileEntry.Initialize), new Type[] { typeof(ExtendedSaveFileInfo), typeof(CampaignLoadMenu), typeof(CampaignMenu) })]
[HarmonyPrefix]
public static void CampaignTileEntry_UpdateLoadMenuGameInformation(CampaignTileEntry __instance, ExtendedSaveFileInfo fileInfo, CampaignLoadMenu loadMenu, CampaignMenu campaignMenu)
{
CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentUICulture;
}
}

0 comments on commit aca4784

Please sign in to comment.