Example #1
0
        private void TryApplyBeatmapInfomation(object obj)
        {
            BeatmapEntry beatmap      = obj as BeatmapEntry;
            bool         apply_result = false;

            switch (source)
            {
            case UsingSource.OsuRTDataProvider:
                apply_result = ApplyBeatmapInfomationforOsuRTDataProvider(beatmap);
                break;

            case UsingSource.DifficultParamModifyPlugin:
                apply_result = ApplyBeatmapInfomationforDifficultParamModifyPlugin(beatmap);
                break;

            case UsingSource.None:
                break;

            default:
                break;
            }

            if (!apply_result)
            {
                CleanOutput();
            }
        }
Example #2
0
        public void OnBeatmapChanged(BeatmapChangedParameter evt)
        {
            BeatmapEntry new_beatmap = evt?.beatmap;

            var processes = Process.GetProcessesByName("osu!");

            if (processes.Length == 0)
            {
                return;
            }

            var osu_process = processes?.First();

            if (new_beatmap == null || osu_process == null)
            {
                if (osu_process == null)
                {
                    Log.Error(OSU_PROCESS_NOTFOUND);
                }
                CleanOutput();
                return;
            }

            TryApplyBeatmapInfomation(new_beatmap);
        }
Example #3
0
        public void OutputBeatmapInfomation(BeatmapEntry current_beatmap, ModsInfo mod)
        {
            sw.Restart();

            string beatmap_osu_file = current_beatmap.OsuFilePath;

            if (string.IsNullOrEmpty(beatmap_osu_file))
            {
                return;
            }
            string osuFileContent = File.ReadAllText(beatmap_osu_file);
            string beatmap_folder = Directory.GetParent(beatmap_osu_file).FullName;

            if (!OutputInfomation(current_beatmap.OutputType, current_beatmap, mod))
            {
                Log.Warn($"Cant output info {current_beatmap.BeatmapSetId}.");
                return;
            }

            #region OutputBackgroundImage

            var    match  = Regex.Match(osuFileContent, @"\""((.+?)\.((jpg)|(png)|(jpeg)))\""", RegexOptions.IgnoreCase);
            string bgPath = beatmap_folder + @"\" + match.Groups[1].Value;

            if (bgPath != current_bg_file_path)
            {
                OutputBackgroundImage(bgPath, current_beatmap.OutputType);
            }

            current_bg_file_path = bgPath;

            #endregion OutputBackgroundImage

            #region Mods Ouptut

            if (EnableOutputModPicture.ToBool() && mods_pic_output == null)
            {
                //init mods_pic_output
                TryCreateModsPictureGenerator(out mods_pic_output);
            }

            if (mods_pic_output != null && mod != prev_mods)
            {
                prev_mods = mod;

                var mod_list = mod.Name.Split(',');

                using (Bitmap result = mods_pic_output.GenerateModsPicture(mod_list))
                {
                    result.Save(OutputModImageFilePath, ImageFormat.Png);
                }
            }

            #endregion Mods Ouptut

            EventBus.RaiseEvent(new OutputInfomationEvent(current_beatmap.OutputType));

            Log.Output($"Done!time:{sw.ElapsedMilliseconds}ms output_type:{current_beatmap.OutputType} setid:{current_beatmap.BeatmapSetId} mod:{mod}");
        }
Example #4
0
        private bool OutputInfomation(OutputType output_type, BeatmapEntry entry, ModsInfo mods)
        {
            var extra = entry.ExtraParam ?? new Dictionary <string, object>();

            extra.Add("osu_file_path", entry.OsuFilePath);
            extra.Add("beatmap_id", entry.BeatmapId.ToString());
            extra.Add("beatmap_setid", entry.BeatmapSetId.ToString());

            return(PPShowPluginInstance.Output(output_type, entry.OsuFilePath, mods, extra));
        }
Example #5
0
        private bool ApplyBeatmapInfomationforOsuRTDataProvider(BeatmapEntry current_beatmap)
        {
            RealtimeDataProvideWrapperBase OsuRTDataProviderWrapperInstance = SourceWrapper as RealtimeDataProvideWrapperBase;

            ModsInfo mod = default(ModsInfo);

            //添加Mods
            if (OsuRTDataProviderWrapperInstance.current_mod.Mod != OsuRTDataProvider.Mods.ModsInfo.Mods.Unknown)
            {
                //处理不能用的PP
                mod.Mod = (ModsInfo.Mods)((uint)OsuRTDataProviderWrapperInstance.current_mod.Mod);
            }

            OutputBeatmapInfomation(current_beatmap, mod);

            return(true);
        }
Example #6
0
        private bool ApplyBeatmapInfomationforDifficultParamModifyPlugin(BeatmapEntry current_beatmap)
        {
            var wrapper = SourceWrapper as DifficultParamModifyPluginSourceWrapper;

            ModsInfo mod = default(ModsInfo);

            //添加Mods
            if (wrapper.CurrentMod.Mod != Mods.ModsInfo.Mods.Unknown)
            {
                //处理不能用的PP
                mod.Mod = wrapper.CurrentMod.Mod;
            }

            OutputBeatmapInfomation(current_beatmap, mod);

            return(true);
        }