diff --git a/README.md b/README.md index 77a1131..bf80498 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ # TodoChecklister I have bad memory so I made this. A todolist/checklist AddOn for World of Warcraft +![demoGif](./demo.gif) + +**I have tested it only in WoW Classic** + ## Reference material - [A Guide and Reference for Creating WoW Addons: WoW Programming](http://garde.sylvanas.free.fr/ressources/Guides/Macros-Addons/Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons.pdf) diff --git a/constants.lua b/constants.lua index 87771d1..03073fb 100644 --- a/constants.lua +++ b/constants.lua @@ -12,8 +12,8 @@ local Constants = core.Constants; Constants.debugMode = true; Constants.addonName = addonName; Constants.theme = { - red = 0, - green = 0.8, -- 204/255 + red = 0.8, -- 204/255 + green = 0.2, -- 51/255 blue = 1, - hex = "00ccff" + hex = "cc33ff" }; \ No newline at end of file diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..b75e67b Binary files /dev/null and b/demo.gif differ diff --git a/init.lua b/init.lua index bce4ae3..5b390cc 100644 --- a/init.lua +++ b/init.lua @@ -10,8 +10,41 @@ function core:Init(event, name) core.Debug:Init(); core.Chat:Init(); - - core.Chat:Print("All loaded :)"); + + if (#TodoChecklisterDB > 0) then + local completedList = core.TableUtils:Filter(TodoChecklisterDB, function(x) return x.isChecked == true end) + local notList = core.TableUtils:Filter(TodoChecklisterDB, function(x) return x.isChecked == false end) + + if (#completedList > 0 and #notList > 0) then + local completedTaskPlural = "" + if (#completedList > 1) then + completedTaskPlural = "tasks" + else + completedTaskPlural = "task" + end + + local notTaskPlural = "" + if (#notList > 1) then + notTaskPlural = "tasks" + else + notTaskPlural = "task" + end + + core.Chat:Print("You have |cff6cf900"..tostring(#completedList).."|r completed "..completedTaskPlural.." and |cffff0000"..tostring(#notList).."|r pending "..notTaskPlural); + elseif (#completedList > 0) then + core.Chat:Print("You have completed all your tasks"); + elseif (#notList > 0) then + local taskPlural = "" + if (#notList > 1) then + taskPlural = "tasks" + else + taskPlural = "task" + end + core.Chat:Print("You have |cffff0000"..tostring(#notList).."|r pending "..taskPlural); + end + else + core.Chat:Print("You have no pending tasks."); + end end local events = CreateFrame("Frame"); diff --git a/tableUtils.lua b/tableUtils.lua index 7a460a5..21caf75 100644 --- a/tableUtils.lua +++ b/tableUtils.lua @@ -13,4 +13,12 @@ function TableUtils:IndexOf(tb, comparator) for i=1, #tb do if(comparator(tb[i])) then return i end end +end + +function TableUtils:Filter(tb, comparator) + local newTb = {}; + for i=1, #tb do + if(comparator(tb[i])) then table.insert(newTb, #newTb+1, tb[i]) end + end + return newTb end \ No newline at end of file