Пример #1
0
        private void Main_Tool_Export_Playlist_MP3_Click(object sender, EventArgs e)
        {
            var dialog = new FolderBrowserDialog();

            if (DialogResult.OK != dialog.ShowDialog())
            {
                return;
            }
            var worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                foreach (var song in Core.PlayList)
                {
                    Core.Allsets[song].SaveAudios(dialog.SelectedPath);
                }
                foreach (
                    var file in
                    Directory.GetFiles(dialog.SelectedPath)
                    .Select(filename => new FileInfo(filename))
                    .Where(file => file.Extension == ".bak"))
                {
                    file.Delete();
                }
            };
            worker.RunWorkerCompleted += delegate { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Save_Complete")); };
            NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Saving"));
            worker.RunWorkerAsync();
        }
Пример #2
0
 public void InitBG()
 {
     if (Map.Background != "" && !File.Exists(Map.Background))
     {
         NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("BG_Loss_Tip_Text"));
         Map.Background = "";
     }
     if (Map.Background == "")
     {
         using (var s = new MemoryStream())
         {
             Resources.defaultBG.Save(s, ImageFormat.Png);
             s.Seek(0, SeekOrigin.Begin);
             _bgTexture = Texture2D.FromFile(device, s);
         }
     }
     else
     {
         using (var s = new FileStream(Map.Background, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         {
             _bgTexture = Texture2D.FromFile(device, s);
         }
     }
     _bgScale  = Math.Min((float)_showRect.Width / _bgTexture.Width, (float)_showRect.Height / _bgTexture.Height);
     _bgCenter = new Vector2((float)_bgTexture.Width / 2, (float)_bgTexture.Height / 2);
 }
Пример #3
0
 /// <summary>
 ///     初始化Set的总方法,从文件读取或从osu!.db读取
 /// </summary>
 private static void Initset()
 {
     if (DBSupporter.LoadList() && (Allsets != null))
     {
         Initplaylist();
     }
     else
     {
         if (File.Exists(Path.Combine(Settings.Default.OSUpath, "osu!.db")))
         {
             try
             {
                 OsuDB.ReadDb(Path.Combine(Settings.Default.OSUpath, "osu!.db"));
             }
             catch (Exception)
             {
                 NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), "Fallback client detected, reloading...");
                 OsuDB.ReadDb(Path.Combine(Settings.Default.OSUpath, "osu!.db"), "fallback");
             }
         }
         Initplaylist();
         NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), string.Format(LanguageManager.Get("Core_Init_Finish_Text"), Allsets.Count));
         _needsave = true;
     }
     CurrentSet     = Allsets[PlayList[0]];
     CurrentBeatmap = CurrentSet.GetBeatmaps()[0];
     TmpSet         = CurrentSet;
     TmpBeatmap     = CurrentBeatmap;
 }
Пример #4
0
        static void Main()
        {
            Application.SetCompatibleTextRenderingDefault(false);
            //设置应用程序处理异常方式:ThreadException处理
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += Application_ThreadException;
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            try
            {
                bool ret;
                _mutex = new Mutex(true, Application.ProductName, out ret);
                if (!ret)
                {
                    MessageBox.Show(@"The Program is already running!", @"Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.ExitThread();
                    return;
                }
                var filename = Assembly.GetExecutingAssembly().Location;
                if (File.Exists(filename + ".detele"))
                {
                    File.Delete(filename + ".delete");
                }
                if (!File.Exists("bass_fx.dll"))
                {
                    if (File.Exists(Properties.Settings.Default.OSUpath + "\\bass_fx.dll"))
                    {
                        File.Copy(Properties.Settings.Default.OSUpath + "\\bass_fx.dll", "bass_fx.dll");
                    }
                    else
                    {
                        MessageBox.Show(@"如果不能播放,请重新下载完整包!\nPlease re-download the full pack if it can't play!", @"Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                Un4seen.Bass.BassNet.Registration(PrivateConfig.BassEmail, PrivateConfig.BassReg);
                Un4seen.Bass.AddOn.Fx.BassFx.LoadMe();
                LanguageManager.InitLanguage(System.Globalization.CultureInfo.CurrentCulture.Name);

                /*var mainwindow = new Main();
                 * mainwindow.Show();
                 * while (mainwindow.Created)
                 * {
                 *   Application.DoEvents();
                 *   Core.Render();
                 *   Thread.Sleep(5);
                 * }*/
                Application.Run(new Main());
            }
            #region 异常处理
            catch (Exception ex)
            {
                GetExceptionMsg(ex);
                NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error);
            }
        }
Пример #5
0
 /// <summary>
 ///     全局初始化
 /// </summary>
 /// <param name="shandle">显示区域的handle</param>
 /// <param name="ssize">显示区域的大小</param>
 public static void Init(IntPtr shandle, Size ssize)
 {
     _player = new Player(shandle, ssize);
     NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Init_Text"));
     Getpath();
     new Thread(Selfupdate.check_update).Start();
     Initset();
     _renderThread = new Thread(Render);
     _renderThread.Start();
 }
Пример #6
0
 public static void Play()
 {
     if (!CurrentSet.Detailed)
     {
         CurrentSet.GetDetail();
     }
     if (!CurrentBeatmap.Detailed)
     {
         CurrentBeatmap.GetDetail();
     }
     if (!File.Exists(CurrentBeatmap.Audio))
     {
         NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_MP3_Text"));
         return;
     }
     _player.Play();
     NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Current_Playing_Text") + CurrentBeatmap.NameToString());
     NotifySystem.SetText(CurrentBeatmap.NameToString());
 }
Пример #7
0
 public static bool SetMap(int value, bool p = false)
 {
     TmpBeatmap = TmpSet.GetBeatmaps()[value];
     if (!TmpBeatmap.Detailed)
     {
         TmpBeatmap.GetDetail();
     }
     if (!File.Exists(TmpBeatmap.Audio))
     {
         NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text"));
         Remove(TmpSet.GetHash());
         return(true);
     }
     if (p)
     {
         Tmp2Current(false);
     }
     return(false);
 }
Пример #8
0
 public static bool SetSet(int value, bool p = false)
 {
     TmpSet = Allsets[PlayList[value]];
     if (!TmpSet.Check())
     {
         NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text"));
         Remove(TmpSet.GetHash());
         return(true);
     }
     if (!TmpSet.Detailed)
     {
         TmpSet.GetDetail();
     }
     if (p)
     {
         Tmp2Current(true);
     }
     return(false);
 }
Пример #9
0
        public static bool SetSet(int value, bool p = false)
        {
            TmpSet = Allsets[PlayList[value]];
            if (!TmpSet.Check())
            {
                NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text"));
                Remove(TmpSet.GetHash());
#if THROW
                throw new Exception("Set net found, text is " + TmpSet.location);
#endif
                return(true);
            }
            if (!TmpSet.Detailed)
            {
                TmpSet.GetDetail();
            }
            if (p)
            {
                Tmp2Current(true);
            }
            return(false);
        }
Пример #10
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     GetExceptionMsg(e.ExceptionObject as Exception);
     NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error);
 }
Пример #11
0
 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     GetExceptionMsg(e.Exception);
     NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error);
 }