-
Notifications
You must be signed in to change notification settings - Fork 0
/
Core.lua
107 lines (97 loc) · 3.06 KB
/
Core.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
local AceConfig = LibStub("AceConfig-3.0");
local AceConfigDialog = LibStub("AceConfigDialog-3.0");
local AceConfigCmd = LibStub("AceConfigCmd-3.0");
local AceDB = LibStub("AceDB-3.0");
local AceGUI = LibStub("AceGUI-3.0");
local L = LibStub("AceLocale-3.0"):GetLocale("KiNoYo_Rotation");
local KiNoYo_Rotation = LibStub("AceAddon-3.0"):NewAddon("KiNoYo_Rotation", "AceConsole-3.0");
local defaults = {
global = {
test = L["kinoyo/rotation/options/enable/defaultValue"],
enable = true
}
};
local options = {
name = L["kinoyo/rotation/options/name"],
desc = L["kinoyo/rotation/options/description"],
handler = KiNoYo_Rotation,
type = "group",
args = {
enable = {
name = L["kinoyo/rotation/options/enable/name"],
desc = L["kinoyo/rotation/options/enable/description"],
type = "toggle",
set = "SetEnableStatus",
get = "GetEnableStatus"
},
test = {
name = L["kinoyo/rotation/options/test/name"],
desc = L["kinoyo/rotation/options/test/description"],
type = "input",
set = "SetTest",
get = "GetTest"
}
}
};
-- Show the GUI if no input is supplied, otherwise handle the chat input.
function KiNoYo_Rotation:ChatCommand(input)
if not input or input:trim() == "" then
-- AceConfigDialog:Open("KiNoYo_Rotation");
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame);
else
AceConfigCmd.HandleCommand(KiNoYo_Rotation, "kinoyo", "KiNoYo_Rotation", input);
end
end
function KiNoYo_Rotation:GetEnableStatus(info)
return self:IsEnabled();
end
function KiNoYo_Rotation:SetEnableStatus(info, value)
self.db.global.enable = value;
if value then
self:Enable();
else
self:Disable();
end
end
function KiNoYo_Rotation:GetTest(info)
return self.db.global.test;
end
function KiNoYo_Rotation:SetTest(info, value)
self.db.global.test = value;
end
function KiNoYo_Rotation:OnInitialize()
-- Code that you want to run when the addon is first loaded goes here.
self:Print("KiNoYo_Rotation - loaded!");
AceConfig:RegisterOptionsTable("KiNoYo_Rotation", options);
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("KiNoYo_Rotation", L["kinoyo/rotation/options/name"]);
self:RegisterChatCommand("kinoyo", "ChatCommand");
self:RegisterChatCommand("kny", "ChatCommand");
self.db = AceDB:New("KiNoYo_RotationDB", defaults, true);
if self.db.global.enable then
self:Enable();
else
self:Disable();
end
end
function KiNoYo_Rotation:OnEnable()
-- Called when the addon is enabled
self:Print("KiNoYo_Rotation - enable!");
-- Create a container frame
local f = AceGUI:Create("Frame");
f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end);
f:SetTitle("AceGUI-3.0 Example");
f:SetStatusText("Status Bar");
f:SetLayout("Flow");
-- Create a button
local btn = AceGUI:Create("Icon");
btn:SetWidth(50);
btn:SetHeight(50);
-- Add the button to the container
f:AddChild(btn);
--local frame = CreateFrame("Frame", "Actions", UIParent);
--local image = CreateFrame("Button", "CurrentAction", UIParent);
end
function KiNoYo_Rotation:OnDisable()
-- Called when the addon is disabled
self:Print("KiNoYo_Rotation - disabled!");
end