dfhack/plugins/embark-assistant/screen.cpp

28 lines
716 B
C++

2017-09-01 06:13:34 -06:00
#include "screen.h"
namespace embark_assist {
namespace screen {
}
}
2017-09-01 06:13:34 -06:00
bool embark_assist::screen::paintString(const DFHack::Screen::Pen &pen, int x, int y, const std::string &text, bool map) {
auto screen_size = DFHack::Screen::getWindowSize();
2017-09-01 06:13:34 -06:00
if (y < 1 || y + 1 >= screen_size.y || x < 1)
{
return false; // Won't paint outside of the screen or on the frame
}
2017-09-01 06:13:34 -06:00
if (x + text.length() - 1 < screen_size.x - 2) {
DFHack::Screen::paintString(pen, x, y, text, map);
}
else if (x < screen_size.x - 2) {
DFHack::Screen::paintString(pen, x, y, text.substr(0, screen_size.x - 2 - x + 1), map);
2017-09-01 06:13:34 -06:00
}
else {
return false;
}
return true;
}