From 2e622295b8843440ddc80e99afb091d20de1c953 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Sat, 12 Oct 2024 04:52:40 +0200 Subject: [PATCH] Simplify layout setup --- itemcontroller.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/itemcontroller.lua b/itemcontroller.lua index 09beb44..7e332d8 100644 --- a/itemcontroller.lua +++ b/itemcontroller.lua @@ -499,8 +499,6 @@ local PAGES = { id = "data_divider", top = 0, bottom = 0, - left = math.floor((state.width - (PADDING_RQC_H * 2) - #tostring(pageState.request) - #tostring(group:getItemCount())) / 2), - right = math.ceil((state.width - (PADDING_RQC_H * 2) - #tostring(pageState.request) - #tostring(group:getItemCount())) / 2), element = Text:new{ text = "/" } }, Text:new{ id = "data_available", text = tostring(group:getItemCount()) }, @@ -557,12 +555,15 @@ local PAGES = { local dataAvailableText = paddedRequestCount:findById("data_available") local requestCapProgress = paddedRequestCount:findById("request_capacity") - dataRequestText:setText(tostring(pageState.request)) + local requestText = tostring(pageState.request) + local availableText = tostring(group:getItemCount()) + + dataRequestText:setText(requestText) dataDividerPad:setPadding{ - left = math.floor((state.width - (PADDING_RQC_H * 2) - #tostring(pageState.request) - #tostring(group:getItemCount())) / 2), - right = math.ceil((state.width - (PADDING_RQC_H * 2) - #tostring(pageState.request) - #tostring(group:getItemCount())) / 2) + left = math.ceil((state.width - 1 - (PADDING_RQC_H * 2) - #requestText - #availableText) / 2), + right = math.floor((state.width - 1 - (PADDING_RQC_H * 2) - #requestText - #availableText) / 2) } - dataAvailableText:setText(tostring(group:getItemCount())) + dataAvailableText:setText(availableText) requestCapProgress:setProgress(pageState.request / group:getItemCount()) stuffContainer:setDirty(true) @@ -585,6 +586,8 @@ local PAGES = { bindRequestButton(1) bindRequestButton(5) + updateDisplayState() + return renderDefault(state, stuffContainer) end }