From ec75bc2b03e707c479f3605ffc1a8d9fe38c165b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 17 Nov 2009 15:25:54 +0000 Subject: header tags that are not supported are written to the end of the songheader when saving in editor fixed header reader ending in infinite loop when there is a header line w/o Colon git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1943 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UFiles.pas | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/base/UFiles.pas') diff --git a/src/base/UFiles.pas b/src/base/UFiles.pas index a46d4e0d..2820a08c 100644 --- a/src/base/UFiles.pas +++ b/src/base/UFiles.pas @@ -102,6 +102,22 @@ var SaveSong := ssrEncodingError; end; + procedure WriteCustomTags; + var + I: integer; + Line: RawByteString; + begin + for I := 0 to High(Song.CustomTags) do + begin + Line := EncodeToken(Song.CustomTags[I].Content); + if (Length(Song.CustomTags[I].Tag) > 0) then + Line := EncodeToken(Song.CustomTags[I].Tag) + ':' + Line; + + SongFile.WriteLine('#' + Line); + end; + + end; + begin // Relative := true; // override (idea - use shift+S to save with relative) Result := ssrOK; @@ -109,6 +125,9 @@ begin try SongFile := TMemTextFileStream.Create(Name, fmCreate); try + // to-do: should we really write the BOM? + // it causes problems w/ older versions + // e.g. usdx 1.0.1a or ultrastar < 0.7.0 if (Song.Encoding = encUTF8) then SongFile.WriteString(UTF8_BOM); @@ -136,6 +155,9 @@ begin SongFile.WriteLine('#BPM:' + FloatToStr(Song.BPM[0].BPM / 4)); SongFile.WriteLine('#GAP:' + FloatToStr(Song.GAP)); + // write custom header tags + WriteCustomTags; + RelativeSubTime := 0; for B := 1 to High(Song.BPM) do SongFile.WriteLine('B ' + FloatToStr(Song.BPM[B].StartBeat) + ' ' -- cgit v1.2.3