コード例 #1
0
        private static void ReloadConfig()
        {
            if (trackConfig == null)
            {
                trackConfig = BTConfigUtils.LoadConfigFile(configPath, trackConfig);

                if (trackConfig != null)
                {
                    // on first load every track is "new"
                    IEnumerable <KeyValuePair <string, TrackConfig> >
                    newTracks = trackConfig.trackList.Where(entry => !string.IsNullOrEmpty(entry.Value.filePath));
                    foreach ((string key, TrackConfig value) in newTracks)
                    {
                        AudioHandlerPatcher.OnTrackAddition(key, value);
                    }
                }
            }
            else
            {
                // otherwise memorize current tracks and call events selectively
                Dictionary <string, string> previousData = trackConfig.trackList
                                                           .ToDictionary(entry => entry.Key, entry => entry.Value.filePath);
                trackConfig = BTConfigUtils.LoadConfigFile(configPath, trackConfig);

                if (trackConfig != null)
                {
                    IEnumerable <KeyValuePair <string, TrackConfig> > newTracks = trackConfig.trackList
                                                                                  .Where(entry => !previousData.ContainsKey(entry.Key) && !string.IsNullOrEmpty(entry.Value.filePath));
                    foreach ((string key, TrackConfig value) in newTracks)
                    {
                        AudioHandlerPatcher.OnTrackAddition(key, value);
                    }

                    IEnumerable <KeyValuePair <string, TrackConfig> > tracksWithChangedFilePath = trackConfig.trackList
                                                                                                  .Where(entry => previousData.ContainsKey(entry.Key) &&
                                                                                                         !string.IsNullOrEmpty(entry.Value.filePath) &&
                                                                                                         !previousData[entry.Key].Equals(entry.Value.filePath));
                    foreach ((string key, TrackConfig value) in tracksWithChangedFilePath)
                    {
                        AudioHandlerPatcher.OnTrackChanged(key, value);
                    }
                }
            }

            nextConfigCheckIn = 30f;
        }
コード例 #2
0
        private static void FirstLoadConfig()
        {
            foreach (string modDirName in FindCustomMusicConfigs())
            {
                TracksConfig config = BTConfigUtils.LoadConfigFile(configBasePath + modDirName + ".cs", (TracksConfig)null);
                if (config == null)
                {
                    continue;
                }

                customTrackConfigs[modDirName] = config;
                foreach ((string trackName, TrackConfig trackConfig) in config.trackList.Where(entry => !string.IsNullOrEmpty(entry.Value.filePath)))
                {
                    HandleTrackAddition(trackName, modDirName, trackConfig);
                }
            }

            nextConfigCheckIn = 30f;
        }
コード例 #3
0
        private static void ReloadConfig()
        {
            // store current config to identify changes
            // as mapping of modName->trackName->filePath
            Dictionary <string, Dictionary <string, string> > previousConfig = customTrackConfigs
                                                                               .ToDictionary(
                modConfig => modConfig.Key,
                modConfig => modConfig.Value.trackList
                .ToDictionary(track => track.Key, track => track.Value.filePath)
                );

            foreach (string modDirName in FindCustomMusicConfigs())
            {
                Dictionary <string, string> previousModData = previousConfig.ContainsKey(modDirName) ? previousConfig[modDirName] : null;
                TracksConfig config = BTConfigUtils.LoadConfigFile(configBasePath + modDirName + ".cs", (TracksConfig)null);
                if (config == null)
                {
                    continue;
                }

                customTrackConfigs[modDirName] = config;
                foreach ((string trackName, TrackConfig trackConfig) in config.trackList.Where(entry => !string.IsNullOrEmpty(entry.Value.filePath)))
                {
                    if (previousModData == null || !previousModData.ContainsKey(trackName))
                    {
                        // new track
                        HandleTrackAddition(trackName, modDirName, trackConfig);
                    }
                    else if (!previousModData[trackName].Equals(trackConfig.filePath))
                    {
                        // track changed filePath
                        HandleTrackChanged(trackName, modDirName, trackConfig);
                    }
                }
            }

            nextConfigCheckIn = 30f;
        }