void BattleListTab::OnHost( wxCommandEvent& /*unused*/ ) { if ( !ui().IsConnected() ) { wxLogWarning( _T( "Trying to host while offline" ) ); customMessageBoxNoModal( SL_MAIN_ICON, _( "You cannot host a game while being offline. Please connect to a lobby server." ), _( "Not Online." ), wxOK ); ui().ShowConnectWindow(); return; } if ( !ui().IsSpringCompatible() ) { wxLogWarning( _T( "Hosting is disabled due to the incompatible version " ) ); customMessageBoxNoModal( SL_MAIN_ICON, _( "Hosting is disabled due to the incompatible version you're using" ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK ); return; } Battle* battle = ui().mw().GetJoinTab().GetCurrentBattle(); if ( battle != 0 ) { if ( ui().Ask( _( "Already in a battle" ), _( "You are already in a battle.\n\nDo you want to leave current battle to start a new?" ) ) ) { battle->Leave(); ui().mw().GetJoinTab().LeaveCurrentBattle(); } else { return; } } SL::RunHostBattleDialog( this ); }
void BattleListTab::DoJoin( Battle& battle ) { if ( !ui().IsSpringCompatible() ) { wxLogWarning( _T( "trying to join battles with imcompatible spring version" ) ); customMessageBox( SL_MAIN_ICON, _( "Joining battles is disabled due to the incompatible spring version you're using." ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK ); return; } Battle* curbattle = ui().mw().GetJoinTab().GetCurrentBattle(); if ( curbattle != 0 && curbattle->GetID() == battle.GetID() ) { if ( ui().Ask( _( "Already in this battle" ), _( "You are already in this battle.\n\nDo you want to leave it?" ) ) ) { curbattle->Leave(); ui().mw().GetJoinTab().LeaveCurrentBattle(); return; } else { return; } } if ( curbattle != 0 ) { if ( ui().Ask( _( "Already in another battle" ), _( "You are already in a battle.\n\nDo you want to leave your current battle and join this one?" ) ) ) { curbattle->Leave(); ui().mw().GetJoinTab().LeaveCurrentBattle(); } else { return; } } #ifdef NO_TORRENT_SYSTEM wxString downloadProc = _( "Do you want me to take you to the download page?" ); #else wxString downloadProc = _( "Should i try to download it for you?\nYou can see the progress in the \"Download Manager\" tab." ); #endif if ( !battle.ModExists() ) { if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the game before you can join this game.\n\n" ) + downloadProc, _( "Game not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) { wxString modhash = battle.GetHostModHash(); wxString modname = battle.GetHostModName(); ui().DownloadMod ( modhash, modname ); } return; } if ( !battle.MapExists() ) { if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the map to be able to play in this game.\n\n" ) + downloadProc, _( "Map not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) { wxString maphash = battle.GetHostMapHash(); wxString mapname = battle.GetHostMapName(); ui().DownloadMap ( maphash, mapname ); } } if ( battle.IsPassworded() ) { wxPasswordEntryDialog pw( this, _( "Battle password" ), _( "Enter password (spaces will be stripped)" ) ); pw.SetFocus(); if ( pw.ShowModal() == wxID_OK ) { wxString password = pw.GetValue(); password.Replace(_T(" "), _T("")); battle.Join( password ); } } else { battle.Join(); } }