annotate Options.lua @ 177:44ce007189e0 v83

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