mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-03-06 05:07:41 +00:00
Make GameInfoCache understand PSP savedata as a "game" type. Use it to create a basic savedata listing screen.
This commit is contained in:
parent
8ec48507f1
commit
084aad74c3
@ -820,6 +820,7 @@ set(NativeAppSource
|
||||
UI/OnScreenDisplay.cpp
|
||||
UI/ControlMappingScreen.cpp
|
||||
UI/ReportScreen.cpp
|
||||
UI/SavedataScreen.cpp
|
||||
UI/Store.cpp
|
||||
UI/CwCheatScreen.cpp
|
||||
UI/InstallZipScreen.cpp
|
||||
|
@ -786,20 +786,27 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader)
|
||||
if (fileLoader->IsDirectory()) {
|
||||
std::string filename = fileLoader->Path();
|
||||
if (filename.size() > 4) {
|
||||
FileInfo ebootInfo;
|
||||
FileInfo fileInfo;
|
||||
// Check for existence of EBOOT.PBP, as required for "Directory games".
|
||||
if (getFileInfo((filename + "/EBOOT.PBP").c_str(), &ebootInfo)) {
|
||||
if (ebootInfo.exists) {
|
||||
if (getFileInfo((filename + "/EBOOT.PBP").c_str(), &fileInfo)) {
|
||||
if (fileInfo.exists) {
|
||||
return FILETYPE_PSP_PBP_DIRECTORY;
|
||||
}
|
||||
}
|
||||
|
||||
// check if it's a disc directory
|
||||
if (getFileInfo((filename + "/PSP_GAME").c_str(), &ebootInfo)) {
|
||||
if (ebootInfo.exists) {
|
||||
if (getFileInfo((filename + "/PSP_GAME").c_str(), &fileInfo)) {
|
||||
if (fileInfo.exists) {
|
||||
return FILETYPE_PSP_DISC_DIRECTORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Not that, okay, let's guess it's a savedata directory if it has a param.sfo...
|
||||
if (getFileInfo((filename + "/PARAM.SFO").c_str(), &fileInfo)) {
|
||||
if (fileInfo.exists) {
|
||||
return FILETYPE_PSP_SAVEDATA_DIRECTORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FILETYPE_NORMAL_DIRECTORY;
|
||||
|
@ -43,6 +43,8 @@ enum IdentifiedFileType {
|
||||
|
||||
FILETYPE_NORMAL_DIRECTORY,
|
||||
|
||||
FILETYPE_PSP_SAVEDATA_DIRECTORY,
|
||||
|
||||
FILETYPE_UNKNOWN
|
||||
};
|
||||
|
||||
|
@ -31,9 +31,8 @@ class DevMenu : public PopupScreen {
|
||||
public:
|
||||
DevMenu() : PopupScreen("Dev Tools") {}
|
||||
|
||||
virtual void CreatePopupContents(UI::ViewGroup *parent);
|
||||
|
||||
virtual void dialogFinished(const Screen *dialog, DialogResult result);
|
||||
void CreatePopupContents(UI::ViewGroup *parent) override;
|
||||
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
||||
|
||||
protected:
|
||||
UI::EventReturn OnLogView(UI::EventParams &e);
|
||||
@ -48,7 +47,7 @@ protected:
|
||||
class LogConfigScreen : public UIDialogScreenWithBackground {
|
||||
public:
|
||||
LogConfigScreen() {}
|
||||
virtual void CreateViews();
|
||||
virtual void CreateViews() override;
|
||||
|
||||
private:
|
||||
UI::EventReturn OnToggleAll(UI::EventParams &e);
|
||||
|
@ -48,7 +48,7 @@ GameInfo::~GameInfo() {
|
||||
delete fileLoader;
|
||||
}
|
||||
|
||||
bool GameInfo::DeleteGame() {
|
||||
bool GameInfo::Delete() {
|
||||
switch (fileType) {
|
||||
case FILETYPE_PSP_ISO:
|
||||
case FILETYPE_PSP_ISO_NP:
|
||||
@ -63,9 +63,9 @@ bool GameInfo::DeleteGame() {
|
||||
return true;
|
||||
}
|
||||
case FILETYPE_PSP_PBP_DIRECTORY:
|
||||
case FILETYPE_PSP_SAVEDATA_DIRECTORY:
|
||||
{
|
||||
// TODO: This could be handled by Core/Util/GameManager too somehow.
|
||||
|
||||
const char *directoryToRemove = filePath_.c_str();
|
||||
INFO_LOG(HLE, "Deleting %s", directoryToRemove);
|
||||
if (!File::DeleteDirRecursively(directoryToRemove)) {
|
||||
@ -97,6 +97,7 @@ u64 GameInfo::GetGameSizeInBytes() {
|
||||
}
|
||||
}
|
||||
|
||||
// Not too meaningful if the object itself is a savedata directory...
|
||||
std::vector<std::string> GameInfo::GetSaveDataDirectories() {
|
||||
std::string memc = GetSysDirectory(DIRECTORY_SAVEDATA);
|
||||
|
||||
@ -132,7 +133,7 @@ u64 GameInfo::GetSaveDataSizeInBytes() {
|
||||
filesSizeInDir += finfo.size;
|
||||
}
|
||||
if (filesSizeInDir < 0xA00000) {
|
||||
//Generally the savedata size in a dir shouldn't be more than 10MB.
|
||||
// HACK: Generally the savedata size in a dir shouldn't be more than 10MB.
|
||||
totalSize += filesSizeInDir;
|
||||
}
|
||||
filesSizeInDir = 0;
|
||||
@ -156,7 +157,7 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
|
||||
filesSizeInDir += finfo.size;
|
||||
}
|
||||
if (filesSizeInDir >= 0xA00000) {
|
||||
// Generally the savedata size in a dir shouldn't be more than 10MB.
|
||||
// HACK: Generally the savedata size in a dir shouldn't be more than 10MB.
|
||||
// This is probably GameInstall data.
|
||||
totalSize += filesSizeInDir;
|
||||
}
|
||||
@ -371,6 +372,28 @@ handleELF:
|
||||
}
|
||||
break;
|
||||
|
||||
case FILETYPE_PSP_SAVEDATA_DIRECTORY:
|
||||
{
|
||||
SequentialHandleAllocator handles;
|
||||
VirtualDiscFileSystem umd(&handles, gamePath_.c_str());
|
||||
|
||||
// Alright, let's fetch the PARAM.SFO.
|
||||
std::string paramSFOcontents;
|
||||
if (ReadFileToString(&umd, "/PARAM.SFO", ¶mSFOcontents, 0)) {
|
||||
lock_guard lock(info_->lock);
|
||||
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
|
||||
info_->ParseParamSFO();
|
||||
}
|
||||
|
||||
ReadFileToString(&umd, "/ICON0.PNG", &info_->iconTextureData, &info_->lock);
|
||||
info_->iconDataLoaded = true;
|
||||
if (info_->wantFlags & GAMEINFO_WANTBG) {
|
||||
ReadFileToString(&umd, "/PIC1.PNG", &info_->pic1TextureData, &info_->lock);
|
||||
info_->pic1DataLoaded = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case FILETYPE_PSP_DISC_DIRECTORY:
|
||||
{
|
||||
info_->fileType = FILETYPE_PSP_ISO;
|
||||
@ -517,7 +540,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
GameInfoCache::~GameInfoCache() {
|
||||
Clear();
|
||||
}
|
||||
@ -531,18 +553,6 @@ void GameInfoCache::Shutdown() {
|
||||
StopProcessingWorkQueue(gameInfoWQ_);
|
||||
}
|
||||
|
||||
void GameInfoCache::Save() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void GameInfoCache::Load() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void GameInfoCache::Decimate() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void GameInfoCache::Clear() {
|
||||
if (gameInfoWQ_)
|
||||
gameInfoWQ_->Flush();
|
||||
|
@ -33,6 +33,8 @@ class Thin3DTexture;
|
||||
// does on the PSP, namely checking for and deleting savedata, and similar things.
|
||||
// Only cares about games that are installed on the current device.
|
||||
|
||||
// A GameInfo object can also represent a piece of savedata.
|
||||
|
||||
// Guessed from GameID, not necessarily accurate
|
||||
enum GameRegion {
|
||||
GAMEREGION_JAPAN,
|
||||
@ -99,7 +101,7 @@ public:
|
||||
gameSize(0), saveDataSize(0), installDataSize(0), fileLoader(nullptr) {}
|
||||
~GameInfo();
|
||||
|
||||
bool DeleteGame(); // Better be sure what you're doing when calling this.
|
||||
bool Delete(); // Better be sure what you're doing when calling this.
|
||||
bool DeleteAllSaveData();
|
||||
bool LoadFromPath(const std::string &gamePath);
|
||||
FileLoader *GetFileLoader();
|
||||
@ -180,13 +182,8 @@ public:
|
||||
// redrawing the UI often. Only set flags to GAMEINFO_WANTBG or WANTSND if you really want them
|
||||
// because they're big. bgTextures and sound may be discarded over time as well.
|
||||
GameInfo *GetInfo(Thin3DContext *thin3d, const std::string &gamePath, int wantFlags);
|
||||
void Decimate(); // Deletes old info.
|
||||
void FlushBGs(); // Gets rid of all BG textures. Also gets rid of bg sounds.
|
||||
|
||||
// TODO - save cache between sessions
|
||||
void Save();
|
||||
void Load();
|
||||
|
||||
PrioritizedWorkQueue *WorkQueue() { return gameInfoWQ_; }
|
||||
|
||||
private:
|
||||
|
@ -265,7 +265,7 @@ UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
|
||||
void GameScreen::CallbackDeleteGame(bool yes) {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0);
|
||||
if (yes) {
|
||||
info->DeleteGame();
|
||||
info->Delete();
|
||||
g_gameInfoCache.Clear();
|
||||
screenManager()->switchScreen(new MainScreen());
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "UI/GameSettingsScreen.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/ControlMappingScreen.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "UI/Store.h"
|
||||
#include "UI/ui_atlas.h"
|
||||
#include "Core/Config.h"
|
||||
@ -394,40 +395,6 @@ void DirButton::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
class GameBrowser : public UI::LinearLayout {
|
||||
public:
|
||||
GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, int flags = 0, UI::LayoutParams *layoutParams = 0);
|
||||
|
||||
UI::Event OnChoice;
|
||||
UI::Event OnHoldChoice;
|
||||
UI::Event OnHighlight;
|
||||
|
||||
UI::Choice *HomebrewStoreButton() { return homebrewStoreButton_; }
|
||||
private:
|
||||
void Refresh();
|
||||
bool IsCurrentPathPinned();
|
||||
const std::vector<std::string> GetPinnedPaths();
|
||||
const std::string GetBaseName(const std::string &path);
|
||||
|
||||
UI::EventReturn GameButtonClick(UI::EventParams &e);
|
||||
UI::EventReturn GameButtonHoldClick(UI::EventParams &e);
|
||||
UI::EventReturn GameButtonHighlight(UI::EventParams &e);
|
||||
UI::EventReturn NavigateClick(UI::EventParams &e);
|
||||
UI::EventReturn LayoutChange(UI::EventParams &e);
|
||||
UI::EventReturn LastClick(UI::EventParams &e);
|
||||
UI::EventReturn HomeClick(UI::EventParams &e);
|
||||
UI::EventReturn PinToggleClick(UI::EventParams &e);
|
||||
|
||||
UI::ViewGroup *gameList_;
|
||||
PathBrowser path_;
|
||||
bool *gridStyle_;
|
||||
bool allowBrowsing_;
|
||||
std::string lastText_;
|
||||
std::string lastLink_;
|
||||
int flags_;
|
||||
UI::Choice *homebrewStoreButton_;
|
||||
};
|
||||
|
||||
GameBrowser::GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle, std::string lastText, std::string lastLink, int flags, UI::LayoutParams *layoutParams)
|
||||
: LinearLayout(UI::ORIENT_VERTICAL, layoutParams), gameList_(0), path_(path), gridStyle_(gridStyle), allowBrowsing_(allowBrowsing), lastText_(lastText), lastLink_(lastLink), flags_(flags) {
|
||||
using namespace UI;
|
||||
@ -539,13 +506,16 @@ void GameBrowser::Refresh() {
|
||||
path_.GetListing(fileInfo, "iso:cso:pbp:elf:prx:");
|
||||
for (size_t i = 0; i < fileInfo.size(); i++) {
|
||||
bool isGame = !fileInfo[i].isDirectory;
|
||||
bool isSaveData = false;
|
||||
// Check if eboot directory
|
||||
if (!isGame && path_.GetPath().size() >= 4 && File::Exists(path_.GetPath() + fileInfo[i].name + "/EBOOT.PBP"))
|
||||
isGame = true;
|
||||
else if (!isGame && File::Exists(path_.GetPath() + fileInfo[i].name + "/PSP_GAME/SYSDIR"))
|
||||
isGame = true;
|
||||
else if (!isGame && File::Exists(path_.GetPath() + fileInfo[i].name + "/PARAM.SFO"))
|
||||
isSaveData = true;
|
||||
|
||||
if (!isGame) {
|
||||
if (!isGame && !isSaveData) {
|
||||
if (allowBrowsing_) {
|
||||
dirButtons.push_back(new DirButton(fileInfo[i].name, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)));
|
||||
}
|
||||
@ -824,6 +794,7 @@ void MainScreen::CreateViews() {
|
||||
rightColumnItems->Add(new Choice(m->T("Load","Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile);
|
||||
#endif
|
||||
rightColumnItems->Add(new Choice(m->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings);
|
||||
rightColumnItems->Add(new Choice(m->T("Saved Data")))->OnClick.Handle(this, &MainScreen::OnSavedData);
|
||||
rightColumnItems->Add(new Choice(m->T("Credits")))->OnClick.Handle(this, &MainScreen::OnCredits);
|
||||
rightColumnItems->Add(new Choice(m->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg);
|
||||
#ifndef GOLD
|
||||
@ -1052,6 +1023,13 @@ UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn MainScreen::OnSavedData(UI::EventParams &e) {
|
||||
// screenManager()->push(new SettingsScreen());
|
||||
auto saveData = new SavedataScreen("");
|
||||
screenManager()->push(saveData);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn MainScreen::OnRecentChange(UI::EventParams &e) {
|
||||
RecreateViews();
|
||||
if (host) {
|
||||
|
@ -18,13 +18,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/functional.h"
|
||||
#include "file/path.h"
|
||||
#include "ui/ui_screen.h"
|
||||
#include "ui/viewgroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
|
||||
// Game screen: Allows you to start a game, delete saves, delete the game,
|
||||
// set game specific settings, etc.
|
||||
// Uses GameInfoCache heavily to implement the functionality.
|
||||
class GameBrowser : public UI::LinearLayout {
|
||||
public:
|
||||
GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, int flags = 0, UI::LayoutParams *layoutParams = 0);
|
||||
|
||||
UI::Event OnChoice;
|
||||
UI::Event OnHoldChoice;
|
||||
UI::Event OnHighlight;
|
||||
|
||||
UI::Choice *HomebrewStoreButton() { return homebrewStoreButton_; }
|
||||
|
||||
private:
|
||||
void Refresh();
|
||||
bool IsCurrentPathPinned();
|
||||
const std::vector<std::string> GetPinnedPaths();
|
||||
const std::string GetBaseName(const std::string &path);
|
||||
|
||||
UI::EventReturn GameButtonClick(UI::EventParams &e);
|
||||
UI::EventReturn GameButtonHoldClick(UI::EventParams &e);
|
||||
UI::EventReturn GameButtonHighlight(UI::EventParams &e);
|
||||
UI::EventReturn NavigateClick(UI::EventParams &e);
|
||||
UI::EventReturn LayoutChange(UI::EventParams &e);
|
||||
UI::EventReturn LastClick(UI::EventParams &e);
|
||||
UI::EventReturn HomeClick(UI::EventParams &e);
|
||||
UI::EventReturn PinToggleClick(UI::EventParams &e);
|
||||
|
||||
UI::ViewGroup *gameList_;
|
||||
PathBrowser path_;
|
||||
bool *gridStyle_;
|
||||
bool allowBrowsing_;
|
||||
std::string lastText_;
|
||||
std::string lastLink_;
|
||||
int flags_;
|
||||
UI::Choice *homebrewStoreButton_;
|
||||
};
|
||||
|
||||
class MainScreen : public UIScreenWithBackground {
|
||||
public:
|
||||
@ -52,6 +84,7 @@ private:
|
||||
// Event handlers
|
||||
UI::EventReturn OnLoadFile(UI::EventParams &e);
|
||||
UI::EventReturn OnGameSettings(UI::EventParams &e);
|
||||
UI::EventReturn OnSavedData(UI::EventParams &e);
|
||||
UI::EventReturn OnRecentChange(UI::EventParams &e);
|
||||
UI::EventReturn OnCredits(UI::EventParams &e);
|
||||
UI::EventReturn OnSupport(UI::EventParams &e);
|
||||
|
@ -149,7 +149,12 @@ void UIScreenWithBackground::DrawBackground(UIContext &dc) {
|
||||
}
|
||||
|
||||
void UIScreenWithGameBackground::DrawBackground(UIContext &dc) {
|
||||
DrawGameBackground(dc, gamePath_);
|
||||
if (!gamePath_.empty()) {
|
||||
DrawGameBackground(dc, gamePath_);
|
||||
} else {
|
||||
::DrawBackground(dc, 1.0f);
|
||||
dc.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void UIDialogScreenWithGameBackground::DrawBackground(UIContext &dc) {
|
||||
|
@ -140,57 +140,13 @@ private:
|
||||
|
||||
class SaveSlotView : public UI::LinearLayout {
|
||||
public:
|
||||
SaveSlotView(int slot, UI::LayoutParams *layoutParams = nullptr) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), slot_(slot) {
|
||||
using namespace UI;
|
||||
|
||||
screenshotFilename_ = SaveState::GenerateSaveSlotFilename(slot, "jpg");
|
||||
PrioritizedWorkQueue *wq = g_gameInfoCache.WorkQueue();
|
||||
Add(new Spacer(5));
|
||||
|
||||
AsyncImageFileView *fv = Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, wq, new UI::LayoutParams(82 * 2, 47 * 2)));
|
||||
fv->SetOverlayText(StringFromFormat("%i", slot_ + 1));
|
||||
|
||||
I18NCategory *i = GetI18NCategory("Pause");
|
||||
|
||||
LinearLayout *buttons = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
||||
buttons->SetSpacing(2.0);
|
||||
Add(buttons);
|
||||
|
||||
saveStateButton_ = buttons->Add(new Button(i->T("Save State"), new LinearLayoutParams(0.0, G_VCENTER)));
|
||||
saveStateButton_->OnClick.Handle(this, &SaveSlotView::OnSaveState);
|
||||
|
||||
fv->OnClick.Handle(this, &SaveSlotView::OnScreenshotClick);
|
||||
|
||||
if (SaveState::HasSaveInSlot(slot)) {
|
||||
loadStateButton_ = buttons->Add(new Button(i->T("Load State"), new LinearLayoutParams(0.0, G_VCENTER)));
|
||||
loadStateButton_->OnClick.Handle(this, &SaveSlotView::OnLoadState);
|
||||
|
||||
std::string dateStr = SaveState::GetSlotDateAsString(slot_);
|
||||
std::vector<std::string> dateStrs;
|
||||
SplitString(dateStr, ' ', dateStrs);
|
||||
if (!dateStrs.empty() && !dateStrs[0].empty()) {
|
||||
LinearLayout *strs = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
||||
Add(strs);
|
||||
for (size_t i = 0; i < dateStrs.size(); i++) {
|
||||
strs->Add(new TextView(dateStrs[i], new LinearLayoutParams(0.0, G_VCENTER)))->SetShadow(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fv->SetFilename("");
|
||||
}
|
||||
}
|
||||
SaveSlotView(int slot, UI::LayoutParams *layoutParams = nullptr);
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override {
|
||||
w = 500; h = 90;
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) {
|
||||
if (g_Config.iCurrentStateSlot == slot_) {
|
||||
dc.FillRect(UI::Drawable(0x70000000), GetBounds().Expand(3));
|
||||
dc.FillRect(UI::Drawable(0x70FFFFFF), GetBounds().Expand(3));
|
||||
}
|
||||
UI::LinearLayout::Draw(dc);
|
||||
}
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
int GetSlot() const {
|
||||
return slot_;
|
||||
@ -220,6 +176,53 @@ private:
|
||||
std::string screenshotFilename_;
|
||||
};
|
||||
|
||||
SaveSlotView::SaveSlotView(int slot, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), slot_(slot) {
|
||||
using namespace UI;
|
||||
|
||||
screenshotFilename_ = SaveState::GenerateSaveSlotFilename(slot, "jpg");
|
||||
PrioritizedWorkQueue *wq = g_gameInfoCache.WorkQueue();
|
||||
Add(new Spacer(5));
|
||||
|
||||
AsyncImageFileView *fv = Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, wq, new UI::LayoutParams(82 * 2, 47 * 2)));
|
||||
fv->SetOverlayText(StringFromFormat("%i", slot_ + 1));
|
||||
|
||||
I18NCategory *i = GetI18NCategory("Pause");
|
||||
|
||||
LinearLayout *buttons = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
||||
buttons->SetSpacing(2.0);
|
||||
Add(buttons);
|
||||
|
||||
saveStateButton_ = buttons->Add(new Button(i->T("Save State"), new LinearLayoutParams(0.0, G_VCENTER)));
|
||||
saveStateButton_->OnClick.Handle(this, &SaveSlotView::OnSaveState);
|
||||
|
||||
fv->OnClick.Handle(this, &SaveSlotView::OnScreenshotClick);
|
||||
|
||||
if (SaveState::HasSaveInSlot(slot)) {
|
||||
loadStateButton_ = buttons->Add(new Button(i->T("Load State"), new LinearLayoutParams(0.0, G_VCENTER)));
|
||||
loadStateButton_->OnClick.Handle(this, &SaveSlotView::OnLoadState);
|
||||
|
||||
std::string dateStr = SaveState::GetSlotDateAsString(slot_);
|
||||
std::vector<std::string> dateStrs;
|
||||
SplitString(dateStr, ' ', dateStrs);
|
||||
if (!dateStrs.empty() && !dateStrs[0].empty()) {
|
||||
LinearLayout *strs = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
||||
Add(strs);
|
||||
for (size_t i = 0; i < dateStrs.size(); i++) {
|
||||
strs->Add(new TextView(dateStrs[i], new LinearLayoutParams(0.0, G_VCENTER)))->SetShadow(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fv->SetFilename("");
|
||||
}
|
||||
}
|
||||
|
||||
void SaveSlotView::Draw(UIContext &dc) {
|
||||
if (g_Config.iCurrentStateSlot == slot_) {
|
||||
dc.FillRect(UI::Drawable(0x70000000), GetBounds().Expand(3));
|
||||
dc.FillRect(UI::Drawable(0x70FFFFFF), GetBounds().Expand(3));
|
||||
}
|
||||
UI::LinearLayout::Draw(dc);
|
||||
}
|
||||
|
||||
UI::EventReturn SaveSlotView::OnLoadState(UI::EventParams &e) {
|
||||
g_Config.iCurrentStateSlot = slot_;
|
||||
|
57
UI/SavedataScreen.cpp
Normal file
57
UI/SavedataScreen.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2013- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "gfx_es2/draw_buffer.h"
|
||||
#include "i18n/i18n.h"
|
||||
#include "math/curves.h"
|
||||
#include "util/text/utf8.h"
|
||||
#include "ui/ui_context.h"
|
||||
#include "ui/view.h"
|
||||
#include "ui/viewgroup.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "UI/MainScreen.h"
|
||||
|
||||
#include "Core/Host.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
class SaveDataPopup : public UIScreenWithGameBackground {
|
||||
public:
|
||||
SaveDataPopup(std::string savePath) : UIScreenWithGameBackground(savePath) {
|
||||
|
||||
}
|
||||
|
||||
void CreateViews() override {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
SavedataScreen::SavedataScreen(std::string gamePath) : UIScreenWithGameBackground(gamePath) {
|
||||
|
||||
}
|
||||
|
||||
void SavedataScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
std::string dir = GetSysDirectory(DIRECTORY_SAVEDATA);
|
||||
gridStyle_ = false;
|
||||
root_ = new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
//ScrollView *scroll = root_->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)));
|
||||
browser_ = root_->Add(new GameBrowser(dir, false, &gridStyle_, "", "", 0, new LayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
}
|
36
UI/SavedataScreen.h
Normal file
36
UI/SavedataScreen.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2015- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/functional.h"
|
||||
#include "ui/ui_screen.h"
|
||||
#include "ui/viewgroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
|
||||
class GameBrowser;
|
||||
|
||||
class SavedataScreen : public UIScreenWithGameBackground {
|
||||
public:
|
||||
// gamePath can be empty, in that case this screen will show all savedata in the save directory.
|
||||
SavedataScreen(std::string gamePath);
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
bool gridStyle_;
|
||||
GameBrowser *browser_;
|
||||
};
|
@ -34,6 +34,7 @@
|
||||
<ClCompile Include="OnScreenDisplay.cpp" />
|
||||
<ClCompile Include="PauseScreen.cpp" />
|
||||
<ClCompile Include="ReportScreen.cpp" />
|
||||
<ClCompile Include="SavedataScreen.cpp" />
|
||||
<ClCompile Include="Store.cpp" />
|
||||
<ClCompile Include="TiltAnalogSettingsScreen.cpp" />
|
||||
<ClCompile Include="TiltEventProcessor.cpp" />
|
||||
@ -57,6 +58,7 @@
|
||||
<ClInclude Include="OnScreenDisplay.h" />
|
||||
<ClInclude Include="PauseScreen.h" />
|
||||
<ClInclude Include="ReportScreen.h" />
|
||||
<ClInclude Include="SavedataScreen.h" />
|
||||
<ClInclude Include="Store.h" />
|
||||
<ClInclude Include="TiltAnalogSettingsScreen.h" />
|
||||
<ClInclude Include="TiltEventProcessor.h" />
|
||||
|
@ -53,6 +53,9 @@
|
||||
<ClCompile Include="PauseScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SavedataScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameInfoCache.h" />
|
||||
@ -106,6 +109,9 @@
|
||||
<ClInclude Include="PauseScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SavedataScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Screens">
|
||||
|
@ -336,6 +336,7 @@ LOCAL_SRC_FILES := \
|
||||
$(SRC)/UI/MiscScreens.cpp \
|
||||
$(SRC)/UI/ReportScreen.cpp \
|
||||
$(SRC)/UI/PauseScreen.cpp \
|
||||
$(SRC)/UI/SavedataScreen.cpp \
|
||||
$(SRC)/UI/Store.cpp \
|
||||
$(SRC)/UI/GamepadEmu.cpp \
|
||||
$(SRC)/UI/GameInfoCache.cpp \
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 316d6ab84def4666fe13ff0c14c9bcb1659ab5c1
|
||||
Subproject commit 32a75bea4639bd361ebf1bd532f6969547d6e3ba
|
Loading…
x
Reference in New Issue
Block a user