Add Screen::drawBorder(string), duplicates DF's interfacest::drawborder()

develop
Quietust 2012-08-21 15:28:11 -05:00
parent 985d96c596
commit 51ba252344
2 changed files with 24 additions and 0 deletions

@ -98,6 +98,9 @@ namespace DFHack
/// Fills a rectangle with one pen. Possibly more efficient than a loop over paintTile.
DFHACK_EXPORT bool fillRect(const Pen &pen, int x1, int y1, int x2, int y2);
/// Draws a standard dark gray window border with a title string
DFHACK_EXPORT bool drawBorder(const std::string &title);
/// Wipes the screen to full black
DFHACK_EXPORT bool clear();

@ -151,6 +151,27 @@ bool Screen::fillRect(const Pen &pen, int x1, int y1, int x2, int y2)
return true;
}
bool Screen::drawBorder(const std::string &title)
{
if (!gps) return false;
int dimx = gps->dimx, dimy = gps->dimy;
Pen border(0xDB, 8);
Pen text(0, 0, 7);
for (int x = 0; x < dimx; x++)
{
doSetTile(border, x * dimy + 0);
doSetTile(border, x * dimy + dimy - 1);
}
for (int y = 0; y < dimy; y++)
{
doSetTile(border, 0 * dimy + y);
doSetTile(border, (dimx - 1) * dimy + y);
}
return paintString(text, (dimx - title.length()) / 2, 0, title);
}
bool Screen::clear()
{
if (!gps) return false;