Skip to content

Commit

Permalink
finish adding the image of the last rom
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 25, 2015
1 parent 3c41c2c commit 6f836b9
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Database/ROMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down
26 changes: 5 additions & 21 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
92 changes: 50 additions & 42 deletions SelectROMPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>

Expand All @@ -23,13 +23,14 @@
<VisualStateGroup>
<VisualState x:Name="wideView">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1000" />
<AdaptiveTrigger MinWindowWidth="1000" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="saveBtn.Width" Value="88"/>
<Setter Target="selectStateBtn.Width" Value="88"/>
<Setter Target="resetBtn.Width" Value="88"/>
<Setter Target="loadBtn.Width" Value="88"/>
<Setter Target="lastRomGrid.Height" Value="250" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="mediumView">
Expand All @@ -41,6 +42,7 @@
<Setter Target="selectStateBtn.Width" Value="68"/>
<Setter Target="resetBtn.Width" Value="68"/>
<Setter Target="loadBtn.Width" Value="68"/>
<Setter Target="lastRomGrid.Height" Value="300" />
</VisualState.Setters>
</VisualState>

Expand Down Expand Up @@ -92,57 +94,63 @@
VerticalScrollBarVisibility="Auto"
Grid.Row="1"
>
<StackPanel >
<StackPanel x:Name="Container"
>
<StackPanel.Resources>
<CollectionViewSource x:Name="AllROMEntries"/>
<CollectionViewSource x:Name="cvsAllROMEntries"/>
<CollectionViewSource x:Name="cvsLastROMEntry"/>
<!--<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"
/>
<Button x:Name="lastRomGrid"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Tapped="lastRomImage_Tapped"
Background="Transparent"
Margin="0" Padding="0"
Style="{StaticResource ImageButtonStyle}"

>
<Button.Content>
<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"
<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}"
VerticalAlignment="Bottom"
TextWrapping="Wrap"
FontSize="30"

LineHeight="38"
LineStackingStrategy="BaselineToBaseline"
Margin="20, 0, 20, 12"
Foreground="White"
LineHeight="38"
LineStackingStrategy="BaselineToBaseline"
Margin="20, 0, 20, 12"
Foreground="White"

/>
</Grid>
/>
</Grid>

<Image Source="/Assets/play.png"
Width="100"
Opacity="0.7"/>
</Grid>-->
<Image Source="/Assets/play.png"
Width="100"
Opacity="0.7"/>
</Grid>
</Button.Content>
</Button>

<ListBox Name="romList"
SelectionChanged="romList_SelectionChanged"
ItemsSource="{Binding Source={StaticResource AllROMEntries}}"
ItemsSource="{Binding Source={StaticResource cvsAllROMEntries}}"
Margin="-4,0,0,0"

Padding="0"
Expand Down Expand Up @@ -225,7 +233,7 @@
<Button x:Name="addROMbtn" HorizontalAlignment="Center"
Content="Add ROM"
Width="120" Height="40"
Margin="0,12,0,0"
Margin="0,12,0,12"
Click="addROMbtn_Click"/>
</StackPanel>
</ScrollViewer>
Expand Down
36 changes: 35 additions & 1 deletion SelectROMPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}


2 changes: 2 additions & 0 deletions SelectROMPane.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

};
}
72 changes: 72 additions & 0 deletions Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,78 @@
<Setter Property="Height" Value="48"/>
<Setter Property="Padding" Value="0"/>
</Style>
<Style x:Key="ImageButtonStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundTransparentBrush}"/>
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>
<Setter Property="Padding" Value="8,4,8,4"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
<Setter Property="UseSystemFocusVisuals" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="ContentPresenter" >
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseHighBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseHighBrush}"/>
</ObjectAnimationUsingKeyFrames>
<PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>





Expand Down

0 comments on commit 6f836b9

Please sign in to comment.