aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-04 09:55:53 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-04 09:55:53 +0000
commit37cc5e26505c441d3de151fbe1a70f7d01f085e0 (patch)
treeea8c07735da8b26922c13bc3728457dc520b919c /Game/Code
parent5d8cb78bc5b8187da6e80954124f076c408b3c34 (diff)
downloadusdx-37cc5e26505c441d3de151fbe1a70f7d01f085e0.tar.gz
usdx-37cc5e26505c441d3de151fbe1a70f7d01f085e0.tar.xz
usdx-37cc5e26505c441d3de151fbe1a70f7d01f085e0.zip
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
Diffstat (limited to 'Game/Code')
-rw-r--r--Game/Code/Classes/USong.pas52
1 files 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