From caa525e31d045c5456e93eb386540d8aa29b9aa6 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Mon, 4 May 2020 04:09:13 -0400 Subject: [PATCH] Swshop: Add option to show out of stock items - Make ShopView use colors from ui.theme --- swshop/shopConfig.lua | 13 ++++++++----- swshop/shopView.lua | 23 +++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/swshop/shopConfig.lua b/swshop/shopConfig.lua index 857d0c1..c5958ea 100644 --- a/swshop/shopConfig.lua +++ b/swshop/shopConfig.lua @@ -29,10 +29,13 @@ local wizardPage = UI.WizardPage { [3] = UI.Checkbox { formLabel = 'Single shop', formKey = 'refundInvalid', help = 'Only this shop uses this domain', - limit = 64, }, - [4] = UI.Chooser { - formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 5, + [4] = UI.Checkbox { + formLabel = 'Show out of stock', formKey = 'showOutOfStock', + help = 'Show out of stock items in red', + }, + [5] = UI.Chooser { + formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 6, width = 10, nochoice = 'Top', choices = { @@ -45,9 +48,9 @@ local wizardPage = UI.WizardPage { }, required = true, }, - [5] = UI.Chooser { + [6] = UI.Chooser { width = 9, - formIndex = 6, + formIndex = 7, formLabel = 'Font Size', formKey = 'textScale', nochoice = 'Small', choices = { diff --git a/swshop/shopView.lua b/swshop/shopView.lua index 223ff6c..4a51b17 100644 --- a/swshop/shopView.lua +++ b/swshop/shopView.lua @@ -49,15 +49,15 @@ local function createPage(node) local page = UI.Page { parent = monitor, header = UI.Window { - backgroundColor = colors.cyan, + backgroundColor = 'primary', ey = 3, }, grid = UI.Grid { y = 4, ey = -7, headerHeight = 3, - headerBackgroundColor = colors.gray, + headerBackgroundColor = 'tertiary', backgroundSelectedColor = colors.black, - unfocusedBackgroundSelectedColor = colors.gray, + unfocusedBackgroundSelectedColor = 'tertiary', columns = { { heading = 'Stock', key = 'count', width = 6, align = 'right' }, { heading = 'Name', key = 'displayName' }, @@ -68,17 +68,17 @@ local function createPage(node) }, footer = UI.Window { y = -6, - backgroundColor = colors.gray, + backgroundColor = 'tertiary', prevButton = UI.Button { x = 2, y = 3, height = 3, width = 5, event = 'previous', - backgroundColor = colors.lightGray, + backgroundColor = 'secondary', text = ' \017 ', }, nextButton = UI.Button { x = -6, y = 3, height = 3, width = 5, event = 'next', - backgroundColor = colors.lightGray, + backgroundColor = 'secondary', text = ' \016 ', }, info = UI.Window { @@ -94,7 +94,7 @@ local function createPage(node) if node.header then self:centeredWrite(2, node.header, nil, colors.white) end - self:write(self.width - 15, 3, 'powered by Milo', nil, colors.gray) + self:write(self.width - 15, 3, 'powered by Milo', nil, 'tertiary') end function page.footer.info:draw() @@ -112,6 +112,9 @@ local function createPage(node) end function page.grid:getRowTextColor(row, selected) + if row.count < 1 then + return colors.red + end if selected then return colors.yellow end @@ -151,11 +154,11 @@ local function createPage(node) local list = Milo:listItems() self.grid.values = { } for k,v in pairs(config) do - local item = list[k] - if item and item.count > 0 then + local item = list[k] or itemDB:get(k) + if item and (node.showOutOfStock or item.count > 0) then table.insert(self.grid.values, { displayName = item.displayName, - count = item.count, + count = item.count or 0, name = v.name, price = v.price, info = v.info,