Add snap turn angle settings ui

This commit is contained in:
Kung-vr
2019-03-19 15:05:29 +09:00
parent bdf4227e5c
commit 510e3291f4
4 changed files with 150 additions and 4 deletions
+29 -2
View File
@@ -78,6 +78,11 @@ void MoveCenterTabController::initStage1()
{
m_turnComfortFactor = value.toUInt();
}
value = settings->value( "snapTurnAngle", m_snapTurnAngle );
if ( value.isValid() && !value.isNull() )
{
m_snapTurnAngle = value.toInt();
}
value = settings->value( "heightToggleOffset", m_heightToggleOffset );
if ( value.isValid() && !value.isNull() )
{
@@ -256,6 +261,28 @@ void MoveCenterTabController::setTempRotation( int value, bool notify )
}
}
int MoveCenterTabController::snapTurnAngle() const
{
return m_snapTurnAngle;
}
void MoveCenterTabController::setSnapTurnAngle( int value, bool notify )
{
if ( m_snapTurnAngle != value )
{
m_snapTurnAngle = value;
auto settings = OverlayController::appSettings();
settings->beginGroup( "playspaceSettings" );
settings->setValue( "snapTurnAngle", m_snapTurnAngle );
settings->endGroup();
settings->sync();
if ( notify )
{
emit snapTurnAngleChanged( m_snapTurnAngle );
}
}
}
bool MoveCenterTabController::adjustChaperone() const
{
return m_adjustChaperone;
@@ -1363,7 +1390,7 @@ void MoveCenterTabController::snapTurnLeft( bool snapTurnLeftJustPressed )
// TODO add interface to configure snap angle.
// temporarily hard coded to 45 degrees
int newRotationAngleDeg = m_rotation - 4500;
int newRotationAngleDeg = m_rotation - m_snapTurnAngle;
// Keep angle within -18000 ~ 18000 centidegrees
if ( newRotationAngleDeg > 18000 )
{
@@ -1386,7 +1413,7 @@ void MoveCenterTabController::snapTurnRight( bool snapTurnRightJustPressed )
// TODO add interface to configure snap angle.
// temporarily hard coded to 45 degrees
int newRotationAngleDeg = m_rotation + 4500;
int newRotationAngleDeg = m_rotation + m_snapTurnAngle;
// Keep angle within -18000 ~ 18000 centidegrees
if ( newRotationAngleDeg > 18000 )
{