-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from bizzehdee/main
Fix for date-time's in the save/load menu not respecting machine culture
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/CommunityFixes/Fix/SaveLoadDateTimeFix/SaveLoadDateTimeFix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/CommunityFixes/Fix/SaveLoadDateTimeFix/SaveLoadDateTimeFix_Patch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |