comparison Options.lua @ 61:cf2b6b9a8337 v23

6.2 update, shopping list bug fixes, ui scale option
author yellowfive
date Tue, 23 Jun 2015 00:27:21 -0700
parents 01b63b8ed811
children b8e9664d3229
comparison
equal deleted inserted replaced
60:017c05f42fd4 61:cf2b6b9a8337
3 local AceGUI = LibStub("AceGUI-3.0") 3 local AceGUI = LibStub("AceGUI-3.0")
4 4
5 local _chkMinimap 5 local _chkMinimap
6 local _chkAutoGear 6 local _chkAutoGear
7 local _chkAh 7 local _chkAh
8 local _txtScale
9
10 local function onTextboxEnter(widget)
11 local setting = widget:GetUserData("setting")
12 local val = widget:GetText()
13
14 val = tonumber(val)
15 if not val then
16 widget:SetText(Amr.db.profile.options[setting])
17 else
18 if setting == "uiScale" then
19 if val < 0.5 then
20 val = 0.5
21 elseif val > 1.5 then
22 val = 1.5
23 end
24 end
25
26 Amr.db.profile.options[setting] = val
27 Amr:RefreshConfig()
28 end
29 end
8 30
9 local function onCheckClick(widget) 31 local function onCheckClick(widget)
10 local setting = widget:GetUserData("setting") 32 local setting = widget:GetUserData("setting")
11 local val = widget:GetChecked() 33 local val = widget:GetChecked()
12 34
40 container:AddChild(desc) 62 container:AddChild(desc)
41 63
42 return chk, desc 64 return chk, desc
43 end 65 end
44 66
67 local function createSmallTextbox(container, setting, text, description)
68
69 local txt = AceGUI:Create("AmrUiTextarea")
70 txt:SetUserData("setting", setting)
71 txt:SetMultiLine(false)
72 txt:SetWidth(35)
73 txt:SetHeight(24)
74 txt:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
75 txt:SetCallback("OnEnterPressed", onTextboxEnter)
76 container:AddChild(txt)
77
78 local lbl = AceGUI:Create("AmrUiLabel")
79 lbl:SetWidth(600)
80 lbl:SetText(text)
81 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
82 lbl:SetPoint("LEFT", txt.frame, "RIGHT", 6, 0)
83 container:AddChild(lbl)
84
85 local desc = AceGUI:Create("AmrUiLabel")
86 desc:SetWidth(800)
87 desc:SetText(description)
88 desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan))
89 desc:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -4)
90 container:AddChild(desc)
91
92 return txt, desc
93 end
94
45 -- renders the main UI for the Combat Log tab 95 -- renders the main UI for the Combat Log tab
46 function Amr:RenderTabOptions(container) 96 function Amr:RenderTabOptions(container)
47 97
48 local header = AceGUI:Create("AmrUiLabel") 98 local header = AceGUI:Create("AmrUiLabel")
49 header:SetWidth(600) 99 header:SetWidth(600)
53 container:AddChild(header) 103 container:AddChild(header)
54 104
55 local desc, desc2 105 local desc, desc2
56 106
57 _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc) 107 _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc)
58 _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 0, -20) 108 _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 10, -20)
59 109
60 _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc) 110 _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc)
61 _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20) 111 _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20)
62 112
63 _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc) 113 _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc)
64 _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) 114 _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20)
115
116 _txtScale, desc2 = createSmallTextbox(container, "uiScale", L.OptionsUiScaleName, L.OptionsUiScaleDesc)
117 _txtScale:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -43, -20)
65 118
66 -- initialize state of controls 119 -- initialize state of controls
67 Amr:RefreshOptionsUi() 120 Amr:RefreshOptionsUi()
68 end 121 end
69 122
82 end 135 end
83 136
84 if _chkAh then 137 if _chkAh then
85 _chkAh:SetChecked(self.db.profile.options.shopAh) 138 _chkAh:SetChecked(self.db.profile.options.shopAh)
86 end 139 end
140
141 if _txtScale then
142 _txtScale:SetText(self.db.profile.options.uiScale)
143 _txtScale:ClearFocus()
144 end
87 end 145 end