yellowfive@57
|
1 local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot")
|
yellowfive@57
|
2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true)
|
yellowfive@57
|
3 local AceGUI = LibStub("AceGUI-3.0")
|
yellowfive@57
|
4
|
yellowfive@57
|
5 local _chkMinimap
|
yellowfive@57
|
6 local _chkAutoGear
|
yellowfive@57
|
7 local _chkAh
|
yellowfive@57
|
8
|
yellowfive@57
|
9 local function onCheckClick(widget)
|
yellowfive@57
|
10 local setting = widget:GetUserData("setting")
|
yellowfive@57
|
11 local val = widget:GetChecked()
|
yellowfive@57
|
12
|
yellowfive@57
|
13 if setting == "minimap" then
|
yellowfive@57
|
14 Amr.db.profile.minimap.hide = val
|
yellowfive@57
|
15 else
|
yellowfive@57
|
16 Amr.db.profile.options[setting] = val
|
yellowfive@57
|
17 end
|
yellowfive@57
|
18
|
yellowfive@57
|
19 Amr:RefreshConfig()
|
yellowfive@57
|
20 end
|
yellowfive@57
|
21
|
yellowfive@57
|
22 local function onChkMinimapClick()
|
yellowfive@57
|
23 Amr.db.profile.minimap.hide = _chkMinimap:GetChecked()
|
yellowfive@57
|
24 Amr:RefreshConfig()
|
yellowfive@57
|
25 end
|
yellowfive@57
|
26
|
yellowfive@57
|
27 local function createCheck(container, setting, text, description)
|
yellowfive@57
|
28
|
yellowfive@57
|
29 local chk = AceGUI:Create("AmrUiCheckBox")
|
yellowfive@57
|
30 chk:SetUserData("setting", setting)
|
yellowfive@57
|
31 chk:SetText(text)
|
yellowfive@57
|
32 chk:SetCallback("OnClick", onCheckClick)
|
yellowfive@57
|
33 container:AddChild(chk)
|
yellowfive@57
|
34
|
yellowfive@57
|
35 local desc = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
36 desc:SetWidth(800)
|
yellowfive@57
|
37 desc:SetText(description)
|
yellowfive@57
|
38 desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan))
|
yellowfive@57
|
39 desc:SetPoint("TOPLEFT", chk.frame, "BOTTOMLEFT", 24, -3)
|
yellowfive@57
|
40 container:AddChild(desc)
|
yellowfive@57
|
41
|
yellowfive@57
|
42 return chk, desc
|
yellowfive@57
|
43 end
|
yellowfive@57
|
44
|
yellowfive@57
|
45 -- renders the main UI for the Combat Log tab
|
yellowfive@57
|
46 function Amr:RenderTabOptions(container)
|
yellowfive@57
|
47
|
yellowfive@57
|
48 local header = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
49 header:SetWidth(600)
|
yellowfive@57
|
50 header:SetText(L.OptionsHeaderGeneral)
|
yellowfive@57
|
51 header:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive))
|
yellowfive@57
|
52 header:SetPoint("TOPLEFT", container.content, "TOPLEFT", 12, -40)
|
yellowfive@57
|
53 container:AddChild(header)
|
yellowfive@57
|
54
|
yellowfive@57
|
55 local desc, desc2
|
yellowfive@57
|
56
|
yellowfive@57
|
57 _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc)
|
yellowfive@57
|
58 _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 0, -20)
|
yellowfive@57
|
59
|
yellowfive@57
|
60 _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc)
|
yellowfive@57
|
61 _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20)
|
yellowfive@57
|
62
|
yellowfive@57
|
63 _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc)
|
yellowfive@57
|
64 _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20)
|
yellowfive@57
|
65
|
yellowfive@57
|
66 -- initialize state of controls
|
yellowfive@57
|
67 Amr:RefreshOptionsUi()
|
yellowfive@57
|
68 end
|
yellowfive@57
|
69
|
yellowfive@57
|
70 function Amr:ReleaseTabOptions()
|
yellowfive@57
|
71 _chkMinimap = nil
|
yellowfive@57
|
72 end
|
yellowfive@57
|
73
|
yellowfive@57
|
74 function Amr:RefreshOptionsUi()
|
yellowfive@57
|
75
|
yellowfive@57
|
76 if _chkMinimap then
|
yellowfive@57
|
77 _chkMinimap:SetChecked(self.db.profile.minimap.hide)
|
yellowfive@57
|
78 end
|
yellowfive@57
|
79
|
yellowfive@57
|
80 if _chkAutoGear then
|
yellowfive@57
|
81 _chkAutoGear:SetChecked(self.db.profile.options.autoGear)
|
yellowfive@57
|
82 end
|
yellowfive@57
|
83
|
yellowfive@57
|
84 if _chkAh then
|
yellowfive@57
|
85 _chkAh:SetChecked(self.db.profile.options.shopAh)
|
yellowfive@57
|
86 end
|
yellowfive@57
|
87 end |