48 lines
951 B
C++
48 lines
951 B
C++
|
|
#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);
|
||
|
|
}
|
||
|
|
}
|