Skip to content

Commit

Permalink
add command bar. Can now save state.
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 12, 2015
1 parent 0571ebc commit 55f1988
Show file tree
Hide file tree
Showing 15 changed files with 462 additions and 149 deletions.
7 changes: 4 additions & 3 deletions DirectXPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
xmlns:controls="using:VBA10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
mc:Ignorable="d"
KeyDown="AppShell_KeyDown">

<Page.Resources>
<DataTemplate x:Key="NavMenuItemTemplate" x:DataType="local:NavMenuItem">
Expand Down Expand Up @@ -78,7 +79,7 @@
<RelativePanel Background="#FF4D3A89">
<!-- A custom ListView to display the items in the pane. The automation Name is set in the ContainerContentChanging event. -->
<controls:NavMenuListView x:Name="NavMenuList"
TabIndex="3"
IsTabStop="False"
Margin="0,48,0,0"
ContainerContentChanging="NavMenuItemContainerContentChanging"
ItemContainerStyle="{StaticResource NavMenuItemContainerStyle}"
Expand Down Expand Up @@ -118,7 +119,7 @@

<!-- Declared last to have it rendered above everything else, but it needs to be the first item in the tab sequence. -->
<ToggleButton x:Name="TogglePaneButton"
TabIndex="1"
IsTabStop="False"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
IsChecked="{Binding IsPaneOpen, ElementName=RootSplitView, Mode=TwoWay}"
Unchecked="TogglePaneButton_UnChecked"
Expand Down
75 changes: 51 additions & 24 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "NavMenuListView.h"
#include "SelectROMPane.xaml.h"
#include "SettingsPage.xaml.h"

#include "HelpPage.xaml.h"

using namespace std;
using namespace VBA10;
Expand Down Expand Up @@ -136,6 +136,13 @@ DirectXPage::DirectXPage():
"Settings",
Symbol::Setting,
TypeName(SettingsPage::typeid)));

navlist->Append(
ref new NavMenuItem(
"Help",
Symbol::Help,
TypeName(HelpPage::typeid)));

NavMenuList->ItemsSource = navlist;
//load settings
auto settings = ApplicationData::Current->LocalSettings->Values;
Expand Down Expand Up @@ -326,28 +333,7 @@ void DirectXPage::NavMenuList_ItemInvoked(Object^ sender, ListViewItem^ listView
}
}

/// <summary>
/// Callback when the SplitView's Pane is toggled close. When the Pane is not visible
/// then the floating hamburger may be occluding other content in the app unless it is aware.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void DirectXPage::TogglePaneButton_UnChecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
//change splitview to overlay, so that it disappear
//RootSplitView->DisplayMode = SplitViewDisplayMode::Overlay;

//change the size of app frame to zero to hide content
AppFrame->Width = 0.0f;

//unselect item
NavMenuList->SetSelectedItem(nullptr);

CheckTogglePaneButtonSizeChanged();

//unpause emulator
m_main->emulator->Unpause();
}



Expand Down Expand Up @@ -392,7 +378,28 @@ void DirectXPage::NavMenuItemContainerContentChanging(ListViewBase^ sender, Cont
}


/// <summary>
/// Callback when the SplitView's Pane is toggled close. When the Pane is not visible
/// then the floating hamburger may be occluding other content in the app unless it is aware.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void DirectXPage::TogglePaneButton_UnChecked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
//change splitview to overlay, so that it disappear
//RootSplitView->DisplayMode = SplitViewDisplayMode::Overlay;

//change the size of app frame to zero to hide content
AppFrame->Width = 0.0f;

//unselect item
NavMenuList->SetSelectedItem(nullptr);

CheckTogglePaneButtonSizeChanged();

//unpause emulator
m_main->emulator->Unpause();
}

void DirectXPage::TogglePaneButton_Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Expand All @@ -413,10 +420,30 @@ void DirectXPage::TogglePaneButton_Checked(Platform::Object^ sender, Windows::UI

}


void DirectXPage::AppShell_KeyDown(Object^ sender, KeyRoutedEventArgs^ e)
{
if (e->Key == VirtualKey::Escape )
{
RootSplitView->IsPaneOpen = !RootSplitView->IsPaneOpen;

}


}

void DirectXPage::LoadROM(StorageFile ^file, StorageFolder ^folder)
{
LoadROMAsync(file, folder);

RootSplitView->IsPaneOpen = false;
//TogglePaneButton_UnChecked(nullptr, nullptr);
RootSplitView->IsPaneOpen = false; //this will toggle the hamburger menu because of the 2-way binding

}

void DirectXPage::SaveState()
{
SaveStateAsync();
m_main->emulator->GetVirtualController()->Reset();

RootSplitView->IsPaneOpen = false; //this will toggle the hamburger menu because of the 2-way binding
}
4 changes: 4 additions & 0 deletions DirectXPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace VBA10
}

void LoadROM(StorageFile ^file, StorageFolder ^folder);
void SaveState();

//from AppShell
internal:
Expand Down Expand Up @@ -91,6 +92,9 @@ namespace VBA10
void OnCompositionScaleChanged(Windows::UI::Xaml::Controls::SwapChainPanel^ sender, Object^ args);
void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);

//keyboard
void AppShell_KeyDown(Object^ sender, KeyRoutedEventArgs^ e);

// Track our independent input on a background worker thread.
Windows::Foundation::IAsyncAction^ m_inputLoopWorker;
Windows::UI::Core::CoreIndependentInputSource^ m_coreInput;
Expand Down
93 changes: 93 additions & 0 deletions HelpPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<Page
x:Class="VBA10.HelpPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VBA10"
xmlns:ctl="using:VBA10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<ctl:PageHeader>
<ctl:PageHeader.HeaderContent>
<TextBlock x:Name="title"
Style="{ThemeResource PageTitleTextBlockStyle}" Text="HELP"/>
</ctl:PageHeader.HeaderContent>
</ctl:PageHeader>

<Pivot Grid.Row="1" >
<PivotItem Header="Keyboard">
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left"
MaxWidth="440">
<TextBlock TextWrapping="Wrap" >
<Run Text="Here are some keyboard shortcut"/>
</TextBlock>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="About">
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Left"
MaxWidth="440">
<TextBlock TextWrapping="Wrap" >
<Run Text="VBA10"/>
</TextBlock>
<TextBlock TextWrapping="Wrap" Name="versionBlock"
Text="Version: check .cpp">
</TextBlock>

<TextBlock TextWrapping="Wrap" Name="contactBlock"
Tapped="contactBlock_Tapped"
>
<Run>Contact:&#160; </Run>
<Underline>
<Run Foreground="#4444D9">[email protected]</Run>
</Underline>
</TextBlock>

<TextBlock TextWrapping="Wrap" >
<LineBreak />
<Run Text="Feel free to report bugs or broken games."/>
<LineBreak />
<LineBreak />
<Run Text="The author is not responsible for any illegal use of this software. "/>
<LineBreak/>
<LineBreak/>
<Run Text="This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or(at your option) any later version. "/>
<LineBreak/>
<LineBreak/>
<Run Text="This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. "/>
<LineBreak/>
<LineBreak/>
<Run Text="You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA."/>
<LineBreak/>

</TextBlock>
<Button Name="gplButton" Content="GNU Public License v3"
Click="gplButton_Click"
Margin="0,0,0,8"/>

<Button Name="sourceButton" Content="Source code"
Click="sourceButton_Click"
Margin="0,0,0,8"/>

</StackPanel>
</ScrollViewer>
</PivotItem>
</Pivot>

</Grid>
</Page>
64 changes: 64 additions & 0 deletions HelpPage.xaml.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// HelpPage.xaml.cpp
// Implementation of the HelpPage class
//

#include "pch.h"
#include "HelpPage.xaml.h"

using namespace VBA10;

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

HelpPage::HelpPage()
{
InitializeComponent();

//get version
auto myPackage = Windows::ApplicationModel::Package::Current;
auto version = myPackage->Id->Version;
versionBlock->Text = "Version: " + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;

}

void HelpPage::gplButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Windows::System::Launcher::LaunchUriAsync(ref new Windows::Foundation::Uri("http://www.gnu.org/licenses/gpl-3.0.txt"));
}


void HelpPage::sourceButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Windows::System::Launcher::LaunchUriAsync(ref new Windows::Foundation::Uri("http://sdrv.ms/10ehg2a"));
}

void HelpPage::contactBlock_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
{
auto uri = ref new Windows::Foundation::Uri("mailto:[email protected]");

// Launch the URI
concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
launchUriOperation.then([](bool success)
{
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
});

}
26 changes: 26 additions & 0 deletions HelpPage.xaml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// HelpPage.xaml.h
// Declaration of the HelpPage class
//

#pragma once

#include "HelpPage.g.h"

namespace VBA10
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[Windows::Foundation::Metadata::WebHostHidden]
public ref class HelpPage sealed
{
public:
HelpPage();

private:
void gplButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void sourceButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void contactBlock_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
};
}
Loading

0 comments on commit 55f1988

Please sign in to comment.