diff options
| author | Quietust | 2012-08-21 15:28:11 -0500 |
|---|---|---|
| committer | Quietust | 2012-08-21 15:28:11 -0500 |
| commit | 51ba2523446596f4cdf0f179702ecc3b1eefa965 (patch) | |
| tree | 8b6e8a815685b449463d8815e15dab48c8f6be26 /library | |
| parent | 985d96c596ac190493f36c9764bfe5308dfecfe3 (diff) | |
| download | dfhack-51ba2523446596f4cdf0f179702ecc3b1eefa965.tar.gz dfhack-51ba2523446596f4cdf0f179702ecc3b1eefa965.tar.bz2 dfhack-51ba2523446596f4cdf0f179702ecc3b1eefa965.tar.xz | |
Add Screen::drawBorder(string), duplicates DF's interfacest::drawborder()
Diffstat (limited to 'library')
| -rw-r--r-- | library/include/modules/Screen.h | 3 | ||||
| -rw-r--r-- | library/modules/Screen.cpp | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/library/include/modules/Screen.h b/library/include/modules/Screen.h index 334b466f..e2923317 100644 --- a/library/include/modules/Screen.h +++ b/library/include/modules/Screen.h @@ -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(); diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 57b014ac..561ae2c5 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -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; |
