aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UDataBase.pas
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Code/Classes/UDataBase.pas')
-rw-r--r--Game/Code/Classes/UDataBase.pas34
1 files changed, 29 insertions, 5 deletions
diff --git a/Game/Code/Classes/UDataBase.pas b/Game/Code/Classes/UDataBase.pas
index 8f5ebf50..bbdce9ec 100644
--- a/Game/Code/Classes/UDataBase.pas
+++ b/Game/Code/Classes/UDataBase.pas
@@ -55,6 +55,7 @@ type
Function GetStats(var Stats: AStatResult; const Typ, Count: Byte; const Page: Cardinal; const Reversed: Boolean): Boolean;
Function GetTotalEntrys(const Typ: Byte): Cardinal;
+ Function GetStatReset: TDateTime;
end;
var
@@ -71,6 +72,7 @@ uses
const
cUS_Scores = 'us_scores';
cUS_Songs = 'us_songs';
+ cUS_Statistics_Info = 'us_statistics_info';
//--------------------
//Create - Opens Database and Create Tables if not Exist
@@ -97,7 +99,14 @@ begin
ScoreDB.execsql('CREATE TABLE `'+cUS_Songs+'` (`ID` INTEGER PRIMARY KEY, `Artist` VARCHAR( 255 ) NOT NULL , `Title` VARCHAR( 255 ) NOT NULL , `TimesPlayed` int(5) NOT NULL );');
debugWriteln( 'TDataBaseSystem.Init - CREATED US_Songs' );
end;
-
+
+ if not ScoreDB.TableExists( cUS_Statistics_Info ) then
+ begin
+ ScoreDB.execsql('CREATE TABLE `'+cUS_Statistics_Info+'` (`ResetTime` VARCHAR(17) );');
+ ScoreDB.execsql('INSERT INTO `'+cUS_Statistics_Info+'` (`ResetTime`) VALUES ("'+datetimetostr(now)+'");');
+ debugWriteln( 'TDataBaseSystem.Init - CREATED US_Statistics_Info' );
+ end;
+
//Not possible because of String Limitation to 255 Chars //Need to rewrite Wrapper
{if not ScoreDB.TableExists('US_SongCache') then
ScoreDB.ExecSQL('CREATE TABLE `US_SongCache` (`Path` VARCHAR( 255 ) NOT NULL , `Filename` VARCHAR( 255 ) NOT NULL , `Title` VARCHAR( 255 ) NOT NULL , `Artist` VARCHAR( 255 ) NOT NULL , `Folder` VARCHAR( 255 ) NOT NULL , `Genre` VARCHAR( 255 ) NOT NULL , `Edition` VARCHAR( 255 ) NOT NULL , `Language` VARCHAR( 255 ) NOT NULL , `Creator` VARCHAR( 255 ) NOT NULL , `Cover` VARCHAR( 255 ) NOT NULL , `Background` VARCHAR( 255 ) NOT NULL , `Video` VARCHAR( 255 ) NOT NULL , `VideoGap` FLOAT NOT NULL , `Gap` FLOAT NOT NULL , `Start` FLOAT NOT NULL , `Finish` INT( 11 ) NOT NULL , `BPM` INT( 5 ) NOT NULL , `Relative` BOOLEAN NOT NULL , `NotesGap` INT( 11 ) NOT NULL);');}
@@ -148,7 +157,7 @@ begin
while not TableData.Eof do //Go through all Entrys
begin //Add one Entry to Array
- Difficulty := StrToIntDef(TableData.FieldAsString(TableData.FieldIndex['Difficulty']), -1);
+ Difficulty := StrToIntDef(TableData.FieldAsString(TableData.FieldIndex['Difficulty']), -1);
if (Difficulty >= 0) AND (Difficulty <= 2) then
begin
SetLength(Song.Score[Difficulty], Length(Song.Score[Difficulty]) + 1);
@@ -362,9 +371,8 @@ begin
Result := ScoreDB.GetTableValue(Query);
except
- // TODO : JB_Linux - Why do we get these exceptions on linux !!
- on E:ESQLiteException DO // used to handle : Could not retrieve data "SELECT COUNT(`ID`) FROM `US_Songs`;" : SQL logic error or missing database
- // however, we should pre-empt this error... and make sure the database DOES exist.
+ // TODO : JB_Linux - Why do we get these exceptions on linux !! -> should be solved!
+ on E:ESQLiteException DO
begin
exit;
end;
@@ -372,4 +380,20 @@ begin
end;
+//--------------------
+//GetStatReset - Get reset date of statistic data
+//--------------------
+Function TDataBaseSystem.GetStatReset: TDateTime;
+var
+ Query: String;
+ TableData: TSqliteTable;
+begin
+ if not assigned( ScoreDB ) then
+ exit;
+
+ Query := 'SELECT `ResetTime` FROM `'+cUS_Statistics_Info+'`;';
+ TableData := ScoreDB.GetTable(Query);
+ result:=StrToDateTime(TableData.Fields[0]);
+end;
+
end.