diff Main.lua @ 8:6e160ec1ef0f

locale, add DBIcon, experiment with frames
author Jay Bird <a4blank@yahoo.com>
date Mon, 22 Nov 2010 08:39:57 -0500
parents d067c361c4e9
children f93b554bb7cf
line wrap: on
line diff
--- a/Main.lua	Sun Nov 21 20:38:20 2010 -0500
+++ b/Main.lua	Mon Nov 22 08:39:57 2010 -0500
@@ -1,25 +1,70 @@
-
-
-RTT = LibStub("AceAddon-3.0"):NewAddon("RaidTargetTactics", "AceConsole-3.0")
---local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics")
-
-
-function RTT:OnInitialize()
-    self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true)
-    local AceGUI = LibStub("AceGUI-3.0")
-    -- Create a container frame
-    local f = AceGUI:Create("Frame")
-    f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
-    f:SetTitle("AceGUI-3.0 Example")
-    f:SetStatusText("Status Bar")
-    f:SetLayout("Flow")
-    -- Create a button
-    local btn = AceGUI:Create("Button")
-    btn:SetWidth(170)
-    btn:SetText("Button !")
-    btn:SetCallback("OnClick", function() print("Click!") end)
-    -- Add the button to the container
-    f:AddChild(btn)
-
-end
-
+
+
+RTT = LibStub("AceAddon-3.0"):NewAddon("RaidTargetTactics", "AceConsole-3.0")
+local L = LibStub("AceLocale-3.0"):GetLocale("RaidTargetTactics")
+
+
+local LDB = LibStub("LibDataBroker-1.1", true)
+local LDBIcon = LibStub("LibDBIcon-1.0", true)
+
+local RTTIcon = LibStub("LibDataBroker-1.1"):NewDataObject("RTTIcon", {
+    type = "data source",
+    text = "Raid Target Tactics",
+    icon = "Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_8",
+    OnClick = function() RTT:OnIconClick() end,
+    OnTooltipShow = function(tooltip)
+        tooltip:AddLine("Raid Target Tactics")
+        tooltip:AddLine(L.Minimap_Icon_Tooltip)
+    end,
+})
+
+local defaults = {
+    profile = {
+        visible = true,
+        minimap = {
+            hide = false,
+        },
+    },
+}
+
+function RTT:OnInitialize()
+    self.db = LibStub("AceDB-3.0"):New("TacticsSettings", defaults, true)
+
+    LDBIcon:Register("RTTIcon", RTTIcon, self.db.profile.minimap)
+    self:InitFrame()
+    if self.f:IsShown() != self.db.profile.visible then
+        if self.db.profile.visible then
+            self:ShowFrame()
+        else
+            self:HideFrame()
+        end
+    end
+end
+
+function RTT:InitFrame()
+    self.f = CreateFrame("Frame", nil, UIParent)
+    self.f:SetWidth(100)
+    self.f:SetHeight(200)
+    self.f:SetPoint("LEFT", UIParent, "LEFT", 10, 0)
+end
+
+function RTT:OnIconClick()
+    if self.db.profile.visible then
+        self:HideFrame()
+    else
+        self:ShowFrame()
+    end
+    self.db.profile.visible = !self.db.profile.visible
+end
+
+function RTT:HideFrame()
+    self.f:Hide()
+end
+
+function RTT:ShowFrame()
+    self.f:Show()
+end
+
+
+
+