Esempio n. 1
0
bool SinglePlayerTab::ValidSetup() const
{
    if ( (unsigned int)m_mod_pick->GetSelection() >= m_mod_pick->GetCount()-1 )
    {
		wxLogWarning( _T("no game selected") );
		customMessageBox(SL_MAIN_ICON, _("You have to select a game first."), _("Game setup error") );
        return false;
    }

    if ( (unsigned int)m_map_pick->GetSelection() >= m_map_pick->GetCount()-1 )
    {
        wxLogWarning( _T("no map selected") );
		customMessageBox(SL_MAIN_ICON, _("You have to select a map first."), _("Game setup error") );
        return false;
    }

    if ( m_battle.GetNumUsers() == 1 )
    {
        wxLogWarning(_T("trying to start sp game without bot"));
        if ( customMessageBox(SL_MAIN_ICON, _("Continue without adding a bot first?.\n The game will be over pretty fast.\n "),
                              _("No Bot added"), wxYES_NO) == wxNO )
            return false;
    }
    return true;
}
Esempio n. 2
0
//all messageboxes need to be modal, updater closes immeadiately when receiving the UpdateFinished event
void UpdaterClass::OnDownloadEvent( wxCommandEvent& event )
{
    int code = event.GetInt();
    if ( code != 0)
        customMessageBox(SL_MAIN_ICON, _("There was an error downloading for the latest version.\nPlease try again later.\nIf the problem persists, please use Help->Report Bug to report this bug."), _("Error"));
    else {
        if (!PostMinGW44( m_newexe ) ) {
            customMessageBox(SL_MAIN_ICON, _("Automatic update failed\n\nyou will be redirected to a web page with instructions and the download link will be opened in your browser."), _("Updater error.") );
			OpenWebBrowser( _T("http://projects.springlobby.info/wiki/springlobby/Install#Windows-Binary") );
            OpenWebBrowser( GetDownloadUrl( m_latest_version ) );
        }
        if ( !UpdateExe( m_newexe , false ) ) {
			customMessageBox(SL_MAIN_ICON,
							 wxFormat( _("There was an error while trying to replace the current executable version.\n Please manually copy springlobby.exe from: %s\n to: %s\n") )
											   % m_newexe
											   % m_currentexe,
							 _("Error") );
        }
        else {
            bool locale_ok = UpdateLocale( m_newexe, false );
            if ( locale_ok ) {
				customMessageBox(SL_MAIN_ICON, IdentityString( _("Update complete. \nPlease restart %s now.") ), _("Success"));
            }
            else {
				customMessageBox(SL_MAIN_ICON,
								 IdentityString( _("Binary updated successfully. \nSome translation files could not be updated.\nPlease report this in #springlobby. \nPlease restart %s now.") ),
								 _("Partial success") );
            }
            wxRmdir( m_newexe );
        }
    }
    GetGlobalEventSender( GlobalEvents::UpdateFinished ).SendEvent( 0 );
}
Esempio n. 3
0
bool abstract_panel::loadValuesIntoMap()
{
	try
	{
		//special treatment for resolution that'll set proper defaults for res
		wxDisplay display(0);
		wxRect display_rect ( display.GetGeometry() );
//		const int current_x_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[0].key,display_rect.width);
//		const int current_y_res = LSL::susynclib().GetSpringConfigInt(RC_TEXT[1].key,display_rect.height);

		for (int i = 0; i< intControls_size;++i)
		{
      intSettings[intControls[i].key]
          = LSL::susynclib().GetSpringConfigInt(STD_STRING(intControls[i].key),fromString(intControls[i].def));
		}
    for (int i = 0; i< floatControls_size;++i)
    {
      floatSettings[floatControls[i].key]
          = LSL::susynclib().GetSpringConfigFloat(STD_STRING(floatControls[i].key),fromString(floatControls[i].def));
		}
	}
	catch (...)
	{
		customMessageBox(SS_MAIN_ICON,_("Could not access your settings.\n"), _("Error"), wxOK|wxICON_HAND, 0);
		abstract_panel::settingsChanged = false;
		return false;
	}

	return true; // SUCCESS!
}
Esempio n. 4
0
bool ChatLog::OpenLogFile()
{
    wxLogMessage( _T( "OpenLogFile( ) server = %s, room = %s" ), m_server.c_str(), m_room.c_str() ) ;
    wxString logFilePath ( GetCurrentLogfilePath() );

    if ( LogEnabled() && CreateCurrentLogFolder() ) {
        m_logfile.Open( logFilePath, wxFile::write_append );

        if ( !m_logfile.IsOpened() ) {
            wxLogWarning( _T( "Can't open log file %s" ), logFilePath.c_str() ) ;
            customMessageBox( SL_MAIN_ICON,
                              _( "Can't open log file \"" ) + logFilePath + _("\".\nBe sure that there isn't a write protection.\n" ),
                              _( "Log Warning" ) ) ;
            m_active = false;
        }
        else {
            FillLastLineArray();

            wxDateTime now = wxDateTime::Now();
            wxString text = _T( "### Session Start at [" ) + now.Format( _T( "%Y-%m-%d %H:%M" ) ) + _T( "]" ) + wxTextBuffer::GetEOL();
            return WriteLine( text );
        }
    }
    return false;
}
Esempio n. 5
0
void HostBattleDialog::OnOk( wxCommandEvent& /*unused*/ )
{
	if ( m_mod_pic->GetSelection() == wxNOT_FOUND ) {
		wxLogWarning( _T( "no mod selected" ) );
		customMessageBox( SL_MAIN_ICON, _( "You have to select a game first." ), _( "No game selected." ), wxOK );
		return;
	}
	if ( m_desc_text->GetValue().IsEmpty() ) m_desc_text->SetValue( _T( "(none)" ) );
	sett().SetLastHostDescription( m_desc_text->GetValue() );
	sett().SetLastHostMod( m_mod_pic->GetString( m_mod_pic->GetSelection() ) );
	wxString password = m_pwd_text->GetValue();
	password.Replace(_T(" "), _T(""));
	sett().SetLastHostPassword( password );
	long tmp = DEFSETT_SPRING_PORT;
	m_port_text->GetValue().ToLong( &tmp );
	sett().SetLastHostPort( tmp );
//  sett().SetTestHostPort( m_port_test_check->GetValue() );
	sett().SetTestHostPort( false );
	sett().SetLastHostPlayerNum( m_players_slide->GetValue() );
	sett().SetLastHostNATSetting( m_nat_radios->GetSelection() );
	sett().SetLastRankLimit( GetSelectedRank() );
	sett().SetLastHostRelayedMode( m_relayed_host_check->GetValue() );
	sett().SetBattleLastAutoAnnounceDescription( m_desc_check->GetValue() );
	sett().SetLastRelayedHost( m_last_relayhost );
	sett().SaveSettings();
	EndModal( wxID_OK );
}
Esempio n. 6
0
void settings_frame::handleExit() {
  if (settingsChangedAbstract())
  {
    int action = customMessageBox(SS_MAIN_ICON,_("Save Spring settings before exiting?"), _("Confirmation needed"),wxYES_NO|wxCANCEL|wxICON_QUESTION );
    switch (action) {
      case wxYES:
        if (saveSettingsAbstract())
               (abstract_panel::settingsChanged) = false;
        if (simpleTab!=0)
            simpleTab->saveCbxChoices();
      case wxNO:
        doQuit();
        return;

      case wxCANCEL:
      default:
        return;
    }
  }
  else
  {
    doQuit();
    return;
  }
}
Esempio n. 7
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 {
			m_battle->m_autohost_manager->GetAutohostHandler().Start();
			//customMessageBoxNoModal( SL_MAIN_ICON, _("Host is not ingame."), _("Error") );
		}
	}
}
Esempio n. 8
0
bool ChatLog::WriteLine( const wxString& text )
{
    if ( !m_logfile.Write( text, wxConvUTF8 ) ) {
        m_active = false;
        wxLogWarning( _T( "can't write message to log (%s)" ),  wxString( m_server + _T( "::" ) + m_room ).c_str() );
        customMessageBox( SL_MAIN_ICON, _( "Couldn't write message to log.\nLogging will be disabled for room " )
                          + m_server + _T( "::" ) + m_room + _( ".\n\nRejoin room to reactivate logging." ),
                          _( "Log Warning" ) );
        return false;
    }
    return true;
}
Esempio n. 9
0
void SpringOptionsTab::OnAddBundle(wxCommandEvent& /*event*/)
{
	wxFileDialog pick(this, _("Choose UnitSync library"),
			  wxPathOnly(TowxString(SlPaths::GetUnitSync())),
			  wxFileName::FileName(TowxString(SlPaths::GetUnitSync())).GetFullName(),
			  GetUnitsyncFilter());
	if (pick.ShowModal() == wxID_OK) {
		//get unitsync version & add to list
		bool failed = false;
		wxString failMessage;
		LSL::SpringBundle bundle;
#ifdef __APPLE__
		wxString path = pick.GetPath();
		bundle.unitsync = STD_STRING(path + (path.EndsWith("libunitsync.dylib") ? "" : "/Contents/MacOS/libunitsync.dylib"));
#else
		bundle.unitsync = STD_STRING(pick.GetPath());
#endif
		wxString version;
		try {
			bundle.AutoComplete();
			version = TowxString(bundle.version);
			if (!bundle.IsValid() || version.IsEmpty()) { // couldn't detect paths automaticly, allow user to select spring executable
				wxFileDialog pick(this, _("Choose a Spring executable"),
						  wxPathOnly(TowxString(bundle.unitsync)),
						  wxFileName::FileName(TowxString(SlPaths::GetSpringBinary())).GetFullName(),
						  GetSpringFilter());
				if (pick.ShowModal() == wxID_OK) {
					bundle.spring = STD_STRING(pick.GetPath());
				}
			}

			if (!bundle.IsValid() || version.IsEmpty()) {
				failed = true;
				failMessage = wxString::Format(_T("%s did not find engine and unitsync executables at %s\n\nPlease ensure that both exist and that you have appropriate access privileges."), getSpringlobbyName().c_str(), bundle.path.c_str());
			}
		} catch (const LSL::Exceptions::unitsync& e) {
			failed = true;
			failMessage = wxString::Format(_T("%s could not obtain the version string from the shared library file %s\n\nPlease provide a valid unitsync file."), getSpringlobbyName().c_str(), bundle.unitsync.c_str());
		}
		if (failed) {
			customMessageBox(SL_MAIN_ICON, failMessage, _("Configuration error"), wxOK);
			return;
		}

		m_spring_list->Append(version);
		m_spring_list->SetStringSelection(version);
		m_sync_edit->SetValue(TowxString(bundle.unitsync));
		m_exec_edit->SetValue(TowxString(bundle.spring));
		SlPaths::RefreshSpringVersionList(false, &bundle);
		DoRestore();
	}
}
Esempio n. 10
0
void SpringOptionsTab::SwitchUnitsync(const std::string& newIndex, const std::string& oldIndex /* can be empty */)
{
	UiEvents::ScopedStatusMessage(_("Reloading unitsync"), 0);
	SlPaths::SetUsedSpringIndex(newIndex);
	if (!LSL::usync().LoadUnitSyncLib(SlPaths::GetUnitSync(newIndex))) { //FIXME: make LoadUnitSyncLib() async (partly done)
		wxLogWarning(_T( "Cannot load UnitSync" ));
		customMessageBox(SL_MAIN_ICON,
				 wxString::Format(_T("%s is unable to load your UnitSync library into the process.\n\nYou might want to take another look at your unitsync setting."), getSpringlobbyName().c_str()),
				 _("Spring error"), wxOK);
		SlPaths::SetUsedSpringIndex(oldIndex);
		DoRestore();
	}
}
Esempio n. 11
0
bool ChatLog::CreateCurrentLogFolder()
{
    wxString path ( wxFileName(GetCurrentLogfilePath()).GetPath() );
    if ( !tryCreateDirectory( path ) ) {
        wxLogWarning( _T( "can't create logging folder: %s" ), path.c_str() );
        customMessageBox( SL_MAIN_ICON,
                          _( "Couldn't create folder. \nBe sure that there isn't a write protection.\n" ) + path
                          + _( "Log function is disabled until restart SpringLobby." ), _( "Log Warning" ) );
        m_active = false;
        return false;
    }
    return true;
}
Esempio n. 12
0
void MainWindow::ShowChannelChooser()
{
	if ((m_channel_chooser == NULL) || (m_channel_chooser && m_channel_chooser->IsShown()))
		return;

	if (!ui().IsConnected()) {
		customMessageBox(SL_MAIN_ICON, _("You need to be connected to a server to view the channel list"), _("Not connected"));
	} else {
		m_channel_chooser->ClearChannels();
		serverSelector().GetServer().RequestChannels();
		m_channel_chooser->Show(true);
	}
}
void AddSelectionCmdDlg::OnButtonAddClick( wxCommandEvent& /*event*/ )
{
	const wxString valResult = this->validateInputFields();

	if ( valResult.size() == 0 )
	{
		this->EndModal( wxID_OK );
	}
	else
	{
		customMessageBox( SS_MAIN_ICON, valResult, _("Invalid input"), wxOK | wxICON_HAND  );
	}
}
Esempio n. 14
0
void settings_frame::handleExternExit()
{
	if ( !alreadyCalled){
		alreadyCalled = true;
		if (settingsChangedAbstract())
		{
			int choice = customMessageBox(SS_MAIN_ICON,_("Save Spring settings before exiting?"), _("Confirmation needed"), wxYES|wxNO |wxICON_QUESTION);
			if ( choice == wxYES)
			{
				saveSettingsAbstract();
				if (simpleTab!=0)
					simpleTab->saveCbxChoices();
			}
		}
	}

	sett().SaveSettings();
}
Esempio n. 15
0
//TODO inquire about floatsettings
bool abstract_panel::saveSettings()
{
	try {
		for (intMap::const_iterator i = intSettings.begin(); i != intSettings.end(); ++i) {
			LSL::usync().SetSpringConfigInt(STD_STRING(i->first), i->second);
		}
		for (stringMap::const_iterator s = stringSettings.begin(); s != stringSettings.end(); ++s) {
			LSL::usync().SetSpringConfigString(STD_STRING(s->first), STD_STRING(s->second));
		}
		for (floatMap::const_iterator f = floatSettings.begin(); f != floatSettings.end(); ++f) {
			LSL::usync().SetSpringConfigFloat(STD_STRING(f->first), f->second);
		}
	} catch (...) {
		customMessageBox(SS_MAIN_ICON, _("Could not save, unitsync not properly loaded"), _("SpringSettings Error"), wxOK | wxICON_HAND, 0);
		return false;
	}

	return true;
}
Esempio n. 16
0
void SpringOptionsTab::OnApply( wxCommandEvent& /*unused*/ )
{
	sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), m_exec_edit->GetValue() );
	sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), m_sync_edit->GetValue() );
	sett().SetSearchSpringOnlyInSLPath( m_dontsearch_chkbox->IsChecked() );
	sett().SetOldSpringLaunchMethod( m_oldlaunch_chkbox->IsChecked() );

	if ( sett().IsFirstRun() ) return;

	UiEvents::ScopedStatusMessage( _("Reloading unitsync"), 0 );
	sett().RefreshSpringVersionList();
	if ( !usync().LoadUnitSyncLib( sett().GetCurrentUsedUnitSync() ) )
	{
		wxLogWarning( _T( "Cannot load UnitSync" ) );
		customMessageBox( SL_MAIN_ICON,
						  IdentityString( _( "%s is unable to load your UnitSync library.\n\nYou might want to take another look at your unitsync setting." ) ),
		                  _( "Spring error" ), wxOK );
	}
}
Esempio n. 17
0
//TODO inquire about floatsettings
bool abstract_panel::saveSettings() {
	try {
		for (intMap::const_iterator i = intSettings.begin(); i != intSettings.end();++i)
		{
			configHandler.SetSpringConfigInt(i->first,i->second);
		}
//		for (stringMap::const_iterator s = stringSettings.begin(); s != stringSettings.end();++s)
//		{
//			//not used
//			//configHandler.SetSpringConfigString(s->first,s->second);
//		}
		for (floatMap::const_iterator f = floatSettings.begin(); f != floatSettings.end();++f)
		{
			configHandler.SetSpringConfigFloat(f->first,f->second);
		}
	} catch (...) {
		customMessageBox(SS_MAIN_ICON,_("Could not save, unitsync not properly loaded"), _("SpringSettings Error"), wxOK|wxICON_HAND, 0);
		return false;
	}
	return true;
}
Esempio n. 18
0
void AddBotDialog::ReloadAIList()
{
	try {
		m_ais = lslTowxArrayString(LSL::usync().GetAIList(m_battle.GetHostGameName()));
	} catch (...) {
	}

	m_ai->Clear();
	for (unsigned int i = 0; i < m_ais.GetCount(); i++)
		m_ai->Append(RefineAIName(m_ais[i]));
	if (m_ais.GetCount() > 0) {
		m_ai->SetStringSelection(sett().GetLastAI());
		if (m_ai->GetStringSelection() == wxEmptyString)
			m_ai->SetSelection(0);
	} else {
		customMessageBox(SL_MAIN_ICON, _("No AI bots found in your Spring installation."), _("No bot-libs found"), wxOK);
	}
	m_add_btn->Enable(m_ai->GetStringSelection() != wxEmptyString);
	ShowAIInfo();
	ShowAIOptions();
}
Esempio n. 19
0
bool UpdaterClass::StartUpdate( const wxString& latestVersion, const wxString& exe_to_update )
{
    wxString sep = wxFileName::GetPathSeparator();
    m_latest_version = latestVersion;
    m_currentexe = exe_to_update;
    if ( !wxFileName::IsDirWritable( wxPathOnly( m_currentexe ) ) ) {
        wxLogError( _T("dir not writable: ") + m_currentexe );
        customMessageBox(SL_MAIN_ICON, _("Unable to write to the lobby installation directory.\nPlease update manually or enable write permissions for the current user."), _("Error"));
        return false;
    }
    m_newexe = sett().GetLobbyWriteDir() + _T("update") + sep;
    wxLogError( m_newexe  );
    if ( !wxDirExists( m_newexe ) ) {
        if ( !wxMkdir( m_newexe ) ){
            wxLogError( _T("couldn't create update directory") );
            return false;
        }
    }

    m_http_thread = new HttpDownloaderThread<UpdaterClass>( GetDownloadUrl( m_latest_version ), m_newexe + _T("temp.zip"), *this, wxNewId(), true, true );

    //could prolly use some test on the thread here instead
    return true;
}
Esempio n. 20
0
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();
	}
}
Esempio n. 21
0
void ConnectWindow::OnOk(wxCommandEvent& )
{
    Hide();
    wxString HostAddress = m_server_combo->GetValue();
    if ( HostAddress.Find( _T(":") ) == wxNOT_FOUND )
		{
			if ( !sett().ServerExists( HostAddress ) )
			{
				HostAddress += wxFormat(_T(":%d") ) % DEFSETT_DEFAULT_SERVER_PORT;
			}
		}
    if ( m_tabs->GetSelection() <= 0 )
    {
        sett().SetServerAccountNick( HostAddress,m_nick_text->GetValue() );
        sett().SetServerAccountSavePass( HostAddress, m_rpass_check->GetValue() );

        // We assume that the server is given as : "host:port" so we split based on ":"
        wxArrayString serverString = wxStringTokenize( HostAddress ,_T(":") );
        if ( serverString.GetCount() == 2 )
        {
            long port;
            if ( !serverString[1].ToLong( &port ) )
            {
                wxLogWarning( _T("Invalid port.") );
                customMessageBox(SL_MAIN_ICON, _("Invalid port."), _("Invalid port"), wxOK );
                return;
            }
            if ( port < 1 || port > 65535)
            {
                wxLogWarning( _T("port number out of range") );
                customMessageBox(SL_MAIN_ICON, _("Port number out of range.\n\nIt must be an integer between 1 and 65535"), _("Invalid port"), wxOK );
                return;
            }
            sett().SetServer( HostAddress, serverString[0], port );
        }

        if ( serverString.GetCount() > 2 )
        {
            wxLogWarning( _T("invalid host/port.") );
            customMessageBox(SL_MAIN_ICON, _("Invalid host/port."), _("Invalid host"), wxOK );
            return;
        }
        sett().SetAutoConnect( m_autoconnect_check->IsChecked() );

        //if autoconnect enabled force saving of pw, actual saving is done in Ui::DoConnect
        if ( m_autoconnect_check->IsChecked() ) sett().SetServerAccountSavePass( HostAddress, true );

        sett().SaveSettings();
        ReloadServerList();

        m_ui.DoConnect( HostAddress, m_nick_text->GetValue(), m_pass_text->GetValue() );
    }
    else
    {
        wxString reason;
        if ( !IsValidNickname( m_regnick_text->GetValue() ) )
        {
            customMessageBox(SL_MAIN_ICON,_("The entered nickname contains invalid characters like )? &%.\n Please try again") , _("Invalid nickname"), wxOK );
            Show();
        }
        else if ( m_regpass2_text->GetValue()!= m_regpass1_text->GetValue() || m_regpass1_text->GetValue().IsEmpty() )
        {
            Show();
            wxLogWarning( _T("registration failed, reason: password/confirmation mismatch")  );
            customMessageBox(SL_MAIN_ICON,_("Registration failed, the reason was:\nPassword / confirmation mismatch (or empty passwort)") , _("Registration failed."), wxOK );
        }
        else if ( m_ui.DoRegister( HostAddress, m_regnick_text->GetValue(), m_regpass1_text->GetValue(),reason ) )
        {
            m_tabs->SetSelection( 0 );
            m_nick_text->SetValue(m_regnick_text->GetValue());
            m_pass_text->SetValue(m_regpass1_text->GetValue());
            Show();
        }
        else
        {
            Show();
        }

    }
}
Esempio n. 22
0
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();
			}

  }
}
Esempio n. 23
0
void settings_frame::OnMenuChoice(wxCommandEvent& event)
{
	switch (event.GetId()) {
		case ID_MENUITEM_SAVE:
			if (saveSettingsAbstract())
				(abstract_panel::settingsChanged) = false;
			if (simpleTab != 0)
				simpleTab->saveCbxChoices();
			break;

		case ID_MENUITEM_QUIT:
			handleExit();
			break;

		case ID_MENUITEM_RESET:
			if ((customMessageBox(SS_MAIN_ICON, _("Reset ALL settings to default values?"), _("Confirmation needed"), wxYES_NO | wxCANCEL)) == wxYES) {
				resetSettings();
			}
			break;

		case ID_MENUITEM_SIMPLE:
			if (sett().getMode() == SET_MODE_EXPERT) {
				sett().setMode(SET_MODE_SIMPLE);

				simpleTab = new tab_simple(this, notebook, ID_SIMPLE);
				notebook->InsertPage(0, simpleTab, simpleTabCap);
				simpleTab->updateControls(UPDATE_ALL);

				//if not on ui page goto simple
				if (notebook->GetSelection() != 1) {
					notebook->SetSelection(0);
				}
				for (int i = notebook->GetPageCount() - 1; i > 1; i--) { //delete all pages expect page 0 + 1
					notebook->DeletePage(i);
				}
				qualityTab = 0;
				detailTab = 0;
				audioTab = 0;
				//				hotkeyTab = 0;
				SetTitle(TowxString(getSpringlobbyName()) + _("(simple mode)"));
				if (!sett().getDisableWarning()) {
					customMessageBox(SS_MAIN_ICON, expertModeWarning, _("Hint"), wxOK);
				}
			}
			break;

		case ID_MENUITEM_EXPERT:
			if (sett().getMode() == SET_MODE_SIMPLE) {
				switchToExpertMode();
			}
			break;
		case ID_MENUITEM_DISABLE_WARN:
			sett().setDisableWarning(menuFile->IsChecked(ID_MENUITEM_DISABLE_WARN));
			break;

		case ID_MENUITEM_ABOUT:
			aboutbox().Show();
			break;
		case ID_MENUITEM_CONTACT:
			aboutbox().openContactPage();
			break;
		case ID_MENUITEM_BUGREPORT:
			aboutbox().openNewTicket();
			break;
	}
}
Esempio n. 24
0
void PlaybackTab<PlaybackTraits>::AskForceWatch( typename PlaybackTab<PlaybackTraits>::PlaybackType& rep ) const
{
	if ( customMessageBox( SL_MAIN_ICON, _( "I don't think you will be able to watch this replay.\nTry anyways? (MIGHT CRASH!)" ) , _( "Invalid replay" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
		rep.battle.StartSpring();
	}
}
Esempio n. 25
0
void PlaybackTab<PlaybackTraits>::OnWatch( wxCommandEvent& /*unused*/ )
{
	if ( m_replay_listctrl->GetSelectedIndex() != -1 ) {
		int m_sel_replay_id = m_replay_listctrl->GetSelectedData()->id;

		wxString type = PlaybackTraits::IsReplayType ? _( "replay" ) : _( "savegame" ) ;
		wxLogMessage( _T( "Watching %s %d " ), type.c_str(), m_sel_replay_id );
		try {
			PlaybackType& rep = playbacklist<ListType>().GetPlaybackById( m_sel_replay_id );

			std::map<wxString, wxString> versionlist = sett().GetSpringVersionList();
			if ( versionlist.size() == 0 ) {
				wxLogWarning( _T( "can't get spring version from any unitsync" ) );
				customMessageBox( SL_MAIN_ICON,  _( "Couldn't get your spring versions from any unitsync library." ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				AskForceWatch( rep );
				return;
			}
			bool versionfound = false;
			for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) {
				if ( itor->second == rep.SpringVersion ) {
					if ( sett().GetCurrentUsedSpringIndex() != itor->first ) {
						wxLogMessage( _T( "%s requires version: %s, switching to profile: %s" ), type.c_str(), rep.SpringVersion.c_str(), itor->first.c_str() );
						sett().SetUsedSpringIndex( itor->first );
						usync().AddReloadEvent(); // request an unitsync reload
					}
					versionfound = true;
				}
			}
			if ( !ReplayTraits::IsReplayType )
                versionfound = true; // quick hack to bypass spring version check
			if ( !versionfound ) {
				wxString message = wxString::Format( _( "No compatible installed spring version has been found, this %s requires version: %s\n" ), type.c_str(), rep.SpringVersion.c_str() );
				message << _( "Your current installed versions are:" );
				for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) message << _T( " " ) << itor->second;
				customMessageBox( SL_MAIN_ICON, message, _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				wxLogWarning ( _T( "no spring version supported by this replay found" ) );
				AskForceWatch( rep );
				return;
			}
			rep.battle.GetMe().SetNick( usync().GetDefaultNick() );
			bool watchable = rep.battle.MapExists() && rep.battle.ModExists();
			if ( watchable )
				rep.battle.StartSpring();
			else {
#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

				OfflineBattle& battle = rep.battle;

				if ( !battle.ModExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the game before you can watch this replay.\n\n" ) + downloadProc, _( "Game not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString modhash = battle.GetHostModHash();
						wxString modname = battle.GetHostModName();
						ui().DownloadMod ( modhash, modname );
					}
					else {
						AskForceWatch( rep );
					}
					return;
				}

				if ( !battle.MapExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( " I couldn't find the map to be able to watch this replay\nThis can be caused by tasclient writing broken map hash value\nIf you're sure you have the map, press no\nYou need to download the map to be able to watch this replay.\n\n" ) + downloadProc, _( "Map not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString maphash = battle.GetHostMapHash();
						wxString mapname = battle.GetHostMapName();
						ui().DownloadMap ( maphash, mapname );
					}
					else {
						AskForceWatch( rep );
					}
				}
			}
		} catch ( std::runtime_error ) {
			return;
		}
	} else {
		Deselected();
	}
}
Esempio n. 26
0
void settings_frame::OnMenuChoice(wxCommandEvent& event) {
	switch (event.GetId()) {
		case ID_MENUITEM_SAVE:
			if (abstract_panel::saveSettings())
			 (abstract_panel::settingsChanged) = false;
			if (simpleTab!=0)
        			simpleTab->saveCbxChoices();
		 break;

		case ID_MENUITEM_QUIT:
				handleExit();
		 break;

		case ID_MENUITEM_RESET:
			if ((customMessageBox(SS_MAIN_ICON,_("Reset ALL settings to default values?"), _("Confirmation needed"), wxYES_NO)) == wxYES) {
						resetSettings();
			}
		 break;

		case ID_MENUITEM_SIMPLE:
			if (sett().getMode()==SET_MODE_EXPERT)
				sett().setMode(SET_MODE_SIMPLE);

				simpleTab = new tab_simple(this,notebook,ID_SIMPLE);
				notebook->InsertPage(0,simpleTab,simpleTabCap);
				simpleTab->updateControls(UPDATE_ALL);

				//if not on ui page goto simple
				if (notebook->GetSelection()!=1)
					notebook->SetSelection(0);

				notebook->DeletePage(4);
				notebook->DeletePage(3);
				notebook->DeletePage(2);
				qualityTab = 0;
				detailTab = 0;
				audioTab = 0;

				SetTitle(_("SpringSettings (simple mode)"));
				if (!sett().getDisableWarning()){
					customMessageBox(SS_MAIN_ICON,expertModeWarning, _("Hint"), wxOK);
				}
		  break;

		case ID_MENUITEM_EXPERT:
			if (sett().getMode()==SET_MODE_SIMPLE) {
				switchToExpertMode();
			}
			break;
		case ID_MENUITEM_DISABLE_WARN:
			sett().setDisableWarning(menuFile->IsChecked(ID_MENUITEM_DISABLE_WARN));
			break;

		case ID_MENUITEM_ABOUT:
			showAbout();
			break;
		case ID_MENUITEM_CREDITS:
			showCredits();
			break;
		case ID_MENUITEM_CONTACT:
			openContactPage();
			break;
		case ID_MENUITEM_BUGREPORT:
			openNewTicket();
			break;
	}
}
//! @brief Initializes the application.
//!
//! It will open the main window and connect default to server or open the connect window.
bool SpringLobbyApp::OnInit()
{
	wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") );
    //this triggers the Cli Parser amongst other stuff
    if (!wxApp::OnInit())
		return false;
	SetAppName( m_appname );

    if (!m_crash_handle_disable) {
    #if wxUSE_ON_FATAL_EXCEPTION
        wxHandleFatalExceptions( true );
    #endif
    #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT)
        //this undocumented function acts as a workaround for the dysfunctional
        // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler )
        SetUnhandledExceptionFilter(filter);
    #endif
    }

    //initialize all loggers, we'll use the returned pointer to set correct parent window later
    wxLogChain* logchain = 0;
	wxLogWindow *loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, !m_crash_handle_disable, m_log_verbosity, logchain );

    //this needs to called _before_ mainwindow instance is created
    wxInitAllImageHandlers();
    wxFileSystem::AddHandler(new wxZipFSHandler);
    wxSocketBase::Initialize();


#ifdef __WXMSW__
    wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale");
#else
	#if defined(LOCALE_INSTALL_DIR)
		wxString path ( _T(LOCALE_INSTALL_DIR) );
	#else
		// use a dummy name here, we're only interested in the base path
		wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages);
		path = path.Left( path.First(_T("noneWH") ) );
	#endif
#endif
    m_translationhelper = new wxTranslationHelper( *( (wxApp*)this ), path );
    m_translationhelper->Load();

	if ( !wxDirExists( GetConfigfileDir() ) )
		wxMkdir( GetConfigfileDir() );

#ifdef __WXMSW__
	sett().SetSearchSpringOnlyInSLPath( sett().GetSearchSpringOnlyInSLPath() );
#endif
	sett().SetSpringBinary( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedSpringBinary() );
	sett().SetUnitSync( sett().GetCurrentUsedSpringIndex(), sett().GetCurrentUsedUnitSync() );

	if ( sett().DoResetPerspectives() )
	{
		//we do this early on and reset the config var a little later so we can save a def. perps once mw is created
		sett().RemoveLayouts();
		sett().SetDoResetPerspectives( false );
		ui().mw().SavePerspectives( _T("SpringLobby-default") );
	}

	sett().RefreshSpringVersionList();

	//this should take off the firstload time considerably *ie nil it :P )
	mapSelectDialog();
	if ( !m_customizer_archive_name.IsEmpty() )
	{//this needsto happen before usync load
		sett().SetForcedSpringConfigFilePath( GetCustomizedEngineConfigFilePath() );
	}
	//unitsync first load, NEEDS to be blocking
	const bool usync_loaded = usync().ReloadUnitSyncLib();
	if ( !sett().IsFirstRun() && !usync_loaded )
	{
		customMessageBox( SL_MAIN_ICON, _("Please check that the file given in Preferences->Spring is a proper, readable unitsync library"),
						 _("Coulnd't load required unitsync library"), wxOK );
	}

	#ifndef DISABLE_SOUND
		//sound sources/buffer init
		sound();
	#endif


	CacheAndSettingsSetup();

	if ( !m_customizer_archive_name.IsEmpty() ) {
		if ( SLcustomizations().Init( m_customizer_archive_name ) ) {
			ui().mw().SetIcons( SLcustomizations().GetAppIconBundle() );
		}
		else {
			customMessageBox( SL_MAIN_ICON, _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error"), wxOK );
//            wxLogError( _("Couldn't load customizations for ") + m_customizer_archive_name + _("\nPlease check that that is the correct name, passed in qoutation"), _("Fatal error") );
			exit( OnExit() );//for some twisted reason returning false here does not terminate the app
		}
	}

	notificationManager(); //needs to be initialized too
    ui().ShowMainWindow();
    SetTopWindow( &ui().mw() );
	if ( sett().DoResetPerspectives() )
	{
		//now that mainwindow is shown, we can save what is the default layout and remove the flag to reset
		sett().SetDoResetPerspectives( false );
		ui().mw().SavePerspectives( _T("SpringLobby-default") );
	}

	//interim fix for resize crashes on metacity and kwin
	#ifdef __WXMSW__
		mapSelectDialog().Reparent( &ui().mw() );
	#endif

    ui().FirstRunWelcome();
    m_timer->Start( TIMER_INTERVAL );

    ui().mw().SetLogWin( loggerwin, logchain );

#ifndef NO_TORRENT_SYSTEM
    plasmaInterface();
//    plasmaInterface().InitResourceList();
//	plasmaInterface().FetchResourceList();
#endif


    return true;
}