mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add screenshots + extract LoadStateConfirmScreen
This commit is contained in:
+3
-10
@@ -76,10 +76,10 @@ using namespace std::placeholders;
|
||||
#include "Core/HLE/__sceAudio.h"
|
||||
#include "Core/HW/Display.h"
|
||||
|
||||
#include "Common/UI/PopupScreens.h"
|
||||
#include "UI/BackgroundAudio.h"
|
||||
#include "UI/GamepadEmu.h"
|
||||
#include "UI/PauseScreen.h"
|
||||
#include "UI/LoadStateConfirmScreen.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/Background.h"
|
||||
#include "UI/EmuScreen.h"
|
||||
@@ -509,7 +509,7 @@ EmuScreen::~EmuScreen() {
|
||||
|
||||
void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
|
||||
std::string_view tag = dialog->tag();
|
||||
if (tag == "TextEditPopup") {
|
||||
if (tag == "TextEditPopup" || tag == "LoadStateConfirm") {
|
||||
// Chat message finished.
|
||||
return;
|
||||
}
|
||||
@@ -1058,16 +1058,9 @@ void EmuScreen::ProcessVKey(VirtKey virtKey) {
|
||||
case VIRTKEY_LOAD_STATE:
|
||||
if (!Achievements::WarnUserIfHardcoreModeActive(false) && !NetworkWarnUserIfOnlineAndCantSavestate() && !bootPending_) {
|
||||
if (g_Config.bConfirmLoadState) {
|
||||
auto pa = GetI18NCategory(I18NCat::PAUSE);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
std::string prefix = SaveState::GetGamePrefix(g_paramSFO);
|
||||
int slot = g_Config.iCurrentStateSlot;
|
||||
std::string message(di->T("ConfirmLoadState"));
|
||||
std::string dateStr = SaveState::GetSlotDateAsString(prefix, slot);
|
||||
if (!dateStr.empty()) {
|
||||
message += "\n\n" + dateStr;
|
||||
}
|
||||
screenManager()->push(new UI::MessagePopupScreen(pa->T("Load State"), message, pa->T("Load State"), di->T("Cancel"), [prefix, slot](bool result) {
|
||||
screenManager()->push(new LoadStateConfirmScreen(prefix, slot, [prefix, slot](bool result) {
|
||||
if (result) {
|
||||
SaveState::LoadSlot(prefix, slot, &ShowMessageAfterSaveStateAction);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "UI/LoadStateConfirmScreen.h"
|
||||
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Core/SaveState.h"
|
||||
|
||||
LoadStateConfirmScreen::LoadStateConfirmScreen(std::string_view saveStatePrefix, int slot, std::function<void(bool)> callback)
|
||||
: UI::PopupScreen(GetI18NCategory(I18NCat::PAUSE)->T("Load State"),
|
||||
GetI18NCategory(I18NCat::PAUSE)->T("Load State"),
|
||||
GetI18NCategory(I18NCat::DIALOG)->T("Cancel")),
|
||||
saveStatePrefix_(saveStatePrefix), slot_(slot), callback_(callback) {
|
||||
screenshotFilename_ = SaveState::GenerateSaveSlotPath(saveStatePrefix_, slot_, SaveState::SCREENSHOT_EXTENSION);
|
||||
}
|
||||
|
||||
void LoadStateConfirmScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
// 480:272 PSP ratio; at default popup width 550, effective area ~510 → height ~289
|
||||
parent->Add(new AsyncImageFileView(screenshotFilename_, IS_KEEP_ASPECT,
|
||||
new LinearLayoutParams(FILL_PARENT, 289.0f)));
|
||||
std::string dateStr = SaveState::GetSlotDateAsString(saveStatePrefix_, slot_);
|
||||
if (!dateStr.empty()) {
|
||||
parent->Add(new TextView(dateStr, ALIGN_HCENTER, false,
|
||||
new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(0, 4))));
|
||||
}
|
||||
parent->Add(new TextView(di->T("ConfirmLoadState"), ALIGN_HCENTER | FLAG_WRAP_TEXT, false,
|
||||
new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, Margins(0, 8))));
|
||||
}
|
||||
|
||||
void LoadStateConfirmScreen::OnCompleted(DialogResult result) {
|
||||
if (callback_) callback_(result == DR_OK);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/UI/PopupScreens.h"
|
||||
|
||||
class LoadStateConfirmScreen : public UI::PopupScreen {
|
||||
public:
|
||||
LoadStateConfirmScreen(std::string_view saveStatePrefix, int slot, std::function<void(bool)> callback);
|
||||
const char *tag() const override { return "LoadStateConfirm"; }
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
protected:
|
||||
void OnCompleted(DialogResult result) override;
|
||||
private:
|
||||
std::string saveStatePrefix_;
|
||||
int slot_;
|
||||
Path screenshotFilename_;
|
||||
std::function<void(bool)> callback_;
|
||||
};
|
||||
+4
-7
@@ -57,6 +57,7 @@
|
||||
|
||||
#include "UI/EmuScreen.h"
|
||||
#include "UI/PauseScreen.h"
|
||||
#include "UI/LoadStateConfirmScreen.h"
|
||||
#include "UI/GameSettingsScreen.h"
|
||||
#include "UI/ReportScreen.h"
|
||||
#include "UI/CwCheatScreen.h"
|
||||
@@ -162,9 +163,7 @@ void ScreenshotViewScreen::OnLoadState(UI::EventParams &e) {
|
||||
if (!NetworkWarnUserIfOnlineAndCantSavestate()) {
|
||||
g_Config.iCurrentStateSlot = slot_;
|
||||
if (g_Config.bConfirmLoadState) {
|
||||
auto pa = GetI18NCategory(I18NCat::PAUSE);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
screenManager()->push(new UI::MessagePopupScreen(pa->T("Load State"), di->T("ConfirmLoadState"), pa->T("Load State"), di->T("Cancel"), [this](bool result) {
|
||||
screenManager()->push(new LoadStateConfirmScreen(saveStatePrefix_, slot_, [this](bool result) {
|
||||
if (result) {
|
||||
SaveState::LoadSlot(saveStatePrefix_, slot_, &ShowMessageAfterSaveStateAction);
|
||||
TriggerFinish(DR_OK);
|
||||
@@ -414,9 +413,7 @@ void GamePauseScreen::CreateSavestateControls(UI::LinearLayout *leftColumnItems,
|
||||
finishNextFrameResult_ = DR_CANCEL;
|
||||
};
|
||||
if (g_Config.bConfirmLoadState) {
|
||||
auto pa = GetI18NCategory(I18NCat::PAUSE);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
screenManager()->push(new UI::MessagePopupScreen(pa->T("Load State"), di->T("ConfirmLoadState"), pa->T("Load State"), di->T("Cancel"), [doLoad](bool result) {
|
||||
screenManager()->push(new LoadStateConfirmScreen(saveStatePrefix_, slotNum, [doLoad](bool result) {
|
||||
if (result) doLoad();
|
||||
}));
|
||||
} else {
|
||||
@@ -832,7 +829,7 @@ void GamePauseScreen::dialogFinished(const Screen *dialog, DialogResult dr) {
|
||||
} else {
|
||||
if (tag == "Game") {
|
||||
g_BackgroundAudio.SetGame(Path());
|
||||
} else if (tag != "MessagePopupScreen" && tag != "Prompt" && tag != "ContextMenuPopup" && tag != "ContextMenuCallbackPopup" && tag != "Report" && tag != "listpopup") {
|
||||
} else if (tag != "MessagePopupScreen" && tag != "Prompt" && tag != "ContextMenuPopup" && tag != "ContextMenuCallbackPopup" && tag != "Report" && tag != "listpopup" && tag != "LoadStateConfirm") {
|
||||
// Maybe should invert the logic here, so many cases..
|
||||
// There may have been changes to our savestates, so let's recreate.
|
||||
SaveState::Rescan(saveStatePrefix_);
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<ClCompile Include="ImDebugger\ImStructViewer.cpp" />
|
||||
<ClCompile Include="JitCompareScreen.cpp" />
|
||||
<ClCompile Include="JoystickHistoryView.cpp" />
|
||||
<ClCompile Include="LoadStateConfirmScreen.cpp" />
|
||||
<ClCompile Include="MainScreen.cpp" />
|
||||
<ClCompile Include="MemStickScreen.cpp" />
|
||||
<ClCompile Include="MiscScreens.cpp" />
|
||||
@@ -117,6 +118,7 @@
|
||||
<ClInclude Include="ImDebugger\ImStructViewer.h" />
|
||||
<ClInclude Include="JitCompareScreen.h" />
|
||||
<ClInclude Include="JoystickHistoryView.h" />
|
||||
<ClInclude Include="LoadStateConfirmScreen.h" />
|
||||
<ClInclude Include="MainScreen.h" />
|
||||
<ClInclude Include="MemStickScreen.h" />
|
||||
<ClInclude Include="MiscScreens.h" />
|
||||
|
||||
Reference in New Issue
Block a user