Пример #1
0
        private void ConsumerTask()
        {
            try
            {
                while (true)
                {
                    if (_filesChanged.TryDequeue(out var fileFullPath))
                    {
                        Beatmap beatmap = null;
                        _settings.Add(_names.LoadingRawBeatmaps.Name, true);
                        Interlocked.Increment(ref _numberOfBeatmapsCurrentlyBeingLoaded);
                        _logger.Log("Processing new beatmap", LogLevel.Debug);
                        beatmap = BeatmapHelpers.ReadBeatmap(fileFullPath);

                        _sqliteControler.StoreTempBeatmap(beatmap);
                        _logger.Log("Added new Temporary beatmap {0} - {1} [{2}]", LogLevel.Debug, beatmap.ArtistRoman,
                                    beatmap.TitleRoman, beatmap.DiffName);
                        if (Interlocked.Decrement(ref _numberOfBeatmapsCurrentlyBeingLoaded) == 0)
                        {
                            _settings.Add(_names.LoadingRawBeatmaps.Name, false);
                        }
                    }
                    Thread.Sleep(5);
                }
            }
            catch (ThreadAbortException)
            {
                return;
            }
        }
Пример #2
0
        public void Start(ILogger logger)
        {
            string FilePath = GetConfigFilePath();

            if (!isValidWindowsPath(FilePath))
            {
                logger.Log("WARNING: Path to osu! config location isn't valid. Tried: \"{0}\"", LogLevel.Basic, FilePath);
                return;
            }
            if (!File.Exists(FilePath))
            {
                logger.Log("WARNING: Could not get correct osu! config location. Tried: \"{0}\"", LogLevel.Basic, FilePath);
                return;
            }
            ReadSettings(FilePath);

            _settings.Add(_names.OsuFallback.Name, _isFallback);
            if (_isFallback)
            {
                logger.Log("Detected osu fallback version!", LogLevel.Basic);
            }

            _settings.Add(_names.SongsFolderLocation.Name, _customBeatmapDirectoryLocation);
            if (_customBeatmapDirectoryLocation != _names.SongsFolderLocation.Default <string>())
            {
                logger.Log("Detected custom songs folder location \"{0}\"", LogLevel.Basic, _customBeatmapDirectoryLocation);
            }
        }
 private void checkBox_EnableMemoryFinder_CheckedChanged(object sender, EventArgs e)
 {
     if (init)
     {
         return;
     }
     _settings.Add(_names.EnableMemoryScanner.Name, checkBox_EnableMemoryFinder.Checked, true);
 }
Пример #4
0
 private void textBox_Mods_TextChanged(object sender, EventArgs e)
 {
     if (init)
     {
         return;
     }
     _settings.Add(_names.NoModsDisplayText.Name, textBox_Mods.Text);
 }
Пример #5
0
 private void textBox_login_TextChanged(object sender, EventArgs e)
 {
     if (init)
     {
         return;
     }
     _settings.Add(_names.osuPostLogin.Name, textBox_userId.Text);
 }
Пример #6
0
        public FirstRunMemoryCalibration(IOsuMemoryReader reader, ISettingsHandler settings)
        {
            memoryReader = reader;
            _settings    = settings;

            InitializeComponent();
            this.pictureBox1.Image = GetStreamCompanionLogo();
            _settings.Add(_names.EnableMemoryScanner.Name, false);
            _settings.Add(_names.EnableMemoryPooling.Name, false);
            CurrentMap = _maps[rnd.Next(0, _maps.Count)];
        }
Пример #7
0
        public void GotMemory(int mapId, OsuStatus status, string mapString)
        {
            if (!this.IsHandleCreated)
            {
                return;
            }
            lock (_lockingObject)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    label_memoryStatus.Text = $"{status}, id:{mapId}, valid mapset:{CurrentMap.BelongsToSet(mapId)}";
                });

                if (CurrentMap.BelongsToSet(mapId) && status == OsuStatus.Playing)
                {
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        SetCalibrationText("Searching. It can take up to 20 seconds.");
                        this.button_Next.Enabled = false;
                    });
                    var everythingIsOk = Helpers.ExecWithTimeout(token =>
                    {
                        Thread.Sleep(2000);
                        if (token.IsCancellationRequested)
                        {
                            return(false);
                        }
                        int mods = memoryReader.GetMods();

                        if (mods == ExpectedMods)
                        {
                            return(true);
                        }

                        return(false);
                    }, 20000);

                    _settings.Add(_names.EnableMemoryScanner.Name, everythingIsOk);
                    _settings.Add(_names.EnableMemoryPooling.Name, everythingIsOk);
                    Passed = everythingIsOk;

                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        var resultText = everythingIsOk
                           ? "Found right offset, Continue :)"
                           : "Something went wrong. Try again(start map again) or continue with DISABLED memory";
                        SetCalibrationText(resultText);
                        this.button_Next.Enabled = true;
                    });
                }
            }
        }
 private void nUd_ValueChanged(object sender, EventArgs e)
 {
     if (init)
     {
         return;
     }
     if (sender == nUd_ImageWidth)
     {
         _settings.Add(_names.ImageWidth.Name, Convert.ToInt32(nUd_ImageWidth.Value));
     }
     else if (sender == nUd_ModImageWidth)
     {
         _settings.Add(_names.ModWidth.Name, Convert.ToInt32(nUd_ModImageWidth.Value));
     }
     else if (sender == nUd_ModImageHeight)
     {
         _settings.Add(_names.ModHeight.Name, Convert.ToInt32(nUd_ModImageHeight.Value));
     }
     else if (sender == nUd_Spacing)
     {
         _settings.Add(_names.ModImageSpacing.Name, Convert.ToInt32(nUd_Spacing.Value));
     }
     else if (sender == nUd_Opacity)
     {
         _settings.Add(_names.ModImageOpacity.Name, Convert.ToInt32(nUd_Opacity.Value));
     }
     CreatePreview();
 }
        public virtual void Start(ILogger logger)
        {
            Logger = logger;

            OsuMemoryDataProvider.DataProvider.Initalize();
            _memoryReader = OsuMemoryDataProvider.DataProvider.Instance;

            _settings.SettingUpdated += OnSettingsSettingUpdated;

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

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

            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(Helpers.GetFullSongsLocation(_settings));
            _memoryListener.NewOsuEvent += (s, args) => NewOsuEvent?.Invoke(this, args);
            _memoryListener.SetHighFrequencyDataHandlers(_highFrequencyDataHandlers);
            _memoryListener.SetSettingsHandle(_settings);

            Started = true;
        }
Пример #10
0
 private void SaveOsuDir(string dir)
 {
     if (dir != string.Empty)
     {
         _settings.Add(_names.MainOsuDirectory.Name, dir);
     }
 }
        private void ConsumerTask()
        {
            try
            {
                while (true)
                {
                    if (_filesChanged.TryDequeue(out var fsArgs))
                    {
                        Beatmap beatmap = null;
                        _settings.Add(_names.LoadingRawBeatmaps.Name, true);
                        Interlocked.Increment(ref _numberOfBeatmapsCurrentlyBeingLoaded);
                        _logger.Log("Processing new beatmap", LogLevel.Debug);
                        beatmap = BeatmapHelpers.ReadBeatmap(fsArgs.FullPath);

                        _sqliteControler.StoreTempBeatmap(beatmap);

                        _logger.Log("Added new Temporary beatmap {0} - {1} [{2}]", LogLevel.Debug, beatmap.ArtistRoman,
                                    beatmap.TitleRoman, beatmap.DiffName);
                        if (Interlocked.Decrement(ref _numberOfBeatmapsCurrentlyBeingLoaded) == 0)
                        {
                            _settings.Add(_names.LoadingRawBeatmaps.Name, false);
                        }

                        if (fsArgs.ChangeType == WatcherChangeTypes.Changed && lastMapSearchArgs != null)
                        {
                            var l = lastMapSearchArgs;
                            NewOsuEvent?.Invoke(this, new MapSearchArgs($"OsuMemory-FolderWatcherReplay")
                            {
                                Artist    = beatmap.Artist,
                                MapHash   = beatmap.Md5,
                                Title     = beatmap.Title,
                                Diff      = beatmap.DiffName,
                                EventType = OsuEventType.MapChange,
                                PlayMode  = beatmap.PlayMode,
                                Status    = l.Status,
                                MapId     = -123//bogus id to force string search
                            });
                        }
                    }
                    Thread.Sleep(5);
                }
            }
            catch (ThreadAbortException)
            {
                return;
            }
        }
Пример #12
0
        public void Dispose()
        {
            var tokenFormats = Tokens.AllTokens.ToDictionary(k => k.Key, t => t.Value.Format);

            _settings.Add(SettingNames.Instance.TokenFormats.Name, JsonConvert.SerializeObject(tokenFormats));
            _settings.Save();
            _commandsPreviewSettings?.Dispose();
        }
Пример #13
0
        public static void SaveColor(ISettingsHandler settings, ConfigEntry entry, Color color)
        {
            var colors = BitConverter.GetBytes(color.ToArgb())
                         .Reverse()
                         .ToList();

            settings.Add(entry.Name, string.Join(";", colors.Select(v => v.ToString())), true);
        }
Пример #14
0
        private void Save()
        {
            lock (_lockingObject)
            {
                var serializedPatterns = JsonConvert.SerializeObject(_patterns);

                _settings.Add(_names.ActualPatterns.Name, serializedPatterns);
            }
            _settings.Save();
        }
        public void Start(ILogger logger)
        {
            Started = true;
            _logger = logger;

            if (_settings.Get <bool>(_names.LoadingRawBeatmaps))
            {
                _settings.Add(_names.LoadingRawBeatmaps.Name, false);
            }

            var dir = _settings.Get <string>(_names.SongsFolderLocation);

            if (dir == _names.SongsFolderLocation.Default <string>())
            {
                dir = _settings.Get <string>(_names.MainOsuDirectory);
                dir = Path.Combine(dir, "Songs\\");
            }

            if (dir != "")
            {
                if (Directory.Exists(dir))
                {
                    _watcher          = new FileSystemWatcher(dir, "*.osu");
                    _watcher.Created += Watcher_FileCreated;
                    _watcher.IncludeSubdirectories = true;
                    _watcher.EnableRaisingEvents   = true;
                    _consumerThread = new Thread(ConsumerTask);
                    _consumerThread.Start();
                }
                else
                {
                    MessageBox.Show($"Could not find osu! songs directory at \"{dir}\"" + Environment.NewLine +
                                    "StreamCompanion won't be able to provide data for newly loaded songs!"
                                    , "StreamCompanion - New songs watcher error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //TODO: ask user to provide songs directory path?
                    _logger.Log($"Could not find osu! songs directory, tried: \"{dir}\" & setting value was: \"{_settings.Get<string>(_names.SongsFolderLocation)}\"", LogLevel.Error);
                }
            }
        }
        public OsuMemoryEventSourceBase(ILogger logger, ISettingsHandler settings, ISqliteControler sqliteControler, IModParser modParser, List <IHighFrequencyDataHandler> highFrequencyDataHandlers)
        {
            _settings                  = settings;
            _sqLiteController          = sqliteControler;
            _modParser                 = modParser;
            _highFrequencyDataHandlers = highFrequencyDataHandlers;
            Logger        = logger;
            TokenSetter   = Tokens.CreateTokenSetter(Name);
            _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();
            _memoryListener.NewOsuEvent += async(s, args) =>
            {
                while (NewOsuEvent == null)
                {
                    await Task.Delay(5);
                }

                NewOsuEvent.Invoke(this, args);
            };
            _memoryListener.SetHighFrequencyDataHandlers(_highFrequencyDataHandlers);
            _memoryListener.SetSettingsHandle(_settings);

            Started = true;
        }
Пример #17
0
        private void CheckBox_enableMouseHook_CheckedChanged(object sender, EventArgs e)
        {
            var enabled = _frmSettings.checkBox_enableMouseHook.Checked;

            _settings.Add(_names.EnableMouseHook.Name, enabled);

            if (enabled)
            {
                HookMouse();
            }
            else
            {
                UnHookMouse();
            }
        }
Пример #18
0
        private bool AddKey(int key, string filename)
        {
            var currentKeys      = _settings.Get("keyList");
            var currentKeysSaves = _settings.Get("keyNames");
            var currentKeyCounts = _settings.Geti("keyCounts");

            if (currentKeysSaves.Any(f => f.ToLower().Equals(filename.ToLower())))
            {
                return(false);
            }
            currentKeys.Add(key.ToString());
            currentKeysSaves.Add(filename);
            currentKeyCounts.Add(0);

            _settings.Add("keyList", currentKeys, true);
            _settings.Add("keyNames", currentKeysSaves, true);
            _settings.Add("keyCounts", currentKeyCounts, true);

            OnKeysChanged();
            return(true);
        }
        public OsuSongsFolderWatcher(ILogger logger, ISettingsHandler settings, ISqliteControler sqliteControler)
        {
            _settings        = settings;
            _sqliteControler = sqliteControler;
            _logger          = logger;

            if (_settings.Get <bool>(_names.LoadingRawBeatmaps))
            {
                _settings.Add(_names.LoadingRawBeatmaps.Name, false);
            }

            var dir = _settings.Get <string>(_names.SongsFolderLocation);

            if (dir == _names.SongsFolderLocation.Default <string>())
            {
                dir = _settings.Get <string>(_names.MainOsuDirectory);
                dir = Path.Combine(dir, "Songs\\");
            }

            if (Directory.Exists(dir))
            {
                _watcher          = new FileSystemWatcher(dir, "*.osu");
                _watcher.Created += Watcher_FileCreated;
                _watcher.Changed += Watcher_FileChanged;
                _watcher.IncludeSubdirectories = true;
                _watcher.EnableRaisingEvents   = true;
                _consumerThread = new Thread(ConsumerTask);
                _consumerThread.Start();
            }
            else
            {
                MessageBox.Show($"Could not find osu! songs directory at \"{dir}\"" + Environment.NewLine +
                                "This is most likely caused by moved or incorrectly detected osu! songs directory" + Environment.NewLine +
                                "Set osu! path manually in settings for StreamCompanion to be able to provide data for newly loaded songs"
                                , "StreamCompanion - New songs watcher error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #20
0
 private void CheckBoxIngameOverlayOnCheckedChanged(object sender, EventArgs eventArgs)
 {
     _settings.Add(PluginSettings.EnableIngameOverlay.Name, checkBox_ingameOverlay.Checked);
 }
Пример #21
0
 private void CheckBox_disableDiskSaving_CheckedChanged(object sender, EventArgs e)
 {
     _settings.Add(_names.DisableDiskPatternWrite.Name, checkBox_disableDiskSaving.Checked);
 }
 private void checkBox_EnableTcpOutput_CheckedChanged(object sender, EventArgs e)
 {
     _settings.Add(_names.tcpSocketEnabled.Name, checkBox_EnableTcpOutput.Checked, true);
 }
Пример #23
0
 private void CheckBoxEnableWebSocketOutputOnCheckedChanged(object sender, EventArgs e)
 {
     _settings.Add(WebSocketDataGetter.Enabled.Name, checkBox_EnableWebSocketOutput.Checked);
 }
Пример #24
0
 private void CheckBoxEnableWindowRezisingOnCheckedChanged(object sender, EventArgs e)
 {
     _settings.Add(ConfigEntrys.EnableResizing.Name, checkBox_enableWindowRezising.Checked, true);
 }