Skip to content

Commit

Permalink
✨ Added toggle command
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Sep 15, 2019
1 parent c907c47 commit 8de8481
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 10 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ I have bad memory so I made this. A todolist/checklist AddOn for World of Warcra

**I have tested it only in WoW Classic**

## How to install it
- Extract the files on your WoW Addon folder, usually `C:\Program Files (x86)\World of Warcraft\_classic_\Interface\AddOns`.
- Ensure that the .lua files are not spread inside the AddOns folder, but rather, inside the correct `TodoChecklister` folder.
- Your files shoud look like this:
```
WowFolder
\
\
Interface
\
\
AddOns
\
\
TodoChecklister
\
\
TodoChecklister.toc/*.lua files/Any other addon file and folder
```

## How to use it
- If you happen to have any AddOn that integrates with `AceAddon` or `LibDBIcon`, a "list" button should appear on your minimap and you can toggle the addon by clicking it
![mapButton](./button.png)
- Or you can also type `/todo tg` on your chatbox to toggle the window

## List of slash commands
- **/todo tg** - Toggle the Todo window
- **/todo help** - Display available commands on chat

## 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)
Expand Down
3 changes: 2 additions & 1 deletion TodoChecklister.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Notes: I have bad memory so I made this. A todolist/checklist AddOn for World of Warcraft.
## Version: 1.0
## DefaultState: enabled
## SavedVariables: TodoChecklisterDB
## SavedVariables: TodoChecklisterDB, TodoChecklisterMapIcon

constants.lua
tableUtils.lua
Expand All @@ -14,4 +14,5 @@ debug.lua
components\components.xml

chat.lua
minimapIcon.lua
init.lua
Binary file added button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ local Utils = core.Utils;
Chat.command = "/todo";
Chat.commands = {
["tg"] = function()
core.TodoUI.Toggle();
core.TodoChecklisterFrame:Toggle()
end,

["help"] = function()
print(" ");
Chat:Print("List of slash commands:")
-- Chat:Print("|cff00cc66/todo config|r - shows config menu");
-- Chat:Print("|cff00cc66/todo help|r - shows help info");
Chat:Print("|cff00cc66/todo tg|r - Toggle todo window");
print(" ");
end,

["example"] = {
["test"] = function(...)
Chat:Print("My Value:", tostringall(...));
end
}
-- ["example"] = {
-- ["test"] = function(...)
-- Chat:Print("My Value:", tostringall(...));
-- end
-- }
};

--------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion components/TodoChecklister.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ function TodoChecklisterFrame:CheckItem(text)
end
end

function TodoChecklisterFrame:Toggle()
if (self.frame:IsShown()) then
self.frame:Hide();
else
self.frame:Show();
end
end

--------------------------------------
-- TodoChecklisterFrame Events
--------------------------------------
Expand Down Expand Up @@ -96,7 +104,7 @@ function TodoChecklisterFrame:OnLoad(frame)
HybridScrollFrame_CreateButtons(frame.ScrollFrame, "TodoItemTemplate")

-- Display the frame
frame:Show()
self:Toggle();
end

function TodoChecklisterFrame:OnShow(frame)
Expand Down
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function core:Init(event, name)

core.Debug:Init();
core.Chat:Init();
core.MinimapIcon:Init();

if (#TodoChecklisterDB > 0) then
local completedList = core.TableUtils:Filter(TodoChecklisterDB, function(x) return x.isChecked == true end)
Expand Down
27 changes: 27 additions & 0 deletions minimapIcon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--------------------------------------
-- Namespaces
--------------------------------------
local addonName, core = ...;
core.MinimapIcon = {}; -- adds Config table to addon namespace

local MinimapIcon = core.MinimapIcon;
local Constants = core.Constants;

--------------------------------------
-- MinimapIcon functions
--------------------------------------
function MinimapIcon:Init()
if type(TodoChecklisterMapIcon) ~= "table" then
TodoChecklisterMapIcon = { hide=false }
end
if LibStub("LibDBIcon-1.0", true) then
local minimapIconLDB = LibStub("LibDataBroker-1.1"):NewDataObject(addonName.."MinimapIcon", {
type = "data source",
text = addonName,
icon = "Interface\\Icons\\INV_Misc_Note_03",
OnClick = function (self, button) core.TodoChecklisterFrame:Toggle() end
});

LibStub("LibDBIcon-1.0"):Register(addonName, minimapIconLDB, TodoChecklisterMapIcon)
end
end

0 comments on commit 8de8481

Please sign in to comment.