From ef4a4e90074443f129ce8b21867c2a719f45394a Mon Sep 17 00:00:00 2001 From: MrOinky <61294271+MrOinky@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:12:22 +0100 Subject: [PATCH 1/3] display mod version + id in errors --- src/kristal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kristal.lua b/src/kristal.lua index cf015df6f..f746ddf61 100644 --- a/src/kristal.lua +++ b/src/kristal.lua @@ -523,6 +523,10 @@ function Kristal.errorHandler(msg) version_string = version_string .. " (" .. trimmed_commit .. ")" end -- TODO: mod version + local mod_string = "" + if Mod then + mod_string = "Mod: " .. tostring(Mod.info.id) .. " ".. tostring(Mod.info.version) + end local function draw() @@ -536,6 +540,8 @@ function Kristal.errorHandler(msg) love.graphics.setFont(smaller_font) love.graphics.printf(version_string, -20, 10, 640, "right") + love.graphics.printf(mod_string, 20, 10, 640) + love.graphics.setFont(font) local warp = 640 - pos*2 @@ -621,7 +627,7 @@ function Kristal.errorHandler(msg) local function copyToClipboard() if not love.system then return end copy_color = {0, 1, 0, 1} - love.system.setClipboardText(tostring(msg) .. "\n" .. trace .. "\n\n" .. version_string) + love.system.setClipboardText(tostring(msg) .. "\n" .. trace .. "\n\n" .. version_string .. "\n" .. mod_string) draw() end From a3ab478fd43cbf312dd5401ab4f810d5096ceeeb Mon Sep 17 00:00:00 2001 From: MrOinky <61294271+MrOinky@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:01:40 +0100 Subject: [PATCH 2/3] more error handler changes added library display, and returning to menu with gamepad or touchscreen as alternatives to keyboard --- src/kristal.lua | 54 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/kristal.lua b/src/kristal.lua index f746ddf61..dd2512af4 100644 --- a/src/kristal.lua +++ b/src/kristal.lua @@ -524,9 +524,23 @@ function Kristal.errorHandler(msg) end -- TODO: mod version local mod_string = "" + local lib_string = "" + + local w = 0 + local h = 18 if Mod then - mod_string = "Mod: " .. tostring(Mod.info.id) .. " ".. tostring(Mod.info.version) + mod_string = "Mod: " .. Mod.info.id .. " " .. (Mod.info.version or "v?.?.?") + if Utils.tableLength(Mod.libs) > 0 then + lib_string = "Libraries:" + for _, lib in pairs(Mod.libs) do + local line = (lib.info.id or "") .. " " .. (lib.info.version or "v?.?.?") + lib_string = lib_string .. "\n" .. line + w = math.max(w, #line * 7) + h = h + 16 + end + end end + local show_libraries = false local function draw() @@ -539,7 +553,6 @@ function Kristal.errorHandler(msg) Draw.setColor(1, 1, 1, 1) love.graphics.setFont(smaller_font) love.graphics.printf(version_string, -20, 10, 640, "right") - love.graphics.printf(mod_string, 20, 10, 640) love.graphics.setFont(font) @@ -619,7 +632,13 @@ function Kristal.errorHandler(msg) Draw.setColor(copy_color) love.graphics.print("Press CTRL+C to copy traceback to clipboard", 8, 480 - 20) end - Draw.setColor(1, 1, 1, 1) + + if show_libraries then + Draw.setColor(0, 0, 0, 0.7) + love.graphics.rectangle("fill", 20, 38, w + 4, h + 2) + Draw.setColor(1, 1, 1, 1) + love.graphics.printf(lib_string, 22, 40, 640, "left") + end love.graphics.present() end @@ -627,7 +646,7 @@ function Kristal.errorHandler(msg) local function copyToClipboard() if not love.system then return end copy_color = {0, 1, 0, 1} - love.system.setClipboardText(tostring(msg) .. "\n" .. trace .. "\n\n" .. version_string .. "\n" .. mod_string) + love.system.setClipboardText(tostring(msg) .. "\n" .. trace .. "\n\n" .. version_string .. "\n" .. mod_string .. "\n" .. lib_string) draw() end @@ -652,16 +671,30 @@ function Kristal.errorHandler(msg) elseif e == "touchpressed" then local name = love.window.getTitle() if #name == 0 or name == "Untitled" then name = "Game" end - local buttons = {"OK", "Cancel"} + local buttons = {"Yes", "No", enterbutton = 1, escapebutton = 2} if love.system and not critical then buttons[3] = "Copy to clipboard" end - local pressed = love.window.showMessageBox("Quit "..name.."?", "", buttons) + local errormessage = Kristal.getModOption("hardReset") and "Would you like to restart Kristal?" or "Would you like to return to the Kristal menu?" + local pressed = love.window.showMessageBox(name, errormessage, buttons) if pressed == 1 then - return 1 + + if Kristal.getModOption("hardReset") then + return "restart" + else + return "reload" + end elseif pressed == 3 then copyToClipboard() end + elseif e == "gamepadpressed" and b == "a" then + if Kristal.getModOption("hardReset") then + return "restart" + else + return "reload" + end + elseif e == "gamepadpressed" and b == "y" then + copyToClipboard() end end @@ -669,6 +702,13 @@ function Kristal.errorHandler(msg) DT = love.timer.step() end + local x, y = love.mouse:getPosition() + + show_libraries = false + if 20 < x and x < 20 + #mod_string*7 and 10 < y and y < 26 then + show_libraries = true + end + draw() love.timer.sleep(0.01) From 5b68f11d3961bf40dbf1d36a715f353b517f55cd Mon Sep 17 00:00:00 2001 From: MrOinky <61294271+MrOinky@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:19:08 +0100 Subject: [PATCH 3/3] add MrOinky to credits --- src/engine/menu/menu.lua | 6 +++--- src/kristal.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/menu/menu.lua b/src/engine/menu/menu.lua index 2f69ad23d..749a0994b 100644 --- a/src/engine/menu/menu.lua +++ b/src/engine/menu/menu.lua @@ -150,10 +150,10 @@ function Menu:enter() "Vitellary", } }, - --[[{ + { { {"GitHub Contributors", COLORS.silver}, - "", + "MrOinky", "", "", "", @@ -177,7 +177,7 @@ function Menu:enter() "", "", } - }]] + } } self.credits_page = 1 diff --git a/src/kristal.lua b/src/kristal.lua index dd2512af4..c07cff65f 100644 --- a/src/kristal.lua +++ b/src/kristal.lua @@ -522,7 +522,7 @@ function Kristal.errorHandler(msg) if trimmed_commit then version_string = version_string .. " (" .. trimmed_commit .. ")" end - -- TODO: mod version + local mod_string = "" local lib_string = ""