2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "GameViewer.h"
|
|
|
|
|
#include "Loader/PSF.h"
|
|
|
|
|
|
|
|
|
|
static const wxString m_class_name = "GameViewer";
|
2013-06-30 10:46:29 +02:00
|
|
|
GameViewer::GameViewer(wxWindow* parent) : wxListView(parent)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
|
|
|
|
LoadSettings();
|
2013-06-30 10:46:29 +02:00
|
|
|
m_columns.Show(this);
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-02-22 03:53:06 +01:00
|
|
|
m_path = "/dev_hdd0/game/";
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
Connect(GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler(GameViewer::DClick));
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GameViewer::~GameViewer()
|
|
|
|
|
{
|
|
|
|
|
SaveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::DoResize(wxSize size)
|
|
|
|
|
{
|
|
|
|
|
SetSize(size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::LoadGames()
|
|
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
vfsDir dir(m_path);
|
|
|
|
|
ConLog.Write("path: %s", m_path.wx_str());
|
|
|
|
|
if(!dir.IsOpened()) return;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
m_games.Clear();
|
|
|
|
|
|
2014-02-22 03:53:06 +01:00
|
|
|
for(const DirEntryInfo* info = dir.Read(); info; info = dir.Read())
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
if(info->flags & DirEntry_TypeDir)
|
|
|
|
|
{
|
|
|
|
|
m_games.Add(info->name);
|
|
|
|
|
}
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 17:59:13 +01:00
|
|
|
//ConLog.Write("path: %s", m_path.wx_str());
|
2012-11-15 00:39:56 +01:00
|
|
|
//ConLog.Write("folders count: %d", m_games.GetCount());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::LoadPSF()
|
|
|
|
|
{
|
|
|
|
|
m_game_data.Clear();
|
|
|
|
|
for(uint i=0; i<m_games.GetCount(); ++i)
|
|
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
const wxString& path = m_path + m_games[i] + "/PARAM.SFO";
|
|
|
|
|
vfsFile f;
|
2014-02-16 16:19:06 +01:00
|
|
|
if(!f.Open(path))
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
PSFLoader psf(f);
|
2012-11-15 00:39:56 +01:00
|
|
|
if(!psf.Load(false)) continue;
|
|
|
|
|
psf.m_info.root = m_games[i];
|
|
|
|
|
m_game_data.Add(new GameInfo(psf.m_info));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_columns.Update(m_game_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::ShowData()
|
|
|
|
|
{
|
2013-06-30 10:46:29 +02:00
|
|
|
m_columns.ShowData(this);
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::Refresh()
|
|
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
Emu.GetVFS().Init(m_path);
|
2012-11-15 00:39:56 +01:00
|
|
|
LoadGames();
|
|
|
|
|
LoadPSF();
|
|
|
|
|
ShowData();
|
2014-02-22 03:53:06 +01:00
|
|
|
Emu.GetVFS().UnMountAll();
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::SaveSettings()
|
|
|
|
|
{
|
2013-06-30 10:46:29 +02:00
|
|
|
m_columns.LoadSave(false, m_class_name, this);
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::LoadSettings()
|
|
|
|
|
{
|
|
|
|
|
m_columns.LoadSave(true, m_class_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameViewer::DClick(wxListEvent& event)
|
|
|
|
|
{
|
2013-06-30 10:46:29 +02:00
|
|
|
long i = GetFirstSelected();
|
2012-11-15 00:39:56 +01:00
|
|
|
if(i < 0) return;
|
|
|
|
|
|
2013-12-08 17:54:45 +01:00
|
|
|
const wxString& path = m_path + m_game_data[i].root;
|
|
|
|
|
|
2014-02-22 13:06:23 +01:00
|
|
|
Emu.Stop();
|
2014-02-22 03:53:06 +01:00
|
|
|
Emu.GetVFS().Init(path);
|
|
|
|
|
wxString local_path;
|
|
|
|
|
if(Emu.GetVFS().GetDevice(path, local_path) && !Emu.BootGame(local_path.ToStdString()))
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2014-02-10 13:53:09 +01:00
|
|
|
ConLog.Error("Boot error: elf not found! [%s]", path.wx_str());
|
2012-11-15 00:39:56 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Emu.Run();
|
2013-11-19 11:30:58 +01:00
|
|
|
}
|