Quantcast

Fix all the interfaces, they should work correctly now.

Eyal Shilony [10-20-14 - 00:26]
Fix all the interfaces, they should work correctly now.
Filename
Core.lua
Menu.lua
libs/EasyDisplay.lua
options/Menu.lua
diff --git a/Core.lua b/Core.lua
index 26a5052..1537b45 100644
--- a/Core.lua
+++ b/Core.lua
@@ -92,7 +92,8 @@ addon.secureItems = {
 	["journal"] = true,
 	["guild"] = true,
 	--["help"] = true,
-	["interface"] = true
+	["interface"] = true,
+	["options"] = true
 }

 core:SetOnUpdate(function(self, elapsed)
diff --git a/Menu.lua b/Menu.lua
index f2ee30d..8a39465 100644
--- a/Menu.lua
+++ b/Menu.lua
@@ -40,21 +40,26 @@ end
 local function insertItem(name, order)
 	local interface = addon.display:GetInterface(name)
 	if interface and order > 0 then
+		local inCombat = UnitAffectingCombat("player")
+
 		local entry = {
 			order = order,
 			name = name,
 			text = interface.title,
 			icon = interface.icon,
 			notCheckable = 1,
-			disabled = addon.secureItems[interface.name] and UnitAffectingCombat("player"),
-			attributes = {
+			disabled = inCombat and addon.secureItems[interface.name]
+		}
+
+		if not inCombat and interface.button and addon.secureItems[interface.name] then
+			entry.attributes = {
 				["type"] = "click",
 				["clickbutton"] = interface.button,
 			}
-		}
-
-		if not addon.secureItems[interface.name] then
+		elseif interface.special then
 			entry.func = function() addon.display:DisplayInterface(name) end
+		else
+			entry.func = interface.func
 		end

 		table.insert(menu, entry)
diff --git a/libs/EasyDisplay.lua b/libs/EasyDisplay.lua
index 61382b2..3e2b1dc 100644
--- a/libs/EasyDisplay.lua
+++ b/libs/EasyDisplay.lua
@@ -25,7 +25,7 @@

 assert(LibStub, "EasyDisplay-1.0 requires LibStub")

-local lib, minor = LibStub:NewLibrary("EasyDisplay-1.0", 9)
+local lib, minor = LibStub:NewLibrary("EasyDisplay-1.0", 10)
 if not lib then return end
 minor = minor or 0

@@ -49,6 +49,7 @@ GameMenu_OptionFrames = {
 	["InterfaceOptionsFrame"] = true,
 	["MacOptionsFrame"] = true,
 	["KeyBindingFrame"] = true,
+	["AddonList"] = true,
 }

 -- Must be loaded before the interface is displayed.
@@ -73,21 +74,10 @@ LoD_AddonFrames = {
 	button (frame) - The button to click to open the interface.
 	level - (number) The minimum level of the player required to display the interface.
 	func - (function) The function (handler) to display the interface.
+	special - (boolean) Requires special handling before it can be displayed so it's recommended to use the DisplayInterface api to show the interface.
 ]]
 local interfaces = {
 	{
-		name = "addons",
-		title = ADDONS,
-		func = function()
-			if not AddonList:IsVisible() then
-				ShowUIPanel(AddonList)
-				AddonList.hideMenu = true
-			else
-				HideUIPanel(AddonList)
-			end
-		end,
-	},
-	{
 		name = "character",
 		title = CHARACTER_BUTTON,
 		alias = "char",
@@ -136,13 +126,6 @@ local interfaces = {
 		func = ToggleQuestLog,
 	},
 	{
-		name = "social",
-		title = SOCIAL_BUTTON,
-		alias = "soc",
-		frameName = "FriendsFrame",
-		func = ToggleFriendsFrame,
-	},
-	{
 		name = "pvp",
 		title = PLAYER_V_PLAYER,
 		frameName = "PVPFrame",
@@ -218,10 +201,30 @@ local interfaces = {
 		func = ToggleHelpFrame,
 	},
 	{
+		name = "shops",
+		title = BLIZZARD_STORE,
+		func = ToggleStoreUI,
+	},
+	{
+		name = "whatsnew",
+		title = GAMEMENU_NEW_BUTTON,
+		special = true,
+		func = SplashFrame_Open,
+	},
+	{
+		name = "social",
+		title = SOCIAL_BUTTON,
+		alias = "soc",
+		frameName = "FriendsFrame",
+		special = true,
+		func = ToggleFriendsFrame,
+	},
+	{
 		name = "options",
 		title = SYSTEMOPTIONS_MENU,
 		alias = "system",
 		frameName = "VideoOptionsFrame",
+		special = true,
 		func = function()
 			if not VideoOptionsFrame:IsVisible() then
 				ShowUIPanel(VideoOptionsFrame)
@@ -236,6 +239,7 @@ local interfaces = {
 		name = "interface",
 		title = UIOPTIONS_MENU,
 		frameName = "InterfaceOptionsFrame",
+		special = true,
 		func = function()
 			if not InterfaceOptionsFrame:IsVisible() then
 				ShowUIPanel(InterfaceOptionsFrame)
@@ -250,6 +254,7 @@ local interfaces = {
 		name = "mac",
 		title = MAC_OPTIONS,
 		frameName = "MacOptionsFrame",
+		special = true,
 		func = function()
 			if not MacOptionsFrame:IsVisible() then
 				ShowUIPanel(MacOptionsFrame)
@@ -264,6 +269,7 @@ local interfaces = {
 		title = KEY_BINDINGS,
 		alias = "keys",
 		frameName = "KeyBindingFrame",
+		special = true,
 		func = function()
 			if not KeyBindingFrame:IsVisible() then
 				ShowUIPanel(KeyBindingFrame)
@@ -277,6 +283,7 @@ local interfaces = {
 		name = "macro",
 		title = MACROS,
 		frameName = "MacroFrame",
+		special = true,
 		func = function()
 			if not MacroFrame:IsVisible() then
 				ShowUIPanel(MacroFrame)
@@ -286,6 +293,20 @@ local interfaces = {
 		end,
 	},
 	{
+		name = "addons",
+		title = ADDONS,
+		frameName = "AddonList",
+		special = true,
+		func = function()
+			if not AddonList:IsVisible() then
+				ShowUIPanel(AddonList)
+				AddonList.hideMenu = true
+			else
+				HideUIPanel(AddonList)
+			end
+		end,
+	},
+	{
 		name = "mainmenu",
 		title = MAINMENU_BUTTON,
 		alias = "menu",
@@ -309,16 +330,6 @@ local interfaces = {
 			end
 		end,
 	},
-	{
-		name = "whatsnew",
-		title = GAMEMENU_NEW_BUTTON,
-		func = SplashFrame_Open,
-	},
-	{
-		name = "shops",
-		title = BLIZZARD_STORE,
-		func = ToggleStoreUI,
-	}
 }

 -- if we're not using a mac client, remove the interface from the table.
@@ -332,7 +343,7 @@ if IsMacClient() ~= 1 then
 end

 -- We need to show addons only when we have more than one addon available.
-if GetNumAddOns() > 0 then
+if GetNumAddOns() <= 0 then
 	for i, v in ipairs(interfaces) do
 		if v.name == "addons" then
 			table.remove(interfaces, i)
diff --git a/options/Menu.lua b/options/Menu.lua
index b4958ea..639cbd5 100644
--- a/options/Menu.lua
+++ b/options/Menu.lua
@@ -94,13 +94,13 @@ function options:OnInitialize()

 	local availableItems = ui:CreateList(order)
 	availableItems:SetTitle("Available Interfaces")
-	availableItems:SetPoint("TOPLEFT", 10, -120)
-	availableItems:SetSize(220, 400)
+	availableItems:SetPoint("TOPLEFT", 10, -80)
+	availableItems:SetSize(220, 435)

 	local visibleItems = ui:CreateList(order)
 	visibleItems:SetTitle("Visible Menu Items")
 	visibleItems:SetPoint("TOPLEFT", availableItems, "TOPRIGHT", 23, 0)
-	visibleItems:SetSize(220, 400)
+	visibleItems:SetSize(220, 435)

 	reset(availableItems, visibleItems)