2015-06-09 13:29:15 +00:00
|
|
|
|
//
|
|
|
|
|
|
// SelectROMPane.xaml.cpp
|
|
|
|
|
|
// Implementation of the SelectROMPane class
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "pch.h"
|
2015-08-03 13:36:25 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
#include "SelectROMPane.xaml.h"
|
2015-08-03 13:36:25 +00:00
|
|
|
|
|
2015-08-04 03:27:54 +00:00
|
|
|
|
#include "DirectXPage.xaml.h"
|
|
|
|
|
|
#include "EmulatorSettings.h"
|
2015-06-12 20:34:55 +00:00
|
|
|
|
#include "EmulatorFileHandler.h"
|
2015-06-14 17:41:27 +00:00
|
|
|
|
#include "SelectStatePane.xaml.h"
|
2015-06-18 22:29:52 +00:00
|
|
|
|
#include "Database\ROMDBEntry.h"
|
2015-06-20 23:07:48 +00:00
|
|
|
|
#include "Converter.h"
|
2015-08-03 13:36:25 +00:00
|
|
|
|
#include "App.xaml.h"
|
2015-08-22 21:51:33 +00:00
|
|
|
|
#include "AdControl.xaml.h"
|
2015-08-03 13:36:25 +00:00
|
|
|
|
|
2015-06-20 23:07:48 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
2015-06-12 20:34:55 +00:00
|
|
|
|
using namespace Windows::UI::Popups;
|
2015-06-09 13:29:15 +00:00
|
|
|
|
using namespace Windows::Storage::Pickers;
|
|
|
|
|
|
using namespace Windows::Storage;
|
|
|
|
|
|
using namespace Windows::Storage::AccessCache;
|
2015-08-02 15:48:12 +00:00
|
|
|
|
using namespace Windows::UI::ViewManagement;
|
2015-09-27 05:11:09 +00:00
|
|
|
|
using namespace Windows::ApplicationModel::Resources;
|
2015-10-09 13:48:56 +00:00
|
|
|
|
using namespace Windows::Devices::HumanInterfaceDevice;
|
|
|
|
|
|
using namespace Windows::Devices::Enumeration;
|
2015-06-09 13:29:15 +00:00
|
|
|
|
|
|
|
|
|
|
StorageFolderModel::StorageFolderModel(StorageFolder ^folder)
|
|
|
|
|
|
{
|
|
|
|
|
|
this->Folder = folder;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StorageFileModel::StorageFileModel(StorageFile ^file, StorageFolder ^folder)
|
|
|
|
|
|
{
|
|
|
|
|
|
this->File = file;
|
|
|
|
|
|
this->Folder = folder;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
SelectROMPane::SelectROMPane()
|
|
|
|
|
|
{
|
2015-06-18 22:29:52 +00:00
|
|
|
|
initdone = false;
|
2015-06-12 20:34:55 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
this->InitializeComponent();
|
2015-07-31 16:32:11 +00:00
|
|
|
|
|
2015-10-09 13:48:56 +00:00
|
|
|
|
|
|
|
|
|
|
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
//move command bar to bottom if setting says so
|
|
|
|
|
|
if ((EmulatorSettings::Current->CommandButtonPosition == 0 && Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
|
|
|
|
|
|
|| EmulatorSettings::Current->CommandButtonPosition == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
svContainer->SetValue(Grid::RowProperty, 0);
|
|
|
|
|
|
LayoutRoot->RowDefinitions->GetAt(0)->Height = GridLength(1, GridUnitType::Star);
|
|
|
|
|
|
|
2015-09-27 06:05:05 +00:00
|
|
|
|
LayoutRoot->RowDefinitions->GetAt(1)->Height = GridLength::Auto;
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
topbar->SetValue(Grid::RowProperty, 2);
|
|
|
|
|
|
|
2015-09-27 06:05:05 +00:00
|
|
|
|
if (App::HasAds)
|
|
|
|
|
|
{
|
|
|
|
|
|
AdControl^ adControl = ref new AdControl();
|
|
|
|
|
|
LayoutRoot->Children->Append(adControl);
|
|
|
|
|
|
adControl->SetValue(Grid::RowProperty, 1);
|
|
|
|
|
|
}
|
2015-09-27 05:11:09 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
2015-09-27 06:05:05 +00:00
|
|
|
|
else
|
2015-08-22 21:51:33 +00:00
|
|
|
|
{
|
2015-09-27 06:05:05 +00:00
|
|
|
|
topbar->SetValue(Grid::RowProperty, 0);
|
|
|
|
|
|
LayoutRoot->RowDefinitions->GetAt(0)->Height = GridLength::Auto;
|
|
|
|
|
|
|
|
|
|
|
|
svContainer->SetValue(Grid::RowProperty, 1);
|
|
|
|
|
|
LayoutRoot->RowDefinitions->GetAt(1)->Height = GridLength(1, GridUnitType::Star);
|
|
|
|
|
|
|
|
|
|
|
|
if (App::HasAds)
|
|
|
|
|
|
{
|
|
|
|
|
|
AdControl^ adControl = ref new AdControl();
|
|
|
|
|
|
LayoutRoot->Children->Append(adControl);
|
|
|
|
|
|
adControl->SetValue(Grid::RowProperty, 2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-22 21:51:33 +00:00
|
|
|
|
}
|
2015-06-18 22:29:52 +00:00
|
|
|
|
|
2015-09-27 06:05:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-18 22:29:52 +00:00
|
|
|
|
//bind list of ROM to display
|
2015-06-25 15:13:26 +00:00
|
|
|
|
cvsAllROMEntries->Source = App::ROMDB->AllROMDBEntries;
|
2015-06-18 22:29:52 +00:00
|
|
|
|
romList->SelectedItem = nullptr;
|
|
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
//refresh last played image
|
|
|
|
|
|
ResetLastPlayedImage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//disable the command bar if no rom is loaded
|
|
|
|
|
|
topbar->IsEnabled = IsROMLoaded();
|
|
|
|
|
|
|
2015-10-09 13:48:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
initdone = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::ResetLastPlayedImage()
|
|
|
|
|
|
{
|
2015-06-25 15:13:26 +00:00
|
|
|
|
//find the most recently play game
|
|
|
|
|
|
if (App::ROMDB->AllROMDBEntries->Size == 0) //no rom in list
|
2015-08-01 03:49:59 +00:00
|
|
|
|
{
|
2015-06-25 15:13:26 +00:00
|
|
|
|
lastRomGrid->Visibility = Windows::UI::Xaml::Visibility::Collapsed; //collapse
|
2015-08-01 03:49:59 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2015-06-25 15:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
2015-08-03 17:00:09 +00:00
|
|
|
|
for (unsigned int i = 1; i < App::ROMDB->AllROMDBEntries->Size; i++)
|
2015-06-25 15:13:26 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2015-06-09 13:29:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
//void SelectROMPane::DeleteFolderClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// Button ^button = safe_cast<Button ^>(sender);
|
|
|
|
|
|
// StorageFolderModel ^model = safe_cast<StorageFolderModel ^>(button->DataContext);
|
|
|
|
|
|
// StorageApplicationPermissions::FutureAccessList->Remove(model->Name);
|
|
|
|
|
|
// this->RemoveFolderByToken(model->Name);
|
|
|
|
|
|
// this->romDirList->ItemsSource = this->storageFolderVector;
|
|
|
|
|
|
// this->RefreshROMList();
|
|
|
|
|
|
//}
|
2015-06-09 13:29:15 +00:00
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
//void SelectROMPane::RemoveFolderByToken(Platform::String ^token)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// for (int i = 0; i < this->storageFolderVector->Size; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if(this->storageFolderVector->GetAt(i)->Name == token)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// this->storageFolderVector->RemoveAt(i);
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
2015-06-09 13:29:15 +00:00
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::RefreshROMList(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
this->storageFileVector->Clear();
|
|
|
|
|
|
|
|
|
|
|
|
if(this->storageFolderVector->Size == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFolder ^localfolder = ApplicationData::Current->LocalFolder;
|
|
|
|
|
|
create_task([localfolder]()
|
|
|
|
|
|
{
|
2015-07-06 04:39:58 +00:00
|
|
|
|
|
|
|
|
|
|
return localfolder->GetFileAsync("Bunny Advance (Demo).gba");
|
|
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
}).then([this, localfolder](StorageFile ^file)
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFileModel ^model = ref new StorageFileModel(file, localfolder);
|
|
|
|
|
|
this->storageFileVector->Append(model);
|
|
|
|
|
|
}).then([this]()
|
|
|
|
|
|
{
|
|
|
|
|
|
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
|
|
|
|
|
|
{
|
|
|
|
|
|
this->romList->ItemsSource = this->storageFileVector;
|
|
|
|
|
|
}));
|
|
|
|
|
|
}).then([](task<void> t)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
t.get();
|
|
|
|
|
|
}catch(...)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if _DEBUG
|
|
|
|
|
|
OutputDebugStringW(L"Cannot find demo ROM.");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Search::QueryOptions ^options = ref new Search::QueryOptions();
|
2015-07-06 04:39:58 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
options->FileTypeFilter->Append(".gba");
|
|
|
|
|
|
options->FileTypeFilter->Append(".gbc");
|
|
|
|
|
|
options->FileTypeFilter->Append(".gb");
|
2015-07-06 04:39:58 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StorageFolder ^folder = this->storageFolderVector->GetAt(0)->Folder;
|
|
|
|
|
|
task<void> t = create_task([this, folder, options]()
|
|
|
|
|
|
{
|
|
|
|
|
|
return folder->CreateFileQueryWithOptions(options)->GetFilesAsync();
|
|
|
|
|
|
}).then([this, folder](IVectorView<StorageFile ^> ^files)
|
|
|
|
|
|
{
|
2015-08-03 17:00:09 +00:00
|
|
|
|
for (unsigned int i = 0; i < files->Size; i++)
|
2015-06-09 13:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
StorageFileModel ^model = ref new StorageFileModel(files->GetAt(i), folder);
|
|
|
|
|
|
this->storageFileVector->Append(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2015-08-03 17:00:09 +00:00
|
|
|
|
for (unsigned int i = 1; i < this->storageFolderVector->Size; i++)
|
2015-06-09 13:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
StorageFolder ^folder = this->storageFolderVector->GetAt(i)->Folder;
|
|
|
|
|
|
t = t.then([this, folder, options]()
|
|
|
|
|
|
{
|
|
|
|
|
|
return folder->CreateFileQueryWithOptions(options)->GetFilesAsync();
|
|
|
|
|
|
}).then([this, folder](IVectorView<StorageFile ^> ^files)
|
|
|
|
|
|
{
|
2015-08-03 17:00:09 +00:00
|
|
|
|
for (unsigned int i = 0; i < files->Size; i++)
|
2015-06-09 13:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
StorageFileModel ^model = ref new StorageFileModel(files->GetAt(i), folder);
|
|
|
|
|
|
this->storageFileVector->Append(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StorageFolder ^localfolder = ApplicationData::Current->LocalFolder;
|
|
|
|
|
|
t = t.then([localfolder]()
|
|
|
|
|
|
{
|
2015-07-06 04:39:58 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
return localfolder->GetFileAsync("Bunny Advance (Demo).gba");
|
2015-07-06 04:39:58 +00:00
|
|
|
|
|
2015-06-09 13:29:15 +00:00
|
|
|
|
}).then([this, localfolder](StorageFile ^file)
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFileModel ^model = ref new StorageFileModel(file, localfolder);
|
|
|
|
|
|
this->storageFileVector->Append(model);
|
|
|
|
|
|
}).then([](task<void> t)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
t.get();
|
|
|
|
|
|
}catch(...)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if _DEBUG
|
|
|
|
|
|
OutputDebugStringW(L"Cannot find demo ROM.");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
t.then([this]()
|
|
|
|
|
|
{
|
|
|
|
|
|
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
|
|
|
|
|
|
{
|
|
|
|
|
|
this->romList->ItemsSource = this->storageFileVector;
|
|
|
|
|
|
}));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-11 05:21:49 +00:00
|
|
|
|
void SelectROMPane::romList_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
|
2015-06-09 13:29:15 +00:00
|
|
|
|
{
|
2015-06-18 22:29:52 +00:00
|
|
|
|
//StorageFileModel ^model = safe_cast<StorageFileModel ^>(this->romList->SelectedValue);
|
2015-06-12 20:34:55 +00:00
|
|
|
|
|
2015-06-11 05:21:49 +00:00
|
|
|
|
|
2015-06-18 22:29:52 +00:00
|
|
|
|
//DirectXPage::Current->LoadROM(model->File, model->Folder);
|
|
|
|
|
|
if (initdone && this->romList->SelectedItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
ROMDBEntry^ entry = safe_cast<ROMDBEntry^> (this->romList->SelectedValue);
|
2015-06-24 23:02:09 +00:00
|
|
|
|
DirectXPage::Current->LoadROM(entry);
|
2015-06-18 22:29:52 +00:00
|
|
|
|
|
2015-06-24 23:02:09 +00:00
|
|
|
|
//create_task([ entry]
|
2015-06-23 19:10:53 +00:00
|
|
|
|
//{
|
2015-06-24 23:02:09 +00:00
|
|
|
|
// return entry->Folder->GetFileAsync(entry->FileName);
|
2015-06-20 06:00:56 +00:00
|
|
|
|
|
2015-06-24 23:02:09 +00:00
|
|
|
|
//}).then([entry](StorageFile^ file)
|
2015-06-23 19:10:53 +00:00
|
|
|
|
//{
|
2015-06-24 23:02:09 +00:00
|
|
|
|
// return DirectXPage::Current->LoadROM(entry);
|
|
|
|
|
|
//});
|
2015-06-20 06:00:56 +00:00
|
|
|
|
|
2015-06-18 22:29:52 +00:00
|
|
|
|
|
|
|
|
|
|
#if _DEBUG
|
|
|
|
|
|
Platform::String ^message = entry->FileName;
|
|
|
|
|
|
wstring wstr(message->Begin(), message->End());
|
|
|
|
|
|
OutputDebugStringW(wstr.c_str());
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
2015-06-09 13:29:15 +00:00
|
|
|
|
}
|
2015-06-12 20:34:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::saveBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsSaveConfirmationDisabled())
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->SaveState();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-10-06 04:54:26 +00:00
|
|
|
|
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
|
2015-09-27 05:11:09 +00:00
|
|
|
|
|
|
|
|
|
|
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("OverwriteSaveConfirmText"),loader->GetString("OverwriteAsk"));
|
|
|
|
|
|
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
|
2015-06-12 20:34:55 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->SaveState();
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
//UICommand ^confirmRemember = ref new UICommand("Yes, don't ask again",
|
|
|
|
|
|
// ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// DisableSaveConfirmation(true);
|
|
|
|
|
|
// DirectXPage::Current->SaveState();
|
|
|
|
|
|
//}));
|
2015-06-12 20:34:55 +00:00
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
UICommand ^no = ref new UICommand(loader->GetString("NoText"),
|
2015-06-12 20:34:55 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
//do nothing
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
dialog->Commands->Append(confirm);
|
|
|
|
|
|
//dialog->Commands->Append(confirmRemember); //windows phone crashes when there are 3 options
|
|
|
|
|
|
dialog->Commands->Append(no);
|
|
|
|
|
|
|
|
|
|
|
|
dialog->DefaultCommandIndex = 0;
|
|
|
|
|
|
dialog->CancelCommandIndex = 1; //would be two if confirm remember is used
|
|
|
|
|
|
|
|
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-06-13 19:11:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::loadBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsLoadConfirmationDisabled())
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->LoadState();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-10-06 04:54:26 +00:00
|
|
|
|
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
|
2015-09-27 05:11:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("LoadConfirmPrompt"), loader->GetString("WarningText"));
|
|
|
|
|
|
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
|
2015-06-13 19:11:53 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->LoadState();
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
//UICommand ^confirmRemember = ref new UICommand("Yes, don't ask again",
|
|
|
|
|
|
// ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// DisableLoadConfirmation(true);
|
|
|
|
|
|
// DirectXPage::Current->LoadState();
|
|
|
|
|
|
//}));
|
2015-06-13 19:11:53 +00:00
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
UICommand ^no = ref new UICommand(loader->GetString("NoText"),
|
2015-06-13 19:11:53 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
//do nothing
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
dialog->Commands->Append(confirm);
|
|
|
|
|
|
//dialog->Commands->Append(confirmRemember);
|
|
|
|
|
|
dialog->Commands->Append(no);
|
|
|
|
|
|
|
|
|
|
|
|
dialog->DefaultCommandIndex = 0;
|
|
|
|
|
|
dialog->CancelCommandIndex = 1;
|
|
|
|
|
|
|
|
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-06-13 22:33:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::resetBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
2015-10-06 04:54:26 +00:00
|
|
|
|
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
|
2015-09-27 05:11:09 +00:00
|
|
|
|
|
|
|
|
|
|
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("ResetConfirmPrompt"), loader->GetString("WarningText"));
|
|
|
|
|
|
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
|
2015-06-13 22:33:35 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->Reset();
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
UICommand ^no = ref new UICommand(loader->GetString("NoText"),
|
2015-06-13 22:33:35 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
//do nothing
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
dialog->Commands->Append(confirm);
|
|
|
|
|
|
dialog->Commands->Append(no);
|
|
|
|
|
|
|
|
|
|
|
|
dialog->DefaultCommandIndex = 0;
|
|
|
|
|
|
dialog->CancelCommandIndex = 1;
|
|
|
|
|
|
|
|
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
}
|
2015-06-14 17:41:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::selectStateBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Popup ^statePopup = ref new Popup();
|
|
|
|
|
|
statePopup->IsLightDismissEnabled = true;
|
2015-09-29 06:30:12 +00:00
|
|
|
|
statePopup->MaxHeight = Window::Current->Bounds.Height - 48;
|
|
|
|
|
|
statePopup->IsLightDismissEnabled = true;
|
2015-06-14 17:41:27 +00:00
|
|
|
|
|
|
|
|
|
|
SelectStatePane ^pane = ref new SelectStatePane(GetSavestateSlot());
|
|
|
|
|
|
statePopup->Child = pane;
|
2015-09-29 06:30:12 +00:00
|
|
|
|
pane->Width = statePopup->Width;
|
|
|
|
|
|
pane->MaxHeight = statePopup->MaxHeight;
|
|
|
|
|
|
|
2015-06-14 17:41:27 +00:00
|
|
|
|
|
|
|
|
|
|
//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());
|
2015-07-29 21:55:35 +00:00
|
|
|
|
statePopup->HorizontalOffset = point.X + 1; //+ selectStateBtn->ActualWidth / 2.0f - pane->Width / 2.0f;
|
2015-06-14 17:41:27 +00:00
|
|
|
|
|
2015-09-29 06:30:12 +00:00
|
|
|
|
//command bar at bottom
|
|
|
|
|
|
if ((EmulatorSettings::Current->CommandButtonPosition == 0 && Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
|
|
|
|
|
|
|| EmulatorSettings::Current->CommandButtonPosition == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
statePopup->VerticalOffset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
statePopup->VerticalOffset = point.Y + selectStateBtn->ActualHeight;
|
|
|
|
|
|
|
2015-06-14 17:41:27 +00:00
|
|
|
|
//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;
|
|
|
|
|
|
}
|
2015-06-19 14:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::addROMbtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DirectXPage::Current->GoToPage(2);
|
|
|
|
|
|
}
|
2015-06-25 15:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::lastRomImage_Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ROMDBEntry^ entry = (ROMDBEntry^)this->lastRomImage->DataContext;
|
|
|
|
|
|
DirectXPage::Current->LoadROM(entry);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-07-30 05:06:08 +00:00
|
|
|
|
void SelectROMPane::RemoveROMButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button ^button = safe_cast<Button ^>(sender);
|
|
|
|
|
|
ROMDBEntry ^entry = safe_cast<ROMDBEntry ^>(button->DataContext);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
Rect SelectROMPane::GetElementRect(FrameworkElement^ element)
|
|
|
|
|
|
{
|
|
|
|
|
|
GeneralTransform^ buttonTransform = element->TransformToVisual(nullptr);
|
|
|
|
|
|
const Windows::Foundation::Point pointOrig(0, 0);
|
|
|
|
|
|
const Windows::Foundation::Point pointTransformed = buttonTransform->TransformPoint(pointOrig);
|
|
|
|
|
|
const Rect rect(pointTransformed.X, pointTransformed.Y, safe_cast<float>(element->ActualWidth), safe_cast<float>(element->ActualHeight));
|
|
|
|
|
|
return rect;
|
|
|
|
|
|
}
|
2015-06-25 15:13:26 +00:00
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::ContextMenuBtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create a menu and add commands specifying a callback delegate for each.
|
|
|
|
|
|
// Since command delegates are unique, no need to specify command Ids.
|
2015-08-01 03:49:59 +00:00
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
Button ^button = safe_cast<Button ^>(sender);
|
|
|
|
|
|
ROMDBEntry ^entry = safe_cast<ROMDBEntry ^>(button->DataContext);
|
2015-08-01 03:49:59 +00:00
|
|
|
|
auto rect = GetElementRect(safe_cast<FrameworkElement^>(sender));
|
2015-07-31 16:32:11 +00:00
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
ShowContextMenu( entry, rect);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void VBA10::SelectROMPane::lbAllROMMainGrid_RightTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Grid ^grid = safe_cast<Grid ^>(sender);
|
|
|
|
|
|
ROMDBEntry ^entry = safe_cast<ROMDBEntry ^>(grid->DataContext);
|
|
|
|
|
|
|
|
|
|
|
|
auto point = e->GetPosition(nullptr);
|
|
|
|
|
|
auto rect = Rect(point.X, point.Y, 10.0f, 10.0f);
|
|
|
|
|
|
ShowContextMenu( entry, rect);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::ShowContextMenu(ROMDBEntry^ entry, Windows::Foundation::Rect rect)
|
|
|
|
|
|
{
|
2015-10-06 04:54:26 +00:00
|
|
|
|
auto loader = Windows::ApplicationModel::Resources::ResourceLoader::GetForViewIndependentUse();
|
2015-09-27 05:11:09 +00:00
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
auto menu = ref new PopupMenu();
|
2015-09-27 05:11:09 +00:00
|
|
|
|
menu->Commands->Append(ref new UICommand(loader->GetString("DeleteText"), ref new UICommandInvokedHandler([this, entry, loader](IUICommand^ command)
|
2015-07-31 16:32:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (IsROMLoaded() && entry->FolderPath + L"\\" + entry->FileName == ROMFile->Path) //rom is runnning
|
|
|
|
|
|
{
|
2015-09-27 05:11:09 +00:00
|
|
|
|
MessageDialog ^dialog = ref new MessageDialog(loader->GetString("CannotDeleteRunningROMError"));
|
2015-07-31 16:32:11 +00:00
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageDialog ^dialog;
|
|
|
|
|
|
|
|
|
|
|
|
if (entry->LocationType == 0) //private folder
|
2015-09-27 05:11:09 +00:00
|
|
|
|
dialog = ref new MessageDialog(loader->GetString("DeleteROMPrompt"), loader->GetString("ConfirmText"));
|
2015-07-31 16:32:11 +00:00
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
else
|
2015-09-27 05:11:09 +00:00
|
|
|
|
dialog = ref new MessageDialog(loader->GetString("RemoveROMPrompt"), loader->GetString("ConfirmText"));
|
2015-08-01 03:49:59 +00:00
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
UICommand ^confirm = ref new UICommand(loader->GetString("YesText"),
|
2015-08-01 03:49:59 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this, entry](IUICommand ^cmd)
|
2015-07-31 16:32:11 +00:00
|
|
|
|
{
|
2015-08-01 03:49:59 +00:00
|
|
|
|
//find the index of the entry in the list
|
|
|
|
|
|
int idx = -1;
|
2015-08-04 03:27:54 +00:00
|
|
|
|
for (unsigned int i = 0; i < App::ROMDB->AllROMDBEntries->Size; i++)
|
2015-08-01 03:49:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
ROMDBEntry^ entry2 = App::ROMDB->AllROMDBEntries->GetAt(i);
|
|
|
|
|
|
if (entry2->Token == entry->Token && entry2->FileName == entry->FileName) //found the entry
|
|
|
|
|
|
{
|
|
|
|
|
|
idx = i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (idx == -1) //not found error
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (entry->LocationType == 0)
|
|
|
|
|
|
{
|
2015-08-05 04:08:51 +00:00
|
|
|
|
wstring name(entry->FileName->Begin(), entry->FileName->End());
|
|
|
|
|
|
int index = name.find_last_of('.');
|
|
|
|
|
|
//wstring ext = name.substr(index + 1);
|
|
|
|
|
|
|
|
|
|
|
|
wstring filenamenoext = name.substr(0, index);
|
|
|
|
|
|
|
|
|
|
|
|
wstring snapshotname = filenamenoext + L".jpg";
|
|
|
|
|
|
Platform::String^ psnapshotname = ref new Platform::String(snapshotname.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
wstring autosavename = filenamenoext + L"9.sgm";
|
|
|
|
|
|
Platform::String^ pautosavename = ref new Platform::String(autosavename.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
wstring sramname = filenamenoext + L".sav";
|
|
|
|
|
|
Platform::String^ psramname = ref new Platform::String(sramname.c_str());
|
|
|
|
|
|
|
2015-08-01 03:49:59 +00:00
|
|
|
|
//delete the rom file
|
2015-08-05 04:08:51 +00:00
|
|
|
|
create_task(entry->Folder->GetFileAsync(entry->FileName)).then([] (task<StorageFile^> tfile)
|
2015-08-01 03:49:59 +00:00
|
|
|
|
{
|
2015-08-05 04:08:51 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFile^ file = tfile.get();
|
|
|
|
|
|
file->DeleteAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Platform::Exception^) {}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//delete the snapshot file
|
|
|
|
|
|
create_task(entry->Folder->GetFileAsync(psnapshotname)).then([](task<StorageFile^> tfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFile^ file = tfile.get();
|
|
|
|
|
|
file->DeleteAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Platform::Exception^) {}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//delete the auto save file
|
|
|
|
|
|
create_task(entry->Folder->GetFileAsync(pautosavename)).then([](task<StorageFile^> tfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFile^ file = tfile.get();
|
|
|
|
|
|
file->DeleteAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Platform::Exception^) {}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//delete the sram file
|
|
|
|
|
|
create_task(entry->Folder->GetFileAsync(psramname)).then([](task<StorageFile^> tfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageFile^ file = tfile.get();
|
|
|
|
|
|
file->DeleteAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Platform::Exception^) {}
|
2015-08-01 03:49:59 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
App::ROMDB->AllROMDBEntries->RemoveAt(idx);
|
|
|
|
|
|
App::ROMDB->RemoveAsync(entry);
|
|
|
|
|
|
ResetLastPlayedImage();
|
2015-07-31 16:32:11 +00:00
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-27 05:11:09 +00:00
|
|
|
|
UICommand ^no = ref new UICommand(loader->GetString("NoText"),
|
2015-07-31 16:32:11 +00:00
|
|
|
|
ref new UICommandInvokedHandler([this](IUICommand ^cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
//do nothing
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
dialog->Commands->Append(confirm);
|
|
|
|
|
|
dialog->Commands->Append(no);
|
|
|
|
|
|
|
|
|
|
|
|
dialog->DefaultCommandIndex = 1;
|
|
|
|
|
|
dialog->CancelCommandIndex = 1;
|
|
|
|
|
|
|
|
|
|
|
|
dialog->ShowAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We don't want to obscure content, so pass in a rectangle representing the sender of the context menu event.
|
2015-08-01 03:49:59 +00:00
|
|
|
|
|
2015-07-31 16:32:11 +00:00
|
|
|
|
create_task(menu->ShowForSelectionAsync(rect, Placement::Below)).then([this](IUICommand^ command)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (command == nullptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
// The command is null if no command was invoked.
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2015-08-02 15:48:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SelectROMPane::maximizebtn_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationView^ view = ApplicationView::GetForCurrentView();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view->IsFullScreenMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
view->ExitFullScreenMode();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
view->TryEnterFullScreenMode();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|