From 488c2e0fe526a1fd5045fb546f7ace220c488085 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Mon, 16 May 2011 18:04:45 +0000 Subject: - new option: song quality check on/off - exclude freestyle notes on song check - added quality factors in config.ini git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2831 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UFiles.pas | 43 ++++++++++++++++++--------- Game/Code/Classes/UIni.pas | 61 +++++++++++++++++++++++++++++++++++++++ Game/Code/Classes/ULog.pas | 9 +++--- Game/Code/Screens/UScreenSong.pas | 5 ++-- Game/Code/UltraStar.dpr | 26 ++++++++--------- 5 files changed, 111 insertions(+), 33 deletions(-) (limited to 'Game') diff --git a/Game/Code/Classes/UFiles.pas b/Game/Code/Classes/UFiles.pas index 7a5e7de4..e38ad7f1 100644 --- a/Game/Code/Classes/UFiles.pas +++ b/Game/Code/Classes/UFiles.pas @@ -890,7 +890,8 @@ begin Result := false; end; - SongQuality(Result); + if (Ini.EnableQualityCheck=1) then + SongQuality(Result); end; procedure SongQuality(Check: boolean); @@ -906,6 +907,7 @@ var Gaps: array[0..2] of integer; //0=total; 1=gaps with length 0; 2=gaps with length 0 + note jump GoldenNotes: integer; gn: real; + Sum: integer; begin // syntax quality @@ -964,21 +966,24 @@ begin if (Czesci[p].Czesc[line].Nuta[note].Wartosc = 2) then Inc(GoldenNotes); - if firstNote then - firstNote := false - else + if not Czesci[p].Czesc[line].Nuta[note].FreeStyle then begin - Gaps[0] := Gaps[0] + 1; - if (lastNoteEnd = Czesci[p].Czesc[line].Nuta[note].Start) then + if firstNote then + firstNote := false + else begin - Gaps[1] := Gaps[1] + 1; - if (abs(lastNoteTone - Czesci[p].Czesc[line].Nuta[note].Ton) > 1) then - Gaps[2] := Gaps[2] + 1; + Gaps[0] := Gaps[0] + 1; + if (lastNoteEnd = Czesci[p].Czesc[line].Nuta[note].Start) then + begin + Gaps[1] := Gaps[1] + 1; + if (abs(lastNoteTone - Czesci[p].Czesc[line].Nuta[note].Ton) > 1) then + Gaps[2] := Gaps[2] + 1; + end; end; - end; - lastNoteTone := Czesci[p].Czesc[line].Nuta[note].Ton; - lastNoteEnd := Czesci[p].Czesc[line].Nuta[note].Start + Czesci[p].Czesc[line].Nuta[note].Dlugosc; + lastNoteTone := Czesci[p].Czesc[line].Nuta[note].Ton; + lastNoteEnd := Czesci[p].Czesc[line].Nuta[note].Start + Czesci[p].Czesc[line].Nuta[note].Dlugosc; + end; end; end; end; @@ -990,8 +995,18 @@ begin gn := 100 * GoldenNotes/(Gaps[0]+1); end; - AktSong.Quality.Value := (AktSong.Quality.Syntax + AktSong.Quality.BPM*3 + AktSong.Quality.NoteGaps*2 + - AktSong.Quality.NoteJumps*2 + AktSong.Quality.Scores*2) / 10; + Sum := Ini.Qualityfactors[0] + Ini.Qualityfactors[1] + Ini.Qualityfactors[2] + + Ini.Qualityfactors[3] + Ini.Qualityfactors[4]; + + if (Sum>0) then + AktSong.Quality.Value := ( + AktSong.Quality.Syntax * Ini.Qualityfactors[0] + + AktSong.Quality.BPM * Ini.Qualityfactors[1] + + AktSong.Quality.NoteGaps * Ini.Qualityfactors[2] + + AktSong.Quality.NoteJumps * Ini.Qualityfactors[3] + + AktSong.Quality.Scores * Ini.Qualityfactors[4]) / Sum + else + AktSong.Quality.Value := 0; Log.LogSongQuality(AktSong.Artist, AktSong.Title, AktSong.Quality.Syntax, AktSong.Quality.BPM, AktSong.Quality.NoteGaps, AktSong.Quality.NoteJumps, AktSong.Quality.Scores, AktSong.Quality.Value, gn); diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas index 3b33785b..53664817 100644 --- a/Game/Code/Classes/UIni.pas +++ b/Game/Code/Classes/UIni.pas @@ -95,6 +95,10 @@ type PossibleScore: integer; LogSession: integer; + // Quality-Check + EnableQualityCheck: integer; + QualityFactors: array[0..4] of integer; + // Soundcards SoundCard: array[0..7, 1..2] of integer; @@ -200,6 +204,9 @@ const IPossibleScore: array[0..3] of string = ('Off', 'Bar', 'Numbers', 'Name'); ILogSession: array[0..1] of string = ('Off', 'On'); + IEnableQualityCheck: array[0..1] of string = ('Off', 'On'); + IQualityFactors: array[0..9] of string = ('x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9'); + IChannel: array[0..6] of string = ('Off', '1', '2', '3', '4', '5', '6'); implementation @@ -676,6 +683,36 @@ begin for Pet := 0 to High(ILogSession) do if Tekst = ILogSession[Pet] then Ini.LogSession := Pet; + // EnableQualityCheck + Tekst := IniFile.ReadString('Quality', 'EnableQualityCheck', IEnableQualityCheck[0]); + for Pet := 0 to High(IEnableQualityCheck) do + if Tekst = IEnableQualityCheck[Pet] then Ini.EnableQualityCheck := Pet; + + // Quality Factor Syntax + Tekst := IniFile.ReadString('Quality', 'QualityFactorSyntax', IQualityFactors[1]); + for Pet := 0 to High(IQualityFactors) do + if Tekst = IQualityFactors[Pet] then Ini.QualityFactors[0] := Pet; + + // Quality Factor BPM + Tekst := IniFile.ReadString('Quality', 'QualityFactorBPM', IQualityFactors[3]); + for Pet := 0 to High(IQualityFactors) do + if Tekst = IQualityFactors[Pet] then Ini.QualityFactors[1] := Pet; + + // Quality Factor Note Gaps + Tekst := IniFile.ReadString('Quality', 'QualityFactorNoteGaps', IQualityFactors[2]); + for Pet := 0 to High(IQualityFactors) do + if Tekst = IQualityFactors[Pet] then Ini.QualityFactors[2] := Pet; + + // Quality Factor Note Jumps + Tekst := IniFile.ReadString('Quality', 'QualityFactorNoteJumps', IQualityFactors[2]); + for Pet := 0 to High(IQualityFactors) do + if Tekst = IQualityFactors[Pet] then Ini.QualityFactors[3] := Pet; + + // Quality Factor Scores + Tekst := IniFile.ReadString('Quality', 'QualityFactorScores', IQualityFactors[1]); + for Pet := 0 to High(IQualityFactors) do + if Tekst = IQualityFactors[Pet] then Ini.QualityFactors[4] := Pet; + // SongPath if (Params.SongPath <> '') then SongPaths[0] := IncludeTrailingPathDelimiter(Params.SongPath) @@ -962,6 +999,30 @@ begin Tekst := ILogSession[Ini.LogSession]; IniFile.WriteString('Advanced', 'LogSession', Tekst); + // EnableQualityCheck + Tekst := IEnableQualityCheck[Ini.EnableQualityCheck]; + IniFile.WriteString('Quality', 'EnableQualityCheck', Tekst); + + //Quality Factor Syntax + Tekst := IQualityFactors[Ini.QualityFactors[0]]; + IniFile.WriteString('Quality', 'QualityFactorSyntax', Tekst); + + //Quality Factor BPM + Tekst := IQualityFactors[Ini.QualityFactors[1]]; + IniFile.WriteString('Quality', 'QualityFactorBPM', Tekst); + + //Quality Factor NoteJumps + Tekst := IQualityFactors[Ini.QualityFactors[2]]; + IniFile.WriteString('Quality', 'QualityFactorNoteJumps', Tekst); + + //Quality Factor NoteGaps + Tekst := IQualityFactors[Ini.QualityFactors[3]]; + IniFile.WriteString('Quality', 'QualityFactorNoteGaps', Tekst); + + //Quality Factor Scores + Tekst := IQualityFactors[Ini.QualityFactors[4]]; + IniFile.WriteString('Quality', 'QualityFactorScores', Tekst); + // Directories (add a template if section is missing, from 1.1) if (not IniFile.SectionExists('Path')) then IniFile.WriteString('Path', 'Songs', ' '); diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas index 9e6f26fb..63cf8d52 100644 --- a/Game/Code/Classes/ULog.pas +++ b/Game/Code/Classes/ULog.pas @@ -651,7 +651,7 @@ begin //If File is opened write column names to File If (FileSongQualityO) then begin - WriteLn(FileSongQuality, 'Artist; Title; Syntax; BPM; Note Gaps; Note Jumps; Scores; Value; Anteil Goldene Noten'); + WriteLn(FileSongQuality, '"Artist";"Title";"Syntax";"BPM";"Note Gaps";"Note Jumps";"Scores";"Value";"Golden Note Ratio"'); Flush(FileSongQuality); end; end; @@ -659,9 +659,10 @@ begin if FileSongQualityO then begin try - WriteLn(FileSongQuality, artist + ';' + title + ';' + FloatToStr(syntax) + ';' + - FloatToStr(bpm) + ';' + FloatToStr(notegaps) + ';' + FloatToStr(notejumps) + ';' + - FloatToStr(score) + ';' + FloatToStr(value) + ';' + FloatToStr(goldennotes) + ';'); + WriteLn(FileSongQuality, '"' + artist + '";"' + title + '";' + FormatFloat('#.0', syntax) + ';' + + FormatFloat('#.0', bpm) + ';' + FormatFloat('#.0', notegaps) + ';' + + FormatFloat('#.0', notejumps) + ';' + FormatFloat('#.0', score) + ';' + + FormatFloat('#.0', value) + ';' + FormatFloat('#.0', goldennotes) + ';'); except FileSongQualityO := false; end; diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 9b811a62..0483284e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -520,7 +520,7 @@ begin SDLK_I: begin - if (Mode = smNormal) then + if (Mode = smNormal) and (Ini.EnableQualityCheck = 1) then ShowSongQuality := not ShowSongQuality; end; @@ -2691,7 +2691,8 @@ begin DrawExtensions; // Song Quality - if ShowSongQuality and not CatSongs.Song[Interaction].Main then + if ShowSongQuality and (TargetVidVis = windowed) and (VidVis = windowed) + and not CatSongs.Song[Interaction].Main then begin SetFontStyle(0); SetFontItalic(false); diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr index 1774e948..e7733430 100644 --- a/Game/Code/UltraStar.dpr +++ b/Game/Code/UltraStar.dpr @@ -272,6 +272,19 @@ begin Log.BenchmarkEnd(1); Log.LogBenchmark('Initializing 3D', 1); + // Score Saving System + Log.BenchmarkStart(1); + Log.LogStatus('DataBase System', 'Initialization'); + DataBase := TDataBaseSystem.Create; + + if (Params.ScoreFile = '') then + DataBase.Init ('Ultrastar.db') + else + DataBase.Init (Params.ScoreFile); + + Log.BenchmarkEnd(1); + Log.LogBenchmark('Loading DataBase System', 1); + // Songs Log.BenchmarkStart(1); Log.LogStatus('Creating Song Array', 'Initialization'); Songs := TSongs.Create; @@ -302,19 +315,6 @@ begin Log.BenchmarkEnd(1); Log.LogBenchmark('Initializing Sound', 1); - // Score Saving System - Log.BenchmarkStart(1); - Log.LogStatus('DataBase System', 'Initialization'); - DataBase := TDataBaseSystem.Create; - - if (Params.ScoreFile = '') then - DataBase.Init ('Ultrastar.db') - else - DataBase.Init (Params.ScoreFile); - - Log.BenchmarkEnd(1); - Log.LogBenchmark('Loading DataBase System', 1); - //Playlist Manager Log.BenchmarkStart(1); Log.LogStatus('Playlist Manager', 'Initialization'); -- cgit v1.2.3