yellowfive@57: local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot") yellowfive@57: local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) yellowfive@57: local AceGUI = LibStub("AceGUI-3.0") yellowfive@57: yellowfive@57: local _chkMinimap yellowfive@57: local _chkAutoGear yellowfive@161: local _chkJunk yellowfive@57: local _chkAh yellowfive@91: local _chkEm yellowfive@61: local _txtScale yellowfive@61: yellowfive@61: local function onTextboxEnter(widget) yellowfive@61: local setting = widget:GetUserData("setting") yellowfive@61: local val = widget:GetText() yellowfive@61: yellowfive@61: val = tonumber(val) yellowfive@61: if not val then yellowfive@61: widget:SetText(Amr.db.profile.options[setting]) yellowfive@61: else yellowfive@61: if setting == "uiScale" then yellowfive@61: if val < 0.5 then yellowfive@61: val = 0.5 yellowfive@61: elseif val > 1.5 then yellowfive@61: val = 1.5 yellowfive@61: end yellowfive@61: end yellowfive@61: yellowfive@61: Amr.db.profile.options[setting] = val yellowfive@61: Amr:RefreshConfig() yellowfive@61: end yellowfive@61: end yellowfive@57: yellowfive@124: local function onCheckClick(widget) yellowfive@57: local setting = widget:GetUserData("setting") yellowfive@57: local val = widget:GetChecked() yellowfive@57: yellowfive@57: if setting == "minimap" then yellowfive@57: Amr.db.profile.minimap.hide = val yellowfive@57: else yellowfive@57: Amr.db.profile.options[setting] = val yellowfive@57: end yellowfive@57: yellowfive@57: Amr:RefreshConfig() yellowfive@57: end yellowfive@57: yellowfive@57: local function createCheck(container, setting, text, description) yellowfive@57: yellowfive@57: local chk = AceGUI:Create("AmrUiCheckBox") yellowfive@159: container:AddChild(chk) yellowfive@57: chk:SetUserData("setting", setting) yellowfive@57: chk:SetText(text) yellowfive@57: chk:SetCallback("OnClick", onCheckClick) yellowfive@57: yellowfive@57: local desc = AceGUI:Create("AmrUiLabel") yellowfive@124: container:AddChild(desc) yellowfive@57: desc:SetWidth(800) yellowfive@57: desc:SetText(description) yellowfive@57: desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan)) yellowfive@57: desc:SetPoint("TOPLEFT", chk.frame, "BOTTOMLEFT", 24, -3) yellowfive@57: yellowfive@57: return chk, desc yellowfive@57: end yellowfive@57: yellowfive@61: local function createSmallTextbox(container, setting, text, description) yellowfive@61: yellowfive@61: local txt = AceGUI:Create("AmrUiTextarea") yellowfive@61: txt:SetUserData("setting", setting) yellowfive@61: txt:SetMultiLine(false) yellowfive@61: txt:SetWidth(35) yellowfive@61: txt:SetHeight(24) yellowfive@61: txt:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text)) yellowfive@61: txt:SetCallback("OnEnterPressed", onTextboxEnter) yellowfive@61: container:AddChild(txt) yellowfive@61: yellowfive@61: local lbl = AceGUI:Create("AmrUiLabel") yellowfive@124: container:AddChild(lbl) yellowfive@61: lbl:SetWidth(600) yellowfive@61: lbl:SetText(text) yellowfive@61: lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text)) yellowfive@61: lbl:SetPoint("LEFT", txt.frame, "RIGHT", 6, 0) yellowfive@61: yellowfive@61: local desc = AceGUI:Create("AmrUiLabel") yellowfive@124: container:AddChild(desc) yellowfive@61: desc:SetWidth(800) yellowfive@61: desc:SetText(description) yellowfive@61: desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan)) yellowfive@61: desc:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -4) yellowfive@61: yellowfive@61: return txt, desc yellowfive@61: end yellowfive@61: yellowfive@57: -- renders the main UI for the Combat Log tab yellowfive@57: function Amr:RenderTabOptions(container) yellowfive@57: yellowfive@57: local header = AceGUI:Create("AmrUiLabel") yellowfive@124: container:AddChild(header) yellowfive@57: header:SetWidth(600) yellowfive@57: header:SetText(L.OptionsHeaderGeneral) yellowfive@57: header:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive)) yellowfive@57: header:SetPoint("TOPLEFT", container.content, "TOPLEFT", 12, -40) yellowfive@57: yellowfive@57: local desc, desc2 yellowfive@57: yellowfive@57: _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc) yellowfive@61: _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 10, -20) yellowfive@57: yellowfive@57: _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc) yellowfive@57: _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20) yellowfive@57: yellowfive@161: _chkJunk, desc = createCheck(container, "junkVendor", L.OptionsJunkVendorName, L.OptionsJunkVendorDesc) yellowfive@161: _chkJunk:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) yellowfive@161: yellowfive@161: _chkAh, desc2 = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc) yellowfive@161: _chkAh:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20) yellowfive@57: yellowfive@161: _chkEm, desc = createCheck(container, "disableEm", L.OptionsDisableEmName, L.OptionsDisableEmDesc) yellowfive@161: _chkEm:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) yellowfive@91: yellowfive@161: _txtScale, desc2 = createSmallTextbox(container, "uiScale", L.OptionsUiScaleName, L.OptionsUiScaleDesc) yellowfive@161: _txtScale:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -43, -20) yellowfive@61: yellowfive@57: -- initialize state of controls yellowfive@57: Amr:RefreshOptionsUi() yellowfive@57: end yellowfive@57: yellowfive@57: function Amr:ReleaseTabOptions() yellowfive@57: _chkMinimap = nil yellowfive@124: _chkAutoGear = nil yellowfive@161: _chkJunk = nil yellowfive@124: _chkAh = nil yellowfive@124: _chkEm = nil yellowfive@124: _txtScale = nil yellowfive@57: end yellowfive@57: yellowfive@189: -- sometimes the game doesn't repaint checkboxes when it should... doing this forces it to do so yellowfive@189: local function setCheckboxChecked(chk, val) yellowfive@189: chk:SetChecked(val) yellowfive@189: chk:SetChecked(not val) yellowfive@189: chk:SetChecked(val) yellowfive@189: end yellowfive@189: yellowfive@57: function Amr:RefreshOptionsUi() yellowfive@57: yellowfive@57: if _chkMinimap then yellowfive@189: --setCheckboxChecked(_chkMinimap, self.db.profile.minimap.hide) yellowfive@57: _chkMinimap:SetChecked(self.db.profile.minimap.hide) yellowfive@57: end yellowfive@57: yellowfive@57: if _chkAutoGear then yellowfive@189: --setCheckboxChecked(_chkAutoGear, self.db.profile.options.autoGear) yellowfive@57: _chkAutoGear:SetChecked(self.db.profile.options.autoGear) yellowfive@57: end yellowfive@161: yellowfive@161: if _chkJunk then yellowfive@189: --setCheckboxChecked(_chkJunk, self.db.profile.options.junkVendor) yellowfive@161: _chkJunk:SetChecked(self.db.profile.options.junkVendor) yellowfive@161: end yellowfive@161: yellowfive@57: if _chkAh then yellowfive@189: --setCheckboxChecked(_chkAh, self.db.profile.options.shopAh) yellowfive@57: _chkAh:SetChecked(self.db.profile.options.shopAh) yellowfive@57: end yellowfive@61: yellowfive@91: if _chkEm then yellowfive@189: --setCheckboxChecked(_chkEm, self.db.profile.options.disableEm) yellowfive@91: _chkEm:SetChecked(self.db.profile.options.disableEm) yellowfive@91: end yellowfive@91: yellowfive@61: if _txtScale then yellowfive@61: _txtScale:SetText(self.db.profile.options.uiScale) yellowfive@61: _txtScale:ClearFocus() yellowfive@61: end yellowfive@122: end