Exemplo n.º 1
0
        private void loadContentPacks()
        {
            foreach (IContentPack pack in Helper.GetContentPacks())
            {
                MusicContent content = pack.ReadJsonFile <MusicContent>("content.json");

                foreach (MusicItem music in content.Music)
                {
                    string path = Path.Combine(pack.DirectoryPath, music.File);
                    if (!music.Preload && !config.Convert)
                    {
                        Task.Run(() =>
                        {
                            addMusic(path, music);
                        });
                    }
                    else
                    {
                        addMusic(path, music);
                    }
                }

                foreach (LocationItem location in content.Locations)
                {
                    if (locations.ContainsKey(location.Location))
                    {
                        locations.Remove(location.Location);
                    }

                    locations.Add(location.Location, location.MusicId);
                }
            }
        }
        private void loadContentPacks()
        {
            loads   = 0;
            simLoad = 0;
            foreach (IContentPack pack in Helper.ContentPacks.GetOwned())
            {
                MusicContent content = pack.ReadJsonFile <MusicContent>("content.json");
                loads += content.Music.Count;
                foreach (MusicItem music in content.Music)
                {
                    string path = Path.Combine(pack.DirectoryPath, music.File);
                    if (!music.Preload && !config.Convert)
                    {
                        Task.Run(() =>
                        {
                            addMusic(path, music);
                        });
                    }
                    else if (!config.Convert)
                    {
                        addMusic(path, music);
                    }
                    else
                    {
                        while (simLoad > simuMax || working.Contains(path))
                        {
                            Thread.Sleep(slp);
                        }

                        simLoad++;
                        working.Add(path);
                        Task.Run(() =>
                        {
                            addMusic(path, music);
                        });
                    }
                }
                if (config.Convert)
                {
                    while (loads > 0)
                    {
                        Thread.Sleep(slp);
                    }
                }

                foreach (LocationItem location in content.Locations)
                {
                    if (locations.ContainsKey(location.Location))
                    {
                        locations.Remove(location.Location);
                    }

                    locations.Add(location.Location, location.MusicId);
                }
            }
        }
Exemplo n.º 3
0
        private void loadContentPacks()
        {
            foreach (IContentPack pack in Helper.ContentPacks.GetOwned())
            {
                MusicContent content = pack.ReadJsonFile <MusicContent>("content.json");
                loads += content.Music.Count;
                foreach (MusicItem music in content.Music)
                {
                    string path = Path.Combine(pack.DirectoryPath, music.File);
                    addMusic(path, music);
                }

                foreach (LocationItem location in content.Locations)
                {
                    if (locations.ContainsKey(location.Location))
                    {
                        locations.Remove(location.Location);
                    }

                    locations.Add(location.Location, location.MusicId);
                }
            }
        }
        private void loadContentPacks()
        {
            foreach (IContentPack pack in Helper.GetContentPacks())
            {
                MusicContent content = pack.ReadJsonFile <MusicContent>("content.json");

                foreach (MusicItem music in content.Music)
                {
                    string path = Path.Combine(pack.DirectoryPath, music.File);

                    if (!music.Preload)
                    {
                        Task.Run(() =>
                        {
                            addMusic(path, music);
                        });
                    }
                    else
                    {
                        addMusic(path, music);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void loadContentPacks()
        {
            List <string> ids   = new List <string>();
            List <string> files = new List <string>();

            foreach (IContentPack pack in Helper.ContentPacks.GetOwned())
            {
                MusicContent     content = pack.ReadJsonFile <MusicContent>("content.json");
                List <MusicItem> all     = new List <MusicItem>();
                all.AddRange(content.Music);
                all.AddRange(content.Sounds);
                all.AddRange(content.Emitters);
                loads += all.Count;
                foreach (MusicItem music in all)
                {
                    string path = Path.Combine(pack.DirectoryPath, music.File);
                    addMusic(path, music);
                    if (!ids.Contains(music.Id))
                    {
                        ids.Add(music.Id);
                    }

                    if (!files.Contains(Path.GetFileNameWithoutExtension(path)))
                    {
                        files.Add(Path.GetFileNameWithoutExtension(path));
                    }
                }

                foreach (LocationItem location in content.Locations)
                {
                    if (location.MusicId != null && location.MusicId != "")
                    {
                        if (locations.ContainsKey(location.Location))
                        {
                            locations.Remove(location.Location);
                        }

                        locations.Add(location.Location, location.MusicId);
                    }

                    if (location.Emitters.Count > 0)
                    {
                        if (!emitterPlacements.ContainsKey(location.Location))
                        {
                            emitterPlacements.Add(location.Location, location.Emitters);
                        }
                        else
                        {
                            emitterPlacements[location.Location].AddRange(location.Emitters);
                        }
                    }
                }
            }

            List <GMCMOption> options = new List <GMCMOption>();

            foreach (var id in ids)
            {
                List <string> choices = new List <string>()
                {
                    "CM:Default", "Vanilla", "Random", "Any"
                };

                foreach (var file in files.OrderBy(f => f))
                {
                    choices.Add(Path.GetFileNameWithoutExtension(file));
                }

                int activeIndex = 0;

                if (config.Presets.ContainsKey(id) && config.Presets[id] != "Default" && choices.Exists(c => c == config.Presets[id]))
                {
                    activeIndex = choices.IndexOf(config.Presets[id]);
                }

                choices[1] = choices[1] + ":" + id;

                options.Add(new GMCMOption(id, choices, "", activeIndex));
            }

            if (options.Count == 0)
            {
                return;
            }

            GMCMConfig gmcmConfig = new GMCMConfig(ModManifest, (key, value) =>
            {
                if (key == "save" && value == "file")
                {
                    Helper.WriteConfig <Config>(config);
                    return;
                }

                if (value == "CM:Default")
                {
                    value = "Default";
                }

                if (value.StartsWith("Vanilla:"))
                {
                    value = "Vanilla";
                }

                if (!config.Presets.ContainsKey(key))
                {
                    config.Presets.Add(key, value);
                }
                else
                {
                    config.Presets[key] = value;
                }
            }, options, new GMCMLabel("Music Choices", "Default: Content packs. Random: Packs and vanilla mixed. Any: All mixed."));

            while (!Context.IsGameLaunched)
            {
                Thread.Sleep(1);
            }

            if (gmcmConfig.register(Helper))
            {
                Monitor.Log("Added Custom Music Config to GMCM", LogLevel.Info);
            }
        }