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@57: local _chkAh yellowfive@57: yellowfive@57: 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 onChkMinimapClick() yellowfive@57: Amr.db.profile.minimap.hide = _chkMinimap:GetChecked() 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@57: chk:SetUserData("setting", setting) yellowfive@57: chk:SetText(text) yellowfive@57: chk:SetCallback("OnClick", onCheckClick) yellowfive@57: container:AddChild(chk) yellowfive@57: yellowfive@57: local desc = AceGUI:Create("AmrUiLabel") 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: container:AddChild(desc) yellowfive@57: yellowfive@57: return chk, desc yellowfive@57: end yellowfive@57: 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@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: container:AddChild(header) yellowfive@57: yellowfive@57: local desc, desc2 yellowfive@57: yellowfive@57: _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc) yellowfive@57: _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 0, -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@57: _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc) yellowfive@57: _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) yellowfive@57: 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@57: end yellowfive@57: yellowfive@57: function Amr:RefreshOptionsUi() yellowfive@57: yellowfive@57: if _chkMinimap then yellowfive@57: _chkMinimap:SetChecked(self.db.profile.minimap.hide) yellowfive@57: end yellowfive@57: yellowfive@57: if _chkAutoGear then yellowfive@57: _chkAutoGear:SetChecked(self.db.profile.options.autoGear) yellowfive@57: end yellowfive@57: yellowfive@57: if _chkAh then yellowfive@57: _chkAh:SetChecked(self.db.profile.options.shopAh) yellowfive@57: end yellowfive@57: end