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