annotate ui/ExportTab.lua @ 11:ece9167c0d1c v1.2.14.0

Localization support, combat log features (wipe command, aura/pet tracking, and realm detection).
author yellowfive
date Thu, 10 Jul 2014 12:24:59 -0700
parents ec731d2fe6ba
children e77e01abce98
rev   line source
adam@0 1 local _, AskMrRobot = ...
yellowfive@11 2 local L = AskMrRobot.L;
adam@0 3
adam@0 4 -- initialize the ExportTab class
adam@0 5 AskMrRobot.ExportTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame)
adam@0 6
adam@0 7 -- helper to create text for this tab
adam@0 8 local function CreateText(state, tab, font, relativeTo, xOffset, yOffset, text)
adam@0 9 local t = tab:CreateFontString(nil, "ARTWORK", font)
adam@0 10 t:SetPoint("TOPLEFT", relativeTo, "BOTTOMLEFT", xOffset, yOffset)
adam@0 11 t:SetPoint("RIGHT", tab, "RIGHT", -25, 0)
adam@0 12 t:SetWidth(t:GetWidth())
adam@0 13 t:SetJustifyH("LEFT")
adam@0 14 t:SetText(text)
adam@0 15
adam@0 16 if (state ~= nil) then
adam@0 17 table.insert(state, t)
adam@0 18 end
adam@0 19
adam@0 20 return t
adam@0 21 end
adam@0 22
adam@0 23 function AskMrRobot.ExportTab:new(parent)
adam@0 24
adam@0 25 local tab = AskMrRobot.Frame:new(nil, parent)
adam@0 26 setmetatable(tab, { __index = AskMrRobot.ExportTab })
adam@0 27 tab:SetPoint("TOPLEFT")
adam@0 28 tab:SetPoint("BOTTOMRIGHT")
adam@0 29 tab:Hide()
adam@0 30
adam@0 31 -- used to toggle between the two states... could use like, tabs or a UI panel or something, but then I would have to read more pseudo-documentation.
adam@0 32 tab.manualElements = {}
adam@0 33 tab.autoElements = {}
adam@0 34
adam@0 35 local text = tab:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
adam@0 36 text:SetPoint("TOPLEFT", 0, -5)
yellowfive@11 37 text:SetText(L.AMR_EXPORTTAB_EXPORT_BB)
adam@0 38
adam@0 39 local chooseText = CreateText(nil, tab, "GameFontWhite", text, 0, -15, "Choose a method:")
adam@0 40 chooseText:SetJustifyV("MIDDLE")
adam@0 41 chooseText:SetHeight(30)
adam@0 42
adam@0 43 local btn = CreateFrame("Button", "AmrExportManual", tab, "UIPanelButtonTemplate")
adam@0 44 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 125, -15)
yellowfive@11 45 btn:SetText(L.AMR_EXPORTTAB_COPY_PASTE)
adam@0 46 btn:SetWidth(120)
adam@0 47 btn:SetHeight(30)
adam@0 48 tab.btnManual = btn
adam@0 49
adam@0 50 btn:SetScript("OnClick", function()
adam@0 51 AmrOptions.exportToClient = false
adam@0 52 tab:Update()
adam@0 53 end)
adam@0 54
adam@0 55 btn = CreateFrame("Button", "AmrExportAuto", tab, "UIPanelButtonTemplate")
adam@0 56 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 275, -15)
yellowfive@11 57 btn:SetText(L.AMR_EXPORTTAB_AMR_CLIENT)
adam@0 58 btn:SetWidth(120)
adam@0 59 btn:SetHeight(30)
adam@0 60 tab.btnAuto = btn
adam@0 61
adam@0 62 btn:SetScript("OnClick", function()
adam@0 63 AmrOptions.exportToClient = true
adam@0 64 tab:Update()
adam@0 65 end)
adam@0 66
adam@0 67 -- copy/paste
yellowfive@11 68 text = CreateText(tab.manualElements, tab, "GameFontNormalLarge", chooseText, 0, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT)
yellowfive@11 69 local text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_1)
yellowfive@11 70 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_2)
adam@0 71
adam@0 72 local txtExportString = CreateFrame("ScrollFrame", "AmrScrollFrame", tab, "InputScrollFrameTemplate")
adam@0 73 txtExportString:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10)
adam@0 74 txtExportString:SetPoint("RIGHT", -25, 0)
adam@0 75 txtExportString:SetWidth(txtExportString:GetWidth())
adam@0 76 txtExportString:SetHeight(50)
adam@0 77 txtExportString.EditBox:SetWidth(txtExportString:GetWidth())
adam@0 78 txtExportString.EditBox:SetMaxLetters(0)
adam@0 79 txtExportString.CharCount:Hide()
adam@0 80 tab.txtExportString = txtExportString
adam@0 81 table.insert(tab.manualElements, txtExportString)
adam@0 82
adam@0 83 txtExportString.EditBox:SetScript("OnEscapePressed", function()
adam@0 84 AskMrRobot_ReforgeFrame:Hide()
adam@0 85 end)
adam@0 86
yellowfive@11 87 text = CreateText(tab.manualElements, tab, "GameFontWhite", txtExportString, -12, -20, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_3)
yellowfive@11 88 text2 = CreateText(tab.manualElements, tab, "GameFontWhite", text, 10, -5, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_4)
adam@0 89
adam@0 90 local image = tab:CreateTexture(nil, "BACKGROUND")
adam@0 91 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10)
adam@0 92 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen")
adam@0 93 table.insert(tab.manualElements, image)
adam@0 94
yellowfive@11 95 text = CreateText(tab.manualElements, tab, "GameFontWhite", text2, 0, -120, L.AMR_EXPORTTAB_COPY_PASTE_EXPORT_NOTE)
adam@0 96
adam@0 97 btn = CreateFrame("Button", "AmrUpdateExportString", tab, "UIPanelButtonTemplate")
adam@0 98 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -5)
adam@0 99 btn:SetText("Update")
adam@0 100 btn:SetWidth(120)
adam@0 101 btn:SetHeight(25)
adam@0 102 table.insert(tab.manualElements, btn)
adam@0 103
adam@0 104 btn:SetScript("OnClick", function()
adam@0 105 tab:Update()
adam@0 106 end)
adam@0 107
adam@0 108 -- amr client
yellowfive@11 109 text = CreateText(tab.autoElements, tab, "GameFontNormalLarge", chooseText, 0, -20, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT)
yellowfive@11 110 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 0, -15, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_1)
yellowfive@11 111 text = CreateText(tab.autoElements, tab, "GameFontWhite", text2, 0, -15, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_2)
adam@0 112
adam@0 113 btn = CreateFrame("Button", "AmrExportFile", tab, "UIPanelButtonTemplate")
adam@0 114 btn:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 12, -10)
adam@0 115 btn:SetText("Export to File")
adam@0 116 btn:SetWidth(180)
adam@0 117 btn:SetHeight(25)
adam@0 118 table.insert(tab.autoElements, btn)
adam@0 119
adam@0 120 btn:SetScript("OnClick", function()
adam@0 121 AskMrRobot.SaveAll()
adam@0 122 ReloadUI()
adam@0 123 end)
adam@0 124
yellowfive@11 125 text = CreateText(tab.autoElements, tab, "GameFontWhite", btn, -12, -20, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_3)
yellowfive@11 126 text2 = CreateText(tab.autoElements, tab, "GameFontWhite", text, 10, -5, L.AMR_EXPORTTAB_AMR_CLIENT_EXPORT_4)
adam@0 127
adam@0 128 image = tab:CreateTexture(nil, "BACKGROUND")
adam@0 129 image:SetPoint("TOPLEFT", text2, "BOTTOMLEFT", 2, -10)
adam@0 130 image:SetTexture("Interface\\AddOns\\AskMrRobot\\Media\\BiBScreen")
adam@0 131 table.insert(tab.autoElements, image)
adam@0 132
adam@0 133 tab:SetScript("OnShow", function()
adam@0 134 tab:Update()
adam@0 135 end)
adam@0 136
adam@0 137 return tab
adam@0 138 end
adam@0 139
adam@0 140 -- update the panel and state
adam@0 141 function AskMrRobot.ExportTab:Update()
adam@0 142
adam@0 143 if (AmrOptions.exportToClient) then
adam@0 144 for i, v in ipairs(self.manualElements) do v:Hide() end
adam@0 145 for i, v in ipairs(self.autoElements) do v:Show() end
adam@0 146 self.btnManual:UnlockHighlight()
adam@0 147 self.btnAuto:LockHighlight()
adam@0 148 else
adam@0 149 for i, v in ipairs(self.autoElements) do v:Hide() end
adam@0 150 for i, v in ipairs(self.manualElements) do v:Show() end
adam@0 151 self.btnAuto:UnlockHighlight()
adam@0 152 self.btnManual:LockHighlight()
adam@0 153
adam@0 154 AskMrRobot.SaveAll()
adam@0 155 self.txtExportString.EditBox:SetText(AskMrRobot.ExportToString())
adam@0 156 self.txtExportString.EditBox:HighlightText()
adam@0 157 self.txtExportString.EditBox:SetFocus()
adam@0 158 end
adam@0 159 end