Beispiel #1
0
void WeatherFaxWizard::OnWizardPageChanged( wxWizardEvent& event )
{
    if(event.GetPage() == m_pages[1]) {
        if(!event.GetDirection()) {
            /* if we backed up, convert the mapped coordinates back to the input */
            double x1, y1, mx1, my1;
            double x2, y2, mx2, my2;

            x1 = m_sCoord1X->GetValue(), y1 = m_sCoord1Y->GetValue();
            x2 = m_sCoord2X->GetValue(), y2 = m_sCoord2Y->GetValue();

            m_wfimg.MercatorToInput(x1, y1, mx1, my1);
            m_sCoord1XUnMapped->SetValue(round(mx1));
            m_sCoord1YUnMapped->SetValue(round(my1));

            m_wfimg.MercatorToInput(x2, y2, mx2, my2);
            m_sCoord2XUnMapped->SetValue(round(mx2));
            m_sCoord2YUnMapped->SetValue(round(my2));
    
            double coord1lat, coord1lon, coord2lat, coord2lon;
            m_tCoord1Lat->GetValue().ToDouble(&coord1lat);
            m_tCoord1Lon->GetValue().ToDouble(&coord1lon);
            m_tCoord2Lat->GetValue().ToDouble(&coord2lat);
            m_tCoord2Lon->GetValue().ToDouble(&coord2lon);
            WriteMappingLatLon(coord1lat, coord1lon, coord2lat, coord2lon);
        }

        SetUnMappedCoordRanges();
        UpdateMappingControls();

        m_rbCoord1UnMapped->SetValue(true);
        m_rbCoord2UnMapped->SetValue(false);
    } else if(event.GetPage() == m_pages[2]) {
        StoreMappingParams();
        /* invalidate mapped image */
        m_wfimg.m_mappedimg = wxNullImage;
        m_rbCoord1UnMapped->SetValue(true);
        m_rbCoord2UnMapped->SetValue(false);

        if(!ApplyMapping()) {
            wxMessageDialog w
                ( this, _("Failed to apply mapping\nCheck Mapping Correction Parameters"),
                  _("Mapping"), wxOK | wxICON_ERROR );
            w.ShowModal();
            ShowPage(m_pages[1], true);
        } else if(m_curCoords->mapping == WeatherFaxImageCoordinates::MERCATOR &&
                m_curCoords->mappingmultiplier == 1 &&
                  m_curCoords->mappingratio == 1) {
            wxWizardEvent dummy;
            OnWizardFinished( dummy );
            if(IsModal())
                EndModal(wxID_OK);
            else
                Hide();
        }
    }
}
Beispiel #2
0
void InputMapper::AutoMapJoysticksForCurrentGame()
{
	vector<InputDevice> vDevices;
	vector<CString> vDescriptions;
	INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);

	int iNumJoysticksMapped = 0;

	const Game* pGame = GAMESTATE->m_pCurGame;

	for( unsigned i=0; i<vDevices.size(); i++ )
	{
		InputDevice device = vDevices[i];
		CString sDescription = vDescriptions[i];
		for( unsigned j=0; j<ARRAYLEN(g_AutoJoyMappings); j++ )
		{
			const AutoJoyMapping& mapping = g_AutoJoyMappings[j];

			if( pGame != GAMEMAN->StringToGameType(mapping.szGame) )
				continue;	// games don't match

			CString sDriverRegex = mapping.szDriverRegex;
			Regex regex( sDriverRegex );
			if( !regex.Compare(sDescription) )
				continue;	// driver names don't match

			//
			// We have a mapping for this joystick
			//
			GameController gc = (GameController)iNumJoysticksMapped;
			if( gc >= GAME_CONTROLLER_INVALID )
				break;	// stop mapping.  We already mapped one device for each game controller.

			LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
				iNumJoysticksMapped+1, mapping.szDriverRegex, mapping.szControllerName );

			ApplyMapping( mapping.maps, gc, device );

			iNumJoysticksMapped++;
		}
	}
}