Skip to content

Commit

Permalink
UI: Show a reset button on the crash screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Aug 9, 2021
1 parent bd99574 commit eb8a239
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,19 @@ void EmuScreen::CreateViews() {
if (g_Config.bShowDeveloperMenu) {
root_->Add(new Button(dev->T("DevMenu")))->OnClick.Handle(this, &EmuScreen::OnDevTools);
}
resumeButton_ = root_->Add(new Button(dev->T("Resume"), new AnchorLayoutParams(bounds.centerX(), NONE, NONE, 60, true)));

LinearLayout *buttons = new LinearLayout(Orientation::ORIENT_HORIZONTAL, new AnchorLayoutParams(bounds.centerX(), NONE, NONE, 60, true));
buttons->SetSpacing(20.0f);
root_->Add(buttons);

resumeButton_ = buttons->Add(new Button(dev->T("Resume")));
resumeButton_->OnClick.Handle(this, &EmuScreen::OnResume);
resumeButton_->SetVisibility(V_GONE);

resetButton_ = buttons->Add(new Button(dev->T("Reset")));
resetButton_->OnClick.Handle(this, &EmuScreen::OnReset);
resetButton_->SetVisibility(V_GONE);

cardboardDisableButton_ = root_->Add(new Button(sc->T("Cardboard VR OFF"), new AnchorLayoutParams(bounds.centerX(), NONE, NONE, 30, true)));
cardboardDisableButton_->OnClick.Handle(this, &EmuScreen::OnDisableCardboard);
cardboardDisableButton_->SetVisibility(V_GONE);
Expand Down Expand Up @@ -914,12 +923,20 @@ UI::EventReturn EmuScreen::OnResume(UI::EventParams &params) {
return UI::EVENT_DONE;
}

UI::EventReturn EmuScreen::OnReset(UI::EventParams &params) {
if (coreState == CoreState::CORE_RUNTIME_ERROR) {
NativeMessageReceived("reset", "");
}
return UI::EVENT_DONE;
}

void EmuScreen::update() {
using namespace UI;

UIScreen::update();
onScreenMessagesView_->SetVisibility(g_Config.bShowOnScreenMessages ? V_VISIBLE : V_GONE);
resumeButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR && Memory::MemFault_MayBeResumable() ? V_VISIBLE : V_GONE);
resetButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR ? V_VISIBLE : V_GONE);

if (bootPending_) {
bootGame(gamePath_);
Expand Down
2 changes: 2 additions & 0 deletions UI/EmuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class EmuScreen : public UIScreen {
UI::EventReturn OnDisableCardboard(UI::EventParams &params);
UI::EventReturn OnChat(UI::EventParams &params);
UI::EventReturn OnResume(UI::EventParams &params);
UI::EventReturn OnReset(UI::EventParams &params);

void bootGame(const Path &filename);
bool bootAllowStorage(const Path &filename);
Expand Down Expand Up @@ -98,6 +99,7 @@ class EmuScreen : public UIScreen {
UI::Spinner *loadingSpinner_ = nullptr;
UI::TextView *loadingTextView_ = nullptr;
UI::Button *resumeButton_ = nullptr;
UI::Button *resetButton_ = nullptr;
UI::View *chatButton_ = nullptr;

UI::Button *cardboardDisableButton_ = nullptr;
Expand Down

0 comments on commit eb8a239

Please sign in to comment.