private PerformanceCalculatorBase GetCalculator(OsuPlayMode mode) { switch (mode) { case OsuPlayMode.Osu: _stdPpCalculator = _stdPpCalculator ?? new StdPerformanceCalculator(); return(_stdPpCalculator); case OsuPlayMode.Taiko: _taikoPpCalculator = _taikoPpCalculator ?? new TaikoPerformanceCalculator(); return(_taikoPpCalculator); case OsuPlayMode.Mania: _maniaPpCalculator = _maniaPpCalculator ?? new ManiaPerformanceCalculator(); return(_maniaPpCalculator); case OsuPlayMode.CatchTheBeat: _ctbPpCalculator = _ctbPpCalculator ?? new CatchTheBeatPerformanceCalculator(); return(_ctbPpCalculator); default: CurrentIO.WriteColor($"[RealTimePPDisplay]Unknown Mode! Mode:0x{(int)mode:X8}", ConsoleColor.Red); return(null); } }
public bool language(Arguments arg) { if (arg.Count == 0) { CultureInfo info = CultureInfo.GetCultureInfo(I18n.Instance.CurrentLanguage); CurrentIO.WriteColor(string.Format("Current culture: {0:S}\t{1:S}", info.Name, info.NativeName), ConsoleColor.Yellow); return(true); } else if (arg.Count == 1) { try { CultureInfo info = CultureInfo.GetCultureInfo(arg[0]); Configuration.Language = arg[0]; CurrentIO.WriteColor(string.Format("Success switch to {1:S}({0:S})", arg[0], info.NativeName), ConsoleColor.Green); return(true); } catch (CultureNotFoundException) { CurrentIO.WriteColor("Culture not found! Please specify other culture name.", ConsoleColor.Red); return(false); } } return(false); }
private bool switchclient(Arguments arg) { if (arg.Count == 0) { foreach (var item in MainClients.Clients) { CurrentIO.WriteColor("", ConsoleColor.Gray, false); CurrentIO.WriteColor(LANG_COMMANDS_CLIENT_NAME, ConsoleColor.Cyan, false, false); CurrentIO.WriteColor(item.ClientName.PadRight(18), ConsoleColor.White, false, false); CurrentIO.WriteColor(LANG_COMMANDS_CLIENT_AUTHOR, ConsoleColor.DarkCyan, false, false); CurrentIO.WriteColor(item.Author, ConsoleColor.White, true, false); } CurrentIO.WriteColor(string.Format(LANG_COMMANDS_CURRENT, MainClient.Client.ClientName), ConsoleColor.Green); } else { if (MainClients.Clients.FirstOrDefault(p => p.ClientName == arg[0]) == null) { return(false); } Configuration.Client = arg[0]; MainClient.ResetClient(); } return(true); }
public bool msgmgr(Arguments arg) { int value = 0; if (arg.Count == 0) { CurrentIO.WriteColor(LANG_COMMANDS_ARGUMENT_WRONG, ConsoleColor.Red); } else { switch (arg[0].Trim()) { case "--help": CurrentIO.WriteColor(LANG_COMMANDS_MSGMGR_HELP, ConsoleColor.Yellow); break; case "--status": CurrentIO.WriteColor(String.Format(LANG_COMMANDS_MSGMGR_STATUS, (string)(MessageManager.IsLimit ? LANG_COMMANDS_MSGMGR_LIMIT : LANG_COMMANDS_MSGMGR_FREE), MessageManager.CurrentQueueCount, MessageManager.LimitLevel, MessageManager.RecoverTime, MessageManager.Option.ToString()), ConsoleColor.Yellow); break; case "--limit": if (arg.Count == 2 && Int32.TryParse(arg[1].Trim(), out value)) { MessageManager.LimitLevel = value; CurrentIO.WriteColor(string.Format(LANG_COMMANDS_MSGMGR_LIMIT_SPEED_SET, MessageManager.LimitLevel), ConsoleColor.Yellow); } else { CurrentIO.WriteColor(LANG_COMMANDS_ARGUMENT_WRONG, ConsoleColor.Red); } break; case "--option": if (arg.Count == 2) { switch (arg[1].Trim().ToLower()) { case "auto": MessageManager.Option = MessageManager.PeekOption.Auto; break; case "force_all": MessageManager.Option = MessageManager.PeekOption.Force_All; break; case "force_limit": MessageManager.Option = MessageManager.PeekOption.Only_Send_Command; break; } CurrentIO.WriteColor(string.Format(LANG_COMMANDS_MSGMGR_LIMIT_STYPE_SET, MessageManager.Option.ToString()), ConsoleColor.Yellow); } else { CurrentIO.WriteColor(LANG_COMMANDS_ARGUMENT_WRONG, ConsoleColor.Red); } break; } } return(true); }
static void InitSync() { //Apply update if (Updater.ApplyUpdate(NeedUpdateSync)) { Environment.Exit(0); } //Add Console close event handler SetConsoleCtrlHandler(cancelHandler, true); //Initialize Sync core SyncHost.Instance = new SyncHost(); SyncHost.Instance.Load(); //Sync ready message to all plugins SyncHost.Instance.Plugins.ReadySync(); //Check update if (DefaultConfiguration.Instance.CheckUpdateOnStartup.ToBool()) { Updater.update.SyncUpdateCheck(); } //Sync program update check if (Updater.IsUpdated) { CurrentIO.WriteColor("Sync is already up to date!", ConsoleColor.Green); } }
public bool listsource(Arguments arg) { foreach (SourceBase src in MainSources.SourceList) { CurrentIO.WriteColor("", ConsoleColor.Gray, false); CurrentIO.WriteColor(LANG_COMMANDS_SOURCES_NAME, ConsoleColor.Cyan, false, false); CurrentIO.WriteColor(src.Name.PadRight(18), ConsoleColor.White, false, false); CurrentIO.WriteColor(LANG_COMMANDS_SOURCES_AUTHOR, ConsoleColor.DarkCyan, false, false); CurrentIO.WriteColor(src.Author, ConsoleColor.White, true, false); } return(true); }
private bool filters(Arguments arg) { foreach (var item in MainFilters.GetFiltersEnum()) { CurrentIO.WriteColor("", ConsoleColor.Gray, false); CurrentIO.WriteColor(LANG_COMMANDS_FILTERS_ITEM, ConsoleColor.Cyan, false, false); CurrentIO.WriteColor(item.Key.Name.PadRight(22), ConsoleColor.White, false, false); CurrentIO.WriteColor(LANG_COMMANDS_FILTERS_OBJ, ConsoleColor.DarkCyan, false, false); CurrentIO.WriteColor(item.Value.GetType().Name, ConsoleColor.White, true, false); } return(true); }
private bool target(Arguments arg) { if (arg.Count == 0) { CurrentIO.WriteColor(string.Format(LANG_COMMANDS_TARGET_CURRENT, BiliBili.RoomID), ConsoleColor.Green); } else { BiliBili.RoomID = arg[0]; CurrentIO.WriteColor(string.Format(LANG_COMMANDS_TARGET_SET, BiliBili.RoomID), ConsoleColor.Green); } return(true); }
private void SyncInstanceLocker(MemoryMappedFile syncMappedFile, bool forceExit) { using (var syncViewStream = syncMappedFile.CreateViewStream()) { int pid = 0; using (var reader = new BinaryReader(syncViewStream)) { pid = reader.ReadInt32(); if (pid != 0) { var oldSync = Process.GetProcesses().FirstOrDefault((proc) => proc.Id == pid); if (oldSync != null) { if (forceExit) { oldSync.Kill(); } else { CurrentIO.WriteColor(DefaultI18n.LANG_Instance_Exist, ConsoleColor.Red); int limit = 50, current = 0; while (!oldSync.WaitForExit(100)) { current++; if (current > limit) { break; } } if (!oldSync.WaitForExit(100)) { oldSync.Kill(); } } } } using (var writer = new BinaryWriter(syncViewStream)) { writer.Seek(0, SeekOrigin.Begin); writer.Write(Process.GetCurrentProcess().Id); } } } }
/// <summary> /// Invoke to load plugins /// </summary> internal void Load() { CurrentIO.Write(LANG_Loading); //Initial plugins manager plugins = new PluginManager(); CurrentIO.WriteColor(String.Format(LANG_Plugins, plugins.LoadPlugins()), ConsoleColor.Green); //Initial danmaku source sources = new SourceManager(); CurrentIO.WriteColor(String.Format(LANG_Sources, plugins.LoadSources()), ConsoleColor.Green); //select a danmaku source by config try { sourceWrapper = new SourceWorkWrapper(sources); PluginEvents.Instance.RaiseEvent(new PluginEvents.InitSourceWarpperEvent(sourceWrapper)); } catch { CurrentIO.Write(""); CurrentIO.WriteColor(LANG_Error, ConsoleColor.Red); CurrentIO.WriteColor("Press enter to continue", ConsoleColor.Red); CurrentIO.ReadCommand(); } //Get clients singleton clients = ClientManager.Instance; CurrentIO.WriteColor(String.Format(LANG_Client, plugins.LoadClients()), ConsoleColor.Green); clientWrapper = new ClientWorkWrapper(clients); PluginEvents.Instance.RaiseEvent(new PluginEvents.InitClientWarpperEvent(clientWrapper)); commands = new CommandManager(); CurrentIO.WriteColor(String.Format(LANG_Commands, plugins.LoadCommnads()), ConsoleColor.Green); filters = new FilterManager(); CurrentIO.WriteColor(String.Format(LANG_Filters, plugins.LoadFilters()), ConsoleColor.Green); messages = new MessageDispatcher(filters); plugins.ReadyProgram(); CurrentIO.WriteColor(LANG_Ready, ConsoleColor.Cyan); }
private void RtppOnBeatmapChanged(OsuRTDataProvider.BeatmapInfo.Beatmap beatmap) { string file = beatmap.FilenameFull; if (string.IsNullOrWhiteSpace(file)) { CurrentIO.WriteColor($"[RealTimePPDisplayer]No found .osu file(Set:{beatmap.BeatmapSetID} Beatmap:{beatmap.BeatmapID}])", ConsoleColor.Yellow); _beatmapReader = null; return; } if (Setting.DebugMode) { CurrentIO.WriteColor($"[RealTimePPDisplayer]File:{file}", ConsoleColor.Blue); } _beatmapReader = new BeatmapReader(beatmap, _mode); _ppCalculator.ClearCache(); }
private bool setosubot(Arguments arg) { if (arg.Count == 0) { CurrentIO.WriteColor(string.Format(LANG_COMMANDS_BOTIRC_CURRENT, DirectOSUIRCBot.IRCBotName), ConsoleColor.Cyan); CurrentIO.WriteColor(string.Format(LANG_COMMANDS_IRC_CURRENT, DirectOSUIRCBot.IRCNick), ConsoleColor.Cyan); return(true); } if (arg.Count < 3) { return(false); } DirectOSUIRCBot.IRCBotName = arg[0]; DirectOSUIRCBot.IRCBotPasswd = arg[1]; DirectOSUIRCBot.IRCNick = arg[2]; return(true); }
public bool languages(Arguments arg) { if (arg.Count > 0 && arg[0] == "--all") { foreach (var item in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { CurrentIO.WriteColor(string.Format("CultureName: {0:S}\t{1:S}", item.Name, item.NativeName), ConsoleColor.Yellow); } } else { foreach (var item in System.IO.Directory.EnumerateDirectories(I18n.Instance.LangFolder)) { string name = item.Substring(item.LastIndexOf('\\') + 1); CurrentIO.WriteColor(string.Format("CultureName: {0:S}\t{1:S}", name, CultureInfo.GetCultureInfo(name).NativeName), ConsoleColor.Yellow); } } return(true); }
private void RtppOnPlayModeChanged(OsuPlayMode last, OsuPlayMode mode) { if (_status == OsuStatus.Playing) { _tmpLastPpCalculator = _ppCalculator; } switch (mode) { case OsuPlayMode.Osu: _ppCalculator = new StdPerformanceCalculator(); break; case OsuPlayMode.Taiko: _ppCalculator = new TaikoPerformanceCalculator(); break; case OsuPlayMode.Mania: _ppCalculator = new ManiaPerformanceCalculator(); break; default: CurrentIO.WriteColor("[RealTimePPDisplayer]Unsupported Mode", ConsoleColor.Red); _ppCalculator = null; break; } _mode = mode; }
private void RtppOnPlayingTimeChanged(int time) { var cal = GetCalculator(_mode); if (cal == null) { return; } if (_status != OsuStatus.Playing) { return; } if (_curMods == ModsInfo.Mods.Unknown) { return; } int totalhit = _n300 + _n100 + _n50 + _nkatu + _ngeki + _nmiss; if (time > cal.Beatmap?.BeatmapDuration && totalhit == 0) { return; } if (_time > time)//Reset { cal.ClearCache(); _combo = 0; _maxCombo = 0; _n100 = 0; _n50 = 0; _nmiss = 0; _score = 0; foreach (var p in Displayers) { p.Value?.Clear(); } } if (_beatmapReader == null) { CurrentIO.WriteColor(DefaultLanguage.HINT_BEATMAP_NO_FOUND, ConsoleColor.Red); return; } cal.Beatmap = _beatmapReader; cal.Time = time; cal.MaxCombo = _maxCombo; cal.Count300 = _n300; cal.Count100 = _n100; cal.Count50 = _n50; cal.CountMiss = _nmiss; cal.CountGeki = _ngeki; cal.CountKatu = _nkatu; cal.Score = _score; cal.Mods = (uint)_curMods.Mod; var ppTuple = cal.GetPerformance(); ppTuple.RealTimePP = F(ppTuple.RealTimePP, ppTuple.MaxPP); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, ppTuple.MaxPP); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, ppTuple.MaxPP); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, ppTuple.MaxPP); ppTuple.RealTimePP = F(ppTuple.RealTimePP, double.NaN); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, double.NaN); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, double.NaN); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, double.NaN); int fullCombo = GetFullCombo(cal); int rtMaxCombo = GetRtMaxCombo(cal); HitCountTuple hitTuple; hitTuple.Count300 = _n300; hitTuple.Count100 = _n100; hitTuple.Count50 = _n50; hitTuple.CountMiss = _nmiss; hitTuple.Combo = _combo; hitTuple.FullCombo = fullCombo; hitTuple.PlayerMaxCombo = _maxCombo; hitTuple.CurrentMaxCombo = rtMaxCombo; hitTuple.CountGeki = _ngeki; hitTuple.CountKatu = _nkatu; hitTuple.ErrorStatistics = _error_statistics; int duration = cal.Beatmap?.BeatmapDuration ?? -1; int objectsCount = cal.Beatmap?.ObjectsCount ?? -1; BeatmapTuple beatmapTuple; beatmapTuple.Duration = duration; beatmapTuple.ObjectsCount = objectsCount; beatmapTuple.RealTimeStars = cal.RealTimeStars; beatmapTuple.Stars = cal.Stars; beatmapTuple.BeatmapID = cal.Beatmap.OrtdpBeatmap.BeatmapID; if (_maxCombo > (fullCombo == 0 ? 20000 : fullCombo)) { _maxCombo = 0; } foreach (var p in Displayers) { if (p.Value == null) { continue; } p.Value.Pp = ppTuple; p.Value.HitCount = hitTuple; p.Value.BeatmapTuple = beatmapTuple; p.Value.Playtime = time; p.Value.Mode = _mode; p.Value.Mods = _curMods; p.Value.Status = _status; p.Value.Playername = _playername; p.Value.Accuracy = cal.Accuracy; p.Value.Score = _score; p.Value.Display(); } _time = time; }
private void RtppOnPlayingTimeChanged(int time) { if (_ppCalculator == null) { return; } if (_status != OsuStatus.Playing) { return; } if (_curMods == ModsInfo.Mods.Unknown) { return; } var cal = _tmpLastPpCalculator ?? _ppCalculator; int totalhit = _n300 + _n100 + _n50 + _n50 + _nkatu + _ngeki + _nmiss; if (time > cal.Beatmap?.BeatmapDuration && totalhit == 0) { return; } if (_time > time)//Reset { _ppCalculator.ClearCache(); _combo = 0; _maxCombo = 0; _n100 = 0; _n50 = 0; _nmiss = 0; foreach (var p in _displayers) { p.Value.Clear(); } } if (Setting.DebugMode && _beatmapReader == null) { CurrentIO.WriteColor("[RealTimePPDisplayer]Can\'t get beatmap information!", ConsoleColor.Yellow); return; } cal.Beatmap = _beatmapReader; cal.Time = time; cal.MaxCombo = _maxCombo; cal.Count300 = _n300; cal.Count100 = _n100; cal.Count50 = _n50; cal.CountMiss = _nmiss; cal.CountGeki = _ngeki; cal.CountKatu = _nkatu; cal.Score = _score; cal.Mods = _curMods; var ppTuple = cal.GetPerformance(); ppTuple.RealTimePP = F(ppTuple.RealTimePP, ppTuple.MaxPP); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, ppTuple.MaxPP); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, ppTuple.MaxPP); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, ppTuple.MaxPP); ppTuple.RealTimePP = F(ppTuple.RealTimePP, double.NaN); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, double.NaN); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, double.NaN); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, double.NaN); if (_maxCombo > ((cal as OppaiPerformanceCalculator)?.Oppai.FullCombo ?? 20000)) { _maxCombo = 0; } foreach (var p in _displayers) { p.Value.Pp = ppTuple; if (Setting.DisplayHitObject) { HitCountTuple hitTuple; hitTuple.Count300 = _n300; hitTuple.Count100 = _n100; hitTuple.Count50 = _n50; hitTuple.CountMiss = _nmiss; hitTuple.Combo = _combo; hitTuple.FullCombo = (cal as OppaiPerformanceCalculator)?.Oppai.FullCombo ?? 0; hitTuple.PlayerMaxCombo = _maxCombo; hitTuple.CurrentMaxCombo = (cal as OppaiPerformanceCalculator)?.Oppai.RealTimeMaxCombo ?? 0; hitTuple.CountGeki = _ngeki; hitTuple.CountKatu = _nkatu; hitTuple.ObjectsCount = cal.Beatmap.ObjectsCount; hitTuple.PlayTime = time; hitTuple.Duration = cal.Beatmap.BeatmapDuration; p.Value.HitCount = hitTuple; } p.Value.Display(); } _time = time; }
private void RtppOnPlayingTimeChanged(int time) { var cal = GetCalculator(_mode); if (cal == null) { return; } if (_status != OsuStatus.Playing) { return; } if (_curMods == ModsInfo.Mods.Unknown) { return; } int totalhit = _n300 + _n100 + _n50 + _nkatu + _ngeki + _nmiss; if (time > cal.Beatmap?.BeatmapDuration && totalhit == 0) { return; } if (_time > time)//Reset { cal.ClearCache(); _combo = 0; _maxCombo = 0; _n100 = 0; _n50 = 0; _nmiss = 0; _score = 0; foreach (var p in _displayers) { p.Value.Clear(); } } if (Setting.DebugMode && _beatmapReader == null) { CurrentIO.WriteColor("[RealTimePPDisplayer]Can\'t get beatmap information!", ConsoleColor.Yellow); return; } cal.Beatmap = _beatmapReader; cal.Time = time; cal.MaxCombo = _maxCombo; cal.Count300 = _n300; cal.Count100 = _n100; cal.Count50 = _n50; cal.CountMiss = _nmiss; cal.CountGeki = _ngeki; cal.CountKatu = _nkatu; cal.Score = _score; cal.Mods = (uint)_curMods.Mod; var ppTuple = cal.GetPerformance(); ppTuple.RealTimePP = F(ppTuple.RealTimePP, ppTuple.MaxPP); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, ppTuple.MaxPP); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, ppTuple.MaxPP); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, ppTuple.MaxPP); ppTuple.RealTimePP = F(ppTuple.RealTimePP, double.NaN); ppTuple.RealTimeSpeedPP = F(ppTuple.RealTimeSpeedPP, double.NaN); ppTuple.RealTimeAimPP = F(ppTuple.RealTimeAimPP, double.NaN); ppTuple.RealTimeAccuracyPP = F(ppTuple.RealTimeAccuracyPP, double.NaN); int fullCombo = GetFullCombo(cal); int rtMaxCombo = GetRtMaxCombo(cal); HitCountTuple hitTuple; hitTuple.Count300 = _n300; hitTuple.Count100 = _n100; hitTuple.Count50 = _n50; hitTuple.CountMiss = _nmiss; hitTuple.Combo = _combo; hitTuple.FullCombo = fullCombo; hitTuple.PlayerMaxCombo = _maxCombo; hitTuple.CurrentMaxCombo = rtMaxCombo; hitTuple.CountGeki = _ngeki; hitTuple.CountKatu = _nkatu; BeatmapTuple beatmapTuple; beatmapTuple.Duration = cal.Beatmap.BeatmapDuration; beatmapTuple.ObjectsCount = cal.Beatmap.ObjectsCount; if (_maxCombo > (fullCombo == 0 ? 20000 : fullCombo)) { _maxCombo = 0; } foreach (var p in _displayers) { p.Value.Pp = ppTuple; p.Value.HitCount = hitTuple; p.Value.BeatmapTuple = beatmapTuple; p.Value.Playtime = time; p.Value.Display(); } _time = time; }