using System.Collections.Generic; using System.Reflection; using Harmony; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using StardewValley; using StardewValley.BellsAndWhistles; using StardewValley.Objects; using StardewValley.Projectiles; namespace StardewModdingAPI.Mods.CustomLocalization { public class ModEntry : Mod { public static ModConfig ModConfig; public static IMonitor monitor; public static string ModPath; private static ModEntry Instance; public static void SaveConfig() { Instance.Helper.WriteConfig(ModConfig); } public override void Entry(IModHelper helper) { Instance = this; ModConfig = helper.ReadConfig(); ModPath = helper.DirectoryPath; monitor = this.Monitor; HarmonyInstance harmony = HarmonyInstance.Create("zaneyork.CustomLocalization"); harmony.PatchAll(Assembly.GetExecutingAssembly()); Dictionary dictionary = this.Helper.Reflection.GetField>(Game1.content, "_localizedAsset").GetValue(); Dictionary dictionaryAssets = this.Helper.Reflection.GetField>(Game1.content, "loadedAssets").GetValue(); dictionary.Clear(); dictionaryAssets.Clear(); LoadContent(); if (ModConfig.CurrentLanguageCode > ModConfig.OriginLocaleCount) { monitor.Log($"Restore locale to : {ModConfig.CurrentLanguageCode}"); LocalizedContentManager.CurrentLanguageCode = (LocalizedContentManager.LanguageCode)ModConfig.CurrentLanguageCode; } else { if (!LocalizedContentManager.CurrentLanguageLatin) { this.Helper.Reflection.GetMethod(typeof(SpriteText), "OnLanguageChange").Invoke(LocalizedContentManager.CurrentLanguageCode); } } } private void LoadContent() { Game1.concessionsSpriteSheet = ((ContentManager)Game1.content).Load("LooseSprites\\Concessions"); Game1.birdsSpriteSheet = ((ContentManager)Game1.content).Load("LooseSprites\\birds"); Game1.daybg = ((ContentManager)Game1.content).Load("LooseSprites\\daybg"); Game1.nightbg = ((ContentManager)Game1.content).Load("LooseSprites\\nightbg"); Game1.menuTexture = ((ContentManager)Game1.content).Load("Maps\\MenuTiles"); Game1.uncoloredMenuTexture = ((ContentManager)Game1.content).Load("Maps\\MenuTilesUncolored"); Game1.lantern = ((ContentManager)Game1.content).Load("LooseSprites\\Lighting\\lantern"); Game1.windowLight = ((ContentManager)Game1.content).Load("LooseSprites\\Lighting\\windowLight"); Game1.sconceLight = ((ContentManager)Game1.content).Load("LooseSprites\\Lighting\\sconceLight"); Game1.cauldronLight = ((ContentManager)Game1.content).Load("LooseSprites\\Lighting\\greenLight"); Game1.indoorWindowLight = ((ContentManager)Game1.content).Load("LooseSprites\\Lighting\\indoorWindowLight"); Game1.shadowTexture = ((ContentManager)Game1.content).Load("LooseSprites\\shadow"); Game1.mouseCursors = ((ContentManager)Game1.content).Load("LooseSprites\\Cursors"); Game1.mouseCursors2 = ((ContentManager)Game1.content).Load("LooseSprites\\Cursors2"); Game1.giftboxTexture = ((ContentManager)Game1.content).Load("LooseSprites\\Giftbox"); Game1.controllerMaps = ((ContentManager)Game1.content).Load("LooseSprites\\ControllerMaps"); Game1.animations = ((ContentManager)Game1.content).Load("TileSheets\\animations"); Game1.mobileSpriteSheet = ((ContentManager)Game1.content).Load("LooseSprites\\MobileAtlas_manually_made"); Game1.achievements = (Dictionary)((ContentManager)Game1.content).Load>("Data\\Achievements"); Game1.NPCGiftTastes = (IDictionary)((ContentManager)Game1.content).Load>("Data\\NPCGiftTastes"); this.Helper.Reflection.GetMethod(Game1.game1, "TranslateFields").Invoke(); Game1.dialogueFont = (SpriteFont)((ContentManager)Game1.content).Load("Fonts\\SpriteFont1"); Game1.smallFont = (SpriteFont)((ContentManager)Game1.content).Load("Fonts\\SmallFont"); Game1.tinyFont = (SpriteFont)((ContentManager)Game1.content).Load("Fonts\\tinyFont"); Game1.tinyFontBorder = (SpriteFont)((ContentManager)Game1.content).Load("Fonts\\tinyFontBorder"); Game1.objectSpriteSheet = ((ContentManager)Game1.content).Load("Maps\\springobjects"); Game1.cropSpriteSheet = ((ContentManager)Game1.content).Load("TileSheets\\crops"); Game1.emoteSpriteSheet = ((ContentManager)Game1.content).Load("TileSheets\\emotes"); Game1.debrisSpriteSheet = ((ContentManager)Game1.content).Load("TileSheets\\debris"); Game1.bigCraftableSpriteSheet = ((ContentManager)Game1.content).Load("TileSheets\\Craftables"); Game1.rainTexture = ((ContentManager)Game1.content).Load("TileSheets\\rain"); Game1.buffsIcons = ((ContentManager)Game1.content).Load("TileSheets\\BuffsIcons"); Game1.objectInformation = (IDictionary)((ContentManager)Game1.content).Load>("Data\\ObjectInformation"); Game1.clothingInformation = (IDictionary)((ContentManager)Game1.content).Load>("Data\\ClothingInformation"); Game1.objectContextTags = (IDictionary)((ContentManager)Game1.content).Load>("Data\\ObjectContextTags"); Game1.bigCraftablesInformation = (IDictionary)((ContentManager)Game1.content).Load>("Data\\BigCraftablesInformation"); FarmerRenderer.hairStylesTexture = ((ContentManager)Game1.content).Load("Characters\\Farmer\\hairstyles"); FarmerRenderer.shirtsTexture = ((ContentManager)Game1.content).Load("Characters\\Farmer\\shirts"); FarmerRenderer.pantsTexture = ((ContentManager)Game1.content).Load("Characters\\Farmer\\pants"); FarmerRenderer.hatsTexture = ((ContentManager)Game1.content).Load("Characters\\Farmer\\hats"); FarmerRenderer.accessoriesTexture = ((ContentManager)Game1.content).Load("Characters\\Farmer\\accessories"); Furniture.furnitureTexture = ((ContentManager)Game1.content).Load("TileSheets\\furniture"); SpriteText.spriteTexture = ((ContentManager)Game1.content).Load("LooseSprites\\font_bold"); SpriteText.coloredTexture = ((ContentManager)Game1.content).Load("LooseSprites\\font_colored"); Tool.weaponsTexture = ((ContentManager)Game1.content).Load("TileSheets\\weapons"); Projectile.projectileSheet = ((ContentManager)Game1.content).Load("TileSheets\\Projectiles"); } } }