Eliminate some netplay gamelist ugliness.
This commit is contained in:
parent
c07b8a6e37
commit
ae14578bc5
|
@ -34,7 +34,7 @@ struct Rpt : public std::vector<u8>
|
||||||
|
|
||||||
typedef std::vector<Rpt> NetWiimote;
|
typedef std::vector<Rpt> NetWiimote;
|
||||||
|
|
||||||
#define NETPLAY_VERSION "Dolphin NetPlay r6423"
|
#define NETPLAY_VERSION "Dolphin NetPlay 2013-03-03"
|
||||||
|
|
||||||
// messages
|
// messages
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -659,7 +659,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
||||||
// 1. Boot the selected iso
|
// 1. Boot the selected iso
|
||||||
// 2. Boot the default or last loaded iso.
|
// 2. Boot the default or last loaded iso.
|
||||||
// 3. Call BrowseForDirectory if the gamelist is empty
|
// 3. Call BrowseForDirectory if the gamelist is empty
|
||||||
if (!m_GameListCtrl->GetGameNames().size() &&
|
if (!m_GameListCtrl->GetISO(0) &&
|
||||||
!((SConfig::GetInstance().m_ListGC &&
|
!((SConfig::GetInstance().m_ListGC &&
|
||||||
SConfig::GetInstance().m_ListWii &&
|
SConfig::GetInstance().m_ListWii &&
|
||||||
SConfig::GetInstance().m_ListWad) &&
|
SConfig::GetInstance().m_ListWad) &&
|
||||||
|
@ -693,7 +693,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
||||||
|
|
||||||
m_GameListCtrl->Update();
|
m_GameListCtrl->Update();
|
||||||
}
|
}
|
||||||
else if (!m_GameListCtrl->GetGameNames().size())
|
else if (!m_GameListCtrl->GetISO(0))
|
||||||
m_GameListCtrl->BrowseForDirectory();
|
m_GameListCtrl->BrowseForDirectory();
|
||||||
else
|
else
|
||||||
// Game started by double click
|
// Game started by double click
|
||||||
|
|
|
@ -285,10 +285,6 @@ void CGameListCtrl::Update()
|
||||||
m_imageListSmall = NULL;
|
m_imageListSmall = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetPlay : Set/Reset the GameList string
|
|
||||||
m_gameList.clear();
|
|
||||||
m_gamePath.clear();
|
|
||||||
|
|
||||||
Hide();
|
Hide();
|
||||||
|
|
||||||
ScanForISOs();
|
ScanForISOs();
|
||||||
|
@ -406,15 +402,6 @@ wxString NiceSizeFormat(s64 _size)
|
||||||
return(NiceString);
|
return(NiceString);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CGameListCtrl::GetGamePaths() const
|
|
||||||
{
|
|
||||||
return m_gamePath;
|
|
||||||
}
|
|
||||||
std::string CGameListCtrl::GetGameNames() const
|
|
||||||
{
|
|
||||||
return m_gameList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGameListCtrl::InsertItemInReportView(long _Index)
|
void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
{
|
{
|
||||||
// When using wxListCtrl, there is no hope of per-column text colors.
|
// When using wxListCtrl, there is no hope of per-column text colors.
|
||||||
|
@ -424,7 +411,6 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
int ImageIndex = -1;
|
int ImageIndex = -1;
|
||||||
|
|
||||||
GameListItem& rISOFile = *m_ISOFiles[_Index];
|
GameListItem& rISOFile = *m_ISOFiles[_Index];
|
||||||
m_gamePath.append(rISOFile.GetFileName() + '\n');
|
|
||||||
|
|
||||||
// Insert a first row with nothing in it, that will be used as the Index
|
// Insert a first row with nothing in it, that will be used as the Index
|
||||||
long ItemIndex = InsertItem(_Index, wxEmptyString);
|
long ItemIndex = InsertItem(_Index, wxEmptyString);
|
||||||
|
@ -438,31 +424,25 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
// Set the game's banner in the second column
|
// Set the game's banner in the second column
|
||||||
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
|
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
|
||||||
|
|
||||||
std::string name;
|
|
||||||
|
|
||||||
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
|
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
|
||||||
|
|
||||||
|
// Is this sane?
|
||||||
switch (rISOFile.GetCountry())
|
switch (rISOFile.GetCountry())
|
||||||
{
|
{
|
||||||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
||||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
case DiscIO::IVolume::COUNTRY_JAPAN:
|
||||||
{
|
SelectedLanguage = -1;
|
||||||
name = rISOFile.GetName(-1);
|
|
||||||
m_gameList.append(StringFromFormat("%s (J)\n", name.c_str()));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DiscIO::IVolume::COUNTRY_USA:
|
case DiscIO::IVolume::COUNTRY_USA:
|
||||||
// Is this sane?
|
|
||||||
SelectedLanguage = 0;
|
SelectedLanguage = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
name = rISOFile.GetName(SelectedLanguage);
|
|
||||||
m_gameList.append(StringFromFormat("%s (%c)\n", name.c_str(),
|
|
||||||
(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const name = rISOFile.GetName(SelectedLanguage);
|
||||||
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);
|
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);
|
||||||
|
|
||||||
// We show the company string on Gamecube only
|
// We show the company string on Gamecube only
|
||||||
|
|
|
@ -47,10 +47,6 @@ public:
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
// Net Play method
|
|
||||||
std::string GetGamePaths() const;
|
|
||||||
std::string GetGameNames() const;
|
|
||||||
|
|
||||||
void BrowseForDirectory();
|
void BrowseForDirectory();
|
||||||
const GameListItem *GetSelectedISO();
|
const GameListItem *GetSelectedISO();
|
||||||
const GameListItem *GetISO(size_t index) const;
|
const GameListItem *GetISO(size_t index) const;
|
||||||
|
@ -84,10 +80,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetPlay string for the gamelist
|
|
||||||
std::string m_gameList;
|
|
||||||
std::string m_gamePath;
|
|
||||||
|
|
||||||
int last_column;
|
int last_column;
|
||||||
int last_sort;
|
int last_sort;
|
||||||
wxSize lastpos;
|
wxSize lastpos;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define NETPLAY_TITLEBAR "Dolphin NetPlay"
|
#define NETPLAY_TITLEBAR "Dolphin NetPlay"
|
||||||
|
|
||||||
|
@ -35,6 +36,21 @@ static NetPlay* netplay_ptr = NULL;
|
||||||
extern CFrame* main_frame;
|
extern CFrame* main_frame;
|
||||||
NetPlayDiag *NetPlayDiag::npd = NULL;
|
NetPlayDiag *NetPlayDiag::npd = NULL;
|
||||||
|
|
||||||
|
std::string BuildGameName(const GameListItem& game)
|
||||||
|
{
|
||||||
|
auto const selected_lang = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
|
||||||
|
|
||||||
|
// TODO: this should use the name from the volume not the banner
|
||||||
|
// (I seems banner name can sometimes depend on save contents)
|
||||||
|
return game.GetName(selected_lang) + " (" + game.GetUniqueID() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list)
|
||||||
|
{
|
||||||
|
for (u32 i = 0 ; auto game = game_list.GetISO(i); ++i)
|
||||||
|
game_lbox->Append(StrToWxStr(BuildGameName(*game)));
|
||||||
|
}
|
||||||
|
|
||||||
NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list)
|
NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list)
|
||||||
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
|
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
|
||||||
, m_game_list(game_list)
|
, m_game_list(game_list)
|
||||||
|
@ -121,11 +137,8 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*
|
||||||
|
|
||||||
m_game_lbox = new wxListBox(host_tab, wxID_ANY);
|
m_game_lbox = new wxListBox(host_tab, wxID_ANY);
|
||||||
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &NetPlaySetupDiag::OnHost, this);
|
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &NetPlaySetupDiag::OnHost, this);
|
||||||
|
|
||||||
std::istringstream ss(game_list->GetGameNames());
|
FillWithGameNames(m_game_lbox, *game_list);
|
||||||
std::string game;
|
|
||||||
while (std::getline(ss,game))
|
|
||||||
m_game_lbox->Append(StrToWxStr(game));
|
|
||||||
|
|
||||||
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||||
top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5);
|
top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5);
|
||||||
|
@ -360,24 +373,17 @@ void NetPlayDiag::OnChat(wxCommandEvent&)
|
||||||
|
|
||||||
void NetPlayDiag::OnStart(wxCommandEvent&)
|
void NetPlayDiag::OnStart(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
// find path for selected game
|
// find path for selected game, sloppy..
|
||||||
std::string ntmp, ptmp, path;
|
for (u32 i = 0 ; auto game = m_game_list->GetISO(i); ++i)
|
||||||
std::istringstream nss(m_game_list->GetGameNames()), pss(m_game_list->GetGamePaths());
|
|
||||||
|
|
||||||
while(std::getline(nss,ntmp))
|
|
||||||
{
|
{
|
||||||
std::getline(pss,ptmp);
|
if (m_selected_game == BuildGameName(*game))
|
||||||
if (m_selected_game == ntmp)
|
|
||||||
{
|
{
|
||||||
path = ptmp;
|
netplay_ptr->StartGame(game->GetFileName());
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.length())
|
PanicAlertT("Game not found!");
|
||||||
netplay_ptr->StartGame(path);
|
|
||||||
else
|
|
||||||
PanicAlertT("Game not found!!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetPlayDiag::OnStop(wxCommandEvent&)
|
void NetPlayDiag::OnStop(wxCommandEvent&)
|
||||||
|
@ -550,11 +556,7 @@ ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* cons
|
||||||
m_game_lbox = new wxListBox(this, wxID_ANY);
|
m_game_lbox = new wxListBox(this, wxID_ANY);
|
||||||
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &ChangeGameDiag::OnPick, this);
|
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &ChangeGameDiag::OnPick, this);
|
||||||
|
|
||||||
// fill list with games
|
FillWithGameNames(m_game_lbox, *game_list);
|
||||||
std::istringstream ss(game_list->GetGameNames());
|
|
||||||
std::string game;
|
|
||||||
while (std::getline(ss,game))
|
|
||||||
m_game_lbox->Append(StrToWxStr(game));
|
|
||||||
|
|
||||||
wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
|
wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
|
||||||
ok_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ChangeGameDiag::OnPick, this);
|
ok_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ChangeGameDiag::OnPick, this);
|
||||||
|
|
Loading…
Reference in New Issue