Esempio n. 1
0
        private static void _DrawDebugInfos()
        {
            if (CConfig.Config.Debug.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
            {
                return;
            }

            List <String> debugOutput = new List <string> {
                CTime.GetFPS().ToString("FPS: 000")
            };

            if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
            {
                debugOutput.Add(CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00"));
                debugOutput.Add(CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00"));
                debugOutput.Add(CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000"));
                long memory = GC.GetTotalMemory(false);
                debugOutput.Add((memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB"));

                if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
                {
                    debugOutput.Add(CRecord.GetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
                    debugOutput.Add(CRecord.GetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
                    debugOutput.Add(CRecord.GetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
                    debugOutput.Add(CRecord.GetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));

                    if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
                    {
                        debugOutput.Add(CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"));

                        if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX)
                        {
                            debugOutput.Add(_Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)"));
                        }
                    }
                }
            }
            CFont   font = new CFont("Normal", EStyle.Normal, 25);
            SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
            float   y    = 0;

            foreach (string txt in debugOutput)
            {
                float      textWidth = CFonts.GetTextWidth(txt, font);
                RectangleF rect      = new RectangleF(CSettings.RenderW - textWidth, y, textWidth, CFonts.GetTextHeight(txt, font));
                CDraw.DrawRect(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
                CFonts.DrawText(txt, font, rect.X, rect.Y, CSettings.ZNear);
                y += rect.Height;
            }
        }
Esempio n. 2
0
        public static string GetPlayerName(Guid profileID, int playerNum = 0)
        {
            if (IsProfileIDValid(profileID))
            {
                return(_Profiles[profileID].PlayerName);
            }

            string playerName = CLanguage.Translate("TR_SCREENNAMES_PLAYER");

            if (playerNum > 0)
            {
                playerName += " " + playerNum;
            }
            return(playerName);
        }
Esempio n. 3
0
        private static string _GetNoCategoryName()
        {
            string noCategoryName;

            switch (CSongs.Sorter.SongSorting)
            {
            case ESongSorting.TR_CONFIG_FOLDER:
            case ESongSorting.TR_CONFIG_NONE:
                noCategoryName = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
                break;

            case ESongSorting.TR_CONFIG_ARTIST:
            case ESongSorting.TR_CONFIG_ARTIST_LETTER:
            case ESongSorting.TR_CONFIG_TITLE_LETTER:
                noCategoryName = "";
                Debug.Assert(false, "Should not have an uncategorized song");
                break;

            case ESongSorting.TR_CONFIG_EDITION:
                noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
                break;

            case ESongSorting.TR_CONFIG_GENRE:
                noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
                break;

            case ESongSorting.TR_CONFIG_LANGUAGE:
                noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
                break;

            case ESongSorting.TR_CONFIG_DECADE:
            case ESongSorting.TR_CONFIG_YEAR:
                noCategoryName = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
                break;

            case ESongSorting.TR_CONFIG_DATEADDED:
                noCategoryName = "";
                Debug.Assert(false, "Should not have an uncategorized song");
                break;

            default:
                noCategoryName = "";
                Debug.Assert(false, "Forgot category option");
                break;
            }
            return(noCategoryName);
        }
Esempio n. 4
0
        public Bitmap GetCover(string text, string firstCoverPath)
        {
            if (!_Valid)
            {
                return(null);
            }
            text = CLanguage.Translate(_Theme.Text.Text.Replace("%TEXT%", text));
            using (Bitmap bmpImage = new Bitmap(_Image))
            {
                Bitmap bmp = new Bitmap(bmpImage.Width, bmpImage.Height, PixelFormat.Format32bppArgb);
                try
                {
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        g.SmoothingMode     = SmoothingMode.AntiAlias;
                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        g.TextRenderingHint = TextRenderingHint.AntiAlias;

                        _DrawBackground(g, bmpImage, firstCoverPath);

                        if (text != "")
                        {
                            CFont font = new CFont(_Theme.Text.Font);
                            Font  fo   = CFonts.GetSystemFont(font);
                            IEnumerable <string> textParts = _SplitText(text);
                            List <CTextElement>  elements  = textParts.Select(line => new CTextElement(line, g, fo)).ToList();
                            float factor = _DistributeText(elements, bmp.Width, bmp.Height);
                            foreach (CTextElement element in elements)
                            {
                                element.AdjustSize(factor);
                            }
                            font.Height *= factor / (1f + CFonts.GetOutlineSize(font)); //Adjust for outline size
                            _DrawText(g, bmp.GetSize(), font, elements);
                        }
                    }
                    return(bmp);
                }
                catch (Exception)
                {
                    bmp.Dispose();
                }
            }
            return(null);
        }
Esempio n. 5
0
        private static void _Sort(ESongSorting sorting, EOffOn Tabs, string SearchString)
        {
            if (_Songs.Count == 0)
            {
                return;
            }

            _Categories.Clear();
            string category = String.Empty;

            _Tabs = Tabs;

            List <SongPointer> _SortList = new List <SongPointer>();
            List <CSong>       _SongList = new List <CSong>();

            foreach (CSong song in _Songs)
            {
                if (SearchString == String.Empty)
                {
                    _SongList.Add(song);
                }
                else
                {
                    if (song.Title.ToUpper().Contains(SearchString.ToUpper()) || song.Artist.ToUpper().Contains(SearchString.ToUpper()))
                    {
                        _SongList.Add(song);
                    }
                }
            }

            switch (sorting)
            {
            case ESongSorting.TR_CONFIG_EDITION:
                foreach (CSong song in _SongList)
                {
                    if (song.Edition.Count == 0)
                    {
                        _SortList.Add(new SongPointer(song.ID, String.Empty));
                    }
                    else
                    {
                        for (int i = 0; i < song.Edition.Count; i++)
                        {
                            _SortList.Add(new SongPointer(song.ID, song.Edition[i]));
                        }
                    }
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString.Length > 0)
                    {
                        if (_SongsSortList[i].SortString != category)
                        {
                            category = _SongsSortList[i].SortString;
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                    else
                    {
                        if (CLanguage.Translate("TR_SCREENSONG_NOEDITION") != category)
                        {
                            category = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_GENRE:
                foreach (CSong song in _SongList)
                {
                    if (song.Genre.Count == 0)
                    {
                        _SortList.Add(new SongPointer(song.ID, String.Empty));
                    }
                    else
                    {
                        for (int i = 0; i < song.Genre.Count; i++)
                        {
                            _SortList.Add(new SongPointer(song.ID, song.Genre[i]));
                        }
                    }
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString.Length > 0)
                    {
                        if (_SongsSortList[i].SortString != category)
                        {
                            category = _SongsSortList[i].SortString;
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                    else
                    {
                        if (CLanguage.Translate("TR_SCREENSONG_NOGENRE") != category)
                        {
                            category = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_NONE:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, String.Empty));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    _SongsSortList[i].CatIndex = 0;
                }
                category = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
                _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                break;

            case ESongSorting.TR_CONFIG_FOLDER:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.FolderName));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString != category)
                    {
                        category = _SongsSortList[i].SortString;
                        _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                    }
                    _SongsSortList[i].CatIndex = _Categories.Count - 1;
                }
                break;

            case ESongSorting.TR_CONFIG_ARTIST:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.Artist));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString != category)
                    {
                        category = _SongsSortList[i].SortString;
                        _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                    }
                    _SongsSortList[i].CatIndex = _Categories.Count - 1;
                }
                break;

            case ESongSorting.TR_CONFIG_ARTIST_LETTER:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.Artist));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();

                int NotLetterCat = -1;
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString[0]);

                    if (!Char.IsLetter(firstLetter))
                    {
                        firstLetter = '#';
                    }
                    if (firstLetter.ToString() != category)
                    {
                        if (firstLetter != '#' || NotLetterCat == -1)
                        {
                            category = firstLetter.ToString();
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));

                            _SongsSortList[i].CatIndex = _Categories.Count - 1;

                            if (firstLetter == '#')
                            {
                                NotLetterCat = _SongsSortList[i].CatIndex;
                            }
                        }
                        else
                        {
                            _SongsSortList[i].CatIndex = NotLetterCat;
                        }
                    }
                    else
                    {
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_TITLE_LETTER:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.Title));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
                    if (res == 0)
                    {
                        return(_Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()));
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();

                NotLetterCat = -1;
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString[0]);

                    if (!Char.IsLetter(firstLetter))
                    {
                        firstLetter = '#';
                    }
                    if (firstLetter.ToString() != category)
                    {
                        if (firstLetter != '#' || NotLetterCat == -1)
                        {
                            category = firstLetter.ToString();
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));

                            _SongsSortList[i].CatIndex = _Categories.Count - 1;

                            if (firstLetter == '#')
                            {
                                NotLetterCat = _SongsSortList[i].CatIndex;
                            }
                        }
                        else
                        {
                            _SongsSortList[i].CatIndex = NotLetterCat;
                        }
                    }
                    else
                    {
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_DECADE:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.Year));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.CompareTo(s2.SortString);
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000"))
                    {
                        String decade = _SongsSortList[i].SortString.Substring(0, 3) + "0 - " + _SongsSortList[i].SortString.Substring(0, 3) + "9";
                        if (decade != category)
                        {
                            category = decade;
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                    else
                    {
                        if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category)
                        {
                            category = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_YEAR:
                foreach (CSong song in _SongList)
                {
                    _SortList.Add(new SongPointer(song.ID, song.Year));
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.CompareTo(s2.SortString);
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000"))
                    {
                        if (_SongsSortList[i].SortString != category)
                        {
                            category = _SongsSortList[i].SortString;
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                    else
                    {
                        if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category)
                        {
                            category = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            case ESongSorting.TR_CONFIG_LANGUAGE:
                foreach (CSong song in _SongList)
                {
                    if (song.Language.Count == 0)
                    {
                        _SortList.Add(new SongPointer(song.ID, String.Empty));
                    }
                    else
                    {
                        for (int i = 0; i < song.Language.Count; i++)
                        {
                            _SortList.Add(new SongPointer(song.ID, song.Language[i]));
                        }
                    }
                }

                _SortList.Sort(delegate(SongPointer s1, SongPointer s2)
                {
                    int res = s1.SortString.CompareTo(s2.SortString);
                    if (res == 0)
                    {
                        res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
                        if (res == 0)
                        {
                            return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper()));
                        }
                        return(res);
                    }
                    return(res);
                });

                _SongsSortList = _SortList.ToArray();
                _Categories.Clear();
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    if (_SongsSortList[i].SortString.Length > 0)
                    {
                        if (_SongsSortList[i].SortString != category)
                        {
                            category = _SongsSortList[i].SortString;
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                    else
                    {
                        if (CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE") != category)
                        {
                            category = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
                            _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
                        }
                        _SongsSortList[i].CatIndex = _Categories.Count - 1;
                    }
                }
                break;

            default:
                break;
            }


            if (_Tabs == EOffOn.TR_CONFIG_OFF)
            {
                _Categories.Clear();
                _Categories.Add(new CCategory("", new STexture(-1), new STexture(-1)));
                for (int i = 0; i < _SongsSortList.Length; i++)
                {
                    _SongsSortList[i].CatIndex = 0;
                }
            }

            foreach (CCategory cat in _Categories)
            {
                STexture cover = CCover.Cover(cat.Name);
                cat.CoverTextureSmall = cover;
            }
        }
Esempio n. 6
0
 public string Translate(string keyWord, int partyModeID)
 {
     return(CLanguage.Translate(keyWord, partyModeID));
 }
Esempio n. 7
0
 public string Translate(string keyWord)
 {
     return(CLanguage.Translate(keyWord));
 }
Esempio n. 8
0
 public static RectangleF GetTextBounds(CText text, float height)
 {
     Height = height;
     return(new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text)), GetTextHeight(CLanguage.Translate(text.Text))));
 }