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;
|
||||
|
||||
#define NETPLAY_VERSION "Dolphin NetPlay r6423"
|
||||
#define NETPLAY_VERSION "Dolphin NetPlay 2013-03-03"
|
||||
|
||||
// messages
|
||||
enum
|
||||
|
|
|
@ -659,7 +659,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
|||
// 1. Boot the selected iso
|
||||
// 2. Boot the default or last loaded iso.
|
||||
// 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_ListWii &&
|
||||
SConfig::GetInstance().m_ListWad) &&
|
||||
|
@ -693,7 +693,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
|||
|
||||
m_GameListCtrl->Update();
|
||||
}
|
||||
else if (!m_GameListCtrl->GetGameNames().size())
|
||||
else if (!m_GameListCtrl->GetISO(0))
|
||||
m_GameListCtrl->BrowseForDirectory();
|
||||
else
|
||||
// Game started by double click
|
||||
|
|
|
@ -285,10 +285,6 @@ void CGameListCtrl::Update()
|
|||
m_imageListSmall = NULL;
|
||||
}
|
||||
|
||||
// NetPlay : Set/Reset the GameList string
|
||||
m_gameList.clear();
|
||||
m_gamePath.clear();
|
||||
|
||||
Hide();
|
||||
|
||||
ScanForISOs();
|
||||
|
@ -406,15 +402,6 @@ wxString NiceSizeFormat(s64 _size)
|
|||
return(NiceString);
|
||||
}
|
||||
|
||||
std::string CGameListCtrl::GetGamePaths() const
|
||||
{
|
||||
return m_gamePath;
|
||||
}
|
||||
std::string CGameListCtrl::GetGameNames() const
|
||||
{
|
||||
return m_gameList;
|
||||
}
|
||||
|
||||
void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||
{
|
||||
// When using wxListCtrl, there is no hope of per-column text colors.
|
||||
|
@ -424,7 +411,6 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
int ImageIndex = -1;
|
||||
|
||||
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
|
||||
long ItemIndex = InsertItem(_Index, wxEmptyString);
|
||||
|
@ -438,31 +424,25 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
// Set the game's banner in the second column
|
||||
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
|
||||
|
||||
std::string name;
|
||||
|
||||
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
|
||||
|
||||
// Is this sane?
|
||||
switch (rISOFile.GetCountry())
|
||||
{
|
||||
case DiscIO::IVolume::COUNTRY_TAIWAN:
|
||||
case DiscIO::IVolume::COUNTRY_JAPAN:
|
||||
{
|
||||
name = rISOFile.GetName(-1);
|
||||
m_gameList.append(StringFromFormat("%s (J)\n", name.c_str()));
|
||||
}
|
||||
SelectedLanguage = -1;
|
||||
break;
|
||||
case DiscIO::IVolume::COUNTRY_USA:
|
||||
// Is this sane?
|
||||
SelectedLanguage = 0;
|
||||
default:
|
||||
{
|
||||
name = rISOFile.GetName(SelectedLanguage);
|
||||
m_gameList.append(StringFromFormat("%s (%c)\n", name.c_str(),
|
||||
(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
|
||||
|
||||
}
|
||||
case DiscIO::IVolume::COUNTRY_USA:
|
||||
SelectedLanguage = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
std::string const name = rISOFile.GetName(SelectedLanguage);
|
||||
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);
|
||||
|
||||
// We show the company string on Gamecube only
|
||||
|
|
|
@ -47,10 +47,6 @@ public:
|
|||
|
||||
void Update();
|
||||
|
||||
// Net Play method
|
||||
std::string GetGamePaths() const;
|
||||
std::string GetGameNames() const;
|
||||
|
||||
void BrowseForDirectory();
|
||||
const GameListItem *GetSelectedISO();
|
||||
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_sort;
|
||||
wxSize lastpos;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "Frame.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#define NETPLAY_TITLEBAR "Dolphin NetPlay"
|
||||
|
||||
|
@ -35,6 +36,21 @@ static NetPlay* netplay_ptr = NULL;
|
|||
extern CFrame* main_frame;
|
||||
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)
|
||||
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
|
||||
, m_game_list(game_list)
|
||||
|
@ -122,10 +138,7 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*
|
|||
m_game_lbox = new wxListBox(host_tab, wxID_ANY);
|
||||
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &NetPlaySetupDiag::OnHost, this);
|
||||
|
||||
std::istringstream ss(game_list->GetGameNames());
|
||||
std::string game;
|
||||
while (std::getline(ss,game))
|
||||
m_game_lbox->Append(StrToWxStr(game));
|
||||
FillWithGameNames(m_game_lbox, *game_list);
|
||||
|
||||
wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5);
|
||||
|
@ -360,24 +373,17 @@ void NetPlayDiag::OnChat(wxCommandEvent&)
|
|||
|
||||
void NetPlayDiag::OnStart(wxCommandEvent&)
|
||||
{
|
||||
// find path for selected game
|
||||
std::string ntmp, ptmp, path;
|
||||
std::istringstream nss(m_game_list->GetGameNames()), pss(m_game_list->GetGamePaths());
|
||||
|
||||
while(std::getline(nss,ntmp))
|
||||
// find path for selected game, sloppy..
|
||||
for (u32 i = 0 ; auto game = m_game_list->GetISO(i); ++i)
|
||||
{
|
||||
std::getline(pss,ptmp);
|
||||
if (m_selected_game == ntmp)
|
||||
if (m_selected_game == BuildGameName(*game))
|
||||
{
|
||||
path = ptmp;
|
||||
break;
|
||||
netplay_ptr->StartGame(game->GetFileName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.length())
|
||||
netplay_ptr->StartGame(path);
|
||||
else
|
||||
PanicAlertT("Game not found!!");
|
||||
PanicAlertT("Game not found!");
|
||||
}
|
||||
|
||||
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->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &ChangeGameDiag::OnPick, this);
|
||||
|
||||
// fill list with games
|
||||
std::istringstream ss(game_list->GetGameNames());
|
||||
std::string game;
|
||||
while (std::getline(ss,game))
|
||||
m_game_lbox->Append(StrToWxStr(game));
|
||||
FillWithGameNames(m_game_lbox, *game_list);
|
||||
|
||||
wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
|
||||
ok_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ChangeGameDiag::OnPick, this);
|
||||
|
|
Loading…
Reference in New Issue