Walls And Holes  1
tiletemplate.h
Go to the documentation of this file.
1 #ifndef TILETEMPLATE_H
2 #define TILETEMPLATE_H
3 
4 #define MIN_TILE_THICKNESS 0.1
5 
6 #include <QSharedPointer>
7 #include <QObject>
8 #include <QVector2D>
9 #include <QColor>
10 
11 #include "tilematerial.h"
12 
13 class TileTemplate : public QObject
14 {
15  Q_OBJECT
16 
17 public:
18  explicit TileTemplate(QColor color = Qt::white,
19  QString name = "New Tile Template",
20  float height = 0,
21  float thickness = 1,
22  TileMaterial *topMaterial = nullptr,
23  QVector2D position = QVector2D(0.5, 0.5),
24  bool bridgeTiles = false,
25  bool connectDiagonals = false,
26  QObject *parent = nullptr);
27 
28 
29  void setHeight(float height);
30 
31  // TODO : Might be nice to pop up a message when the user tries to change the thickness or height,
32  // but it doesn't change because of the restraintes. The message would explain why, and how
33  // to make it change, and have a checkbox to not show up again?
34  // Maybe this could be implemented in a tutorial system?
35 
47  float setThickness(float thickness);
48 
60  QVector2D setPosition(QVector2D position);
61 
62  void setColor(QColor color);
63 
64  void setHasSideMaterial(bool enabled);
65 
70  void setTopMaterial(TileMaterial *material);
71 
76  void setSideMaterial(TileMaterial *material);
77 
78 
79  QString name() const { return mName; }
80  void setName(QString name) { mName = name; emit changed(); }
81 
82  float height() const { return mHeight; }
83  float thickness() const { return mThickness; }
84  QVector2D position() const { return mPosition; }
85 
86  QColor color() const { return mColor; }
87 
88  bool hasSideMaterial() { return mHasSideMaterial; }
89 
90  const TileMaterial *topMaterial() const { return mTopMaterial; }
91  TileMaterial *topMaterial() { return mTopMaterial; }
92 
93  const TileMaterial *sideMaterial() const { return mSideMaterial; }
94  TileMaterial *sideMaterial() { return mSideMaterial; }
95 
96  bool bridgeTiles() const { return mBridgeTiles; }
97  void setBridgeTiles(bool enabled);
98 
99  bool connectDiagonals() const { return mConnectDiagonals; }
100  void setConnectDiagonals(bool enabled);
101 
108  void emitTilePing() { emit pingTiles(); }
109 
110 signals:
111 
116  void thicknessChanged();
117  void positionChanged();
118  void materialChanged();
119 
123  void changed();
124 
125  void pingTiles();
126 
127 private:
128  QString mName;
129 
130  float mHeight;
131  float mThickness;
132  QVector2D mPosition;
133 
134  //The color the tile will be in the map view.
135  //Has no affect on evental output mesh
136  QColor mColor;
137 
138  bool mHasSideMaterial;
139  TileMaterial *mTopMaterial;
140  TileMaterial *mSideMaterial;
141 
142  bool mBridgeTiles;
143  bool mConnectDiagonals;
144 };
145 
146 #endif // TILETEMPLATE_H
TileMaterial * topMaterial()
Definition: tiletemplate.h:91
void exclusivePropertyChanged()
Emitted when a property is changed but does not affect mesh-related properties.
void setSideMaterial(TileMaterial *material)
Updates the side material for the tile template.
Definition: tiletemplate.cpp:145
void setTopMaterial(TileMaterial *material)
Updates the top material for the tile template.
Definition: tiletemplate.cpp:119
void setHasSideMaterial(bool enabled)
Definition: tiletemplate.cpp:109
void setColor(QColor color)
Definition: tiletemplate.cpp:101
void setHeight(float height)
Definition: tiletemplate.cpp:32
const TileMaterial * topMaterial() const
Definition: tiletemplate.h:90
TileMaterial * sideMaterial()
Definition: tiletemplate.h:94
float setThickness(float thickness)
setThickness
Definition: tiletemplate.cpp:42
void changed()
Emitted whenever something changes that needs to be saved.
void positionChanged()
float height() const
Definition: tiletemplate.h:82
void materialChanged()
bool connectDiagonals() const
Definition: tiletemplate.h:99
TileTemplate(QColor color=Qt::white, QString name="New Tile Template", float height=0, float thickness=1, TileMaterial *topMaterial=nullptr, QVector2D position=QVector2D(0.5, 0.5), bool bridgeTiles=false, bool connectDiagonals=false, QObject *parent=nullptr)
Definition: tiletemplate.cpp:6
void setBridgeTiles(bool enabled)
Definition: tiletemplate.cpp:171
QVector2D position() const
Definition: tiletemplate.h:84
bool hasSideMaterial()
Definition: tiletemplate.h:88
Definition: tiletemplate.h:13
QString name() const
Definition: tiletemplate.h:79
void setName(QString name)
Definition: tiletemplate.h:80
void setConnectDiagonals(bool enabled)
Definition: tiletemplate.cpp:181
bool bridgeTiles() const
Definition: tiletemplate.h:96
void thicknessChanged()
Definition: tilematerial.h:8
void pingTiles()
void emitTilePing()
emitTilePing Sends a signal to all tiles using this template, which will be forwarded to the containi...
Definition: tiletemplate.h:108
const TileMaterial * sideMaterial() const
Definition: tiletemplate.h:93
QColor color() const
Definition: tiletemplate.h:86
float thickness() const
Definition: tiletemplate.h:83
QVector2D setPosition(QVector2D position)
setPosition
Definition: tiletemplate.cpp:73