Initial commit
This commit is contained in:
47
src/renderer.cpp
Normal file
47
src/renderer.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "renderer.hpp"
|
||||
#include <ncurses.h>
|
||||
#include <string>
|
||||
|
||||
namespace Dive {
|
||||
void Renderer::init() {
|
||||
if (!hasInit) {
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
keypad(stdscr, TRUE);
|
||||
set_escdelay(10);
|
||||
|
||||
hasInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::close() {
|
||||
if (hasInit) endwin();
|
||||
hasInit = false;
|
||||
}
|
||||
|
||||
void Renderer::display() {
|
||||
if (hasInit) refresh();
|
||||
}
|
||||
|
||||
void Renderer::clear() {
|
||||
if (hasInit) erase();
|
||||
}
|
||||
|
||||
Keycode Renderer::wait() {
|
||||
if (hasInit) return getch();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void Renderer::putString(int x, int y, std::string str) {
|
||||
if (hasInit) mvprintw(y, x, "%s", str.c_str());
|
||||
}
|
||||
|
||||
void Renderer::appendString(std::string str) {
|
||||
if (hasInit) printw("%s", str.c_str());
|
||||
}
|
||||
|
||||
void Renderer::setPos(int x, int y) {
|
||||
if (hasInit) move(y, x);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user