Skip to content

Commit

Permalink
Update last played time in rom entry when quit
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 25, 2015
1 parent baa95ce commit 3c41c2c
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
Binary file added Assets/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Database/ROMDBEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace VBA10
}
}

property Windows::Foundation::DateTime LastPlay
property Windows::Foundation::DateTime LastPlayed
{
Windows::Foundation::DateTime get()
{
Expand Down
11 changes: 5 additions & 6 deletions Database/ROMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace VBA10
"DISPLAYNAME TEXT NOT NULL,"\
"FILENAME INT NOT NULL,"\
"FILEPATH INT NOT NULL,"\
"LASTPLAY INT NOT NULL,"\
"LASTPLAYED INT NOT NULL,"\
"LASTSAVEINDEX INT NOT NULL, "\
"AUTOSAVEINDEX INT NOT NULL, "\
"SNAPSHOTURI TEXT NOT NULL );");
Expand Down Expand Up @@ -94,12 +94,12 @@ namespace VBA10


//prepare statement to add to rom table
Platform::String^ cmd = "INSERT INTO ROMTABLE (LOCATIONTYPE, DISPLAYNAME, FILENAME, FILEPATH, LASTPLAY, LASTSAVEINDEX, AUTOSAVEINDEX, SNAPSHOTURI) VALUES (";
Platform::String^ cmd = "INSERT INTO ROMTABLE (LOCATIONTYPE, DISPLAYNAME, FILENAME, FILEPATH, LASTPLAYED, LASTSAVEINDEX, AUTOSAVEINDEX, SNAPSHOTURI) VALUES (";
cmd += entry->LocationType + ",";
cmd += "'" + entry->DisplayName + "',";
cmd += "'" + entry->FileName + "',";
cmd += "'" + entry->FilePath + "',";
cmd += entry->LastPlay.UniversalTime + ",";
cmd += entry->LastPlayed.UniversalTime + ",";
cmd += entry->LastSaveIndex + ",";
cmd += entry->AutoSaveIndex + ",";
cmd += "'" + entry->SnapshotUri + "')";
Expand Down Expand Up @@ -238,10 +238,9 @@ namespace VBA10
{

//prepare statement to update entry
Platform::String^ cmd = "UPDATE ROMTABLE SET DISPLAYNAME = "; //, FILENAME, FILEPATH, LASTPLAY, LASTSAVEINDEX, AUTOSAVEINDEX, SNAPSHOTURI) VALUES (";
Platform::String^ cmd = "UPDATE ROMTABLE SET DISPLAYNAME = ";
cmd += "'" + entry->DisplayName + "',";
cmd += " LASTPLAY = " + entry->LastPlay.UniversalTime + ",";

cmd += " LASTPLAYED = " + entry->LastPlayed.UniversalTime + ",";
cmd += " LASTSAVEINDEX = " + entry->LastSaveIndex + ",";
cmd += " AUTOSAVEINDEX = " + entry->AutoSaveIndex ;
cmd += " WHERE FILEPATH = '" + entry->FilePath + "';";
Expand Down
9 changes: 9 additions & 0 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ using namespace Windows::Storage::Streams;
using namespace Windows::Storage::FileProperties;
using namespace Windows::UI::ViewManagement;
using namespace Windows::Graphics::Imaging;
using namespace Windows::Globalization; //to get date time

using namespace std;
using namespace VBA10;
Expand Down Expand Up @@ -331,7 +332,15 @@ task<void> DirectXPage::SaveBeforeStop()
//move saving stuff from StopROMAsync over here + add save snapshot
if (IsROMLoaded())
{

m_main->emulator->Pause();

//update last played time
Calendar^ calendar = ref new Calendar();
calendar->SetToNow();
loadedEntry->LastPlayed = calendar->GetDateTime();

//save stuff
SaveSnapshot().wait();
UpdateDBEntry().wait();
SaveSRAMAsync().wait();
Expand Down
42 changes: 42 additions & 0 deletions SelectROMPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,48 @@
<!--<local:IsoImageConverter x:Key="SnapshotConverter" />-->
</StackPanel.Resources>

<!--<Grid x:Name="lastRomGrid"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"
Height="272"
>
<Image Source="{Binding Snapshot}"
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center"
x:Name="lastRomImage"
/>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Offset="0.6"/>
<GradientStop Color="#B2000000" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TextBlock Text="{Binding DisplayName}"
d:DataContext="{Binding DesignROMDBEntry[0]}"
VerticalAlignment="Bottom"
TextWrapping="Wrap"
FontSize="30"
LineHeight="38"
LineStackingStrategy="BaselineToBaseline"
Margin="20, 0, 20, 12"
Foreground="White"
/>
</Grid>
<Image Source="/Assets/play.png"
Width="100"
Opacity="0.7"/>
</Grid>-->

<ListBox Name="romList"
SelectionChanged="romList_SelectionChanged"
ItemsSource="{Binding Source={StaticResource AllROMEntries}}"
Expand Down
1 change: 1 addition & 0 deletions VBA10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<Image Include="Assets\pad_l_button.dds" />
<Image Include="Assets\pad_r_button.dds" />
<Image Include="Assets\pad_start_select.dds" />
<Image Include="Assets\play.png" />
<Image Include="Assets\SmallLogo.scale-100.png" />
<Image Include="Assets\StoreLogo.scale-100.png" />
<Image Include="Assets\SplashScreen.scale-100.png" />
Expand Down
3 changes: 3 additions & 0 deletions VBA10.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,8 @@
<Image Include="Assets\no_snapshot.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\play.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
</Project>

0 comments on commit 3c41c2c

Please sign in to comment.