public MemoryDataProcessor(ISettings settings, IContextAwareLogger logger, IModParser modParser,
                                   bool isMainProcessor,
                                   string tokensPath)
        {
            _settings  = settings;
            _logger    = logger;
            _modParser = modParser;
            foreach (var v in (InterpolatedValueName[])Enum.GetValues(typeof(InterpolatedValueName)))
            {
                InterpolatedValues.Add(v, new InterpolatedValue(0.15));
            }

            ToggleSmoothing(true);
            IsMainProcessor = isMainProcessor;
            TokensPath      = tokensPath;

            _strainsToken = _tokenSetter("mapStrains", new Dictionary <int, double>(), TokenType.Normal, ",", new Dictionary <int, double>());

            _skinToken                = _tokenSetter("skin", string.Empty, TokenType.Normal, null, string.Empty);
            _skinPathToken            = _tokenSetter("skinPath", string.Empty, TokenType.Normal, null, string.Empty);
            _firstHitObjectTimeToken  = _tokenSetter("firstHitObjectTime", 0d, TokenType.Normal, null, 0d);
            _MapBreaksToken           = _tokenSetter("mapBreaks", new List <BreakPeriod>(), TokenType.Normal, null, new List <BreakPeriod>());
            _MapTimingPointsToken     = _tokenSetter("mapTimingPoints", new List <TimingPoint>(), TokenType.Normal, null, new List <TimingPoint>());
            _beatmapRankedStatusToken = _tokenSetter("rankedStatus", (short)0, TokenType.Normal, null, (short)0);
            _statusToken              = _tokenSetter("status", OsuStatus.Null, TokenType.Normal, "", OsuStatus.Null);
            _rawStatusToken           = _tokenSetter("rawStatus", OsuMemoryStatus.NotRunning, TokenType.Normal, "", OsuMemoryStatus.NotRunning);
            InitLiveTokens();
            Task.Run(TokenThreadWork, cancellationTokenSource.Token).HandleExceptions();
        }
Exemplo n.º 2
0
        public BrowserOverlay(IContextAwareLogger logger, ISettings settings, ISaver saver, List <Lazy <IHighFrequencyDataConsumer> > dataConsumers, Delegates.Restart restarter)
        {
            _logger        = logger;
            _settings      = settings;
            _saver         = saver;
            _dataConsumers = dataConsumers;
            _restarter     = restarter;
            _browserOverlayConfiguration = _settings.GetConfiguration <Configuration>(BrowserOverlayConfigurationConfigEntry);
            _browserOverlayConfiguration.OverlayTabs ??= new List <OverlayTab> {
                new OverlayTab()
            };

            if (_browserOverlayConfiguration.Enabled && TextOverlayIsEnabled(_settings))
            {
                _browserOverlayConfiguration.Enabled = false;
                var infoText = $"TextIngameOverlay and BrowserIngameOverlay can't be ran at the same time.{Environment.NewLine} BrowserIngameOverlay was disabled in order to prevent osu! crash.";
                _logger.Log(infoText, LogLevel.Warning);
                MessageBox.Show(infoText, "BrowserIngameOverlay Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (_browserOverlayConfiguration.Enabled)
            {
                Initialize().HandleExceptions();
            }

            SendConfiguration();
        }
Exemplo n.º 3
0
 public BackgroundImageProviderPlugin(ISaver saver, ISettings settings, IContextAwareLogger logger)
 {
     _saver        = saver;
     _settings     = settings;
     _logger       = logger;
     _saveLocation = Path.Combine(_saver.SaveDirectory, "BG.png");
     _tokenSetter  = Tokens.CreateTokenSetter(Name);
     _imageToken   = _tokenSetter("backgroundImage", null);
 }
Exemplo n.º 4
0
        public MemoryListener(ISettings settings, ISaver saver, IContextAwareLogger logger)
        {
            _settings = settings;
            _settings.SettingUpdated += SettingUpdated;

            _memoryDataProcessor = new MemoryDataProcessor(settings, logger);
            _patternsDispatcher  = new PatternsDispatcher(settings, saver);
            _memoryDataProcessor.TokensUpdated += (_, status) => _patternsDispatcher.TokensUpdated(status);
            _memoryDataProcessor.ToggleSmoothing(_settings.Get <bool>(Helpers.EnablePpSmoothing));
        }
Exemplo n.º 5
0
        public OsuEventHandler(MainMapDataGetter mainMapDataGetter, List <IOsuEventSource> osuEventSources, ISettings settings, IContextAwareLogger logger)
        {
            _settings          = settings;
            _mainMapDataGetter = mainMapDataGetter;
            foreach (var source in osuEventSources)
            {
                source.NewOsuEvent += NewOsuEvent;
            }

            _logger    = logger;
            WorkerTask = Task.Run(OsuEventWorkerLoop);
        }
Exemplo n.º 6
0
        public MapStringFormatter(MainMapDataGetter mainMapDataGetter, List <IOsuEventSource> osuEventSources, ISettings settings, IContextAwareLogger logger)
        {
            _settings          = settings;
            _mainMapDataGetter = mainMapDataGetter;
            foreach (var source in osuEventSources)
            {
                source.NewOsuEvent += NewOsuEvent;
            }
            ConsumerThread = new Thread(ConsumerTask);

            _logger = logger;
            ConsumerThread.Start();
        }
        public BackgroundImageProviderPlugin(ISaver saver, ISettings settings, IContextAwareLogger logger)
        {
            _saver        = saver;
            _settings     = settings;
            _logger       = logger;
            _saveLocation = Path.Combine(_saver.SaveDirectory, "BG.png");
            _tokenSetter  = Tokens.CreateTokenSetter(Name);
            var initialValue = settings.Get <bool>(EnableImageToken)
                ? null
                : $"Disabled, enable it in configuration manually under {EnableImageToken.Name}";

            _imageToken = _tokenSetter("backgroundImage", initialValue);
        }
        public OsuMemoryEventSourceBase(IContextAwareLogger logger, ISettings settings,
                                        IDatabaseController databaseControler, IModParser modParser,
                                        List <IHighFrequencyDataConsumer> highFrequencyDataConsumers, ISaver saver)
        {
            _settings                   = settings;
            _databaseController         = databaseControler;
            _modParser                  = modParser;
            _highFrequencyDataConsumers = highFrequencyDataConsumers;
            Logger          = logger;
            LiveTokenSetter = Tokens.CreateTokenSetter(Name);
            TokenSetter     = Tokens.CreateTokenSetter($"{Name}-Regular");
            _memoryReader   = OsuMemoryReader.Instance;

            _settings.SettingUpdated += OnSettingsSettingUpdated;

            bool isFallback             = _settings.Get <bool>(_names.OsuFallback);
            bool memoryScannerIsEnabled = _settings.Get <bool>(_names.EnableMemoryScanner);

            MemoryPoolingIsEnabled = _settings.Get <bool>(_names.EnableMemoryPooling);

            _poolingMsDelay = _settings.Get <int>(_names.MemoryPoolingFrequency);
            if (!memoryScannerIsEnabled)
            {
                return;
            }
            if (isFallback)
            {
                _settings.Add(_names.EnableMemoryScanner.Name, false);
                return;
            }

            lock (_lockingObject)
                _timer = new Timer(TimerCallback, null, 250, Int32.MaxValue);


            _memoryListener              = new MemoryListener(settings, saver, logger);
            _memoryListener.NewOsuEvent += async(s, args) =>
            {
                while (NewOsuEvent == null)
                {
                    await Task.Delay(5);
                }

                NewOsuEvent.Invoke(this, args);
            };
            _memoryListener.SetHighFrequencyDataHandlers(_highFrequencyDataConsumers);

            Started = true;
        }
Exemplo n.º 9
0
        public MemoryDataProcessor(ISettings settings, IContextAwareLogger logger, bool enablePpSmoothing = true)
        {
            _settings = settings;
            _logger   = logger;
            foreach (var v in (InterpolatedValueName[])Enum.GetValues(typeof(InterpolatedValueName)))
            {
                InterpolatedValues.Add(v, new InterpolatedValue(0.15));
            }

            ToggleSmoothing(enablePpSmoothing);

            InitLiveTokens();

            Task.Run(InterpolatedValueThreadWork, cancellationTokenSource.Token);
            Task.Run(TokenThreadWork, cancellationTokenSource.Token);
        }
Exemplo n.º 10
0
        public MemoryDataProcessor(ISettings settings, IContextAwareLogger logger, bool enablePpSmoothing = true)
        {
            _settings = settings;
            _logger   = logger;
            foreach (var v in (InterpolatedValueName[])Enum.GetValues(typeof(InterpolatedValueName)))
            {
                InterpolatedValues.Add(v, new InterpolatedValue(0.15));
            }

            ToggleSmoothing(enablePpSmoothing);

            _strainsToken = _tokenSetter("mapStrains", new Dictionary <int, double>(), TokenType.Normal, ",", new Dictionary <int, double>());

            _skinToken     = _tokenSetter("skin", string.Empty, TokenType.Normal, null, string.Empty);
            _skinPathToken = _tokenSetter("skinPath", string.Empty, TokenType.Normal, null, string.Empty);

            InitLiveTokens();

            Task.Run(TokenThreadWork, cancellationTokenSource.Token);
        }
Exemplo n.º 11
0
        public MemoryListener(ISettings settings, ISaver saver, IContextAwareLogger logger, int clientCount = 1)
        {
            _settings = settings;
            _settings.SettingUpdated += SettingUpdated;
            var tournamentMode = clientCount > 1;
            var mainClientId   = tournamentMode
                ? _settings.Get <int>(OsuMemoryEventSourceBase.DataClientId)
                : 0;

            _memoryDataProcessors = Enumerable.Range(0, clientCount)
                                    .Select(x => new MemoryDataProcessor(settings, logger, x == mainClientId, tournamentMode ? $"client_{x}_" : string.Empty)).ToList();
            _patternsDispatcher = new PatternsDispatcher(settings, saver);
            var mainProcessor = _memoryDataProcessors.First(p => p.IsMainProcessor);

            mainProcessor.TokensUpdated += (sender, status) => _patternsDispatcher.TokensUpdated(status);
            foreach (var memoryDataProcessor in _memoryDataProcessors)
            {
                memoryDataProcessor.ToggleSmoothing(_settings.Get <bool>(Helpers.EnablePpSmoothing));
            }
        }
Exemplo n.º 12
0
 public OsuMemoryEventSource(IContextAwareLogger logger, ISettings settings, IDatabaseController databaseController,
                             IModParser modParser, List <Lazy <IHighFrequencyDataConsumer> > highFrequencyDataConsumers,
                             ISaver saver, Delegates.Exit exiter) : base(logger, settings, databaseController, modParser, highFrequencyDataConsumers, saver, exiter)
 {
 }
Exemplo n.º 13
0
        public OsuMemoryEventSourceBase(IContextAwareLogger logger, ISettings settings,
                                        IDatabaseController databaseControler, IModParser modParser,
                                        List <Lazy <IHighFrequencyDataConsumer> > highFrequencyDataConsumers, ISaver saver, Delegates.Exit exiter)
        {
            _settings                   = settings;
            _databaseController         = databaseControler;
            _modParser                  = modParser;
            _highFrequencyDataConsumers = highFrequencyDataConsumers;
            Logger          = logger;
            LiveTokenSetter = Tokens.CreateTokenSetter(Name);
            TokenSetter     = Tokens.CreateTokenSetter($"{Name}-Regular");
            var clientCount = _settings.Get <bool>(TourneyMode)
                ? _settings.Get <int>(ClientCount)
                : 1;

            if (_settings.Get <bool>(TourneyMode))
            {
                string exitReason = null;
                if (clientCount < 2)
                {
                    exitReason = $"{ClientCount.Name} setting value is invalid. Set value equal or bigger than 2";
                }

                if (_settings.Get <int>(DataClientId) > clientCount - 1)
                {
                    exitReason = $"{DataClientId.Name} can't be bigger than {ClientCount.Name}. Client ids are 0-indexed";
                }

                if (!string.IsNullOrWhiteSpace(exitReason))
                {
                    Logger.Log(exitReason, LogLevel.Warning);
                    MessageBox.Show(exitReason, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    exiter(exitReason);
                    return;
                }

                _clientMemoryReaders.AddRange(Enumerable.Range(0, clientCount)
                                              .Select(i =>
                {
                    var instance = StructuredOsuMemoryReader.Instance.GetInstanceForWindowTitleHint(
                        $" Tournament Client {i}");
                    instance.OsuMemoryAddresses.GeneralData.KeyOverlay = null;
                    return(instance);
                }));

                //TODO: provide tournament-manager specific data via tokens
                var _tournamentManagerMemoryReader = OsuMemoryReader.Instance.GetInstanceForWindowTitleHint("Tournament Manager");

                Logger.Log($"{_clientMemoryReaders.Count} client readers prepared", LogLevel.Information);
            }
            else
            {
                _clientMemoryReaders.Add(StructuredOsuMemoryReader.Instance);
                StructuredOsuMemoryReader.Instance.OsuMemoryAddresses.GeneralData.KeyOverlay = null;
                StructuredOsuMemoryReader.Instance.InvalidRead += OnInvalidMemoryRead;
            }

            _settings.SettingUpdated += OnSettingsSettingUpdated;

            bool isFallback             = _settings.Get <bool>(_names.OsuFallback);
            bool memoryScannerIsEnabled = _settings.Get <bool>(_names.EnableMemoryScanner);

            MemoryPoolingIsEnabled = _settings.Get <bool>(_names.EnableMemoryPooling);

            _poolingMsDelay = _settings.Get <int>(_names.MemoryPoolingFrequency);
            if (!memoryScannerIsEnabled)
            {
                return;
            }
            if (isFallback)
            {
                _settings.Add(_names.EnableMemoryScanner.Name, false);
                return;
            }

            memoryListener              = new MemoryListener(settings, saver, logger, clientCount);
            memoryListener.NewOsuEvent += async(s, args) =>
            {
                while (NewOsuEvent == null)
                {
                    await Task.Delay(5);
                }

                NewOsuEvent.Invoke(this, args);
            };
            memoryListener.SetHighFrequencyDataHandlers(_highFrequencyDataConsumers);

            MemoryWorkerTask = Task.Run(MemoryWorker, cts.Token).HandleExceptions();

            Started = true;
        }
 public LiveVisualizerPluginBase(IContextAwareLogger logger, ISettings settings)
 {
     Logger   = logger;
     Settings = settings;
 }
 public OsuMemoryEventSource(IContextAwareLogger logger, ISettings settings, IDatabaseController databaseController, IModParser modParser, List <IHighFrequencyDataConsumer> highFrequencyDataConsumers) : base(logger, settings, databaseController, modParser, highFrequencyDataConsumers)
 {
 }