diff --git a/Titan/Titan.lua b/Titan/Titan.lua index f26d23b..ca5eeb5 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -1373,7 +1373,7 @@ function TitanPanelBarButton_ForceLDBLaunchersRight() buttonText:SetText("") button:SetWidth(16); TitanPlugins[id].buttonTextFunction = nil; - _G["TitanPanel"..id..TITAN_PANEL_BUTTON_TEXT] = nil; + _G[TitanUtils_ButtonName(id)..TITAN_PANEL_TEXT] = nil; if button:IsVisible() then local bar = TitanUtils_GetWhichBar(id) TitanPanel_RemoveButton(id); @@ -1697,7 +1697,7 @@ function TitanPanel_InitPanelButtons() -- ========================= -- capture the button for the next plugin - r_prior.button = "TitanPanel"..id.."Button" + r_prior.button = TitanUtils_ButtonName(id) -- set prior[x] the anchor points and offsets for the next plugin r_prior.anchor = "LEFT" r_prior.x = icon_spacing @@ -1724,7 +1724,7 @@ print("Bar plugins" -- ========================= -- capture the next plugin - l_prior.button = "TitanPanel"..id.."Button" + l_prior.button = TitanUtils_ButtonName(id) -- set prior[x] (anchor points and offsets) for the next plugin l_prior.anchor = "RIGHT" l_prior.x = (button_spacing) diff --git a/Titan/Titan.toc b/Titan/Titan.toc index 9ed9282..85359f8 100644 --- a/Titan/Titan.toc +++ b/Titan/Titan.toc @@ -1,7 +1,7 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa007.00.03.100100|r ## Author: Titan Panel Development Team -## Version: 7.00.02.100007 +## Version: 7.00.03.100100 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## Notes: Adds display bars on the top and/or bottom of the screen; also adds user placable bars. Allows users to show and control information/launcher plugins. ## X-Credits: TitanMod, Dark Imakuni, Adsertor, Titan Dev Team @@ -38,6 +38,7 @@ locale\Localization.MX.lua locale\Localization.RU.lua locale\Localization.TW.lua +TitanGlobal.lua TitanUtils.lua TitanVariables.lua TitanTemplate.xml diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 579ac38..15a5621 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -27,39 +27,31 @@ Highlight - notes. tips. and details --]] local notes = "" + ..TitanUtils_GetRedText("NOTE : ") ..TitanUtils_GetNormalText("" - .."- 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" + .."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" ) local changes = "" -do -- recent change history -changes = changes - ..TitanUtils_GetGoldText("7.00.01.100007 : 2023/03/31\n") + ..TitanUtils_GetGoldText("6.00.16.100100 : 2023/05/03\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" - .."- NEW : 10 Short bars! See new consolidated Configuration > Titan Panel Help for enabling and using.\n" - .."- NEW : Skins OR solid color selectable in Config - Global or per bar. \n" - .."- NEW : Can Hide any Titan bar by right click on the Titan bar (not a plugin) then click Hide.\n" - .."- NEW : Hide in Combat is now selectable in Config - Global or per bar.\n" - .."- NOTE : Solid colors are done via the default color picker. Download an enhanced color picker for more options.\n" - .."- NOTE : Downgrading from Titan 7.xx to 6.xx - Prior to downgrading, move any plugins on a Short bar to one of the original full width Titan Bars or Hide the plugin.\n" - .."--- Titan 6.xx will throw an error IF any plugin is assigned to ANY Short Bar. If Titan throws an error, wipe the Titan saved variables.\n" - .."- Configuration > Bars has a new consolidated config for each Titan bar.\n" - .."- Configuration > Bars All has a new config for options across all Titan bars.\n" - .."- Configuration > Transparency moved into Bars.\n" - .."- Configuration > Titan Panel Help has details on using Titan 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" - .."- Internal code cleanup.\n" .."- Update TOC\n" + .."- Fix for some LDB addons not loading (creation post Player Entering World).\n" ) .."\n\n" - ..TitanUtils_GetGoldText("6.00.13.100005 : 2023/03/20\n") + ..TitanUtils_GetGoldText("6.00.15.100100 : 2023/05/02\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" - .."- Update TOC only to 10.00.07\n" + .."- Update TOC and WoW version (10.1)\n" + .."- Update for changes Blizzard made API routine which get Addon meta data.\n" + ) + .."\n\n" + ..TitanUtils_GetGoldText("6.00.14.100007 : 2023/03/29\n") + ..TitanUtils_GetGoldText("6.00.13.100007 : 2023/03/20\n") + ..TitanUtils_GetGreenText("Titan : \n") + ..TitanUtils_GetHighlightText("" + .."- Update TOC\n" + .."- Back out Short Bar release.\n" ) .."\n\n" ..TitanUtils_GetGoldText("6.00.12.100005 : 2023/01/31\n") @@ -99,60 +91,92 @@ changes = 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" -end TITAN_PANEL_CONFIG = { topic = { About = L["TITAN_PANEL"], - top = L["TITAN_PANEL_MENU_OPTIONS_BARS"], - globals = L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"], + top = L["TITAN_PANEL_MENU_TOP_BARS"], 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 = L["TITAN_PANEL_MENU_CHANGE_HISTORY"], - slash = L["TITAN_PANEL_MENU_SLASH_COMMAND"], - help = L["TITAN_PANEL_MENU_HELP"], + changes = (CHANGE or "Change").." "..(HISTORY or "History"), + slash = ("/").." "..(COMMAND or "Command"), } } +-- TITAN_PANEL_CONFIG.topic.trans -- Titan local helper funcs local function TitanPanel_GetTitle() - return GetAddOnMetadata(TITAN_ID, "Title") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "Title") or L["TITAN_NA"]; end local function TitanPanel_GetAuthor() - return GetAddOnMetadata(TITAN_ID, "Author") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "Author") or L["TITAN_NA"]; end local function TitanPanel_GetCredits() - return GetAddOnMetadata(TITAN_ID, "X-Credits") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Credits") or L["TITAN_NA"]; end local function TitanPanel_GetCategory() - return GetAddOnMetadata(TITAN_ID, "X-Category") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Category") or L["TITAN_NA"]; end local function TitanPanel_GetEmail() - return GetAddOnMetadata(TITAN_ID, "X-Email") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Email") or L["TITAN_NA"]; end local function TitanPanel_GetWebsite() - return GetAddOnMetadata(TITAN_ID, "X-Website") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Website") or L["TITAN_NA"]; end local function TitanPanel_GetLicense() - return GetAddOnMetadata(TITAN_ID, "X-License") or L["TITAN_NA"]; + return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-License") or L["TITAN_NA"]; +end + +--[[ local +NAME: TitanAdjustPanelScale +DESC: Set the Titan bars and plugins to the selected scale then adjust other frames as needed. +VAR: scale - the scale the user has selected for Titan +OUT: None +--]] +local function TitanAdjustPanelScale(scale) + TitanPanel_SetScale() + TitanPanel_AdjustFrames(true, "AdjustPanelScale") 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 @@ -166,24 +190,14 @@ local optionsControl = { type = "group", args = { confgendesc = { - name = "About", order = 1, - 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 - }, - } + 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 }, confnotes = { name = "Notes", @@ -279,95 +293,84 @@ local optionsControl = { ------------- ------------- +-- transparency config section --[[ local -NAME: optionsSkins -DESC: Local table to hold the Titan skins options. Shows default Titan and any custom skins the user has added. +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 --]] -local optionsSkins = { - name = TITAN_PANEL_CONFIG.topic.skins, - type = "group", - args = { - } -} - --- skins config section +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 function Show_Skins(t, position) ---[[ - table.sort(TitanSkins, function(a, b) - return string.lower(TitanSkins[a].name) - < string.lower(TitanSkins[b].name) - end) +--[[ 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 --]] - 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", +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, } + position = position + 1 end - - position = position + 1 -- final spacer - bottom of config - t[skin..position] = { - type = "description", - name = "", - order = position, width = "full", - } end +------------- -local function BuildSkins() - optionsSkins.args = {} - - Show_Skins(optionsSkins.args, 100) -- the current list of skins with images - AceConfigRegistry:NotifyChange("Titan Panel Skin Control") +------------- +-- 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 end --[[ local @@ -403,11 +406,69 @@ 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. @@ -531,30 +592,16 @@ local optionsSkinsCustom = { end end, }, - nulloption4 = { - order = 24, + notes_delete = { + order = 23, type = "description", - name = " ", + name = L["TITAN_SKINS_REMOVE_NOTES"].."\n", 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, + nulloption4 = { + order = 24, type = "description", - name = "\n\n"..L["TITAN_SKINS_REMOVE_NOTES"].."\n", + name = " ", cmdHidden = true }, } @@ -605,16 +652,16 @@ local optionsUIScale = { min = 0.75, max = 1.25, step = 0.01, get = function() return TitanPanelGetVar("Scale") end, set = function(_, a) - TitanPanelSetVar("Scale", a) --- TitanPanel_SetScale() - TitanPanel_InitPanelBarButton("Config scale change "..a) + if not InCombatLockdown() then + TitanPanelSetVar("Scale", a) + TitanAdjustPanelScale(a) + end end, disabled = function() if InCombatLockdown() then return true - else - return false end + return false end, }, buttonspacing = { @@ -639,20 +686,10 @@ local optionsUIScale = { TitanPanel_InitPanelButtons(); end, }, - spacer01 = { - type = "description", - name = "\n\n", imageHeight = 0, - order = 10, width = "full", - }, - tooltipdesc = { - order = 20, width = "full", - type = "header", - name = "Tooltip", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"], - }, tooltipfont = { name = L["TITAN_UISCALE_CONTROL_TOOLTIP_TOOLTIPFONT"], desc = L["TITAN_UISCALE_TOOLTIP_SLIDER_DESC"], - order = 21, type = "range", width = "full", + order = 10, type = "range", width = "full", min = 0.5, max = 1.3, step = 0.01, get = function() return TitanPanelGetVar("TooltipFont") end, set = function(_, a) @@ -662,21 +699,16 @@ local optionsUIScale = { tooltipfontdisable = { name = L["TITAN_UISCALE_TOOLTIP_DISABLE_TEXT"], desc = L["TITAN_UISCALE_DISABLE_TOOLTIP_DESC"], - order = 22, type = "toggle", width = "full", + order = 11, type = "toggle", width = "full", get = function() return TitanPanelGetVar("DisableTooltipFont") end, set = function() TitanPanelToggleVar("DisableTooltipFont"); end, }, - fontdesc = { - order = 30, width = "full", - type = "header", - name = "Font", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"], - }, fontselection = { name = L["TITAN_PANEL_MENU_LSM_FONTS"], desc = L["TITAN_PANEL_MENU_LSM_FONTS_DESC"], - order = 31, type = "select", width = "40", + order = 12, type = "select", dialogControl = "LSM30_Font", get = function() return TitanPanelGetVar("FontName") @@ -687,14 +719,10 @@ local optionsUIScale = { end, values = AceGUIWidgetLSMlists.font, }, - fontspacer = { - order = 32, type = "description", width = "20", - name = " ", - }, fontsize = { name = L["TITAN_PANEL_MENU_FONT_SIZE"], desc = L["TITAN_PANEL_MENU_FONT_SIZE_DESC"], - order = 33, type = "range", width = "40", + order = 13, type = "range", min = 7, max = 15, step = 1, get = function() return TitanPanelGetVar("FontSize") end, set = function(_, v) @@ -702,15 +730,10 @@ local optionsUIScale = { TitanSetPanelFont(TitanPanelGetVar("FontName"), v) end, }, - paneldesc = { - order = 40, width = "full", - type = "header", - name = "Strata", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"], - }, panelstrata = { name = L["TITAN_PANEL_MENU_FRAME_STRATA"], desc = L["TITAN_PANEL_MENU_FRAME_STRATA_DESC"], - order = 41, type = "select", + order = 14, type = "select", get = function() return TitanPanelGetVar("FrameStrata") end, @@ -747,402 +770,252 @@ Main (top) controls: :DESC --]] local optionsBars = { - name = TITAN_PANEL_CONFIG.topic.top, + 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 - local frame_str = bar.frame_name - if TitanBarDataVars[frame_str].show then - -- leave as is - else - res = "|cff808080"..res.._G["FONT_COLOR_CODE_CLOSE"] - end - - return res -end - --[[ local -NAME: TitanUpdateConfigBars -DESC: Allow the user to control each Titan bar. +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 :DESC -VAR: None -OUT: None --]] -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 - -- ====== - -- Build the bar list in order (left side) - -- NOTE: v.name is the 'group' name which is the table passed to callbacks : info[1] - local v = bar_list[idx] -- process this bar - position = position + 1 - args[v.name] = { - type = "group", - name = ColorShown(v), - order = position, - } - -- ====== - -- Build bar options (right side) - args[v.name].args = {} -- ,args caused the nesting / right side - position = position + 1 -- Title divider - args[v.name].args.title = { +local optionsAuxBars = { + name = TITAN_PANEL_CONFIG.topic.bottom, --L["TITAN_PANEL_MENU_OPTIONS_AUX_BARS"], + type = "group", + args = { + confdesc1 = { + order = 100, type = "header", - 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_BOTTOM"], + }, + optiontop = { name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = position, - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].show - end, - set = function(info, val) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanBarDataVars[frame_str].show = not TitanBarDataVars[frame_str].show - TitanPanelBarButton_DisplayBarsWanted(info[1].."Show "..tostring(val)) - TitanUpdateConfigBars(optionsBars.args, 1000) - end, - } - position = position + 1 -- Auto hide toggle - args[v.name].args.autohide = { - type = "toggle", width = .75, --"fill", + 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"], - order = position, - disabled = (v.hider == nil), - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].auto_hide - end, - set = function(info, val) - Titan_AutoHide_ToggleAutoHide(info[1]) -- short bar name - end, - } - position = position + 1 -- Center toggle - args[v.name].args.center = { - type = "toggle", width = .75, --"fill", + 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"], - order = position, - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return (TitanBarDataVars[frame_str].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - if (TitanBarDataVars[frame_str].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then - TitanBarDataVars[frame_str].align = TITAN_PANEL_BUTTONS_ALIGN_LEFT - else - TitanBarDataVars[frame_str].align = TITAN_PANEL_BUTTONS_ALIGN_CENTER - end - - -- Justify button position - TitanPanelButton_Justify(); - end, - } - 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(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].hide_in_combat - end, - set = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanBarDataVars[frame_str].hide_in_combat = - not TitanBarDataVars[frame_str].hide_in_combat - end, - } - position = position + 1 -- spacer - args[v.name].args.transpacer1 = { - order = position, type = "description", width = "full", - name = " ", - } - 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) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanVariables_SetBarPos(_G[frame_str], true) - TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - "..tostring(info[1])) + 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, - } - -- ====== - -- Background group - position = position + 1 -- background - args[v.name].args.back = { - type = "header", - name = "=== "..BACKGROUND.." ===", - order = position, - } - position = position + 1 -- select background - args[v.name].args.settextousebar = { - name = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN"], - desc = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TIP"], - order = position, type = "select", width = "full", - style = "radio", - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].texure end, - set = function(info, val) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanBarDataVars[frame_str].texure = val - TitanPanel_SetBarTexture(frame_str) - end, - values = { - [TitanVars.SKIN] = L["TITAN_SKINS_TITLE"], - [TitanVars.COLOR] = COLOR, - }, - } - position = position + 1 -- Title divider - args[v.name].args.skintitle = { + set = function() TitanPanelBarButton_ToggleAlign("AuxBar_Align"); end, + }, + confdesc2 = { + order = 200, type = "header", - name = L["TITAN_SKINS_TITLE"], - order = position, width = "full", - } - position = position + 1 -- Skin select - args[v.name].args.skinselect = { - type = "select", width = "normal", - name = "", --v.locale_name, - order = position, - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].skin.path - end, - set = function(info,val) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanBarDataVars[frame_str].skin.path = val - TitanPanel_SetBarTexture(frame_str) - if TitanSkinToRemove == TitanPanelGetVar("Texture"..info[1]) then - TitanSkinToRemove = "None" - end - end, - values = function(info) - local Skinlist = {} - local frame_str = TitanVariables_GetFrameName(info[1]) - for _, val in pairs (TitanSkins) do - if val.path ~= TitanBarDataVars[frame_str].skin.path then - -- 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 + 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"))) 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(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - local vert = TitanBarData[frame_str].vert - if vert == TITAN_SHORT then - vert = TITAN_TOP - else - -- Use it as is - end - return TitanBarDataVars[frame_str].skin.path.."TitanPanelBackground"..vert.."0" + }, + 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") end, - imageWidth = 256, - order = position, type = "description", width = .5, --"60", - } - 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 frame_str = TitanVariables_GetFrameName(info[1]) - return TitanBarDataVars[frame_str].skin.alpha + 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") end, - set = function(info, a) - local frame_str = TitanVariables_GetFrameName(info[1]) - _G[frame_str]:SetAlpha(a) - TitanBarDataVars[frame_str].skin.alpha = a + }, + 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") end, - } - position = position + 1 -- Title divider - args[v.name].args.colortitle = { - type = "header", - name = COLOR, - order = position, width = "full", - } - position = position + 1 -- spacer - args[v.name].args.colorspacer = { - order = position, type = "description", width = "full", - name = " ", - } - position = position + 1 -- reset pos - args[v.name].args.colorselect = { - type = "color", width = "Full", - name = "Select Bar Color", -- L["TITAN_PANEL_MENU_RESET_POSITION"], - order = position, - -- disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), - hasAlpha = true, - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - local color = TitanBarDataVars[frame_str].color - return color.r, - color.g, - color.b, - color.alpha - end, - set = function(info, r, g, b, a) - local frame_str = TitanVariables_GetFrameName(info[1]) - - TitanBarDataVars[frame_str].color.r = r - TitanBarDataVars[frame_str].color.g = g - TitanBarDataVars[frame_str].color.b = b - TitanBarDataVars[frame_str].color.alpha = a - TitanPanel_SetBarTexture(frame_str) - end, - } - end - - -- Config Tables changed! - AceConfigRegistry:NotifyChange("Titan Panel Bars") ---[===[ -print("Color new:" -.." "..tostring(format("%0.1f", r)).."" -.." "..tostring(format("%0.1f", g)).."" -.." "..tostring(format("%0.1f", b)).."" -.." "..tostring(format("%0.1f", a)).."" -) ---]===] -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" - .."- Open Configuration > Bars to enable and change Bar options.\n" - .."- The default position is the top center under the full width bars. They will be stacked to not overlap.\n" - .."- Move : Use Shift + left mouse and dragging.\n" - .."- Change width by 1 : Use Shift + mouse wheel.\n" - .."- Change width by 10: Use Shift + Ctrl + mouse wheel.\n" - .."- When dragging, best to place your mouse over the left side padding before moving or changing width.\n" - .."- When dragging stops, if the Short Bar is beyond the screen edge the Short Bar should 'snap' to the edge.\n" - .."- Skin : Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" - .."- Reset : In case a Short bar gets messed up, use Reset Position to place it at original position and width. This does not move plugins.\n" - .."- Min width : Left side padding plus one icon width.\n" - .."- Max width : Screen width.\n" - .."Limitations\n" - .."- There is no 'snap together' or grid for placing Short Bars.\n" - ) - .."\n\n" - ..TitanUtils_GetGreenText("All Bars: \n") - ..TitanUtils_GetHighlightText("" - .."- Bar Right click menu shows the name of the Bar in the menu title corresponding to configuration options.\n" - .."- Hide any Titan bar by using the Bar Right click menu then click Hide.\n" - .."- Titan does not restrict plugins to fit within the visible width. Using Configuration, plugins can be assigned well beyond the visible side. This may be desirable for some users.\n" - .."- Setting a plugin to right-side will use the visible right side; and may overlap with left or center aligned plugins.\n" - .."- Skins : \n" - .."--- Select per Titan bar.\n" - .."--- Select a skin for all Titan bars. This does NOT change the individual Titan bar skin settings.\n" - .."- Hide in Combat : \n" - .."--- Select per Titan bar.\n" - .."--- Hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" - .."- Bar Order (English): Configuration > Bars shows localized Bar names.\n" - .."--- Top : Always top of screen\n" - .."--- Top 2 : Always under Top Bar\n" - .."--- Bottom 2 : Always above Bottom Bar\n" - .."--- Bottom : Always bottom of screen\n" - .."--- Short 01 - 10 : User placed\n" - ) - .."\n\n" - ..TitanUtils_GetGreenText("Plugins: \n") - ..TitanUtils_GetHighlightText("" - .."Show / Hide Plugins - use one of the methods below:\n" - .."--- Open the right-click Bar menu; find the plugin in a category then click to show / hide the plugin.\n" - .."--- Open Titan Configuration > Plugins then select the plugin by name then check / uncheck Show. If needed, use the Bar dropdown to select the Bar the plugin should be on.\n" - ) - ..TitanUtils_GetHighlightText("" - .."Moving Plugins - use one of the methods below:\n" - .."--- Open the right-click menu; find the plugin in a category then hide then show.\n" - .."--- Drag and drop on another bar or on the same bar.\n" - .."--- Drag and drop on another plugin to swap the plugins.\n" - .."--- Open Titan Configuration > Plugins then check / uncheck Show then use the Bar dropdown and Right / Left buttons.\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, + }, + }, + }, + confxpbardesc = { + name = "Status Bar", type = "group", inline = true, + order = 410, args = { - confdesc = { - order = 1, - type = "description", - name = help_text, - cmdHidden = true + 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") + 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") + 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") + end, + }, + }, }, } } -------------- +------------- -- General Titan config section --[[ local NAME: optionsFrames @@ -1194,8 +1067,8 @@ local optionsFrames = { cmdHidden = true, }, advname = { - name = L["TITAN_PANEL_MENU_TOOLTIP_MOD"], - desc = "", -- L[""], + name = "Use Modifier to Show Tooltip", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], order = 120, type = "toggle", width = "full", get = function() return TitanAllGetVar("UseTooltipModifer") end, set = function(_, a) @@ -1208,8 +1081,8 @@ local optionsFrames = { order = 140, args = { alt_key = { - name = L["TITAN_KEY_ALT"], - desc = L["TITAN_KEY_ALT_DESC"], + name = ALT_KEY_TEXT, + desc = ALT_KEY, order = 110, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferAlt") end, set = function(_, a) @@ -1217,8 +1090,8 @@ local optionsFrames = { end, }, ctrl_key = { - name = L["TITAN_KEY_CTRL"], - desc = L["TITAN_KEY_CTRL_DESC"], + name = CTRL_KEY_TEXT, + desc = CTRL_KEY, order = 120, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferCtrl") end, set = function(_, a) @@ -1226,8 +1099,8 @@ local optionsFrames = { end, }, shift_key = { - name = L["TITAN_KEY_SHIFT"], - desc = L["TITAN_KEY_SHIFT_DESC"], + name = SHIFT_KEY_TEXT, + desc = SHIFT_KEY, order = 130, type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferShift") end, set = function(_, a) @@ -1245,18 +1118,21 @@ 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, @@ -1302,172 +1178,6 @@ 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 = "select", width = "full", - style = "radio", - get = function() return TitanBarDataVars["Global"].texure end, - set = function(_, v) - TitanBarDataVars["Global"].texure = v - for idx, val in pairs (TitanBarData) do - TitanPanel_SetBarTexture(idx) - end - end, - values = { - [TitanVars.SKIN] = L["TITAN_SKINS_TITLE"], - [TitanVars.COLOR] = COLOR, - [TitanVars.NONE] = NONE, - }, - }, - confskindesc = { - order = 20, width = "full", - type = "description", - name = L["TITAN_SKINS_TITLE"], - }, - setskinglobal = { - order = 21, type = "select", width = "30", - name = " ", --L["TITAN_SKINS_LIST_TITLE"], - desc = L["TITAN_SKINS_SET_DESC"], - get = function() return TitanBarDataVars["Global"].skin.path end, - set = function(_,v) - TitanBarDataVars["Global"].skin.path = v --TitanPanelSetVar("TexturePath", v); - if TitanBarDataVars["Global"].texure == TitanVars.SKIN then - for idx, val in pairs (TitanBarData) do - TitanPanel_SetBarTexture(idx) - end - end - end, - values = function() - local Skinlist = {} - local v; - for _,v in pairs (TitanSkins) do - if v.path ~= TitanBarDataVars["Global"].skin.path then --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 TitanBarDataVars["Global"].skin.path.."TitanPanelBackgroundTop0" --- return TitanPanelGetVar("TexturePath").."TitanPanelBackgroundTop0" - end, - imageWidth = 256, - order = 31, width = "60", - }, - confcolorspacer = { -- spacer - order = 50, type = "description", width = "full", - name = " ", - }, - confcolordesc = { - order = 51, width = "full", - type = "description", - name = COLOR, - }, - show_skin_color_picker = { - type = "color", width = "Full", - name = "Select Bar Color", -- L["TITAN_PANEL_MENU_RESET_POSITION"], - order = 55, --- disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), - hasAlpha = true, - get = function() - local color = TitanBarDataVars["Global"].color - return color.r, - color.g, - color.b, - color.alpha - end, - set = function(info, r, g, b, a) ---[===[ -print("Color new:" -.." "..tostring(format("%0.1f", r)).."" -.." "..tostring(format("%0.1f", g)).."" -.." "..tostring(format("%0.1f", b)).."" -.." "..tostring(format("%0.1f", a)).."" -) ---]===] - TitanBarDataVars["Global"].color.r = r - TitanBarDataVars["Global"].color.g = g - TitanBarDataVars["Global"].color.b = b - TitanBarDataVars["Global"].color.alpha = a - if TitanBarDataVars["Global"].texure == TitanVars.COLOR then - for idx, val in pairs (TitanBarData) do - TitanPanel_SetBarTexture(idx) - end - end - end, - }, - hidecombatspacer = { -- spacer - order = 100, type = "description", width = "full", - name = " ", - }, - confcombatdesc = { - order = 101, 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("HideBarsInCombat") end, - set = function() TitanPanelToggleVar("HideBarsInCombat"); end, - }, - arenaspacer = { -- spacer - order = 200, type = "description", width = "full", - name = " ", - }, - confarenadesc = { - order = 201, width = "full", - type = "header", - name = BATTLEGROUND.." / "..ARENA, - }, - setarenauseglobal = { - name = HIDE.." "..L["TITAN_PANEL_MENU_TOP_BARS"] - .." - "..BATTLEGROUND.." / "..ARENA , - desc = "Hide" - .." "..TitanBarData[TitanVariables_GetFrameName("Bar")].locale_name - .." and" - .." "..TitanBarData[TitanVariables_GetFrameName("Bar2")].locale_name - .." in "..BATTLEGROUND.." / "..ARENA, - order = 205, type = "toggle", width = "full", - get = function() return TitanPanelGetVar("HideBarsInPVP") end, - set = function() - TitanPanelToggleVar("HideBarsInPVP") - TitanPanelBarButton_DisplayBarsWanted("HideBarsInPVP" - .." "..tostring(TitanPanelGetVar("HideBarsInPVP"))) - end, - }, - } -} - -------------- -- attempted plugins config section --[[ local NAME: optionsAddonAttempts @@ -1478,7 +1188,6 @@ 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. @@ -1607,8 +1316,7 @@ 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. @@ -1679,7 +1387,6 @@ local optionsChars = { type = "group", args = {} } - --[[ local NAME: TitanUpdateChars DESC: Allow the user to delete toon data (just not the one they are logged into). @@ -1917,7 +1624,6 @@ local optionsAddons = { type = "group", args = {} } - local function ColorVisible(id, name) local res = "?" if TitanPanel_IsPluginShown(id) then @@ -1928,7 +1634,6 @@ local function ColorVisible(id, name) return res end - --[[ local NAME: TitanUpdateConfigAddons DESC: Allow the user to control each plugin registered to Titan. @@ -2119,8 +1824,7 @@ local function TitanUpdateConfigAddons() local Locationlist = {} local v for idx,v in pairs (TitanBarData) do - if TitanBarDataVars[idx].show then --- if TitanPanelGetVar(TitanBarData[idx].name.."_Show") then + if TitanPanelGetVar(TitanBarData[idx].name.."_Show") then Locationlist[TitanBarData[idx].name] = TitanBarData[idx].locale_name end end @@ -2145,12 +1849,12 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.custom_notes = { order = 60, type = "header", - name = L["TITAN_PANEL_MENU_ADV_NOTES_PLUGIN"], + name = "Notes", } if plug_in.notes then args[plug_in.id].args.notes = { type = "description", - name = L["TITAN_PANEL_MENU_ADV_NOTES"], + name = "Notes", order = 61, name = "" .._G["GREEN_FONT_COLOR_CODE"]..plug_in.notes.."|r", @@ -2159,9 +1863,9 @@ local function TitanUpdateConfigAddons() else args[plug_in.id].args.notes = { type = "description", - name = L["TITAN_PANEL_MENU_ADV_NOTES"], + name = "Notes", order = 61, - name = _G["GREEN_FONT_COLOR_CODE"]..L["TITAN_NONE"].."|r", + name = _G["GREEN_FONT_COLOR_CODE"]..NONE.."|r", cmdHidden = true, } end @@ -2173,11 +1877,11 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.custom_labels = { order = 70, type = "header", - name = L["TITAN_PANEL_MENU_ADV_LABEL"], + name = SHOW.." "..CUSTOM.." ".."Labels", } args[plug_in.id].args.custom_label_show = { type = "toggle", - name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 1", + name = SHOW, order = 71, get = function(info) return (TitanGetVar(info[1], "CustomLabelTextShow") or false) end, set = function(info, v) @@ -2187,8 +1891,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label_text = { order = 72, - name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], - desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], + name = CUSTOM, + desc = "Custom label text to show", type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabelText") or "") end, set = function(info,v) @@ -2200,7 +1904,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 2 then args[plug_in.id].args.custom_label2_show = { type = "toggle", - name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 2", + name = SHOW.." 2", order = 73, get = function(info) return (TitanGetVar(info[1], "CustomLabel2TextShow") or false) end, set = function(info, v) @@ -2210,8 +1914,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label2_text = { order = 74, - name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], - desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], + name = CUSTOM, + desc = "Custom label text to show", type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel2Text") or "") end, set = function(info,v) @@ -2223,7 +1927,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 3 then args[plug_in.id].args.custom_label3_show = { type = "toggle", - name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 3", + name = SHOW.." 3", order = 75, get = function(info) return (TitanGetVar(info[1], "CustomLabel3TextShow") or false) end, set = function(info, v) @@ -2233,8 +1937,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label3_text = { order = 76, - name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], - desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], + name = CUSTOM, + desc = "Custom label text to show", type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel3Text") or "") end, set = function(info,v) @@ -2246,7 +1950,7 @@ local function TitanUpdateConfigAddons() if num_labels >= 4 then args[plug_in.id].args.custom_label4_show = { type = "toggle", - name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 4", + name = SHOW.." 4", order = 77, get = function(info) return (TitanGetVar(info[1], "CustomLabel4TextShow") or false) end, set = function(info, v) @@ -2256,8 +1960,8 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.custom_label4_text = { order = 78, - name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], - desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], + name = CUSTOM, + desc = "Custom label text to show", type = "input", width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel4Text") or "") end, set = function(info,v) @@ -2272,7 +1976,6 @@ local function TitanUpdateConfigAddons() -- Config Tables changed! AceConfigRegistry:NotifyChange("Titan Panel Addon Control") end - ------------- --[[ local NAME: optionsAdvanced @@ -2294,12 +1997,12 @@ local optionsAdvanced = { confdesc = { order = 110, type = "description", - name = L["TITAN_PANEL_MENU_ADV_DESC"], + name = "Output Various Titan Info At Startup.", --L["TITAN_PANEL_MENU_ADV_DESC"], cmdHidden = true }, advname = { - name = L["TITAN_PANEL_MENU_ADV_NAME"], - desc = L["TITAN_PANEL_MENU_ADV_NAME_DESC"], + name = "Name and Version", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], order = 120, type = "toggle", width = "full", get = function() return not TitanAllGetVar("Silenced") end, -- yes, we did it to ourselves... set = function(_, a) @@ -2307,8 +2010,8 @@ local optionsAdvanced = { end, }, advplugins = { - name = L["TITAN_PANEL_MENU_ADV_PLUGINS"], - desc = L["TITAN_PANEL_MENU_ADV_PLUGINS_DESC"], + 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"], order = 120, type = "toggle", width = "full", get = function() return TitanAllGetVar("Registered") end, set = function(_, a) @@ -2321,7 +2024,7 @@ local optionsAdvanced = { } --[[ local -NAME: Recent change history +NAME: change history DESC: Show change history of releases :DESC --]] @@ -2331,13 +2034,14 @@ 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 }, } @@ -2422,8 +2126,7 @@ function TitanUpdateConfig(action) TitanUpdateAddonAttempts() TitanUpdateExtras() TitanUpdateChars() - BuildSkins() - BuildBars() + TitanPanel_TransOptions(optionsTrans.args) end if action == "nuke" then local nuked = { @@ -2436,8 +2139,7 @@ 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 Globals", nuked) --- AceConfig:RegisterOptionsTable("Titan Panel Aux Bars", 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) @@ -2448,12 +2150,9 @@ 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. --]] @@ -2463,8 +2162,9 @@ 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 Globals", optionsGlobals) +AceConfig:RegisterOptionsTable("Titan Panel Aux Bars", optionsAuxBars) 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) @@ -2475,7 +2175,6 @@ 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' @@ -2485,11 +2184,12 @@ 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 Globals", optionsGlobals.name, optionsControl.name) +AceConfigDialog:AddToBlizOptions("Titan Panel Aux Bars", optionsAuxBars.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) @@ -2497,4 +2197,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/TitanGlobal.lua b/Titan/TitanGlobal.lua new file mode 100644 index 0000000..f7b70b2 --- /dev/null +++ b/Titan/TitanGlobal.lua @@ -0,0 +1,110 @@ +--[[ File +NAME: TitanGlobal.lua +DESC: This file contains the global variables and constants used throughout Titan. +:DESC +--]] + +-- Global variables +TITAN_ID = "Titan" + +TitanVars = {} -- begin the slow journey to a smaller _G footprint + + +TITAN_DEBUG_ARRAY_MAX = 100 +TITAN_PANEL_NONMOVABLE_PLUGINS = {}; +TITAN_PANEL_MENU_FUNC_HIDE = "TitanPanelRightClickMenu_Hide"; +TitanPlugins = {}; -- Used by plugins +TitanPluginsIndex = {}; +TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"].."Not_Registered_Yet".._G["FONT_COLOR_CODE_CLOSE"] +TITAN_REGISTERED = _G["GREEN_FONT_COLOR_CODE"].."Registered".._G["FONT_COLOR_CODE_CLOSE"] +TITAN_REGISTER_FAILED = _G["RED_FONT_COLOR_CODE"].."Failed_to_Register".._G["FONT_COLOR_CODE_CLOSE"] + +Titan__InitializedPEW = nil +Titan__Initialized_Settings = nil + +TITAN_AT = "@" + +TitanAll = nil; +TitanSettings = nil; +TitanPlayerSettings = nil +TitanPluginSettings = nil; -- Used by plugins +TitanPanelSettings = nil; + +TITAN_PANEL_UPDATE_BUTTON = 1; +TITAN_PANEL_UPDATE_TOOLTIP = 2; +TITAN_PANEL_UPDATE_ALL = 3; +TitanTooltipOrigScale = 1; +TitanTooltipScaleSet = 0; + +-- Set Titan Version var for backwards compatibility +TITAN_VERSION = GetAddOnMetadata(TITAN_ID, "Version") or L["TITAN_NA"] + +-- Various constants +TITAN_PANEL_PLACE_TOP = 1; +TITAN_PANEL_PLACE_BOTTOM = 2; +TITAN_PANEL_PLACE_BOTH = 3; +TITAN_PANEL_MOVING = 0; + +TITAN_WOW_SCREEN_TOP = 768 +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; +TITAN_PANEL_BUTTONS_ALIGN_CENTER = 2; + +-- Titan plugins are in the form of TitanPanel<id>Button +TitanVars.plugin = {} +TitanVars.plugin.PRE = "TitanPanel" +TitanVars.plugin.POST = "Button" + + +TITAN_PANEL_CONTROL = "TitanPanelBarButton" +-- New bar vars +TITAN_PANEL_BAR_HEIGHT = 24 +TITAN_PANEL_BAR_TEXTURE_HEIGHT = 30 +TITAN_PANEL_AUTOHIDE_PREFIX = "TitanPanelAutoHide_" +TITAN_PANEL_AUTOHIDE_SUFFIX = "Button" +TITAN_PANEL_HIDE_PREFIX = "Titan_Bar__Hider_" +TITAN_PANEL_DISPLAY_PREFIX = "Titan_Bar__Display_" +TITAN_PANEL_DISPLAY_MENU = "Menu_" +TITAN_PANEL_BACKGROUND_PREFIX = "TitanPanelBackground_" +TITAN_PANEL_CLICK_MENU_SUFFIX = "RightClickMenu" +TITAN_PANEL_TEXT = "Text" +TITAN_PANEL_TEXTURE_VAR = "Texture" +TITAN_PANEL_BUTTON_TEXT = "Button"..TITAN_PANEL_TEXT +TITAN_PANEL_CONSTANTS = { + FONT_SIZE = 10, + FONT_NAME = "Friz Quadrata TT" +} + +TITAN_CUSTOM_PROFILE_POSTFIX = "TitanCustomProfile" +TITAN_PROFILE_NONE = "<>" +TITAN_PROFILE_RESET = "<RESET>" +TITAN_PROFILE_USE = "<USE>" +TITAN_PROFILE_INIT = "<INIT>" + +AUTOHIDE_PREFIX = "TitanPanelAutoHide_" +AUTOHIDE_SUFFIX = "Button" + +TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = + {"Built-ins","General","Combat","Information","Interface","Profession"} + +-- Bar background types +TitanVars.SKIN = "skin" +TitanVars.COLOR = "color" +TitanVars.NONE = "none" + +-- For debug across Titan Panel +TitanVars.debug = {} +TitanVars.debug.movable = false +TitanVars.debug.events = false +TitanVars.debug.ldb_setup = false +TitanVars.debug.tool_tips = false +TitanVars.debug.plugin_register = false +TitanVars.debug.plugin_register_deep = false + diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index bd1a942..37ba2ca 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -96,7 +96,6 @@ local SupportedDOTypes = {DATA_SOURCE, LAUNCHER, "macro"} -- in the 1.1 spec -- constants & variables local CALLBACK_PREFIX = "LibDataBroker_AttributeChanged_" -local NAME_PREFIX = "" --"LDBT_" local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; -- Create control frame so we can get events @@ -226,7 +225,7 @@ NOTE: :NOTE --]] function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) - local TitanPluginframe = _G["TitanPanel"..NAME_PREFIX..name.."Button"]; + local TitanPluginframe = _G["TitanPanel"..name.."Button"]; -- tooltip if event:find("tooltip") and not event:find("OnTooltipShow") then @@ -234,7 +233,7 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) if pluginframe then TitanPluginframe:SetScript("OnEnter", function(self) TitanPanelButton_OnEnter(self); - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) + LDBToTitan:TitanLDBSetTooltip(name, pluginframe, nil) end ) @@ -261,7 +260,7 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) -- do nothing else pluginframe:SetScript("OnShow", function(self) - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) + LDBToTitan:TitanLDBSetTooltip(name, pluginframe, nil) end ) end @@ -272,7 +271,7 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) elseif event:find("OnTooltipShow") then TitanPluginframe:SetScript("OnEnter", function(self) if TITAN_PANEL_MOVING == 0 and func then - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, GameTooltip, func); + LDBToTitan:TitanLDBSetTooltip(name, GameTooltip, func); end TitanPanelButton_OnEnter(self); end @@ -411,7 +410,7 @@ function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) return end -- This check is overkill but just in case... - local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) + local plugin = TitanUtils_GetPlugin(name) local ldb = plugin and plugin.LDBVariables if not ldb then -- This plugin has not been registered @@ -425,7 +424,7 @@ function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) if attr == "label" then ldb.label = value end -- Now update the button with the change - TitanPanelButton_UpdateButton(NAME_PREFIX..name) + TitanPanelButton_UpdateButton(name) end --[[ Titan @@ -438,7 +437,7 @@ OUT: text to show function TitanLDBShowText(name) -- Set 'label1' and 'value1' for the Titan button display local nametrim = string.gsub (name, "LDBT_", ""); - local fontstring = _G["TitanPanel"..NAME_PREFIX..nametrim..TITAN_PANEL_BUTTON_TEXT]; + local fontstring = _G[TitanUtils_ButtonName(nametrim)..TITAN_PANEL_TEXT]; local separator = ": " local lab1, val1 = "", "" local plugin = TitanUtils_GetPlugin(name) @@ -503,7 +502,7 @@ function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) return end -- This check is overkill but just in case... - local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) + local plugin = TitanUtils_GetPlugin(name) local ldb = plugin and plugin.LDBVariables if not ldb then -- This plugin is not registered yet @@ -511,17 +510,17 @@ function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) end if attr == "icon" then - TitanPlugins[NAME_PREFIX..name].icon = value; - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name); + TitanPlugins[name].icon = value; + TitanPanelButton_SetButtonIcon(name); end -- support for iconCoords, iconR, iconG, iconB attributes if attr == "iconCoords" then - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, value); + TitanPanelButton_SetButtonIcon(name, value); end if attr == "iconR" or attr == "iconB" or attr == "iconG" then - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, nil, + TitanPanelButton_SetButtonIcon(name, nil, dataobj.iconR, dataobj.iconG, dataobj.iconB); end end @@ -561,17 +560,42 @@ NOTE: - This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended. :NOTE --]] -function LDBToTitan:TitanLDBCreateObject(_, name, obj) - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug(tostring(name).." Attempting to register "); +function TitanLDBCreateObject(self, name_str, obj) + local name = name_str + if TitanVars.debug.ldb_setup then + TitanDebug(tostring(name).." : Attempting to register "); end -- couple sanity checks - if not obj or not name then - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("LDB request to create Titan plugin was unrecognizable!!!!"); +-- if not obj or not name then + if name and type(name) == 'string' then + -- The name should be reasonable + else + local issue = "LDB request name " + .." '"..tostring(name).."'" + .." unrecognizable !!!!" + if TitanVars.debug.ldb_setup then + TitanDebug(issue); end - return + error (issue) -- get out + end + if obj and type(obj) == 'table' then + -- The LDB obj should be reasonable + else + local object = "" + if obj then + object = "is not a table" + else + object = "does not exist" + end + local issue = "LDB request object for " + .." '"..tostring(name).."'" + .." "..tostring(object).."" + .." !!!!" + if TitanVars.debug.ldb_setup then + TitanDebug(issue); + end + error (issue) -- get out end -- anything to pass to the developer / user @@ -591,23 +615,11 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) -- Create enough of a plugin to tell the user / developer -- that this plugin failed miserably local issue = "Unsupported LDB type '"..tostring(obj.type).."'" - local plugin = - { - self = nil, - button = nil, - isChild = nil, - name = (name or "?"), - issue = issue, - notes = "", - status = TITAN_REGISTER_FAILED, - category = "", - plugin_type = (obj.type or ""), - } - TitanUtils_PluginFail(plugin) - if TITAN_PANEL_VARS.debug.ldb_setup then + if TitanVars.debug.ldb_setup then TitanDebug(TITAN_REGISTER_FAILED.." "..issue); end - return -- get out, there is nothing more that can be done + error (issue) +-- return TITAN_REGISTER_FAILED -- get out, there is nothing more that can be done end -- @@ -695,7 +707,7 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) -- Create the appropriate Titan registry for the DO local registry = { - id = NAME_PREFIX..name, + id = name, ldb = tostring(obj.type), -- per 1.1 spec if .label exists use it else use data object's name menuText = obj.label or name, @@ -731,7 +743,7 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) iconG = (obj.iconG or nil), }; - if TITAN_PANEL_VARS.debug.ldb_setup then + if TitanVars.debug.ldb_setup then TitanDebug("" .." type: '"..tostring(registry.ldb).."' " ) @@ -750,11 +762,11 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) -- This was a sanity check but does not allow for multiple -- LDB to be within an addon yet act as their own addon. -- if IsAddOnLoaded(tempname) then - addoncategory = GetAddOnMetadata(tempname, "X-Category"); + addoncategory = TitanUtils_GetAddOnMetadata(tempname, "X-Category"); registry["category"]= (addoncategory and xcategories[addoncategory]) or (obj.category) or nil - addonversion = GetAddOnMetadata(tempname, "Version") + addonversion = TitanUtils_GetAddOnMetadata(tempname, "Version") or (obj.version) or "" registry["version"]= addonversion; @@ -782,11 +794,11 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj) -- -- Create the Titan frame for this LDB addon - -- Titan _OnLoad will be used to request the plugin be registered by Titan + -- Titan _OnLoad will be used to request the plugin be registered by Titan (Template) local newTitanFrame -- a frame if obj.type == "macro" then -- custom newTitanFrame = CreateFrame("Button", - "TitanPanel"..NAME_PREFIX..name.."Button", + TitanUtils_ButtonName(name), UIParent, "TitanPanelComboTemplate") -- UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") newTitanFrame:RegisterForClicks("AnyUp", "AnyDown") @@ -803,14 +815,14 @@ print("LDB macrotext" .." "..tostring(obj.commandtext).."" ) --]] - if TITAN_PANEL_VARS.debug.ldb_setup then + if TitanVars.debug.ldb_setup then TitanDebug("" .." macrotext cmd: '"..tostring(obj.commandtext).."' " ) end else newTitanFrame = CreateFrame("Button", - "TitanPanel"..NAME_PREFIX..name.."Button", + TitanUtils_ButtonName(name), UIParent, "TitanPanelComboTemplate") end @@ -863,30 +875,73 @@ print("LDB macrotext" CALLBACK_PREFIX..name.."_OnDoubleClick", "TitanLDBHandleScripts") end - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." id: '"..tostring(registry.id).."' " - .." type: '"..tostring(registry.ldb).."' " - .." type: '"..tostring(registry.ldb).."' " - ) - end - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." id: '"..tostring(registry.id).."' " - .." registered" + local pew = "event" + if Titan__InitializedPEW then + pew = "post event" + -- Plugins have already been registered and loaded + -- Get this one loaded + -- This works because the .registry is now set + TitanUtils_RegisterPluginList() + TitanVariables_SyncSinglePluginSettings(registry.id) +-- TitanUtils_RegisterPluginList() + end + if TitanVars.debug.ldb_setup then + TitanDebug("LDB create" + .." "..tostring(pew).."" + .." '"..tostring(registry.id).."'" + .." '"..tostring(registry.ldb).."'" + .."\n...'"..tostring(newTitanFrame:GetName()).."'" ) end + return "Success" +end - -- If plugins have already been registered and loaded then get this one loaded - -- This works because the .registry is now set - if Titan__InitializedPEW then ---[[ -print("LDB late" -.." id: '"..tostring(registry.id).."' " -) +--[[ Titan +NAME: LDBToTitan:SetScript +DESC: OnEvent handler for LDBToTitan +VAR: event - string +VAR: function +OUT: None +NOTE: +- PLAYER_LOGIN - Read through all the LDB objects requesting creation so far. Try to create cooresponding Titan plugins. +:NOTE --]] - TitanUtils_RegisterPluginList() --- TitanPanel_PlayerEnteringWorld() +--function LDBToTitan:TitanLDBCreateObject(name, obj) +function LDBToTitan:TitanLDBCreateObject(sender, name, obj) + local call_success = true + local ret_val = "" + + call_success, -- needed for pcall + ret_val = -- actual return values + pcall (TitanLDBCreateObject, self, name, obj) + + if call_success then + -- Registration request created + else + -- Create enough of a plugin to tell the user / developer + -- that this plugin failed + local plugin = + { + self = nil, + button = nil, + isChild = nil, + name = tostring(name), + issue = ret_val, + notes = "", + status = TITAN_REGISTER_FAILED, + category = "", + plugin_type = tostring(obj.type or "LDB"), + } + TitanUtils_PluginFail(plugin) + end + + if TitanVars.debug.ldb_setup then + TitanDebug("LDB Create:" +-- .." "..tostring(sender).."" + .." "..tostring(name).."" + .." "..tostring(call_success).."" + .." "..tostring(ret_val).."" + ) end end @@ -903,21 +958,48 @@ NOTE: LDBToTitan:SetScript("OnEvent", function(self, event, ...) if (event == "PLAYER_LOGIN") then self:UnregisterEvent("PLAYER_LOGIN") - -- In case a LDB plugin is created later... - ldb.RegisterCallback(self, - "LibDataBroker_DataObjectCreated", "TitanLDBCreateObject") - -- Register the LDB plugins that have been created so far for name, obj in ldb:DataObjectIterator() do - self:TitanLDBCreateObject(nil, name, obj) - --TitanDebug("Registered "..name.."."); + local call_success = true + local ret_val = "" + + -- Just in case, catch any errors + call_success, -- needed for pcall + ret_val = -- actual return values + pcall (TitanLDBCreateObject, self, name, obj) + + if call_success then + -- Registration request created + else + -- Create enough of a plugin to tell the user / developer + -- that this plugin failed + local plugin = + { + self = nil, + button = nil, + isChild = nil, + name = tostring(name), + issue = ret_val, + notes = "", + status = TITAN_REGISTER_FAILED, + category = "", + plugin_type = tostring(obj.type or "LDB"), + } + TitanUtils_PluginFail(plugin) + end + + if TitanVars.debug.ldb_setup then + TitanDebug("LDB" + .." "..tostring(name).."" + .." "..tostring(call_success).."" + .." "..tostring(ret_val).."" + ) + end end - end ---[[ - if (event == "PLAYER_ENTERING_WORLD") then - self:UnregisterEvent("PLAYER_ENTERING_WORLD") + -- In case a LDB plugin is created later... + ldb.RegisterCallback(self, + "LibDataBroker_DataObjectCreated", "TitanLDBCreateObject") end ---]] end ) \ No newline at end of file diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index a98a186..875f604 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -352,7 +352,7 @@ local function TitanPanelButton_OnDragStart(self, ChildButton) -- Clear button positions or we'll grab the button and all buttons 'after' local i,j; for i, j in pairs(TitanPanelSettings.Buttons) do - local pluginid = _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; + local pluginid = _G[TitanUtils_ButtonName(TitanPanelSettings.Buttons[i])]; if pluginid then pluginid:ClearAllPoints() end @@ -440,7 +440,8 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) local i,j; for i, j in pairs(TitanPanelSettings.Buttons) do local pluginid = - _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; + _G[TitanUtils_ButtonName(TitanPanelSettings.Buttons[i])]; +-- _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; if (pluginid and MouseIsOver(pluginid)) and frname ~= pluginid then TITAN_PANEL_DROPOFF_ADDON = TitanPanelSettings.Buttons[i]; end @@ -566,12 +567,12 @@ function TitanPanelPluginHandle_OnUpdate(table, oldarg) -- Used by plugins if (updateType == TITAN_PANEL_UPDATE_TOOLTIP or updateType == TITAN_PANEL_UPDATE_ALL) - and MouseIsOver(_G["TitanPanel"..id.."Button"]) then + and MouseIsOver(_G[TitanUtils_ButtonName(id)]) then if TitanPanelRightClickMenu_IsVisible() or TITAN_PANEL_MOVING == 1 then return end - TitanPanelButton_SetTooltip(_G["TitanPanel"..id.."Button"], id) + TitanPanelButton_SetTooltip(_G[TitanUtils_ButtonName(id)], id) end end end @@ -585,7 +586,7 @@ VAR: isChildButton - boolean function TitanPanelDetectPluginMethod(id, isChildButton) -- Ensure the id is not nil if not id then return end - local TitanPluginframe = _G["TitanPanel"..id.."Button"]; + local TitanPluginframe = _G[TitanUtils_ButtonName(id)]; if isChildButton then TitanPluginframe = _G[id]; end diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 2154bff..ab589b2 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -2,23 +2,6 @@ NAME: TitanUtils.lua DESC: This file contains various utility routines used by Titan and routines available to plugin developers. --]] -TITAN_ID = "Titan" -TITAN_DEBUG_ARRAY_MAX = 100 -TITAN_PANEL_NONMOVABLE_PLUGINS = {}; -TITAN_PANEL_MENU_FUNC_HIDE = "TitanPanelRightClickMenu_Hide"; -TitanPlugins = {}; -- Used by plugins -TitanPluginsIndex = {}; -TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"].."Not_Registered_Yet".._G["FONT_COLOR_CODE_CLOSE"] -TITAN_REGISTERED = _G["GREEN_FONT_COLOR_CODE"].."Registered".._G["FONT_COLOR_CODE_CLOSE"] -TITAN_REGISTER_FAILED = _G["RED_FONT_COLOR_CODE"].."Failed_to_Register".._G["FONT_COLOR_CODE_CLOSE"] - --- For debug across Titan Panel -TITAN_PANEL_VARS = {} -TITAN_PANEL_VARS.debug = {} -TITAN_PANEL_VARS.debug.movable = false -TITAN_PANEL_VARS.debug.events = false -TITAN_PANEL_VARS.debug.ldb_setup = false -TITAN_PANEL_VARS.debug.tool_tips = false local _G = getfenv(0); local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -47,58 +30,26 @@ function TitanUtils_GetBarAnchors() -- Used by addons return TitanPanelTopAnchor, TitanPanelBottomAnchor end ---[[ API -NAME: TitanUtils_GetMinimapAdjust -DESC: Return the current setting of the Titan MinimapAdjust option. -VAR: None -OUT: The value of the MinimapAdjust option -NOTE: -- As of DragonFlight Titan Loc no longer adjusts or manipulates the minimap. ---]] -function TitanUtils_GetMinimapAdjust() -- Used by addons --- return not TitanPanelGetVar("MinimapAdjust") - return false -end - ---[[ API -NAME: TitanUtils_SetMinimapAdjust -DESC: Set the current setting of the Titan MinimapAdjust option. -VAR: bool - true (off) or false (on) -OUT: None -NOTE: -- As of DragonFlight Titan Loc no longer adjusts or manipulates the minimap. ---]] -function TitanUtils_SetMinimapAdjust(bool) -- Used by addons - -- This routine allows an addon to turn on or off - -- the Titan minimap adjust. --- TitanPanelSetVar("MinimapAdjust", not bool) -end - ---[[ API -NAME: TitanUtils_AddonAdjust -DESC: Tell Titan to adjust (or not) a frame. -VAR: frame - is the name (string) of the frame -VAR: bool - true if the addon will adjust the frame or false if Titan will adjust -OUT: None -Note: --- As of DragonFlight, this is no longer needed. The Titan user can user place - or not - a couple frames not user placeable, - -- Titan will NOT store the adjust value across a log out / exit. -- This is a generic way for an addon to tell Titan to not adjust a frame. The addon will take responsibility for adjusting that frame. This is useful for UI style addons so the user can run Titan and a modifed UI. -- The list of frames Titan adjusts is specified in TitanMovableData within TitanMovable.lua. -- If the frame name is not in TitanMovableData then Titan does not adjust that frame. -:NOTE ---]] -function TitanUtils_AddonAdjust(frame, bool) -- Used by addons --- TitanMovable_AddonAdjust(frame, bool) -end - -------------------------------------------------------------- -- -- Plugin button search & manipulation routines -- --[[ API NAME: TitanUtils_GetButton +DESC: Create thebutton name from plugin id. +VAR: id - is the id of the plugin +OUT: string - The button / frame name +--]] +function TitanUtils_ButtonName(id) + if (id) then + return TitanVars.plugin.PRE..id..TitanVars.plugin.POST + else + return nil + end +end + +--[[ API +NAME: TitanUtils_GetButton DESC: Return the actual button frame and the plugin id. VAR: id - is the id of the plugin OUT: frame - The button table @@ -106,7 +57,7 @@ OUT: string - The id of the plugin --]] function TitanUtils_GetButton(id) -- Used by plugins if (id) then - return _G["TitanPanel"..id.."Button"], id; + return _G[TitanVars.plugin.PRE..id..TitanVars.plugin.POST], id; else return nil, nil; end @@ -145,7 +96,7 @@ OUT: string - plugin id or nil --]] function TitanUtils_GetButtonID(name) if name then - local s, e, id = string.find(name, "TitanPanel(.*)Button"); + local s, e, id = string.find(name, TitanVars.plugin.PRE.."(.*)"..TitanVars.plugin.POST); return id; else return nil; @@ -1251,8 +1202,16 @@ end -------------------------------------------------------------- -- --- Frame check & manipulation routines +-- Control Frame check & manipulation routines -- +--[[ Titan Plugins +NAME: TitanUtils_CheckFrameCounting +DESC: Check the frame - expected to be a control / menu frame. Close if timer has expired. Used in plugin OnUpdate +VAR: +- frame - control / menu frame +- elapsed - portion of second since last OnUpdate +OUT: None +--]] function TitanUtils_CheckFrameCounting(frame, elapsed) if (frame:IsVisible()) then if (not frame.frameTimer or not frame.isCounting) then @@ -1267,15 +1226,36 @@ function TitanUtils_CheckFrameCounting(frame, elapsed) end end +--[[ Titan Plugins +NAME: TitanUtils_StartFrameCounting +DESC: Set the max time the control frame could be open once cursor has left frame. Used in plugin OnLeave +VAR: +- frame - control / menu frame +- frameShowTime - max time +OUT: None +--]] function TitanUtils_StartFrameCounting(frame, frameShowTime) frame.frameTimer = frameShowTime; frame.isCounting = 1; end +--[[ Titan Plugins +NAME: TitanUtils_StopFrameCounting +DESC: Remove timer flag once cursor has entered frame. Used in plugin OnEnter +VAR: +- frame - control / menu frame +OUT: None +--]] function TitanUtils_StopFrameCounting(frame) frame.isCounting = nil; end +--[[ Titan Plugins AND Titan +NAME: TitanUtils_CloseAllControlFrames +DESC: Remove all timer flags on plugin control frames. Used for plugin Shift+Left and within Titan +VAR: None +OUT: None +--]] function TitanUtils_CloseAllControlFrames() for index, value in pairs(TitanPlugins) do local frame = _G["TitanPanel"..index.."ControlFrame"]; @@ -1285,16 +1265,13 @@ function TitanUtils_CloseAllControlFrames() end end -function TitanUtils_IsAnyControlFrameVisible() -- need? - for index, value in TitanPlugins do - local frame = _G["TitanPanel"..index.."ControlFrame"]; - if (frame:IsVisible()) then - return true; - end - end - return false; -end - +--[[ Titan Plugins AND Titan +NAME: TitanUtils_GetOffscreen +DESC: Check where the control frame should be on screen; return x and y +VAR: None +OUT: float - x where frame should be +OUT: float - y where frame should be +--]] function TitanUtils_GetOffscreen(frame) local offscreenX, offscreenY; local ui_scale = UIParent:GetEffectiveScale() @@ -1331,6 +1308,32 @@ end -- Plugin registration routines -- --[[ Titan +NAME: TitanUtils_GetAddOnMetadata +DESC: Attempt to get meta data from the addon +VAR: +- name - string of addon name +- field - string of addon field to get +OUT: None +NOTE: +- As of May 2023 (10.1) the routine moved and no longer dies silently so it is wrapped here... +--]] +function TitanUtils_GetAddOnMetadata(name, field) + local call_success, ret_val + + -- Just in case, catch any errors + call_success, -- needed for pcall + ret_val = -- actual return values + pcall (C_AddOns.GetAddOnMetadata, name, field) + if call_success then + -- all is good + return ret_val + else + -- Some error.. for our use return nil + return nil + end +end + +--[[ Titan NAME: TitanUtils_PluginToRegister DESC: Place the plugin to be registered later by Titan VAR: @@ -1351,9 +1354,11 @@ function TitanUtils_PluginToRegister(self, isChildButton) TitanPluginToBeRegisteredNum = TitanPluginToBeRegisteredNum + 1 local cat = "" local notes = "" + local name = "" if self and self.registry then cat = (self.registry.category or "") notes = (self.registry.notes or "") + name = (self.registry.id or "") end -- Some of the fields in this record are displayed in the "Attempts" -- so they are defaulted here. @@ -1374,7 +1379,19 @@ function TitanUtils_PluginToRegister(self, isChildButton) --[[ For updated menu lib (Dec 2018) Old way was to use the XML file to declare the frame, now it needs to be in Lua --]] - local f = CreateFrame("Frame", self:GetName()..TITAN_PANEL_CLICK_MENU_SUFFIX, self or nil, "UIDropDownMenuTemplate") + local f = CreateFrame("Frame", + self:GetName()..TITAN_PANEL_CLICK_MENU_SUFFIX, + self or nil, + "UIDropDownMenuTemplate") + + -- Debug + if TitanVars.debug.plugin_register then + TitanDebug("Queue Plugin" +-- .." '"..tostring(self:GetName()).."'" + .." '"..tostring(TitanUtils_GetButtonID(self:GetName())).."'" + .." "..tostring(TITAN_NOT_REGISTERED).."" + ) + end end --[[ Titan @@ -1399,10 +1416,17 @@ function TitanUtils_PluginFail(plugin) isChild = (plugin.isChild and true or false), name = (plugin.name or "?"), issue = (plugin.issue or "?"), - status = TITAN_REGISTER_FAILED, + status = (plugin.status or "?"), category = (plugin.category or ""), plugin_type = (plugin.plugin_type or ""), } + + local message = "" + .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].status).."'" + .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].name).."'" + .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].category).."'" + .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].issue).."'" + TitanPrint(message, "error") end local function NoColor(name) @@ -1457,6 +1481,7 @@ local function TitanUtils_RegisterPluginProtected(plugin) local cat = "" local ptype = "" local notes = "" + local str = "" local self = plugin.self local isChildButton = (plugin.isChild and true or false) @@ -1482,7 +1507,10 @@ local function TitanUtils_RegisterPluginProtected(plugin) .."<Titan>.registry.id or <LDB>.label" else -- A sanity check just in case it was already in the list - if (not TitanUtils_TableContainsValue(TitanPluginsIndex, id)) then + if TitanUtils_TableContainsValue(TitanPluginsIndex, id) then + str = "In List ??" + else + str = "Save .registry" -- Herein lies any special per plugin variables Titan wishes to control -- These will be overwritten from saved vars, if any -- @@ -1540,6 +1568,7 @@ local function TitanUtils_RegisterPluginProtected(plugin) end end notes = (self.registry.notes or "") + else -- There could be a couple reasons the .registry was not found result = TITAN_REGISTER_FAILED @@ -1557,6 +1586,16 @@ local function TitanUtils_RegisterPluginProtected(plugin) issue = "Can not determine plugin button name" end + -- Debug + if TitanVars.debug.plugin_register then + TitanDebug("Plugin RegProt" +-- .." '"..tostring(self:GetName()).."'" + .." '"..tostring(id).."'" + .." '"..tostring(result).."'" + .." '"..tostring(str).."'" + .." '"..tostring(TitanPlugins[id].id).."'" + ) + end -- create and return the results local ret_val = {} ret_val.issue = (issue or "") @@ -1617,7 +1656,7 @@ function TitanUtils_RegisterPlugin(plugin) -- If there was an error tell the user. if not plugin.issue == "" or plugin.status ~= TITAN_REGISTERED then - TitanDebug(TitanUtils_GetRedText("Error Registering Plugin") + TitanPrint(TitanUtils_GetRedText("Error Registering Plugin") ..TitanUtils_GetGreenText( ": " .."name: '"..(plugin.name or "?_").."' " @@ -1626,6 +1665,20 @@ function TitanUtils_RegisterPlugin(plugin) ) ) end + + -- Debug + if TitanVars.debug.plugin_register then + local status = plugin.status + if plugin.status == TITAN_REGISTER_FAILED then + status = TitanUtils_GetRedText(status) + else + status = TitanUtils_GetGreenText(status) + end + TitanDebug("Registering Plugin" + .." "..tostring(plugin.name).."" + .." "..tostring(status).."" + ) + end end end @@ -1711,7 +1764,7 @@ local function TitanRightClickMenu_OnLoad(self) UIDropDownMenu_Initialize(self, prepareFunction, "MENU"); end else - if TITAN_PANEL_VARS.debug.tool_tips then + if TitanVars.debug.tool_tips then TitanDebug("Could not display tooltip. " .."Could not determine Titan ID for " .."'"..(self:GetName() or "?").."'. " @@ -2030,10 +2083,10 @@ OUT: --]] function TitanPrint(message, msg_type) local dtype = "" - local pre = TitanUtils_GetGoldText(L["TITAN_PRINT"]..": ".._G["FONT_COLOR_CODE_CLOSE"]) + local pre = TitanUtils_GetGoldText(L["TITAN_PRINT"]..": ") local msg = "" if msg_type == "error" then - dtype = TitanUtils_GetRedText("Error: ").._G["FONT_COLOR_CODE_CLOSE"] + dtype = TitanUtils_GetRedText("Error: ") elseif msg_type == "warning" then dtype = "|cFFFFFF00".."Warning: ".._G["FONT_COLOR_CODE_CLOSE"] elseif msg_type == "plain" then @@ -2195,6 +2248,61 @@ end -- Deprecated routines -- These routines will be commented out for a couple releases then deleted. -- ---[[ +--[===[ +--[[ API +NAME: TitanUtils_GetMinimapAdjust +DESC: Return the current setting of the Titan MinimapAdjust option. +VAR: None +OUT: The value of the MinimapAdjust option +NOTE: +- As of DragonFlight Titan Loc no longer adjusts or manipulates the minimap. +--]] +function TitanUtils_GetMinimapAdjust() -- Used by addons +-- return not TitanPanelGetVar("MinimapAdjust") + return false +end + +--[[ API +NAME: TitanUtils_SetMinimapAdjust +DESC: Set the current setting of the Titan MinimapAdjust option. +VAR: bool - true (off) or false (on) +OUT: None +NOTE: +- As of DragonFlight Titan Loc no longer adjusts or manipulates the minimap. +--]] +function TitanUtils_SetMinimapAdjust(bool) -- Used by addons + -- This routine allows an addon to turn on or off + -- the Titan minimap adjust. +-- TitanPanelSetVar("MinimapAdjust", not bool) +end + +--[[ API +NAME: TitanUtils_AddonAdjust +DESC: Tell Titan to adjust (or not) a frame. +VAR: frame - is the name (string) of the frame +VAR: bool - true if the addon will adjust the frame or false if Titan will adjust +OUT: None +Note: +-- As of DragonFlight, this is no longer needed. The Titan user can user place - or not - a couple frames not user placeable, +- Titan will NOT store the adjust value across a log out / exit. +- This is a generic way for an addon to tell Titan to not adjust a frame. The addon will take responsibility for adjusting that frame. This is useful for UI style addons so the user can run Titan and a modifed UI. +- The list of frames Titan adjusts is specified in TitanMovableData within TitanMovable.lua. +- If the frame name is not in TitanMovableData then Titan does not adjust that frame. +:NOTE --]] +function TitanUtils_AddonAdjust(frame, bool) -- Used by addons +-- TitanMovable_AddonAdjust(frame, bool) +end + +function TitanUtils_IsAnyControlFrameVisible() -- need? + for index, value in TitanPlugins do + local frame = _G["TitanPanel"..index.."ControlFrame"]; + if (frame:IsVisible()) then + return true; + end + end + return false; +end + +--]===] diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index bf787e6..8fc892d 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -33,87 +33,12 @@ local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local _G = getfenv(0); local media = LibStub("LibSharedMedia-3.0") --- Global variables -Titan__InitializedPEW = nil -Titan__Initialized_Settings = nil - -TITAN_AT = "@" - -TitanAll = nil; -TitanSettings = nil; -TitanPlayerSettings = nil -TitanPluginSettings = nil; -- Used by plugins -TitanPanelSettings = nil; - -TITAN_PANEL_UPDATE_BUTTON = 1; -TITAN_PANEL_UPDATE_TOOLTIP = 2; -TITAN_PANEL_UPDATE_ALL = 3; -TitanTooltipOrigScale = 1; -TitanTooltipScaleSet = 0; - --- Set Titan Version var for backwards compatibility -TITAN_VERSION = GetAddOnMetadata(TITAN_ID, "Version") or L["TITAN_NA"] - --- Various constants -TITAN_PANEL_PLACE_TOP = 1; -TITAN_PANEL_PLACE_BOTTOM = 2; -TITAN_PANEL_PLACE_BOTH = 3; -TITAN_PANEL_MOVING = 0; - -TITAN_WOW_SCREEN_TOP = 768 -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; -TITAN_PANEL_BUTTONS_ALIGN_CENTER = 2; - -TITAN_PANEL_CONTROL = "TitanPanelBarButton" --- New bar vars -TITAN_PANEL_BAR_HEIGHT = 24 -TITAN_PANEL_BAR_TEXTURE_HEIGHT = 30 -TITAN_PANEL_AUTOHIDE_PREFIX = "TitanPanelAutoHide_" -TITAN_PANEL_AUTOHIDE_SUFFIX = "Button" -TITAN_PANEL_HIDE_PREFIX = "Titan_Bar__Hider_" -TITAN_PANEL_DISPLAY_PREFIX = "Titan_Bar__Display_" -TITAN_PANEL_DISPLAY_MENU = "Menu_" -TITAN_PANEL_BACKGROUND_PREFIX = "TitanPanelBackground_" -TITAN_PANEL_CLICK_MENU_SUFFIX = "RightClickMenu" -TITAN_PANEL_TEXT = "Text" -TITAN_PANEL_TEXTURE_VAR = "Texture" -TITAN_PANEL_BUTTON_TEXT = "Button"..TITAN_PANEL_TEXT -TITAN_PANEL_CONSTANTS = { - FONT_SIZE = 10, - FONT_NAME = "Friz Quadrata TT" -} if (GetLocale() == "ruRU") then -- Special fix for Russian - "Friz Quadrata TT" does not seem to work TITAN_PANEL_CONSTANTS.FONT_NAME = "Arial Narrow" end local TPC = TITAN_PANEL_CONSTANTS -- shortcut -TITAN_CUSTOM_PROFILE_POSTFIX = "TitanCustomProfile" -TITAN_PROFILE_NONE = "<>" -TITAN_PROFILE_RESET = "<RESET>" -TITAN_PROFILE_USE = "<USE>" -TITAN_PROFILE_INIT = "<INIT>" - -AUTOHIDE_PREFIX = "TitanPanelAutoHide_" -AUTOHIDE_SUFFIX = "Button" - -TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = - {"Built-ins","General","Combat","Information","Interface","Profession"} -TitanVars = {} -- begin the slow journey to a smaller _G footprint -TitanVars.scaling = 0 -- store the 'old' scaling to react on initial start or when it changes. -TitanVars.scaling_ui = 0 -- store the 'old' scaling to react on initial start or when it changes. -TitanVars.SKIN = "skin" -TitanVars.COLOR = "color" -TitanVars.NONE = "none" - --[[ Titan NAME: Titan bar overview DESC: @@ -814,30 +739,53 @@ local function Set_Timers(reset) end --[[ Titan +NAME: TitanVariables_SyncSinglePluginSettings +DESC: Routine to sync one plugin - current loaded (lua file) to its plugin saved vars (last save to disk). +VAR: id : plugin name +OUT: None +--]] +function TitanVariables_SyncSinglePluginSettings(id) + -- Init this plugin +print("Sync1" +.." "..tostring(id).."" +) + local plugin = TitanPlugins[id] + if (plugin and plugin.savedVariables) then + -- Init savedVariables table + if TitanPluginSettings then + -- exists + else + TitanPluginSettings = {}; +print(">>Sync1 void settings" +.." "..tostring(id).."" +) + end + if TitanPluginSettings[id] then + -- exists + else + TitanPluginSettings[id] = {}; +print(">>Sync1 new settings" +.." "..tostring(id).."" +) + end + + -- Synchronize registered and saved variables + TitanVariables_SyncRegisterSavedVariables( + plugin.savedVariables, TitanPluginSettings[id]); + end +end + +--[[ Titan NAME: TitanVariables_SyncPluginSettings DESC: Routine to sync plugin datas - current loaded (lua file) to any plugin saved vars (last save to disk). VAR: None OUT: None --]] function TitanVariables_SyncPluginSettings() -- one plugin uses this - -- Init each and every plugin for id, plugin in pairs(TitanPlugins) do if (plugin and plugin.savedVariables) then - -- Init savedVariables table - if TitanPluginSettings then - -- exists - else - TitanPluginSettings = {}; - end - if TitanPluginSettings[id] then - -- exists - else - TitanPluginSettings[id] = {}; - end - - -- Synchronize registered and saved variables - TitanVariables_SyncRegisterSavedVariables( - plugin.savedVariables, TitanPluginSettings[id]); + -- Init / sync every plugin + TitanVariables_SyncSinglePluginSettings(id) else -- Remove plugin savedVariables table if there's one if (TitanPluginSettings[id]) then @@ -879,80 +827,6 @@ function TitanVariables_InitTitanSettings() end end ---[===[ - if TitanSettings.Players[player] then - -- all is good - else - -- Create the bare player tables so profile(s) can be added - if trace then - TitanDebug("TitanSettings.Players[] {}") - end - TitanSettings.Players[player] = {} - 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"] = {} - TitanPlayerSettings["BarVars"] = TitanBarVarsDefaults -- New Mar 2023 - - new_toon = true - end - -- New Mar 2023 : TitanSettings.Players[player].BarData to hold Short bar data - if TitanSettings.Players[player].BarVars then - -- All good - else - -- Set to defaults - TitanSettings.Players[player].BarVars = TitanBarVarsDefaults - local BV = TitanSettings.Players[player].BarVars - - local panel = TitanSettings.Players[player].Panel - - -- Set the original (full width) Titan bars to the current user settings. - -- If this is a new toon or news saved vars then it will just get the original defaults. - for idx, v in pairs (TitanBarData) do - if v.user_move == false then -print("orig defs" -.." "..tostring(idx).."" -.." "..tostring(v.name).."" -) - -- Set original Bar options from the 'old' saved vars location - BV[idx].show = panel[v.name.."_Show"] - BV[idx].auto_hide = panel[v.name.."_Hide"] - BV[idx].align = panel[v.name.."_Align"] - -- only skins before 7.x - BV[idx].texure = TitanVars.SKIN - BV[idx].skin.alpha = panel[v.name.."_Transparency"] - BV[idx].skin.path = panel["TexturePath"] -print(">_Show" -.." "..tostring(panel[v.name.."_Show"]).."" -.." > "..tostring(BV[idx].show).."" -) -print(">orig defs" -.." "..tostring(BV[idx].auto_hide).."" -.." "..tostring(BV[idx].align).."" -.." "..tostring(BV[idx].skin.alpha).."" -.." "..tostring(panel["TexturePath"]).."" -.." > "..tostring(BV[idx].skin.path).."" -) - end - end - - if trace then - TitanDebug("TitanSettings.Players[].BarVars Default") - end - end - - -- Set global variables - TitanPlayerSettings = TitanSettings.Players[player] - TitanPluginSettings = TitanPlayerSettings["Plugins"] - TitanPanelSettings = TitanPlayerSettings["Panel"] - TitanBarPositions = TitanPlayerSettings["BarData"] - TitanBarDataVars = TitanPlayerSettings["BarVars"] ---]===] - if (TitanAll) then -- All good else diff --git a/TitanBag/TitanBag.toc b/TitanBag/TitanBag.toc index 9fa5170..46208ad 100644 --- a/TitanBag/TitanBag.toc +++ b/TitanBag/TitanBag.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanBag.lua diff --git a/TitanClock/TitanClock.toc b/TitanClock/TitanClock.toc index f531c41..3e18ccb 100644 --- a/TitanClock/TitanClock.toc +++ b/TitanClock/TitanClock.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa007.00.03.100100|r ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanClock.lua diff --git a/TitanGold/TitanGold.toc b/TitanGold/TitanGold.toc index 5c8475e..1a0c4cc 100644 --- a/TitanGold/TitanGold.toc +++ b/TitanGold/TitanGold.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanGold.lua diff --git a/TitanLocation/TitanLocation.toc b/TitanLocation/TitanLocation.toc index 5151ade..92c90ba 100644 --- a/TitanLocation/TitanLocation.toc +++ b/TitanLocation/TitanLocation.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa007.00.03.100100|r ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanLocation.lua diff --git a/TitanLootType/TitanLootType.toc b/TitanLootType/TitanLootType.toc index fb294dd..9445e7d 100644 --- a/TitanLootType/TitanLootType.toc +++ b/TitanLootType/TitanLootType.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanLootType.lua diff --git a/TitanPerformance/TitanPerformance.toc b/TitanPerformance/TitanPerformance.toc index aede5b2..b923cca 100644 --- a/TitanPerformance/TitanPerformance.toc +++ b/TitanPerformance/TitanPerformance.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanPerformance.lua diff --git a/TitanRepair/TitanRepair.toc b/TitanRepair/TitanRepair.toc index a2b564f..7f1cf07 100644 --- a/TitanRepair/TitanRepair.toc +++ b/TitanRepair/TitanRepair.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa007.00.03.100100|r ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: ## OptionalDeps: ## Dependencies: Titan -## Version: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanRepair.lua diff --git a/TitanVolume/TitanVolume.toc b/TitanVolume/TitanVolume.toc index 87699b8..a983405 100644 --- a/TitanVolume/TitanVolume.toc +++ b/TitanVolume/TitanVolume.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanVolume.lua diff --git a/TitanXP/TitanXP.toc b/TitanXP/TitanXP.toc index ae593be..3a3f504 100644 --- a/TitanXP/TitanXP.toc +++ b/TitanXP/TitanXP.toc @@ -1,10 +1,10 @@ -## Interface: 100007 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa007.00.02.100007|r +## Interface: 100100 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa007.00.03.100100|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: 7.00.02.100007 +## Version: 7.00.03.100100 ## X-Child-Of: Titan TitanXP.lua