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@91
|
8 local _chkEm
|
yellowfive@61
|
9 local _txtScale
|
yellowfive@61
|
10
|
yellowfive@61
|
11 local function onTextboxEnter(widget)
|
yellowfive@61
|
12 local setting = widget:GetUserData("setting")
|
yellowfive@61
|
13 local val = widget:GetText()
|
yellowfive@61
|
14
|
yellowfive@61
|
15 val = tonumber(val)
|
yellowfive@61
|
16 if not val then
|
yellowfive@61
|
17 widget:SetText(Amr.db.profile.options[setting])
|
yellowfive@61
|
18 else
|
yellowfive@61
|
19 if setting == "uiScale" then
|
yellowfive@61
|
20 if val < 0.5 then
|
yellowfive@61
|
21 val = 0.5
|
yellowfive@61
|
22 elseif val > 1.5 then
|
yellowfive@61
|
23 val = 1.5
|
yellowfive@61
|
24 end
|
yellowfive@61
|
25 end
|
yellowfive@61
|
26
|
yellowfive@61
|
27 Amr.db.profile.options[setting] = val
|
yellowfive@61
|
28 Amr:RefreshConfig()
|
yellowfive@61
|
29 end
|
yellowfive@61
|
30 end
|
yellowfive@57
|
31
|
yellowfive@57
|
32 local function onCheckClick(widget)
|
yellowfive@57
|
33 local setting = widget:GetUserData("setting")
|
yellowfive@57
|
34 local val = widget:GetChecked()
|
yellowfive@57
|
35
|
yellowfive@57
|
36 if setting == "minimap" then
|
yellowfive@57
|
37 Amr.db.profile.minimap.hide = val
|
yellowfive@57
|
38 else
|
yellowfive@57
|
39 Amr.db.profile.options[setting] = val
|
yellowfive@57
|
40 end
|
yellowfive@57
|
41
|
yellowfive@57
|
42 Amr:RefreshConfig()
|
yellowfive@57
|
43 end
|
yellowfive@57
|
44
|
yellowfive@57
|
45 local function onChkMinimapClick()
|
yellowfive@57
|
46 Amr.db.profile.minimap.hide = _chkMinimap:GetChecked()
|
yellowfive@57
|
47 Amr:RefreshConfig()
|
yellowfive@57
|
48 end
|
yellowfive@57
|
49
|
yellowfive@57
|
50 local function createCheck(container, setting, text, description)
|
yellowfive@57
|
51
|
yellowfive@57
|
52 local chk = AceGUI:Create("AmrUiCheckBox")
|
yellowfive@57
|
53 chk:SetUserData("setting", setting)
|
yellowfive@57
|
54 chk:SetText(text)
|
yellowfive@57
|
55 chk:SetCallback("OnClick", onCheckClick)
|
yellowfive@57
|
56 container:AddChild(chk)
|
yellowfive@57
|
57
|
yellowfive@57
|
58 local desc = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
59 desc:SetWidth(800)
|
yellowfive@57
|
60 desc:SetText(description)
|
yellowfive@57
|
61 desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan))
|
yellowfive@57
|
62 desc:SetPoint("TOPLEFT", chk.frame, "BOTTOMLEFT", 24, -3)
|
yellowfive@57
|
63 container:AddChild(desc)
|
yellowfive@57
|
64
|
yellowfive@57
|
65 return chk, desc
|
yellowfive@57
|
66 end
|
yellowfive@57
|
67
|
yellowfive@61
|
68 local function createSmallTextbox(container, setting, text, description)
|
yellowfive@61
|
69
|
yellowfive@61
|
70 local txt = AceGUI:Create("AmrUiTextarea")
|
yellowfive@61
|
71 txt:SetUserData("setting", setting)
|
yellowfive@61
|
72 txt:SetMultiLine(false)
|
yellowfive@61
|
73 txt:SetWidth(35)
|
yellowfive@61
|
74 txt:SetHeight(24)
|
yellowfive@61
|
75 txt:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
|
yellowfive@61
|
76 txt:SetCallback("OnEnterPressed", onTextboxEnter)
|
yellowfive@61
|
77 container:AddChild(txt)
|
yellowfive@61
|
78
|
yellowfive@61
|
79 local lbl = AceGUI:Create("AmrUiLabel")
|
yellowfive@61
|
80 lbl:SetWidth(600)
|
yellowfive@61
|
81 lbl:SetText(text)
|
yellowfive@61
|
82 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
|
yellowfive@61
|
83 lbl:SetPoint("LEFT", txt.frame, "RIGHT", 6, 0)
|
yellowfive@61
|
84 container:AddChild(lbl)
|
yellowfive@61
|
85
|
yellowfive@61
|
86 local desc = AceGUI:Create("AmrUiLabel")
|
yellowfive@61
|
87 desc:SetWidth(800)
|
yellowfive@61
|
88 desc:SetText(description)
|
yellowfive@61
|
89 desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan))
|
yellowfive@61
|
90 desc:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -4)
|
yellowfive@61
|
91 container:AddChild(desc)
|
yellowfive@61
|
92
|
yellowfive@61
|
93 return txt, desc
|
yellowfive@61
|
94 end
|
yellowfive@61
|
95
|
yellowfive@57
|
96 -- renders the main UI for the Combat Log tab
|
yellowfive@57
|
97 function Amr:RenderTabOptions(container)
|
yellowfive@57
|
98
|
yellowfive@57
|
99 local header = AceGUI:Create("AmrUiLabel")
|
yellowfive@57
|
100 header:SetWidth(600)
|
yellowfive@57
|
101 header:SetText(L.OptionsHeaderGeneral)
|
yellowfive@57
|
102 header:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive))
|
yellowfive@57
|
103 header:SetPoint("TOPLEFT", container.content, "TOPLEFT", 12, -40)
|
yellowfive@57
|
104 container:AddChild(header)
|
yellowfive@57
|
105
|
yellowfive@57
|
106 local desc, desc2
|
yellowfive@57
|
107
|
yellowfive@57
|
108 _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc)
|
yellowfive@61
|
109 _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 10, -20)
|
yellowfive@57
|
110
|
yellowfive@57
|
111 _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc)
|
yellowfive@57
|
112 _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20)
|
yellowfive@57
|
113
|
yellowfive@57
|
114 _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc)
|
yellowfive@57
|
115 _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20)
|
yellowfive@57
|
116
|
yellowfive@91
|
117 _chkEm, desc2 = createCheck(container, "disableEm", L.OptionsDisableEmName, L.OptionsDisableEmDesc)
|
yellowfive@91
|
118 _chkEm:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20)
|
yellowfive@91
|
119
|
yellowfive@91
|
120 _txtScale, desc = createSmallTextbox(container, "uiScale", L.OptionsUiScaleName, L.OptionsUiScaleDesc)
|
yellowfive@91
|
121 _txtScale:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -43, -20)
|
yellowfive@61
|
122
|
yellowfive@57
|
123 -- initialize state of controls
|
yellowfive@57
|
124 Amr:RefreshOptionsUi()
|
yellowfive@57
|
125 end
|
yellowfive@57
|
126
|
yellowfive@57
|
127 function Amr:ReleaseTabOptions()
|
yellowfive@57
|
128 _chkMinimap = nil
|
yellowfive@57
|
129 end
|
yellowfive@57
|
130
|
yellowfive@57
|
131 function Amr:RefreshOptionsUi()
|
yellowfive@57
|
132
|
yellowfive@57
|
133 if _chkMinimap then
|
yellowfive@57
|
134 _chkMinimap:SetChecked(self.db.profile.minimap.hide)
|
yellowfive@57
|
135 end
|
yellowfive@57
|
136
|
yellowfive@57
|
137 if _chkAutoGear then
|
yellowfive@57
|
138 _chkAutoGear:SetChecked(self.db.profile.options.autoGear)
|
yellowfive@57
|
139 end
|
yellowfive@57
|
140
|
yellowfive@57
|
141 if _chkAh then
|
yellowfive@57
|
142 _chkAh:SetChecked(self.db.profile.options.shopAh)
|
yellowfive@57
|
143 end
|
yellowfive@61
|
144
|
yellowfive@91
|
145 if _chkEm then
|
yellowfive@91
|
146 _chkEm:SetChecked(self.db.profile.options.disableEm)
|
yellowfive@91
|
147 end
|
yellowfive@91
|
148
|
yellowfive@61
|
149 if _txtScale then
|
yellowfive@61
|
150 _txtScale:SetText(self.db.profile.options.uiScale)
|
yellowfive@61
|
151 _txtScale:ClearFocus()
|
yellowfive@61
|
152 end
|
yellowfive@122
|
153 end
|