Refactor touch handling to use structured logging for improved debugging
This commit is contained in:
@@ -2272,13 +2272,13 @@ end
|
|||||||
local function handleTouch(x, y)
|
local function handleTouch(x, y)
|
||||||
local action, data = hitTest(x, y)
|
local action, data = hitTest(x, y)
|
||||||
if not action then
|
if not action then
|
||||||
print("[TOUCH] No zone hit")
|
log.debug("TOUCH", "No zone hit")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if action == "amount" then
|
if action == "amount" then
|
||||||
selectedAmount = data
|
selectedAmount = data
|
||||||
print("[UI] Amount set to " .. data)
|
log.debug("UI", "Amount set to %s", data)
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
|
|
||||||
elseif action == "order" then
|
elseif action == "order" then
|
||||||
@@ -2298,11 +2298,11 @@ local function handleTouch(x, y)
|
|||||||
statusColor = colors.cyan
|
statusColor = colors.cyan
|
||||||
statusTimer = 3
|
statusTimer = 3
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
print("[UI] Manual refresh")
|
log.debug("UI", "Manual refresh")
|
||||||
|
|
||||||
elseif action == "kb_toggle" then
|
elseif action == "kb_toggle" then
|
||||||
showKeyboard = not showKeyboard
|
showKeyboard = not showKeyboard
|
||||||
print("[UI] Keyboard " .. (showKeyboard and "open" or "closed"))
|
log.debug("UI", "Keyboard %s", showKeyboard and "open" or "closed")
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
|
|
||||||
elseif action == "kb_key" then
|
elseif action == "kb_key" then
|
||||||
@@ -2328,26 +2328,26 @@ local function handleTouch(x, y)
|
|||||||
|
|
||||||
elseif action == "kb_done" then
|
elseif action == "kb_done" then
|
||||||
showKeyboard = false
|
showKeyboard = false
|
||||||
print("[UI] Keyboard closed")
|
log.debug("UI", "Keyboard closed")
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
|
|
||||||
elseif action == "kb_clear" then
|
elseif action == "kb_clear" then
|
||||||
searchQuery = ""
|
searchQuery = ""
|
||||||
currentPage = 1
|
currentPage = 1
|
||||||
print("[UI] Search cleared")
|
log.debug("UI", "Search cleared")
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
|
|
||||||
elseif action == "page_prev" then
|
elseif action == "page_prev" then
|
||||||
if currentPage > 1 then
|
if currentPage > 1 then
|
||||||
currentPage = currentPage - 1
|
currentPage = currentPage - 1
|
||||||
print("[UI] Page " .. currentPage)
|
log.debug("UI", "Page %d", currentPage)
|
||||||
end
|
end
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
|
|
||||||
elseif action == "page_next" then
|
elseif action == "page_next" then
|
||||||
if currentPage < totalPages then
|
if currentPage < totalPages then
|
||||||
currentPage = currentPage + 1
|
currentPage = currentPage + 1
|
||||||
print("[UI] Page " .. currentPage)
|
log.debug("UI", "Page %d", currentPage)
|
||||||
end
|
end
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
end
|
end
|
||||||
@@ -2364,12 +2364,12 @@ local function handleSmelterTouch(x, y)
|
|||||||
if action == "tab" then
|
if action == "tab" then
|
||||||
smelterView = data
|
smelterView = data
|
||||||
smelterPage = 1
|
smelterPage = 1
|
||||||
print("[SMELT-UI] Tab: " .. data)
|
log.debug("UI", "Tab: %s", data)
|
||||||
smelterNeedsRedraw = true
|
smelterNeedsRedraw = true
|
||||||
|
|
||||||
elseif action == "toggle_pause" then
|
elseif action == "toggle_pause" then
|
||||||
smeltingPaused = not smeltingPaused
|
smeltingPaused = not smeltingPaused
|
||||||
print("[SMELT-UI] Smelting " .. (smeltingPaused and "PAUSED" or "RESUMED"))
|
log.debug("UI", "Smelting %s", smeltingPaused and "PAUSED" or "RESUMED")
|
||||||
saveDisabledRecipes()
|
saveDisabledRecipes()
|
||||||
smelterNeedsRedraw = true
|
smelterNeedsRedraw = true
|
||||||
needsRedraw = true
|
needsRedraw = true
|
||||||
@@ -2381,13 +2381,13 @@ local function handleSmelterTouch(x, y)
|
|||||||
disabledRecipes[data] = true
|
disabledRecipes[data] = true
|
||||||
end
|
end
|
||||||
local short = data:gsub("^minecraft:", ""):gsub("_", " ")
|
local short = data:gsub("^minecraft:", ""):gsub("_", " ")
|
||||||
print("[SMELT-UI] Recipe " .. short .. ": " .. (disabledRecipes[data] and "OFF" or "ON"))
|
log.debug("UI", "Recipe %s: %s", short, disabledRecipes[data] and "OFF" or "ON")
|
||||||
saveDisabledRecipes()
|
saveDisabledRecipes()
|
||||||
smelterNeedsRedraw = true
|
smelterNeedsRedraw = true
|
||||||
|
|
||||||
elseif action == "enable_all" then
|
elseif action == "enable_all" then
|
||||||
disabledRecipes = {}
|
disabledRecipes = {}
|
||||||
print("[SMELT-UI] All recipes enabled")
|
log.debug("UI", "All recipes enabled")
|
||||||
saveDisabledRecipes()
|
saveDisabledRecipes()
|
||||||
smelterNeedsRedraw = true
|
smelterNeedsRedraw = true
|
||||||
|
|
||||||
@@ -2395,7 +2395,7 @@ local function handleSmelterTouch(x, y)
|
|||||||
for inputName in pairs(SMELTABLE) do
|
for inputName in pairs(SMELTABLE) do
|
||||||
disabledRecipes[inputName] = true
|
disabledRecipes[inputName] = true
|
||||||
end
|
end
|
||||||
print("[SMELT-UI] All recipes disabled")
|
log.debug("UI", "All recipes disabled")
|
||||||
saveDisabledRecipes()
|
saveDisabledRecipes()
|
||||||
smelterNeedsRedraw = true
|
smelterNeedsRedraw = true
|
||||||
|
|
||||||
@@ -2416,7 +2416,7 @@ local function handleSmelterTouch(x, y)
|
|||||||
local recipe = CRAFTABLE[recipeIdx]
|
local recipe = CRAFTABLE[recipeIdx]
|
||||||
if recipe then
|
if recipe then
|
||||||
local short = recipe.output:gsub("^minecraft:", ""):gsub("_", " ")
|
local short = recipe.output:gsub("^minecraft:", ""):gsub("_", " ")
|
||||||
print(string.format("[CRAFT-UI] Craft request: %s (#%d)", short, recipeIdx))
|
log.info("CRAFT", "Craft request: %s (#%d)", short, recipeIdx)
|
||||||
local ok, err = craftItem(recipeIdx)
|
local ok, err = craftItem(recipeIdx)
|
||||||
if ok then
|
if ok then
|
||||||
statusMessage = "Crafted " .. short .. " x" .. recipe.count
|
statusMessage = "Crafted " .. short .. " x" .. recipe.count
|
||||||
|
|||||||
Reference in New Issue
Block a user