Skip to content

Commit

Permalink
load rom database before DirectXPage to prevent blackscreen before menu
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 25, 2015
1 parent 6f836b9 commit 4fd5267
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 47 deletions.
44 changes: 24 additions & 20 deletions App.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,36 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent
Windows::Foundation::Size minsize = { 320.0f, 320.0f };
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->SetPreferredMinSize(minsize);

if (m_directXPage == nullptr)
{
m_directXPage = ref new DirectXPage();
}
App::ROMDB->Initialize().then([this, e] {
if (m_directXPage == nullptr)
{
m_directXPage = ref new DirectXPage();
}



// Create a AppShell to act as the navigation context and navigate to the first page
//auto shell = ref new AppShell();
// Create a AppShell to act as the navigation context and navigate to the first page
//auto shell = ref new AppShell();

//if (shell->AppFrame->Content == nullptr)
//{
// // When the navigation stack isn't restored navigate to the first page,
// // suppressing the initial entrance animation and configuring the new
// // page by passing required information as a navigation parameter
// //shell->AppFrame->Navigate(TypeName(Views::LandingPage::typeid), e->Arguments, ref new Windows::UI::Xaml::Media::Animation::SuppressNavigationTransitionInfo());
//}
//if (shell->AppFrame->Content == nullptr)
//{
// // When the navigation stack isn't restored navigate to the first page,
// // suppressing the initial entrance animation and configuring the new
// // page by passing required information as a navigation parameter
// //shell->AppFrame->Navigate(TypeName(Views::LandingPage::typeid), e->Arguments, ref new Windows::UI::Xaml::Media::Animation::SuppressNavigationTransitionInfo());
//}

if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
{
m_directXPage->LoadInternalState(ApplicationData::Current->LocalSettings->Values);
}
if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
{
m_directXPage->LoadInternalState(ApplicationData::Current->LocalSettings->Values);
}

// Place the page in the current window and ensure that it is active.
Window::Current->Content = m_directXPage;
Window::Current->Activate();
// Place the page in the current window and ensure that it is active.

Window::Current->Content = m_directXPage;
Window::Current->Activate();
});

}

/// <summary>
Expand Down
45 changes: 19 additions & 26 deletions DirectXPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,40 +187,33 @@ DirectXPage::DirectXPage():
//DL: modified to not do it autmatically
//m_main->StartRenderLoop();

//open the database
App::ROMDB->Initialize().then([this, settings]
{
if (!settings->HasKey("FIRSTSTART"))
{
settings->Insert("FIRSTSTART", dynamic_cast<PropertyValue^>(PropertyValue::CreateBoolean(false)));

//copy DEMO ROm then open menu
return CopyDemoROM();
}
else
return create_task([] {});
//}).then([this]
//{
//test insert ROM
//ROMDBEntry^ entry = ref new ROMDBEntry(0, "Test game", "testgame.gba", "D:\\ROM");
//return App::ROMDB->Add(entry);

//test obtain ROM
//auto entry = App::ROMDB->AllROMDBEntries->GetAt(1);



}).then([this]
// create_task([this] {return CopyDemoROMAsync();}).then([this] //NOTE: this will make CopyDemoROM to run on background thread
//and cause exception at entry->Snapshot->SetSourceAsync(stream);

CopyDemoROMAsync().then([this] //NOTE: this let CopyDemonROM to run on UI thread
{
//open menu
RootSplitView->IsPaneOpen = true;
//open menu, need dispatcher to move it to UI thread, otherwise exception
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
{
RootSplitView->IsPaneOpen = true;
}));

});


}

task<void> DirectXPage::CopyDemoROM(void)
task<void> DirectXPage::CopyDemoROMAsync(void)
{
auto settings = ApplicationData::Current->LocalSettings->Values;

if (settings->HasKey("FIRSTSTART"))
return create_task([] {});



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

StorageFolder ^installDir = Windows::ApplicationModel::Package::Current->InstalledLocation;
return create_task(installDir->GetFolderAsync("Assets/"))
Expand Down
2 changes: 1 addition & 1 deletion DirectXPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace VBA10
StorageFolder^ tmpfolder;

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


// XAML low-level rendering event handler.
Expand Down

0 comments on commit 4fd5267

Please sign in to comment.