namespace graphics {
-void Font::DrawChar(char c, SDL_Surface *dest, Point<int> position) const {
+void Font::DrawChar(char c, SDL_Surface *dest, const Point<int> &position) const {
int col(colOffset + (c % 0x10));
int row(rowOffset + (c / 0x10));
sprite->Draw(dest, position, col, row);
}
-void Font::DrawString(const char *s, SDL_Surface *dest, Point<int> positionIn, int maxChars) const {
+void Font::DrawString(const char *s, SDL_Surface *dest, const Point<int> &positionIn, int maxChars) const {
Point<int> position(positionIn);
Vector<int> step(CharWidth(), 0);
for (int i(0); s[i] && (maxChars <= 0 || i < maxChars); ++i, position += step) {
}
}
-void Font::DrawDigit(int digit, SDL_Surface *dest, Point<int> position) const {
+void Font::DrawDigit(int digit, SDL_Surface *dest, const Point<int> &position) const {
DrawChar(digit + 0x30, dest, position);
}
-void Font::DrawNumber(int numberIn, SDL_Surface *dest, Point<int> positionIn, int digits) const {
+void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Point<int> &positionIn, int digits) const {
int number(numberIn);
if (digits > 0 && numberIn >= pow(10.0, digits)) {
numberIn = pow(10.0, digits) - 1;
public:
int CharWidth() const { return sprite->Width(); }
int CharHeight() const { return sprite->Height(); }
- void DrawChar(char c, SDL_Surface *dest, geometry::Point<int> position) const;
- void DrawString(const char *s, SDL_Surface *dest, geometry::Point<int> position, int maxChars = 0) const;
- void DrawDigit(int d, SDL_Surface *dest, geometry::Point<int> position) const;
- void DrawNumber(int n, SDL_Surface *dest, geometry::Point<int> position, int digits = 0) const;
+ void DrawChar(char c, SDL_Surface *dest, const geometry::Point<int> &position) const;
+ void DrawString(const char *s, SDL_Surface *dest, const geometry::Point<int> &position, int maxChars = 0) const;
+ void DrawDigit(int d, SDL_Surface *dest, const geometry::Point<int> &position) const;
+ void DrawNumber(int n, SDL_Surface *dest, const geometry::Point<int> &position, int digits = 0) const;
private:
const Sprite *sprite;
namespace graphics {
// TODO: maybe create a cache for frames?
-void Frame::Draw(SDL_Surface *dest, Point<int> position, int width, int height) const {
+void Frame::Draw(SDL_Surface *dest, const Point<int> &position, int width, int height) const {
// top-left corner
SDL_Rect srcRect;
srcRect.x = xOffset;
int MinHeight() const { return 2 * borderHeight; }
int BorderWidth() const { return borderWidth; }
int BorderHeight() const { return borderHeight; }
- void Draw(SDL_Surface *dest, geometry::Point<int> position, int width, int height) const;
+ void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int width, int height) const;
private:
SDL_Surface *surface;
namespace graphics {
-void Gauge::Draw(SDL_Surface *dest, Point<int> position, int width, Uint8 fill) const {
+void Gauge::Draw(SDL_Surface *dest, const Point<int> &position, int width, Uint8 fill) const {
SDL_Rect srcRect, destRect;
int filledWidth = fill * (width - startWidth - endWidth) / 255;
public:
int MinWidth() const { return startWidth + endWidth; }
int Height() const { return height; }
- void Draw(SDL_Surface *dest, geometry::Point<int> position, int width, Uint8 fill) const;
+ void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int width, Uint8 fill) const;
private:
SDL_Surface *surface;
void Reserve(int n) { entries.reserve(n); }
void Clear() { entries.clear(); }
- void Draw(SDL_Surface *dest, geometry::Point<int> position) const;
+ void Draw(SDL_Surface *dest, const geometry::Point<int> &position) const;
private:
int GetRow(int index) const { return index / cols; }
template<class T>
-void Menu<T>::Draw(SDL_Surface *dest, geometry::Point<int> position) const {
+void Menu<T>::Draw(SDL_Surface *dest, const geometry::Point<int> &position) const {
int start(topRow * cols);
int slots(rows * cols);
int items(entries.size() - start);
namespace graphics {
-void Sprite::Draw(SDL_Surface *dest, Point<int> position, int col, int row) const {
+void Sprite::Draw(SDL_Surface *dest, const Point<int> &position, int col, int row) const {
SDL_Rect srcRect, destRect;
srcRect.x = xOffset + col * Width();
srcRect.y = yOffset + row * Height();
public:
int Width() const { return width; }
int Height() const { return height; }
- void Draw(SDL_Surface *dest, geometry::Point<int> position, int col = 0, int row = 0) const;
- void DrawTopRight(SDL_Surface *dest, geometry::Point<int> position, int col = 0, int row = 0) const {
+ void Draw(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const;
+ void DrawTopRight(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width(), 0);
Draw(dest, position + offset, col, row);
}
- void DrawCenter(SDL_Surface *dest, geometry::Point<int> position, int col = 0, int row = 0) const {
+ void DrawCenter(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width() / 2, -Height() / 2);
Draw(dest, position + offset, col, row);
}
- void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position, int col = 0, int row = 0) const {
+ void DrawCenterBottom(SDL_Surface *dest, const geometry::Point<int> &position, int col = 0, int row = 0) const {
geometry::Vector<int> offset(-Width() / 2, -Height());
Draw(dest, position + offset, col, row);
}