diff --git a/Database/ROMDatabase.cpp b/Database/ROMDatabase.cpp index a472121..74877b8 100644 --- a/Database/ROMDatabase.cpp +++ b/Database/ROMDatabase.cpp @@ -55,7 +55,7 @@ namespace VBA10 "SNAPSHOTURI TEXT NOT NULL );"); }).then([this] { - return db->PrepareStatementAsync("SELECT * FROM ROMTABLE;"); + return db->PrepareStatementAsync("SELECT * FROM ROMTABLE ORDER BY DISPLAYNAME ASC;"); }).then([this](SQLiteWinRT::Statement^ stmt) { @@ -135,7 +135,7 @@ namespace VBA10 { ROMDBEntry^ entry = ref new ROMDBEntry( statement->GetIntAt(0), statement->GetTextAt(1), statement->GetTextAt(2), statement->GetTextAt(3), - DateTime{ statement->GetIntAt(4) }, statement->GetIntAt(5), statement->GetIntAt(6), statement->GetTextAt(7) + DateTime{ statement->GetInt64At(4) }, statement->GetIntAt(5), statement->GetIntAt(6), statement->GetTextAt(7) ); items->Append(entry); diff --git a/DirectXPage.xaml.cpp b/DirectXPage.xaml.cpp index e565880..1b35555 100644 --- a/DirectXPage.xaml.cpp +++ b/DirectXPage.xaml.cpp @@ -561,27 +561,6 @@ void DirectXPage::TogglePaneButton_Checked(Platform::Object^ sender, Windows::UI if (IsROMLoaded()) { - //first find the rom entry -// ROMDBEntry^ entry = nullptr; -// for (int i = 0; i < App::ROMDB->AllROMDBEntries->Size; i++) -// { -// entry = App::ROMDB->AllROMDBEntries->GetAt(i); -// -//#if _DEBUG -// Platform::String ^message = entry->FilePath; -// wstring wstr(message->Begin(), message->End()); -// OutputDebugStringW(wstr.c_str()); -// -// message = ROMFile->Path; -// wstring wstr2(message->Begin(), message->End()); -// OutputDebugStringW(wstr2.c_str()); -//#endif -// -// if (entry->FilePath == ROMFile->Path) -// { -// break; -// } -// } //calculate snapshot name Platform::String ^file_path = ROMFile->Path; @@ -600,6 +579,11 @@ void DirectXPage::TogglePaneButton_Checked(Platform::Object^ sender, Windows::UI // new snapshot loadedEntry->Snapshot = TakeSnapshot(); + //update last played time + Calendar^ calendar = ref new Calendar(); + calendar->SetToNow(); + loadedEntry->LastPlayed = calendar->GetDateTime(); + } //enable app frame AppFrame->IsEnabled = true; diff --git a/SelectROMPane.xaml b/SelectROMPane.xaml index e644842..f2ec827 100644 --- a/SelectROMPane.xaml +++ b/SelectROMPane.xaml @@ -7,7 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - d:DesignWidth="320" + d:DesignWidth="600" Name="page" > @@ -23,13 +23,14 @@ - + + @@ -41,6 +42,7 @@ + @@ -92,57 +94,63 @@ VerticalScrollBarVisibility="Auto" Grid.Row="1" > - + - + + - + + + + diff --git a/SelectROMPane.xaml.cpp b/SelectROMPane.xaml.cpp index 96233af..5414100 100644 --- a/SelectROMPane.xaml.cpp +++ b/SelectROMPane.xaml.cpp @@ -51,9 +51,34 @@ SelectROMPane::SelectROMPane() //this->InitializeStorageLists(); //bind list of ROM to display - AllROMEntries->Source = App::ROMDB->AllROMDBEntries; + cvsAllROMEntries->Source = App::ROMDB->AllROMDBEntries; romList->SelectedItem = nullptr; + //find the most recently play game + if (App::ROMDB->AllROMDBEntries->Size == 0) //no rom in list + lastRomGrid->Visibility = Windows::UI::Xaml::Visibility::Collapsed; //collapse + + int index = 0; + for (int i = 1; i < App::ROMDB->AllROMDBEntries->Size; i++) + { +#if _DEBUG + int64 test = App::ROMDB->AllROMDBEntries->GetAt(i)->LastPlayed.UniversalTime; + Platform::String ^message = test + "\n"; + wstring wstr(message->Begin(), message->End()); + OutputDebugStringW(wstr.c_str()); +#endif + + if (App::ROMDB->AllROMDBEntries->GetAt(i)->LastPlayed.UniversalTime > App::ROMDB->AllROMDBEntries->GetAt(index)->LastPlayed.UniversalTime) + index = i; + } + + + + + if (App::ROMDB->AllROMDBEntries->GetAt(index)->LastPlayed.UniversalTime > 0) // have been played + lastRomGrid->DataContext = App::ROMDB->AllROMDBEntries->GetAt(index); + else + lastRomGrid->Visibility = Windows::UI::Xaml::Visibility::Collapsed; //collapse //disable the command bar if no rom is loaded @@ -494,3 +519,12 @@ void SelectROMPane::addROMbtn_Click(Platform::Object^ sender, Windows::UI::Xaml: { DirectXPage::Current->GoToPage(2); } + + +void SelectROMPane::lastRomImage_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) +{ + ROMDBEntry^ entry = (ROMDBEntry^)this->lastRomImage->DataContext; + DirectXPage::Current->LoadROM(entry); +} + + diff --git a/SelectROMPane.xaml.h b/SelectROMPane.xaml.h index fd76e65..46f7bbf 100644 --- a/SelectROMPane.xaml.h +++ b/SelectROMPane.xaml.h @@ -92,5 +92,7 @@ namespace VBA10 void addROMbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); StorageFolder^ tmpFolder; + void lastRomImage_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); + }; } diff --git a/Styles.xaml b/Styles.xaml index 49debb2..5bff5f8 100644 --- a/Styles.xaml +++ b/Styles.xaml @@ -132,6 +132,78 @@ + + +