Sky Zone Omega - PC Version
 All Classes Namespaces Files Functions Variables Macros
C_Text.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <SDL_ttf.h>
5 #include <iostream>
6 #include <string>
7 #include "C_Vec2.h"
8 
13 class C_Text
14 {
15 public:
22  C_Text(std::string text, std::string fontLocation, SDL_Renderer* renderer);
23 
31  C_Text(std::string text, std::string fontLocation, int fontSize, SDL_Renderer* renderer);
32 
42  C_Text(std::string text, std::string fontLocation, SDL_Renderer* renderer, int r, int g, int b);
43 
51  C_Text(std::string text, std::string fontLocation, SDL_Renderer* renderer, SDL_Colour fontColour);
52 
63  C_Text(std::string text, std::string fontLocation, int fontSize, SDL_Renderer* renderer, int r, int g, int b);
64 
73  C_Text(std::string text, std::string fontLocation, int fontSize, SDL_Renderer* renderer, SDL_Colour fontColour);
74 
78  ~C_Text();
79 
84  void pushToScreen(C_Vec2 pos);
85 
92  void setColour(int r, int g, int b);
93 
98  void setColour(SDL_Colour colour);
99 
104  void setFontSize(int fontSize);
105 
110  void setFont(std::string fontLocation);
111 
116  void setText(std::string text);
117 
123 
124 private:
126  TTF_Font* font;
128  SDL_Colour fontColour;
130  SDL_Texture* textureData;
132  SDL_Renderer* renderer;
134  int fontSize;
136  std::string text, fontLocation;
139 
143  void createTextTexture();
144 };
void setFont(std::string fontLocation)
Sets the font of the text.
Definition: C_Text.cpp:146
Creates a Text Texture for use with a renderer using the Text formating.
Definition: C_Text.h:13
void setFontSize(int fontSize)
Sets the font size of the text.
Definition: C_Text.cpp:128
C_Vec2 dimensions
The Texture dimensions.
Definition: C_Text.h:138
Contains the Vec2 structure with functions and overloaded operators.
Definition: C_Vec2.h:7
std::string fontLocation
Definition: C_Text.h:136
~C_Text()
Destructs the Text Texture.
Definition: C_Text.cpp:82
C_Vec2 getDimensions()
Gets the dimensions of the Text Texture.
Definition: C_Text.cpp:173
TTF_Font * font
Font.
Definition: C_Text.h:126
void pushToScreen(C_Vec2 pos)
Pushes the Text Texture to the Renderer to the XY Coordinates.
Definition: C_Text.cpp:91
int fontSize
Font size.
Definition: C_Text.h:134
void setColour(int r, int g, int b)
Sets the colour of the text.
Definition: C_Text.cpp:104
void createTextTexture()
Creates a Text Texture using the Text data.
Definition: C_Text.cpp:178
SDL_Colour fontColour
Font colour.
Definition: C_Text.h:128
SDL_Renderer * renderer
A pointer to the render.
Definition: C_Text.h:132
C_Text(std::string text, std::string fontLocation, SDL_Renderer *renderer)
Constructs the Text Texture. Font size and colour will be default (size 10 and black).
Definition: C_Text.cpp:3
SDL_Texture * textureData
The Texture data.
Definition: C_Text.h:130
void setText(std::string text)
Sets the text.
Definition: C_Text.cpp:161
std::string text
The text and font location.
Definition: C_Text.h:136