22
33local _ENV = mkmodule (' gui' )
44
5+ local textures = require (' gui.textures' )
56local utils = require (' utils' )
67
78local dscreen = dfhack .screen
@@ -912,33 +913,46 @@ local BASE_FRAME = {
912913 paused_pen = to_pen {fg = COLOR_RED , bg = COLOR_BLACK },
913914}
914915
915- local function make_frame (name , double_line )
916- local texpos = dfhack .textures [' get' .. name .. ' BordersTexposStart' ]()
917- local tp = function (offset )
918- if texpos == - 1 then return nil end
919- return texpos + offset
920- end
921916
917+ local function make_frame (tp , double_line )
922918 local frame = copyall (BASE_FRAME )
923- frame .t_frame_pen = to_pen { tile = tp ( 1 ), ch = double_line and 205 or 196 , fg = COLOR_GREY , bg = COLOR_BLACK }
924- frame .l_frame_pen = to_pen { tile = tp ( 7 ), ch = double_line and 186 or 179 , fg = COLOR_GREY , bg = COLOR_BLACK }
925- frame .b_frame_pen = to_pen { tile = tp ( 15 ), ch = double_line and 205 or 196 , fg = COLOR_GREY , bg = COLOR_BLACK }
926- frame .r_frame_pen = to_pen { tile = tp ( 9 ), ch = double_line and 186 or 179 , fg = COLOR_GREY , bg = COLOR_BLACK }
927- frame .lt_frame_pen = to_pen { tile = tp ( 0 ), ch = double_line and 201 or 218 , fg = COLOR_GREY , bg = COLOR_BLACK }
928- frame .lb_frame_pen = to_pen { tile = tp ( 14 ), ch = double_line and 200 or 192 , fg = COLOR_GREY , bg = COLOR_BLACK }
929- frame .rt_frame_pen = to_pen { tile = tp ( 2 ), ch = double_line and 187 or 191 , fg = COLOR_GREY , bg = COLOR_BLACK }
930- frame .rb_frame_pen = to_pen { tile = tp ( 16 ), ch = double_line and 188 or 217 , fg = COLOR_GREY , bg = COLOR_BLACK }
919+ frame .t_frame_pen = to_pen { tile = curry ( tp , 2 ), ch = double_line and 205 or 196 , fg = COLOR_GREY , bg = COLOR_BLACK }
920+ frame .l_frame_pen = to_pen { tile = curry ( tp , 8 ), ch = double_line and 186 or 179 , fg = COLOR_GREY , bg = COLOR_BLACK }
921+ frame .b_frame_pen = to_pen { tile = curry ( tp , 16 ), ch = double_line and 205 or 196 , fg = COLOR_GREY , bg = COLOR_BLACK }
922+ frame .r_frame_pen = to_pen { tile = curry ( tp , 10 ), ch = double_line and 186 or 179 , fg = COLOR_GREY , bg = COLOR_BLACK }
923+ frame .lt_frame_pen = to_pen { tile = curry ( tp , 1 ), ch = double_line and 201 or 218 , fg = COLOR_GREY , bg = COLOR_BLACK }
924+ frame .lb_frame_pen = to_pen { tile = curry ( tp , 15 ), ch = double_line and 200 or 192 , fg = COLOR_GREY , bg = COLOR_BLACK }
925+ frame .rt_frame_pen = to_pen { tile = curry ( tp , 3 ), ch = double_line and 187 or 191 , fg = COLOR_GREY , bg = COLOR_BLACK }
926+ frame .rb_frame_pen = to_pen { tile = curry ( tp , 17 ), ch = double_line and 188 or 217 , fg = COLOR_GREY , bg = COLOR_BLACK }
931927 return frame
932928end
933929
934- FRAME_WINDOW = make_frame (' Window' , true )
935- FRAME_PANEL = make_frame (' Panel' , false )
936- FRAME_MEDIUM = make_frame (' Medium' , false )
937- FRAME_BOLD = make_frame (' Bold' , true )
938- FRAME_INTERIOR = make_frame (' Thin' , false )
939- FRAME_INTERIOR .signature_pen = false
940- FRAME_INTERIOR_MEDIUM = copyall (FRAME_MEDIUM )
941- FRAME_INTERIOR_MEDIUM .signature_pen = false
930+ function FRAME_WINDOW (resizable )
931+ local frame = make_frame (textures .tp_border_window , true )
932+ if not resizable then
933+ frame .rb_frame_pen = to_pen { tile = curry (textures .tp_border_panel , 17 ), ch = double_line and 188 or 217 , fg = COLOR_GREY , bg = COLOR_BLACK }
934+ end
935+ return frame
936+ end
937+ function FRAME_PANEL (resizable )
938+ return make_frame (textures .tp_border_panel , false )
939+ end
940+ function FRAME_MEDIUM (resizable )
941+ return make_frame (textures .tp_border_medium , false )
942+ end
943+ function FRAME_BOLD (resizable )
944+ return make_frame (textures .tp_border_bold , true )
945+ end
946+ function FRAME_INTERIOR (resizable )
947+ local frame = make_frame (textures .tp_border_thin , false )
948+ frame .signature_pen = false
949+ return frame
950+ end
951+ function FRAME_INTERIOR_MEDIUM (resizable )
952+ local frame = make_frame (textures .tp_border_medium , false )
953+ frame .signature_pen = false
954+ return frame
955+ end
942956
943957-- for compatibility with pre-steam code
944958GREY_LINE_FRAME = FRAME_PANEL
@@ -951,18 +965,16 @@ BOLD_FRAME = FRAME_BOLD
951965INTERIOR_FRAME = FRAME_INTERIOR
952966INTERIOR_MEDIUM_FRAME = FRAME_INTERIOR_MEDIUM
953967
954-
955- function paint_frame (dc ,rect ,style ,title ,inactive ,pause_forced ,resizable )
968+ function paint_frame (dc , rect , style , title , inactive , pause_forced , resizable )
969+ if type (style ) == ' function' then
970+ style = style (resizable )
971+ end
956972 local pen = style .frame_pen
957973 local x1 ,y1 ,x2 ,y2 = dc .x1 + rect .x1 , dc .y1 + rect .y1 , dc .x1 + rect .x2 , dc .y1 + rect .y2
958974 dscreen .paintTile (style .lt_frame_pen or pen , x1 , y1 )
959975 dscreen .paintTile (style .rt_frame_pen or pen , x2 , y1 )
960976 dscreen .paintTile (style .lb_frame_pen or pen , x1 , y2 )
961- local rb_frame_pen = style .rb_frame_pen
962- if rb_frame_pen == FRAME_WINDOW .rb_frame_pen and not resizable then
963- rb_frame_pen = FRAME_PANEL .rb_frame_pen
964- end
965- dscreen .paintTile (rb_frame_pen or pen , x2 , y2 )
977+ dscreen .paintTile (style .rb_frame_pen or pen , x2 , y2 )
966978 dscreen .fillRect (style .t_frame_pen or style .h_frame_pen or pen ,x1 + 1 ,y1 ,x2 - 1 ,y1 )
967979 dscreen .fillRect (style .b_frame_pen or style .h_frame_pen or pen ,x1 + 1 ,y2 ,x2 - 1 ,y2 )
968980 dscreen .fillRect (style .l_frame_pen or style .v_frame_pen or pen ,x1 ,y1 + 1 ,x1 ,y2 - 1 )
0 commit comments