From 2b79582e99654282a03ee10424db380942b04b10 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov The screen module implements support for drawing to the tiled screen of the game.
Note that drawing only has any effect when done from callbacks, so it can only
be feasibly used in the core context. Basic painting functions: dfhack.screen.getWindowSize() Returns width, height of the screen.
In order to actually be able to paint to the screen, it is necessary to create and register a viewscreen (basically a modal dialog) with -the game. Screens are managed with the following functions:
+the game. +NOTE: As a matter of policy, in order to avoid user confusion, all +interface screens added by dfhack should bear the "DFHack" signature.
+Screens are managed with the following functions:
dfhack.screen.show(screen[,below])
Displays the given screen, possibly placing it below a different one. diff --git a/library/lua/gui.lua b/library/lua/gui.lua index ee3bccb9f..3156894d2 100644 --- a/library/lua/gui.lua +++ b/library/lua/gui.lua @@ -245,9 +245,18 @@ end -- Framed screen object -- ------------------------ +-- Plain grey-colored frame. GREY_FRAME = { frame_pen = { ch = ' ', fg = COLOR_BLACK, bg = COLOR_GREY }, title_pen = { fg = COLOR_BLACK, bg = COLOR_WHITE }, + signature_pen = { fg = COLOR_BLACK, bg = COLOR_GREY }, +} + +-- The usual boundary used by the DF screens. Often has fancy pattern in tilesets. +BOUNDARY_FRAME = { + frame_pen = { ch = 0xDB, fg = COLOR_DARKGREY, bg = COLOR_BLACK }, + title_pen = { fg = COLOR_BLACK, bg = COLOR_GREY }, + signature_pen = { fg = COLOR_BLACK, bg = COLOR_DARKGREY }, } function paint_frame(x1,y1,x2,y2,style,title) @@ -260,6 +269,7 @@ function paint_frame(x1,y1,x2,y2,style,title) dscreen.fillRect(style.b_frame_pen or style.h_frame_pen or pen,x1+1,y2,x2-1,y2) dscreen.fillRect(style.l_frame_pen or style.v_frame_pen or pen,x1,y1+1,x1,y2-1) dscreen.fillRect(style.r_frame_pen or style.v_frame_pen or pen,x2,y1+1,x2,y2-1) + dscreen.paintString(style.signature_pen or style.title_pen or pen,x2-7,y2,"DFHack") if title then local x = math.max(0,math.floor((x2-x1-3-#title)/2)) + x1 diff --git a/library/lua/gui/dwarfmode.lua b/library/lua/gui/dwarfmode.lua index 8c761aefe..f38b975f7 100644 --- a/library/lua/gui/dwarfmode.lua +++ b/library/lua/gui/dwarfmode.lua @@ -163,6 +163,12 @@ function MenuOverlay:onRender() local menu = self.df_layout.menu if menu then + -- Paint signature on the frame. + dscreen.paintString( + {fg=COLOR_BLACK,bg=COLOR_DARKGREY}, + menu.x1+1, menu.y2+1, "DFHack" + ) + self:onRenderBody(gui.Painter.new(menu)) end end diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 7dcbba322..cadd4c6d5 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -158,6 +158,7 @@ bool Screen::drawBorder(const std::string &title) int dimx = gps->dimx, dimy = gps->dimy; Pen border(0xDB, 8); Pen text(0, 0, 7); + Pen signature(0, 0, 8); for (int x = 0; x < dimx; x++) { @@ -169,6 +170,9 @@ bool Screen::drawBorder(const std::string &title) doSetTile(border, 0 * dimy + y); doSetTile(border, (dimx - 1) * dimy + y); } + + paintString(signature, dimx-8, dimy-1, "DFHack"); + return paintString(text, (dimx - title.length()) / 2, 0, title); }