diff --git a/Titan/LDBToTitan.lua b/Titan/LDBToTitan.lua index 71f75f6..2aa4b0c 100644 --- a/Titan/LDBToTitan.lua +++ b/Titan/LDBToTitan.lua @@ -786,12 +786,25 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) if obj.type == "macro" then -- custom newTitanFrame = CreateFrame("Button", "TitanPanel"..NAME_PREFIX..name.."Button", - UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") + UIParent, "TitanPanelComboTemplate") +-- UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") + newTitanFrame:RegisterForClicks("AnyUp", "AnyDown") + newTitanFrame:SetMouseClickEnabled(true) newTitanFrame:SetAttribute("type", "macro") +-- newTitanFrame:SetAttribute("macro", obj.commandtext) newTitanFrame:SetAttribute("macrotext", obj.commandtext) + newTitanFrame:SetScript("OnClick", function(self, button, down) + SecureUnitButton_OnClick(self, button, down) + --TitanPanelBarButton_OnClick(self, button) + end) +--[[ +print("LDB macrotext" +.." "..tostring(obj.commandtext).."" +) +--]] if TITAN_PANEL_VARS.debug.ldb_setup then TitanDebug("" - .." macro cmd: '"..tostring(obj.commandtext).."' " + .." macrotext cmd: '"..tostring(obj.commandtext).."' " ) end else diff --git a/Titan/Titan.toc b/Titan/Titan.toc index 1713232..fae1a0d 100644 --- a/Titan/Titan.toc +++ b/Titan/Titan.toc @@ -1,7 +1,7 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa006.00.13.100007|r ## Author: Titan Panel Development Team -## Version: 6.00.12.100005 +## Version: 6.00.13.100007 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds a display bar on the top and/or bottom of the screen. Allows users to show and control information/launcher plugins. diff --git a/Titan/TitanAutoHide.lua b/Titan/TitanAutoHide.lua index 7cfa942..1248fe2 100644 --- a/Titan/TitanAutoHide.lua +++ b/Titan/TitanAutoHide.lua @@ -3,11 +3,12 @@ NAME:TitanAutoHide.lua DESC: Contains the routines of AutoHide Titan plugin to auto hide a Titan bar. Auto hide uses a data driven approach. Rather than seperate routines for each bar, auto hide is implemented in a general manner. -The tables TitanBarData & AutoHideData hold relevant data needed to control auto hide. -The index into AutoHideData is the plugin button name given in TitanPanel.xml. +The table TitanBarData hold relevant data needed to control auto hide. If auto hide is turned on these routines will show / hide the proper bar (and plugins on the bar). These routines control the 'push pin' on each bar, if shown. + +The hider bar is a 1/2 height bar used to catch the mouse over to show the bar again. :DESC --]] local AceTimer = LibStub("AceTimer-3.0") @@ -24,7 +25,7 @@ OUT: None --]] local function Titan_AutoHide_SetIcon(self) local frame = self:GetName() - local bar = AutoHideData[frame].name + local bar = self.bar_name -- Get the icon of the icon template local icon = _G[frame.."Icon"] @@ -44,7 +45,7 @@ OUT: None --]] function Titan_AutoHide_OnLoad(self) local frame = self:GetName() - local bar = AutoHideData[frame].name + local bar = self.bar_name self.registry = { id = "AutoHide_"..bar, @@ -78,7 +79,7 @@ OUT: None --]] function Titan_AutoHide_OnClick(self, button) if (button == "LeftButton") then - Titan_AutoHide_ToggleAutoHide(self); + Titan_AutoHide_ToggleAutoHide(self.bar_name); end end @@ -94,7 +95,7 @@ function Titan_AutoHide_Timers(frame, action) if not frame or not action then return end - local bar = (TitanBarData[frame] and TitanBarData[frame].name or nil) + local bar = TitanBarData[frame].name --(frame.bar_name or nil) local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) if bar and hide then @@ -114,25 +115,28 @@ DESC: Show / hide the given bar per the user requested settings VAR: self - The bar OUT: None --]] -function Titan_AutoHide_Init(self) - if not self then return end -- sanity check - - local frame = self:GetName() - if frame then -- sanity check - local bar = AutoHideData[frame].name +function Titan_AutoHide_Init(frame) + if _G[frame] then -- sanity check + local bar = TitanBarData[frame].name -- Make sure the bar should be processed if (TitanPanelGetVar(bar.."_Show")) then - -- Hide / show the bar the plugin is on + -- Hide / show the bar if (TitanPanelGetVar(bar.."_Hide")) then - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX..bar); + TitanPanelBarButton_Hide(frame); else - TitanPanelBarButton_Show(TITAN_PANEL_DISPLAY_PREFIX..bar); + TitanPanelBarButton_Show(frame); end else - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX..bar); + TitanPanelBarButton_Hide(frame); + end + if TitanBarData[frame].hider then + Titan_AutoHide_SetIcon(_G[AUTOHIDE_PREFIX..bar..AUTOHIDE_SUFFIX]) + else + -- No auto hide end - Titan_AutoHide_SetIcon(self) + else + -- sanity check, do nothing end end @@ -142,14 +146,11 @@ DESC: Toggle the user requested show / hide setting then show / hide given bar VAR: self - The bar OUT: None --]] -function Titan_AutoHide_ToggleAutoHide(self) - local frame = self:GetName() - local bar = AutoHideData[frame].name - +function Titan_AutoHide_ToggleAutoHide(bar) -- toggle the correct auto hide variable TitanPanelToggleVar(bar.."_Hide") - -- Hide / show the requested bar - Titan_AutoHide_Init(self) + -- Hide / show the requested Titan bar + Titan_AutoHide_Init(TITAN_PANEL_DISPLAY_PREFIX..bar) end --[[ Titan @@ -179,87 +180,42 @@ function Handle_OnUpdateAutoHide(frame) end end --- ====== Create needed frames -local function Create_Hide_Button(name, f) - local window = CreateFrame("Button", name, f, "TitanPanelIconTemplate") - window:SetFrameStrata("FULLSCREEN") +-- +--========================== +-- Routines to handle moving and sizing of short bars +-- +local function Create_Hide_Button(bar, f) + local name = AUTOHIDE_PREFIX..bar..AUTOHIDE_SUFFIX + local plugin = CreateFrame("Button", name, f, "TitanPanelIconTemplate") + plugin:SetFrameStrata("FULLSCREEN") + + plugin.bar_name = bar -- set the bar name for the .registry + -- Using SetScript("OnLoad", does not work - Titan_AutoHide_OnLoad(window); --- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... + Titan_AutoHide_OnLoad(plugin); +-- TitanPanelButton_OnLoad(plugin); -- Titan XML template calls this... - window:SetScript("OnShow", function(self) + plugin:SetScript("OnShow", function(self) Titan_AutoHide_OnShow(self) end) - window:SetScript("OnClick", function(self, button) + plugin:SetScript("OnClick", function(self, button) Titan_AutoHide_OnClick(self, button); TitanPanelButton_OnClick(self, button); end) end -local function Create_Frames() - if _G["Titan_Bar__Display_Bar"] then - return -- if already created - end - - -- Display & Hide bars - - local top1_d = CreateFrame("Button", "Titan_Bar__Display_Bar", UIParent, "Titan_Bar__Display_Template") - top1_d:SetFrameStrata("DIALOG") - top1_d:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0) - top1_d:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", 0, -24) - local top1_h = CreateFrame("Button", "Titan_Bar__Hider_Bar", UIParent, "TitanPanelBarButtonHiderTemplate") - top1_h:SetFrameStrata("DIALOG") - top1_h:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, -24) ---[===[ --- NOTE: To allow bars to be less than full screen the BOTTOMRIGHT set point must be commented out! ---_G[bar_name]:SetWidth(screenWidth) -top1_d:SetSize(1000, TITAN_PANEL_BAR_TEXTURE_HEIGHT) -top1_h:SetSize(1000, TITAN_PANEL_BAR_TEXTURE_HEIGHT) --- bar width test -print("T CHBar" -.." scr w: "..tostring(format("%0.2f", GetScreenWidth())).."" -.." pyh w: "..tostring(GetPhysicalScreenSize()).."" -.." bar: "..tostring(format("%0.2f", top1_d:GetWidth())).."" -.." "..tostring(format("%0.2f", UIParent:GetEffectiveScale())).."" -) ---]===] - - local top2_d = CreateFrame("Button", "Titan_Bar__Display_Bar2", UIParent, "Titan_Bar__Display_Template") - top2_d:SetFrameStrata("DIALOG") - top2_d:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 24) - top2_d:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", 0, 48) - local top2_h = CreateFrame("Button", "Titan_Bar__Hider_Bar2", UIParent, "TitanPanelBarButtonHiderTemplate") - top2_h:SetFrameStrata("DIALOG") - top2_h:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, -24) - - - local bot1_d = CreateFrame("Button", "Titan_Bar__Display_AuxBar", UIParent, "Titan_Bar__Display_Template") - bot1_d:SetFrameStrata("DIALOG") - bot1_d:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) - bot1_d:SetPoint("TOPRIGHT", UIParent, "BOTTOMRIGHT", 0, 24) - local bot1_h = CreateFrame("Button", "Titan_Bar__Hider_AuxBar", UIParent, "TitanPanelBarButtonHiderTemplate") - bot1_h:SetFrameStrata("DIALOG") - bot1_h:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, -24) - - local bot2_d = CreateFrame("Button", "Titan_Bar__Display_AuxBar2", UIParent, "Titan_Bar__Display_Template") - bot2_d:SetFrameStrata("DIALOG") - bot2_d:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 24) - bot2_d:SetPoint("TOPRIGHT", UIParent, "BOTTOMRIGHT", 0, 48) - local bot2_h = CreateFrame("Button", "Titan_Bar__Hider_AuxBar2", UIParent, "TitanPanelBarButtonHiderTemplate") - bot2_h:SetFrameStrata("DIALOG") - bot2_h:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, -24) - +--local function Create_Frames() +function Titan_AutoHide_Create_Frames() + --====== Titan Auto hide plugin buttons ============================== -- general container frame local f = CreateFrame("Frame", nil, UIParent) --- f:Hide() - -- Titan Auto hide Buttons - Create_Hide_Button("TitanPanelAutoHide_BarButton", f) - Create_Hide_Button("TitanPanelAutoHide_Bar2Button", f) - Create_Hide_Button("TitanPanelAutoHide_AuxBar2Button", f) - Create_Hide_Button("TitanPanelAutoHide_AuxBarButton", f) + Create_Hide_Button("Bar", f) + Create_Hide_Button("Bar2", f) + Create_Hide_Button("AuxBar2", f) + Create_Hide_Button("AuxBar", f) end -Create_Frames() -- do the work +--Create_Frames() -- do the work diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index c23aede..031428d 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -27,17 +27,44 @@ Highlight - notes. tips. and details --]] local notes = "" - ..TitanUtils_GetRedText("NOTE : ") ..TitanUtils_GetNormalText("" - .."The menu & bag frame and the status / xp frame ARE adjustable via edit mode in 10.00.05. The ability to adjust the menu & bag frame and the status / xp frame *vertically only* will be removed soon.\n" + .."- Adjusting the menu & bag frame and the status / xp frame have been removed.\n" + .."\n" + .."- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" ) local changes = "" +do -- changes var set +changes = changes + ..TitanUtils_GetGoldText("7.00.00.100007 : 2023/03/31\n") + ..TitanUtils_GetGreenText("Titan : \n") + ..TitanUtils_GetHighlightText("" + ..TitanUtils_GetRedText("- NOTE : Downgrading from 7.xx to 6.xx *will require* wiping the Titan saved variables file.\n") + .."- NEW : Configuration > Titan Bar Help has details on bars.\n" + .."- NEW : 10 Short bars! See new Configuration > Titan Bar Help for enabling and using.\n" + .."- NEW : Can Hide any Titan bar by right click on the Titan bar (not a plugin) then click Hide.\n" + .."- NEW : Global Skin is now selectable in Config. \n" + .."- NEW : Hide in Combat is now selectable in Config.\n" + .."- Configuration > Bars has a consolidated config for all Titan bars.\n" + .."- Configuration > Transparency moved into Bars.\n" + .."- Configuration > Skins shows available skins.\n" + .."- Remove adjustment of XP & status bars and Bag & Menu buttons.\n" + .."- Remove unused timers; only LDB timer left.\n" + .."- Update TOC\n" + ) + .."\n\n" + ..TitanUtils_GetGoldText("6.00.13.100005 : 2023/03/20\n") + ..TitanUtils_GetGreenText("Titan : \n") + ..TitanUtils_GetHighlightText("" + .."- Update TOC only to 10.00.07\n" + ) + .."\n\n" ..TitanUtils_GetGoldText("6.00.12.100005 : 2023/01/31\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" .."- Update TOC\n" .."- Update Titan settings once on load.\n" ) + .."\n\n" ..TitanUtils_GetGoldText("6.00.11.100002 : 2023/01/31\n") ..TitanUtils_GetGreenText("TitanRepair : \n") ..TitanUtils_GetHighlightText("" @@ -68,54 +95,29 @@ local changes = "" .."- Labels : Extend custom labels to 2 (second) through 4 (fourth). Plugins should be used / shown at least once, especially if more than one label / value pair is shown by that plugin.\n" ) .."\n\n" - ..TitanUtils_GetGoldText("6.00.10.100002 : 2022/12/13\n") - ..TitanUtils_GetGreenText("TitanBag : \n") - ..TitanUtils_GetHighlightText("" - .."- Made 'open bags' (left click) an option (default off) until container taint resolved.\n" - ) - ..TitanUtils_GetGreenText("TitanGold : \n") - ..TitanUtils_GetHighlightText("" - .."- Fan fix for total being reset in certain situations - thanks to GrimNotepad.\n" - ) - ..TitanUtils_GetGreenText("TitanRepair : \n") - ..TitanUtils_GetHighlightText("" - .."- Removed unused tool tip code from old API.\n" - ) - ..TitanUtils_GetGreenText("TitanVolume : \n") - ..TitanUtils_GetHighlightText("" - .."- Fix to make sliders work via mouse wheel again.\n" - ) - ..TitanUtils_GetGreenText("TitanPanel : \n") - ..TitanUtils_GetHighlightText("" - .."- Fix for some LDB addons not being updating properly.\n" - ) - .."\n\n" - ..TitanUtils_GetGoldText("6.00.09.100002 : 2022/12/01\n") - ..TitanUtils_GetGreenText("TitanRepair : \n") - ..TitanUtils_GetHighlightText("" - .."- Quick fix for repair pop up.\n" - ) +end TITAN_PANEL_CONFIG = { topic = { About = L["TITAN_PANEL"], - top = L["TITAN_PANEL_MENU_TOP_BARS"], + top = L["TITAN_PANEL_MENU_OPTIONS_BARS"], + globals = L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"], bottom = L["TITAN_PANEL_MENU_BOTTOM_BARS"], plugins = L["TITAN_PANEL_MENU_PLUGINS"], profiles = L["TITAN_PANEL_MENU_PROFILES"], tooltips = L["TITAN_PANEL_MENU_OPTIONS_SHORT"], scale = L["TITAN_UISCALE_MENU_TEXT_SHORT"], - trans = L["TITAN_TRANS_MENU_TEXT_SHORT"], + trans = L["TITAN_TRANS_MENU_TEXT_SHORT"], skins = L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"], skinscust = L["TITAN_SKINS_OPTIONS_CUSTOM"], extras = L["TITAN_PANEL_EXTRAS_SHORT"], attempts = L["TITAN_PANEL_ATTEMPTS_SHORT"], advanced = L["TITAN_PANEL_MENU_ADV"], - changes = (CHANGE or "Change").." "..(HISTORY or "History"), - slash = ("/").." "..(COMMAND or "Command"), + changes = L["TITAN_PANEL_MENU_CHANGE_HISTORY"], + slash = L["TITAN_PANEL_MENU_SLASH_COMMAND"], + help = L["TITAN_PANEL_MENU_HELP"], } } --- TITAN_PANEL_CONFIG.topic.trans -- Titan local helper funcs local function TitanPanel_GetTitle() @@ -158,29 +160,6 @@ local function TitanAdjustPanelScale(scale) end -- helper functions ---[[ local -NAME: TitanPanel_TicketReload -DESC: When the user changes the option to adjust for the Blizz ticket frame the UI must be reloaded. Ask the user if they want to do it now. -VAR: None -OUT: None ---]] -local function TitanPanel_TicketReload() - StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - TitanPanelToggleVar("TicketAdjust"); - ReloadUI(); - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RELOAD"); -end ------------- -- about config section @@ -194,14 +173,24 @@ local optionsControl = { type = "group", args = { confgendesc = { + name = "About", order = 1, - type = "description", --- name = L["TITAN_PANEL_CONFIG_MAIN_LABEL"].."\n\n", - name = "" - .."Titan Panel is an Interface Enhancement addon." - .."\n" - .."This addon does not interfere with, enhance, or replace any of your actual gameplay within the game. Titan Panel is meant to give you a quick visual point or click-on access to see the data related to your character without having to open other dialog boxes in the game or, in some cases, other addons. There are points we allow you to customize these features, but they do not relate directly to your gameplay. Our main program allows you to add bars to the top and bottom of your game screen. Over the years, we have been able to add some other features, but only if they do not interfere with your actual game experience.", - cmdHidden = true + type = "group", inline = true, + args = { + confdesc = { + order = 1, + type = "description", + name = "" + .."Titan Panel is an Interface Enhancement addon which allows you to add short display bars to the UI as well as the top and bottom of your game screen." + .."\n\n" + .."This addon does not interfere with, enhance, or replace any of your actual gameplay within the game. Titan Panel is meant to give you a quick visual point or click-on access to see the data related to your character without having to open other dialog boxes in the game or, in some cases, other addons." + .."\n\n" + .."Our main program allows you to add bars to the UI as well as the top and bottom of your game screen." + .."\n\n" + .."Over the years, we have been able to add some other features, but only if they do not interfere with your actual game experience.", + cmdHidden = true + }, + } }, confnotes = { name = "Notes", @@ -297,84 +286,95 @@ local optionsControl = { ------------- ------------- --- transparency config section --[[ local -NAME: optionsTrans -DESC: Local table to hold the Titan transparency options. Each bar and the tooltip can be set to a different transparancy setting. -This is the starting shell -- the option description -- add the tooltip transparency (at the bottom of the options screen) -- the code for each bar will be added via another routine. -:DESC +NAME: optionsSkins +DESC: Local table to hold the Titan skins options. Shows default Titan and any custom skins the user has added. --]] -local optionsTrans = { - name = TITAN_PANEL_CONFIG.topic.trans, --L["TITAN_TRANS_MENU_TEXT"], - type = "group", - args = { - confdesc = { - order = 1, - type = "description", - name = L["TITAN_TRANS_MENU_DESC"].."\n", - cmdHidden = true - }, - }, - } +local optionsSkins = { + name = TITAN_PANEL_CONFIG.topic.skins, + type = "group", + args = { + } +} ---[[ local -NAME: TitanPanel_TransOptions -DESC: This will add each Titan bar to the transparency option table so it can be adjusted by the user. Each bar is shown whether ot not the user has them displayed. -VAR: args - the table holding the Titan option data -OUT: None +-- skins config section + +local function Show_Skins(t, position) +--[[ + table.sort(TitanSkins, function(a, b) + return string.lower(TitanSkins[a].name) + < string.lower(TitanSkins[b].name) + end) --]] -local function TitanPanel_TransOptions(args) - local bar = "" - local bar_name = "" - local var = "" - local vert = nil - local position - for idx,v in pairs (TitanBarData) do - bar = TitanBarData[idx].name - vert = TitanBarData[idx].vert - position = TitanBarData[idx].order + 10 - var = bar.."_Transparency" - bar_name = TITAN_PANEL_DISPLAY_PREFIX..bar - args[bar_name] = { - name = TitanBarData[idx].locale_name, - desc = "", - order = position, type = "range", width = "full", - min = 0, max = 1, step = 0.01, - get = function(info) - local bar = TitanBarData[info[1]].name - return TitanPanelGetVar(bar.."_Transparency") - end, - set = function(info, a) - local bar = TitanBarData[info[1]].name - _G[info[1]]:SetAlpha(a) - TitanPanelSetVar(bar.."_Transparency", a); - end, + local skin = "Skin" + for idx, v in pairs (TitanSkins) do + + position = position + 1 -- spacer + t[skin..position] = { + type = "header", + name = "", + order = position, width = "full", + } + + position = position + 1 -- Name of skin (col 1) + t[skin..position] = { + type = "description", + name = "|cff19ff19"..v.name.."|r", + order = position, width = "30", + } + + position = position + 1 -- Top image (col 2) + t[skin..position] = { + type = "description", + name = "", + image = v.path.."TitanPanelBackgroundTop0", + imageWidth = 256, + order = position, width = "50", + } + + position = position + 1 -- spacer + t[skin..position] = { + type = "description", + name = "", imageHeight = 0, + order = position, width = "full", + } + + position = position + 1 -- Bottom (col 1) + t[skin..position] = { + type = "description", + name = "", + order = position, width = "30", + } + position = position + 1 -- Bottom image (col 2) + t[skin..position] = { + type = "description", + name = "", + image = v.path.."TitanPanelBackgroundBottom0", + imageWidth = 256, + order = position, width = "50", + } + + position = position + 1 -- final spacer - bottom of config + t[skin..position] = { + type = "description", + name = "", imageHeight = 0, + order = position, width = "full", } - position = position + 1 end + + position = position + 1 -- final spacer - bottom of config + t[skin..position] = { + type = "description", + name = "", + order = position, width = "full", + } end -------------- -------------- --- skins config section ---[[ local -NAME: TitanPanel_SetCustomTexture -DESC: Update the skin when the user changes it. -VAR: path - the file path to the skin -OUT: None ---]] -local function TitanPanel_SetCustomTexture(path) - if path ~= TitanPanelGetVar("TexturePath") then - TitanPanelSetVar("TexturePath", path); - for idx,v in pairs (TitanBarData) do - TitanPanel_SetTexture( - TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name, - TITAN_PANEL_PLACE_TOP); - end - end +local function BuildSkins() + optionsSkins.args = {} + + Show_Skins(optionsSkins.args, 100) -- the current list of skins with images + AceConfigRegistry:NotifyChange("Titan Panel Skin Control") end --[[ local @@ -410,69 +410,11 @@ local function TitanPanel_AddNewSkin(skinname, skinpath) if not found then table.insert(TitanSkins, {name = skinname, path = skinpath }) end + + BuildSkins() + end ---[[ local -NAME: optionsSkins -DESC: Local table to hold the Titan skins options. Shows default Titan and any custom skins the user has added. ---]] -local optionsSkins = { - name = TITAN_PANEL_CONFIG.topic.skins, --L["TITAN_SKINS_TITLE"], - type = "group", - args = { - setskinhdear = { - order = 2, - type = "header", - name = L["TITAN_SKINS_SET_HEADER"], - }, - setskinlist = { - order = 3, type = "select", - name = L["TITAN_SKINS_LIST_TITLE"], - desc = L["TITAN_SKINS_SET_DESC"], - get = function() return TitanPanelGetVar("TexturePath") end, - set = function(_,v) - TitanPanel_SetCustomTexture(v) - if TitanSkinToRemove == TitanPanelGetVar("TexturePath") then - TitanSkinToRemove = "None" - end - end, - values = function() - local Skinlist = {} - local v; - for _,v in pairs (TitanSkins) do - if v.path ~= TitanPanelGetVar("TexturePath") then - Skinlist[v.path] = "|cff19ff19"..v.name.."|r" - else - Skinlist[v.path] = "|cffffff9a"..v.name.."|r" - end - end - table.sort(Skinlist, function(a, b) - return string.lower(TitanSkins[a].name) - < string.lower(TitanSkins[b].name) - end) - return Skinlist - end, - }, - nulloption1 = { - order = 5, - type = "description", - name = " ", - cmdHidden = true - }, - resetskinhdear = { - order = 20, - type = "header", - name = L["TITAN_SKINS_RESET_HEADER"], - }, - defaultskins = { - order = 21, - name = L["TITAN_SKINS_RESET_DEFAULTS_TITLE"], type = "execute", - desc = L["TITAN_SKINS_RESET_DEFAULTS_DESC"], - func = function() - TitanSkins = TitanSkinsDefault; - end, - }, - } -} + --[[ local NAME: optionsSkinsCustom DESC: Local table to hold the Titan custom skins options that allow a user to add or delete skins. @@ -596,18 +538,32 @@ local optionsSkinsCustom = { end end, }, - notes_delete = { - order = 23, - type = "description", - name = L["TITAN_SKINS_REMOVE_NOTES"].."\n", - cmdHidden = true - }, nulloption4 = { order = 24, type = "description", name = " ", cmdHidden = true }, + resetskinhdear = { + order = 200, + type = "header", + name = L["TITAN_SKINS_RESET_HEADER"], + }, + defaultskins = { + order = 201, + name = L["TITAN_SKINS_RESET_DEFAULTS_TITLE"], type = "execute", + desc = L["TITAN_SKINS_RESET_DEFAULTS_DESC"], + func = function() + TitanSkins = TitanSkinsDefault; + BuildSkins() + end, + }, + notes_delete = { + order = 999, + type = "description", + name = "\n\n"..L["TITAN_SKINS_REMOVE_NOTES"].."\n", + cmdHidden = true + }, } } ------------- @@ -777,249 +733,273 @@ local optionsBars = { name = TITAN_PANEL_CONFIG.topic.top, --L["TITAN_PANEL_MENU_OPTIONS_MAIN_BARS"], type = "group", args = { - confdesc1 = { - order = 100, - type = "header", - name = L["TITAN_PANEL_MENU_TOP"], - }, - optiontop = { - name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - desc = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = 101, type = "toggle", width = "full", - get = function() return (TitanPanelGetVar("Bar_Show")) end, - set = function() - TitanPanelToggleVar("Bar_Show") - TitanPanelBarButton_DisplayBarsWanted("Bar_Show "..tostring(TitanPanelGetVar("Bar_Show"))) - end, - }, - optiontophide = { - name = L["TITAN_PANEL_MENU_AUTOHIDE"], - desc = L["TITAN_PANEL_MENU_AUTOHIDE"], - order = 103, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("Bar_Hide") end, - set = function() - TitanPanelBarButton_ToggleAutoHide(TITAN_PANEL_DISPLAY_PREFIX.."Bar") - end, - }, - optiontopcenter = { - name = L["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 104, type = "toggle", width = "full", - get = function() - return (TitanPanelGetVar("Bar_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function() - local tmp = TitanPanelGetVar("Bar_Align"); - TitanPanelBarButton_ToggleAlign("Bar_Align"); --- TitanDebug("Bar c: "..tmp.." "..TitanPanelGetVar("Bar_Align")); - end, - }, - confdesc2 = { - order = 200, - type = "header", - name = L["TITAN_PANEL_MENU_TOP2"], - }, - optionbottom = { - name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - desc = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = 201, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("Bar2_Show") end, - set = function() - TitanPanelToggleVar("Bar2_Show") - TitanPanelBarButton_DisplayBarsWanted("Bar2_Show "..tostring(TitanPanelGetVar("Bar2_Show"))) - end, - }, - optionbottomhide = { - name = L["TITAN_PANEL_MENU_AUTOHIDE"], - desc = L["TITAN_PANEL_MENU_AUTOHIDE"], - order = 203, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("Bar2_Hide") end, - set = function() - TitanPanelBarButton_ToggleAutoHide(TITAN_PANEL_DISPLAY_PREFIX.."Bar2"); - end, - }, - optionbottomcenter = { - name = L["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 204, type = "toggle", width = "full", - get = function() - return (TitanPanelGetVar("Bar2_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function() TitanPanelBarButton_ToggleAlign("Bar2_Align"); end, - }, } } +local function ColorShown(bar) + local res = (bar.locale_name or "?") + if TitanPanelGetVar(bar.name.."_Show") then + -- leave as is + else + res = "|cff808080"..res.._G["FONT_COLOR_CODE_CLOSE"] + end + + return res +end + --[[ local -NAME: optionsAuxBars -DESC: Bar control for the aux (bottom) bars: -Each bar: -- Show -- Auto hide -- Center text (plugins) -Main (top) controls: -- Disable screen adjust - allows action button bar to be 'over' the Titan bars -- Log adjust - move the chat frame to be 'above' the Titan bars -- Bag adjust - move the bag frames to be 'above' the Titan bars +NAME: TitanUpdateConfigBars +DESC: Allow the user to control each Titan bar. :DESC +VAR: None +OUT: None --]] -local optionsAuxBars = { - name = TITAN_PANEL_CONFIG.topic.bottom, --L["TITAN_PANEL_MENU_OPTIONS_AUX_BARS"], - type = "group", - args = { - confdesc1 = { - order = 100, - type = "header", - name = L["TITAN_PANEL_MENU_BOTTOM"], - }, - optiontop = { - name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - desc = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = 101, type = "toggle", width = "full", - get = function() return (TitanPanelGetVar("AuxBar_Show")) end, - set = function() - TitanPanelToggleVar("AuxBar_Show") - TitanPanelBarButton_DisplayBarsWanted("AuxBar_Show "..tostring(TitanPanelGetVar("AuxBar_Show"))) - end, - }, - optiontophide = { - name = L["TITAN_PANEL_MENU_AUTOHIDE"], - desc = L["TITAN_PANEL_MENU_AUTOHIDE"], - order = 103, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("AuxBar_Hide") end, - set = function() - TitanPanelBarButton_ToggleAutoHide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"); - end, - }, - optiontopcenter = { - name = L["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 104, type = "toggle", width = "full", - get = function() - return (TitanPanelGetVar("AuxBar_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function() TitanPanelBarButton_ToggleAlign("AuxBar_Align"); end, - }, - confdesc2 = { - order = 200, +local function TitanUpdateConfigBars(t, pos) + local args = t + local position = pos + + -- sort the bar data by their intended order + local bar_list = {} + for _,v in pairs (TitanBarData) do + bar_list[v.order] = v + end + table.sort(bar_list, function(a, b) + return a.order < b.order + end) + + local label = "Bar" + + wipe(args) + + for idx = 1, #bar_list do + local v = bar_list[idx] -- process this bar + -- Build the bar list in order (left side) + position = position + 1 + args[v.name] = { + type = "group", + name = ColorShown(v), + order = position, + } + -- ====== + -- Build bar options (right side) + args[v.name].args = {} + position = position + 1 -- Title divider + args[v.name].args.title = { type = "header", - name = L["TITAN_PANEL_MENU_BOTTOM2"], - }, - optionbottom = { - name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - desc = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = 201, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("AuxBar2_Show") end, - set = function() - TitanPanelToggleVar("AuxBar2_Show") - TitanPanelBarButton_DisplayBarsWanted("AuxBar2_Show "..tostring(TitanPanelGetVar("AuxBar2_Show"))) + name = v.locale_name, + order = position, width = "full", + } + position = position + 1 -- Show toggle + args[v.name].args.show = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], + order = position, + get = function(info) return (TitanPanelGetVar(v.name.."_Show")) end, + set = function(info, val) + TitanPanelToggleVar(v.name.."_Show") + TitanPanelBarButton_DisplayBarsWanted(v.name.."_Show "..tostring(TitanPanelGetVar(v.name.."_Show"))) + + TitanUpdateConfigBars(optionsBars.args, 1000) end, - }, - optionbottomhide = { - name = L["TITAN_PANEL_MENU_AUTOHIDE"], - desc = L["TITAN_PANEL_MENU_AUTOHIDE"], - order = 203, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("AuxBar2_Hide") end, - set = function() - TitanPanelBarButton_ToggleAutoHide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"); - end, - }, - optionbottomcenter = { - name = L["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 204, type = "toggle", width = "full", - get = function() - return (TitanPanelGetVar("AuxBar2_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function() TitanPanelBarButton_ToggleAlign("AuxBar2_Align"); end, - }, - confdesc3 = { - order = 400, - type = "header", - name = "Vertical Adjustment", --L["TITAN_PANEL_MENU_BOTTOM2"], - }, - confmainmenudesc = { - name = "Menu and Bag Buttons", - type = "group", inline = true, - order = 401, - args = { - confbuffdesc = { - order = 110, - type = "description", - name = "Adjust Micro menu and Bag Buttons Vertically", --L["TITAN_PANEL_MENU_ADV_DESC"], - cmdHidden = true - }, - optionadjon = { - name = USE, -- "On.", --["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = "Adjust Menu and Bag Bar", --L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 115, type = "toggle", width = "full", - get = function() - return TitanPanelGetVar("MenuAndBagVerticalAdjOn") + } + position = position + 1 -- Auto hide toggle + args[v.name].args.autohide = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_AUTOHIDE"], + order = position, + disabled = (v.hider == nil), + get = function(info) return (TitanPanelGetVar(v.name.."_Hide")) end, + set = function(info, val) + Titan_AutoHide_ToggleAutoHide(v.name) -- short bar name end, - set = function(_, a) - TitanPanelSetVar("MenuAndBagVerticalAdjOn", a) --- DF switch to sliding menu & bag bar since 10.0 allows user to adjust most frames - TitanPanel_AdjustFrames(true, "MenuAndBagVerticalAdj") + } + position = position + 1 -- Center toggle + args[v.name].args.center = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_CENTER_TEXT"], + order = position, + get = function() + return (TitanPanelGetVar(v.name.."_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) end, - }, - advbuffadj = { - name = "Menu and Bags", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], - order = 120, type = "range", width = "full", - min = -100, max = 500, step = 1, - get = function() return TitanPanelGetVar("MenuAndBagVerticalAdj") end, - set = function(_, a) - TitanPanelSetVar("MenuAndBagVerticalAdj", a); - -- Adjust frame positions --- DF switch to sliding menu & bag bar since 10.0 allows user to adjust most frames - TitanPanel_AdjustFrames(true, "MenuAndBagVerticalAdj") + set = function() + TitanPanelBarButton_ToggleAlign(v.name.."_Align"); end, - }, - }, - }, - confxpbardesc = { - name = "Status Bar", - type = "group", inline = true, - order = 410, - args = { - confbuffdesc = { - order = 110, - type = "description", - name = "Adjust XP Bar Vertically", --L["TITAN_PANEL_MENU_ADV_DESC"], - cmdHidden = true - }, - optionadjon = { - name = USE, -- "On.", --["TITAN_PANEL_MENU_CENTER_TEXT"], - desc = "Adjust Status Bar", --L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = 115, type = "toggle", width = "full", - get = function() - return TitanPanelGetVar("XPBarVerticalAdjOn") + } + position = position + 1 -- Combat hide toggle + args[v.name].args.hideincombat = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_HIDE_IN_COMBAT"], + order = position, + get = function() + return TitanPanelGetVar(v.name.."_HideInCombat") end, - set = function(_, a) - TitanPanelSetVar("XPBarVerticalAdjOn", a) --- DF switch to sliding menu & bag bar since 10.0 allows user to adjust most frames - TitanPanel_AdjustFrames(true, "XPBarVerticalAdj") + set = function() + TitanPanelToggleVar(v.name.."_HideInCombat") end, - }, - advbuffadj = { - name = "XP and Status", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], - order = 120, type = "range", width = "full", - min = -20, max = 500, step = 1, - get = function() return TitanPanelGetVar("XPBarVerticalAdj") end, - set = function(_, a) - TitanPanelSetVar("XPBarVerticalAdj", a); - -- Adjust frame positions --- DF switch to sliding menu & bag bar since 10.0 allows user to adjust most frames - TitanPanel_AdjustFrames(true, "XPBarVerticalAdj") + } + position = position + 1 -- spacer + args[v.name].args.barspacer1 = { + order = position, type = "description", width = "full", + name = " ", + } + position = position + 1 -- Skin select + args[v.name].args.skinselect = { + type = "select", width = "normal", + name = "", --v.locale_name, + order = position, + get = function() return TitanPanelGetVar("Texture"..v.name) end, + set = function(_,val) + TitanPanelSetVar("Texture"..v.name, val); + TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..v.name) + if TitanSkinToRemove == TitanPanelGetVar("Texture"..v.name) then + TitanSkinToRemove = "None" + end + end, + values = function() + local Skinlist = {} + for _,val in pairs (TitanSkins) do + if val.path ~= TitanPanelGetVar("Texture"..v.name) then + Skinlist[val.path] = "|cff19ff19"..val.name.."|r" + else + Skinlist[val.path] = "|cffffff9a"..val.name.."|r" + end + end + table.sort(Skinlist, function(a, b) + return string.lower(TitanSkins[a].name) + < string.lower(TitanSkins[b].name) + end) + return Skinlist end, + } +---[[ + position = position + 1 -- spacer + args[v.name].args.skinspacer = { + order = position, type = "description", width = "5", + name = " ", + } +--]] + position = position + 1 -- selected skin + args[v.name].args.skinselected = { + name = "", + image = function() + local vert = v.vert + if vert == TITAN_SHORT then + vert = TITAN_TOP + else + -- Use it as is + end + return TitanPanelGetVar("Texture"..v.name).."TitanPanelBackground"..vert.."0" + end, + imageWidth = 256, + order = position, type = "description", width = .5, --"60", + } + position = position + 1 -- spacer + args[v.name].args.transpacer1 = { + order = position, type = "description", width = "full", + name = " ", + } + position = position + 1 -- transparency + args[v.name].args.trans = { + type = "range", width = "full", + name = L["TITAN_TRANS_MENU_TEXT_SHORT"], + order = position, + min = 0, max = 1, step = 0.01, + get = function(info) +-- local bar = TitanBarData[info[1]].name + return TitanPanelGetVar(v.name.."_Transparency") + end, + set = function(info, a) + local bar = TITAN_PANEL_DISPLAY_PREFIX..info[1] + _G[bar]:SetAlpha(a) + TitanPanelSetVar(info[1].."_Transparency", a); + end, + } + position = position + 1 -- spacer + args[v.name].args.resetposspacer = { + order = position, type = "description", width = "full", + name = " ", + } + position = position + 1 -- reset pos + args[v.name].args.resetbar = { + type = "execute", width = "Full", + name = L["TITAN_PANEL_MENU_RESET_POSITION"], + order = position, + disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), + func = function(info, arg1) + TitanVariables_SetBarPos(_G[TITAN_PANEL_DISPLAY_PREFIX..v.name], true) + end, + } + end + + -- Config Tables changed! + AceConfigRegistry:NotifyChange("Titan Panel Bars") +end + +local function BuildBars() + TitanUpdateConfigBars(optionsBars.args, 1000) + AceConfigRegistry:NotifyChange("Titan Panel Bars") +end + +------------- +-- Help config section + +local help_text = "" +do -- set help_text +help_text = "" + ..TitanUtils_GetGreenText("Short Bars: \n") + ..TitanUtils_GetHighlightText("" + .."Short bars are 10 shorter Titan bars that the user can place and change width.\n" + .."- Short bars are independent. They may be used with or without the full width Titan bars.\n" + .."- Enable and change options using Configuration > Bars.\n" + .."- The position is the top center under the full width bars. They will be stacked to not overlap.\n" + .."- Move : Use Alt + left mouse and dragging.\n" + .."- Change width : Use Alt + mouse wheel.\n" + .."- When moving or changing, best to place your mouse over the left side padding before moving or changing width.\n" + .."- Reset : In case a Short bar gets messed up use Reset Position to reset it to original position and width.\n" + .."- Min width : Left side padding plus one icon width.\n" + .."- Max width : Screen width.\n" + .."- Skin : Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" + ) + .."\n\n" + ..TitanUtils_GetGreenText("All Bars: \n") + ..TitanUtils_GetHighlightText("" + .."- Hide any Titan bar by right click on the Titan bar (not a plugin) then click Hide.\n" + .."- Skins : \n" + .."--- Can select per Titan bar.\n" + .."--- Can select a skin for all Titan bars. This does NOT change the individual Titan bar skin settings.\n" + .."- Hide in Combat : \n" + .."--- Can select per Titan bar.\n" + .."--- Can hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" + .."- NOTE : Right click menu shows the name of the bar in the title to enable finding the correct configuration options.\n" + ) + .."\n\n" +end +--[[ local +NAME: helpBars +DESC: Help for the Titan Panel user +:DESC +--]] +local helpBars = { + name = TITAN_PANEL_CONFIG.topic.help, + type = "group", + args = { + confgendesc = { + name = "Help", + order = 1, + type = "group", inline = true, + args = { + confdesc = { + order = 1, + type = "description", + name = help_text, + cmdHidden = true }, - }, + } }, } } - ------------- + -- General Titan config section --[[ local NAME: optionsFrames @@ -1071,8 +1051,8 @@ local optionsFrames = { cmdHidden = true, }, advname = { - name = "Use Modifier to Show Tooltip", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + name = L["TITAN_PANEL_MENU_TOOLTIP_MOD"], + desc = "", -- L[""], order = 120, type = "toggle", width = "full", get = function() return TitanAllGetVar("UseTooltipModifer") end, set = function(_, a) @@ -1085,8 +1065,8 @@ local optionsFrames = { order = 140, args = { alt_key = { - name = ALT_KEY_TEXT, - desc = ALT_KEY, + name = L["TITAN_KEY_ALT"], + desc = L["TITAN_KEY_ALT_DESC"], order = 110, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferAlt") end, set = function(_, a) @@ -1094,8 +1074,8 @@ local optionsFrames = { end, }, ctrl_key = { - name = CTRL_KEY_TEXT, - desc = CTRL_KEY, + name = L["TITAN_KEY_CTRL"], + desc = L["TITAN_KEY_CTRL_DESC"], order = 120, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferCtrl") end, set = function(_, a) @@ -1103,8 +1083,8 @@ local optionsFrames = { end, }, shift_key = { - name = SHIFT_KEY_TEXT, - desc = SHIFT_KEY, + name = L["TITAN_KEY_SHIFT"], + desc = L["TITAN_KEY_SHIFT_DESC"], order = 130, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferShift") end, set = function(_, a) @@ -1122,21 +1102,18 @@ local optionsFrames = { }, optionlock = { name = L["TITAN_PANEL_MENU_LOCK_BUTTONS"], - desc = L["TITAN_PANEL_MENU_LOCK_BUTTONS"], order = 301, type = "toggle", width = "full", get = function() return TitanPanelGetVar("LockButtons") end, set = function() TitanPanelToggleVar("LockButtons") end, }, optionversions = { name = L["TITAN_PANEL_MENU_VERSION_SHOWN"], --- desc = L["TITAN_PANEL_MENU_VERSION_SHOWN"], order = 302, type = "toggle", width = "full", get = function() return TitanPanelGetVar("VersionShown") end, set = function() TitanPanelToggleVar("VersionShown") end, }, autohidelock = { name = L["TITAN_PANEL_MENU_AUTOHIDE_IN_COMBAT"], - desc = "Lock_auto_hide", order = 303, type = "toggle", width = "full", get = function() return TitanPanelGetVar("LockAutoHideInCombat") end, set = function() TitanPanelToggleVar("LockAutoHideInCombat") end, @@ -1182,6 +1159,83 @@ local optionsFrames = { ------------- ------------- +-- Bars Global config section +------------- +local optionsGlobals = { + name = TITAN_PANEL_CONFIG.topic.globals, + type = "group", + args = { + confdesc = { + order = 10, width = "full", + type = "header", + name = L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"], + }, + setskinuseglobal = { + name = L["TITAN_PANEL_MENU_GLOBAL_SKIN"], + desc = L["TITAN_PANEL_MENU_GLOBAL_SKIN_TIP"], + order = 15, type = "toggle", width = "full", + get = function() return TitanPanelGetVar("UseGlobalTexture") end, + set = function() TitanPanelToggleVar("UseGlobalTexture"); + for idx, v in pairs (TitanBarData) do + TitanPanel_SetTexture(idx) + end + end, + }, + setskinglobal = { + order = 20, type = "select", width = "30", + name = " ", --L["TITAN_SKINS_LIST_TITLE"], + desc = L["TITAN_SKINS_SET_DESC"], + get = function() return TitanPanelGetVar("TexturePath") end, + set = function(_,v) + TitanPanelSetVar("TexturePath", v); + end, + values = function() + local Skinlist = {} + local v; + for _,v in pairs (TitanSkins) do + if v.path ~= TitanPanelGetVar("TexturePath") then + Skinlist[v.path] = "|cff19ff19"..v.name.."|r" + else + Skinlist[v.path] = "|cffffff9a"..v.name.."|r" + end + end + table.sort(Skinlist, function(a, b) + return string.lower(TitanSkins[a].name) + < string.lower(TitanSkins[b].name) + end) + return Skinlist + end, + }, + show_skin_top_desc = { + type = "description", + name = "", + order = 30, width = "10", + }, + show_skin_global_top = { + type = "description", + name = "", + image = function() + return TitanPanelGetVar("TexturePath").."TitanPanelBackgroundTop0" + end, + imageWidth = 256, + order = 31, width = "60", + }, + confcombatdesc = { + order = 100, width = "full", + type = "header", + name = L["TITAN_PANEL_MENU_COMMAND"], + }, + setcombatuseglobal = { + name = L["TITAN_PANEL_MENU_HIDE_IN_COMBAT"], + desc = L["TITAN_PANEL_MENU_HIDE_IN_COMBAT_DESC"], + order = 105, type = "toggle", width = "full", + get = function() return TitanPanelGetVar("UseGlobal_HideInCombat") end, + set = function() TitanPanelToggleVar("UseGlobal_HideInCombat"); end, + }, + } +} + +------------- -- attempted plugins config section --[[ local NAME: optionsAddonAttempts @@ -1192,6 +1246,7 @@ local optionsAddonAttempts = { type = "group", args = {} } + --[[ local NAME: TitanUpdateAddonAttempts DESC: Show the each plugin that attempted to register with Titan. This can be used by plugin developers as the create / update plugins (Titan or LDB). It can also be used by user to attempt to figure out why a plugin is not shown or to report an issue to Titan. @@ -1320,7 +1375,8 @@ local optionsExtras = { name = TITAN_PANEL_CONFIG.topic.extras, --L["TITAN_PANEL_EXTRAS"], type = "group", args = {} - } +} + --[[ local NAME: TitanUpdateAddonAttempts DESC: Show plugins that are not registered (loaded) but have config data. The data can be deleted by the user. @@ -1391,6 +1447,7 @@ local optionsChars = { type = "group", args = {} } + --[[ local NAME: TitanUpdateChars DESC: Allow the user to delete toon data (just not the one they are logged into). @@ -1628,6 +1685,7 @@ local optionsAddons = { type = "group", args = {} } + local function ColorVisible(id, name) local res = "?" if TitanPanel_IsPluginShown(id) then @@ -1638,6 +1696,7 @@ local function ColorVisible(id, name) return res end + --[[ local NAME: TitanUpdateConfigAddons DESC: Allow the user to control each plugin registered to Titan. @@ -1853,12 +1912,12 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.custom_notes = { order = 60, type = "header", - name = "Notes", + name = L["TITAN_PANEL_MENU_ADV_NOTES_PLUGIN"], } if plug_in.notes then args[plug_in.id].args.notes = { type = "description", - name = "Notes", + name = L["TITAN_PANEL_MENU_ADV_NOTES"], order = 61, name = "" .._G["GREEN_FONT_COLOR_CODE"]..plug_in.notes.."|r", @@ -1867,9 +1926,9 @@ local function TitanUpdateConfigAddons() else args[plug_in.id].args.notes = { type = "description", - name = "Notes", + name = L["TITAN_PANEL_MENU_ADV_NOTES"], order = 61, - name = _G["GREEN_FONT_COLOR_CODE"]..NONE.."|r", + name = _G["GREEN_FONT_COLOR_CODE"]..L["TITAN_NONE"].."|r", cmdHidden = true, } end @@ -1881,11 +1940,11 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.custom_labels = { order = 70, type = "header", - name = SHOW.." "..CUSTOM.." ".."Labels", + name = L["TITAN_PANEL_MENU_ADV_LABEL"], } args[plug_in.id].args.custom_label_show = { type = "toggle", - name = SHOW, + name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 1", order = 71, get = function(info) return (TitanGetVar(info[1], "CustomLabelTextShow") or false) end, set = function(info, v) @@ -1895,8 +1954,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label_text = { order = 72, - name = CUSTOM, - desc = "Custom label text to show", + name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], + desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabelText") or "") end, set = function(info,v) @@ -1908,7 +1967,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 2 then args[plug_in.id].args.custom_label2_show = { type = "toggle", - name = SHOW.." 2", + name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 2", order = 73, get = function(info) return (TitanGetVar(info[1], "CustomLabel2TextShow") or false) end, set = function(info, v) @@ -1918,8 +1977,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label2_text = { order = 74, - name = CUSTOM, - desc = "Custom label text to show", + name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], + desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel2Text") or "") end, set = function(info,v) @@ -1931,7 +1990,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 3 then args[plug_in.id].args.custom_label3_show = { type = "toggle", - name = SHOW.." 3", + name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 3", order = 75, get = function(info) return (TitanGetVar(info[1], "CustomLabel3TextShow") or false) end, set = function(info, v) @@ -1941,8 +2000,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label3_text = { order = 76, - name = CUSTOM, - desc = "Custom label text to show", + name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], + desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel3Text") or "") end, set = function(info,v) @@ -1954,7 +2013,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 4 then args[plug_in.id].args.custom_label4_show = { type = "toggle", - name = SHOW.." 4", + name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 4", order = 77, get = function(info) return (TitanGetVar(info[1], "CustomLabel4TextShow") or false) end, set = function(info, v) @@ -1964,8 +2023,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label4_text = { order = 78, - name = CUSTOM, - desc = "Custom label text to show", + name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], + desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel4Text") or "") end, set = function(info,v) @@ -1980,6 +2039,7 @@ local function TitanUpdateConfigAddons() -- Config Tables changed! AceConfigRegistry:NotifyChange("Titan Panel Addon Control") end + ------------- --[[ local NAME: optionsAdvanced @@ -2001,12 +2061,12 @@ local optionsAdvanced = { confdesc = { order = 110, type = "description", - name = "Output Various Titan Info At Startup.", --L["TITAN_PANEL_MENU_ADV_DESC"], + name = L["TITAN_PANEL_MENU_ADV_DESC"], cmdHidden = true }, advname = { - name = "Name and Version", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + name = L["TITAN_PANEL_MENU_ADV_NAME"], + desc = L["TITAN_PANEL_MENU_ADV_NAME_DESC"], order = 120, type = "toggle", width = "full", get = function() return not TitanAllGetVar("Silenced") end, -- yes, we did it to ourselves... set = function(_, a) @@ -2014,8 +2074,8 @@ local optionsAdvanced = { end, }, advplugins = { - name = "Plugin Registration process", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "Shows start and end of Registration process and number of registered plugins", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + name = L["TITAN_PANEL_MENU_ADV_PLUGINS"], + desc = L["TITAN_PANEL_MENU_ADV_PLUGINS_DESC"], order = 120, type = "toggle", width = "full", get = function() return TitanAllGetVar("Registered") end, set = function(_, a) @@ -2028,7 +2088,7 @@ local optionsAdvanced = { } --[[ local -NAME: change history +NAME: Recent change history DESC: Show change history of releases :DESC --]] @@ -2038,14 +2098,13 @@ local changeHistory = { args = { confchanges = { order = 7, - name = CHANGES_COLON, + name = " ", --CHANGES_COLON, type = "group", inline = true, args = { confversiondesc = { order = 1, type = "description", - name = "" - ..changes, + name = ""..changes, cmdHidden = true }, } @@ -2130,7 +2189,8 @@ function TitanUpdateConfig(action) TitanUpdateAddonAttempts() TitanUpdateExtras() TitanUpdateChars() - TitanPanel_TransOptions(optionsTrans.args) + BuildSkins() + BuildBars() end if action == "nuke" then local nuked = { @@ -2143,7 +2203,8 @@ function TitanUpdateConfig(action) -- Use the same group as below!! -- AceConfig:RegisterOptionsTable("Titan Panel Main", nuked) AceConfig:RegisterOptionsTable("Titan Panel Bars", nuked) - AceConfig:RegisterOptionsTable("Titan Panel Aux Bars", nuked) + AceConfig:RegisterOptionsTable("Titan Panel Globals", nuked) +-- AceConfig:RegisterOptionsTable("Titan Panel Aux Bars", nuked) AceConfig:RegisterOptionsTable("Titan Panel Frames", nuked) AceConfig:RegisterOptionsTable("Titan Panel Transparency Control", nuked) AceConfig:RegisterOptionsTable("Titan Panel Panel Control", nuked) @@ -2154,9 +2215,12 @@ function TitanUpdateConfig(action) AceConfig:RegisterOptionsTable("Titan Panel Addon Extras", nuked) AceConfig:RegisterOptionsTable("Titan Panel Addon Chars", nuked) AceConfig:RegisterOptionsTable("Titan Panel Addon Advanced", nuked) + AceConfig:RegisterOptionsTable("Titan Panel Addon Changes", nuked) + AceConfig:RegisterOptionsTable("Titan Panel Addon Slash", nuked) end end + --[[ Register the options tables with Ace then register the options with Blizz so the user can use them. --]] @@ -2166,9 +2230,8 @@ The second param must be the table Ace will use to create the user options --]] AceConfig:RegisterOptionsTable("Titan Panel Main", optionsControl) AceConfig:RegisterOptionsTable("Titan Panel Bars", optionsBars) -AceConfig:RegisterOptionsTable("Titan Panel Aux Bars", optionsAuxBars) +AceConfig:RegisterOptionsTable("Titan Panel Globals", optionsGlobals) AceConfig:RegisterOptionsTable("Titan Panel Frames", optionsFrames) -AceConfig:RegisterOptionsTable("Titan Panel Transparency Control", optionsTrans) AceConfig:RegisterOptionsTable("Titan Panel Panel Control", optionsUIScale) AceConfig:RegisterOptionsTable("Titan Panel Skin Control", optionsSkins) AceConfig:RegisterOptionsTable("Titan Panel Skin Custom", optionsSkinsCustom) @@ -2179,6 +2242,7 @@ AceConfig:RegisterOptionsTable("Titan Panel Addon Chars", optionsChars) AceConfig:RegisterOptionsTable("Titan Panel Addon Advanced", optionsAdvanced) AceConfig:RegisterOptionsTable("Titan Panel Addon Changes", changeHistory) AceConfig:RegisterOptionsTable("Titan Panel Addon Slash", slashHelp) +AceConfig:RegisterOptionsTable("Titan Panel Help", helpBars) --]] -- Set the main options pages --[[ The first param must be the same as the cooresponding 'Ace register' @@ -2188,12 +2252,11 @@ if not, any 'open' may fail. --AceConfigDialog:AddToBlizOptions("Titan Panel Main", L["TITAN_PANEL"]) AceConfigDialog:AddToBlizOptions("Titan Panel Main", optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Bars", optionsBars.name, optionsControl.name) -AceConfigDialog:AddToBlizOptions("Titan Panel Aux Bars", optionsAuxBars.name, optionsControl.name) +AceConfigDialog:AddToBlizOptions("Titan Panel Globals", optionsGlobals.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Control", optionsAddons.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Chars", optionsChars.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Frames", optionsFrames.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Panel Control", optionsUIScale.name, optionsControl.name) -AceConfigDialog:AddToBlizOptions("Titan Panel Transparency Control", optionsTrans.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Skin Control", optionsSkins.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Skin Custom", optionsSkinsCustom.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Extras", optionsExtras.name, optionsControl.name) @@ -2201,4 +2264,4 @@ AceConfigDialog:AddToBlizOptions("Titan Panel Addon Attempts", optionsAddonAttem AceConfigDialog:AddToBlizOptions("Titan Panel Addon Advanced", optionsAdvanced.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Changes", changeHistory.name, optionsControl.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Slash", slashHelp.name, optionsControl.name) - +AceConfigDialog:AddToBlizOptions("Titan Panel Help", helpBars.name, optionsControl.name) diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index cf996b4..a3147c1 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -1,50 +1,18 @@ --[[ File NAME: TitanMovable.lua -DESC: Contains the routines to adjust the Blizzard frames to make room for the Titan bars the user has selected. - -DragonFlight introduced an Edit Mode for the user to move various frames where they want them. -However two UI elements were not included: -- XP / Status bar (with the reputation bar above) -- menu & bag buttons - -This greatly chanegd the work Titan needed to do. -Now Titan only needs to allow the user to manually adjust the two UI elements themselves. +DESC: DragonFlight introduced an Edit Mode for the user to move various frames where they want them. +Titan no longer needs to do this work. +The only routine is an API call so other addons can determine where Titan Panel is on the UI based on user selection - top and bottom bars only. :DESC -NOTE: -- All secure hooks were removed from Movable. -- All timers were removed from Movable. -:NOTE - --]] -- Globals -- Locals local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; -local hooks_done = false; -local move_count = 0 - -local function Titan_AdjustFrame(frame_str, flag, offset) - local frame = _G[frame_str] - local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint() - if point and relativeTo and relativePoint and xOfs then - -- Check if user has requested... We can get here via player entering world - if TitanPanelGetVar(flag) then - frame:ClearAllPoints() - frame:SetPoint(point, relativeTo:GetName(), relativePoint, xOfs, TitanPanelGetVar(offset)) - op = "move - y "..tostring(y) - else - -- User has not reqeuested Titan do anything. - op = "skip - User has not asked Titan to move XP / Status bar" - end - else - op = "skip - :GetPoint invalid" - -- do not proceed - end -end --[[ API NAME: TitanMovable_GetPanelYOffset @@ -93,74 +61,6 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons return 0 end --- ============= ---[[ Titan -NAME: TitanPanel_AdjustFrames -DESC: Adjust the frames for the Titan visible bars. -This is a shell for the actual Movable routine used by other Titan routines and secure hooks -VAR: force - Force an adjust such as when the user changes bars shown -VAR: reason - Debug to determine where and why an adjust is requested -OUT: None -NOTE: -:NOTE ---]] -function TitanPanel_AdjustFrames(force, reason) - if TITAN_PANEL_VARS.debug.movable then - TitanDebug ("_AdjustFrames :" - .." f: "..tostring(force) - .." r: '"..tostring(reason).."'" - ) - end - --- DF Titan no longer react to hooks to move frames - -- Adjust frame positions top and bottom based on user choices - Titan_AdjustFrame("MicroButtonAndBagsBar", "MenuAndBagVerticalAdjOn", "MenuAndBagVerticalAdj") - Titan_AdjustFrame("StatusTrackingBarManager", "XPBarVerticalAdjOn", "XPBarVerticalAdj") - ---[[ - if hooks_done then - if reason == "Init: PEW (Player Entering World)" - or reason == "MenuAndBagVerticalAdj" then - Titan_AdjustFrame("MicroButtonAndBagsBar", "MenuAndBagVerticalAdjOn", "MenuAndBagVerticalAdj") - end - if reason == "Init: PEW (Player Entering World)" - or reason == "XPBarVerticalAdj" then - Titan_AdjustFrame("StatusTrackingBarManager", "XPBarVerticalAdjOn", "XPBarVerticalAdj") - end - end ---]] -end - ---[[ Titan -NAME: TitanMovable_SecureFrames -DESC: Once Titan is initialized get info we need to help adjust frames properly. -VAR: None -OUT: None ---]] -function TitanMovable_SecureFrames() - - -- Save the original Y offest for the few frames the user may want to adjust via Titan - local point, relativeTo, relativePoint, xOfs, yOfs, frame - ----[=[ - frame = _G["MicroButtonAndBagsBar"] - point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint() - frame.original_y = yOfs ---]=] - ----[=[ - frame = _G["StatusTrackingBarManager"] - point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint() - frame.original_y = yOfs ---]=] - - hooks_done = true - - -- On start, adjust according to the user settings - TitanPanel_AdjustFrames(true, "Init: PEW (Player Entering World)") - -end - --[[ TitanDebug ("MoveFrame :" .." "..tostring(frame:GetName()) diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua index 3a0dd28..1a8f481 100644 --- a/Titan/TitanPanel.lua +++ b/Titan/TitanPanel.lua @@ -15,8 +15,7 @@ local TITAN_PANEL_FROM_TOP_MAIN = 1; local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; local IsTitanPanelReset = nil; -local numOfTextures = 0; -local numOfTexturesHider = 0; +local new_toon = false -- Library references local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -237,7 +236,7 @@ end --[[ local NAME: TitanPanel_CreateABar -DESC: Helper to create the Titan bar passed in. +DESC: Helper to add scripts to the Titan bar passed in. VAR: frame - The frame name (string) of the Titan bar to create OUT: None NOTE: @@ -245,36 +244,43 @@ NOTE: :NOTE --]] local function TitanPanel_CreateABar(frame) - if not frame then return end - local hide_name = TitanBarData[frame].hider - local bar_name = TitanBarData[frame].name - - if hide_name and bar_name then - -- Set script handlers for display - _G[frame]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - _G[frame]:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) - _G[frame]:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) - _G[frame]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - -- Set script handlers for display - _G[hide_name]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - _G[hide_name]:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) - _G[hide_name]:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) - _G[hide_name]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - _G[hide_name]:SetFrameStrata("BACKGROUND") - _G[hide_name]:SetHeight(TITAN_PANEL_BAR_HEIGHT/2); - - -- Set the display bar - local container = _G[frame] - container:SetHeight(TITAN_PANEL_BAR_HEIGHT); - -- Set local identifier - local container_text = _G[frame.."_Text"] - if container_text then -- was used for debug/creating of the independent bars - container_text:SetText(tostring(bar_name)) - -- for now show it - container:Show() + if frame then + local bar_name = TitanBarData[frame].name + local bar_width = TitanBarData[frame].width + + if bar_name then + -- Set script handlers for display + _G[frame]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + _G[frame]:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) + _G[frame]:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) + _G[frame]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + _G[frame]:SetWidth(bar_width) + + local hide_name = TitanBarData[frame].hider + if hide_name then + -- Set script handlers for display + _G[hide_name]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + _G[hide_name]:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) + _G[hide_name]:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) + _G[hide_name]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + + _G[hide_name]:SetFrameStrata("BACKGROUND") + _G[hide_name]:SetWidth(bar_width) + _G[hide_name]:SetHeight(TITAN_PANEL_BAR_HEIGHT/2); + end + + -- Set the display bar + local container = _G[frame] + container:SetHeight(TITAN_PANEL_BAR_HEIGHT); + -- Set local identifier + local container_text = _G[frame.."_Text"] + if container_text then -- was used for debug/creating of the independent bars + container_text:SetText(tostring(bar_name)) + -- for now show it + container:Show() + end end + else end end @@ -301,15 +307,14 @@ function TitanPanel_PlayerEnteringWorld() if Titan__InitializedPEW then -- Currently no additional steps needed else ---[[ moved addon loaded -- Get Profile and Saved Vars - TitanVariables_InitTitanSettings(); - - -- only do this sort of initialization on the first PEW event - if not TitanAllGetVar("Silenced") then + new_toon = TitanVariables_InitTitanSettings(); + if TitanAllGetVar("Silenced") then + -- No header output + else TitanPrint("", "header") end ---]] + if not ServerTimeOffsets then ServerTimeOffsets = {}; end @@ -324,11 +329,13 @@ function TitanPanel_PlayerEnteringWorld() TitanPanelBottomAnchor:ClearAllPoints(); TitanPanelBottomAnchor:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0); - -- Ensure the bars are created before the - -- plugins are registered. + -- Ensure the bars are created before the plugins are registered. for idx, v in pairs (TitanBarData) do - TitanPanel_CreateABar(idx) + -- Not create frames but set up scripts plus +-- TitanPanel_CreateABar(idx) + TitanPanelButton_CreateBar(idx) end + Titan_AutoHide_Create_Frames() local realmName = GetRealmName() @@ -370,7 +377,14 @@ function TitanPanel_PlayerEnteringWorld() TitanUtils_RegisterPluginList() -- Init detailed settings only after plugins are registered! - TitanVariables_UseSettings(nil, TITAN_PROFILE_INIT) + local profile_action = nil + if new_toon then + profile_action = TITAN_PROFILE_RESET + else + profile_action = TITAN_PROFILE_INIT + end + + TitanVariables_UseSettings(nil, profile_action) -- all addons are loaded so update the config (options) -- some could have registered late... @@ -394,7 +408,7 @@ function TitanPanel_PlayerEnteringWorld() Titan__InitializedPEW = true -- Move frames - TitanMovable_SecureFrames() +-- TitanMovable_SecureFrames() -- Also sync LDB object text with their created Titan plugin TitanLDBRefreshButton() @@ -427,15 +441,15 @@ function TitanPanelBarButton:ADDON_LOADED(addon) _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("CVAR_UPDATE"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_LOGOUT"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_LOGOUT"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_LOGOUT"); -- For the pet battle - for now we'll hide the Titan bars... -- Cannot seem to move the 'top' part of the frame. - _G[TITAN_PANEL_CONTROL]:RegisterEvent("PET_BATTLE_OPENING_START"); - _G[TITAN_PANEL_CONTROL]:RegisterEvent("PET_BATTLE_CLOSE"); - -- Adjust a couple frames per user - _G[TITAN_PANEL_CONTROL]:RegisterEvent("EDIT_MODE_LAYOUTS_UPDATED"); - + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_ENABLED"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_DISABLED"); +--[===[ -- Get Profile and Saved Vars - TitanVariables_InitTitanSettings(); + new_toon = TitanVariables_InitTitanSettings(); -- local VERSION = TitanPanel_GetVersion(); -- local POS = strfind(VERSION," - "); -- VERSION = strsub(VERSION,1,POS-1); @@ -449,6 +463,7 @@ function TitanPanelBarButton:ADDON_LOADED(addon) if not ServerHourFormat then ServerHourFormat = {}; end +--]===] else -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. @@ -505,7 +520,6 @@ function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) or cvarname == "uiScale" then if TitanPlayerSettings and TitanPanelGetVar("Scale") then TitanPanel_SetScale() - TitanPanel_AdjustFrames(true, "CVar update "..tostring(cvarname)) end end end @@ -528,15 +542,34 @@ function TitanPanelBarButton:PET_BATTLE_OPENING_START() -- Hide all bars and hiders TitanPanelBarButton_HideAllBars() end + function TitanPanelBarButton:PET_BATTLE_CLOSE() -- A combat check will be done inside the adjust TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_CLOSE") end -- -function TitanPanelBarButton:EDIT_MODE_LAYOUTS_UPDATED(layout_info, from_server) - TitanPanel_AdjustFrames(true, "EDIT_MODE_LAYOUTS_UPDATED "..tostring(from_server)) +-- +function TitanPanelBarButton:PLAYER_REGEN_ENABLED() + for idx,v in pairs (TitanBarData) do + if TitanPanelGetVar(v.name.."_Show") then + if TitanPanelGetVar(v.name.."_HideInCombat") + or TitanPanelGetVar("UseGlobal_HideInCombat") then + TitanPanelBarButton_Show(idx) + end + end + end end +function TitanPanelBarButton:PLAYER_REGEN_DISABLED() + for idx,v in pairs (TitanBarData) do + if TitanPanelGetVar(v.name.."_Show") then + if TitanPanelGetVar(v.name.."_HideInCombat") + or TitanPanelGetVar("UseGlobal_HideInCombat") then + TitanPanelBarButton_Hide(idx) + end + end + end +end -- --[[ Titan @@ -552,7 +585,11 @@ NOTE: --]] function TitanPanelBarButton_OnClick(self, button) -- ensure that the right-click menu will not appear on "hidden" bottom bar(s) - local bar = self:GetName(); +--[[ +print("_OnClick" +.." "..tostring(bar).."" +) +--]] if (button == "LeftButton") then TitanUtils_CloseAllControlFrames(); TitanUtils_CloseRightClickMenu(); @@ -560,7 +597,7 @@ function TitanPanelBarButton_OnClick(self, button) TitanUtils_CloseAllControlFrames(); TitanPanelRightClickMenu_Close(); -- Show RightClickMenu anyway - TitanPanelDisplayRightClickMenu_Toggle(self) -- self not used... + TitanPanelRightClickMenu_Toggle(self) end end @@ -677,7 +714,6 @@ local function handle_reset_cmds(cmd_list) if not InCombatLockdown() then TitanPanelSetVar("Scale", 1); TitanPanel_SetScale() - TitanPanel_AdjustFrames(true, "Command: reset scale") TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info") else TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning") @@ -871,6 +907,9 @@ SLASH_TitanPanel2 = "/titan"; -------------------------------------------------------------- -- -- Texture routines +local function CalcNumTextures() +end + --[[ Titan NAME: TitanPanel_ClearAllBarTextures DESC: Clear the current texture from all Titan bars. @@ -881,7 +920,7 @@ function TitanPanel_ClearAllBarTextures() -- Clear textures if they already exist local tex = "" for idx,v in pairs (TitanBarData) do - for i = 0, numOfTexturesHider do + for i = 0, _G[idx].numOfTextures do tex = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i if _G[tex] then _G[tex]:SetTexture() @@ -901,33 +940,33 @@ function TitanPanel_CreateBarTextures() local i, titanTexture local texture_path = TitanPanelGetVar("TexturePath") local bar_name - local screenWidth + local bar_width local lastTextureWidth local tex, tex_pre -- loop through the bars to set the texture for idx,v in pairs (TitanBarData) do bar_name = TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name - screenWidth = ((_G[bar_name]:GetWidth() or GetScreenWidth()) + 1 ) --/ 2 + bar_width = ((_G[bar_name]:GetWidth() or GetScreenWidth()) + 1 ) --/ 2 ---[===[ - screenWidth = (1900 + 1 ) ---_G[bar_name]:SetWidth(screenWidth) -_G[bar_name]:SetSize(screenWidth, TITAN_PANEL_BAR_TEXTURE_HEIGHT) --- bar width test -print("T CBar" -.." scr w: "..tostring(format("%0.2f", GetScreenWidth())).."" -.." pyh w: "..tostring(GetPhysicalScreenSize()).."" -.." bar: "..tostring(format("%0.2f", _G[bar_name]:GetWidth())).."" -.." "..tostring(format("%0.2f", UIParent:GetEffectiveScale())).."" -.." "..tostring(screenWidth).."" -.." "..tostring(bar_name).."" -) ---]===] - numOfTextures = floor(screenWidth / 256 ) - numOfTexturesHider = (numOfTextures * 2) + 1 - lastTextureWidth = screenWidth - (numOfTextures * 256) + local numOfTextures = floor(bar_width / 256 ) +-- local numOfTexturesHider = (numOfTextures * 2) + 1 + lastTextureWidth = bar_width - (numOfTextures * 256) + if lastTextureWidth > 0 then + numOfTextures = numOfTextures --+ 1 -- to clear / remove the partial + else + -- exact length, somehow :) + end + _G[bar_name].numOfTextures = numOfTextures -- not all bars are equal width... +--[[ +print("Create tex" +.." "..tostring(TitanBarData[idx].name).."" +.." "..tostring(bar_width).."" +.." "..tostring(floor(bar_width / 256 )).."" +.." "..tostring(numOfTextures).."" +) +--]] for i = 0, numOfTextures do -- Create textures if they don't exist tex = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i @@ -950,26 +989,6 @@ print("T CBar" titanTexture:SetPoint("TOPLEFT", tex_pre, "TOPRIGHT") end end - titanTexture:SetWidth(256) - - -- Handle Hider Textures - for i = numOfTextures + 1, numOfTexturesHider do - tex = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i - tex_pre = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i-1 - if not _G[tex] then - titanTexture = _G[bar_name]:CreateTexture(tex, "BACKGROUND") - else - titanTexture = _G[tex] - end - titanTexture:SetHeight(TITAN_PANEL_BAR_TEXTURE_HEIGHT) - if i == numOfTexturesHider then - titanTexture:SetWidth(lastTextureWidth) - else - titanTexture:SetWidth(256) - end - titanTexture:ClearAllPoints() - titanTexture:SetPoint("TOPLEFT", tex_pre, "TOPRIGHT") - end end end @@ -977,30 +996,56 @@ end NAME: TitanPanel_SetTexture DESC: Set texture frames for the given Titan bar with the user chosen texture (bar graphic). VAR: frame - expected to be a Titan bar name (string) -VAR: position - not used +VAR: position - for lookup OUT: None NOTE: - Assumes "TexturePath" contains the user selected texture. :NOTE --]] -function TitanPanel_SetTexture(frame, position) +function TitanPanel_SetTexture(frame) if frame and TitanBarData[frame] then -- proceed else return end - -- Determine the bar that needs the texture applied. - local bar = TitanBarData[frame].name - local vert = TitanBarData[frame].vert + + local name = TitanBarData[frame].name + local tex = "TitanPanelBackground" - local tex_pre = tex.."_"..bar.."_" + local tex_pre = tex.."_"..TitanBarData[frame].name.."_" + -- TODO : have Short bars choose top ot bottom skin?? + local skin = "" + local rel_y = _G[frame]:GetTop() + if rel_y <= (TITAN_PANEL_BAR_HEIGHT * 2) then + skin = TITAN_BOTTOM + else + skin = TITAN_TOP + end + + local tex_path = "" + if TitanPanelGetVar("UseGlobalTexture") then -- apply new choice + tex_path = TitanPanelGetVar("TexturePath") + else + tex_path = TitanPanelGetVar("Texture"..TitanBarData[frame].name) + end -- Create the path & file name to the texture - local texture_file = TitanPanelGetVar("TexturePath")..tex..vert.."0" + local texture_file = tex_path..tex..skin.."0" + local applied = 0 -- include the normal bar (numOfTextures) and hider textures (numOfTexturesHider) - for i = 0, numOfTexturesHider do - _G[tex_pre..i]:SetTexture(texture_file); + for i = 0, _G[frame].numOfTextures do + _G[tex_pre..i]:SetTexture(texture_file) + applied = applied + 1 end + +--[[ +print("_Set tex" +.." "..tostring(TitanBarData[frame].name).."" +.." "..tostring(_G[frame].numOfTextures).."" +.." "..tostring(tex_path).."" +.." "..tostring(applied).."" +) +--]] end -------------------------------------------------------------- @@ -1096,21 +1141,6 @@ function TitanPanelBarButton_ToggleAlign(align) end --[[ Titan -NAME: TitanPanelBarButton_ToggleAutoHide -DESC: Toggle the auto hide of the given Titan bar per the user's new choice. -VAR: frame - expected to be a Titan bar -OUT: None ---]] -function TitanPanelBarButton_ToggleAutoHide(frame) - local frName = _G[frame] - local plugin = (TitanBarData[frame] and TitanBarData[frame].auto_hide_plugin or nil) - - if frName then - Titan_AutoHide_ToggleAutoHide(_G[plugin]) - end -end - ---[[ Titan NAME: TitanPanelBarButton_ForceLDBLaunchersRight DESC: Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. Any visible plugin will be forced to the right side on the same bar it is currently on. VAR: None @@ -1172,12 +1202,12 @@ TitanDebug("Anc top: "..top_y.." bot: "..bot_y if top_y ~= anchor_top then TitanPanelTopAnchor:ClearAllPoints() TitanPanelTopAnchor:SetPoint(top_point, top_rel_to, top_rel_point, top_x, anchor_top); ---TitanDebug("Anc top: "..top_y.." -> "..anchor_top) + end if bot_y ~= anchor_bot then TitanPanelBottomAnchor:ClearAllPoints() TitanPanelBottomAnchor:SetPoint(bot_point, bot_rel_to, bot_rel_point, bot_x, anchor_bot) ---TitanDebug("Anc bot: "..bot_y.." -> "..anchor_bot) + end end @@ -1191,14 +1221,11 @@ function TitanPanelBarButton_DisplayBarsWanted(reason) -- Check all bars to see if the user has requested they be shown for idx,v in pairs (TitanBarData) do -- Show / hide plus kick auto hide, if needed - Titan_AutoHide_Init((_G[TitanBarData[idx].auto_hide_plugin] or nil)) + Titan_AutoHide_Init(idx) end -- Set anchors for other addons to use. TitanAnchors() - - -- Adjust other frames because the bars shown / hidden may have changed - TitanPanel_AdjustFrames(true, reason) end --[[ Titan @@ -1212,26 +1239,8 @@ NOTE: :NOTE --]] function TitanPanelBarButton_HideAllBars() - -- Check all bars to see if the user has requested they be shown for idx,v in pairs (TitanBarData) do - local bar = TitanBarData[idx].name - local hider = _G[TitanBarData[idx].hider] - local hide = TitanBarData[idx].hide ---[[ -TitanDebug("_HideAllBars: " -.."idx: "..(idx or "?").." " -.."bar: "..(bar or "?").." " -.."hider: "..(TitanBarData[idx].hider or "?").." " -) ---]] - -- Hide the Titan bar. The hider bar MAY be hidden as well TitanPanelBarButton_Hide(idx) - -- In case the user selected auto hide for this bar we need to hide it as well - if (TitanPanelGetVar(bar.."_Show")) and (TitanPanelGetVar(bar.."_Hide")) then - hider:ClearAllPoints(); - hider:SetPoint(hide.top.pt, hide.top.rel_fr, hide.top.rel_pt, hide.top.x, hide.top.y); - hider:SetPoint(hide.bot.pt, hide.bot.rel_fr, hide.bot.rel_pt, hide.bot.x, hide.bot.y); - end end end @@ -1285,28 +1294,45 @@ NOTE: function TitanPanelBarButton_Show(frame) local display = _G[frame]; local bar = (TitanBarData[frame].name or nil) - local hide = TitanBarData[frame] and TitanBarData[frame].hide or nil local show = TitanBarData[frame] and TitanBarData[frame].show or nil - local hider = _G[TitanBarData[frame].hider] or nil - if bar and display and hider and show and hide + if bar and display then -- Show the display bar if the user requested it if (TitanPanelGetVar(bar.."_Show")) then - if hide and show then - display:ClearAllPoints(); - display:SetPoint(show.top.pt, show.top.rel_fr, show.top.rel_pt, show.top.x, show.top.y); - display:SetPoint(show.bot.pt, show.bot.rel_fr, show.bot.rel_pt, show.bot.x, show.bot.y); - hider:Hide() + display:ClearAllPoints(); +--[[ +print("T_BBS" +.." "..tostring(frame).."" +.." "..tostring(bar).."" +.." "..tostring(TitanPanelGetVar(bar.."_Show")).."" +) +print(">>>" +--.." "..tostring(show.pt).."" +--.." "..tostring(show.rel_fr).."" +--.." "..tostring(show.rel_pt).."" +.." x:"..tostring(show.x).."" +.." y:"..tostring(show.y).."" +.." w:"..tostring(TitanBarData[frame].width).."" +) +--]] + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y) + if TitanBarData[frame].hider then + _G[TitanBarData[frame].hider]:Hide() + else + -- not allowed for this bar end else -- The user has not elected to show this bar display:ClearAllPoints(); - display:SetPoint(hide.top.pt, hide.top.rel_fr, hide.top.rel_pt, hide.top.x, hide.top.y); - display:SetPoint(hide.bot.pt, hide.bot.rel_fr, hide.bot.rel_pt, hide.bot.x, hide.bot.y); - hider:ClearAllPoints(); - hider:SetPoint(hide.top.pt, hide.top.rel_fr, hide.top.rel_pt, hide.top.x, hide.top.y); - hider:SetPoint(hide.bot.pt, hide.bot.rel_fr, hide.bot.rel_pt, hide.bot.x, hide.bot.y); + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, (show.y)*-1) + if TitanBarData[frame].hider then + local hider = _G[TitanBarData[frame].hider] + hider:ClearAllPoints(); + hider:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y) + else + -- not allowed for this bar + end end end end @@ -1326,28 +1352,34 @@ function TitanPanelBarButton_Hide(frame) local display = _G[frame] local data = TitanBarData[frame] - local hider = _G[data.hider] local bar = (data.name or nil) - local hide = data.hide or nil - local show = data.show or nil - if display and hider and bar and show and hide then - -- This moves rather than hides. If we just hide then - -- the plugins will still show. + local show = data.show or nil +--[[ +print("_Hide" +.." "..tostring(frame).."" +.." "..tostring(TitanPanelGetVar(bar.."_Show")).."" +) +--]] + if bar and display + then + -- This moves rather than hides. If we just hide then the plugins will still show. + -- Hide by ensuriing the Y offset is below the screen. display:ClearAllPoints(); - display:SetPoint(hide.top.pt, hide.top.rel_fr, hide.top.rel_pt, hide.top.x, hide.top.y); - display:SetPoint(hide.bot.pt, hide.bot.rel_fr, hide.bot.rel_pt, hide.bot.x, hide.bot.y); - if (TitanPanelGetVar(bar.."_Show")) and (TitanPanelGetVar(bar.."_Hide")) then - -- Auto hide is requested so show the hider bar in the right place - hider:ClearAllPoints(); - hider:SetPoint(show.top.pt, show.top.rel_fr, show.top.rel_pt, show.top.x, show.top.y); - hider:SetPoint(show.bot.pt, show.bot.rel_fr, show.bot.rel_pt, show.bot.x, show.bot.y); - hider:Show() + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, (TITAN_PANEL_BAR_HEIGHT*2)*-1) + if TitanBarData[frame].hider then + local hider = _G[data.hider] + if (TitanPanelGetVar(bar.."_Show")) and (TitanPanelGetVar(bar.."_Hide")) then + -- Auto hide is requested so show the hider bar in the right place + hider:ClearAllPoints(); + hider:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y); + hider:Show() + else + -- The bar was not requested + hider:Hide() + end else - -- The bar was not requested so also move the hider bar to the right place - hider:ClearAllPoints(); - hider:SetPoint(hide.top.pt, hide.top.rel_fr, hide.top.rel_pt, hide.top.x, hide.top.y); - hider:SetPoint(hide.bot.pt, hide.bot.rel_fr, hide.bot.rel_pt, hide.bot.x, hide.bot.y); + -- not allowed for this bar end end end @@ -1361,13 +1393,17 @@ OUT: None function TitanPanel_InitPanelBarButton() -- Set initial Panel Scale TitanPanel_SetScale(); - -- Create textures for the first time - if numOfTextures == 0 then TitanPanel_CreateBarTextures() end -- Reposition textures if needed TitanPanel_CreateBarTextures() for idx,v in pairs (TitanBarData) do - TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name, TITAN_PANEL_PLACE_TOP); + local bar_tex = "" + if TitanPanelGetVar("UseGlobalTexture") then + bar_tex = "Path" + else + bar_tex = v.name + end + TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name, "Texture"..bar_tex); end -- Set transparency of the bars @@ -1569,7 +1605,6 @@ function TitanPanelButton_Justify() end local bar - local vert local y_offset local firstLeftButton local scale = TitanPanelGetVar("Scale"); @@ -1584,8 +1619,8 @@ function TitanPanelButton_Justify() -- Look at each bar for plugins. for idx,v in pairs (TitanBarData) do bar = TitanBarData[idx].name - vert = TitanBarData[idx].vert y_offset = TitanBarData[idx].plugin_y_offset + x_offset = TitanBarData[idx].plugin_x_offset firstLeftButton = TitanUtils_GetButton(TitanPanelSettings.Buttons[TitanUtils_GetFirstButtonOnBar (bar, TITAN_LEFT)]) align = TitanPanelGetVar(bar.."_Align") leftWidth = 0; @@ -1597,7 +1632,7 @@ function TitanPanelButton_Justify() if ( align == TITAN_PANEL_BUTTONS_ALIGN_LEFT ) then -- Now offset the plugins firstLeftButton:ClearAllPoints(); - firstLeftButton:SetPoint("LEFT", idx, "LEFT", 5, y_offset); + firstLeftButton:SetPoint("LEFT", idx, "LEFT", x_offset, y_offset); end -- Center if requested if ( align == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then @@ -1660,34 +1695,40 @@ end --[[ local NAME: TitanPanelRightClickMenu_BarOnClick DESC: Show / hide a plugin. Used by the Titan (right click) menu. -VAR: checked - true (show) or false (hide) -VAR: value - the plugin id +VAR: self +VAR: frame_str - the Titan bar user clicked to build menu +VAR: plugin_id - the plugin clicked OUT: None --]] -local function TitanPanelRightClickMenu_BarOnClick(checked, value) - -- we need to know which bar the user clicked to get the menu... - local frame = TitanPanel_DropMenu:GetParent():GetName() - local bar = TitanBarData[frame].name +local function TitanPanelRightClickMenu_BarOnClick(self, frame_str, plugin_id) + -- frame_str is the bar the user clicked to get the menu... + local bar = TitanBarData[frame_str].name - if checked then - TitanPanel_RemoveButton(value); + if TitanPanel_IsPluginShown(plugin_id) then + TitanPanel_RemoveButton(plugin_id); else - TitanUtils_AddButtonOnBar(bar, value) + TitanUtils_AddButtonOnBar(bar, plugin_id) end end +local function RightClick_HideMe(self, frame_str) + local bar = TitanBarData[frame_str].name + TitanPanelToggleVar(bar.."_Show") + TitanPanelBarButton_DisplayBarsWanted(bar.." user ckicked Hide") +end + --[[ local NAME: TitanPanel_MainMenu DESC: Show main Titan (right click) menu. VAR: None OUT: None --]] -local function TitanPanel_MainMenu() +local function TitanPanel_MainMenu(frame) + local locale_bar = TitanBarData[frame].locale_name local info = {}; - ----------------- -- Menu title - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_TITLE"]); + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_TITLE"].." - "..locale_bar); TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PLUGINS"]); @@ -1767,6 +1808,19 @@ local function TitanPanel_MainMenu() info.keepShownOnClick = nil TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + + ----------------- + -- Hide this bar + info = {}; + info.text = (HIDE or "Hide") + info.value = "" + info.notCheckable = true + info.arg1 = frame; + info.func = RightClick_HideMe + info.keepShownOnClick = nil + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end --[[ local @@ -2060,11 +2114,10 @@ local function TitanPanel_BuildOtherPluginsMenu(frame) if plugin.controlVariables then info.hasArrow = 1; end - info.value = id; - info.func = function() - local checked = TitanPanel_IsPluginShown(id) or nil; - TitanPanelRightClickMenu_BarOnClick(checked, id) - end; + info.value = id; -- for next level dropdown + info.arg1 = frame; + info.arg2 = id; + info.func = TitanPanelRightClickMenu_BarOnClick -- (self, info.arg1, info.arg2) info.checked = TitanPanel_IsPluginShown(id) or nil info.keepShownOnClick = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -2084,12 +2137,17 @@ function TitanPanelRightClickMenu_PrepareBarMenu(self) -- This MUST match the convention used in TitanPanel.xml to declare -- the dropdown menu. ($parentRightClickMenu) local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); - local lev = (TitanPanelRightClickMenu_GetDropdownLevel() or 1) +--[[ +print("_prep R click" +.." "..tostring(frame).."" +.." "..tostring(lev).."" +) +--]] -- Level 1 if lev == 1 then - TitanPanel_MainMenu() + TitanPanel_MainMenu(frame) end -- Level 2 diff --git a/Titan/TitanPanelTemplate.lua b/Titan/TitanPanelTemplate.lua index b22adb9..a5e9773 100644 --- a/Titan/TitanPanelTemplate.lua +++ b/Titan/TitanPanelTemplate.lua @@ -171,36 +171,40 @@ local function TitanTooltip_SetPanelTooltip(self, id, frame) -- Set GameTooltip local button = TitanUtils_GetButton(id); - local scale = TitanPanelGetVar("Scale"); local offscreenX, offscreenY; - local i = TitanPanel_GetButtonNumber(id); local bar = TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(id) - local vert = TitanBarData[bar].vert - -- Get TOP or BOTTOM for the anchor and relative anchor - local rel_pt, pt - if vert == TITAN_TOP then - pt = "TOP" - rel_pt = "BOTTOM" + + -- Adjust the Y offset as needed + local rel_y = self:GetTop() - GameTooltip:GetHeight() + if rel_y > 0 then + pt = "TOP"; + rel_pt = "BOTTOM"; + else + -- too close to bottom of screen + pt = "BOTTOM"; + rel_pt = "TOP"; + end + local rel_x = self:GetLeft() + GameTooltip:GetHeight() + if ( rel_x < GetScreenWidth() ) then + -- menu will fit + pt = pt.."LEFT"; + rel_pt = rel_pt.."LEFT"; else - pt = "BOTTOM" - rel_pt = "TOP" + pt = pt.."RIGHT"; + rel_pt = rel_pt.."RIGHT"; end - TitanTooltip_SetOwnerPosition(button, pt.."LEFT", - button:GetName(), rel_pt.."LEFT", -10, 0, frame) --4 * scale); +--[[ +print("_tooltip" +.." "..tostring(self:GetName()).."" +.." "..tostring(pt).."" +.." "..tostring(rel_pt).."" +.." "..tostring(format("%0.1f", GameTooltip:GetWidth())).."" +.." "..tostring(format("%0.1f", GameTooltip:GetHeight())).."" +) +--]] + TitanTooltip_SetOwnerPosition(button, pt, button:GetName(), rel_pt, 0, 0, frame) TitanTooltip_SetGameTooltip(self); - - -- Adjust GameTooltip position if it's off the screen - offscreenX, offscreenY = TitanUtils_GetOffscreen(GameTooltip); - if ( offscreenX == -1 ) then - TitanTooltip_SetOwnerPosition(button, pt.."LEFT", bar, - rel_pt.."LEFT", 0, 0, frame) - TitanTooltip_SetGameTooltip(self); - elseif ( offscreenX == 1 ) then - TitanTooltip_SetOwnerPosition(button, pt.."RIGHT", bar, - rel_pt.."RIGHT", 0, 0, frame) - TitanTooltip_SetGameTooltip(self); - end end --[[ local @@ -629,7 +633,7 @@ NAME: TitanPanelButton_OnClick DESC: Handle the OnClick mouse event of the requested Titan plugin. VAR: self - frame reference of the plugin VAR: button - mouse button that was clicked -VAR: isChildButton - boolean +VAR: isChildButton - boolean ! NO LONGER USED ! NOTE: - Only the left and right mouse buttons are handled by Titan. :NOTE @@ -656,7 +660,6 @@ end --]] if id then local controlFrame = TitanUtils_GetControlFrame(id); - local rightClickMenu = _G["TitanPanelRightClickMenu"]; if (button == "LeftButton") then local isControlFrameShown; @@ -679,11 +682,16 @@ end local parent = self:GetName() -- plugin with the control frame local point = "" -- point of the control frame local rel_point = "" -- The middle - top or bottom edge - of the plugin to anchor to - if ( position == TitanBarOrder[1] - or position == TitanBarOrder[2] ) then -- a top bar - is there a better check??? + --[[ Mar 2023 : removed reference to Titan bar reference + Instead use the relative position on the screen to show the control (plugin) + frame properly. + NOTE: If Titan bars need a left click to show a control frame the offset + will need to be changed to use the cursor position like right click menu!! + --]] + if (self:GetTop() - controlFrame:GetHeight()) > 0 then point = "TOP" rel_point = "BOTTOM" - else -- a bottom bar + else -- below screen point = "BOTTOM" rel_point = "TOP" end @@ -710,7 +718,7 @@ end TitanUtils_CloseAllControlFrames(); -- Show RightClickMenu anyway TitanPanelRightClickMenu_Close(); - TitanPanelRightClickMenu_Toggle(self, isChildButton); + TitanPanelRightClickMenu_Toggle(self); end GameTooltip:Hide(); @@ -1135,3 +1143,220 @@ function TitanOptionsSliderTemplate_OnLoad(self) edgeSize = 8, }) end + +-- +--========================== +-- Routines to handle moving and sizing of short bars +-- +local function CheckBounds(self, width) + local result = {} + + local f_name = self:GetName() + local locale_name = TitanBarData[f_name].locale_name + local min_w, min_h, max_w, max_h = self:GetResizeBounds() + local x_off = self:GetLeft() + local y_off = self:GetTop() + local screen_edge = GetScreenWidth() --* UIParent:GetEffectiveScale() + local err = "" + local orig_w = self:GetWidth() + local w = 0 + if TitanBarData[f_name] then + w = orig_w + width + if w < min_w then + -- do nothing - too small + err = "Size too small. Set to min width" + self:SetWidth(min_w) + TitanVariables_SetBarPos(self) + -- TODO : overkill - this will recalc all bars... + TitanPanelBarButton_DisplayBarsWanted("Bar width changed - "..tostring(f_name)) + elseif w > max_w then + err = "Size too big" -- do nothing - too big + elseif (x_off + w) > screen_edge then + err = "Off screen. Leaving as is." -- do nothing - off right side of UI + w = max_w + else + self:SetWidth(w) + TitanVariables_SetBarPos(self) + -- TODO : overkill - this will recalc all bars... + TitanPanelBarButton_DisplayBarsWanted("Bar width changed - "..tostring(f_name)) + end + end + + result.x = x_off + result.y = y_off + result.err = err + + if err == "" then + -- all is good + result.ok = true + else + result.ok = false + TitanPrint(locale_name.." "..err.."!!!!", "error") + end +--[[ +print("CheckBounds" +.." '"..tostring(locale_name).."'" +.." w "..tostring(format("%0.1f", orig_w)).."" +.." + "..tostring(format("%0.1f", w)).."" +.." = "..tostring(format("%0.1f", self:GetWidth())).."" +) +print(">>" +.." x "..tostring(format("%0.1f", x_off)).."" +.." => "..tostring(format("%0.1f", result.x)).."" +) +print(">>" +.." y "..tostring(format("%0.1f", y_off)).."" +.." => "..tostring(format("%0.1f", result.y)).."" +) +print(">>" +.." w "..tostring(format("%0.1f", self:GetWidth())).."" +.." s "..tostring(format("%0.1f", screen_edge)).."" +) +--]] + return result +end + +local function OnMoveStart(self) +--[[ +print("OnMoveStart" +.." "..tostring(self:GetName()).."" +.." "..tostring(IsShiftKeyDown()).."" +.." "..tostring(IsAltKeyDown()).."" +) +--]] + if IsShiftKeyDown() then + if self:IsMovable() then + self.isMoving = true + self:StartMoving() + _G.GameTooltip:Hide() + end + else + -- Do not move + end +end + +local function OnMovingStop(self) + + local res = CheckBounds(self, 0) +--[[ +print("OnMovingStop" +.." "..tostring(self:GetName()).."" +.." x: "..tostring(res.x).."" +.." y: "..tostring(res.y).."" +.." ok: "..tostring(res.ok).."" +) +--]] + self:StopMovingOrSizing() + self.isMoving = nil + if res.ok then + -- For now, honor the user move... + -- TODO : 'put back' if off any part of screen + TitanVariables_SetBarPos(self) + else + end + -- TODO : overkill - this will recalc all bars... + TitanPanelBarButton_DisplayBarsWanted("Bar moved - "..tostring(self:GetName())) + +end + +local function OnMouseWheel(self, d) + if IsShiftKeyDown() then + local old_w = self:GetWidth() + local res = CheckBounds(self, d) + if res.ok then + local w = self:GetWidth() + d + self:SetWidth(w) + TitanVariables_SetBarPos(self) + -- TODO : overkill - this will recalc all bars... + TitanPanel_InitPanelBarButton() + end +--[[ +print("wheel" +.." "..tostring(f_name).."" +.." old: "..tostring(old_w).."" +.." new: "..tostring(self:GetWidth()).."" +.." ok: "..tostring(res.ok).."" +) +--]] + end +end + +--[[ Titan +NAME: TitanPanelButton_CreateBar(frame_str) +DESC: Create a Titan bar that can show plugins. +VAR: frame_str - name of the frame +NOTE: +- This assumes ... +:NOTE +--]] +function TitanPanelButton_CreateBar(frame_str) + local this_bar = frame_str + local a_bar = CreateFrame("Button", this_bar, UIParent, "Titan_Bar__Display_Template") + + local bar_data = TitanBarData[this_bar] +--[[ +print("_Create bar" +.." "..tostring(bar_data.name).."" +.." "..tostring(bar_data.width).."" +.." "..tostring(TITAN_PANEL_BAR_HEIGHT).."" +) +--]] + a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, bar_data.show.x, bar_data.show.y) + a_bar:SetFrameStrata("DIALOG") + a_bar:SetSize(bar_data.width, TITAN_PANEL_BAR_HEIGHT) + + -- ====== + -- Bounds only effective on Short bars for now + -- Min : No smaller than the padding & one icon + -- Max : No wider than the screen + -- does not seem to work to restrict size automatically... + a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, GetScreenWidth(), TITAN_PANEL_BAR_HEIGHT) + + -- ====== + -- Scripts + if bar_data.vert == TITAN_TOP + or bar_data.vert == TITAN_BOTTOM + then + -- Set script handlers for display + a_bar:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) + a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) + elseif bar_data.vert == TITAN_SHORT + then + a_bar:SetMovable(true) + a_bar:SetResizable(true) + a_bar:EnableMouse(true) + a_bar:RegisterForDrag("LeftButton") + a_bar:SetScript("OnDragStart", OnMoveStart) + a_bar:SetScript("OnDragStop", OnMovingStop) + a_bar:SetScript("OnMouseWheel", OnMouseWheel) + end + + a_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + a_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + + -- ====== + -- Frame for right clicke + f = CreateFrame("Frame", this_bar.."RightClickMenu", UIParent, "UIDropDownMenuTemplate") + + -- ====== + -- Hider for auto hide feature + local hide_bar_name = TITAN_PANEL_HIDE_PREFIX..bar_data.name + if bar_data.hider then + local hide_bar = CreateFrame("Button", hide_bar_name, UIParent, "TitanPanelBarButtonHiderTemplate") + hide_bar:SetFrameStrata("DIALOG") + hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, bar_data.show.x, -bar_data.show.y) + + -- Set script handlers for display + hide_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + hide_bar:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) + hide_bar:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) + hide_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + + hide_bar:SetFrameStrata("BACKGROUND") + hide_bar:SetWidth(bar_data.width) + hide_bar:SetSize(bar_data.width, TITAN_PANEL_BAR_HEIGHT) + else + -- Not allowed for this bar + end +end + diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 83e64a2..fcc2018 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -179,10 +179,7 @@ function TitanUtils_GetButtonIDFromMenu(self) local ret = nil if self and self:GetParent() then local name = self:GetParent():GetName() - local s, e, id = string.find(name, TITAN_PANEL_DISPLAY_PREFIX); - local temp = "" - - if not s == nil then + if name == "UIParent" then -- The click was on the Titan bar itself ret = "Bar"; elseif self:GetParent():GetParent():GetName() then @@ -250,12 +247,22 @@ VAR: None OUT: string - bar name or nil --]] function TitanUtils_PickBar() - -- Pick the 'first' bar shown. + -- Pick the 'first' bar shown per the Titan defined order. -- This is used for defaulting where plugins are put -- if using the Titan options screen. - for idx,v in pairs (TitanBarOrder) do - if TitanPanelGetVar(v.."_Show") then - return v + local bar_list = {} + for _,v in pairs (TitanBarData) do + bar_list[v.order] = v + end + table.sort(bar_list, function(a, b) + return string.lower(a.order) + < string.lower(b.order) + end) + + for idx = 1, #bar_list do + local bar_name = bar_list[idx].name + if TitanPanelGetVar(bar_name.."_Show") then + return bar_name end end -- fail safe - return something @@ -1682,51 +1689,16 @@ function TitanUtils_CloseRightClickMenu() end --[[ local -NAME: TitanRightClick_UIScale -DESC: Scale the right click menu to the user requested value. -VAR: None -OUT: -- float - x scaled -- float - y scaled -- float - scale used - ---]] -local function TitanRightClick_UIScale() - -- take UI Scale into consideration - local listFrame = _G[drop_down_1]; - local listframeScale = listFrame:GetScale(); - - local uiScale; - local uiParentScale = UIParent:GetScale(); - - local x, y = GetCursorPosition(UIParent) - - if ( GetCVar("useUIScale") == "1" ) then - uiScale = tonumber(GetCVar("uiscale")); - if ( uiParentScale < uiScale ) then - uiScale = uiParentScale; - end - else - uiScale = uiParentScale; - end - - x = x/uiScale; - y = y/uiScale; - - listFrame:SetScale(uiScale); - - return x, y, uiScale -end - ---[[ local NAME: TitanRightClickMenu_OnLoad -DESC: Prepare the plugin right click menu using the function given by the plugin. +DESC: Prepare the plugin right click menu using the function given by the plugin =or Titan bar. VAR: - plugin - frame of the plugin (must be a Titan template) OUT: None NOTE: -- The function name is assumed to be "TitanPanelRightClickMenu_Prepare"..plugin_id.."Menu". -- This routine is for Titan plugins. There is a similar routine for the Titan bar. +- The function to be called is assumed to be "TitanPanelRightClickMenu_Prepare"..plugin_id.."Menu". +- This routine handles Titan plugins and the Titan bars. +- TitanUtils_GetButtonIDFromMenu returns a generic "Bar" when the user clicks on a Titan bar. + This works because every Titan bar uses the same menu; allows one routine to be reused. --]] local function TitanRightClickMenu_OnLoad(self) local id = TitanUtils_GetButtonIDFromMenu(self); @@ -1743,35 +1715,12 @@ local function TitanRightClickMenu_OnLoad(self) ,"error") end end + + -- Under the cover the menu is built as DropDownList1 + return DropDownList1, DropDownList1:GetHeight(), DropDownList1:GetWidth() end ---[[ local -NAME: TitanDisplayRightClickMenu_OnLoad -DESC: Prepare the Titan bar right click menu using the given function. -VAR: -- self - frame of the Titan bar -- func - function to create the menu -OUT: None -NOTE: -- This routine is for Titan bar. There is a similar routine for the Titan plugins. ---]] -local function TitanDisplayRightClickMenu_OnLoad(self, func) - local prepareFunction = _G[func]; - if prepareFunction and type(prepareFunction) == "function" then - -- Nasty "hack", load Blizzard_Calendar if not loaded, - -- for it to secure init 24 dropdown menu buttons, - -- to avoid action blocked by tainting - if not IsAddOnLoaded("Blizzard_Calendar") then - LoadAddOn("Blizzard_Calendar") - end - -- not good practice but there seems to be no other way to get - -- the actual bar (frame parent) to the dropdown implementation - TitanPanel_DropMenu = self - UIDropDownMenu_Initialize(self, prepareFunction, "MENU"); - end -end - ---[[ local +--[[ Titan NAME: TitanPanelRightClickMenu_Toggle DESC: Call the routine to build the plugin menu then place it properly. VAR: @@ -1781,100 +1730,83 @@ OUT: None NOTE: - This routine is for Titan plugins. There is a similar routine for the Titan bar. --]] -function TitanPanelRightClickMenu_Toggle(self, isChildButton) - local x, y, scale - -- Get top / bottom - local name = self:GetName() -- assuming this is a plugin - local parent = self:GetParent():GetName() +function TitanPanelRightClickMenu_Toggle(self) + -- Mar 2023 : Rewritten to place menu relative to the passed in frame (button) + -- There are two places for the menu creation routine + -- 1) Titan bar - creates same menu + -- 2) Plugin creation via the .registry + local frame = self:GetName() local menu = _G[self:GetName().."RightClickMenu"] - local vert - local position - local id - local frame = "" - - TitanRightClickMenu_OnLoad(menu) - - -- if this is a child button then use the parent to get the plugin info - -- otherwise use self as passed in - if isChildButton then - id = TitanUtils_GetButtonID(parent) - else - id = TitanUtils_GetButtonID(name) - end - local i = TitanPanel_GetButtonNumber(id) - frame = TITAN_PANEL_DISPLAY_PREFIX..TitanPanelSettings.Location[i] - -- .Location would tell us the bar but we still need vert (top / bottom) - vert = TitanBarData[frame].vert - position = (vert == TITAN_TOP and TITAN_PANEL_PLACE_TOP or TITAN_PANEL_PLACE_BOTTOM) - - if position == TITAN_PANEL_PLACE_TOP then - menu.point = "TOPLEFT"; - menu.relativePoint = "BOTTOMLEFT"; - else - menu.point = "BOTTOMLEFT"; - menu.relativePoint = "TOPLEFT"; - end - - x, y, scale = TitanRightClick_UIScale() - - ToggleDropDownMenu(1, nil, menu, frame, TitanUtils_Max(x - 40, 0), 0, nil, self); -end - ---[[ Titan -NAME: TitanPanelDisplayRightClickMenu_Toggle -DESC: Call the routine to build the Titan bar menu then place it properly. -VAR: -- self - frame of the Titan bar -- isChildButton - function to create the menu -OUT: None -NOTE: -- This routine is for Titan bar. There is a similar routine for the Titan plugins. -- This is close to TitanPanelRightClickMenu_Toggle but geared to the Titan display bars. This routine allows the Titan display bars to be independent rather than rely on bars being a 'sort of' plugin. -- This relies on name="$parentRightClickMenu" being part of the display bar template. +--[[ +print("_ toggle R menu" +.." "..tostring(frame).."" +) --]] -function TitanPanelDisplayRightClickMenu_Toggle(self, isChildButton) - if not self:GetName() then - return - end + -- Create menu based on the frame's routine for right click menu + local drop_menu, menu_height, menu_width = TitanRightClickMenu_OnLoad(menu) - local frame = (isChildButton and self:GetParent():GetName() or self:GetName()) - if not frame then - -- Only Titan display bars should be processed here!!! - return - end - - local vert = TitanBarData[frame].vert - local position = (vert == TITAN_TOP and TITAN_PANEL_PLACE_TOP or TITAN_PANEL_PLACE_BOTTOM) - local x, y, scale - local menu - - -- Per updated menu lib LibUIDropDownMenu Dec 2018 - -- This could have been done in some initialize code but here it can react - -- better to future Titan frame code changes - local desired_frame = frame.."RightClickMenu" - if _G[desired_frame] then - -- all is good - frame exists + -- Adjust the Y offset as needed + local rel_y = _G[frame]:GetTop() - menu_height + if rel_y > 0 then + menu.point = "TOP"; + menu.relativePoint = "BOTTOM"; + else + -- too close to bottom of screen + menu.point = "BOTTOM"; + menu.relativePoint = "TOP"; + end + + -- Adjust the X offset as needed + local x_offset = 0 + local left = 0 + if TitanBarData[frame] then + -- on a Titan bar so use cursor for the 'left' + left = GetCursorPosition() -- get x; ignore y + left = left / UIParent:GetEffectiveScale() + -- correct for beginning of Titan bar + left = left - _G[frame]:GetLeft() else - -- need to create the frame - -- The _G is needed but it is explicit & shows what needs to done - _G[desired_frame] = CreateFrame("Frame", desired_frame, self or nil, "UIDropDownMenuTemplate") + -- a plugin + left = _G[frame]:GetLeft() end - menu = _G[desired_frame]; + local rel_x = left + menu_width + if ( rel_x < GetScreenWidth() ) then + -- menu will fit + menu.point = menu.point.."LEFT"; + menu.relativePoint = menu.relativePoint.."LEFT"; - -- Initialize the DropDown Menu if not already initialized - TitanDisplayRightClickMenu_OnLoad(menu, "TitanPanelRightClickMenu_PrepareBarMenu") - - if position == TITAN_PANEL_PLACE_TOP then - menu.point = "TOPLEFT"; - menu.relativePoint = "BOTTOMLEFT"; + if TitanBarData[frame] then + x_offset = left + else + -- a plugin + x_offset = 0 + end else - menu.point = "BOTTOMLEFT"; - menu.relativePoint = "TOPLEFT"; + -- Menu would go off right side of the screen + menu.point = menu.point.."RIGHT"; + menu.relativePoint = menu.relativePoint.."RIGHT"; + + if TitanBarData[frame] then + -- correct is on Titan bar (bottom, far right) + -- flip calc since we flipped the anchor to right + x_offset = GetScreenWidth() - left + else + -- a plugin + x_offset = 0 + end end - - x, y, scale = TitanRightClick_UIScale() - - ToggleDropDownMenu(1, nil, menu, frame, TitanUtils_Max(x - 40, 0), 0, nil, self) +--[[ +print("RCM" +.." "..tostring(frame).."" +.." "..tostring(format("%0.1f", menu_height)).."" +.." "..tostring(format("%0.1f", menu_width)).."" +.." "..tostring(format("%0.1f", _G[frame]:GetLeft())).."" +.." "..tostring(menu.point).."" +.." "..tostring(menu.relativePoint).."" +.." "..tostring(format("%0.1f", left)).."" +) +--]] + ToggleDropDownMenu(1, nil, menu, frame, x_offset, 0, nil, self); end --[[ Titan @@ -2170,11 +2102,7 @@ end function TitanDumpTimers() local str = "Titan-timers: " - .."'"..(TitanAllGetVar("TimerPEW") or "?").."' " - .."'"..(TitanAllGetVar("TimerDualSpec") or "?").."' " .."'"..(TitanAllGetVar("TimerLDB") or "?").."' " --- .."'"..(TitanAllGetVar("TimerAdjust") or "?").."' " --- .."'"..(TitanAllGetVar("TimerVehicle") or "?").."' " TitanPrint(str, "plain") end diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index accddd1..73d98f2 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -3,10 +3,24 @@ NAME: TitanVariables.lua DESC: This file contains the routines to initialize, get, and set the basic data structures used by Titan. It also sets the global variables and constants used by Titan. +TitanAll is used for settings used for Titan itself such as use global profile, tootip modifier, etc. TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat are the structures saved to disk (listed in toc). TitanSettings: is the table that holds the Titan variables by character and the plugins used by that character. -TitanSkins: is the table that holds the list of Titan and custom skins available to the user. It is assumed that the skins are in the proper folder on the hard drive. Blizzard does not allow addons to access the disk. +TitanSkins: holds the list of Titan and custom skins available to the user. + It is assumed that the skins are in the proper folder on the hard drive. Blizzard does not allow addons to access the disk. ServerTimeOffsets and ServerHourFormat: are the tables that hold the user selected hour offset and display format per realm (server). + +TitanSettings has 4 major sections with associated shortcuts in the code +TitanPlayerSettings = TitanSettings.Players[toon] +TitanPluginSettings = TitanSettings.Players[toon].Plugins : Successful registered plugins with all flags +TitanPanelSettings = TitanSettings.Players[toon].Panel : ** +TitanPanelRegister = TitanSettings.Players[toon].Register : .registry of all plugins (Titan and LDB) to be registered with Titan +TitanBarData = TitanSettings.Players[toon].BarData : Titan bar reference and placement info + +** : +- Has Plugin placement data under Location and Buttons +- Bar settings Show / Hide, transparency, skins, etc +- Per character Titan settings plugin spacing, global skin, etc :DESC --]] local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -45,6 +59,8 @@ TITAN_WOW_SCREEN_BOT = 0 TITAN_TOP = "Top" TITAN_BOTTOM = "Bottom" +TITAN_SHORT = "Short" + TITAN_RIGHT = "Right" TITAN_LEFT = "Left" TITAN_PANEL_BUTTONS_ALIGN_LEFT = 1; @@ -62,6 +78,7 @@ TITAN_PANEL_DISPLAY_MENU = "Menu_" --TITAN_PANEL_DISPLAY_ID = "Id_" TITAN_PANEL_BACKGROUND_PREFIX = "TitanPanelBackground_" TITAN_PANEL_TEXT = "Text" +TITAN_PANEL_TEXTURE_VAR = "Texture" TITAN_PANEL_BUTTON_TEXT = "Button"..TITAN_PANEL_TEXT TITAN_PANEL_CONSTANTS = { FONT_SIZE = 10, @@ -88,112 +105,192 @@ TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = --[[ Titan NAME: Titan bar overview DESC: --- 3 buttons are used to create a Titan bar: --- the 'display' button, --- the 'hider', --- and the 'auto hide' plugin. --- The display is where the plugins are displayed. --- The hider is used if auto hide is requested. This button will cause the display to show when the mouse is enters. --- The auto hide is the plugin that shows the auto hide 'pin'. -:DESC ---]] ---[[ Titan -NAME: TitanBarOrder table -DESC: -The values must match the 'name' in the TitanBarData table!!! -The values specify the order the options should be ordered in the options pulldown. +-- 3 button frames are used to create a Titan bar: +-- the 'display' button frame - the bar itself, +-- the 'hider' which is a blank 1/2 height bar to capture the cursor moving to the bar, +-- and the 'auto hide' plugin displaying the 'push pin' button. :DESC --]] -TitanBarOrder = {"Bar", "Bar2", "AuxBar2", "AuxBar"} + --[[ Titan NAME: TitanBarData table. DESC: -The index must match the 'button' names in the TitanPanel.xml!!! The table holds: - the name of each Titan bar (in the index) - the short name of the bar - whether the bar is on top or bottom - the order they should be in top to bottom - show / hide give the values for the cooresponding SetPoint +- the name of each Titan bar (as the index) +- the short name of the bar +- whether the bar is relative - top or bottom or short (user placed) +- the order they should be considered +- SetPoint values for show / hide +- short bar specific values The short name is used to build names of the various saved variables, frames, and buttons used by Titan. :DESC -]] -TitanBarData = { +local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() +local x_mid = GetScreenWidth() / 2 +local SHORT_WIDTH = 200 + +--[[ +--]] +TitanBarData = {} +TitanBarDataDefaults = { [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = { locale_name = L["TITAN_PANEL_MENU_TOP"], name = "Bar", vert = TITAN_TOP, order = 1, hider = TITAN_PANEL_HIDE_PREFIX.."Bar", - auto_hide_plugin = AUTOHIDE_PREFIX.."Bar"..AUTOHIDE_SUFFIX, plugin_y_offset = 1, - show = { - top = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT", x=0, y=0}, - bot = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT", x=0, y=-TITAN_PANEL_BAR_HEIGHT} }, - hide = { - top = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT", x=0, y=TITAN_PANEL_BAR_HEIGHT*2}, - bot = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT", x=0, y=TITAN_PANEL_BAR_HEIGHT*2} } + plugin_x_offset = 5, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=y_top-TITAN_PANEL_BAR_HEIGHT}, + user_move = false, + width = GetScreenWidth(), }, [TITAN_PANEL_DISPLAY_PREFIX.."Bar2"] = { locale_name = L["TITAN_PANEL_MENU_TOP2"], name = "Bar2", vert = TITAN_TOP, order = 2, hider = TITAN_PANEL_HIDE_PREFIX.."Bar2", - auto_hide_plugin = AUTOHIDE_PREFIX.."Bar2"..AUTOHIDE_SUFFIX, plugin_y_offset = 1, - show = { - top = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT", x=0, y=-TITAN_PANEL_BAR_HEIGHT}, - bot = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT", x=0, y=-TITAN_PANEL_BAR_HEIGHT*2} }, - hide = { - top = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT", x=0, y=TITAN_PANEL_BAR_HEIGHT*2}, - bot = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT", x=0, y=TITAN_PANEL_BAR_HEIGHT*2} } + plugin_x_offset = 5, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=y_top-(TITAN_PANEL_BAR_HEIGHT*2)}, + user_move = false, + width = GetScreenWidth(), }, -- no idea why -1 is needed for the bottom... seems anchoring to bottom is off a pixel [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"] = { locale_name = L["TITAN_PANEL_MENU_BOTTOM2"], name = "AuxBar2", vert = TITAN_BOTTOM, order = 3, hider = TITAN_PANEL_HIDE_PREFIX.."AuxBar2", - auto_hide_plugin = AUTOHIDE_PREFIX.."AuxBar2"..AUTOHIDE_SUFFIX, plugin_y_offset = 1, - show = { - top = {pt="TOPRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT", x=0, y=TITAN_PANEL_BAR_HEIGHT*2-1}, - bot = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=TITAN_PANEL_BAR_HEIGHT-1} }, - hide = { - top = {pt="TOPRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT", x=0, y=-TITAN_PANEL_BAR_HEIGHT*2}, - bot = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=-TITAN_PANEL_BAR_HEIGHT*2} } + plugin_x_offset = 5, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=TITAN_PANEL_BAR_HEIGHT}, + user_move = false, + width = GetScreenWidth(), }, [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"] = { locale_name = L["TITAN_PANEL_MENU_BOTTOM"], name = "AuxBar", vert = TITAN_BOTTOM, order = 4, hider = TITAN_PANEL_HIDE_PREFIX.."AuxBar", - auto_hide_plugin = AUTOHIDE_PREFIX.."AuxBar"..AUTOHIDE_SUFFIX, plugin_y_offset = 1, - show = { - top = {pt="TOPRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT", x=0, y=TITAN_PANEL_BAR_HEIGHT-1}, - bot = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=0-1} }, - hide = { - top = {pt="TOPRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT", x=0, y=-TITAN_PANEL_BAR_HEIGHT*2}, - bot = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=-TITAN_PANEL_BAR_HEIGHT*2} } + plugin_x_offset = 5, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=0}, + user_move = false, + width = GetScreenWidth(), }, - } +---[[ + [TITAN_PANEL_DISPLAY_PREFIX.."Short01"] = { + locale_name = SHORT.." 01", + name = "Short01", vert = TITAN_SHORT, order = 5, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 2) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short02"] = { + locale_name = SHORT.." 02", + name = "Short02", vert = TITAN_SHORT, order = 6, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 3) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short03"] = { + locale_name = SHORT.." 03", + name = "Short03", vert = TITAN_SHORT, order = 7, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 4) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short04"] = { + locale_name = SHORT.." 04", + name = "Short04", vert = TITAN_SHORT, order = 8, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 5) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short05"] = { + locale_name = SHORT.." 05", + name = "Short05", vert = TITAN_SHORT, order = 9, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 6) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short06"] = { + locale_name = SHORT.." 06", + name = "Short06", vert = TITAN_SHORT, order = 10, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 7) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short07"] = { + locale_name = SHORT.." 07", + name = "Short07", vert = TITAN_SHORT, order = 11, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 8) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short08"] = { + locale_name = SHORT.." 08", + name = "Short08", vert = TITAN_SHORT, order = 12, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 9) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short09"] = { + locale_name = SHORT.." 09", + name = "Short09", vert = TITAN_SHORT, order = 13, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 10) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short10"] = { + locale_name = SHORT.." 10", + name = "Short10", vert = TITAN_SHORT, order = 14, + hider = nil, + plugin_y_offset = 1, + plugin_x_offset = 10, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", + x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 10) -1)}, + user_move = true, + width = SHORT_WIDTH, + }, +} -- Timers used within Titan TitanTimers = {} ---[[ Titan -NAME: AutoHideData table. -DESC: -The index must match the hider 'button' names in the TitanPanel.xml!!! -The table holds: - the name of each hider bar (in the index) - the short name of the hider bar - whether the hider bar is on top or bottom -:DESC ---]] -AutoHideData = { -- This has to follow the convention for plugins... - [AUTOHIDE_PREFIX.."Bar"..AUTOHIDE_SUFFIX] = {name = "Bar", vert = TITAN_TOP}, - [AUTOHIDE_PREFIX.."Bar2"..AUTOHIDE_SUFFIX] = {name = "Bar2", vert = TITAN_TOP}, - [AUTOHIDE_PREFIX.."AuxBar2"..AUTOHIDE_SUFFIX] = {name = "AuxBar2", vert = TITAN_BOTTOM}, - [AUTOHIDE_PREFIX.."AuxBar"..AUTOHIDE_SUFFIX] = {name = "AuxBar", vert = TITAN_BOTTOM}, - } --[[ Titan TitanPluginToBeRegistered table holds each plugin that is requesting to be a plugin. @@ -205,9 +302,6 @@ TitanPluginToBeRegisteredNum = 0 TitanPluginRegisteredNum = 0 ---TitanPluginAttempted = {} ---TitanPluginAttemptedNum = 0 - --[[ Titan TitanPluginExtras table holds the plugin data for plugins that are in saved variables but not loaded on the current character. Saved as TitanPlayerSettings.Extra @@ -236,6 +330,8 @@ TITAN_PANEL_SAVED_VARIABLES = { Buttons = {}, Location = {}, TexturePath = "Interface\\AddOns\\Titan\\Artwork\\", + UseGlobalTexture = false, + UseGlobal_HideInCombat = false, Transparency = 0.7, AuxTransparency = 0.7, Scale = 1, @@ -247,11 +343,6 @@ TITAN_PANEL_SAVED_VARIABLES = { FontName = TPC.FONT_NAME, FrameStrata = "LOW", FontSize = TPC.FONT_SIZE, - LogAdjust = false, - MinimapAdjust = false, - BagAdjust = 1, - TicketAdjust = 1, - Position = 1, ButtonAlign = 1, LockButtons = false, LockAutoHideInCombat = false, @@ -263,23 +354,86 @@ TITAN_PANEL_SAVED_VARIABLES = { Bar_Hide = false, Bar_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, Bar_Transparency = 0.7, + Bar_HideInCombat = false, Bar2_Show = false, Bar2_Hide = false, Bar2_Transparency = 0.7, + Bar2_HideInCombat = false, Bar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, AuxBar_Show = false, AuxBar_Hide = false, AuxBar_Transparency = 0.7, + AuxBar_HideInCombat = false, AuxBar_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, AuxBar2_Show = false, AuxBar2_Hide = false, AuxBar2_Transparency = 0.7, + AuxBar2_HideInCombat = false, AuxBar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - MainMenuBarXAdj = 0, - MenuAndBagVerticalAdjOn = false, - MenuAndBagVerticalAdj = 24, - XPBarVerticalAdjOn = false, - XPBarVerticalAdj = 24, + Short01_Show = false, + Short01_Hide = false, + Short01_Transparency = 0.7, + Short01_HideInCombat = false, + Short01_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short02_Show = false, + Short02_Hide = false, + Short02_Transparency = 0.7, + Short02_HideInCombat = false, + Short02_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short03_Show = false, + Short03_Hide = false, + Short03_Transparency = 0.7, + Short03_HideInCombat = false, + Short03_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short04_Show = false, + Short04_Hide = false, + Short04_Transparency = 0.7, + Short04_HideInCombat = false, + Short04_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short05_Show = false, + Short05_Hide = false, + Short05_Transparency = 0.7, + Short05_HideInCombat = false, + Short05_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short06_Show = false, + Short06_Hide = false, + Short06_Transparency = 0.7, + Short06_HideInCombat = false, + Short06_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short07_Show = false, + Short07_Hide = false, + Short07_Transparency = 0.7, + Short07_HideInCombat = false, + Short07_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short08_Show = false, + Short08_Hide = false, + Short08_Transparency = 0.7, + Short08_HideInCombat = false, + Short08_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short09_Show = false, + Short09_Hide = false, + Short09_Transparency = 0.7, + Short09_HideInCombat = false, + Short09_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + Short10_Show = false, + Short10_Hide = false, + Short10_Transparency = 0.7, + Short10_HideInCombat = false, + Short10_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, + TextureBar = "Interface\\AddOns\\Titan\\Artwork\\", + TextureBar2 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureAuxBar = "Interface\\AddOns\\Titan\\Artwork\\", + TextureAuxBar2 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort01 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort02 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort03 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort04 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort05 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort06 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort07 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort08 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort09 = "Interface\\AddOns\\Titan\\Artwork\\", + TextureShort10 = "Interface\\AddOns\\Titan\\Artwork\\", }; --[[ Titan @@ -287,11 +441,7 @@ TITAN_ALL_SAVED_VARIABLES table holds the Titan Panel Global SavedVars. --]] TITAN_ALL_SAVED_VARIABLES = { -- for timers in seconds - TimerPEW = 4, - TimerDualSpec = 2, TimerLDB = 2, - TimerAdjust = 1, - TimerVehicle = 1, -- Global profile GlobalProfileUse = false, GlobalProfileName = TITAN_PROFILE_NONE, @@ -370,6 +520,12 @@ local function TitanVariables_SyncRegisterSavedVariables(registeredVariables, sa if (registeredVariables and savedVariables) then -- Init registeredVariables for index, value in pairs(registeredVariables) do +--[[ +print("_sync" +.." "..tostring(index).."" +.." : "..tostring(value).."" +) +--]] if (not TitanUtils_TableContainsIndex(savedVariables, index)) then savedVariables[index] = value; end @@ -504,17 +660,6 @@ local function TitanVariables_SyncSkins() end --[[ local -NAME: Sync_panel_settings -DESC: Routine to sync TitanPanelSettings - defaults to saved vars. -VAR: Setting - table to use as the default -OUT: None ---]] -local function Sync_panel_settings(settings) - -- Synchronize registered and saved variables - TitanVariables_SyncRegisterSavedVariables(settings, TitanPanelSettings) -end - ---[[ local NAME: Set_Timers DESC: Routine to reset / sync Titan settings. VAR: None @@ -523,28 +668,27 @@ OUT: None local function Set_Timers(reset) -- Titan is loaded so set the timers we want to use TitanTimers = { --- ["EnterWorld"] = {obj = "PEW", callback = Titan_Hook_PEW, delay = 4,}, --- ["DualSpec"] = {obj = "SpecSwitch", callback = Titan_Hook_SpecSwitch, delay = 2,}, ["LDBRefresh"] = {obj = "LDB", callback = TitanLDBRefreshButton, delay = 2,}, --- ["Adjust"] = {obj = "MoveAdj", callback = Titan_Hook_MoveAdj, delay = 1,}, --- ["Vehicle"] = {obj = "Vehicle", callback = Titan_Hook_Vehicle, delay = 1,}, } if reset then --- TitanAllSetVar("TimerPEW", TitanTimers["EnterWorld"].delay) --- TitanAllSetVar("TimerDualSpec", TitanTimers["DualSpec"].delay) TitanAllSetVar("TimerLDB", TitanTimers["LDBRefresh"].delay) --- TitanAllSetVar("TimerAdjust", TitanTimers["Adjust"].delay) --- TitanAllSetVar("TimerVehicle", TitanTimers["Vehicle"].delay) else --- TitanTimers["EnterWorld"].delay = TitanAllGetVar("TimerPEW") --- TitanTimers["DualSpec"].delay = TitanAllGetVar("TimerDualSpec") TitanTimers["LDBRefresh"].delay = TitanAllGetVar("TimerLDB") --- TitanTimers["Adjust"].delay = TitanAllGetVar("TimerAdjust") --- TitanTimers["Vehicle"].delay = TitanAllGetVar("TimerVehicle") end end +local function Get_Saved_BarData(player) + if TitanSettings.Players[player].BarData then + -- All good + else + -- Set to defaults + TitanSettings.Players[player].BarData = TitanBarDataDefaults + end + -- Set pointer to saved data + return TitanSettings.Players[player].BarData +end + --[[ Titan NAME: TitanVariables_SyncPluginSettings DESC: Routine to sync plugin datas - current loaded (lua file) to any plugin saved vars (last save to disk). @@ -556,7 +700,14 @@ function TitanVariables_SyncPluginSettings() -- one plugin uses this for id, plugin in pairs(TitanPlugins) do if (plugin and plugin.savedVariables) then -- Init savedVariables table - if (not TitanPluginSettings[id]) then + if TitanPluginSettings then + -- exists + else + TitanPluginSettings = {}; + end + if TitanPluginSettings[id] then + -- exists + else TitanPluginSettings[id] = {}; end @@ -582,30 +733,111 @@ NOTE: :NOTE --]] function TitanVariables_InitTitanSettings() + local new_toon = false + local player = TitanUtils_GetPlayer() if (TitanSettings) then -- all is good else +print("_InitTSettings" +.." "..tostring(player).."" +.." "..tostring("Reset of TitanSettings!!!!!").."" +) TitanSettings = {} end + -- check for player list per issue #745 if TitanSettings.Players then -- all is good else - -- Create the table so profile(s) can be added - TitanSettings.Players = {} +print("_InitTSettings" +.." "..tostring(player).."" +.." "..tostring("Reset of TitanSettings.Players!!!!!").."" +) + TitanSettings.Players = {} -- empty saved vars. New install or wipe + end + + if TitanSettings.Players[player] then + -- all is good + else +print("_InitTSettings" +.." "..tostring(player).."" +.." "..tostring("Reset of TitanSettings.Players[player]!!!!!").."" +) +TitanDumpPlayerList() + -- Create the bare player tables so profile(s) can be added + TitanSettings.Players[player] = {} + TitanSettings.Players[player].BarData = TitanBarDataDefaults + TitanSettings.Players[player].Plugins = {} + TitanSettings.Players[player].Panel = TITAN_PANEL_SAVED_VARIABLES + TitanSettings.Players[player].Panel.Buttons = {} + TitanSettings.Players[player].Panel.Location = {} + TitanPlayerSettings = {} + TitanPlayerSettings["Plugins"] = {} + TitanPlayerSettings["Panel"] = {} + TitanPlayerSettings["Register"] = {} + + new_toon = true end + + -- ============== Bar defaults + -- New Mar 2023 to hold Short bars + -- Set pointer to saved data + TitanBarData = Get_Saved_BarData(player) + --[[ TitanDumpPlayerList() --]] --- Sync_panel_settings(TITAN_PANEL_SAVED_VARIABLES) if (TitanAll) then else - TitanAll = {}; + TitanAll = TITAN_ALL_SAVED_VARIABLES end - TitanVariables_SyncRegisterSavedVariables(TITAN_ALL_SAVED_VARIABLES, TitanAll) TitanSettings.Version = TITAN_VERSION; + + return new_toon +end + +--[[ Titan +NAME: TitanVariables_SetBarPos +DESC: Update local and saved vars to new bar pos per user +VAR: None +OUT: None +NOTE: +- Called when Titan is loaded (ADDON_LOADED event) +- Called when user moves or changes width of bar +- :GetPoint(1) results in incorrect values based on point used +:NOTE +--]] +function TitanVariables_SetBarPos(self, reset) + -- Collect bar x & y and save so bar stays put. + local bar_frame = self:GetName() + local off_x = self:GetLeft() + local off_y = self:GetBottom() + local width = self:GetWidth() + + local force_reset = reset or false + +--[[ +print("_SetBarPos" +.." "..tostring(self:GetName()).."" +.." x: "..tostring(off_x).."" +.." y: "..tostring(off_y).."" +) +--]] + local bar_data = TitanBarData[bar_frame] + if bar_data then + if reset then + TitanBarData[bar_frame].show = TitanBarDataDefaults[bar_frame].show + TitanBarData[bar_frame].width = TitanBarDataDefaults[bar_frame].width + TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - "..tostring(bar_data.name)) + else + -- local to show bars as needed + TitanBarData[bar_frame].show.x = off_x + TitanBarData[bar_frame].show.y = off_y + TitanBarData[bar_frame].width = width + end + end end --[[ local @@ -642,8 +874,18 @@ TitanDebug("_UseSettings " --]] CleanupProfile () -- hide currently shown plugins + +--[===[ done at addon loaded -- Ensure the requested profile is at least an empty stub +print("_UseSettings player" +.." "..tostring(TitanSettings.Players).."" +.." : "..tostring(TitanSettings.Players[to_profile]).."" +) if (not TitanSettings.Players[to_profile]) or reset then +---[[ +TitanDebug("_UseSettings player init" +) +--]] TitanSettings.Players[to_profile] = {} TitanSettings.Players[to_profile].Plugins = {} TitanSettings.Players[to_profile].Panel = {} @@ -654,12 +896,14 @@ TitanDebug("_UseSettings " TitanPlayerSettings["Panel"] = {} TitanPlayerSettings["Register"] = {} end +--]===] + -- Set global variables TitanPlayerSettings = TitanSettings.Players[to_profile]; TitanPluginSettings = TitanPlayerSettings["Plugins"]; TitanPanelSettings = TitanPlayerSettings["Panel"]; - Sync_panel_settings(TITAN_PANEL_SAVED_VARIABLES); + TitanVariables_SyncRegisterSavedVariables(TITAN_PANEL_SAVED_VARIABLES, TitanPanelSettings) if action == TITAN_PROFILE_RESET then -- default is global profile OFF @@ -670,6 +914,9 @@ TitanDebug("_UseSettings " elseif action == TITAN_PROFILE_USE then -- The requested profile at least exists so we can copy to it -- Copy from the from_profile to profile - not anything in saved vars + -- Get the bar data settings + TitanBarData = Get_Saved_BarData(from_profile) + if from_profile and TitanSettings.Players[from_profile] then old_player = TitanSettings.Players[from_profile] else @@ -684,6 +931,7 @@ TitanDebug("_UseSettings " for index, id in pairs(old_panel) do TitanPanelSetVar(index, old_panel[index]); end + -- Copy the plugin settings for plugin, i in pairs(old_plugins) do for var, id in pairs(old_plugins[plugin]) do @@ -959,6 +1207,7 @@ TitanDebug("_UseSettings " .."action: "..action.." " ) --]] +--[[ done on addon loaded -- sanity checks to ensure the base tables are set if (TitanSettings) then -- all is good @@ -978,9 +1227,9 @@ TitanDebug("_UseSettings " TitanAll = {}; end TitanVariables_SyncRegisterSavedVariables(TITAN_ALL_SAVED_VARIABLES, TitanAll) - + TitanSettings.Version = TITAN_VERSION; - +--]] local from_profile = nil if action == TITAN_PROFILE_USE then -- Grab the old profile currently in use diff --git a/Titan/locale/Localization.lua b/Titan/locale/Localization.lua index a072909..81091ea 100644 --- a/Titan/locale/Localization.lua +++ b/Titan/locale/Localization.lua @@ -22,6 +22,14 @@ L["TITAN_NONE"] = "None"; L["TITAN_USE_COMMA"] = "Use comma"; L["TITAN_USE_PERIOD"] = "Use period"; +L["TITAN_KEY_CTRL"] = "CTRL"; +L["TITAN_KEY_CTRL_DESC"] = "CTRL key"; +L["TITAN_KEY_SHIFT"] = "SHIFT"; +L["TITAN_KEY_SHIFT_DESC"] = "SHIFT key"; +L["TITAN_KEY_ALT"] = "ALT"; +L["TITAN_KEY_ALT_DESC"] = "ALT key"; + + L["TITAN_PANEL_ERROR_PROF_DELCURRENT"] = "You may not delete your current profile."; local TITAN_PANEL_WARNING = GREEN_FONT_COLOR_CODE.."Warning : "..FONT_COLOR_CODE_CLOSE local TITAN_PANEL_RELOAD_TEXT = "If you wish to continue with this operation, push 'Accept' (your UI will reload), otherwise push 'Cancel' or the 'Escape' key." @@ -104,6 +112,11 @@ L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Show Label Text"; L["TITAN_PANEL_MENU_AUTOHIDE"] = "Auto-Hide"; L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Center Text"; L["TITAN_PANEL_MENU_DISPLAY_BAR"] = "Show Bar"; +L["TITAN_PANEL_MENU_ADV_LABEL"] =(SHOW or "Show").." "..(CUSTOM or "Custom").." Labels" +L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] =(SHOW or "Show") +L["TITAN_PANEL_MENU_ADV_CUSTOM"] =(CUSTOM or "Custom") +L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"] = "Custom label text to show."; + L["TITAN_PANEL_MENU_DISABLE_PUSH"] = "Disable Screen Adjust"; L["TITAN_PANEL_MENU_DISABLE_MINIMAP_PUSH"] = "Disable Minimap Adjust"; L["TITAN_PANEL_MENU_DISABLE_LOGS"] = "Automatic Log Adjust"; @@ -134,6 +147,7 @@ L["TITAN_PANEL_MENU_OPTIONS_SHORT"] = "Tooltips and Frames"; L["TITAN_PANEL_MENU_TOP_BARS"] = "Top Bars" L["TITAN_PANEL_MENU_BOTTOM_BARS"] = "Bottom Bars" L["TITAN_PANEL_MENU_OPTIONS_BARS"] = "Bars" +L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"] = "Bars - "..(ALL or "All") L["TITAN_PANEL_MENU_OPTIONS_MAIN_BARS"] = TITAN_PANEL.." Top Bars"; L["TITAN_PANEL_MENU_OPTIONS_AUX_BARS"] = TITAN_PANEL.." Bottom Bars"; L["TITAN_PANEL_MENU_OPTIONS_TOOLTIPS"] = "Tooltips"; @@ -231,14 +245,31 @@ L["TITAN_PANEL_MENU_FONT_SIZE"] = "Font Size"; L["TITAN_PANEL_MENU_FONT_SIZE_DESC"] = "Sets the size for the "..TITAN_PANEL.." font."; L["TITAN_PANEL_MENU_FRAME_STRATA"] = ""..TITAN_PANEL.." Frame Strata"; L["TITAN_PANEL_MENU_FRAME_STRATA_DESC"] = "Adjusts the frame strata for the "..TITAN_PANEL.." Bar(s)."; --- /end localization strings for AceConfigDialog-3.0 + +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") + +L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") +L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") +L["TITAN_PANEL_MENU_HIDE_IN_COMBAT"] = (HIDE or "Hide").." In Combat" +L["TITAN_PANEL_MENU_HIDE_IN_COMBAT_DESC"] = (HIDE or "Hide").."All Bars While In Combat" +L["TITAN_PANEL_MENU_RESET_POSITION"] = (RESET_POSITION or "Reset Position Only") +L["TITAN_PANEL_MENU_TOOLTIP_MOD"] = "Use Modifier to Show Tooltip" +L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"] = "Global Skin" +L["TITAN_PANEL_MENU_GLOBAL_SKIN"] = "Use Global Skin" +L["TITAN_PANEL_MENU_GLOBAL_SKIN_TIP"] = "Use Global Skin for All Bars" L["TITAN_PANEL_MENU_ADV"] = "Advanced"; -L["TITAN_PANEL_MENU_ADV_DESC"] = "Change Timers only if you experience issues with frames not adjusting.".."\n"; -L["TITAN_PANEL_MENU_ADV_PEW"] = "Entering World"; -L["TITAN_PANEL_MENU_ADV_PEW_DESC"] = "Change value (usually increase) if frames do not adjust when entering / leaving world or an instance."; -L["TITAN_PANEL_MENU_ADV_VEHICLE"] = "Vehicle"; -L["TITAN_PANEL_MENU_ADV_VEHICLE_DESC"] = "Change value (usually increase) if frames do not adjust when entering / leaving vehicle."; +L["TITAN_PANEL_MENU_ADV_DESC"] = "Output Titan Info At Startup.".."\n"; +L["TITAN_PANEL_MENU_ADV_NAME"] = "Name and Version"; +L["TITAN_PANEL_MENU_ADV_NAME_DESC"] = "Show Titan name and version on entering world."; +L["TITAN_PANEL_MENU_ADV_PLUGINS"] = "Plugin Registration process"; +L["TITAN_PANEL_MENU_ADV_PLUGINS_DESC"] = "Shows start and end of Registration process and number of registered plugins."; + +L["TITAN_PANEL_MENU_ADV_NOTES"] = "Notes"; +L["TITAN_PANEL_MENU_ADV_NOTES_PLUGIN"] = "Plugin Notes"; + +L["TITAN_PANEL_MENU_HELP"] = TITAN_PANEL.." "..(HELP_LABEL or "Help") +-- /end localization strings for AceConfigDialog-3.0 L["TITAN_AUTOHIDE_TOOLTIP"] = "Toggles "..TITAN_PANEL.." auto-hide on/off feature"; diff --git a/TitanBag/TitanBag.toc b/TitanBag/TitanBag.toc index b330b89..d91abae 100644 --- a/TitanBag/TitanBag.toc +++ b/TitanBag/TitanBag.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa007.00.00.100007|r ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanBag.lua diff --git a/TitanClock/TitanClock.toc b/TitanClock/TitanClock.toc index 2c1d99a..bca01f8 100644 --- a/TitanClock/TitanClock.toc +++ b/TitanClock/TitanClock.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa007.00.00.100007|r ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanClock.lua diff --git a/TitanGold/TitanGold.toc b/TitanGold/TitanGold.toc index cd37eda..013f85e 100644 --- a/TitanGold/TitanGold.toc +++ b/TitanGold/TitanGold.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa007.00.00.100007|r ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: GoldSave ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanGold.lua diff --git a/TitanLocation/TitanLocation.toc b/TitanLocation/TitanLocation.toc index ce08001..93a4e4c 100644 --- a/TitanLocation/TitanLocation.toc +++ b/TitanLocation/TitanLocation.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa007.00.00.100007|r ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanLocation.lua diff --git a/TitanLootType/TitanLootType.toc b/TitanLootType/TitanLootType.toc index 8fd6222..5fa6bf5 100644 --- a/TitanLootType/TitanLootType.toc +++ b/TitanLootType/TitanLootType.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa007.00.00.100007|r ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanLootType.lua diff --git a/TitanPerformance/TitanPerformance.toc b/TitanPerformance/TitanPerformance.toc index 30e8863..e14e648 100644 --- a/TitanPerformance/TitanPerformance.toc +++ b/TitanPerformance/TitanPerformance.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa007.00.00.100007|r ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanPerformance.lua diff --git a/TitanRepair/TitanRepair.toc b/TitanRepair/TitanRepair.toc index d2f3b98..b677c3c 100644 --- a/TitanRepair/TitanRepair.toc +++ b/TitanRepair/TitanRepair.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa007.00.00.100007|r ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanRepair.lua diff --git a/TitanVolume/TitanVolume.toc b/TitanVolume/TitanVolume.toc index e510f3d..adb8185 100644 --- a/TitanVolume/TitanVolume.toc +++ b/TitanVolume/TitanVolume.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa007.00.00.100007|r ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanVolume.lua diff --git a/TitanXP/TitanXP.toc b/TitanXP/TitanXP.toc index 775427a..fc208d6 100644 --- a/TitanXP/TitanXP.toc +++ b/TitanXP/TitanXP.toc @@ -1,10 +1,10 @@ -## Interface: 100005 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa006.00.12.100005|r +## Interface: 100007 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa007.00.00.100007|r ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 6.00.12.100005 +## Version: 7.00.00.100007 ## X-Child-Of: Titan TitanXP.lua