Add some depth to ProJoysticks
This commit is contained in:
@@ -699,9 +699,9 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center)
|
||||
{
|
||||
// Draw joysticks
|
||||
using namespace Settings::NativeAnalog;
|
||||
DrawProJoystick(p, center + QPointF(-111, -55) + (axis_values[LStick].value * 11),
|
||||
DrawProJoystick(p, center + QPointF(-111, -55), axis_values[LStick].value, 11,
|
||||
button_values[Settings::NativeButton::LStick]);
|
||||
DrawProJoystick(p, center + QPointF(51, 0) + (axis_values[RStick].value * 11),
|
||||
DrawProJoystick(p, center + QPointF(51, 0), axis_values[RStick].value, 11,
|
||||
button_values[Settings::NativeButton::RStick]);
|
||||
DrawRawJoystick(p, center + QPointF(-50, 105), axis_values[LStick].raw_value,
|
||||
axis_values[LStick].properties);
|
||||
@@ -2273,15 +2273,36 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente
|
||||
p.drawLine(p2.at(32), p2.at(71));
|
||||
}
|
||||
|
||||
void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, bool pressed) {
|
||||
void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, float scalar, bool pressed) {
|
||||
const float radius1 = 24.0f;
|
||||
const float radius2 = 17.0f;
|
||||
|
||||
const QPointF offsetCenter = center + offset * scalar;
|
||||
|
||||
const float amplitude = 1 - sqrt(pow(offset.x(), 2) + pow(offset.y(), 2)) * 0.1;
|
||||
const float rotation =
|
||||
((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4));
|
||||
|
||||
QPointF zeroPoint;
|
||||
|
||||
p.save();
|
||||
p.translate(offsetCenter);
|
||||
p.rotate(rotation);
|
||||
|
||||
// Outer circle
|
||||
p.setPen(colors.outline);
|
||||
p.setBrush(pressed ? colors.highlight : colors.button);
|
||||
DrawCircle(p, center, 24.0f);
|
||||
p.drawEllipse(zeroPoint, radius1 * amplitude, radius1);
|
||||
|
||||
// Inner circle
|
||||
p.setBrush(pressed ? colors.highlight2 : colors.button2);
|
||||
DrawCircle(p, center, 17.0f);
|
||||
p.drawEllipse(
|
||||
zeroPoint +
|
||||
QPointF((offset.x() < 0) ? (radius1 - radius2) * -0.4 : (radius1 - radius2) * 0.4, 0) *
|
||||
((1 - amplitude) / 0.1),
|
||||
radius2 * amplitude, radius2);
|
||||
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) {
|
||||
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed);
|
||||
void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value,
|
||||
const Input::AnalogProperties properties);
|
||||
void DrawProJoystick(QPainter& p, QPointF center, bool pressed);
|
||||
void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed);
|
||||
void DrawGCJoystick(QPainter& p, QPointF center, bool pressed);
|
||||
|
||||
// Draw button functions
|
||||
|
||||
Reference in New Issue
Block a user