Skip to content

Commit

Permalink
add safeguard to prevent app save settings when failed to switch to s…
Browse files Browse the repository at this point in the history
…creen mode

more localization
  • Loading branch information
duchuule committed Sep 25, 2015
1 parent b9401a5 commit 0d794b0
Show file tree
Hide file tree
Showing 13 changed files with 424 additions and 127 deletions.
15 changes: 9 additions & 6 deletions Common/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,17 @@ void DX::DeviceResources::CreateWindowSizeDependentResources()

if (m_swapChain != nullptr)
{

// If the swap chain already exists, resize it.
//this will crash under full screen on certain graphic cards
HRESULT hr = m_swapChain->ResizeBuffers(
2, // Double-buffered swap chain.
lround(m_d3dRenderTargetSize.Width),
lround(m_d3dRenderTargetSize.Height),
DXGI_FORMAT_B8G8R8A8_UNORM,
0
);
2, // Double-buffered swap chain.
lround(m_d3dRenderTargetSize.Width),
lround(m_d3dRenderTargetSize.Height),
DXGI_FORMAT_B8G8R8A8_UNORM,
0
);


if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
{
Expand Down
21 changes: 13 additions & 8 deletions ImportPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@

<StackPanel Orientation="Horizontal"
Margin="0,4,0,4">
<Button x:Name="chooseFolderbtn" Content="Import ROM"
<Button x:Name="chooseFolderbtn" Content="**Import ROM"
Click="chooseFolderbtn_Click"
Width="120"
Margin =" 0, 0, 8, 0"/>
Margin =" 0, 0, 8, 0"
x:Uid="ImportROMBtn"/>

<Button x:Name="importSavbtn" Content="Import Save"
<Button x:Name="importSavbtn" Content="**Import Save"
Width="120"
Margin ="0"
Click="importSavbtn_Click"/>
Click="importSavbtn_Click"
x:Uid="ImportSaveBtn"/>
</StackPanel>

<TextBlock Text="OneDrive"
Expand All @@ -69,8 +71,9 @@
Margin="0,8,0,0"
/>
<TextBlock TextWrapping="Wrap"
Text="Use this option to import roms and save files from OneDrive, which will be copied to the app's private storage. NOTE: It is recommended that you store the roms on an user-accessible folder and use the Local Storage option to import them, which will prevent loss of progress if you the app every becomes corrupted."
Margin=" 0, 4, 0, 4" />
Text="**Use this option to"
Margin=" 0, 4, 0, 4"
x:Uid="ImportOneDriveInstruction"/>


<!--<TextBlock x:Name="txtSignedIn"
Expand All @@ -80,15 +83,17 @@
/>-->
<StackPanel Orientation="Horizontal"
Margin="0,4,0,12">
<Button x:Name="SignInbtn" Content="Sign in"
<Button x:Name="SignInbtn" Content="**Sign in"
Click="SignInbtn_Click"
Width="120"
x:Uid="SignInBtn"
Margin =" 0, 0, 8, 0"/>

<Button x:Name="importOneDriveROMbtn" Content="Import R/S"
<Button x:Name="importOneDriveROMbtn" Content="**Import R/S"
Click="importOneDriveROMbtn_Click"
Width="120"
IsEnabled="False"
x:Uid="ImportRSBtn"
Margin =" 0, 0, 0, 0"/>

<!--<Button x:Name="importOneDriveSavebtn" Content="Import Save"
Expand Down
37 changes: 22 additions & 15 deletions ImportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using namespace Windows::Storage::Search;
using namespace Windows::Storage::Streams;
using namespace Concurrency;


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

ImportPage::ImportPage()
Expand All @@ -54,6 +55,8 @@ ImportPage::ImportPage()

void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();

FolderPicker ^picker = ref new FolderPicker();

picker->FileTypeFilter->Append(".gba");
Expand All @@ -66,9 +69,9 @@ void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xa
//picker->FileTypeFilter->Append(".7z");

picker->ViewMode = PickerViewMode::List;
picker->CommitButtonText = "Select ROM Directory";
picker->CommitButtonText = loader->GetString("SelectROMDirText");

task<void> t = create_task(picker->PickSingleFolderAsync()).then([this](StorageFolder ^folder)
task<void> t = create_task(picker->PickSingleFolderAsync()).then([this, loader](StorageFolder ^folder)
{
if (folder)
{
Expand Down Expand Up @@ -100,7 +103,7 @@ void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xa
options->FileTypeFilter->Append(".gb");
//TODO: add support for other file types
return create_task(folder->CreateFileQueryWithOptions(options)->GetFilesAsync())
.then([this, tmpfolder, tmptoken](IVectorView<StorageFile ^> ^files)
.then([this, tmpfolder, tmptoken, loader](IVectorView<StorageFile ^> ^files)
{

//open panel to let user select file
Expand All @@ -111,12 +114,12 @@ void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xa
for (int i = 0; i < files->Size; i++)
fileNames->Append(files->GetAt(i)->Name);

SelectFilesPane ^pane = ref new SelectFilesPane(fileNames, "Select file(s) to import");
SelectFilesPane ^pane = ref new SelectFilesPane(fileNames, loader->GetString("SelectFileImportText"));
statePopup->Child = pane;
pane->Width = titleBar->ActualWidth;//statePopup->Width;
pane->MaxHeight = Window::Current->Bounds.Height - 48; //statePopup->MaxHeight;

pane->FilesSelectedCallback = ref new FilesSelectedDelegate([this, tmpfolder, tmptoken, files](IVector<int>^ selectedIndices)
pane->FilesSelectedCallback = ref new FilesSelectedDelegate([this, tmpfolder, tmptoken, files, loader](IVector<int>^ selectedIndices)
{

vector<task<void>> tasks;
Expand Down Expand Up @@ -205,15 +208,15 @@ void ImportPage::chooseFolderbtn_Click(Platform::Object^ sender, Windows::UI::Xa
}
}

when_all(begin(tasks), end(tasks)).then([this](task<void> t)
when_all(begin(tasks), end(tasks)).then([this, loader](task<void> t)
{
try
{
t.get();
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([]()
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([loader]()
{
// .get() didn't throw, so we succeeded, print out success message
MessageDialog ^dialog = ref new MessageDialog("Files imported successfully.");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("FilesImportSuccessText"));
dialog->ShowAsync();
}));

Expand Down Expand Up @@ -261,8 +264,10 @@ void ImportPage::importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml:

picker->ViewMode = PickerViewMode::List;
//picker->CommitButtonText = "Select";
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();

task<void> t = create_task(picker->PickSingleFileAsync()).then([this](StorageFile ^file)

task<void> t = create_task(picker->PickSingleFileAsync()).then([this, loader](StorageFile ^file)
{
if (file)
{
Expand All @@ -283,7 +288,7 @@ void ImportPage::importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml:

if (entry == nullptr)
{
MessageDialog ^dialog = ref new MessageDialog("Could not find a matching ROM name.", "Error");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("NoMatchingROMError"), loader->GetString("ErrorText"));
dialog->ShowAsync();
return create_task([] {});
}
Expand All @@ -296,16 +301,16 @@ void ImportPage::importSavbtn_Click(Platform::Object^ sender, Windows::UI::Xaml:
Platform::String^ pfolderpath = ref new Platform::String(folderpath.c_str());
if (pfolderpath == entry->Folder->Path)
{
MessageDialog ^dialog = ref new MessageDialog("Save file imported successfully.");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("SaveFileImportSuccessText"));
dialog->ShowAsync();
return create_task([] {});
}
else
{
return create_task(file->CopyAsync(entry->Folder, file->Name, NameCollisionOption::ReplaceExisting))
.then([](StorageFile^ file)
.then([loader](StorageFile^ file)
{
MessageDialog ^dialog = ref new MessageDialog("Save file imported successfully.");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("SaveFileImportSuccessText"));
dialog->ShowAsync();
return create_task([] {});
});
Expand Down Expand Up @@ -349,16 +354,18 @@ void ImportPage::SignInbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::Ro

void ImportPage::signin_Completed(bool isLoggedIn)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();

if (isLoggedIn)
{
this->SignInbtn->Content = "Signed in";
this->SignInbtn->Content = loader->GetString("SignedInText");
this->SignInbtn->IsEnabled = false;
this->importOneDriveROMbtn->IsEnabled = true;
EmulatorSettings::Current->SignedIn = true;
}
else
{
this->SignInbtn->Content = "Sign in";
this->SignInbtn->Content = loader->GetString("SignInText");
this->SignInbtn->IsEnabled = true;
this->importOneDriveROMbtn->IsEnabled = false;
EmulatorSettings::Current->SignedIn = false;
Expand Down
26 changes: 13 additions & 13 deletions PurchasePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,39 @@
<TextBlock TextWrapping="Wrap"

Margin=" 0, 4, 0, 4" >
<Run Text="Dear VBA10 users:" />
<Run Text="**Dear" x:Uid="DearVBA10Users" />
<LineBreak/>
<Run Text="This is a *warning* about in-app purchase in Windows 10. " />
<Run Text="For a small percentage of Microsoft accounts, mine included, after you purchase the in-app products, you will experience the following problems: " />
<Run Text="(1) app crashes upon opening, " />
<Run Text="(2) app can no longer be downloaded from store due to error 0x803F7002, " />
<Run Text="and (3) even if you sideload the app, the store still reports the product as not purchased. " />
<Run Text="**This is a *warning*"
x:Uid="PurchaseWarning1"
/>
<LineBreak/>
<LineBreak/>
<Run Text="If you want to take risk, click on the button below to load the products. " />
<Run Text="Keep in mind that Microsoft handles all the purchases, so I cannot refund you anything should your purchase does not work." />
<Run Text="I can, however, provide you with the .appx to sideload if you can no longer download the app. " />
<Run Text="To current VBA8 paid users: an update will be available soon which lets you request unlock codes, but be aware: using an unlock code has all the same bugs as paying for the products, except you won't lose money."/>
<Run Text="If you want to take risk**"
x:Uid="PurchaseWarning2"/>
</TextBlock>

<Button x:Name="loadProductsBtn"
Content="Load products"
Content="**Load products"
Margin="0,4,0,12"
Click="loadProductsBtn_Click"
x:Uid="LoadProductBtn"
/>
<TextBlock Text="Loading production list. Please wait..."
<TextBlock Text="**Loading production"
TextWrapping="Wrap"
Margin="0,48,0,12"
Visibility="Collapsed"
x:Name="txtLoading"
x:Uid="LoadingProduct"

/>

<TextBlock Text="Error! No Internet connection or Microsoft server error. Please try again later."
<TextBlock Text="**Error! No Internet "
TextWrapping="Wrap"
Margin="0,0,0,12"
Foreground="Red"
Visibility="Collapsed"
x:Name="txtError"
x:Uid="LoadingProductError"
/>

<!--<Grid>
Expand Down Expand Up @@ -134,6 +133,7 @@
Visibility="{Binding BuyNowButtonVisible}"
Click="ButtonBuyNow_Clicked"
Tag="{Binding key}"
x:Uid="PurchaseBtn"
/>
</StackPanel>
</Grid>
Expand Down
20 changes: 12 additions & 8 deletions PurchasePage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ void PurchasePage::ButtonBuyNow_Clicked(Platform::Object^ sender, Windows::UI::X

if (CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive)
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();

//prompt user to restart app if it's ad removal
if (key == "removeads" || key == "noads_premium")
{
MessageDialog ^dialog = ref new MessageDialog("Purchase successful, ads will not be shown the next time you start the app.");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("PurchaseSuccessNoAdsText"));
dialog->ShowAsync();
}

if (key == "premiumfeatures")
{
MessageDialog ^dialog = ref new MessageDialog("Purchase successful.");
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("PurchaseSuccessText"));
dialog->ShowAsync();
}

Expand Down Expand Up @@ -111,6 +113,8 @@ void PurchasePage::loadProductsBtn_Click(Platform::Object^ sender, Windows::UI::
{
try
{
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();

ListingInformation^ li = tli.get();

Vector<ProductItem^>^ picItems = ref new Vector<ProductItem^>();
Expand All @@ -127,13 +131,13 @@ void PurchasePage::loadProductsBtn_Click(Platform::Object^ sender, Windows::UI::
if (li->ProductListings->HasKey(key))
{
auto pListing = li->ProductListings->Lookup(key);
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? "Purchased, thank you!" : pListing->FormattedPrice;
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? loader->GetString("PurchasedThankText") : pListing->FormattedPrice;
buyButtonVisibility = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? Windows::UI::Xaml::Visibility::Collapsed : Windows::UI::Xaml::Visibility::Visible;
pname = pListing->Name;
}
else
{
status = "Product is not available at the moment.";
status = loader->GetString("ProductNotAvailableText");
buyButtonVisibility = Windows::UI::Xaml::Visibility::Collapsed;
pname = "No Ads + Premium Features";
}
Expand All @@ -153,13 +157,13 @@ void PurchasePage::loadProductsBtn_Click(Platform::Object^ sender, Windows::UI::
if (li->ProductListings->HasKey(key))
{
auto pListing = li->ProductListings->Lookup(key);
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? "Purchased, thank you!" : pListing->FormattedPrice;
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? loader->GetString("PurchasedThankText") : pListing->FormattedPrice;
buyButtonVisibility = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? Windows::UI::Xaml::Visibility::Collapsed : Windows::UI::Xaml::Visibility::Visible;
pname = pListing->Name;
}
else
{
status = "Product is not available at the moment.";
status = loader->GetString("ProductNotAvailableText");
buyButtonVisibility = Windows::UI::Xaml::Visibility::Collapsed;
pname = "Remove ads";
}
Expand All @@ -179,13 +183,13 @@ void PurchasePage::loadProductsBtn_Click(Platform::Object^ sender, Windows::UI::
if (li->ProductListings->HasKey(key))
{
auto pListing = li->ProductListings->Lookup(key);
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? "Purchased, thank you!" : pListing->FormattedPrice;
status = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? loader->GetString("PurchasedThankText") : pListing->FormattedPrice;
buyButtonVisibility = CurrentApp::LicenseInformation->ProductLicenses->Lookup(key)->IsActive ? Windows::UI::Xaml::Visibility::Collapsed : Windows::UI::Xaml::Visibility::Visible;
pname = pListing->Name;
}
else
{
status = "Product is not available at the moment.";
status = loader->GetString("ProductNotAvailableText");
buyButtonVisibility = Windows::UI::Xaml::Visibility::Collapsed;
pname = "Premium Features";
}
Expand Down
3 changes: 2 additions & 1 deletion SelectFilePane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
</StackPanel>

<TextBlock x:Name="txtNoFile" Grid.Row="1"
Text="No supported file found!"
Text="**No supported file found!"
Foreground="Red"
x:Uid="NoSupportedFile"
Margin="10,8,0,8"/>

<ListBox Name="fileList"
Expand Down
6 changes: 4 additions & 2 deletions SelectFilesPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@
Margin="0,4,0,4"
Grid.Row="2"
HorizontalAlignment="Center">
<Button Content="Cancel"
<Button Content="**Cancel"
Width="120"
HorizontalAlignment="Center"
x:Name="CancelBtn"
Click="CancelBtn_Click"
Margin="0,0,8,0"
x:Uid="CancelBtn"
/>

<Button Content="OK"
<Button Content="**OK"
Width="120"
HorizontalAlignment="Center"
x:Name="OkBtn"
Click="OkBtn_Click"
x:Uid="OKBtn"
/>
</StackPanel>

Expand Down
Loading

0 comments on commit 0d794b0

Please sign in to comment.