diff --git a/data/art/green-pin.png b/data/art/green-pin.png new file mode 100644 index 000000000..25d0e696f Binary files /dev/null and b/data/art/green-pin.png differ diff --git a/data/art/red-pin.png b/data/art/red-pin.png new file mode 100644 index 000000000..763b83e97 Binary files /dev/null and b/data/art/red-pin.png differ diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index fdd19783a..c327efe1b 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1676,6 +1676,8 @@ static const luaL_Reg dfhack_job_funcs[] = { static const LuaWrapper::FunctionReg dfhack_textures_module[] = { WRAPM(Textures, getDfhackLogoTexposStart), + WRAPM(Textures, getGreenPinTexposStart), + WRAPM(Textures, getRedPinTexposStart), { NULL, NULL } }; diff --git a/library/include/modules/Textures.h b/library/include/modules/Textures.h index 2ef172bff..e088ce477 100644 --- a/library/include/modules/Textures.h +++ b/library/include/modules/Textures.h @@ -30,5 +30,10 @@ void cleanup(); */ DFHACK_EXPORT long getDfhackLogoTexposStart(); +/** + * Get the texpos for the UI pin tiles. Each are 2x2 grids. + */ +DFHACK_EXPORT long getGreenPinTexposStart(); +DFHACK_EXPORT long getRedPinTexposStart(); } } diff --git a/library/lua/gui.lua b/library/lua/gui.lua index 661351d31..f83a1b0cd 100644 --- a/library/lua/gui.lua +++ b/library/lua/gui.lua @@ -818,9 +818,25 @@ function paint_frame(dc,rect,style,title,show_lock,locked,inactive) if show_lock then if locked and style.locked_pen then - dscreen.paintTile(style.locked_pen, x2-1, y1) + local pin_texpos = dfhack.textures.getGreenPinTexposStart() + if pin_texpos == -1 then + 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 - dscreen.paintTile(style.unlocked_pen, x2-1, y1) + local pin_texpos = dfhack.textures.getRedPinTexposStart() + if pin_texpos == -1 then + 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 diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index c5002ddaa..c13757f22 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -502,7 +502,8 @@ function Window:onInput(keys) if keys._MOUSE_L_DOWN and self.parent_view and self.parent_view.toggleLocked then local x,y = dscreen.getMousePos() 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() end end diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index 70011b627..3ae8658c8 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -19,6 +19,8 @@ namespace DFHack { static bool g_loaded = false; static long g_num_dfhack_textures = 0; 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 // (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_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); @@ -146,3 +152,11 @@ void Textures::cleanup() { long Textures::getDfhackLogoTexposStart() { return g_dfhack_logo_texpos_start; } + +long Textures::getGreenPinTexposStart() { + return g_green_pin_texpos_start; +} + +long Textures::getRedPinTexposStart() { + return g_red_pin_texpos_start; +}