From a7b136be61d98b86dd510425f0edad62f50b0a75 Mon Sep 17 00:00:00 2001 From: barbeque-squared Date: Sun, 14 Jul 2024 16:17:59 +0200 Subject: [PATCH] less hardcoding of default #RESOLUTION value --- src/base/UFiles.pas | 3 +-- src/base/USong.pas | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base/UFiles.pas b/src/base/UFiles.pas index d257fecd5..dfa3b8fa7 100644 --- a/src/base/UFiles.pas +++ b/src/base/UFiles.pas @@ -150,8 +150,7 @@ function SaveSong(const Song: TSong; const Tracks: array of TLines; const Name: if Song.Video.IsSet then SongFile.WriteLine('#VIDEO:' + EncodeToken(Song.Video.ToUTF8)); if Song.VideoGAP <> 0.0 then SongFile.WriteLine('#VIDEOGAP:' + FloatToStr(Song.VideoGAP)); - // TODO: this default also appears in USong.ReadTXTHeader and USong.Clear - if Song.Resolution <> 4 then SongFile.WriteLine('#RESOLUTION:' + IntToStr(Song.Resolution)); + if Song.Resolution <> USong.DEFAULT_RESOLUTION then SongFile.WriteLine('#RESOLUTION:' + IntToStr(Song.Resolution)); if Song.NotesGAP <> 0 then SongFile.WriteLine('#NOTESGAP:' + IntToStr(Song.NotesGAP)); if Song.Start <> 0.0 then SongFile.WriteLine('#START:' + FloatToStr(Song.Start)); if Song.Finish <> 0 then SongFile.WriteLine('#END:' + IntToStr(Song.Finish)); diff --git a/src/base/USong.pas b/src/base/USong.pas index 82b6dbe75..d68669c8a 100644 --- a/src/base/USong.pas +++ b/src/base/USong.pas @@ -61,6 +61,9 @@ interface UUnicodeStringHelper, UUnicodeUtils; +const + DEFAULT_RESOLUTION = 4; // default #RESOLUTION + type TSingMode = ( smNormal, smPartyClassic, smPartyFree, smPartyChallenge, smPartyTournament, smJukebox, smPlaylistRandom , smMedley ); @@ -973,9 +976,8 @@ function TSong.ReadTXTHeader(SongFile: TTextFileStream; ReadCustomTags: Boolean) begin TryStrtoInt(Value, self.Resolution); if (self.Resolution < 1) then begin - // TODO: this hardcoded default also appears in Clear and UFiles.SaveSong Log.LogError('Ignoring invalid resolution in song: ' + FullFileName); - self.Resolution := 4; + self.Resolution := DEFAULT_RESOLUTION; end end @@ -1477,8 +1479,7 @@ procedure TSong.Clear(); Video := PATH_NONE; VideoGAP := 0; NotesGAP := 0; - // TODO: this default also appears in ReadTXTHeader and UFiles.SaveSong - Resolution := 4; + Resolution := DEFAULT_RESOLUTION; Creator := ''; PreviewStart := 0; CalcMedley := true;