Mercurial > wow > askmrrobot
diff Options.lua @ 57:01b63b8ed811 v21
total rewrite to version 21
author | yellowfive |
---|---|
date | Fri, 05 Jun 2015 11:05:15 -0700 |
parents | |
children | cf2b6b9a8337 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Options.lua Fri Jun 05 11:05:15 2015 -0700 @@ -0,0 +1,87 @@ +local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot") +local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) +local AceGUI = LibStub("AceGUI-3.0") + +local _chkMinimap +local _chkAutoGear +local _chkAh + +local function onCheckClick(widget) + local setting = widget:GetUserData("setting") + local val = widget:GetChecked() + + if setting == "minimap" then + Amr.db.profile.minimap.hide = val + else + Amr.db.profile.options[setting] = val + end + + Amr:RefreshConfig() +end + +local function onChkMinimapClick() + Amr.db.profile.minimap.hide = _chkMinimap:GetChecked() + Amr:RefreshConfig() +end + +local function createCheck(container, setting, text, description) + + local chk = AceGUI:Create("AmrUiCheckBox") + chk:SetUserData("setting", setting) + chk:SetText(text) + chk:SetCallback("OnClick", onCheckClick) + container:AddChild(chk) + + local desc = AceGUI:Create("AmrUiLabel") + desc:SetWidth(800) + desc:SetText(description) + desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan)) + desc:SetPoint("TOPLEFT", chk.frame, "BOTTOMLEFT", 24, -3) + container:AddChild(desc) + + return chk, desc +end + +-- renders the main UI for the Combat Log tab +function Amr:RenderTabOptions(container) + + local header = AceGUI:Create("AmrUiLabel") + header:SetWidth(600) + header:SetText(L.OptionsHeaderGeneral) + header:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive)) + header:SetPoint("TOPLEFT", container.content, "TOPLEFT", 12, -40) + container:AddChild(header) + + local desc, desc2 + + _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc) + _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 0, -20) + + _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc) + _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20) + + _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc) + _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) + + -- initialize state of controls + Amr:RefreshOptionsUi() +end + +function Amr:ReleaseTabOptions() + _chkMinimap = nil +end + +function Amr:RefreshOptionsUi() + + if _chkMinimap then + _chkMinimap:SetChecked(self.db.profile.minimap.hide) + end + + if _chkAutoGear then + _chkAutoGear:SetChecked(self.db.profile.options.autoGear) + end + + if _chkAh then + _chkAh:SetChecked(self.db.profile.options.shopAh) + end +end \ No newline at end of file