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;
        }
示例#2
0
        public void CreateTokens(MapSearchResult map)
        {
            Dictionary <string, object> dict;
            var OsuFileLocationToken = _tokenSetter("OsuFileLocation", null);

            if (map.FoundBeatmaps)
            {
                dict = map.BeatmapsFound[0].GetTokens();

                var osuLocation         = _settings.Get <string>(_names.MainOsuDirectory);
                var customSongsLocation = _settings.Get <string>(_names.SongsFolderLocation);
                if (string.IsNullOrWhiteSpace(osuLocation))
                {
                    OsuFileLocationToken.Value = null;
                }
                else
                {
                    string baseDirectory = customSongsLocation == _names.SongsFolderLocation.Default <string>()
                        ? Path.Combine(osuLocation, "Songs")
                        : customSongsLocation;
                    OsuFileLocationToken.Value = Path.Combine(baseDirectory, map.BeatmapsFound[0].Dir,
                                                              map.BeatmapsFound[0].OsuFileName);
                }
            }
            else
            {
                dict = ((Beatmap)null).GetTokens(true);
                OsuFileLocationToken.Value = null;
            }

            foreach (var token in dict)
            {
                _tokenSetter(token.Key, token.Value);
            }
        }
示例#3
0
        public MemoryDataFinderSettings(ISettingsHandler settings)
        {
            InitializeComponent();

            _settings = settings;

            checkBox_enableSmoothPp.Checked = _settings.Get <bool>(Helpers.EnablePpSmoothing);

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

            if (isFallback)
            {
                checkBox_EnableMemoryFinder.Enabled = false;
            }
            else
            {
                checkBox_EnableMemoryFinder.Checked = _settings.Get <bool>(_names.EnableMemoryScanner);

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

                checkBox_clearTokensAfterPlay.Checked = _settings.Get <bool>(Helpers.ClearLiveTokensAfterResultScreenExit);
            }

            init = false;
        }
示例#4
0
        private bool ShouldRun()
        {
            bool shouldForceFirstRun;
            var  lastVersionStr = _settings.Get <string>(SettingNames.Instance.LastRunVersion);

            if (lastVersionStr == SettingNames.Instance.LastRunVersion.Default <string>())
            {
                shouldForceFirstRun = true;
            }
            else
            {
                try
                {
                    var lastVersion      = Helpers.Helpers.GetDateFromVersionString(lastVersionStr);
                    var versionToResetOn = Helpers.Helpers.GetDateFromVersionString("v180209.13");
                    shouldForceFirstRun = lastVersion < versionToResetOn;
                }
                catch (Exception e)
                {
                    if (e is FormatException || e is ArgumentNullException)
                    {
                        shouldForceFirstRun = true;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(_firstRunControlProviders.Count != 0 && (shouldForceFirstRun || _settings.Get <bool>(SettingNames.Instance.FirstRun)));
        }
        public Tokens GetMapReplacements(MapSearchResult map)
        {
            Tokens dict;

            if (map.FoundBeatmaps)
            {
                dict = map.BeatmapsFound[0].GetTokens();

                var osuLocation         = _settings.Get <string>(_names.MainOsuDirectory);
                var customSongsLocation = _settings.Get <string>(_names.SongsFolderLocation);
                if (string.IsNullOrWhiteSpace(osuLocation))
                {
                    dict.Add("OsuFileLocation", new Token(null));
                }
                else
                {
                    string baseDirectory = customSongsLocation == _names.SongsFolderLocation.Default <string>()
                        ? Path.Combine(osuLocation, "Songs")
                        : customSongsLocation;
                    dict.Add("OsuFileLocation", new Token(Path.Combine(baseDirectory, map.BeatmapsFound[0].Dir,
                                                                       map.BeatmapsFound[0].OsuFileName)));
                }
            }
            else
            {
                dict = ((Beatmap)null).GetTokens(true);
                dict.Add("OsuFileLocation", new Token(null));
            }

            return(dict);
        }
示例#6
0
        public OsuPost(ILogger logger, ISettingsHandler settings)
        {
            _settings = settings;

            api             = new OsuPostApi(logger);
            api.EndpointUrl = _settings.Get <string>(_names.osuPostEndpoint);
            SwitchApiStatus(_settings.Get <bool>(_names.osuPostEnabled));
            _settings.SettingUpdated += SettingUpdated;
        }
 public osuPostSettings(ISettingsHandler settings)
 {
     _settings = settings;
     InitializeComponent();
     textBox_userId.Text       = _settings.Get <string>(_names.osuPostLogin);
     textBox_userPassword.Text = _settings.Get <string>(_names.osuPostPassword);
     textBox_endpointUrl.Text  = _settings.Get <string>(_names.osuPostEndpoint);
     panel_settings.Enabled    = _settings.Get <bool>(_names.osuPostEnabled);
     init = false;
 }
示例#8
0
 private void SettingUpdated(object sender, SettingUpdated settingUpdated)
 {
     if (settingUpdated.Name == _names.osuPostEnabled.Name)
     {
         SwitchApiStatus(_settings.Get <bool>(_names.osuPostEnabled));
     }
     else if (settingUpdated.Name == _names.osuPostEndpoint.Name)
     {
         api.EndpointUrl = _settings.Get <string>(_names.osuPostEndpoint);
     }
 }
示例#9
0
        public static string GetFullSongsLocation(ISettingsHandler settings)
        {
            var dir = settings.Get <string>(_names.SongsFolderLocation);

            if (dir == _names.SongsFolderLocation.Default <string>())
            {
                dir = settings.Get <string>(_names.MainOsuDirectory);
                dir = Path.Combine(dir, "Songs\\");
            }
            return(dir);
        }
示例#10
0
 public ModParserSettings(ISettingsHandler settings)
 {
     _settings = settings;
     _settings.SettingUpdated += SettingUpdated;
     this.Enabled              = _settings.Get <bool>(_names.EnableMemoryScanner);
     InitializeComponent();
     textBox_Mods.Text             = _settings.Get <string>(_names.NoModsDisplayText);
     radioButton_longMods.Checked  = _settings.Get <bool>(_names.UseLongMods);
     radioButton_shortMods.Checked = !radioButton_longMods.Checked;
     init = false;
 }
示例#11
0
        public void Start(ILogger logger)
        {
            Started = true;
            _logger = logger;

            if (_settings.Get <bool>(PluginSettings.EnableIngameOverlay))
            {
                CopyFreeType();
                _workerThread = new Thread(WatchForProcessStart);
                _workerThread.Start();
            }
        }
示例#12
0
        private void UpdateNoModText()
        {
            string noneText = _settings?.Get <string>(_names.NoModsDisplayText) ?? "None";

            if (LongNoModText != noneText)
            {
                LongNoModText = noneText;
            }
            if (ShortNoModText != noneText)
            {
                ShortNoModText = noneText;
            }
        }
示例#13
0
 public void SetSettingsHandle(ISettingsHandler settings)
 {
     _settings = settings;
     _settings.SettingUpdated += SettingUpdated;
     _memoryDataProcessor.ToggleSmoothing(_settings.Get <bool>(Helpers.EnablePpSmoothing));
     _memoryDataProcessor.SetSettingsHandle(_settings);
 }
        public WebSocketDataGetter(ISettingsHandler settings)
        {
            _settings = settings;
            if (!_settings.Get <bool>(Enabled))
            {
                return;
            }

            webSocketServer = new WebSocketServer(IPAddress.Loopback, _settings.Get <int>(WebSocketPort));
            webSocketServer.ReuseAddress = true;

            webSocketServer.AddWebSocketService("/StreamCompanion/LiveData/Stream", () => new StreamDataProvider(_liveDataContainer));
            webSocketServer.AddWebSocketService("/StreamCompanion/MapData/Stream", () => new StreamDataProvider(_mapDataContainer));

            webSocketServer.Start();
        }
示例#15
0
 private void Load()
 {
     lock (_lockingObject)
     {
         var legacyConfig = new LegacyParserConfigConverter();
         var oldPatterns  = legacyConfig.Convert(_settings);
         if (oldPatterns.Count > 0)
         {
             foreach (var p in oldPatterns)
             {
                 _patterns.Add(p);
             }
             MessageBox.Show("There was a big change in how patterns are stored and they needed to be converted." + Environment.NewLine +
                             "Go to your pattern settings and make sure that everything is still correct(Especialy save events)", "osu!StreamCompanion - Update message", MessageBoxButtons.OK);
         }
         else
         {
             string rawPatterns          = _settings.Get <string>(_names.ActualPatterns);
             var    deserializedPatterns = JsonConvert.DeserializeObject <List <OutputPattern> >(rawPatterns);
             if (deserializedPatterns != null)
             {
                 foreach (var p in deserializedPatterns)
                 {
                     _patterns.Add(p);
                 }
             }
         }
     }
 }
示例#16
0
        public IngameOverlay(ILogger logger, ISettingsHandler settings, Delegates.Exit exiter)
        {
            _logger   = logger;
            _settings = settings;

            try
            {
                SetNewMap(new MapSearchResult(new MapSearchArgs("dummy")));
            }
            catch (Exception)
            {
                MessageBox.Show(
                    $"IngameOverlay plugin version is not valid for this version of StreamCompanion. {Environment.NewLine} Either update or remove it from plugins folder",
                    "osu!StreamCompanion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                exiter("plugin version is invalid for current StreamCompanion version.");
            }

            if (_settings.Get <bool>(PluginSettings.EnableIngameOverlay))
            {
                CopyFreeType();

                Task.Run(() => WatchForProcessStart(cancellationToken.Token), cancellationToken.Token);
            }
        }
 private void SettingUpdated(object sender, SettingUpdated e)
 {
     if (e.Name == Helpers.ClearLiveTokensAfterResultScreenExit.Name)
     {
         _clearLiveTokensAfterResultScreenExit = _settings.Get <bool>(Helpers.ClearLiveTokensAfterResultScreenExit);
     }
 }
示例#18
0
        public TextSaver(ISettingsHandler settings)
        {
            var saveDirectory = settings.Get <string>(SaveDirectoryConfigEntry);

            if (saveDirectory != SaveDirectoryConfigEntry.Default <string>() &&
                !string.IsNullOrWhiteSpace(saveDirectory))
            {
                _saveDirectory = saveDirectory;
                var driveList         = DriveInfo.GetDrives().ToList();
                var saveDirectoryInfo = new DirectoryInfo(_saveDirectory);
                foreach (var drive in driveList)
                {
                    if ((drive.DriveType == DriveType.Network || drive.DriveType == DriveType.Removable) &&
                        saveDirectoryInfo.Root.FullName == drive.RootDirectory.FullName)
                    {
                        MessageBox.Show("Please note that saving patterns on network shares might cause unexpected behaviours(like SC updating with 30s+ delay) - especially if connection is slow, and is not really supported.",
                                        "osu!StreamCompanion - network or removable media information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }

            try
            {
                if (!Directory.Exists(SaveDirectory))
                {
                    Directory.CreateDirectory(SaveDirectory);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                throw new NonLoggableException(ex, "Could not create folder due to insuffisient premissions" +
                                               Environment.NewLine + "Please move this exectuable into a non-system folder");
            }
        }
        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;
        }
示例#20
0
        public WebSocketDataGetter(ISettingsHandler settings)
        {
            _settings = settings;
            if (!_settings.Get <bool>(Enabled))
            {
                return;
            }

            webSocketServer = new WebSocketServer(IPAddress.Parse(_settings.Get <string>(WebSocketAddress)), _settings.Get <int>(WebSocketPort));
            webSocketServer.ReuseAddress = true;
            webSocketServer.WaitTime     = TimeSpan.FromSeconds(30);

            webSocketServer.AddWebSocketService("/StreamCompanion/LiveData/Stream", () => new StreamDataProvider(_liveDataContainer));
            webSocketServer.AddWebSocketService("/StreamCompanion/MapData/Stream", () => new StreamDataProvider(_mapDataContainer));

            webSocketServer.Start();
        }
示例#21
0
 private void SettingUpdated(object sender, SettingUpdated settingUpdated)
 {
     if (settingUpdated.Name == Helpers.EnablePpSmoothing.Name)
     {
         var enableSmoothing = _settings.Get <bool>(Helpers.EnablePpSmoothing);
         _memoryDataProcessor.ToggleSmoothing(enableSmoothing);
     }
 }
示例#22
0
        public WebSocketSettings(ISettingsHandler settings)
        {
            _settings = settings;
            InitializeComponent();

            checkBox_EnableWebSocketOutput.Checked         = settings.Get <bool>(WebSocketDataGetter.Enabled);
            checkBox_EnableWebSocketOutput.CheckedChanged += CheckBoxEnableWebSocketOutputOnCheckedChanged;
        }
示例#23
0
        public IngameOverlaySettings(ISettingsHandler settings)
        {
            _settings = settings;
            InitializeComponent();

            checkBox_ingameOverlay.Checked         = _settings.Get <bool>(PluginSettings.EnableIngameOverlay);
            checkBox_ingameOverlay.CheckedChanged += CheckBoxIngameOverlayOnCheckedChanged;
        }
示例#24
0
 public void Start(ILogger logger)
 {
     Started = true;
     if (!_settings.Get <bool>(_names.StartHidden))
     {
         ShowWindow();
     }
 }
示例#25
0
        public LiveVisualizerSettings(ISettingsHandler settings)
        {
            _settings = settings;

            InitializeComponent();


            using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
            {
                var fontNames = fontsCollection.Families.Select(f => f.Name).ToList();
                comboBox_font.DataSource = fontNames;

                var desiredFont = _settings.Get <string>(ConfigEntrys.Font);

                var font = fontNames.Contains(desiredFont)
                    ? desiredFont
                    : "Arial";

                comboBox_font.SelectedItem = font;
            }


            checkBox_enable.Checked = _settings.Get <bool>(ConfigEntrys.Enable);
            panel1.Enabled          = checkBox_enable.Checked;

            checkBox_autosizeChart.Checked = _settings.Get <bool>(ConfigEntrys.AutoSizeAxisY);
            panel_manualChart.Enabled      = !checkBox_autosizeChart.Checked;

            color_chartPrimary.Color     = ColorHelpers.GetColor(_settings, ConfigEntrys.ChartColor);
            color_chartProgress.Color    = ColorHelpers.GetColor(_settings, ConfigEntrys.ChartProgressColor);
            color_horizontalLegend.Color = ColorHelpers.GetColor(_settings, ConfigEntrys.AxisYSeparatorColor);

            textBox_chartCutoffs.Text = _settings.Get <string>(ConfigEntrys.ManualAxisCutoffs);

            checkBox_showAxisYSeparator.Checked = _settings.Get <bool>(ConfigEntrys.ShowAxisYSeparator);

            numericUpDown_windowHeight.Value      = (decimal)_settings.Get <double>(ConfigEntrys.WindowHeight);
            numericUpDown_windowWidth.Value       = (decimal)_settings.Get <double>(ConfigEntrys.WindowWidth);
            checkBox_enableWindowRezising.Checked = _settings.Get <bool>(ConfigEntrys.EnableResizing);



            color_chartPrimary.ColorChanged     += Color_chartPrimary_ColorChanged;
            color_chartProgress.ColorChanged    += ColorChartProgressOnColorChanged;
            color_horizontalLegend.ColorChanged += ColorHorizontalLegendOnColorChanged;

            checkBox_enable.CheckedChanged             += CheckBoxEnableOnCheckedChanged;
            checkBox_autosizeChart.CheckedChanged      += checkBox_autosizeChart_CheckedChanged;
            comboBox_font.SelectedValueChanged         += ComboBoxFontOnSelectedValueChanged;
            textBox_chartCutoffs.TextChanged           += textBox_chartCutoffs_TextChanged;
            checkBox_showAxisYSeparator.CheckedChanged += checkBox_showAxisYSeparator_CheckedChanged;

            numericUpDown_windowHeight.ValueChanged      += NumericUpDownWindowHeightOnValueChanged;
            numericUpDown_windowWidth.ValueChanged       += NumericUpDownWindowWidthOnValueChanged;
            checkBox_enableWindowRezising.CheckedChanged += CheckBoxEnableWindowRezisingOnCheckedChanged;
        }
        public TcpSocketSettings(ISettingsHandler settings)
        {
            _settings = settings;
            InitializeComponent();
            checkBox_EnableTcpOutput.Checked = _settings.Get <bool>(_names.tcpSocketEnabled);


            checkBox_EnableTcpOutput.CheckedChanged += checkBox_EnableTcpOutput_CheckedChanged;
        }
示例#27
0
 private void HookMouse()
 {
     if (_settings.Get <bool>(_names.EnableMouseHook) && _mouseListener == null)
     {
         _mouseListener = new MouseListener();
         _mouseListener.OnLeftMouseDown  += _mouseListener_OnLeftMouseDown;
         _mouseListener.OnRightMouseDown += MouseListener_OnRightMouseDown;
         _mouseListener.Hook();
         _logger.Log(">Mouse hooked!", LogLevel.Debug);
     }
 }
示例#28
0
 public void Start(ILogger logger)
 {
     Started         = true;
     api             = new OsuPostApi(logger);
     api.EndpointUrl = _settings.Get <string>(_names.osuPostEndpoint);
     SwitchApiStatus(_settings.Get <bool>(_names.osuPostEnabled));
     _settings.SettingUpdated += SettingUpdated;
 }
示例#29
0
 public ParserSettings(ISettingsHandler settings, Action resetPatterns)
 {
     _settings      = settings;
     _resetPatterns = resetPatterns;
     InitializeComponent();
     this.patternList.SelectedItemChanged      += SelectedItemChanged;
     this.checkBox_disableDiskSaving.Checked    = _settings.Get <bool>(_names.DisableDiskPatternWrite);
     this.patternEdit.DeletePattern            += DeletePattern;
     this.patternEdit.AddPattern               += AddPattern;
     checkBox_disableDiskSaving.CheckedChanged += CheckBox_disableDiskSaving_CheckedChanged;
 }
示例#30
0
        public MainWindow(ISettingsHandler settings, IMainWindowModel mainWindowHandle, IEnumerable <ISettingsProvider> settingsProviders, Delegates.Exit exitAction)
        {
            _settings         = settings;
            _mainWindowHandle = mainWindowHandle;
            _exitAction       = exitAction;
            _settingsList     = settingsProviders.ToList();

            if (!_settings.Get <bool>(_names.StartHidden))
            {
                ShowWindow();
            }
        }