Quantcast

#1227 - Add strata menu to main config menu in response, not as a fix

urnati [02-14-19 - 18:30]
#1227 - Add strata menu to main config menu in response, not as a fix
Filename
Titan/TitanPanel.lua
diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua
index 103c3f5..5785da2 100644
--- a/Titan/TitanPanel.lua
+++ b/Titan/TitanPanel.lua
@@ -1770,6 +1770,19 @@ local function TitanPanel_MainMenu()
 	info.checked = glob --TitanAllGetVar("GlobalProfileUse")
 	info.keepShownOnClick = nil
 	L_UIDropDownMenu_AddButton(info, L_UIDROPDOWNMENU_MENU_LEVEL);
+
+	TitanPanelRightClickMenu_AddSpacer();
+
+	-----------------
+	-- Strata change
+	TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_FRAME_STRATA"]);
+
+	info = {};
+	info.notCheckable = true
+	info.text = L["TITAN_PANEL_MENU_FRAME_STRATA"];
+	info.value = "Addons_" .. "TITAN_PANEL_MENU_FRAME_STRATA";
+	info.hasArrow = 1;
+	L_UIDropDownMenu_AddButton(info);
 --[[
 	local player, server = TitanUtils_ParseName(TitanAllGetVar("GlobalProfileName"))
 	info = {};
@@ -2098,6 +2111,50 @@ local function TitanPanel_BuildOtherPluginsMenu(frame)
 end

 --[[ Titan
+NAME: TitanPanel_StrataHelper
+DESC: Show the submenu with strata and change if selected.
+VAR:  None
+OUT:  None
+--]]
+local function TitanPanel_StrataHelper()
+			local values = {
+				["BACKGROUND"] = "BACKGROUND",
+				["LOW"] = "LOW",
+				["MEDIUM"] = "MEDIUM",
+				["HIGH"] = "HIGH",
+				["DIALOG"] = "DIALOG",
+				["FULLSCREEN"] = "FULLSCREEN",
+			}
+--[[
+			get = function()
+				return TitanPanelGetVar("FrameStrata")
+			end,
+			set = function(_, v)
+				TitanPanelSetVar("FrameStrata", v)
+				TitanVariables_SetPanelStrata(v)
+			end,
+--]]
+			for index, id in pairs(values) do
+				info = {};
+				info.text = id
+				info.value = id;
+				info.func = function()
+						TitanPanelSetVar("FrameStrata", id)
+						TitanVariables_SetPanelStrata(id)
+						--[[
+						Avoid confusion of several clicked options
+						although it forces the user to mouse
+						over the 'strata' menu againL_HideDropDownMenu
+						--]]
+						L_HideDropDownMenu(L_UIDROPDOWNMENU_MENU_LEVEL)
+					end;
+				info.checked = TitanPanelGetVar("FrameStrata") == id or nil
+				info.keepShownOnClick = 0; -- clear it to prevent confusion
+				L_UIDropDownMenu_AddButton(info, L_UIDROPDOWNMENU_MENU_LEVEL);
+			end
+end
+
+--[[ Titan
 NAME: TitanPanelRightClickMenu_PrepareBarMenu
 DESC: This is the controller to show the proper level of the Titan (right click) menu.
 VAR: self - expected to be the Tian bar that was right clicked
@@ -2111,8 +2168,14 @@ function TitanPanelRightClickMenu_PrepareBarMenu(self)

 	-- Level 2
 	if ( L_UIDROPDOWNMENU_MENU_LEVEL == 2 ) then
-		TitanPanel_BuildOtherPluginsMenu(frame);
-		TitanPanel_ServerSettingsMenu();
+		-- Could be plugins or strata
+		if ( L_UIDROPDOWNMENU_MENU_VALUE == "Addons_" .. "TITAN_PANEL_MENU_FRAME_STRATA" ) then
+			TitanPanel_StrataHelper()
+		else -- one of the plugins
+			TitanPanel_BuildOtherPluginsMenu(frame);
+			TitanPanel_ServerSettingsMenu();
+		end
+
 		return;
 	end