rpcsx/rpcs3/Gui/GameViewer.cpp
Alexandro Sánchez Bach 2c7269e3de PSF Loader improved & issue #126 fixed
* Improved PSF Loader: Now you can get the value of the PARAM.SFO
entries directly with the GetString(key), GetInteger(key) methods.
GameInfo related lines were removed since they have nothing to do with
PSF files.
* cellGame, cellSysutil, and GameViewer are modified because of the PSF
Loader changes.
* Removed unnecessary null pointer checks:
https://github.com/DHrpcs3/rpcs3/issues/126
2014-03-28 05:20:13 +01:00

122 lines
2.4 KiB
C++

#include "stdafx.h"
#include "GameViewer.h"
#include "Loader/PSF.h"
static const wxString m_class_name = "GameViewer";
GameViewer::GameViewer(wxWindow* parent) : wxListView(parent)
{
LoadSettings();
m_columns.Show(this);
m_path = "/dev_hdd0/game/";
Connect(GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(GameViewer::DClick));
Refresh();
}
GameViewer::~GameViewer()
{
SaveSettings();
}
void GameViewer::DoResize(wxSize size)
{
SetSize(size);
}
void GameViewer::LoadGames()
{
vfsDir dir(m_path);
ConLog.Write("path: %s", m_path.wx_str());
if(!dir.IsOpened()) return;
m_games.Clear();
for(const DirEntryInfo* info = dir.Read(); info; info = dir.Read())
{
if(info->flags & DirEntry_TypeDir)
{
m_games.Add(info->name);
}
}
//ConLog.Write("path: %s", m_path.wx_str());
//ConLog.Write("folders count: %d", m_games.GetCount());
}
void GameViewer::LoadPSF()
{
m_game_data.clear();
for(uint i=0; i<m_games.GetCount(); ++i)
{
const wxString& path = m_path + m_games[i] + "/PARAM.SFO";
vfsFile f;
if(!f.Open(path))
continue;
PSFLoader psf(f);
if(!psf.Load(false))
continue;
GameInfo game;
game.root = m_games[i];
game.serial = psf.GetString("TITLE_ID");
game.name = psf.GetString("TITLE");
game.app_ver = psf.GetString("APP_VER");
game.category = psf.GetString("CATEGORY");
game.fw = psf.GetString("PS3_SYSTEM_VER");
game.parental_lvl = psf.GetInteger("PARENTAL_LEVEL");
game.resolution = psf.GetInteger("RESOLUTION");
game.sound_format = psf.GetInteger("SOUND_FORMAT");
if(game.serial.Length() == 9)
game.serial = game.serial(0, 4) + "-" + game.serial(4, 5);
m_game_data.push_back(game);
}
m_columns.Update(m_game_data);
}
void GameViewer::ShowData()
{
m_columns.ShowData(this);
}
void GameViewer::Refresh()
{
Emu.GetVFS().Init(m_path);
LoadGames();
LoadPSF();
ShowData();
Emu.GetVFS().UnMountAll();
}
void GameViewer::SaveSettings()
{
m_columns.LoadSave(false, m_class_name, this);
}
void GameViewer::LoadSettings()
{
m_columns.LoadSave(true, m_class_name);
}
void GameViewer::DClick(wxListEvent& event)
{
long i = GetFirstSelected();
if(i < 0) return;
const wxString& path = m_path + m_game_data[i].root;
Emu.Stop();
Emu.GetVFS().Init(path);
wxString local_path;
if(Emu.GetVFS().GetDevice(path, local_path) && !Emu.BootGame(local_path.ToStdString()))
{
ConLog.Error("Boot error: elf not found! [%s]", path.wx_str());
return;
}
Emu.Run();
}