Exemple #1
0
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 );
}
Exemple #2
0
void BattleRoomTab::OnStart( wxCommandEvent& /*unused*/ )
{
	if ( !m_battle ) return;
	if ( m_battle->IsFounderMe() )
	{
		m_battle->GetMe().BattleStatus().ready = true;
		if ( !m_battle->IsEveryoneReady() )
		{
			int answer = customMessageBox( SL_MAIN_ICON, _( "Some Players are not ready yet\nDo you want to force start?" ), _( "Not ready" ), wxYES_NO );
			if ( answer == wxNO ) return;
		}

		m_battle->SaveMapDefaults(); // save map presets

		m_battle->StartHostedBattle();
	}
	else
	{
		if ( m_battle->GetFounder().Status().in_game )
		{
			if ( !ui().IsSpringRunning() ) m_battle->StartSpring();
			else customMessageBoxNoModal( SL_MAIN_ICON, _("Spring is already running."), _("Error") );
		}
		else customMessageBoxNoModal( SL_MAIN_ICON, _("Host is not ingame."), _("Error") );
	}
}
Exemple #3
0
void WidgetInfoPanel::OnRemove( wxCommandEvent& /*unused*/ )
{
    if ( m_widget.Remove() ) {
        customMessageBoxNoModal( SL_MAIN_ICON, _("Widget files have been removed."), _("Success") );
    }
    else {
        customMessageBoxNoModal( SL_MAIN_ICON, _("Widget files have not been removed."), _("Error") );
    }
    SetButtonStates();
}
Exemple #4
0
void OpenWebBrowser(const wxString& url)
{
	if (sett().GetWebBrowserUseDefault()
	    // These shouldn't happen, but if they do we use the default browser anyway.
	    ||
	    sett().GetWebBrowserPath() == wxEmptyString || sett().GetWebBrowserPath() == _T("use default")) {
		if (!wxLaunchDefaultBrowser(url)) {
			wxLogWarning(_T("can't launch default browser"));
			customMessageBoxNoModal(SL_MAIN_ICON, _("Couldn't launch browser. URL is: ") + url, _("Couldn't launch browser."));
		}
	} else {
		if (!wxExecute(sett().GetWebBrowserPath() + _T(" ") + url, wxEXEC_ASYNC)) {
			wxLogWarning(_T("can't launch browser: %s"), sett().GetWebBrowserPath().c_str());
			customMessageBoxNoModal(SL_MAIN_ICON, _("Couldn't launch browser. URL is: ") + url + _("\nBroser path is: ") + sett().GetWebBrowserPath(), _("Couldn't launch browser."));
		}
	}
}
Exemple #5
0
void BattleRoomTab::OnHostNew( wxCommandEvent& /*event*/ )
{
	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;
	}
	HostBattleDialog::Run( this );
}
void SinglePlayerTab::OnModSelect( wxCommandEvent& /*unused*/ )
{
    unsigned int index = (unsigned int)m_mod_pick->GetCurrentSelection();
    size_t num_bots = m_battle.GetNumBots();
    SetMod( index );
    if( num_bots != m_battle.GetNumBots() )
        customMessageBoxNoModal( SL_MAIN_ICON, _("Incompatible bots have been removed after game selection changed."), _("Bots removed") );
}
Exemple #7
0
////////////////////////////////////////////////////////
//// private functions to interface with the system ////
////////////////////////////////////////////////////////
void TorrentWrapper::HandleCompleted()
{
	int num_completed = 0;
	{
	ScopedLocker<TorrenthandleInfoMap> l_torrent_table(m_handleInfo_map);
	const TorrenthandleInfoMap& infomap = l_torrent_table.Get();

	TorrenthandleInfoMap::const_iterator it = infomap.begin();
	for ( ; it != infomap.end(); ++it )
	{
		PlasmaResourceInfo info = it->first;
		libtorrent::torrent_handle handle = it->second;
		if ( handle.is_valid() && handle.is_seed() )
		{
			wxString dest_filename = sett().GetCurrentUsedDataDir() +
									 getDataSubdirForType( convertMediaType( info.m_type ) ) +
									 wxFileName::GetPathSeparator() +
									 TowxString( handle.get_torrent_info().file_at( 0 ).path.string() );
			if ( !wxFileExists( dest_filename ) )
			{
				wxString source_path = TowxString( handle.save_path().string() )  +
									   wxFileName::GetPathSeparator() +
									   TowxString( handle.get_torrent_info().file_at( 0 ).path.string() );
				wxString dest_path = wxPathOnly( dest_filename );
				if ( !wxDirExists( dest_path ) )
						wxMkdir( dest_path );
				bool ok = wxCopyFile( source_path, dest_filename );
				if ( !ok )
				{
					wxString msg = wxString::Format( _("File copy from %s to %s failed.\nPlease copy manually and reload maps/mods afterwards"),
								source_path.c_str(), dest_filename.c_str() );
					wxLogError( _T("DL: File copy from %s to %s failed."), source_path.c_str(), dest_filename.c_str() );
					#ifdef __WXMSW__
						UiEvents::StatusData data( msg, 1 );
						UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent( data );
					#else
						customMessageBoxNoModal( SL_MAIN_ICON, msg, _("Copy failed") );
					#endif
					//this basically invalidates the handle for further use
					m_torr->remove_torrent( handle );
				}
				else
				{
					wxRemoveFile( source_path );
					wxLogDebug( _T("DL complete: %s"), info.m_name.c_str() );
					UiEvents::StatusData data( wxString::Format( _("Download completed: %s"), info.m_name.c_str() ), 1 );
					UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent( data );
					num_completed++;
				}
			}
		}
	}
	}
	if ( num_completed > 0 )
	{
		usync().AddReloadEvent();
	}
}
Exemple #8
0
void MainWindow::OnMenuSelectLocale(wxCommandEvent& /*unused*/)
{
	if (wxGetApp().SelectLanguage()) {
		customMessageBoxNoModal(SL_MAIN_ICON,
					_("You need to restart SpringLobby for the language change to take effect."),
					_("Restart required"),
					wxICON_EXCLAMATION | wxOK);
	}
}
void BattleRoomTab::OnHostNew(wxCommandEvent& /*event*/)
{
	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;
	}
	SL::RunHostBattleDialog(this);
}
Exemple #10
0
bool UserActions::IsKnown( const wxString& name, bool outputWarning ) const
{
    bool ret = m_knownUsers.Index( name ) != -1;
    if ( outputWarning ){
        customMessageBoxNoModal( SL_MAIN_ICON, _("To prevent logical inconsistencies, adding a user to more than one group is not allowed"),
           _("Cannot add user to group") );
    }

    return ret;
}
void BattleroomMMOptionsTab<BattleType>::OnLoadPreset( wxCommandEvent& /*unused*/ )
{
	if ( !m_battle ) return;
  wxString presetname = m_options_preset_sel->GetValue();
  if ( presetname.IsEmpty() )
  {
     customMessageBoxNoModal( SL_MAIN_ICON , _("Cannot load an options set without a name\nPlease select one from the list and try again."), _("error"), wxICON_EXCLAMATION|wxOK );
     return;
  }
  m_battle->LoadOptionsPreset( presetname );
  m_battle->SendHostInfo( IBattle::HI_Send_All_opts );
  OnReloadControls( );
}
void BattleRoomTab::OnSavePreset(wxCommandEvent& /*unused*/)
{
	if (!m_battle)
		return;
	wxString presetname;
	if (!ui().AskText(_("Enter a name to save the current set of options\nIf a preset with the same name already exist, it will be overwritten"), _("Enter preset name"), presetname))
		return;
	if (presetname.IsEmpty()) {
		customMessageBoxNoModal(SL_MAIN_ICON, _("Cannot save an options set without a name."), _("error"), wxICON_EXCLAMATION | wxOK);
		return;
	}
	m_battle->SaveOptionsPreset(STD_STRING(presetname));
}
void ChatPanelMenu::OnUserMenuJoinSame( wxCommandEvent& /*unused*/ )
{
	const User* user = m_chatpanel->GetSelectedUser();
	if ( user == 0 ) return;
	Battle* battle = user->GetBattle();
	if ( battle == 0 ) return;

	if ( !usync().ModExists( battle->GetHostModName() ) ) {
		customMessageBoxNoModal( SL_MAIN_ICON, _( "You don't have the mod " ) + battle->GetHostModName()
														 + _( " . Please download it first" ), _( "Mod unavailable" ) );
		return;
	}

	if ( battle->IsLocked() ) {
		customMessageBoxNoModal( SL_MAIN_ICON, _( "The battle you requested to join is locked." ) );
		return;
	}
	wxString password;
	if ( battle->IsPassworded() ) {
		if ( !ui().AskPassword( _( "Battle password" ), _( "This battle is password protected, enter the password." ), password ) ) return;
	}
	battle->Join( password );
}
Exemple #14
0
bool Spring::LaunchSpring( const wxString& params  )
{
  if ( m_running )
  {
    wxLogError( _T("Spring already running!") );
    return false;
  }
    if ( !wxFile::Exists( sett().GetCurrentUsedSpringBinary() ) ) {
        customMessageBoxNoModal( SL_MAIN_ICON, _T("The spring executable was not found at the set location, please re-check."), _T("Executable not found") );
        ui().mw().ShowConfigure( MainWindow::OPT_PAGE_SPRING );
        return false;
    }

  wxString configfileflags = sett().GetCurrentUsedSpringConfigFilePath();
  if ( !configfileflags.IsEmpty() )
  {

		configfileflags = _T("--config=\"") + configfileflags + _T("\" ");
		#ifdef __WXMSW__
      if ( LSL::usync().GetSpringVersion().find("0.78.") != std::string::npos ) configfileflags = _T("");
		#endif
  }

  wxString cmd =  _T("\"") + sett().GetCurrentUsedSpringBinary();
  #ifdef __WXMAC__
    wxChar sep = wxFileName::GetPathSeparator();
	if ( sett().GetCurrentUsedSpringBinary().AfterLast(_T('.')) == _T("app") )
        cmd += sep + wxString(_T("Contents")) + sep + wxString(_T("MacOS")) + sep + wxString(_T("spring")); // append app bundle inner path
  #endif
  cmd += _T("\" ") + configfileflags + params;

  wxLogMessage( _T("spring call params: %s"), cmd.c_str() );

  wxSetWorkingDirectory( sett().GetCurrentUsedDataDir() );
  if ( sett().UseOldSpringLaunchMethod() )
  {
    if ( m_wx_process == 0 ) m_wx_process = new wxSpringProcess( *this );
    if ( wxExecute( cmd , wxEXEC_ASYNC, m_wx_process ) == 0 ) return false;
  }
  else
  {
    if ( m_process == 0 ) m_process = new SpringProcess( *this );
    m_process->Create();
    m_process->SetCommand( cmd );
    m_process->Run();
  }
  m_running = true;
	GlobalEvent::Send(GlobalEvent::OnSpringStarted);
  return true;
}
Exemple #15
0
void ChatPanelMenu::OnUserMenuCreateGroup(wxCommandEvent& /*unused*/)
{
	wxString name;
	if (ui().AskText(_("Enter name"),
			 _("Please enter the name for the new group.\nAfter clicking ok you will be taken to adjust its settings."), name)) {
		const User* user = m_chatpanel->GetSelectedUser();
		if (user) {
			useractions().AddGroup(name);
			useractions().AddUserToGroup(name, TowxString(user->GetNick()));
			ui().mw().ShowConfigure(MainWindow::OPT_PAGE_GROUPS);
		} else
			customMessageBoxNoModal(SL_MAIN_ICON, _("couldn't add user"), _("Error"));
	}
}
void SinglePlayerTab::OnStart( wxCommandEvent& /*unused*/ )
{
    wxLogDebugFunc( _T("SP: ") );

    if ( ui().IsSpringRunning() )
    {
        wxLogWarning(_T("trying to start spring while another instance is running") );
        customMessageBoxNoModal(SL_MAIN_ICON, _("You cannot start a spring instance while another is already running"), _("Spring error"), wxICON_EXCLAMATION );
        return;
    }

	m_battle.SetEngineName("spring");
	m_battle.SetEngineVersion(SlPaths::GetCurrentUsedSpringIndex()); //FIXME: make engine version selectable

    if ( ValidSetup() ) m_battle.StartSpring();
}
Exemple #17
0
void DisplayError( const wxString& resourcename, TorrentWrapper::DownloadRequestStatus status )
{
	wxString msg;
	switch ( status )
	{
		case TorrentWrapper::no_seeds_found: msg = _("The remote server supplied no sources to download the file from."); break;
		case TorrentWrapper::remote_file_dl_failed: msg = _("The file was not found on the remote server"); break;
		case TorrentWrapper::corrupt_torrent_file: msg = _("The downloaded file was corrupted. You should retry the download."); break;
		case TorrentWrapper::torrent_join_failed: msg = _("The downloaded .torrent file was unusable."); break;
		default: msg = _("Unknown"); break;
	}
	msg = wxString::Format(_("Downloading %s failed with reason:\n%s"), resourcename.c_str(), msg.c_str() );
	wxString title = _("Download failure");
#ifdef __WXMSW__
	UiEvents::StatusData data( wxString::Format(_("Downloading %s failed"), resourcename.c_str() ), 1 );
	UiEvents::GetStatusEventSender( UiEvents::addStatusMessage ).SendEvent( data );
#else
	wxMutexGuiLocker locker;
	customMessageBoxNoModal( SL_MAIN_ICON, msg, title );
#endif
}
Exemple #18
0
bool Spring::Run( IBattle& battle )
{
	std::string executable = SlPaths::GetSpringBinary(battle.GetEngineVersion());
	if ( !wxFile::Exists(TowxString(executable)) ) {
		executable = SlPaths::GetSpringBinary(SlPaths::GetCompatibleVersion(battle.GetEngineVersion())); //fallback, no exact version found, try fallback version
		if ( !wxFile::Exists(TowxString(executable)) ) {
			customMessageBoxNoModal( SL_MAIN_ICON, wxFormat(_T("The spring executable version '%s' was not found at the set location '%s', please re-check.")) % battle.GetEngineVersion() % executable, _T("Executable not found") );
			ui().mw().ShowConfigure( MainWindow::OPT_PAGE_SPRING );
			return false;
		}
	}

	wxArrayString params;

	const std::string demopath = battle.GetPlayBackFilePath();
	if (!demopath.empty()){
		params.push_back(TowxString(demopath));
		return LaunchEngine(executable, params);
	}

	const wxString scripttxt = TowxString(SlPaths::GetLobbyWriteDir()) + _T("script.txt");
	try {

		wxFile f( scripttxt, wxFile::write );
		battle.DisableHostStatusInProxyMode( true );
		f.Write( WriteScriptTxt(battle) );
		battle.DisableHostStatusInProxyMode( false );
		f.Close();
	} catch ( std::exception& e ) {
		wxLogError( wxString::Format( _T("Couldn't write %s, exception caught:\n %s"), scripttxt.c_str(), TowxString( e.what() ).c_str() ) );
		return false;
	} catch (...) {
		wxLogError( wxString::Format( _T("Couldn't write %s"), scripttxt.c_str()));
		return false;
	}

	params.push_back(scripttxt);
	return LaunchEngine(executable, params);
}
Exemple #19
0
void PlaybackTab<PlaybackTraits>::OnDelete( wxCommandEvent& /*unused*/ )
{
	int sel_index = m_replay_listctrl->GetSelectedIndex();
	if ( sel_index >= 0 ) {
		try {
			const PlaybackType& rep = *m_replay_listctrl->GetSelectedData();
			int m_sel_replay_id = rep.id;
			int index = m_replay_listctrl->GetIndexFromData( &rep );
			wxLogMessage( _T( "Deleting replay %d " ), m_sel_replay_id );
			wxString fn = rep.Filename;
			if ( !playbacklist<ListType>().DeletePlayback( m_sel_replay_id ) )
				customMessageBoxNoModal( SL_MAIN_ICON, _( "Could not delete Replay: " ) + fn,
				                         _( "Error" ) );
			else {
				RemovePlayback( index ); // Deselect is called in there too
			}
		} catch ( std::runtime_error ) {
			return;
		}
	} else {
		Deselected();
	}
}
void SimpleServerEvents::OnKickedFromBattle()
{
    customMessageBoxNoModal(SL_MAIN_ICON,_("You were kicked from the battle!"),_("Kicked by Host"));
}
Exemple #21
0
bool ChatPanel::Say( const wxString& message )
{
	static const unsigned int flood_threshold = 5;
	wxLogDebugFunc( message );
	wxStringTokenizer lines( message, _T( '\n' ) );
	if ( lines.CountTokens() > flood_threshold ) {
		PasteDialog dl ( this, wxString::Format(
			_( "Are you sure you want to paste %d lines?" ), lines.CountTokens() ) );
		switch ( dl.ShowModal() ) {
			case wxID_NO :
				return true;
			case PasteDialog::pasteButtonReturnCode : {
				wxString url = Paste2Pastebin( message );
				if ( url != wxEmptyString && wxStringTokenizer( url, _T( '\n' )).CountTokens() <= flood_threshold ) {
					Say( url );
					return true;
				}
				else {
					customMessageBoxNoModal( SL_MAIN_ICON, _("Failed to post to pastebin.com.") );
					return false;
				}
			}
			default:
				break;
		}
	}
	while ( lines.HasMoreTokens() ) {
		wxString line = lines.GetNextToken();
		wxLogMessage( _T( "line: %s" ), line.c_str() );

		if ( line.Find( '/' ) == 0 ) {
			if ( ui().ExecuteSayCommand( line ) ) return true;
		}

		if ( line == _T( "/ver" ) ) {
			//!this instance is not replaced with GetAppname for sake of help/debug online
			OutputLine( _( " You have SpringLobby v" ) + GetSpringLobbyVersion(), sett().GetChatColorNormal() , sett().GetChatFont() );
			return true;
		}

		if ( line == _T( "/clear" ) ) {
            m_chatlog_text->SetValue( _T("") );
			return true;
		}

		if ( m_type == CPT_Channel ) {

			if ( m_channel == 0 ) {
				OutputLine( _( " You are not in channel or channel does not exist." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_channel->ExecuteSayCommand( line ) ) return true;
				if ( m_channel->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_channel->Say( line );

		} else if ( m_type == CPT_Battle ) {

			if ( m_battle == 0 ) {
				OutputLine( _( " You are not in battle or battle does not exist, use /help for a list of available commands." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_battle->ExecuteSayCommand( line ) ) return true;
				if ( m_battle->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_battle->Say( line );

		} else if ( m_type == CPT_User ) {

			if ( m_user == 0 ) {
				OutputLine( _( " User is offline." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_user->ExecuteSayCommand( line ) ) return true;
				if ( m_user->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_user->Say( line );

		} else if ( m_type == CPT_Server ) {
			if ( m_server == 0 ) return true;

			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_server->ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}

            //we need to disable the channel tab if leaving manually
            if (line.Upper().StartsWith( _T( "LEAVE" ) ) )
            {
                wxString channame = line.AfterFirst(' ').BeforeFirst(' ');
                try
                {
									Channel& chan = m_server->GetChannel( channame );
									chan.Leave();
									chan.uidata.panel = 0;
								}
								catch( assert_exception ) {}
            }

			m_server->SendRaw( line );
			OutputLine( _( " Sent: \"" ) + line + _( "\"" ), sett().GetChatColorNormal(), sett().GetChatFont() );
		}
	}
	return true;
}
Exemple #22
0
TimerMessageBox::~TimerMessageBox()
{
	wxTimeSpan diff = wxDateTime::Now().Subtract( *m_start );
	customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( m_msg_format ) % diff.Format() );
	delete m_start;
}
void RunHostBattleDialog( wxWindow* parent )
{
	HostBattleDialog dlg( parent );
	if ( dlg.ShowModal() == wxID_OK )
	{
		BattleOptions bo;
		bo.description = sett().GetLastHostDescription();
		bo.port = sett().GetLastHostPort();
		bo.nattype = NatType( sett().GetLastHostNATSetting() );

		if ( bo.nattype == NAT_None && sett().GetTestHostPort() )
		{
			switch ( ui().TestHostPort( bo.port ) )
			{
				case Server::porttest_pass :
					break; // success
				case Server::porttest_pass_WX26 :
					wxLogWarning( _T( "hosting port %d: test aborted (wx26)" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Your using wxWidgets prior to version 2.8,\n "
											 "port testing is not supported.\n Hosting may or may not work." ) ) % bo.port );
					sett().SetTestHostPort( false ); // no need to have it checked anymore
					break;

				case Server::porttest_unreachable :
					wxLogWarning( _T( "hosting port %d: test undetermined" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "The server used for testing your port %d "
											 "is unreachable. \nHosting may or may not work with this setting." ) ) % bo.port );
					break; //inconclusive test shouldn't hinder hosting imo (koshi)

				case Server::porttest_timeout :
				case Server::porttest_socketNotOk :
				case Server::porttest_socketError :
					wxLogWarning( _T( "hosting port %d: test unsuccessful, closing battle" ), bo.port  );
					customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Battle not started because the port you selected (%d) "
											 "is unable to-f /home/kosh/.springlobby/testing.conf recieve incoming packets\n checks your router & firewall configuration again or change port "
											 "in the dialog.\n\nIf everything else fails, enable the Hole Punching NAT Traversal\n "
											 "option in the hosting settings." ) ) % bo.port );
					return;
				default:
					wxLogWarning( _T( "unknonw port forward test result" ) );
					break;

			}
			if ( !ui().TestHostPort( bo.port ) )
			{
				wxLogWarning( _T( "hosting port %d: test unsuccessful, closing battle" ), bo.port  );
				customMessageBoxNoModal( SL_MAIN_ICON, wxFormat( _( "Battle not started because the port you selected (%d) "
										"is unable to recieve incoming packets\n checks your router & firewall configuration "
										"again or change port in the dialog.\n\nIf everything else fails, enable the Hole "
										"Punching NAT Traversal\n option in the hosting settings." ) ) % bo.port );
				return;
			}
		}

		// Get selected mod from unitsync.
		LSL::UnitsyncMod mod;
		try
		{
            mod = LSL::usync().GetMod(STD_STRING(sett().GetLastHostMod()));
            bo.modhash = TowxString(mod.hash);
            bo.modname = TowxString(mod.name);
		}
		catch ( ... )
		{
			wxLogWarning( _T( "can't host: game not found" ) );
			customMessageBoxNoModal( SL_MAIN_ICON, _( "Battle not started beacuse the game you selected could not be found. " ), _( "Error starting battle." ), wxOK );
			return;
		}

		LSL::UnitsyncMap map;
        const auto mname = STD_STRING(sett().GetLastHostMap());
		try {
			if ( LSL::usync().MapExists( mname ) )
				map = LSL::usync().GetMap( mname );
			else if ( LSL::usync().GetNumMaps() <= 0 )
			{
				wxLogWarning( _T( "no maps found" ) );
				customMessageBoxNoModal( SL_MAIN_ICON, _( "Couldn't find any maps in your spring installation. This could happen when you set the Spring settings incorrectly." ), _( "No maps found" ), wxOK );
				return;
			}
			else
			{
				map = LSL::usync().GetMap( 0 );
			}
		}
		catch ( ... )
		{
			wxLogWarning( _T( "no maps found" ) );
			customMessageBoxNoModal( SL_MAIN_ICON, _( "Couldn't find any maps in your spring installation. This could happen when you set the Spring settings incorrectly." ), _( "No maps found" ), wxOK );
			return;
		}
        bo.maphash = TowxString(map.hash);
        bo.mapname = TowxString(map.name);

		bo.rankneeded = sett().GetLastRankLimit();

		bo.maxplayers = sett().GetLastHostPlayerNum();
		bo.userelayhost = sett().GetLastHostRelayedMode();
		if ( bo.userelayhost ) bo.nattype = NAT_None;
		bo.relayhost = sett().GetLastRelayedHost();
		bo.engineName = _T("spring");
		bo.engineVersion = TowxString(LSL::usync().GetSpringVersion());

		serverSelector().GetServer().HostBattle( bo, sett().GetLastHostPassword() );
	}
}
Exemple #24
0
void MainWindow::OnMenuResetLayout(wxCommandEvent& /*event*/)
{
	cfg().Write(_T( "/ResetLayout" ), true);
	sett().SaveSettings();
	customMessageBoxNoModal(SL_MAIN_ICON, _("Please restart SpringLobby now"), wxEmptyString);
}
Exemple #25
0
void MainWindow::OnMessage(wxCommandEvent& event)
{
	customMessageBoxNoModal(SL_MAIN_ICON, event.GetString());
}
void SimpleServerEvents::OnSpringDownloadEvent( wxCommandEvent& event )
{
	int code = event.GetInt();
	wxLogMessage(event.GetString());
  if ( code != 0)
  {
  	 customMessageBox(SL_MAIN_ICON, _("There was an error downloading for the latest version.\n"), _("Error"));
		wxString err;
    switch (code)
    {
      case wxPROTO_NETERR:
        err = _("Network Error");
        break;
      case wxPROTO_PROTERR:
        err = _("Negotiation error");
        break;
      case wxPROTO_CONNERR:
        err = _T("Failed to connect to server");
        break;
      case wxPROTO_INVVAL:
        err = _("Invalid Value");
        break;
      case wxPROTO_NOHNDLR:
        err = _("No Handler");
        break;
      case wxPROTO_NOFILE:
        err = _("File doesn't exit");
        break;
      case wxPROTO_ABRT:
        err = _("Action Aborted");
        break;
      case wxPROTO_RCNCT:
        err = _("Reconnection Error");
        break;
      default:
        err = _("Unknown Error");
        break;
    }

    wxLogDebugFunc(_T("Error connecting! Error is: ") + err);
    customMessageBoxNoModal(SL_MAIN_ICON, _T("Error connecting! (") + err + _T(")\nPlease update manually from http://springrts.com"), _T(""));

  }
  else
  {
			wxString text =  _("Download complete, location is: ") + m_savepath;
			if ( m_autoclose ) text += _("\nlobby will get closed now.");
			customMessageBox(SL_MAIN_ICON, text, _("Download complete.")  );
			if ( m_autolaunch )
			{
				if ( !wxExecute( _T("\"") + m_savepath + _T("\""), wxEXEC_ASYNC ) )
				{
						customMessageBoxNoModal(SL_MAIN_ICON, _("Couldn't launch installer. File location is: ") + m_savepath, _("Couldn't launch installer.")  );
				}
			}
			if ( m_autoclose )
			{
//				ui().mw().Close();
			}

  }
}