1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#ifndef SLD_CONSOLE_H
#define SDL_CONSOLE_H
#include "Ltimer.h"
#include "ConsoleSettings.h"
#undef main;
using namespace std;
enum ConsoleState { blank, input };
class SDL_Console
{
private:
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *backgroundTexture = NULL;
SDL_Texture *consoleOverlayTexture = NULL;
SDL_Texture *consoleCursorTexture = NULL;
SDL_Texture *consoleNoCursorTexture = NULL;
SDL_Rect backGroundTextureRect = { 0, 0, GlobalConsoleSettings::WIN_W, GlobalConsoleSettings::WIN_H };
SDL_Rect consoleOverlayTextureRect = { 0, 0, GlobalConsoleSettings::WIN_W, GlobalConsoleSettings::WIN_H };
SDL_Rect consoleCursorTextureRect = { 0, 0, GlobalConsoleSettings::CURSOR_W, GlobalConsoleSettings::CURSOR_H };
SDL_Rect consoleNoCursorTextureRect = { 0, 0, GlobalConsoleSettings::CURSOR_W, GlobalConsoleSettings::CURSOR_H };
ConsoleState stateOfConsole;
bool consoleIsRunning;
bool cursorShown;
TTF_Font *consoleFont = NULL;
SDL_Colour consoleFontColour = /*{ 255,255,255,255 };*/{ 255, 252, 214, 255 };
SDL_Rect fontPositionRect = { 28, 28, 0, 0 };
SDL_Texture *fontTexture = NULL;
string test = "test"; //TEST STRING HERE
public:
SDL_Console();
~SDL_Console();
void pause();
bool isRunning();
//initialise sdl images, main, and ttf
bool initialiseSDL(const char* title, int xpos, int ypos, int width, int height);
//runs command
void runWithCappedFrames();
void handleConsoleEvents();
//makes the cursor blink
void cursorBlink(int);
//renders different elements to screen
void render(int);
//Renderer functions
SDL_Texture* loadTexture(const char*);
void drawTexture(SDL_Texture*, SDL_Rect, SDL_Rect);
//output a string to console
SDL_Texture* consoleOutput(string, SDL_Rect&);
void renderConsoleOutput(SDL_Texture*, SDL_Rect);
};
#endif
|