From 37cc5e26505c441d3de151fbe1a70f7d01f085e0 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 4 Mar 2008 09:55:53 +0000 Subject: added code to handle , or . decimal seperators in song text files. initial checking, may still need work & testing on delphi etc git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@905 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/USong.pas | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Game/Code/Classes/USong.pas b/Game/Code/Classes/USong.pas index 39220f1c..cf75509a 100644 --- a/Game/Code/Classes/USong.pas +++ b/Game/Code/Classes/USong.pas @@ -334,6 +334,28 @@ end; function TSong.ReadTXTHeader(const aFileName : WideString): boolean; + function Replace_Decimal_Separator( aValue : String ) : String; + var + lReplaceChar : char; + lDecSep : char; + begin + result := aValue; + + {$IFDEF FPC} + lDecSep := DefaultFormatSettings.DecimalSeparator; + {$ELSE} + lDecSep := DecimalSeparator; + {$ENDIF} + + if lDecSep = '.' then + lReplaceChar := ',' + else + lReplaceChar := '.'; + + if (Pos(lReplaceChar, result) <> 0) then + result[Pos(lReplaceChar, result)] := lDecSep; + end; + var Line, Identifier, Value: String; Temp : word; @@ -411,14 +433,10 @@ begin //Beats per Minute else if (Identifier = 'BPM') then begin - // Replace . with , - if (Pos('.', Value) <> 0) then - Value[Pos('.', Value)] := ','; - SetLength(self.BPM, 1); self.BPM[0].StartBeat := 0; - self.BPM[0].BPM := StrtoFloatDef(Value, 0) * Mult * MultBPM; + self.BPM[0].BPM := StrtoFloatDef(Replace_Decimal_Separator( Value ), 0) * Mult * MultBPM; if self.BPM[0].BPM <> 0 then begin @@ -433,13 +451,7 @@ begin // Video Gap else if (Identifier = 'GAP') then - begin - // Replace . with , - if (Pos('.', Value) <> 0) then - Value[Pos('.', Value)] := ','; - - self.GAP := StrtoFloatDef (Value, 0); - end + self.GAP := StrtoFloatDef ( Replace_Decimal_Separator( Value ), 0) //Cover Picture else if (Identifier = 'COVER') then @@ -460,13 +472,7 @@ begin // Video Gap else if (Identifier = 'VIDEOGAP') then - begin - // Replace . with , - if (Pos('.', Value) <> 0) then - Value[Pos('.', Value)] := ','; - - self.VideoGAP := StrtoFloatDef (Value, 0); - end + self.VideoGAP := StrtoFloatDef ( Replace_Decimal_Separator( Value ), 0) //Genre Sorting else if (Identifier = 'GENRE') then @@ -486,13 +492,7 @@ begin // Song Start else if (Identifier = 'START') then - begin - // Replace . with , - if (Pos('.', Value) <> 0) then - Value[Pos('.', Value)] := ','; - - self.Start := StrtoFloatDef(Value, 0); - end + self.Start := StrtoFloatDef( Replace_Decimal_Separator( Value ), 0) // Song Ending else if (Identifier = 'END') then -- cgit v1.2.3