use an actual pin texture for ZScreen pins

develop
Myk Taylor 2023-01-09 00:47:13 -08:00
parent 3e11a31070
commit 2234328a91
No known key found for this signature in database
7 changed files with 41 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

@ -1676,6 +1676,8 @@ static const luaL_Reg dfhack_job_funcs[] = {
static const LuaWrapper::FunctionReg dfhack_textures_module[] = { static const LuaWrapper::FunctionReg dfhack_textures_module[] = {
WRAPM(Textures, getDfhackLogoTexposStart), WRAPM(Textures, getDfhackLogoTexposStart),
WRAPM(Textures, getGreenPinTexposStart),
WRAPM(Textures, getRedPinTexposStart),
{ NULL, NULL } { NULL, NULL }
}; };

@ -30,5 +30,10 @@ void cleanup();
*/ */
DFHACK_EXPORT long getDfhackLogoTexposStart(); DFHACK_EXPORT long getDfhackLogoTexposStart();
/**
* Get the texpos for the UI pin tiles. Each are 2x2 grids.
*/
DFHACK_EXPORT long getGreenPinTexposStart();
DFHACK_EXPORT long getRedPinTexposStart();
} }
} }

@ -818,9 +818,25 @@ function paint_frame(dc,rect,style,title,show_lock,locked,inactive)
if show_lock then if show_lock then
if locked and style.locked_pen then if locked and style.locked_pen then
local pin_texpos = dfhack.textures.getGreenPinTexposStart()
if pin_texpos == -1 then
dscreen.paintTile(style.locked_pen, x2-1, y1) dscreen.paintTile(style.locked_pen, x2-1, y1)
else
dscreen.paintTile(style.locked_pen, x2-2, y1-1, nil, pin_texpos+0)
dscreen.paintTile(style.locked_pen, x2-1, y1-1, nil, pin_texpos+1)
dscreen.paintTile(style.locked_pen, x2-2, y1, nil, pin_texpos+2)
dscreen.paintTile(style.locked_pen, x2-1, y1, nil, pin_texpos+3)
end
elseif not locked and style.unlocked_pen then elseif not locked and style.unlocked_pen then
local pin_texpos = dfhack.textures.getRedPinTexposStart()
if pin_texpos == -1 then
dscreen.paintTile(style.unlocked_pen, x2-1, y1) dscreen.paintTile(style.unlocked_pen, x2-1, y1)
else
dscreen.paintTile(style.unlocked_pen, x2-2, y1-1, nil, pin_texpos+0)
dscreen.paintTile(style.unlocked_pen, x2-1, y1-1, nil, pin_texpos+1)
dscreen.paintTile(style.unlocked_pen, x2-2, y1, nil, pin_texpos+2)
dscreen.paintTile(style.unlocked_pen, x2-1, y1, nil, pin_texpos+3)
end
end end
end end
end end

@ -502,7 +502,8 @@ function Window:onInput(keys)
if keys._MOUSE_L_DOWN and self.parent_view and self.parent_view.toggleLocked then if keys._MOUSE_L_DOWN and self.parent_view and self.parent_view.toggleLocked then
local x,y = dscreen.getMousePos() local x,y = dscreen.getMousePos()
local frame_rect = self.frame_rect local frame_rect = self.frame_rect
if x == frame_rect.x2-1 and y == frame_rect.y1 then if (x == frame_rect.x2-2 or x == frame_rect.x2-1)
and (y == frame_rect.y1-1 or y == frame_rect.y1) then
self.parent_view:toggleLocked() self.parent_view:toggleLocked()
end end
end end

@ -19,6 +19,8 @@ namespace DFHack {
static bool g_loaded = false; static bool g_loaded = false;
static long g_num_dfhack_textures = 0; static long g_num_dfhack_textures = 0;
static long g_dfhack_logo_texpos_start = -1; static long g_dfhack_logo_texpos_start = -1;
static long g_green_pin_texpos_start = -1;
static long g_red_pin_texpos_start = -1;
// Converts an arbitrary Surface to something like the display format // Converts an arbitrary Surface to something like the display format
// (32-bit RGBA), and converts magenta to transparency if convert_magenta is set // (32-bit RGBA), and converts magenta to transparency if convert_magenta is set
@ -111,6 +113,10 @@ void Textures::init(color_ostream &out) {
g_num_dfhack_textures = load_textures(out, "hack/data/art/dfhack.png", g_num_dfhack_textures = load_textures(out, "hack/data/art/dfhack.png",
&g_dfhack_logo_texpos_start); &g_dfhack_logo_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/green-pin.png",
&g_green_pin_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/red-pin.png",
&g_red_pin_texpos_start);
DEBUG(textures,out).print("loaded %ld textures\n", g_num_dfhack_textures); DEBUG(textures,out).print("loaded %ld textures\n", g_num_dfhack_textures);
@ -146,3 +152,11 @@ void Textures::cleanup() {
long Textures::getDfhackLogoTexposStart() { long Textures::getDfhackLogoTexposStart() {
return g_dfhack_logo_texpos_start; return g_dfhack_logo_texpos_start;
} }
long Textures::getGreenPinTexposStart() {
return g_green_pin_texpos_start;
}
long Textures::getRedPinTexposStart() {
return g_red_pin_texpos_start;
}