From 9c9f710d5b1be73a78f76b72d660e9d532ab32ac Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 10 Apr 2016 14:47:33 +0300 Subject: [PATCH 1/4] Fix eventful not showing sidebar sometimes E.g. when destroying buildings --- plugins/lua/eventful.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lua/eventful.lua b/plugins/lua/eventful.lua index a1093b372..56311c639 100644 --- a/plugins/lua/eventful.lua +++ b/plugins/lua/eventful.lua @@ -105,7 +105,7 @@ function registerSidebar(shop_name,callback) dfhack.onStateChange.eventful=unregall else local function drawSidebar( wshop ) - local valid_focus="dwarfmode/QueryBuilding/Some" + local valid_focus="dwarfmode/QueryBuilding" if wshop:getMaxBuildStage()==wshop:getBuildStage() then local sidebar=callback{workshop=wshop} if string.sub(dfhack.gui.getCurFocus(),1,#valid_focus)==valid_focus then From 29f08cd20d517d201c8b54c0a621c55c94c219d8 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 10 Apr 2016 14:58:03 +0300 Subject: [PATCH 2/4] Fix eventful trying to show sidebar It should not try to do that if e.g. showing buildingitems. Maybe later we will have more valid focus strings (e.g. custom item view for some buildings) but for now just use vanilla (or callback function not a class) --- plugins/lua/eventful.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/lua/eventful.lua b/plugins/lua/eventful.lua index 56311c639..0035c3a53 100644 --- a/plugins/lua/eventful.lua +++ b/plugins/lua/eventful.lua @@ -110,8 +110,6 @@ function registerSidebar(shop_name,callback) local sidebar=callback{workshop=wshop} if string.sub(dfhack.gui.getCurFocus(),1,#valid_focus)==valid_focus then sidebar:show() - else - sidebar:show(dfhack.gui.getCurViewscreen(true).parent) end end end From c4c452c288444a20c0c31d82539254128c2c19c6 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 10 Apr 2016 16:51:58 +0300 Subject: [PATCH 3/4] Show sidebar when moving from screen to screen When both are from lua the old logic failed. --- plugins/lua/eventful.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/lua/eventful.lua b/plugins/lua/eventful.lua index 0035c3a53..3fc192505 100644 --- a/plugins/lua/eventful.lua +++ b/plugins/lua/eventful.lua @@ -106,10 +106,14 @@ function registerSidebar(shop_name,callback) else local function drawSidebar( wshop ) local valid_focus="dwarfmode/QueryBuilding" + local another_overlay="dfhack/lua/WorkshopOverlay" if wshop:getMaxBuildStage()==wshop:getBuildStage() then local sidebar=callback{workshop=wshop} - if string.sub(dfhack.gui.getCurFocus(),1,#valid_focus)==valid_focus then - sidebar:show() + if string.sub(dfhack.gui.getCurFocus(true),1,#another_overlay)==another_overlay then + dfhack.screen.dismiss(dfhack.gui.getCurViewscreen(true)) + end + if string.sub(dfhack.gui.getCurFocus(true),1,#valid_focus)==valid_focus then + sidebar:show(dfhack.gui.getCurViewscreen(true)) end end end From 812f6df272adc799c0110ea52513114c7da8c968 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 10 Apr 2016 16:55:08 +0300 Subject: [PATCH 4/4] Fix building-hacks color for auto_gears option Now it should select the gear color correctly --- plugins/lua/building-hacks.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/lua/building-hacks.lua b/plugins/lua/building-hacks.lua index 444b92127..2a242dcc8 100644 --- a/plugins/lua/building-hacks.lua +++ b/plugins/lua/building-hacks.lua @@ -95,8 +95,8 @@ local function findGears( shop_def ) --finds positions of all gears and inverted end return ret end -local function lookup_color( shop_def,x,y,stage )--TODO: background and bright? - return shop_def.tile_color[stage][x][y] +local function lookup_color( shop_def,x,y,stage ) + return shop_def.tile_color[0][stage][x][y],shop_def.tile_color[1][stage][x][y],shop_def.tile_color[2][stage][x][y] end local function processFramesAuto( shop_def ,gears) --adds frames for all gear icons and inverted gear icons local w,h=shop_def.dim_x,shop_def.dim_y @@ -114,8 +114,8 @@ local function processFramesAuto( shop_def ,gears) --adds frames for all gear ic tile_inv=42 end - table.insert(frames[1],{x=v.x,y=v.y,tile,lookup_color(shop_def,v.x,v.y),0,0}) - table.insert(frames[2],{x=v.x,y=v.y,tile_inv,lookup_color(shop_def,v.x,v.y),0,0}) + table.insert(frames[1],{x=v.x,y=v.y,tile,lookup_color(shop_def,v.x,v.y,stage)}) + table.insert(frames[2],{x=v.x,y=v.y,tile_inv,lookup_color(shop_def,v.x,v.y,stage)}) end for frame_id,frame in ipairs(frames) do @@ -176,4 +176,4 @@ function registerBuilding(args) addBuilding(shop_id,fix_impassible,consume,produce,needs_power,gears,updateSkip,frames,frameLength,roomSubset) end -return _ENV \ No newline at end of file +return _ENV