mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 22:49:00 +01:00
DolphinQt: Clean up calibration drawing a bit.
This commit is contained in:
parent
ed24f32c5b
commit
2c843ae06b
@ -149,7 +149,7 @@ constexpr int SPHERE_POINT_COUNT = 200;
|
|||||||
|
|
||||||
// Constructs a polygon by querying a radius at varying angles:
|
// Constructs a polygon by querying a radius at varying angles:
|
||||||
template <typename F>
|
template <typename F>
|
||||||
QPolygonF GetPolygonFromRadiusGetter(F&& radius_getter, Common::DVec2 center = {0.0, 0.0})
|
QPolygonF GetPolygonFromRadiusGetter(F&& radius_getter)
|
||||||
{
|
{
|
||||||
// A multiple of 8 (octagon) and enough points to be visibly pleasing:
|
// A multiple of 8 (octagon) and enough points to be visibly pleasing:
|
||||||
constexpr int shape_point_count = 32;
|
constexpr int shape_point_count = 32;
|
||||||
@ -161,7 +161,7 @@ QPolygonF GetPolygonFromRadiusGetter(F&& radius_getter, Common::DVec2 center = {
|
|||||||
const double angle = MathUtil::TAU * p / shape.size();
|
const double angle = MathUtil::TAU * p / shape.size();
|
||||||
const double radius = radius_getter(angle);
|
const double radius = radius_getter(angle);
|
||||||
|
|
||||||
point = {std::cos(angle) * radius + center.x, std::sin(angle) * radius + center.y};
|
point = {std::cos(angle) * radius, std::sin(angle) * radius};
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,25 +302,30 @@ void ReshapableInputIndicator::DrawReshapableInput(
|
|||||||
|
|
||||||
const auto center = stick.GetCenter();
|
const auto center = stick.GetCenter();
|
||||||
|
|
||||||
|
p.save();
|
||||||
|
p.translate(center.x, center.y);
|
||||||
|
|
||||||
// Deadzone.
|
// Deadzone.
|
||||||
p.setPen(GetDeadZonePen());
|
p.setPen(GetDeadZonePen());
|
||||||
p.setBrush(GetDeadZoneBrush(p));
|
p.setBrush(GetDeadZoneBrush(p));
|
||||||
p.drawPolygon(GetPolygonFromRadiusGetter(
|
p.drawPolygon(GetPolygonFromRadiusGetter(
|
||||||
[&stick](double ang) { return stick.GetDeadzoneRadiusAtAngle(ang); }, center));
|
[&stick](double ang) { return stick.GetDeadzoneRadiusAtAngle(ang); }));
|
||||||
|
|
||||||
// Input shape.
|
// Input shape.
|
||||||
p.setPen(GetInputShapePen());
|
p.setPen(GetInputShapePen());
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.drawPolygon(GetPolygonFromRadiusGetter(
|
p.drawPolygon(GetPolygonFromRadiusGetter(
|
||||||
[&stick](double ang) { return stick.GetInputRadiusAtAngle(ang); }, center));
|
[&stick](double ang) { return stick.GetInputRadiusAtAngle(ang); }));
|
||||||
|
|
||||||
// Center.
|
// Center.
|
||||||
if (center.x || center.y)
|
if (center.x || center.y)
|
||||||
{
|
{
|
||||||
p.setPen(GetInputDotPen(GetCenterColor()));
|
p.setPen(GetInputDotPen(GetCenterColor()));
|
||||||
p.drawPoint(QPointF{center.x, center.y});
|
p.drawPoint(QPointF{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.restore();
|
||||||
|
|
||||||
// Raw stick position.
|
// Raw stick position.
|
||||||
p.setPen(GetInputDotPen(GetRawInputColor()));
|
p.setPen(GetInputDotPen(GetRawInputColor()));
|
||||||
p.drawPoint(QPointF{raw_coord.x, raw_coord.y});
|
p.drawPoint(QPointF{raw_coord.x, raw_coord.y});
|
||||||
@ -745,23 +750,26 @@ void GyroMappingIndicator::Draw()
|
|||||||
|
|
||||||
void ReshapableInputIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
|
void ReshapableInputIndicator::DrawCalibration(QPainter& p, Common::DVec2 point)
|
||||||
{
|
{
|
||||||
// Bounding box size:
|
|
||||||
const auto center = m_calibration_widget->GetCenter();
|
const auto center = m_calibration_widget->GetCenter();
|
||||||
|
|
||||||
|
p.save();
|
||||||
|
p.translate(center.x, center.y);
|
||||||
|
|
||||||
// Input shape.
|
// Input shape.
|
||||||
p.setPen(GetInputShapePen());
|
p.setPen(GetInputShapePen());
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.drawPolygon(GetPolygonFromRadiusGetter(
|
p.drawPolygon(GetPolygonFromRadiusGetter(
|
||||||
[this](double angle) { return m_calibration_widget->GetCalibrationRadiusAtAngle(angle); },
|
[this](double angle) { return m_calibration_widget->GetCalibrationRadiusAtAngle(angle); }));
|
||||||
center));
|
|
||||||
|
|
||||||
// Center.
|
// Center.
|
||||||
if (center.x || center.y)
|
if (center.x || center.y)
|
||||||
{
|
{
|
||||||
p.setPen(GetInputDotPen(GetCenterColor()));
|
p.setPen(GetInputDotPen(GetCenterColor()));
|
||||||
p.drawPoint(QPointF{center.x, center.y});
|
p.drawPoint(QPointF{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.restore();
|
||||||
|
|
||||||
// Stick position.
|
// Stick position.
|
||||||
p.setPen(GetInputDotPen(GetAdjustedInputColor()));
|
p.setPen(GetInputDotPen(GetAdjustedInputColor()));
|
||||||
p.drawPoint(QPointF{point.x, point.y});
|
p.drawPoint(QPointF{point.x, point.y});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user