diff --git a/plugins/lua/eventful.lua b/plugins/lua/eventful.lua index a8840424b..2aa713583 100644 --- a/plugins/lua/eventful.lua +++ b/plugins/lua/eventful.lua @@ -25,13 +25,13 @@ local function getShopName(btype,bsubtype,bcustom) if typenames_shop[bsubtype]~=nil then return typenames_shop[bsubtype] else - return nil --todo add custom (not very useful) + return df.building_def_workshopst.find(bcustom).code end elseif btype==df.building_type.Furnace then if typenames_furnace[bsubtype]~=nil then return typenames_furnace[bsubtype] else - return nil --todo add custom (not very useful) + return df.building_def_furnacest.find(bcustom).code end end end @@ -77,9 +77,19 @@ local function onPostSidebar(workshop) wjob.choices_visible:insert("#",new_button) end end + if _registeredStuff.customSidebar and _registeredStuff.customSidebar[shop_id] then + _registeredStuff.customSidebar[shop_id](workshop) + end + end +end +local function customSidebarsCallback(workshop) + local shop_id=getShopName(workshop:getType(),workshop:getSubtype(),workshop:getCustomType()) + if shop_id then + if _registeredStuff.customSidebar and _registeredStuff.customSidebar[shop_id] then + _registeredStuff.customSidebar[shop_id](workshop) + end end end - function registerReaction(reaction_name,callback) _registeredStuff.reactionCallbacks=_registeredStuff.reactionCallbacks or {} _registeredStuff.reactionCallbacks[reaction_name]=callback @@ -87,6 +97,13 @@ function registerReaction(reaction_name,callback) dfhack.onStateChange.eventful=unregall end +function registerSidebar(shop_name,callback) + _registeredStuff.customSidebar=_registeredStuff.customSidebar or {} + _registeredStuff.customSidebar[shop_name]=callback + onWorkshopFillSidebarMenu._library=customSidebarsCallback + dfhack.onStateChange.eventful=unregall +end + function removeNative(shop_name,name) _registeredStuff.shopNonNative=_registeredStuff.shopNonNative or {} local shops=_registeredStuff.shopNonNative diff --git a/scripts/gui/advfort.lua b/scripts/gui/advfort.lua index e29042e54..ea93aa262 100644 --- a/scripts/gui/advfort.lua +++ b/scripts/gui/advfort.lua @@ -880,7 +880,7 @@ function usetool:init(args) wid.Label{ view_id="mainLabel", frame = {xalign=0,yalign=0}, - text={{key=keybinds.prevJob.key},{gap=1,text=dfhack.curry(usetool.getModeName,self)},{gap=1,key=keybinds.nextJob.key}, + text={{key=keybinds.prevJob.key},{gap=1,text=self:callback("getModeName")},{gap=1,key=keybinds.nextJob.key}, } },