-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathORB_Options.lua
More file actions
152 lines (128 loc) · 3.96 KB
/
ORB_Options.lua
File metadata and controls
152 lines (128 loc) · 3.96 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then
return
end
-----------------------------------------------------------------------------------
-- Info on panels: http://www.wowwiki.com/Using_the_Interface_Options_Addons_panel
-----------------------------------------------------------------------------------
ORB_Options = {};
function ORB_Options:init()
--
-- Make sure we have our configuration available
--
if ( not ORB_Config ) then
if( TRB_Config ) then
ORB_Config = TRB_Config;
TRB_Config = nil;
else
self:ResetConfig();
end
end
--
-- Create settings panel for OneRuneBar under the addon settings in the Blizzard UI
--
local panel = CreateFrame("frame", "OneRuneBar_Options", UIParent);
panel.name = "One Rune Bar";
panel.okay = function() ORB_Options:Okay(ORB_Options); end
panel.default = function() ORB_Options:Default(ORB_Options); end
--
-- Main panel
--
local xoff, yoff = 20, -20;
local header = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge");
header:SetPoint("TOPLEFT", panel, "TOPLEFT", xoff, yoff);
header:SetText(panel.name.." v"..GetAddOnMetadata("Onerunebar", "Version") );
panel.header = header;
local function createSlider(name, textFormat, yoffset, getter, setter)
local slider = CreateFrame("slider", name, panel, "OptionsSliderTemplate");
slider:SetPoint("TOPLEFT", panel, "TOPLEFT", xoff, yoff+yoffset);
slider:SetWidth(200);
slider:SetHeight(20);
slider:SetOrientation("HORIZONTAL");
slider:SetMinMaxValues(0, 1.0);
slider:SetValue(1);
slider:SetValueStep(0.05);
_G[slider:GetName().."Low"]:SetText("0.0");
_G[slider:GetName().."High"]:SetText("1.0");
slider.Text = _G[slider:GetName().."Text"];
slider:SetScript("OnValueChanged", function(self, value)
self.Text:SetText(format(textFormat, value))
setter(OneRuneBar, value);
end);
slider:SetValue(getter(OneRuneBar));
return slider;
end
-- OOC Alpha
self.OOCSlider = createSlider("ORB_OOCSlider", "Out of Combat (OOC) alpha: %.2f",
-50, OneRuneBar.Config_GetOOCAlpha, OneRuneBar.Config_SetOOCAlpha);
self.OOCNotAllReadySlider = createSlider("ORB_OOCNotAllReadySlider", "OOC alpha while still recharging %.2f",
-100, OneRuneBar.Config_GetOOCNotAllReadyAlpha, OneRuneBar.Config_SetOOCNotAllReadyAlpha);
--
-- Add panel to blizzards addon config
--
self.panel = panel;
InterfaceOptions_AddCategory(self.panel);
--
-- Add module panels to blizzards addon config
--
for name, m in pairs(OneRuneBar.modules) do
if( m.InitOptions ) then
m:InitOptions(self.panel);
end
end
end
function ORB_Options:ResetConfig()
DEFAULT_CHAT_FRAME:AddMessage("ORB: Default config loaded.");
ORB_Config = nil;
ORB_Config = {};
-- Copy default settings
ORB_Config.OOC_Alpha = ORB_Config_Defaults.OOC_Alpha;
end
function ORB_Options:Okay()
--
-- Call module panels
--
for name, m in pairs(OneRuneBar.modules) do
if( m._OnOkay ) then
m:_OnOkay();
end
end
-- Restart modules
OneRuneBar:StartModules();
end
function ORB_Options:Default()
self:ResetConfig();
self.OOCSlider:SetValue(ORB_Config_Defaults.OOC_Alpha);
--
-- Call module panels
--
for name, m in pairs(OneRuneBar.modules) do
if( m._OnDefault ) then
m:_OnDefault();
end
end
end
-- add Options to ORB
OneRuneBar.Options = ORB_Options;
---
--- Slash handling
---
SLASH_ORB1, SLASH_ORB2 = "/orb", "/onerunebar";
local function ORB_SlashHandler(msg, editbox)
-- InterfaceOptionsFrame_OpenToCategory(ORB_Options.panel);
-- return;
if(msg == "config") then
InterfaceOptionsFrame_OpenToCategory(ORB_Options.panel.name);
InterfaceOptionsFrame_OpenToCategory(ORB_Options.panel.name);
elseif( not msg or msg=="" or msg=="lock" or msg=="unlock" ) then
if( OneRuneBar.isLocked ) then
OneRuneBar:Unlock();
else
OneRuneBar:Lock();
end
else
DEFAULT_CHAT_FRAME:AddMessage("Usage:");
DEFAULT_CHAT_FRAME:AddMessage(" /orb - Lock/Unlock");
DEFAULT_CHAT_FRAME:AddMessage(" /orb config - Open configuration.");
end
end
SlashCmdList["ORB"] = ORB_SlashHandler;