aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/UFiles.pas
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-08-27 15:00:10 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-08-27 15:00:10 +0000
commit9506a3ab6ae1b5c51eec2ccb8773eb4219766e7d (patch)
treeb65ae0f889de664651dddabee852908f191eac07 /src/classes/UFiles.pas
parent16a6e6801fde495b2782e2e04a0cf055ce1e1516 (diff)
downloadusdx-9506a3ab6ae1b5c51eec2ccb8773eb4219766e7d.tar.gz
usdx-9506a3ab6ae1b5c51eec2ccb8773eb4219766e7d.tar.xz
usdx-9506a3ab6ae1b5c51eec2ccb8773eb4219766e7d.zip
rename Classes part2
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1308 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/classes/UFiles.pas')
-rw-r--r--src/classes/UFiles.pas150
1 files changed, 150 insertions, 0 deletions
diff --git a/src/classes/UFiles.pas b/src/classes/UFiles.pas
new file mode 100644
index 00000000..ca43bb21
--- /dev/null
+++ b/src/classes/UFiles.pas
@@ -0,0 +1,150 @@
+unit UFiles;
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+{$I switches.inc}
+
+uses SysUtils,
+ ULog,
+ UMusic,
+ USongs,
+ USong;
+
+procedure ResetSingTemp;
+function SaveSong(Song: TSong; Lines: TLines; Name: string; Relative: boolean): boolean;
+
+var
+ SongFile: TextFile; // all procedures in this unit operates on this file
+ FileLineNo: integer; //Line which is readed at Last, for error reporting
+
+ // variables available for all procedures
+ Base : array[0..1] of integer;
+ Rel : array[0..1] of integer;
+ Mult : integer = 1;
+ MultBPM : integer = 4;
+
+implementation
+
+uses TextGL,
+ UIni,
+ UPlatform,
+ UMain;
+
+//--------------------
+// Resets the temporary Sentence Arrays for each Player and some other Variables
+//--------------------
+procedure ResetSingTemp;
+var
+ Count: integer;
+begin
+ SetLength(Lines, Length(Player));
+ for Count := 0 to High(Player) do begin
+ SetLength(Lines[Count].Line, 1);
+ SetLength(Lines[Count].Line[0].Note, 0);
+ Lines[Count].Line[0].Lyric := '';
+ Lines[Count].Line[0].LyricWidth := 0;
+ Player[Count].Score := 0;
+ Player[Count].LengthNote := 0;
+ Player[Count].HighNote := -1;
+ end;
+
+ (* FIXME
+ //Reset Path and Filename Values to Prevent Errors in Editor
+ if assigned( CurrentSong ) then
+ begin
+ SetLength(CurrentSong.BPM, 0);
+ CurrentSong.Path := '';
+ CurrentSong.FileName := '';
+ end;
+ *)
+
+// CurrentSong := nil;
+end;
+
+
+//--------------------
+// Saves a Song
+//--------------------
+function SaveSong(Song: TSong; Lines: TLines; Name: string; Relative: boolean): boolean;
+var
+ C: integer;
+ N: integer;
+ S: string;
+ B: integer;
+ RelativeSubTime: integer;
+ NoteState: String;
+
+begin
+// Relative := true; // override (idea - use shift+S to save with relative)
+ AssignFile(SongFile, Name);
+ Rewrite(SongFile);
+
+ Writeln(SongFile, '#TITLE:' + Song.Title + '');
+ Writeln(SongFile, '#ARTIST:' + Song.Artist);
+
+ if Song.Creator <> '' then Writeln(SongFile, '#CREATOR:' + Song.Creator);
+ if Song.Edition <> 'Unknown' then Writeln(SongFile, '#EDITION:' + Song.Edition);
+ if Song.Genre <> 'Unknown' then Writeln(SongFile, '#GENRE:' + Song.Genre);
+ if Song.Language <> 'Unknown' then Writeln(SongFile, '#LANGUAGE:' + Song.Language);
+
+ Writeln(SongFile, '#MP3:' + Song.Mp3);
+
+ if Song.Cover <> '' then Writeln(SongFile, '#COVER:' + Song.Cover);
+ if Song.Background <> '' then Writeln(SongFile, '#BACKGROUND:' + Song.Background);
+ if Song.Video <> '' then Writeln(SongFile, '#VIDEO:' + Song.Video);
+ if Song.VideoGAP <> 0 then Writeln(SongFile, '#VIDEOGAP:' + FloatToStr(Song.VideoGAP));
+ if Song.Resolution <> 4 then Writeln(SongFile, '#RESOLUTION:' + IntToStr(Song.Resolution));
+ if Song.NotesGAP <> 0 then Writeln(SongFile, '#NOTESGAP:' + IntToStr(Song.NotesGAP));
+ if Song.Start <> 0 then Writeln(SongFile, '#START:' + FloatToStr(Song.Start));
+ if Song.Finish <> 0 then Writeln(SongFile, '#END:' + IntToStr(Song.Finish));
+ if Relative then Writeln(SongFile, '#RELATIVE:yes');
+
+ Writeln(SongFile, '#BPM:' + FloatToStr(Song.BPM[0].BPM / 4));
+ Writeln(SongFile, '#GAP:' + FloatToStr(Song.GAP));
+
+ RelativeSubTime := 0;
+ for B := 1 to High(CurrentSong.BPM) do
+ Writeln(SongFile, 'B ' + FloatToStr(CurrentSong.BPM[B].StartBeat) + ' ' + FloatToStr(CurrentSong.BPM[B].BPM/4));
+
+ for C := 0 to Lines.High do begin
+ for N := 0 to Lines.Line[C].HighNote do begin
+ with Lines.Line[C].Note[N] do begin
+
+
+ //Golden + Freestyle Note Patch
+ case Lines.Line[C].Note[N].NoteType of
+ ntFreestyle: NoteState := 'F ';
+ ntNormal: NoteState := ': ';
+ ntGolden: NoteState := '* ';
+ end; // case
+ S := NoteState + IntToStr(Start-RelativeSubTime) + ' ' + IntToStr(Length) + ' ' + IntToStr(Tone) + ' ' + Text;
+
+
+ Writeln(SongFile, S);
+ end; // with
+ end; // N
+
+ if C < Lines.High then begin // don't write end of last sentence
+ if not Relative then
+ S := '- ' + IntToStr(Lines.Line[C+1].Start)
+ else begin
+ S := '- ' + IntToStr(Lines.Line[C+1].Start - RelativeSubTime) +
+ ' ' + IntToStr(Lines.Line[C+1].Start - RelativeSubTime);
+ RelativeSubTime := Lines.Line[C+1].Start;
+ end;
+ Writeln(SongFile, S);
+ end;
+
+ end; // C
+
+
+ Writeln(SongFile, 'E');
+ CloseFile(SongFile);
+
+ Result := true;
+end;
+
+end.