aboutsummaryrefslogtreecommitdiffstats
path: root/ScoreConverter/UScores.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-08 15:33:48 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-06-08 15:33:48 +0000
commit46bb010ca7c5eb04551c030105f9999ca80e472f (patch)
tree3cb6a6bdd7e4e62623c6a83b5d22c1c0dfad73e8 /ScoreConverter/UScores.pas
parentf4425b4558b7fd86de874035f81ea290c987e96d (diff)
downloadusdx-46bb010ca7c5eb04551c030105f9999ca80e472f.tar.gz
usdx-46bb010ca7c5eb04551c030105f9999ca80e472f.tar.xz
usdx-46bb010ca7c5eb04551c030105f9999ca80e472f.zip
- set svn:eol-style to native
- removed some svn:executable properties from non-executable files git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1144 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--ScoreConverter/UScores.pas204
1 files changed, 102 insertions, 102 deletions
diff --git a/ScoreConverter/UScores.pas b/ScoreConverter/UScores.pas
index 3e2c4e92..801d796e 100644
--- a/ScoreConverter/UScores.pas
+++ b/ScoreConverter/UScores.pas
@@ -1,102 +1,102 @@
-unit UScores;
-
-interface
-
-uses USongs;
-
-procedure ReadScore(var Song: TSong);
-procedure WriteScore(var Song: TSong);
-procedure AddScore(var Song: TSong; Level: integer; Name: string; Score: integer);
-
-implementation
-
-uses IniFiles, SysUtils;
-
-procedure ReadScore(var Song: TSong);
-var
- F: TIniFile;
- S: string;
- P: integer;
- Lev: integer;
- LevS: string;
-begin
- F := TIniFile.Create(Song.Path + ChangeFileExt(Song.FileName, '.sco'));
-
- for Lev := 0 to 2 do begin
- case Lev of
- 0: LevS := 'Easy';
- 1: LevS := 'Normal';
- 2: LevS := 'Hard';
- end;
-
- P := 1;
- S := F.ReadString(LevS + IntToStr(P), 'Name', '');
- while (S <> '') and (P<=5) do begin
- SetLength(Song.Score[Lev], P);
- Song.Score[Lev, P-1].Name := S;
- Song.Score[Lev, P-1].Score := F.ReadInteger(LevS + IntToStr(P), 'Score', 0);
-
- Inc(P);
- S := F.ReadString(LevS + IntToStr(P), 'Name', '');
- end;
- end;
-end;
-
-procedure AddScore(var Song: TSong; Level: integer; Name: string; Score: integer);
-var
- S: integer;
- S2: integer;
-begin
- S := 0;
- while (S <= High(Song.Score[Level])) and (Score <= Song.Score[Level, S].Score) do
- Inc(S);
- // S has the number for new score
-
-
- // we create new score
- SetLength(Song.Score[Level], Length(Song.Score[Level]) + 1);
-
- // we move down old scores
- for S2 := High(Song.Score[Level])-1 downto S do
- Song.Score[Level, S2+1] := Song.Score[Level, S2];
-
- // we fill new score
- Song.Score[Level, S].Name := Name;
- Song.Score[Level, S].Score := Score;
-
- if Length(Song.Score[Level]) > 5 then begin
- SetLength(Song.Score[Level], 5);
- end;
-end;
-
-procedure WriteScore(var Song: TSong);
-var
- F: TIniFile;
- S: integer;
- Lev: integer;
- LevS: string;
- FileName: string;
-begin
- FileName := Song.Path + ChangeFileExt(Song.FileName, '.sco');
- if (not FileExists(FileName)) or (FileExists(FileName) and DeleteFile(FileName)) then begin
- // file has been deleted -> creating new file
- F := TIniFile.Create(FileName);
-
- for Lev := 0 to 2 do begin
- case Lev of
- 0: LevS := 'Easy';
- 1: LevS := 'Normal';
- 2: LevS := 'Hard';
- end;
-
- for S := 0 to high(Song.Score[Lev]) do begin
- F.WriteString(LevS + IntToStr(S+1), 'Name', Song.Score[Lev, S].Name);
- F.WriteInteger(LevS + IntToStr(S+1), 'Score', Song.Score[Lev, S].Score);
-
- end; // for S
- end; // for Lev
- F.Free;
- end; // if
-end;
-
-end.
+unit UScores;
+
+interface
+
+uses USongs;
+
+procedure ReadScore(var Song: TSong);
+procedure WriteScore(var Song: TSong);
+procedure AddScore(var Song: TSong; Level: integer; Name: string; Score: integer);
+
+implementation
+
+uses IniFiles, SysUtils;
+
+procedure ReadScore(var Song: TSong);
+var
+ F: TIniFile;
+ S: string;
+ P: integer;
+ Lev: integer;
+ LevS: string;
+begin
+ F := TIniFile.Create(Song.Path + ChangeFileExt(Song.FileName, '.sco'));
+
+ for Lev := 0 to 2 do begin
+ case Lev of
+ 0: LevS := 'Easy';
+ 1: LevS := 'Normal';
+ 2: LevS := 'Hard';
+ end;
+
+ P := 1;
+ S := F.ReadString(LevS + IntToStr(P), 'Name', '');
+ while (S <> '') and (P<=5) do begin
+ SetLength(Song.Score[Lev], P);
+ Song.Score[Lev, P-1].Name := S;
+ Song.Score[Lev, P-1].Score := F.ReadInteger(LevS + IntToStr(P), 'Score', 0);
+
+ Inc(P);
+ S := F.ReadString(LevS + IntToStr(P), 'Name', '');
+ end;
+ end;
+end;
+
+procedure AddScore(var Song: TSong; Level: integer; Name: string; Score: integer);
+var
+ S: integer;
+ S2: integer;
+begin
+ S := 0;
+ while (S <= High(Song.Score[Level])) and (Score <= Song.Score[Level, S].Score) do
+ Inc(S);
+ // S has the number for new score
+
+
+ // we create new score
+ SetLength(Song.Score[Level], Length(Song.Score[Level]) + 1);
+
+ // we move down old scores
+ for S2 := High(Song.Score[Level])-1 downto S do
+ Song.Score[Level, S2+1] := Song.Score[Level, S2];
+
+ // we fill new score
+ Song.Score[Level, S].Name := Name;
+ Song.Score[Level, S].Score := Score;
+
+ if Length(Song.Score[Level]) > 5 then begin
+ SetLength(Song.Score[Level], 5);
+ end;
+end;
+
+procedure WriteScore(var Song: TSong);
+var
+ F: TIniFile;
+ S: integer;
+ Lev: integer;
+ LevS: string;
+ FileName: string;
+begin
+ FileName := Song.Path + ChangeFileExt(Song.FileName, '.sco');
+ if (not FileExists(FileName)) or (FileExists(FileName) and DeleteFile(FileName)) then begin
+ // file has been deleted -> creating new file
+ F := TIniFile.Create(FileName);
+
+ for Lev := 0 to 2 do begin
+ case Lev of
+ 0: LevS := 'Easy';
+ 1: LevS := 'Normal';
+ 2: LevS := 'Hard';
+ end;
+
+ for S := 0 to high(Song.Score[Lev]) do begin
+ F.WriteString(LevS + IntToStr(S+1), 'Name', Song.Score[Lev, S].Name);
+ F.WriteInteger(LevS + IntToStr(S+1), 'Score', Song.Score[Lev, S].Score);
+
+ end; // for S
+ end; // for Lev
+ F.Free;
+ end; // if
+end;
+
+end.