From 3e8d4f925753e35465bb6b3076ddd03ff3ca8d67 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 23:35:07 -0600 Subject: [PATCH] New command for clearing the stockpile order. Shift-Space by default, using the SETUPGAME_SAVE_PROFILE_ABORT key. --- plugins/lua/stockflow.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 3422425ad..1590bf4c4 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -816,6 +816,10 @@ function screen:onRenderBody(dc) dc:string(gui.getKeyDisplay("STANDARDSCROLL_RIGHT"), COLOR_LIGHTGREEN) dc:string(": Select", COLOR_WHITE) + dc:seek(CenterCol, FirstRow + self.page_size + 2) + dc:string(gui.getKeyDisplay("SETUPGAME_SAVE_PROFILE_ABORT"), COLOR_LIGHTGREEN) + dc:string(": No order", COLOR_WHITE) + -- Reaction lines. for _, item in ipairs(self.displayed) do dc:seek(item.x, item.y):string(item.name, item.color) @@ -831,6 +835,9 @@ function screen:onInput(keys) if selected then store_order(self.stockpile, selected.index) end + elseif keys.SETUPGAME_SAVE_PROFILE_ABORT then + self:dismiss() + clear_order(self.stockpile) elseif keys.STANDARDSCROLL_UP then self.position = self.position - 1 elseif keys.STANDARDSCROLL_DOWN then @@ -1002,6 +1009,14 @@ function screen:refilter() self.displayed = displayed end +function clear_order(stockpile) + local saved = saved_orders[stockpile.id] + if saved then + saved.entry:delete() + saved_orders[stockpile.id] = nil + end +end + function store_order(stockpile, order_number) local name = reaction_list[order_number].name -- print("Setting stockpile #"..stockpile.stockpile_number.." to "..name.." (#"..order_number..")")