Skip to content

Commit

Permalink
clean up code: move App.xaml.h out of pch.h
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Aug 3, 2015
1 parent 4b66478 commit 50f18a3
Show file tree
Hide file tree
Showing 19 changed files with 654 additions and 66 deletions.
5 changes: 4 additions & 1 deletion App.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
//

#include "pch.h"
#include "App.xaml.h"
#include "DirectXPage.xaml.h"
#include "EmulatorSettings.h"
#include "live_connect.h"

using namespace VBA10;

Expand All @@ -26,7 +28,7 @@ using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::ViewManagement;

ROMDatabase^ VBA10::App::ROMDB = nullptr;

//web::live::live_client* LiveClient = nullptr;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -40,6 +42,7 @@ App::App()
Resuming += ref new EventHandler<Object^>(this, &App::OnResuming);

ROMDB = ref new ROMDatabase();
//LiveClient = new web::live::live_client();
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions App.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DirectXPage.xaml.h"
#include "Database\ROMDatabase.h"
#include "EmulatorSettings.h"
#include "live_connect.h"

namespace VBA10
{
Expand All @@ -23,6 +24,9 @@ namespace VBA10

internal:
static ROMDatabase^ ROMDB;
static live::live_client* LiveClient;




private:
Expand All @@ -31,5 +35,6 @@ namespace VBA10
DirectXPage^ m_directXPage;



};
}
2 changes: 2 additions & 0 deletions CheatPane.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "CheatPane.g.h"
#include "CheatData.h"

using namespace Platform::Collections;

namespace VBA10
{
[Windows::Foundation::Metadata::WebHostHidden]
Expand Down
6 changes: 4 additions & 2 deletions Common/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "DeviceResources.h"
#include "DirectXHelper.h"
#include <windows.ui.xaml.media.dxinterop.h>
#include <algorithm>


using namespace D2D1;
using namespace DirectX;
Expand Down Expand Up @@ -220,8 +222,8 @@ void DX::DeviceResources::CreateWindowSizeDependentResources()
m_outputSize.Height = m_logicalSize.Height * m_compositionScaleY;

// Prevent zero size DirectX content from being created.
m_outputSize.Width = max(m_outputSize.Width, 1);
m_outputSize.Height = max(m_outputSize.Height, 1);
m_outputSize.Width = std::max(m_outputSize.Width, 1.0f);
m_outputSize.Height = std::max(m_outputSize.Height, 1.0f);

// The width and height of the swap chain must be based on the window's
// natively-oriented width and height. If the window is not in the native
Expand Down
2 changes: 1 addition & 1 deletion Converter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "pch.h"

#include <ppltasks.h>

//IMPORTANT NOTE: need to include this header file in both the .h and .cpp of an xaml page
Expand Down
60 changes: 60 additions & 0 deletions Definitions.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
#pragma once

#define DEFAULT_SNAPSHOT L"Assets/no_snapshot.png"

using namespace Windows::Storage;

namespace VBA10
{
public delegate void ROMSelectedDelegate(StorageFile ^file, StorageFolder ^folder);

[Windows::UI::Xaml::Data::BindableAttribute]
public ref class StorageFolderModel sealed
{
private:
public:
property StorageFolder ^Folder;

property Platform::String ^Name
{
Platform::String ^get()
{
return this->Folder->DisplayName;
}
}

property Platform::String ^Path
{
Platform::String ^get()
{
return this->Folder->Path;
}
}

StorageFolderModel(StorageFolder ^folder);
};

[Windows::UI::Xaml::Data::BindableAttribute]
public ref class StorageFileModel sealed
{
private:
public:
property StorageFile ^File;
property StorageFolder ^Folder;

property Platform::String ^Name
{
Platform::String ^get()
{
return this->File->Name;
}
}

property Platform::String ^Path
{
Platform::String ^get()
{
return this->Folder->Path;
}
}

StorageFileModel(StorageFile ^file, StorageFolder ^folder);
};
}
2 changes: 1 addition & 1 deletion DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Database\ROMDatabase.h"
#include "Definitions.h"
#include "stringhelper.h"

#include "App.xaml.h"

#include "NavMenuItem.h"
#include "NavMenuListView.h"
Expand Down
15 changes: 15 additions & 0 deletions EmulatorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ namespace VBA10
}
}

//keep track of whether the user successfully signed in before or not (so that we tried to silently resign in)
property bool SignedIn
{
bool get()
{
return GetValueOrDefault<bool>(SignedInKey, SignedInDefault);
}
void set(bool value)
{
AddOrUpdateValue(SignedInKey, value);
}
}



#pragma region Button positions
Expand Down Expand Up @@ -556,6 +569,7 @@ namespace VBA10
Platform::String^ TurboFrameSkipKey = "TurboFrameSkipKey";
Platform::String^ EnableTurboKey = "EnableTurboKey";
Platform::String^ FullScreenKey = "FullScreenKey";
Platform::String^ SignedInKey = "SignedInKey";

#pragma region button positions
Platform::String^ PadLeftPKey = "PadLeftPKey";
Expand Down Expand Up @@ -605,6 +619,7 @@ namespace VBA10
const int TurboFrameSkipDefault = 2;
const bool EnableTurboDefault = false;
const bool FullScreenDefault = false;
const bool SignedInDefault = false;


#pragma region button positions (in cm based on 6x10cm phone)
Expand Down
12 changes: 9 additions & 3 deletions ImportPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
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">
mc:Ignorable="d"
Loaded="Page_Loaded">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -66,10 +67,15 @@
<TextBlock TextWrapping="Wrap"
Text="Use this option to import rom through OneDrive. The rom will be copied to the app's private storage."
Margin=" 0, 4, 0, 4" />

<Button x:Name="SignInbtn" Content="Sign in"
Click="chooseFolderbtn_Click"
Width="248"
Margin =" 0, 4, 0, 4"/>

<TextBlock TextWrapping="Wrap"
<!--<TextBlock TextWrapping="Wrap"
Text="This function will be added in a future release. In the mean time, please store roms on your phone's SD Card or documents folder and use the Local Storage option."
Margin=" 0, 4, 0, 4" />
Margin=" 0, 4, 0, 4" />-->

</StackPanel>
</ScrollViewer>
Expand Down
23 changes: 23 additions & 0 deletions ImportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include "Database\ROMDBEntry.h"
#include "Database\ROMDatabase.h"
#include "SelectFilePane.xaml.h"
#include "App.xaml.h"

#include "stringhelper.h"



using namespace VBA10;

using namespace Platform;
Expand Down Expand Up @@ -252,3 +254,24 @@ void ImportPage::importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml:

});
}


void ImportPage::Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
//try re-sign in silently because access token expires every 1 hour
if (!EmulatorSettings::Current->SignedIn)
{
live::live_client* LiveClient = new live::live_client();
LiveClient->login(L"wl.skydrive_update wl.signin")
.then([this](bool isLoggedIn)
{
if (!isLoggedIn)
{
throw std::exception();
}
// Request the "me" object from OneDrive
// and pass the return value to the next continuation
//return model->LiveClient.get(L"me");
});
}
}
1 change: 1 addition & 0 deletions ImportPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ namespace VBA10
StorageFolder^ tmpfolder;
Platform::String^ tmptoken;
void importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
1 change: 1 addition & 0 deletions SelectFilePane.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

using namespace Windows::Foundation::Collections;
using namespace Platform::Collections;
using namespace Windows::Storage;

namespace VBA10
{
Expand Down
5 changes: 4 additions & 1 deletion SelectROMPane.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
//

#include "pch.h"

#include "SelectROMPane.xaml.h"
#include <Windows.h>

#include "DirectXPage.xaml.h";
#include "EmulatorSettings.h";
#include "EmulatorFileHandler.h"
#include "SelectStatePane.xaml.h"
#include "Database\ROMDBEntry.h"
#include "Converter.h"
#include "App.xaml.h"



using namespace VBA10;
Expand Down
59 changes: 5 additions & 54 deletions SelectROMPane.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,11 @@

#include "SelectROMPane.g.h"
#include "Converter.h"
#include "Definitions.h"
#include "Database\ROMDBEntry.h"

namespace VBA10
{
public delegate void ROMSelectedDelegate(StorageFile ^file, StorageFolder ^folder);

[Windows::UI::Xaml::Data::BindableAttribute]
public ref class StorageFolderModel sealed
{
private:
public:
property StorageFolder ^Folder;

property Platform::String ^Name
{
Platform::String ^get()
{
return this->Folder->DisplayName;
}
}

property Platform::String ^Path
{
Platform::String ^get()
{
return this->Folder->Path;
}
}

StorageFolderModel(StorageFolder ^folder);
};

[Windows::UI::Xaml::Data::BindableAttribute]
public ref class StorageFileModel sealed
{
private:
public:
property StorageFile ^File;
property StorageFolder ^Folder;

property Platform::String ^Name
{
Platform::String ^get()
{
return this->File->Name;
}
}

property Platform::String ^Path
{
Platform::String ^get()
{
return this->Folder->Path;
}
}

StorageFileModel(StorageFile ^file, StorageFolder ^folder);
};

[Windows::Foundation::Metadata::WebHostHidden]
public ref class SelectROMPane sealed
Expand Down Expand Up @@ -104,4 +52,7 @@ namespace VBA10
void ShowContextMenu(ROMDBEntry^ entry, Windows::Foundation::Rect rect);
void maximizebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};



}
Loading

0 comments on commit 50f18a3

Please sign in to comment.