aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-10 20:50:23 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-10 20:50:23 +0000
commit786adb9a238a6e8a4e49b16f691a926c265da232 (patch)
treed5c9994ea76f3491cdd9fc55397475f416f98d29
parent1f8df8ece71d733129886f0ee3f695c2c1db4c26 (diff)
downloadusdx-786adb9a238a6e8a4e49b16f691a926c265da232.tar.gz
usdx-786adb9a238a6e8a4e49b16f691a926c265da232.tar.xz
usdx-786adb9a238a6e8a4e49b16f691a926c265da232.zip
folder sorting w/ cats on fixed (ticket #84)
it works good for the moment, but it should be changed when we support nested categories. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1631 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--src/base/USong.pas41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/base/USong.pas b/src/base/USong.pas
index 1197f3be..57f78a27 100644
--- a/src/base/USong.pas
+++ b/src/base/USong.pas
@@ -146,8 +146,10 @@ type
implementation
uses
+ StrUtils,
TextGL,
UIni,
+ UPath,
UMusic, //needed for Lines
UNote; //needed for Player
@@ -156,7 +158,42 @@ begin
inherited;
end;
-constructor TSong.Create( const aFileName : WideString );
+constructor TSong.Create( const aFileName: WideString );
+ // This may be changed, when we rewrite song select code.
+ // it is some kind of dirty, but imho the best possible
+ // solution as we do atm not support nested categorys.
+ // it works like the folder sorting in 1.0.1a
+ // folder is set to the first folder under the songdir
+ // so songs ~/.ultrastardx/songs/punk is in the same
+ // category as songs in shared/ultrastardx/songs are.
+ // note: folder is just the name of a category it has
+ // nothing to do with the path used for file loading
+ function GetFolderCategory: WideString;
+ var
+ I: Integer;
+ P: Integer; //position of next path delimiter
+ begin
+ Result := 'Unknown'; //default folder category, if we can't locate the song dir
+
+ for I := 0 to SongPaths.Count-1 do
+ if (AnsiStartsText(SongPaths.Strings[I], aFilename)) then
+ begin
+ P := PosEx(PathDelim, aFilename, Length(SongPaths.Strings[I]) + 1);
+
+ If (P > 0) then
+ begin
+ // we have found the category name => get it
+ Result := copy(self.Path, Length(SongPaths.Strings[I]) + 1, P - Length(SongPaths.Strings[I]) - 1);
+ end
+ else
+ begin
+ // songs are in the "root" of the songdir => use songdir for the categorys name
+ Result := SongPaths.Strings[I];
+ end;
+
+ Exit;
+ end;
+ end;
begin
inherited Create();
@@ -169,7 +206,7 @@ begin
if fileexists( aFileName ) then
begin
self.Path := ExtractFilePath( aFileName );
- self.Folder := ExtractFilePath( aFileName );
+ self.Folder := GetFolderCategory;
self.FileName := ExtractFileName( aFileName );
(*
if ReadTXTHeader( aFileName ) then