diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index e77f972785..96ff78995a 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -34,7 +34,7 @@ struct Rpt : public std::vector typedef std::vector NetWiimote; -#define NETPLAY_VERSION "Dolphin NetPlay r6423" +#define NETPLAY_VERSION "Dolphin NetPlay 2013-03-03" // messages enum diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index b0b53cc5ea..a0a030081e 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -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 diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 15df0fa3ee..1a828bbf14 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -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; + break; + default: - { - name = rISOFile.GetName(SelectedLanguage); - m_gameList.append(StringFromFormat("%s (%c)\n", name.c_str(), - (rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E')); - - } break; } + std::string const name = rISOFile.GetName(SelectedLanguage); SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1); // We show the company string on Gamecube only diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.h b/Source/Core/DolphinWX/Src/GameListCtrl.h index 5d97c12724..f1923e97c5 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.h +++ b/Source/Core/DolphinWX/Src/GameListCtrl.h @@ -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; diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 60efcedc6f..8cfe41dc93 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -24,6 +24,7 @@ #include "Frame.h" #include +#include #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) @@ -121,11 +137,8 @@ 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);