Skip to content

Commit

Permalink
can now select state
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 14, 2015
1 parent cc86bd6 commit 9515b38
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 15 deletions.
34 changes: 26 additions & 8 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,38 @@ DirectXPage::DirectXPage():
//load settings
auto settings = ApplicationData::Current->LocalSettings->Values;

//copy DEMO ROm
if (!settings->HasKey("FIRSTSTART"))
{
settings->Insert("FIRSTSTART", dynamic_cast<PropertyValue^>(PropertyValue::CreateBoolean(false)));
this->CopyDemoROM();
}


//initalize main object for rendering
m_main = std::unique_ptr<VBA10Main>(new VBA10Main(m_deviceResources));

//start rendering
//DL: modified to not do it autmatically
//m_main->StartRenderLoop();


if (!settings->HasKey("FIRSTSTART"))
{
settings->Insert("FIRSTSTART", dynamic_cast<PropertyValue^>(PropertyValue::CreateBoolean(false)));

//copy DEMO ROm then open menu
CopyDemoROM().then([this]
{
//open menu
RootSplitView->IsPaneOpen = true;
});
}
else
{
//just open menu
RootSplitView->IsPaneOpen = true;
}
}

void DirectXPage::CopyDemoROM(void)
task<void> DirectXPage::CopyDemoROM(void)
{
StorageFolder ^installDir = Windows::ApplicationModel::Package::Current->InstalledLocation;
create_task(installDir->GetFolderAsync("Assets/")).then([](task<StorageFolder ^> t)
return create_task(installDir->GetFolderAsync("Assets/")).then([](task<StorageFolder ^> t)
{
StorageFolder ^assetsFolder = t.get();
return assetsFolder->GetFileAsync("Bunny Advance (Demo).gba");
Expand Down Expand Up @@ -474,3 +487,8 @@ void DirectXPage::Reset()
CloseMenu();
ResetSync();
}

void DirectXPage::SelectSaveState(int slot)
{
SelectSavestateSlot(slot);
}
3 changes: 2 additions & 1 deletion DirectXPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace VBA10
void SaveState();
void LoadState();
void Reset();
void SelectSaveState(int slot);

//from AppShell
internal:
Expand Down Expand Up @@ -77,7 +78,7 @@ namespace VBA10


//function
void CopyDemoROM(void);
task<void> CopyDemoROM(void);

// XAML low-level rendering event handler.
void OnRendering(Platform::Object^ sender, Platform::Object^ args);
Expand Down
18 changes: 12 additions & 6 deletions SelectROMPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="320"
Name="page"
>
<UserControl.Resources>
<Style x:Key="ROMListStyle" TargetType="ListBox">
Expand Down Expand Up @@ -245,11 +246,14 @@
ClosedDisplayMode="Compact">

<!--<AppBarSeparator/>-->
<AppBarButton Icon="Save" Label="Save" x:Name="saveBtn" Click="saveBtn_Click"
HorizontalContentAlignment="Left"/>
<AppBarButton Icon="AllApps" Label="Select State" x:Name="selectStateBtn" />
<AppBarButton Icon="Sync" Label="Reset" x:Name="resetBtn" Click="resetBtn_Click"/>
<AppBarButton Icon="Go" Label="Load" x:Name="loadBtn" Click="loadBtn_Click"/>
<AppBarButton Icon="Save" Label="Save" x:Name="saveBtn"
Click="saveBtn_Click" IsTabStop="False"/>
<AppBarButton Icon="AllApps" Label="Select State" x:Name="selectStateBtn"
Click="selectStateBtn_Click" IsTabStop="False"/>
<AppBarButton Icon="Sync" Label="Reset" x:Name="resetBtn"
Click="resetBtn_Click" IsTabStop="False"/>
<AppBarButton Icon="Go" Label="Load" x:Name="loadBtn"
Click="loadBtn_Click" IsTabStop="False"/>
<AppBarButton x:Name="spacerBtn" IsEnabled="False" Width="1000"/>
<!--<CommandBar.SecondaryCommands>
<AppBarButton Label="Menu Item 1"/>
Expand Down Expand Up @@ -284,7 +288,9 @@
RenderTransformOrigin="1.23,0.758" HorizontalAlignment="Right" Width="84" Height="66" VerticalAlignment="Top"/>

<ListBox Grid.Column="0" Name="romList" Margin="0,70,0,0" SelectionChanged="romList_SelectionChanged"
Background="Transparent" Style="{StaticResource ROMListStyle}" ItemContainerStyle="{StaticResource ROMListItemStyle}">
Background="Transparent" Style="{StaticResource ROMListStyle}"
ItemContainerStyle="{StaticResource ROMListItemStyle}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Left">
Expand Down
28 changes: 28 additions & 0 deletions SelectROMPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DirectXPage.xaml.h";
#include "EmulatorSettings.h";
#include "EmulatorFileHandler.h"
#include "SelectStatePane.xaml.h"

using namespace VBA10;

Expand Down Expand Up @@ -427,3 +428,30 @@ void SelectROMPane::resetBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::

dialog->ShowAsync();
}


void SelectROMPane::selectStateBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
Popup ^statePopup = ref new Popup();
statePopup->IsLightDismissEnabled = true;

SelectStatePane ^pane = ref new SelectStatePane(GetSavestateSlot());
statePopup->Child = pane;
//pane->Width = 200;//statePopup->Width;
pane->MaxHeight = Window::Current->Bounds.Height - 48; //statePopup->MaxHeight;


//auto transform = ((UIElement^)sender)->TransformToVisual(nullptr); //nullptr to get position related to windows
auto transform = ((UIElement^)topbar)->TransformToVisual(nullptr);

Windows::Foundation::Point point = transform->TransformPoint(Windows::Foundation::Point());
statePopup->HorizontalOffset = point.X; //+ selectStateBtn->ActualWidth / 2.0f - pane->Width / 2.0f;
statePopup->VerticalOffset = point.Y + selectStateBtn->ActualHeight;

//statePopup->Measure(Windows::Foundation::Size(Window::Current->Bounds.Width, Window::Current->Bounds.Height));
//statePopup->SetValue(Canvas::LeftProperty, Window::Current->Bounds.Left);
//statePopup->SetValue(Canvas::TopProperty, this->windowBounds.Height - (88 + pane->DesiredSize.Height));


statePopup->IsOpen = true;
}
1 change: 1 addition & 0 deletions SelectROMPane.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ namespace VBA10
void saveBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void loadBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void resetBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void selectStateBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
Loading

0 comments on commit 9515b38

Please sign in to comment.