From f8575639012a1ed75a330ae252df22182f19e129 Mon Sep 17 00:00:00 2001 From: Imbus Date: Sun, 29 Oct 2023 14:32:28 +0100 Subject: [PATCH] Prettier text output in chat --- ImbusBinds.lua | 11 ++++++--- ImbusBinds_Mainline.toc | 1 + ImbusBinds_Wrath.toc | 1 + Util.lua | 51 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 Util.lua diff --git a/ImbusBinds.lua b/ImbusBinds.lua index b922f29..35f22f2 100755 --- a/ImbusBinds.lua +++ b/ImbusBinds.lua @@ -1,3 +1,5 @@ +local _, u = ... + -- https://wowpedia.fandom.com/wiki/BindingID local myBinds = { -- Movement @@ -103,9 +105,9 @@ end local function setBindingRM(key, action) unsetBinding(action); if SetBinding(key, action) then - print("Set binding " .. key .. " to " .. action); + u.success(key .. " -> " .. action); else - print("Failed to set binding " .. key .. " to " .. action); + u.error("Failed to set binding " .. key .. " to " .. action); end end @@ -113,7 +115,8 @@ local function applyBindingSet(set) for key, action in pairs(set) do setBindingRM(key, action) end - print("Bindings set. Dont forget to reload your UI.") + u.info("Bindings set!") + u.warn("Dont forget to reload your UI.") end local function enableBars() @@ -132,6 +135,7 @@ local function enableBars() end local function BindsHandler(msg, editbox) + u.guards() if msg == "" then applyBindingSet(myBinds) enableBars() @@ -140,6 +144,7 @@ local function BindsHandler(msg, editbox) applyBindingSet(cameraBinds) end SaveBindings(1) + u.guards() end -- Register the /hello command diff --git a/ImbusBinds_Mainline.toc b/ImbusBinds_Mainline.toc index 8d753a4..76636f0 100755 --- a/ImbusBinds_Mainline.toc +++ b/ImbusBinds_Mainline.toc @@ -6,4 +6,5 @@ ## URL: https://git.silversoft.se/Imbus/ImbusBinds ## IconTexture: Interface\Icons\Inv_qiraj_jewelglyphed +Util.lua ImbusBinds.lua \ No newline at end of file diff --git a/ImbusBinds_Wrath.toc b/ImbusBinds_Wrath.toc index 7c240e6..66186cb 100755 --- a/ImbusBinds_Wrath.toc +++ b/ImbusBinds_Wrath.toc @@ -6,4 +6,5 @@ ## URL: https://git.silversoft.se/Imbus/ImbusBinds ## IconTexture: Interface\Icons\Inv_qiraj_jewelglyphed +Util.lua ImbusBinds.lua \ No newline at end of file diff --git a/Util.lua b/Util.lua new file mode 100644 index 0000000..d199e34 --- /dev/null +++ b/Util.lua @@ -0,0 +1,51 @@ +local _, u = ... + +-- Hex formatted as "AARRGGBB" +local COLOR = { + blue = "FF" .. "0000FF", + green = "FF" .. "00FF00", + red = "FF" .. "FF0000", + legendary = "FF" .. "A335EE", + heirloom = "FF" .. "E6CC80", + warning = "FF" .. "EED202", +} + +-- Wrap the text in a color code +local function colorWrap(text, colorCode) + return "|c" .. colorCode .. text .. "|r" +end + +-- Special case of the color function +local function prefix() + return colorWrap("ImbusBinds> ", COLOR.legendary) +end + +-- Special print +local function bprint(msg) + print(prefix() .. msg) +end + +-- Prints some separators +function u.guards() + local accum = "" + for _ = 1, 30 do + accum = accum .. "=" + end + print(colorWrap(accum, COLOR.legendary)) +end + +function u.info(msg) + bprint(colorWrap(msg, COLOR.heirloom)) +end + +function u.warn(msg) + bprint(colorWrap(msg, COLOR.warning)) +end + +function u.error(msg) + bprint(colorWrap(msg, COLOR.red)) +end + +function u.success(msg) + bprint(colorWrap(msg, COLOR.green)) +end \ No newline at end of file