qt: Add some more vector types to WzConfig
parent
dda501bf13
commit
c32d791ae0
|
@ -28,6 +28,7 @@
|
|||
#include "frame.h"
|
||||
#include "math_ext.h"
|
||||
|
||||
struct Rotation;
|
||||
struct Vector2i
|
||||
{
|
||||
Vector2i() {}
|
||||
|
@ -48,7 +49,7 @@ struct Vector3i
|
|||
Vector3i() {}
|
||||
Vector3i(int x, int y, int z) : x(x), y(y), z(z) {}
|
||||
Vector3i(Vector2i const &xy, int z) : x(xy.x), y(xy.y), z(z) {}
|
||||
|
||||
Vector3i(Rotation const &r);
|
||||
int x, y, z;
|
||||
};
|
||||
struct Vector3f
|
||||
|
@ -65,11 +66,13 @@ struct Rotation
|
|||
{
|
||||
Rotation() {}
|
||||
Rotation(int direction, int pitch, int roll) : direction(direction), pitch(pitch), roll(roll) {}
|
||||
|
||||
Rotation(Vector3i xyz) : direction(xyz.x), pitch(xyz.y), roll(xyz.z) {}
|
||||
uint16_t direction, pitch, roll; ///< Object rotation in 0..64k range
|
||||
};
|
||||
typedef Vector3i Position; ///< Map position in world coordinates
|
||||
|
||||
inline Vector3i::Vector3i(Rotation const &r) : x(r.direction), y(r.pitch), z(r.roll) {}
|
||||
|
||||
// removeZ(3d_vector) -> 2d_vector
|
||||
static inline WZ_DECL_PURE Vector2i removeZ(Vector3i const &a) { return Vector2i(a.x, a.y); }
|
||||
static inline WZ_DECL_PURE Vector2f removeZ(Vector3f const &a) { return Vector2f(a.x, a.y); }
|
||||
|
|
|
@ -1359,3 +1359,23 @@ Vector3i WzConfig::vector3i(const QString &name)
|
|||
r.z = v[2].toInt();
|
||||
return r;
|
||||
}
|
||||
|
||||
void WzConfig::setVector2i(const QString &name, const Vector2i &v)
|
||||
{
|
||||
QStringList l;
|
||||
l.push_back(QString::number(v.x));
|
||||
l.push_back(QString::number(v.y));
|
||||
setValue(name, l);
|
||||
}
|
||||
|
||||
Vector2i WzConfig::vector2i(const QString &name)
|
||||
{
|
||||
Vector2i r;
|
||||
ASSERT_OR_RETURN(r, contains(name), "Missing %s", name.toUtf8().constData());
|
||||
QList<QVariant> v = value(name).toList();
|
||||
ASSERT(v.size() == 2, "Bad list of %s", name.toUtf8().constData());
|
||||
r.x = v[0].toInt();
|
||||
r.y = v[1].toInt();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
void setVector3f(const QString &name, const Vector3f &v);
|
||||
Vector3i vector3i(const QString &name);
|
||||
void setVector3i(const QString &name, const Vector3i &v);
|
||||
Vector2i vector2i(const QString &name);
|
||||
void setVector2i(const QString &name, const Vector2i &v);
|
||||
};
|
||||
|
||||
class WzMainWindow : public QGLWidget
|
||||
|
|
Loading…
Reference in New Issue