Merge pull request #2525 from myk002/myk_textures_sweet_textures

Render tile textures if specified in the pen
develop
Myk 2022-12-27 19:12:25 -08:00 committed by GitHub
commit 9dec5226c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 39 deletions

@ -11,7 +11,7 @@ USE_GRAPHICS = dscreen.inGraphicsMode()
local to_pen = dfhack.pen.parse local to_pen = dfhack.pen.parse
CLEAR_PEN = to_pen{ch=32,fg=0,bg=0} CLEAR_PEN = to_pen{tile=909, ch=32, fg=0, bg=0}
local FAKE_INPUT_KEYS = { local FAKE_INPUT_KEYS = {
_MOUSE_L = true, _MOUSE_L = true,
@ -624,6 +624,7 @@ function Screen:renderParent()
else else
dscreen.clear() dscreen.clear()
end end
df.global.gps.force_full_display_count = 1
end end
function Screen:sendInputToParent(...) function Screen:sendInputToParent(...)
@ -693,15 +694,17 @@ BOUNDARY_FRAME = {
} }
GREY_LINE_FRAME = { GREY_LINE_FRAME = {
frame_pen = to_pen{ ch = 206, fg = COLOR_GREY, bg = COLOR_BLACK }, frame_pen = to_pen{ ch=206, fg=COLOR_GREY, bg=COLOR_BLACK },
h_frame_pen = to_pen{ ch = 205, fg = COLOR_GREY, bg = COLOR_BLACK }, t_frame_pen = to_pen{ tile=902, ch=205, fg=COLOR_GREY, bg=COLOR_BLACK },
v_frame_pen = to_pen{ ch = 186, fg = COLOR_GREY, bg = COLOR_BLACK }, l_frame_pen = to_pen{ tile=908, ch=186, fg=COLOR_GREY, bg=COLOR_BLACK },
lt_frame_pen = to_pen{ ch = 201, fg = COLOR_GREY, bg = COLOR_BLACK }, b_frame_pen = to_pen{ tile=916, ch=205, fg=COLOR_GREY, bg=COLOR_BLACK },
lb_frame_pen = to_pen{ ch = 200, fg = COLOR_GREY, bg = COLOR_BLACK }, r_frame_pen = to_pen{ tile=910, ch=186, fg=COLOR_GREY, bg=COLOR_BLACK },
rt_frame_pen = to_pen{ ch = 187, fg = COLOR_GREY, bg = COLOR_BLACK }, lt_frame_pen = to_pen{ tile=901, ch=201, fg=COLOR_GREY, bg=COLOR_BLACK },
rb_frame_pen = to_pen{ ch = 188, fg = COLOR_GREY, bg = COLOR_BLACK }, lb_frame_pen = to_pen{ tile=915, ch=200, fg=COLOR_GREY, bg=COLOR_BLACK },
title_pen = to_pen{ fg = COLOR_BLACK, bg = COLOR_GREY }, rt_frame_pen = to_pen{ tile=903, ch=187, fg=COLOR_GREY, bg=COLOR_BLACK },
signature_pen = to_pen{ fg = COLOR_GREY, bg = COLOR_BLACK }, rb_frame_pen = to_pen{ tile=917, ch=188, fg=COLOR_GREY, bg=COLOR_BLACK },
title_pen = to_pen{ fg=COLOR_BLACK, bg=COLOR_GREY },
signature_pen = to_pen{ fg=COLOR_GREY, bg=COLOR_BLACK },
} }
function paint_frame(dc,rect,style,title) function paint_frame(dc,rect,style,title)

@ -54,7 +54,7 @@ using namespace DFHack;
#include "df/tile_pagest.h" #include "df/tile_pagest.h"
#include "df/interfacest.h" #include "df/interfacest.h"
#include "df/enabler.h" #include "df/enabler.h"
#include "df/graphic_map_portst.h" #include "df/graphic_viewportst.h"
#include "df/unit.h" #include "df/unit.h"
#include "df/item.h" #include "df/item.h"
#include "df/job.h" #include "df/job.h"
@ -115,39 +115,72 @@ bool Screen::inGraphicsMode()
return init && init->display.flag.is_set(init_display_flags::USE_GRAPHICS); return init && init->display.flag.is_set(init_display_flags::USE_GRAPHICS);
} }
static bool doSetTile_map(const Pen &pen, int x, int y) {
size_t index = (x * gps->main_viewport->dim_y) + y;
long texpos = pen.tile;
if (texpos == 0) {
texpos = init->font.large_font_texpos[(uint8_t)pen.ch];
}
gps->main_viewport->screentexpos_interface[index] = texpos;
return true;
}
static bool doSetTile_default(const Pen &pen, int x, int y, bool map) static bool doSetTile_default(const Pen &pen, int x, int y, bool map)
{ {
// TODO: understand how this changes for v50 bool use_graphics = Screen::inGraphicsMode();
size_t index = ((x * gps->dimy) + y);
if (!map) { if (map && use_graphics)
// don't let DF overlay interface elements draw over us return doSetTile_map(pen, x, y);
gps->screentexpos_anchored[index] = 0;
gps->screentexpos_top[index] = 0; size_t index = (x * gps->dimy) + y;
gps->screentexpos_flag[index] = 0; uint8_t *screen = &gps->screen[index * 8];
if (screen > gps->screen_limit)
return false;
long *texpos = &gps->screentexpos[index];
long *texpos_lower = &gps->screentexpos_lower[index];
uint32_t *flag = &gps->screentexpos_flag[index];
*screen = 0;
*texpos = 0;
*texpos_lower = 0;
*flag = 4; // remove SCREENTEXPOS_FLAG_ANCHOR_SUBORDINATE
if (gps->top_in_use) {
screen = &gps->screen_top[index * 8];
texpos = &gps->screentexpos_top[index];
texpos_lower = &gps->screentexpos_top_lower[index];
flag = &gps->screentexpos_top_flag[index];
*screen = 0;
*texpos = 0;
*texpos_lower = 0;
*flag = 4; // remove SCREENTEXPOS_FLAG_ANCHOR_SUBORDINATE
}
if (pen.tile_mode == Screen::Pen::CharColor)
*flag |= 2; // SCREENTEXPOS_FLAG_ADDCOLOR
else if (pen.tile_mode == Screen::Pen::TileColor)
*flag |= 1; // SCREENTEXPOS_FLAG_GRAYSCALE
if (pen.tile && use_graphics) {
*texpos = pen.tile;
} else {
screen[0] = uint8_t(pen.ch);
*texpos_lower = 909;
} }
//gps->screen1_opt_tile[index] = uint8_t(pen.tile);
// note that pen.bold currently (50.04) has no representation in the DF data
auto fg = &gps->uccolor[pen.fg][0]; auto fg = &gps->uccolor[pen.fg][0];
auto bg = &gps->uccolor[pen.bg][0]; auto bg = &gps->uccolor[pen.bg][0];
auto argb = &gps->screen[index * 8]; screen[1] = fg[0];
argb[0] = uint8_t(pen.ch); screen[2] = fg[1];
argb[1] = fg[0]; screen[3] = fg[2];
argb[2] = fg[1]; screen[4] = bg[0];
argb[3] = fg[2]; screen[5] = bg[1];
argb[4] = bg[0]; screen[6] = bg[2];
argb[5] = bg[1];
argb[6] = bg[2];
/* old code
// auto screen = gps->screen + index*4;
// screen[0] = uint8_t(pen.ch);
// screen[1] = uint8_t(pen.fg) & 15;
// screen[2] = uint8_t(pen.bg) & 15;
// screen[3] = uint8_t(pen.bold) & 1;
// gps->screentexpos[index] = pen.tile;
// gps->screentexpos_addcolor[index] = (pen.tile_mode == Screen::Pen::CharColor);
// gps->screentexpos_grayscale[index] = (pen.tile_mode == Screen::Pen::TileColor);
// gps->screentexpos_cf[index] = pen.tile_fg;
// gps->screentexpos_cbr[index] = pen.tile_bg;
*/
return true; return true;
} }