aboutsummaryrefslogtreecommitdiffstats
path: root/Medley
diff options
context:
space:
mode:
authorbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-14 20:46:20 +0000
committerbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-14 20:46:20 +0000
commit11facb268ba723b56279638a64c1c4327d9293bb (patch)
tree100688c30c84d5b61c72e9285c7371d6391740d8 /Medley
parentf403503f628be80a67c53e1309480748b4c10d04 (diff)
downloadusdx-11facb268ba723b56279638a64c1c4327d9293bb.tar.gz
usdx-11facb268ba723b56279638a64c1c4327d9293bb.tar.xz
usdx-11facb268ba723b56279638a64c1c4327d9293bb.zip
- SelectPlayers after songselect works now for medley-mode too
- moved medley-tags into txt: #MedleyStartBeat, #MedleyEndBeat - left *.txtm and the FadeIn and FadeOut tags, but they are from now on deprecated - new tag: #PREVIEWSTART - fallback for #PREVIEWSTART: 1. MedleyStart, 2. calculated medleystart, 3. 25%-rule :> git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2034 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Medley')
-rw-r--r--Medley/game/themes/Deluxe.ini2
-rw-r--r--Medley/src/base/USong.pas98
-rw-r--r--Medley/src/base/USongs.pas27
-rw-r--r--Medley/src/screens/UScreenSong.pas22
4 files changed, 112 insertions, 37 deletions
diff --git a/Medley/game/themes/Deluxe.ini b/Medley/game/themes/Deluxe.ini
index d7ac8adb..b9bbc747 100644
--- a/Medley/game/themes/Deluxe.ini
+++ b/Medley/game/themes/Deluxe.ini
@@ -996,7 +996,7 @@ X = 5
Y = 3
W = 790
H = 34
-Tex = Button
+Tex = Leiste2
Color = White
Type = Transparen
diff --git a/Medley/src/base/USong.pas b/Medley/src/base/USong.pas
index 4bc10cf1..38ddaaf6 100644
--- a/Medley/src/base/USong.pas
+++ b/Medley/src/base/USong.pas
@@ -94,10 +94,10 @@ type
Source: TMedleySource; //source of the information
StartBeat: integer; //start beat of medley
EndBeat: integer; //end beat of medley
- FadeIn: integer; //start beat of fadein
- FadeOut: integer; //end beat of fadeout
+ FadeIn: integer; //start beat of fadein deprecated!
+ FadeOut: integer; //end beat of fadeout deprecated!
FadeIn_time: real; //FadeIn-Time in seconds
- FadeOut_time: real; //FadeIn-Time in seconds
+ FadeOut_time: real; //FadeOut-Time in seconds
end;
TSong = class
@@ -155,6 +155,8 @@ type
Encoding: TEncoding;
+ PreviewStart: real; //in seconds
+
CustomTags: array of TCustomHeaderTag;
Score: array[0..2] of array of TScore;
@@ -188,7 +190,7 @@ type
procedure Clear();
procedure FindRefrainStart;
procedure SetMedleyMode;
- function ReadMedleyFile(MedleyFilePath: IPath): boolean;
+ function ReadMedleyFile(MedleyFilePath: IPath): boolean; //deprecated!
end;
implementation
@@ -612,7 +614,6 @@ begin
Lines[Count].Line[High(Lines[Count].Line)].LastLine := true;
end;
Result := true;
- FindRefrainStart;
end;
//Load XML Song
@@ -877,6 +878,7 @@ var
Value: string;
SepPos: integer; // separator position
Done: byte; // bit-vector of mandatory fields
+ MedleyFlags: byte; //bit-vector for medley/preview tags
EncFile: IPath; // encoded filename
FullFileName: string;
@@ -897,6 +899,7 @@ var
begin
Result := true;
Done := 0;
+ MedleyFlags := 0;
FullFileName := Path.Append(Filename).ToNative;
@@ -1100,6 +1103,27 @@ begin
self.Encoding := ParseEncoding(Value, DEFAULT_ENCODING);
end
+ // PreviewStart
+ else if (Identifier = 'PREVIEWSTART') then
+ begin
+ self.PreviewStart := StrToFloatI18n( Value );
+ MedleyFlags := MedleyFlags or 1;
+ end
+
+ // MedleyStartBeat
+ else if (Identifier = 'MEDLEYSTARTBEAT') then
+ begin
+ if TryStrtoInt(Value, self.Medley.StartBeat) then
+ MedleyFlags := MedleyFlags or 2;
+ end
+
+ // MedleyEndBeat
+ else if (Identifier = 'MEDLEYENDBEAT') then
+ begin
+ if TryStrtoInt(Value, self.Medley.EndBeat) then
+ MedleyFlags := MedleyFlags or 4;
+ end
+
// unsupported tag
else
begin
@@ -1134,6 +1158,36 @@ begin
Log.LogError('Title tag missing: ' + FullFileName)
else //unknown Error
Log.LogError('File incomplete or not Ultrastar txt (B - '+ inttostr(Done) +'): ' + FullFileName);
+ end else
+ begin //check medley tags
+ if (MedleyFlags and 6)=6 then //MedleyStartBeat and MedleyEndBeat are both set
+ begin
+ if Medley.StartBeat >= Medley.EndBeat then
+ MedleyFlags := MedleyFlags - 6;
+ end;
+
+ CurrentSong := self;
+
+ if ((MedleyFlags and 1)=0) or (self.PreviewStart<=0) then //PreviewStart is not set or <=0
+ begin
+ if (MedleyFlags and 2)=2 then
+ self.PreviewStart := GetTimeFromBeat(CurrentSong.Medley.StartBeat) //fallback to MedleyStart
+ else
+ self.PreviewStart := 0; //else set it to 0, it will be set in FindRefrainStart
+ end;
+
+ if (MedleyFlags and 6)=6 then
+ begin
+ self.Medley.Source := msTag;
+
+ //calculate fade time
+ self.Medley.FadeIn_time := GetTimeFromBeat(CurrentSong.Medley.StartBeat) -
+ DEFAULT_FADE_IN_TIME;
+
+ self.Medley.FadeOut_time := GetTimeFromBeat(CurrentSong.Medley.FadeOut) -
+ DEFAULT_FADE_OUT_TIME;
+ end else
+ self.Medley.Source := msNone;
end;
end;
@@ -1385,7 +1439,7 @@ var
len_lines, len_notes: integer;
found_end: boolean;
begin
- if Medley.Source = msTag then
+ if Medley.Source = msTag then //will be deleted soon
Exit;
num_lines := Length(Lines[0].Line);
@@ -1443,6 +1497,8 @@ begin
end;
end;
+ len_lines := length(Lines[0].Line);
+
if (Length(series)>0) and (series[max].len > 3) then
begin
Medley.StartBeat := Lines[0].Line[series[max].start].Note[0].Start;
@@ -1464,7 +1520,6 @@ begin
//ahead an set to a line end (if possible)
if not found_end then
begin
- len_lines := length(Lines[0].Line);
for I := series[max].start+1 to len_lines-1 do
begin
len_notes := length(Lines[0].Line[I].Note);
@@ -1491,13 +1546,21 @@ begin
Medley.FadeOut := Medley.EndBeat + round(GetMidBeat(DEFAULT_FADE_OUT_TIME));
//calculate fade time
-
Medley.FadeIn_time := GetTimeFromBeat(Medley.StartBeat) - GetTimeFromBeat(Medley.FadeIn);
Medley.FadeOut_time := GetTimeFromBeat(Medley.FadeOut) - GetTimeFromBeat(Medley.EndBeat);
- end else
- Medley.Source := msNone;
- end else
- Medley.Source := msNone;
+ end;
+ end;
+
+ //set PreviewStart if not set
+ if PreviewStart=0 then
+ begin
+ len_notes := length(Lines[0].Line[len_lines-1].Note);
+ if Medley.Source = msCalculated then
+ PreviewStart := GetTimeFromBeat(Medley.StartBeat)
+ else
+ PreviewStart := (GetTimeFromBeat(Lines[0].Line[len_lines-1].Note[len_notes-1].start+
+ Lines[0].Line[len_lines-1].Note[len_notes-1].length))/4;
+ end;
end;
//sets a song to medley-mod:
@@ -1539,11 +1602,7 @@ begin
end;
//reads the txtm
-//TODO move this to ReadTXTHeader and implement the MEDLEY-TAGS in txt-file:
-//conversion: START-> MEDLEY_START
-// END-> MEDLEY_END
-// FADE_IN -> MEDLEY_FADE_IN
-// FADE_OUT-> MEDLEY_FADE_OUT
+//whole function is deprecated
//TODO: write a tool to convert existing txtm
function TSong.ReadMedleyFile(MedleyFilePath: IPath): boolean;
var
@@ -1700,11 +1759,14 @@ begin
end;
//calculate fade time
-
self.Medley.FadeIn_time := GetTimeFromBeat(CurrentSong.Medley.StartBeat) -
GetTimeFromBeat(CurrentSong.Medley.FadeIn);
self.Medley.FadeOut_time := GetTimeFromBeat(CurrentSong.Medley.FadeOut) -
GetTimeFromBeat(CurrentSong.Medley.EndBeat);
+
+ //set PreviewStart
+ if self.PreviewStart<=0 then //PreviewStart is not set or <=0
+ self.PreviewStart := GetTimeFromBeat(CurrentSong.Medley.StartBeat); //fallback to MedleyStart
end;
end;
diff --git a/Medley/src/base/USongs.pas b/Medley/src/base/USongs.pas
index af7f7a16..d0c7fe0a 100644
--- a/Medley/src/base/USongs.pas
+++ b/Medley/src/base/USongs.pas
@@ -312,31 +312,38 @@ var
Files: TPathDynArray;
Song: TSong;
Extension: IPath;
- MedleyFiles: TPathDynArray;
- MedleyExtension: IPath;
+ MedleyFiles: TPathDynArray; //will be deleted soon!
+ MedleyExtension: IPath; //will be deleted soon!
begin
SetLength(Files, 0);
Extension := Path('.txt');
- MedleyExtension := Path('.txtm');
+ MedleyExtension := Path('.txtm'); //will be deleted soon!
FindFilesByExtension(Dir, Extension, true, Files);
for I := 0 to High(Files) do
begin
Song := TSong.Create(Files[I]);
-
+ Song.Medley.Source := msNone; //will be deleted soon!
if Song.Analyse then
begin
- //medley support... TODO: move it (see USong...)
- SetLength(MedleyFiles, 0);
- FindFilesByExtension(Files[I].GetPath, MedleyExtension, true, MedleyFiles);
-
- if Length(MedleyFiles)>0 then
+ //TODO: delete it to deactivate *.txtm support (see USong...)
+ if Song.Medley.Source = msNone then
begin
- Song.ReadMedleyFile(MedleyFiles[0]);
+ SetLength(MedleyFiles, 0);
+ FindFilesByExtension(Files[I].GetPath, MedleyExtension, true, MedleyFiles);
+
+ if Length(MedleyFiles)>0 then
+ begin
+ Song.ReadMedleyFile(MedleyFiles[0]);
+ end;
end;
+ //medley support
+ if Song.Medley.Source = msNone then
+ Song.FindRefrainStart;
+
SongList.Add(Song);
end else
begin
diff --git a/Medley/src/screens/UScreenSong.pas b/Medley/src/screens/UScreenSong.pas
index c89193a8..421c392a 100644
--- a/Medley/src/screens/UScreenSong.pas
+++ b/Medley/src/screens/UScreenSong.pas
@@ -1774,13 +1774,7 @@ begin
if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then
begin
PreviewOpened := Interaction;
-
- if Song.Medley.Source <> msNone then
- begin
- CurrentSong := Song;
- AudioPlayback.Position := GetTimeFromBeat(Song.Medley.StartBeat);
- end else
- AudioPlayback.Position := AudioPlayback.Length / 4;
+ AudioPlayback.Position := Song.PreviewStart;
// set preview volume
if (Ini.PreviewFading = 0) then
@@ -1941,7 +1935,19 @@ begin
PlaylistMedley.Song[0] := Interaction;
PlaylistMedley.NumMedleySongs := 1;
end;
- FadeTo(@ScreenSing);
+
+ //TODO: how about case 2? menu for medley mode?
+ case Ini.OnSongClick of
+ 0: FadeTo(@ScreenSing);
+ 1: SelectPlayers;
+ 2: FadeTo(@ScreenSing);
+ {2: begin
+ if (CatSongs.CatNumShow = -3) then
+ ScreenSongMenu.MenuShow(SM_Playlist)
+ else
+ ScreenSongMenu.MenuShow(SM_Main);
+ end;}
+ end;
end;
procedure TScreenSong.SkipTo(Target: cardinal);