Esempio n. 1
0
    public static void AddScore(string songID, int score, float maxScorePercent, float difficultyRating, int combo, int maxCombo, KataConfig.Difficulty difficulty)
    {
        var scoreToAdd    = new AudicaScore(songID, score, maxScorePercent, difficulty, combo, maxCombo);
        var previousScore = scores.FirstOrDefault(previous => previous.songID == songID);

        if (!previousScore.Equals(default(AudicaScore)))
        {
            if (scoreToAdd.score < previousScore.score)
            {
                return;
            }
            else
            {
                scores.Add(scoreToAdd);
                scores.Remove(previousScore);
            }
        }
        else
        {
            scores.Add(scoreToAdd);
        }
        lastAudicaScore = audicaScore;
        audicaScore     = CalculateTotalRating();
        SongBrowser.DebugText($"<color=green>+{(audicaScore - lastAudicaScore).ToString("n2")}</color>");
        SaveHistory(PlatformChooser.I.GetLeaderboardID());
    }
Esempio n. 2
0
        public bool SelectFile(string file)
        {
            bool sel = SongBrowser.SelectFile(file);

            if (!sel)
            {
                SongBrowser.ClearSelected();
            }
            return(sel);
        }
Esempio n. 3
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            if (SongBrowserVisible)
            {
                if (e.Delta > 0)
                {
                    SongBrowser.PreviousFile();
                }
                else
                {
                    SongBrowser.NextFile();
                }
            }
        }
Esempio n. 4
0
    public static void ExportDifficultyCalculation(bool extras)
    {
        var songIDs = GameObject.FindObjectOfType <SongSelect>().GetSongIDs(extras);

        using (System.IO.StreamWriter file =
                   new System.IO.StreamWriter(Application.dataPath + "/../" + "difficultyCalculatorOutput.txt"))
        {
            file.WriteLine("Song Name, Difficulty, Difficulty Rating, BPM, Author");
            for (int i = 0; i < songIDs.Count; i++)
            {
                var songData = SongList.I.GetSong(songIDs[i]);
                var calc     = new DifficultyCalculator(songData);
                if (calc.expert != null)
                {
                    file.WriteLine($"{SongBrowser.RemoveFormatting(songData.artist).Replace(",", "")} - {SongBrowser.RemoveFormatting(songData.title).Replace(",", "")}," +
                                   "Expert," +
                                   $"{calc.expert.difficultyRating.ToString("n2")}," +
                                   $"{songData.tempos[0].tempo.ToString("n2")}," +
                                   $"{songData.author}");
                }
                if (calc.advanced != null)
                {
                    file.WriteLine($"{SongBrowser.RemoveFormatting(songData.artist).Replace(",", "")} - {SongBrowser.RemoveFormatting(songData.title).Replace(",", "")}," +
                                   "Advanced," +
                                   $"{calc.advanced.difficultyRating.ToString("n2")}," +
                                   $"{songData.tempos[0].tempo.ToString("n2")}," +
                                   $"{songData.author}");
                }
                if (calc.standard != null)
                {
                    file.WriteLine($"{SongBrowser.RemoveFormatting(songData.artist).Replace(",", "")} - {SongBrowser.RemoveFormatting(songData.title).Replace(",", "")}," +
                                   "Standard," +
                                   $"{calc.standard.difficultyRating.ToString("n2")}," +
                                   $"{songData.tempos[0].tempo.ToString("n2")}," +
                                   $"{songData.author}");
                }
                if (calc.beginner != null)
                {
                    file.WriteLine($"{SongBrowser.RemoveFormatting(songData.artist).Replace(",", "")} - {SongBrowser.RemoveFormatting(songData.title).Replace(",", "")}," +
                                   "Beginner," +
                                   $"{calc.beginner.difficultyRating.ToString("n2")}," +
                                   $"{songData.tempos[0].tempo.ToString("n2")}," +
                                   $"{songData.author}");
                }
            }
        }
    }
Esempio n. 5
0
    public static string CreateDisplayString(List <CalculatedScoreEntry> scores)
    {
        string output = $"{((int)ScoreHistory.audicaScore).ToString()}AP <size=60%><color=#999>(Audica Points)</color></size><size=60%>\nTop scores:<size=40%>";

        for (int i = 0; i < 25; i++)
        {
            if (!(i >= scores.Count))
            {
                var song = SongList.I.GetSong(scores[i].songID);
                if (song != null)
                {
                    output += $"\n<color=green>{scores[i].audicaPointsWeighted.ToString("n2")}AP</color>" +
                              " | " +
                              $"{SongBrowser.RemoveFormatting(song.artist)} - {SongBrowser.RemoveFormatting(song.title)} " +
                              $"<color=#999>({scores[i].maxScorePercent.ToString("P")})</color>";
                }
            }
        }
        return(output);
    }
Esempio n. 6
0
        public BmpExplorer()
        {
            InitializeComponent();

            selectFlashingTimer.Tick += delegate(object o, EventArgs a) {
                Random random = new Random();
                int    min = 180, max = 240;
                SelectorSong.BackColor = Color.FromArgb(random.Next(min, max), random.Next(min, max), random.Next(min, max));
            };
            selectFlashingTimer.Interval = 100;
            selectFlashingTimer.Start();

            SongBrowser.OnMidiFileSelect += SongBrowser_EnterFile;
            SelectorTrack.ValueChanged   += delegate(object o, EventArgs e) {
                if (!ignoreTrackChange)
                {
                    this.EnterFile();
                }
            };

            MusicReload.Click += delegate(object sender, EventArgs e) {
                SongBrowser.RefreshList();
                this.EnterFile();
            };

            MusicReload.MouseDown += delegate(object sender, MouseEventArgs e) {
                if (e.Button == MouseButtons.Middle)
                {
                    string dir  = Path.GetDirectoryName(Application.ExecutablePath);
                    string path = Path.Combine(dir, Properties.Settings.Default.SongDirectory);
                    if (Directory.Exists(path))
                    {
                        Process.Start(path);
                    }
                }
            };

            SelectorSong.GotFocus += delegate(object sender, EventArgs e) {
                if (!SongBrowserVisible)
                {
                    SongBrowserVisible = true;
                }
            };
            SelectorSong.LostFocus += delegate(object sender, EventArgs e) {
                if (!SongBrowser.Focused)
                {
                    SongBrowserVisible = false;
                }
            };

            SongBrowser.LostFocus += delegate(object sender, EventArgs e) {
                if (!SelectorSong.Focused && !SelectorTrack.Focused && !MusicReload.Focused)
                {
                    SongBrowserVisible = false;
                }
            };
            SongBrowser.MouseWheel += delegate(object sender, MouseEventArgs e) {
                BmpBrowser browser = (sender as BmpBrowser);
                if (browser != null)
                {
                    if (e.Delta > 0)
                    {
                        browser.PreviousFile();
                    }
                    else
                    {
                        browser.NextFile();
                    }
                    ((HandledMouseEventArgs)e).Handled = true;
                }
            };
            SelectorSong.OnHandledKeyDown += delegate(object sender, KeyEventArgs e) {
                switch (e.KeyCode)
                {
                case Keys.Up: {
                    SongBrowser.PreviousFile();
                    break;
                }

                case Keys.Down: {
                    SongBrowser.NextFile();
                    break;
                }

                case Keys.PageUp: {
                    SongBrowser.PreviousFile(5);
                    break;
                }

                case Keys.PageDown: {
                    SongBrowser.NextFile(5);
                    break;
                }

                case Keys.Enter: {
                    if (!SongBrowserVisible)
                    {
                        SongBrowserVisible = true;
                    }
                    else
                    {
                        SongBrowser.EnterFile();
                        SelectorTrack.Focus();
                    }
                    break;
                }

                case Keys.Tab:
                case Keys.Escape: {
                    SongBrowserVisible = false;
                    SelectorTrack.Focus();
                    e.Handled = true;
                    break;
                }
                }
            };
            SelectorTrack.KeyDown += delegate(object sender, KeyEventArgs e) {
                switch (e.KeyCode)
                {
                case Keys.Enter: {
                    SelectorSong.Focus();
                    e.Handled          = true;
                    e.SuppressKeyPress = true;
                    break;
                }

                case Keys.Escape: {
                    break;
                }
                }
            };

            SelectorSong.OnTextChange += delegate(object sender, string text) {
                SongBrowser.FilenameFilter = text;
                SongBrowser.RefreshList();
            };
        }
Esempio n. 7
0
 public void EnterFile()
 {
     SongBrowser.Invoke(t => t.EnterFile());
 }
Esempio n. 8
0
 public bool SelectFile(string file)
 {
     return(SongBrowser.SelectFile(file));
 }