diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-08-27 11:44:14 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-08-27 11:44:14 +0000 |
commit | e9fd8ce40b4cbf006695fd6e56f84071407843c9 (patch) | |
tree | e181a5658b6a814215c130588eff177390920894 /ScoreConverter/UScores.pas | |
parent | 33b13cde51e08eda268e63ef7058f037d299f6c7 (diff) | |
download | usdx-e9fd8ce40b4cbf006695fd6e56f84071407843c9.tar.gz usdx-e9fd8ce40b4cbf006695fd6e56f84071407843c9.tar.xz usdx-e9fd8ce40b4cbf006695fd6e56f84071407843c9.zip |
ScoreConverter moved to Tools
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1301 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'ScoreConverter/UScores.pas')
-rw-r--r-- | ScoreConverter/UScores.pas | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/ScoreConverter/UScores.pas b/ScoreConverter/UScores.pas deleted file mode 100644 index 801d796e..00000000 --- a/ScoreConverter/UScores.pas +++ /dev/null @@ -1,102 +0,0 @@ -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. |