public override void OnEnable()
        {
            var Config        = new OverlayConfig();
            var ConfigManager = new PluginConfigurationManager(this);

            ConfigManager.AddItem(Config);
            I18n.Instance.ApplyLanguage(new Language());

            EventBus.BindEvent <PluginEvents.InitCommandEvent>(cmds => new OverlayCommands(cmds.Commands));

            EventBus.BindEvent <PluginEvents.LoadCompleteEvent>(p =>
            {
                new OverlayLoader();
            });

            EventBus.BindEvent <PluginEvents.ProgramReadyEvent>(_ =>
            {
                var guiPlugin = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "ConfigGUI");
                if (guiPlugin != null)
                {
                    RegisterGuiHelper.RegisterGui(guiPlugin);
                }

                var ortdp = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "OsuRTDataProvider") as OsuRTDataProviderPlugin;
                ortdp.ListenerManager.OnStatusChanged += (l, c) =>
                {
                    _currentStatusString = c.ToString();

                    foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
                    {
                        item.Visibility = item.VisibleStatus.Contains(_currentStatusString);
                    }
                    Setting.OverlayConfigs.WriteToMmf(false);
                };

                ortdp.ListenerManager.OnBeatmapChanged += (b) => _breakTimeParser = new BreakTimeParser(b);

                //break time
                ortdp.ListenerManager.OnPlayingTimeChanged += (time) =>
                {
                    if (_breakTimeParser == null)
                    {
                        return;
                    }
                    if (!_currentStatusString.StartsWith("Playing"))
                    {
                        return;
                    }
                    bool updateMmf = false;

                    foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
                    {
                        if (!item.VisibleStatus.Contains("Playing"))
                        {
                            continue;
                        }

                        if (item.BreakTime == false)
                        {
                            item.Visibility = true;
                            updateMmf       = true;
                        }
                        else if (item.BreakTime == true && item.Visibility == false)
                        {
                            if (_breakTimeParser.InBraekTime(time))
                            {
                                item.Visibility = true;
                                updateMmf       = true;
                            }
                        }
                        else if (item.BreakTime == true && item.Visibility == true)
                        {
                            if (!_breakTimeParser.InBraekTime(time))
                            {
                                item.Visibility = false;
                                updateMmf       = true;
                            }
                        }
                    }

                    if (updateMmf)
                    {
                        Setting.OverlayConfigs.WriteToMmf(false);
                    }
                };
            });

            foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
            {
                item.Visibility         = false;
                item.VisibilityChanged += (list) =>
                {
                    item.Visibility = item.VisibleStatus.Contains(_currentStatusString);
                    Setting.OverlayConfigs.WriteToMmf(false);
                };
            }

            Setting.OverlayConfigs.WriteToMmf(true);
        }
Esempio n. 2
0
        public override void OnEnable()
        {
            var Config        = new OverlayConfig();
            var ConfigManager = new PluginConfigurationManager(this);

            ConfigManager.AddItem(Config);
            I18n.Instance.ApplyLanguage(new Language());


            //테스트 코드
            if (Setting.AcceptEula)
            {
                if (!string.IsNullOrWhiteSpace(Setting.OsuExecPath) && File.Exists(Setting.OsuExecPath) &&
                    Setting.OsuExecPath.ToLower().EndsWith("osu!.exe"))
                {
                    Setting.GlobalConfig.WriteToMmf();
                    Setting.OverlayConfigs.WriteToMmf();
                    Process.Start(Setting.OsuExecPath);
                    OverlayLoader.Injcet();
                }
                else
                {
                    Sync.Tools.IO.DefaultIO.WriteColor("Can't find osu!.exe", ConsoleColor.Yellow);
                    Sync.Tools.IO.DefaultIO.WriteColor("config ->  IngameOverlay -> OverlayConfig -> Osu! gmae path", ConsoleColor.Yellow);
                    Sync.Tools.IO.DefaultIO.WriteColor("Set osu.exe path", ConsoleColor.Yellow);
                }
            }


            //테스트 코드 END



            EventBus.BindEvent <PluginEvents.InitCommandEvent>(cmds => new OverlayCommands(cmds.Commands));

            EventBus.BindEvent <PluginEvents.LoadCompleteEvent>(p =>
            {
                new OverlayLoader();
            });

            EventBus.BindEvent <PluginEvents.ProgramReadyEvent>(_ =>
            {
                var guiPlugin = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "ConfigGUI");
                if (guiPlugin != null)
                {
                    RegisterGuiHelper.RegisterGui(guiPlugin);
                }

                var ortdp = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "OsuRTDataProvider") as OsuRTDataProviderPlugin;
                ortdp.ListenerManager.OnStatusChanged += (l, c) =>
                {
                    _currentStatusString = c.ToString();

                    foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
                    {
                        item.Visibility = item.VisibleStatus.Contains(_currentStatusString);
                    }
                    Setting.OverlayConfigs.WriteToMmf(false);
                };

                ortdp.ListenerManager.OnBeatmapChanged += (b) => _breakTimeParser = new BreakTimeParser(b);

                //break time
                ortdp.ListenerManager.OnPlayingTimeChanged += (time) =>
                {
                    if (_breakTimeParser == null)
                    {
                        return;
                    }
                    if (!_currentStatusString.StartsWith("Playing"))
                    {
                        return;
                    }
                    bool updateMmf = false;

                    foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
                    {
                        if (!item.VisibleStatus.Contains("Playing"))
                        {
                            continue;
                        }

                        if (item.BreakTime == false)
                        {
                            item.Visibility = true;
                            updateMmf       = true;
                        }
                        else if (item.BreakTime == true && item.Visibility == false)
                        {
                            if (_breakTimeParser.InBraekTime(time))
                            {
                                item.Visibility = true;
                                updateMmf       = true;
                            }
                        }
                        else if (item.BreakTime == true && item.Visibility == true)
                        {
                            if (!_breakTimeParser.InBraekTime(time))
                            {
                                item.Visibility = false;
                                updateMmf       = true;
                            }
                        }
                    }

                    if (updateMmf)
                    {
                        Setting.OverlayConfigs.WriteToMmf(false);
                    }
                };
            });

            foreach (var item in Setting.OverlayConfigs.OverlayConfigItems)
            {
                item.Visibility         = false;
                item.VisibilityChanged += (list) =>
                {
                    item.Visibility = item.VisibleStatus.Contains(_currentStatusString);
                    Setting.OverlayConfigs.WriteToMmf(false);
                };
            }

            Setting.OverlayConfigs.WriteToMmf(true);
        }