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 action, data = hitTest(x, y)
|
||||
if not action then
|
||||
print("[TOUCH] No zone hit")
|
||||
log.debug("TOUCH", "No zone hit")
|
||||
return
|
||||
end
|
||||
|
||||
if action == "amount" then
|
||||
selectedAmount = data
|
||||
print("[UI] Amount set to " .. data)
|
||||
log.debug("UI", "Amount set to %s", data)
|
||||
needsRedraw = true
|
||||
|
||||
elseif action == "order" then
|
||||
@@ -2298,11 +2298,11 @@ local function handleTouch(x, y)
|
||||
statusColor = colors.cyan
|
||||
statusTimer = 3
|
||||
needsRedraw = true
|
||||
print("[UI] Manual refresh")
|
||||
log.debug("UI", "Manual refresh")
|
||||
|
||||
elseif action == "kb_toggle" then
|
||||
showKeyboard = not showKeyboard
|
||||
print("[UI] Keyboard " .. (showKeyboard and "open" or "closed"))
|
||||
log.debug("UI", "Keyboard %s", showKeyboard and "open" or "closed")
|
||||
needsRedraw = true
|
||||
|
||||
elseif action == "kb_key" then
|
||||
@@ -2328,26 +2328,26 @@ local function handleTouch(x, y)
|
||||
|
||||
elseif action == "kb_done" then
|
||||
showKeyboard = false
|
||||
print("[UI] Keyboard closed")
|
||||
log.debug("UI", "Keyboard closed")
|
||||
needsRedraw = true
|
||||
|
||||
elseif action == "kb_clear" then
|
||||
searchQuery = ""
|
||||
currentPage = 1
|
||||
print("[UI] Search cleared")
|
||||
log.debug("UI", "Search cleared")
|
||||
needsRedraw = true
|
||||
|
||||
elseif action == "page_prev" then
|
||||
if currentPage > 1 then
|
||||
currentPage = currentPage - 1
|
||||
print("[UI] Page " .. currentPage)
|
||||
log.debug("UI", "Page %d", currentPage)
|
||||
end
|
||||
needsRedraw = true
|
||||
|
||||
elseif action == "page_next" then
|
||||
if currentPage < totalPages then
|
||||
currentPage = currentPage + 1
|
||||
print("[UI] Page " .. currentPage)
|
||||
log.debug("UI", "Page %d", currentPage)
|
||||
end
|
||||
needsRedraw = true
|
||||
end
|
||||
@@ -2364,12 +2364,12 @@ local function handleSmelterTouch(x, y)
|
||||
if action == "tab" then
|
||||
smelterView = data
|
||||
smelterPage = 1
|
||||
print("[SMELT-UI] Tab: " .. data)
|
||||
log.debug("UI", "Tab: %s", data)
|
||||
smelterNeedsRedraw = true
|
||||
|
||||
elseif action == "toggle_pause" then
|
||||
smeltingPaused = not smeltingPaused
|
||||
print("[SMELT-UI] Smelting " .. (smeltingPaused and "PAUSED" or "RESUMED"))
|
||||
log.debug("UI", "Smelting %s", smeltingPaused and "PAUSED" or "RESUMED")
|
||||
saveDisabledRecipes()
|
||||
smelterNeedsRedraw = true
|
||||
needsRedraw = true
|
||||
@@ -2381,13 +2381,13 @@ local function handleSmelterTouch(x, y)
|
||||
disabledRecipes[data] = true
|
||||
end
|
||||
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()
|
||||
smelterNeedsRedraw = true
|
||||
|
||||
elseif action == "enable_all" then
|
||||
disabledRecipes = {}
|
||||
print("[SMELT-UI] All recipes enabled")
|
||||
log.debug("UI", "All recipes enabled")
|
||||
saveDisabledRecipes()
|
||||
smelterNeedsRedraw = true
|
||||
|
||||
@@ -2395,7 +2395,7 @@ local function handleSmelterTouch(x, y)
|
||||
for inputName in pairs(SMELTABLE) do
|
||||
disabledRecipes[inputName] = true
|
||||
end
|
||||
print("[SMELT-UI] All recipes disabled")
|
||||
log.debug("UI", "All recipes disabled")
|
||||
saveDisabledRecipes()
|
||||
smelterNeedsRedraw = true
|
||||
|
||||
@@ -2416,7 +2416,7 @@ local function handleSmelterTouch(x, y)
|
||||
local recipe = CRAFTABLE[recipeIdx]
|
||||
if recipe then
|
||||
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)
|
||||
if ok then
|
||||
statusMessage = "Crafted " .. short .. " x" .. recipe.count
|
||||
|
||||
Reference in New Issue
Block a user