aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Game/Code/Classes/UDataBase.pas34
-rw-r--r--Game/Code/UltraStar-linux.lpi165
-rw-r--r--Game/Code/lib/SQLite/SQLiteTable3.pas4
3 files changed, 113 insertions, 90 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.
diff --git a/Game/Code/UltraStar-linux.lpi b/Game/Code/UltraStar-linux.lpi
index 0c9ac7a6..e17baaf6 100644
--- a/Game/Code/UltraStar-linux.lpi
+++ b/Game/Code/UltraStar-linux.lpi
@@ -1,83 +1,82 @@
-<?xml version="1.0"?>
-<CONFIG>
- <ProjectOptions>
- <PathDelim Value="/"/>
- <Version Value="6"/>
- <General>
- <Flags>
- <MainUnitHasCreateFormStatements Value="False"/>
- <MainUnitHasTitleStatement Value="False"/>
- <AlwaysBuild Value="False"/>
- </Flags>
- <SessionStorage Value="InProjectDir"/>
- <MainUnit Value="0"/>
- <IconPath Value="./"/>
- <TargetFileExt Value=".exe"/>
- </General>
- <VersionInfo>
- <ProjectVersion Value=""/>
- </VersionInfo>
- <PublishOptions>
- <Version Value="2"/>
- <IgnoreBinaries Value="False"/>
- <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
- <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
- </PublishOptions>
- <RunParams>
- <local>
- <FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
- </local>
- </RunParams>
- <Units Count="1">
- <Unit0>
- <Filename Value="UltraStar.dpr"/>
- <IsPartOfProject Value="True"/>
- </Unit0>
- </Units>
- </ProjectOptions>
- <CompilerOptions>
- <Version Value="5"/>
- <Target>
- <Filename Value="../../UltraStar"/>
- </Target>
- <SearchPaths>
- <IncludeFiles Value="lib/JEDI-SDL/SDL/Pas/"/>
- <OtherUnitFiles Value="$(LazarusDir)/components/jpeg/lib/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/components/images/lib/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)/"/>
- <UnitOutputDirectory Value="build/linux/lazarus"/>
- <SrcPath Value="Classes/;Menu/;Screens/;lib/"/>
- </SearchPaths>
- <Parsing>
- <SyntaxOptions>
- <CStyleOperator Value="False"/>
- </SyntaxOptions>
- </Parsing>
- <CodeGeneration>
- <Generate Value="Faster"/>
- </CodeGeneration>
- <Linking>
- <Debugging>
- <GenerateDebugInfo Value="True"/>
- </Debugging>
- </Linking>
- <Other>
- <Verbosity>
- <ShowNotes Value="False"/>
- <ShowHints Value="False"/>
- <ShowGenInfo Value="False"/>
- </Verbosity>
- <CustomOptions Value="
-"/>
- <CompilerPath Value="$(CompPath)"/>
- <ExecuteBefore>
- <Command Value="/usr/bin/make"/>
- <ScanForFPCMsgs Value="True"/>
- <ScanForMakeMsgs Value="True"/>
- </ExecuteBefore>
- <ExecuteAfter>
- <CompileReasons Compile="False" Build="False" Run="False"/>
- </ExecuteAfter>
- </Other>
- <CompileReasons Compile="False" Build="False" Run="False"/>
- </CompilerOptions>
-</CONFIG>
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <MainUnitHasCreateFormStatements Value="False"/>
+ <MainUnitHasTitleStatement Value="False"/>
+ <AlwaysBuild Value="False"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".exe"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="UltraStar.dpr"/>
+ <IsPartOfProject Value="True"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <Target>
+ <Filename Value="../../UltraStar"/>
+ </Target>
+ <SearchPaths>
+ <IncludeFiles Value="lib/JEDI-SDL/SDL/Pas/"/>
+ <OtherUnitFiles Value="$(LazarusDir)/components/jpeg/lib/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/components/images/lib/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/packager/units/$(TargetCPU)-$(TargetOS)/"/>
+ <UnitOutputDirectory Value="build/linux/lazarus"/>
+ <SrcPath Value="Classes/;Menu/;Screens/;lib/"/>
+ </SearchPaths>
+ <Parsing>
+ <SyntaxOptions>
+ <CStyleOperator Value="False"/>
+ </SyntaxOptions>
+ </Parsing>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Linking>
+ <Debugging>
+ <GenerateDebugInfo Value="True"/>
+ </Debugging>
+ </Linking>
+ <Other>
+ <Verbosity>
+ <ShowNotes Value="False"/>
+ <ShowHints Value="False"/>
+ <ShowGenInfo Value="False"/>
+ </Verbosity>
+ <CustomOptions Value="
+"/>
+ <CompilerPath Value="$(CompPath)"/>
+ <ExecuteBefore>
+ <Command Value="/usr/bin/make"/>
+ <ScanForFPCMsgs Value="True"/>
+ <ScanForMakeMsgs Value="True"/>
+ </ExecuteBefore>
+ <ExecuteAfter>
+ <CompileReasons Compile="False" Build="False" Run="False"/>
+ </ExecuteAfter>
+ </Other>
+ <CompileReasons Compile="False" Build="False" Run="False"/>
+ </CompilerOptions>
+</CONFIG>
diff --git a/Game/Code/lib/SQLite/SQLiteTable3.pas b/Game/Code/lib/SQLite/SQLiteTable3.pas
index fc958d23..cbf868bd 100644
--- a/Game/Code/lib/SQLite/SQLiteTable3.pas
+++ b/Game/Code/lib/SQLite/SQLiteTable3.pas
@@ -353,8 +353,8 @@ var
ds: TSqliteTable;
begin
//returns true if table exists in the database
- sql := 'select [sql] from sqlite_master where [type] = ''table'' and lower(name) = ''' +
- lowercase(TableName) + ''' ';
+ sql := 'select [sql] from sqlite_master where [type] = "table" and lower(name) = "' +
+ lowercase(TableName) + '"';
ds := self.GetTable(sql);
try
Result := (ds.Count > 0);