Mercurial > wow > askmrrobot
comparison Options.lua @ 57:01b63b8ed811 v21
total rewrite to version 21
| author | yellowfive |
|---|---|
| date | Fri, 05 Jun 2015 11:05:15 -0700 |
| parents | |
| children | cf2b6b9a8337 |
comparison
equal
deleted
inserted
replaced
| 56:75431c084aa0 | 57:01b63b8ed811 |
|---|---|
| 1 local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot") | |
| 2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) | |
| 3 local AceGUI = LibStub("AceGUI-3.0") | |
| 4 | |
| 5 local _chkMinimap | |
| 6 local _chkAutoGear | |
| 7 local _chkAh | |
| 8 | |
| 9 local function onCheckClick(widget) | |
| 10 local setting = widget:GetUserData("setting") | |
| 11 local val = widget:GetChecked() | |
| 12 | |
| 13 if setting == "minimap" then | |
| 14 Amr.db.profile.minimap.hide = val | |
| 15 else | |
| 16 Amr.db.profile.options[setting] = val | |
| 17 end | |
| 18 | |
| 19 Amr:RefreshConfig() | |
| 20 end | |
| 21 | |
| 22 local function onChkMinimapClick() | |
| 23 Amr.db.profile.minimap.hide = _chkMinimap:GetChecked() | |
| 24 Amr:RefreshConfig() | |
| 25 end | |
| 26 | |
| 27 local function createCheck(container, setting, text, description) | |
| 28 | |
| 29 local chk = AceGUI:Create("AmrUiCheckBox") | |
| 30 chk:SetUserData("setting", setting) | |
| 31 chk:SetText(text) | |
| 32 chk:SetCallback("OnClick", onCheckClick) | |
| 33 container:AddChild(chk) | |
| 34 | |
| 35 local desc = AceGUI:Create("AmrUiLabel") | |
| 36 desc:SetWidth(800) | |
| 37 desc:SetText(description) | |
| 38 desc:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.TextTan)) | |
| 39 desc:SetPoint("TOPLEFT", chk.frame, "BOTTOMLEFT", 24, -3) | |
| 40 container:AddChild(desc) | |
| 41 | |
| 42 return chk, desc | |
| 43 end | |
| 44 | |
| 45 -- renders the main UI for the Combat Log tab | |
| 46 function Amr:RenderTabOptions(container) | |
| 47 | |
| 48 local header = AceGUI:Create("AmrUiLabel") | |
| 49 header:SetWidth(600) | |
| 50 header:SetText(L.OptionsHeaderGeneral) | |
| 51 header:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive)) | |
| 52 header:SetPoint("TOPLEFT", container.content, "TOPLEFT", 12, -40) | |
| 53 container:AddChild(header) | |
| 54 | |
| 55 local desc, desc2 | |
| 56 | |
| 57 _chkMinimap, desc = createCheck(container, "minimap", L.OptionsHideMinimapName, L.OptionsHideMinimapDesc) | |
| 58 _chkMinimap:SetPoint("TOPLEFT", header.frame, "BOTTOMLEFT", 0, -20) | |
| 59 | |
| 60 _chkAutoGear, desc2 = createCheck(container, "autoGear", L.OptionsAutoGearName, L.OptionsAutoGearDesc) | |
| 61 _chkAutoGear:SetPoint("TOPLEFT", desc.frame, "BOTTOMLEFT", -24, -20) | |
| 62 | |
| 63 _chkAh, desc = createCheck(container, "shopAh", L.OptionsShopAhName, L.OptionsShopAhDesc) | |
| 64 _chkAh:SetPoint("TOPLEFT", desc2.frame, "BOTTOMLEFT", -24, -20) | |
| 65 | |
| 66 -- initialize state of controls | |
| 67 Amr:RefreshOptionsUi() | |
| 68 end | |
| 69 | |
| 70 function Amr:ReleaseTabOptions() | |
| 71 _chkMinimap = nil | |
| 72 end | |
| 73 | |
| 74 function Amr:RefreshOptionsUi() | |
| 75 | |
| 76 if _chkMinimap then | |
| 77 _chkMinimap:SetChecked(self.db.profile.minimap.hide) | |
| 78 end | |
| 79 | |
| 80 if _chkAutoGear then | |
| 81 _chkAutoGear:SetChecked(self.db.profile.options.autoGear) | |
| 82 end | |
| 83 | |
| 84 if _chkAh then | |
| 85 _chkAh:SetChecked(self.db.profile.options.shopAh) | |
| 86 end | |
| 87 end |
