public void Parse() { if (WindowSize.X == 0 && WindowSize.Y == 0) { WindowSize = new Vector2(1200, 680); } MusicManager.Volume = Music / 100.0f; SoundEffectManager.Volume = Sound / 100.0f; SoundEffectManager.Mute(Muted); MusicManager.Mute(Muted); Localization.Load(Language); if (ContentPackNames.Any()) { var contentPackNames = new List <string>(ContentPackNames); foreach (var contentPack in ContentPackNames) { if (new ContentPacksFolder().CheckExists(contentPack) != ExistenceCheckResult.FolderExists) { contentPackNames.Remove(contentPack); } else { var contentPackFolder = new ContentPacksFolder().GetFolder(contentPack); var contentPackException = contentPackFolder.CreateFile("exceptions.dat", CreationCollisionOption.OpenIfExists); // TODO: Check ContentPackManager.Load(contentPackException.Path); } } ContentPackNames = contentPackNames.ToArray(); } Core.GraphicsManager.PreferMultiSampling = PreferMultiSampling; }
public override void Entry(IModHelper help) { this.Config = this.Helper.ReadConfig <ModConfig>(); Logger = this.Monitor; EnabledAssets = new Dictionary <string, bool>(); ModHelper = help; EnableMod = this.Config.EnableMod; this.HDAssetManager = new HDAssetManager(help); this.ContentPackManager = new ContentPackManager(this.HDAssetManager); this.Helper.Events.Input.ButtonPressed += OnButtonPressed; this.Helper.Events.Player.Warped += OnWarped; this.Helper.Events.GameLoop.DayStarted += OnDayStarted; foreach (var asset in this.Config.LoadAssets) { string loadSection = asset.Key.Substring(0, asset.Key.LastIndexOf("/")); bool enabled = asset.Value && this.Config.LoadSections.GetValueSafe(loadSection); AddEnabledAsset(asset.Key, enabled); if (enabled) { string assetFile = Path.Combine(this.Config.AssetsPath, asset.Key) + ".png"; if (File.Exists(Path.Combine(help.DirectoryPath, assetFile))) { this.HDAssetManager.AddAssetFile(asset.Key, assetFile); } } } string[] contentPackDirs = Directory.GetDirectories(Path.Combine(help.DirectoryPath, "..")); foreach (string dir in contentPackDirs) { string manifestFile = Path.Combine(dir, "manifest.json"); if (Directory.GetParent(manifestFile).Name.StartsWith(".")) { continue; } ContentPackManifest manifest = null; try { manifest = this.Helper.ReadJsonFile <ContentPackManifest>(manifestFile); } catch (Exception e) { continue; } if (manifest != null && this.Config.LoadContentPacks.TryGetValue(manifest.UniqueID, out bool load) && load) { this.Monitor.Log($"Reading content pack: {manifest.Name} {manifest.Version}"); WhenDictionary configChoices = null; try { configChoices = this.Helper.ReadJsonFile <WhenDictionary>(Path.Combine(dir, "config.json")); } catch (Exception e) { this.Monitor.Log($"Failed to read config.json for {manifest.Name} {manifest.Version}"); continue; } if (configChoices == null) { configChoices = new WhenDictionary(); } ContentConfig contentConfig = null; try { contentConfig = this.Helper.ReadJsonFile <ContentConfig>(Path.Combine(dir, "content.json")); } catch (Exception e) { this.Monitor.Log($"Failed to read content.json for {manifest.Name} {manifest.Version}"); continue; } if (contentConfig == null) { continue; } string contentPath = Path.Combine(help.DirectoryPath, this.Config.ContentPacksPath, manifest.UniqueID); Directory.CreateDirectory(contentPath); ContentPackObject contentPack = new ContentPackObject(dir, contentPath, manifest, contentConfig, configChoices); this.ContentPackManager.AddContentPack(contentPack); } } HarmonyInstance instance = HarmonyInstance.Create("NinthWorld.HDSprites"); DrawFix.InitializePatch(instance); instance.PatchAll(Assembly.GetExecutingAssembly()); }