mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
NetPlay: add one click host
Add a context menu entry in main game list to host a netplay game
based on saved settings.
Original commit:
commit 91aaa958e6
Author: Aestek <thib.gilles@gmail.com>
Date: Sun Jul 24 14:51:37 2016 +0200
This commit is contained in:
@ -37,8 +37,6 @@
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
|
||||
#include "DolphinWX/Frame.h"
|
||||
#include "DolphinWX/GameListCtrl.h"
|
||||
#include "DolphinWX/ISOFile.h"
|
||||
@ -56,46 +54,10 @@ NetPlayServer* NetPlayDialog::netplay_server = nullptr;
|
||||
NetPlayClient* NetPlayDialog::netplay_client = nullptr;
|
||||
NetPlayDialog* NetPlayDialog::npd = nullptr;
|
||||
|
||||
static std::string BuildGameName(const GameListItem& game)
|
||||
{
|
||||
// Lang needs to be consistent
|
||||
const DiscIO::Language lang = DiscIO::Language::LANGUAGE_ENGLISH;
|
||||
std::vector<std::string> info;
|
||||
if (!game.GetUniqueID().empty())
|
||||
info.push_back(game.GetUniqueID());
|
||||
if (game.GetRevision() != 0)
|
||||
{
|
||||
std::string rev_str = "Revision ";
|
||||
info.push_back(rev_str + std::to_string((long long)game.GetRevision()));
|
||||
}
|
||||
|
||||
std::string name(game.GetName(lang));
|
||||
if (name.empty())
|
||||
name = game.GetName();
|
||||
|
||||
int disc_number = game.GetDiscNumber() + 1;
|
||||
|
||||
std::string lower_name = name;
|
||||
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
|
||||
if (disc_number > 1 &&
|
||||
lower_name.find(std::string(wxString::Format("disc %i", disc_number))) == std::string::npos &&
|
||||
lower_name.find(std::string(wxString::Format("disc%i", disc_number))) == std::string::npos)
|
||||
{
|
||||
std::string disc_text = "Disc ";
|
||||
info.push_back(disc_text + std::to_string(disc_number));
|
||||
}
|
||||
if (info.empty())
|
||||
return name;
|
||||
std::ostringstream ss;
|
||||
std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", "));
|
||||
ss << info.back();
|
||||
return name + " (" + ss.str() + ")";
|
||||
}
|
||||
|
||||
void NetPlayDialog::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)));
|
||||
game_lbox->Append(StrToWxStr(game->GetUniqueIdentifier()));
|
||||
}
|
||||
|
||||
NetPlayDialog::NetPlayDialog(wxWindow* const parent, const CGameListCtrl* const game_list,
|
||||
@ -307,7 +269,7 @@ std::string NetPlayDialog::FindGame(const std::string& target_game)
|
||||
{
|
||||
// find path for selected game, sloppy..
|
||||
for (u32 i = 0; auto game = m_game_list->GetISO(i); ++i)
|
||||
if (target_game == BuildGameName(*game))
|
||||
if (target_game == game->GetUniqueIdentifier())
|
||||
return game->GetFileName();
|
||||
|
||||
return "";
|
||||
|
Reference in New Issue
Block a user