From df0a8e7c62a4006ea7ac66ad7c0745a48a32ef24 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 17 Nov 2009 16:21:03 +0000 Subject: implemented suggestions by Canni from Assembla ticket #85 artist sorting replaced by artist2 title sorting replaced by title2 new sorting artist2 (suggestions for a better name?!) all songs by the same artist are put into the same category named by the artist git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1945 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UCatCovers.pas | 4 +-- src/base/UIni.pas | 10 +++----- src/base/USongs.pas | 68 ++++++++++++++++++++----------------------------- 3 files changed, 33 insertions(+), 49 deletions(-) diff --git a/src/base/UCatCovers.pas b/src/base/UCatCovers.pas index 6e004b22..d33bbbe1 100644 --- a/src/base/UCatCovers.pas +++ b/src/base/UCatCovers.pas @@ -134,9 +134,9 @@ begin for I := 0 to high(ISorting) do begin TmpName := Name; - if ((I = sTitle) or (I = sTitle2)) and (UTF8Pos('Title', TmpName) <> 0) then + if (I = sTitle) and (UTF8Pos('Title', TmpName) <> 0) then UTF8Delete(TmpName, UTF8Pos('Title', TmpName), 5) - else if (I = sArtist) or (I = sArtist2) and (UTF8Pos('Artist', TmpName) <> 0) then + else if (I = sArtist) and (UTF8Pos('Artist', TmpName) <> 0) then UTF8Delete(TmpName, UTF8Pos('Artist', TmpName), 6); if not CoverExists(I, TmpName) then diff --git a/src/base/UIni.pas b/src/base/UIni.pas index a3bc1876..284389c2 100644 --- a/src/base/UIni.pas +++ b/src/base/UIni.pas @@ -179,15 +179,14 @@ const IDifficulty: array[0..2] of UTF8String = ('Easy', 'Medium', 'Hard'); ITabs: array[0..1] of UTF8String = ('Off', 'On'); - ISorting: array[0..7] of UTF8String = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Title2', 'Artist2'); + ISorting: array[0..6] of UTF8String = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Artist2'); sEdition = 0; sGenre = 1; sLanguage = 2; sFolder = 3; sTitle = 4; sArtist = 5; - sTitle2 = 6; - sArtist2 = 7; + sArtist2 = 6; IDebug: array[0..1] of UTF8String = ('Off', 'On'); @@ -261,7 +260,7 @@ var IDifficultyTranslated: array[0..2] of UTF8String = ('Easy', 'Medium', 'Hard'); ITabsTranslated: array[0..1] of UTF8String = ('Off', 'On'); - ISortingTranslated: array[0..7] of UTF8String = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Title2', 'Artist2'); + ISortingTranslated: array[0..6] of UTF8String = ('Edition', 'Genre', 'Language', 'Folder', 'Title', 'Artist', 'Artist2'); IDebugTranslated: array[0..1] of UTF8String = ('Off', 'On'); @@ -364,8 +363,7 @@ begin ISortingTranslated[3] := ULanguage.Language.Translate('OPTION_VALUE_FOLDER'); ISortingTranslated[4] := ULanguage.Language.Translate('OPTION_VALUE_TITLE'); ISortingTranslated[5] := ULanguage.Language.Translate('OPTION_VALUE_ARTIST'); - ISortingTranslated[6] := ULanguage.Language.Translate('OPTION_VALUE_TITLE2'); - ISortingTranslated[7] := ULanguage.Language.Translate('OPTION_VALUE_ARTIST2'); + ISortingTranslated[6] := ULanguage.Language.Translate('OPTION_VALUE_ARTIST2'); IDebugTranslated[0] := ULanguage.Language.Translate('OPTION_VALUE_OFF'); IDebugTranslated[1] := ULanguage.Language.Translate('OPTION_VALUE_ON'); diff --git a/src/base/USongs.pas b/src/base/USongs.pas index 49b84425..d3018bcf 100644 --- a/src/base/USongs.pas +++ b/src/base/USongs.pas @@ -410,8 +410,6 @@ begin CompareFunc := CompareByArtist; sFolder: // by folder CompareFunc := CompareByFolder; - sTitle2: // by title2 - CompareFunc := CompareByTitle; sArtist2: // by artist2 CompareFunc := CompareByArtist; sLanguage: // by Language @@ -458,12 +456,8 @@ begin Songs.Sort(sTitle); Songs.Sort(sArtist); end; - sTitle2: begin - Songs.Sort(sArtist2); - Songs.Sort(sTitle2); - end; sArtist2: begin - Songs.Sort(sTitle2); + Songs.Sort(sTitle); Songs.Sort(sArtist2); end; end; // case @@ -567,6 +561,15 @@ begin if (Length(CurSong.Title) >= 1) then begin LetterTmp := UCS4UpperCase(UTF8ToUCS4String(CurSong.Title)[0]); + { all numbers and some punctuation chars are put into a + category named '#' + we can't put the other punctuation chars into this category + because they are not in order, so there will be two different + categories named '#' } + if (LetterTmp in [Ord('!') .. Ord('?')]) then + LetterTmp := Ord('#') + else + LetterTmp := UCS4UpperCase(LetterTmp); if (Letter <> LetterTmp) then begin Letter := LetterTmp; @@ -580,6 +583,16 @@ begin if (Length(CurSong.Artist) >= 1) then begin LetterTmp := UCS4UpperCase(UTF8ToUCS4String(CurSong.Artist)[0]); + { all numbers and some punctuation chars are put into a + category named '#' + we can't put the other punctuation chars into this category + because they are not in order, so there will be two different + categories named '#' } + if (LetterTmp in [Ord('!') .. Ord('?')]) then + LetterTmp := Ord('#') + else + LetterTmp := UCS4UpperCase(LetterTmp); + if (Letter <> LetterTmp) then begin Letter := LetterTmp; @@ -598,44 +611,17 @@ begin end; end; - sTitle2: begin - if (Length(CurSong.Title) >= 1) then - begin - LetterTmp := UTF8ToUCS4String(CurSong.Title)[0]; - // pack all numbers into a category named '#' - if (LetterTmp in [Ord('0') .. Ord('9')]) then - LetterTmp := Ord('#') - else - LetterTmp := UCS4UpperCase(LetterTmp); - - if (Letter <> LetterTmp) then - begin - Letter := LetterTmp; - // add a letter Category Button - AddCategoryButton(UCS4ToUTF8String(Letter)); - end; - end; - end; - sArtist2: begin - if (Length(CurSong.Artist) >= 1) then + { this new sorting puts all songs by the same artist into + a single category } + if (UTF8CompareText(CurCategory, CurSong.Artist) <> 0) then begin - LetterTmp := UTF8ToUCS4String(CurSong.Artist)[0]; - // pack all numbers into a category named '#' - if (LetterTmp in [Ord('0') .. Ord('9')]) then - LetterTmp := Ord('#') - else - LetterTmp := UCS4UpperCase(LetterTmp); - - if (Letter <> LetterTmp) then - begin - Letter := LetterTmp; - // add a letter Category Button - AddCategoryButton(UCS4ToUTF8String(Letter)); - end; + CurCategory := CurSong.Artist; + // add folder tab + AddCategoryButton(CurCategory); end; end; - + end; // case (Ini.Sorting) end; // if (Ini.Tabs = 1) -- cgit v1.2.3