diff --git a/Titan/Titan.toc b/Titan/Titan.toc index fae1a0d..151544f 100644 --- a/Titan/Titan.toc +++ b/Titan/Titan.toc @@ -1,7 +1,7 @@ ## Interface: 100007 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa006.00.13.100007|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa006.00.11.100007|r ## Author: Titan Panel Development Team -## Version: 6.00.13.100007 +## Version: 7.00.01.100007 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds a display bar on the top and/or bottom of the screen. Allows users to show and control information/launcher plugins. diff --git a/Titan/TitanAutoHide.lua b/Titan/TitanAutoHide.lua index 1248fe2..4d3c7c4 100644 --- a/Titan/TitanAutoHide.lua +++ b/Titan/TitanAutoHide.lua @@ -29,7 +29,8 @@ local function Titan_AutoHide_SetIcon(self) -- Get the icon of the icon template local icon = _G[frame.."Icon"] - if (TitanPanelGetVar(bar.."_Hide")) then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..bar].auto_hide then +-- if (TitanPanelGetVar(bar.."_Hide")) then icon:SetTexture("Interface\\AddOns\\Titan\\Artwork\\TitanPanelPushpinOut") else icon:SetTexture("Interface\\AddOns\\Titan\\Artwork\\TitanPanelPushpinIn") @@ -96,7 +97,7 @@ function Titan_AutoHide_Timers(frame, action) return end local bar = TitanBarData[frame].name --(frame.bar_name or nil) - local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) + local hide = TitanBarDataVars[frame].auto_hide -- (bar and TitanPanelGetVar(bar.."_Hide") or nil) if bar and hide then if (action == "Enter") then @@ -120,9 +121,10 @@ function Titan_AutoHide_Init(frame) local bar = TitanBarData[frame].name -- Make sure the bar should be processed - if (TitanPanelGetVar(bar.."_Show")) then + if TitanBarDataVars[frame].show then --if (TitanPanelGetVar(bar.."_Show")) then -- Hide / show the bar - if (TitanPanelGetVar(bar.."_Hide")) then + if TitanBarDataVars[frame].auto_hide then +-- if (TitanPanelGetVar(bar.."_Hide")) then TitanPanelBarButton_Hide(frame); else TitanPanelBarButton_Show(frame); @@ -148,7 +150,8 @@ OUT: None --]] function Titan_AutoHide_ToggleAutoHide(bar) -- toggle the correct auto hide variable - TitanPanelToggleVar(bar.."_Hide") + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..bar].auto_hide = + not TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..bar].auto_hide --TitanPanelToggleVar(bar.."_Hide") -- Hide / show the requested Titan bar Titan_AutoHide_Init(TITAN_PANEL_DISPLAY_PREFIX..bar) end @@ -170,9 +173,9 @@ function Handle_OnUpdateAutoHide(frame) if not data then -- sanity check return end - local bar = (data.name or nil) +-- local bar = (data.name or nil) - local hide = TitanPanelGetVar(bar.."_Hide") + local hide = TitanBarDataVars[frame].auto_hide -- TitanPanelGetVar(bar.."_Hide") -- if hide then AceTimer.CancelAllTimers(frame) diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 031428d..30b62f5 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -33,19 +33,20 @@ local notes = "" .."- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" ) local changes = "" -do -- changes var set +do -- recent change history changes = changes ..TitanUtils_GetGoldText("7.00.00.100007 : 2023/03/31\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" - ..TitanUtils_GetRedText("- NOTE : Downgrading from 7.xx to 6.xx *will require* wiping the Titan saved variables file.\n") - .."- NEW : Configuration > Titan Bar Help has details on bars.\n" .."- NEW : 10 Short bars! See new Configuration > Titan Bar Help for enabling and using.\n" + .."- NEW : 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 : Global Skin is now selectable in Config. \n" - .."- NEW : Hide in Combat is now selectable in Config.\n" - .."- Configuration > Bars has a consolidated config for all Titan bars.\n" + .."- 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 enhacned color picker for more options.\n" + .."- NOTE : Downgrading from 7.xx to 6.xx bars wil appear as they were. You may need to hide / show plugins.\n" + .."- Configuration > Bars has a new consolidated config for all Titan bars.\n" .."- Configuration > Transparency moved into Bars.\n" + .."- Configuration > Titan Bar Help has details on 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" @@ -155,8 +156,10 @@ VAR: scale - the scale the user has selected for Titan OUT: None --]] local function TitanAdjustPanelScale(scale) +-- TitanPanel_InitPanelBarButton("Config scale change "..scale) +-- TitanPanelBarButton_DisplayBarsWanted("Config scale change "..scale) TitanPanel_SetScale() - TitanPanel_AdjustFrames(true, "AdjustPanelScale") +-- TitanPanel_AdjustFrames(true, "AdjustPanelScale") end -- helper functions @@ -646,10 +649,20 @@ 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 = 10, type = "range", width = "full", + order = 21, type = "range", width = "full", min = 0.5, max = 1.3, step = 0.01, get = function() return TitanPanelGetVar("TooltipFont") end, set = function(_, a) @@ -659,16 +672,21 @@ local optionsUIScale = { tooltipfontdisable = { name = L["TITAN_UISCALE_TOOLTIP_DISABLE_TEXT"], desc = L["TITAN_UISCALE_DISABLE_TOOLTIP_DESC"], - order = 11, type = "toggle", width = "full", + order = 22, 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 = 12, type = "select", + order = 31, type = "select", width = "40", dialogControl = "LSM30_Font", get = function() return TitanPanelGetVar("FontName") @@ -679,10 +697,14 @@ 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 = 13, type = "range", + order = 33, type = "range", width = "40", min = 7, max = 15, step = 1, get = function() return TitanPanelGetVar("FontSize") end, set = function(_, v) @@ -690,10 +712,15 @@ 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 = 14, type = "select", + order = 41, type = "select", get = function() return TitanPanelGetVar("FrameStrata") end, @@ -738,7 +765,8 @@ local optionsBars = { local function ColorShown(bar) local res = (bar.locale_name or "?") - if TitanPanelGetVar(bar.name.."_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..bar.name].show then +--- if TitanPanelGetVar(bar.name.."_Show") then -- leave as is else res = "|cff808080"..res.._G["FONT_COLOR_CODE_CLOSE"] @@ -772,8 +800,9 @@ local function TitanUpdateConfigBars(t, pos) wipe(args) for idx = 1, #bar_list do - local v = bar_list[idx] -- process this bar + -- ====== -- Build the bar list in order (left side) + local v = bar_list[idx] -- process this bar position = position + 1 args[v.name] = { type = "group", @@ -784,81 +813,148 @@ local function TitanUpdateConfigBars(t, pos) -- Build bar options (right side) args[v.name].args = {} position = position + 1 -- Title divider - args[v.name].args.title = { - type = "header", - name = v.locale_name, - order = position, width = "full", + args[v.name].args.title = { + 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_DISPLAY_BAR"], + order = position, + get = function(info) return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].show --(TitanPanelGetVar(v.name.."_Show")) + end, + set = function(info, val) +-- TitanPanelToggleVar(v.name.."_Show") +-- TitanPanelBarButton_DisplayBarsWanted(v.name.."_Show "..tostring(TitanPanelGetVar(v.name.."_Show"))) + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].show = not TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].show + TitanPanelBarButton_DisplayBarsWanted(v.name.."Show "..tostring(val)) + TitanUpdateConfigBars(optionsBars.args, 1000) + end, } - position = position + 1 -- Show toggle - args[v.name].args.show = { - type = "toggle", width = .75, --"fill", - name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], - order = position, - get = function(info) return (TitanPanelGetVar(v.name.."_Show")) end, - set = function(info, val) - TitanPanelToggleVar(v.name.."_Show") - TitanPanelBarButton_DisplayBarsWanted(v.name.."_Show "..tostring(TitanPanelGetVar(v.name.."_Show"))) + position = position + 1 -- Auto hide toggle + args[v.name].args.autohide = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_AUTOHIDE"], + order = position, + disabled = (v.hider == nil), + get = function(info) return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].auto_hide --(TitanPanelGetVar(v.name.."_Hide")) + end, + set = function(info, val) + Titan_AutoHide_ToggleAutoHide(v.name) -- short bar name + end, + } + position = position + 1 -- Center toggle + args[v.name].args.center = { + type = "toggle", width = .75, --"fill", + name = L["TITAN_PANEL_MENU_CENTER_TEXT"], + order = position, + get = function() +-- return (TitanPanelGetVar(v.name.."_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) + return (TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER) + end, + set = function() + if (TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].align = TITAN_PANEL_BUTTONS_ALIGN_LEFT + else + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].align = TITAN_PANEL_BUTTONS_ALIGN_CENTER + end - TitanUpdateConfigBars(optionsBars.args, 1000) - end, - } - position = position + 1 -- Auto hide toggle - args[v.name].args.autohide = { - type = "toggle", width = .75, --"fill", - name = L["TITAN_PANEL_MENU_AUTOHIDE"], - order = position, - disabled = (v.hider == nil), - get = function(info) return (TitanPanelGetVar(v.name.."_Hide")) end, - set = function(info, val) - Titan_AutoHide_ToggleAutoHide(v.name) -- short bar name - end, - } - position = position + 1 -- Center toggle - args[v.name].args.center = { - type = "toggle", width = .75, --"fill", - name = L["TITAN_PANEL_MENU_CENTER_TEXT"], - order = position, - get = function() - return (TitanPanelGetVar(v.name.."_Align") == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, - set = function() - TitanPanelBarButton_ToggleAlign(v.name.."_Align"); - 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"], + -- Justify button position + TitanPanelButton_Justify(); + --TitanPanelBarButton_ToggleAlign(v.name.."_Align"); + 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() + return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].hide_in_combat +-- return TitanPanelGetVar(v.name.."_HideInCombat") + end, + set = function() + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].hide_in_combat = + not TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].hide_in_combat +-- TitanPanelToggleVar(v.name.."_HideInCombat") + 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) + TitanVariables_SetBarPos(_G[TITAN_PANEL_DISPLAY_PREFIX..v.name], true) + TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - "..tostring(v.name)) + end, + } + -- ====== + -- Background group + position = position + 1 -- background + args[v.name].args.back = { + type = "header", + name = "=== "..BACKGROUND.." ===", order = position, - get = function() - return TitanPanelGetVar(v.name.."_HideInCombat") - end, - set = function() - TitanPanelToggleVar(v.name.."_HideInCombat") - end, - } - position = position + 1 -- spacer - args[v.name].args.barspacer1 = { - order = position, type = "description", width = "full", - name = " ", - } + } + 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() return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].texure end, + set = function(_, val) + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].texure = val + TitanPanel_SetBarTexture(TITAN_PANEL_DISPLAY_PREFIX..v.name) + end, + values = { + [TitanVars.SKIN] = L["TITAN_SKINS_TITLE"], + [TitanVars.COLOR] = COLOR, + }, + } + position = position + 1 -- Title divider + args[v.name].args.skintitle = { + 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() return TitanPanelGetVar("Texture"..v.name) end, + get = function() + return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].skin.path + -- return TitanPanelGetVar("Texture"..v.name) + end, set = function(_,val) - TitanPanelSetVar("Texture"..v.name, val); - TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..v.name) + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].skin.path = val + -- TitanPanelSetVar("Texture"..v.name, val); + TitanPanel_SetBarTexture(TITAN_PANEL_DISPLAY_PREFIX..v.name) if TitanSkinToRemove == TitanPanelGetVar("Texture"..v.name) then + -- if TitanSkinToRemove == TitanPanelGetVar("Texture"..v.name) then TitanSkinToRemove = "None" end end, values = function() local Skinlist = {} for _,val in pairs (TitanSkins) do - if val.path ~= TitanPanelGetVar("Texture"..v.name) then + if val.path ~= TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].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" @@ -871,13 +967,11 @@ local function TitanUpdateConfigBars(t, pos) return Skinlist end, } ----[[ position = position + 1 -- spacer args[v.name].args.skinspacer = { order = position, type = "description", width = "5", name = " ", - } ---]] + } position = position + 1 -- selected skin args[v.name].args.skinselected = { name = "", @@ -888,16 +982,11 @@ local function TitanUpdateConfigBars(t, pos) else -- Use it as is end - return TitanPanelGetVar("Texture"..v.name).."TitanPanelBackground"..vert.."0" + return TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].skin.path.."TitanPanelBackground"..vert.."0" end, imageWidth = 256, order = position, type = "description", width = .5, --"60", } - position = position + 1 -- spacer - args[v.name].args.transpacer1 = { - order = position, type = "description", width = "full", - name = " ", - } position = position + 1 -- transparency args[v.name].args.trans = { type = "range", width = "full", @@ -905,28 +994,65 @@ local function TitanUpdateConfigBars(t, pos) order = position, min = 0, max = 1, step = 0.01, get = function(info) --- local bar = TitanBarData[info[1]].name - return TitanPanelGetVar(v.name.."_Transparency") + -- local bar = TitanBarData[info[1]].name + -- return TitanPanelGetVar(v.name.."_Transparency") + local bar = TITAN_PANEL_DISPLAY_PREFIX..info[1] + return TitanBarDataVars[bar].skin.alpha end, set = function(info, a) local bar = TITAN_PANEL_DISPLAY_PREFIX..info[1] _G[bar]:SetAlpha(a) - TitanPanelSetVar(info[1].."_Transparency", a); + TitanBarDataVars[bar].skin.alpha = a + -- TitanPanelSetVar(info[1].."_Transparency", a); 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.resetposspacer = { + args[v.name].args.colorspacer = { 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"], + 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), - func = function(info, arg1) - TitanVariables_SetBarPos(_G[TITAN_PANEL_DISPLAY_PREFIX..v.name], true) + -- disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), + hasAlpha = true, + get = function() + local color = TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].color +--[===[ +print("Color:" +.." "..tostring(format("%0.1f", color.r)).."" +.." "..tostring(format("%0.1f", color.g)).."" +.." "..tostring(format("%0.1f", color.b)).."" +.." "..tostring(format("%0.1f", color.alpha)).."" +) +--]===] + 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[TITAN_PANEL_DISPLAY_PREFIX..v.name].color.r = r + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].color.g = g + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].color.b = b + TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..v.name].color.alpha = a + TitanPanel_SetBarTexture(TITAN_PANEL_DISPLAY_PREFIX..v.name) end, } end @@ -951,25 +1077,25 @@ help_text = "" .."Short bars are 10 shorter Titan bars that the user can place and change width.\n" .."- Short bars are independent. They may be used with or without the full width Titan bars.\n" .."- Enable and change options using Configuration > Bars.\n" - .."- The position is the top center under the full width bars. They will be stacked to not overlap.\n" + .."- The default position is the top center under the full width bars. They will be stacked to not overlap.\n" .."- Move : Use Alt + left mouse and dragging.\n" .."- Change width : Use Alt + mouse wheel.\n" .."- When moving or changing, best to place your mouse over the left side padding before moving or changing width.\n" + .."- 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 reset it to original position and width.\n" .."- Min width : Left side padding plus one icon width.\n" .."- Max width : Screen width.\n" - .."- Skin : Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" ) .."\n\n" ..TitanUtils_GetGreenText("All Bars: \n") ..TitanUtils_GetHighlightText("" .."- Hide any Titan bar by right click on the Titan bar (not a plugin) then click Hide.\n" .."- Skins : \n" - .."--- Can select per Titan bar.\n" - .."--- Can select a skin for all Titan bars. This does NOT change the individual Titan bar skin settings.\n" + .."--- 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" - .."--- Can select per Titan bar.\n" - .."--- Can hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" + .."--- Select per Titan bar.\n" + .."--- Hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" .."- NOTE : Right click menu shows the name of the bar in the title to enable finding the correct configuration options.\n" ) .."\n\n" @@ -1170,6 +1296,7 @@ local optionsGlobals = { 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"], @@ -1177,23 +1304,53 @@ local optionsGlobals = { get = function() return TitanPanelGetVar("UseGlobalTexture") end, set = function() TitanPanelToggleVar("UseGlobalTexture"); for idx, v in pairs (TitanBarData) do - TitanPanel_SetTexture(idx) + TitanPanel_SetBarTexture(idx) +-- TitanPanel_SetTexture(idx) end end, }, +--]===] + 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 = 20, type = "select", width = "30", + order = 21, type = "select", width = "30", name = " ", --L["TITAN_SKINS_LIST_TITLE"], desc = L["TITAN_SKINS_SET_DESC"], - get = function() return TitanPanelGetVar("TexturePath") end, + get = function() return TitanBarDataVars["Global"].skin.path end, set = function(_,v) - TitanPanelSetVar("TexturePath", 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 ~= TitanPanelGetVar("TexturePath") then + 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" @@ -1215,13 +1372,68 @@ local optionsGlobals = { type = "description", name = "", image = function() - return TitanPanelGetVar("TexturePath").."TitanPanelBackgroundTop0" + 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 +--[===[ +print("Color:" +.." "..tostring(format("%0.1f", color.r)).."" +.." "..tostring(format("%0.1f", color.g)).."" +.." "..tostring(format("%0.1f", color.b)).."" +.." "..tostring(format("%0.1f", color.alpha)).."" +) +--]===] + 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 = 100, width = "full", + order = 101, width = "full", type = "header", name = L["TITAN_PANEL_MENU_COMMAND"], }, @@ -1887,7 +2099,8 @@ local function TitanUpdateConfigAddons() local Locationlist = {} local v for idx,v in pairs (TitanBarData) do - if TitanPanelGetVar(TitanBarData[idx].name.."_Show") then + if TitanBarDataVars[idx].show then +-- if TitanPanelGetVar(TitanBarData[idx].name.."_Show") then Locationlist[TitanBarData[idx].name] = TitanBarData[idx].locale_name end end diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index a3147c1..fbccb3a 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -32,17 +32,22 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons local barnum_top = 0 local barnum_bot = 0 -- If user has the top set then determine the top offset - if TitanPanelGetVar("Bar_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar"].show then +-- if TitanPanelGetVar("Bar_Show") then barnum_top = 1 end - if TitanPanelGetVar("Bar2_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar2"].show then +-- if TitanPanelGetVar("Bar2_Show") then barnum_top = 2 end -- If user has the bottom set then determine the bottom offset - if TitanPanelGetVar("AuxBar_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"].show then +-- if TitanPanelGetVar("AuxBar_Show") then barnum_bot = 1 end - if TitanPanelGetVar("AuxBar2_Show") then + + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"].show then +-- if TitanPanelGetVar("AuxBar2_Show") then barnum_bot = 2 end diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua index 1a8f481..b69a18b 100644 --- a/Titan/TitanPanel.lua +++ b/Titan/TitanPanel.lua @@ -331,10 +331,9 @@ function TitanPanel_PlayerEnteringWorld() -- Ensure the bars are created before the plugins are registered. for idx, v in pairs (TitanBarData) do - -- Not create frames but set up scripts plus --- TitanPanel_CreateABar(idx) TitanPanelButton_CreateBar(idx) end +-- TitanPanel_InitPanelBarButton() Titan_AutoHide_Create_Frames() local realmName = GetRealmName() @@ -447,23 +446,6 @@ function TitanPanelBarButton:ADDON_LOADED(addon) -- Cannot seem to move the 'top' part of the frame. _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_ENABLED"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_DISABLED"); ---[===[ - -- Get Profile and Saved Vars - new_toon = TitanVariables_InitTitanSettings(); --- local VERSION = TitanPanel_GetVersion(); --- local POS = strfind(VERSION," - "); --- VERSION = strsub(VERSION,1,POS-1); - if not TitanAllGetVar("Silenced") then - TitanPrint("", "header") - end - - if not ServerTimeOffsets then - ServerTimeOffsets = {}; - end - if not ServerHourFormat then - ServerHourFormat = {}; - end ---]===] else -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. @@ -480,10 +462,16 @@ function TitanPanelBarButton:ADDON_LOADED(addon) end end -function TitanPanelBarButton:PLAYER_ENTERING_WORLD() +function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2) local call_success = nil local ret_val = nil +--[[ +print("PLAYER_ENTERING_WORLD" +.." "..tostring(arg1).."" +.." "..tostring(arg2).."" +) +--]] call_success, -- needed for pcall ret_val = -- actual return values pcall (TitanPanel_PlayerEnteringWorld) @@ -551,8 +539,9 @@ end -- function TitanPanelBarButton:PLAYER_REGEN_ENABLED() for idx,v in pairs (TitanBarData) do - if TitanPanelGetVar(v.name.."_Show") then - if TitanPanelGetVar(v.name.."_HideInCombat") + if TitanBarDataVars[idx].show then +-- if TitanPanelGetVar(v.name.."_Show") then + if TitanBarDataVars[idx].hide_in_combat -- TitanPanelGetVar(v.name.."_HideInCombat") or TitanPanelGetVar("UseGlobal_HideInCombat") then TitanPanelBarButton_Show(idx) end @@ -562,8 +551,9 @@ end function TitanPanelBarButton:PLAYER_REGEN_DISABLED() for idx,v in pairs (TitanBarData) do - if TitanPanelGetVar(v.name.."_Show") then - if TitanPanelGetVar(v.name.."_HideInCombat") + if TitanBarDataVars[idx].show then +-- if TitanPanelGetVar(v.name.."_Show") then + if TitanBarDataVars[idx].hide_in_combat -- TitanPanelGetVar(v.name.."_HideInCombat") or TitanPanelGetVar("UseGlobal_HideInCombat") then TitanPanelBarButton_Hide(idx) end @@ -907,145 +897,140 @@ SLASH_TitanPanel2 = "/titan"; -------------------------------------------------------------- -- -- Texture routines -local function CalcNumTextures() -end +local function Set_Color(frame, tex, color) ---[[ Titan -NAME: TitanPanel_ClearAllBarTextures -DESC: Clear the current texture from all Titan bars. -VAR: None -OUT: None +--[[ +print("_Set bar color" +.." "..tostring(TitanBarData[frame].tex_name).."" +--.." "..tostring(tex:GetName()).."" +.." "..tostring(format("%0.1f", color.r)).."" +.." "..tostring(format("%0.1f", color.g)).."" +.." "..tostring(format("%0.1f", color.b)).."" +.." "..tostring(format("%0.1f", color.alpha)).."" +) +--]] + _G[frame]:SetBackdrop({ + bgFile="Interface\\Tooltips\\UI-Tooltip-Background", +-- edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", +-- edgeFile="Interface\\DialogFrame\\UI-DialogBox-Gold-Border", + edgeFile="Interface\\Glues\\Common\\TextPanel-Border", + tile = true, + tileEdge = true, +-- insets = { left = 1, right = 1, top = 1, bottom = 1 }, + tileSize = 8, + edgeSize = 8, + }) + + _G[frame]:SetBackdropBorderColor( + TOOLTIP_DEFAULT_COLOR.r, + TOOLTIP_DEFAULT_COLOR.g, + TOOLTIP_DEFAULT_COLOR.b); + _G[frame]:SetBackdropColor( + color.r, + color.g, + color.b, + color.alpha); +--[[ + -- Apply the texture to the bar, using the system repeat to fill it + tex:SetColorTexture( + color.r, + color.g, + color.b, + color.alpha + ) + tex:SetAllPoints() + tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true + tex:SetVertTile(true) -- ensures image is 'full' height of frame --]] -function TitanPanel_ClearAllBarTextures() - -- Clear textures if they already exist - local tex = "" - for idx,v in pairs (TitanBarData) do - for i = 0, _G[idx].numOfTextures do - tex = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i - if _G[tex] then - _G[tex]:SetTexture() - end - end - end end ---[[ Titan -NAME: TitanPanel_CreateBarTextures -DESC: Create empty texture frames for all Titan bars. -VAR: None -OUT: None ---]] -function TitanPanel_CreateBarTextures() - -- Create the basic Titan bars (textures) - local i, titanTexture - local texture_path = TitanPanelGetVar("TexturePath") - local bar_name - local bar_width - local lastTextureWidth - local tex, tex_pre - - -- loop through the bars to set the texture - for idx,v in pairs (TitanBarData) do - bar_name = TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name - bar_width = ((_G[bar_name]:GetWidth() or GetScreenWidth()) + 1 ) --/ 2 - - local numOfTextures = floor(bar_width / 256 ) --- local numOfTexturesHider = (numOfTextures * 2) + 1 - lastTextureWidth = bar_width - (numOfTextures * 256) - if lastTextureWidth > 0 then - numOfTextures = numOfTextures --+ 1 -- to clear / remove the partial - else - -- exact length, somehow :) - end - _G[bar_name].numOfTextures = numOfTextures -- not all bars are equal width... +local function Set_Skin(frame, tex, skin) + -- Use the texture / skin per user selectable options + -- skins are in two parts - top & bottom... + -- TODO : have Short bars choose top or bottom skin?? + local edge = "" + if TitanBarData[frame].vert == TITAN_BOTTOM + then + edge = TITAN_BOTTOM + else + edge = TITAN_TOP + end + + -- Apply the texture to the bar, using the system repeat to fill it + local texture_file = skin.path.."TitanPanelBackground"..edge.."0" --[[ -print("Create tex" -.." "..tostring(TitanBarData[idx].name).."" -.." "..tostring(bar_width).."" -.." "..tostring(floor(bar_width / 256 )).."" -.." "..tostring(numOfTextures).."" +print("_Skin" +.." "..tostring(TitanBarData[frame].tex_name.."" +--.." "..tostring(tex:GetName()).."" +.." "..tostring(skin.path).."" +--.."\n "..tostring(edge).."" +--.." "..tostring(skin.alpha).."" +--.."\n "..tostring(tex:GetTexture()).."" ) --]] - for i = 0, numOfTextures do - -- Create textures if they don't exist - tex = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i - tex_pre = TITAN_PANEL_BACKGROUND_PREFIX..TitanBarData[idx].name.."_"..i-1 - if not _G[tex] then - titanTexture = _G[bar_name]:CreateTexture(tex, "BACKGROUND") - else - titanTexture = _G[tex] - end - titanTexture:SetHeight(TITAN_PANEL_BAR_TEXTURE_HEIGHT) - if i == numOfTextures then - titanTexture:SetWidth(lastTextureWidth) - else - titanTexture:SetWidth(256) - end - titanTexture:ClearAllPoints() - if i == 0 then - titanTexture:SetPoint("TOPLEFT", bar_name, "TOPLEFT", 0, 0) -- -1, 0) - else - titanTexture:SetPoint("TOPLEFT", tex_pre, "TOPRIGHT") - end - end - end +--[[ -- appears seeting image this way just smears image... + _G[frame]:SetBackdrop({ + bgFile=texture_file, +-- edgeFile=nil, + tile = true, +-- tileSize = 256, +-- tileEdge = true, +-- insets = { left = 1, right = 1, top = 1, bottom = 1 }, +-- tileSize = 8, +-- edgeSize = 8, + }) +--]] + tex:SetAllPoints() + tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true + tex:SetTexture(texture_file, "REPEAT") + tex:SetVertTile(true) -- ensures image is 'full' height of frame +-- tex:SetHeight(TITAN_PANEL_BAR_TEXTURE_HEIGHT) -- leaves a gap if used + tex:SetAlpha(skin.alpha) end ---[[ Titan -NAME: TitanPanel_SetTexture -DESC: Set texture frames for the given Titan bar with the user chosen texture (bar graphic). -VAR: frame - expected to be a Titan bar name (string) -VAR: position - for lookup -OUT: None -NOTE: -- Assumes "TexturePath" contains the user selected texture. -:NOTE ---]] -function TitanPanel_SetTexture(frame) +function TitanPanel_SetBarTexture(frame) if frame and TitanBarData[frame] then -- proceed else return end - local name = TitanBarData[frame].name - - local tex = "TitanPanelBackground" - local tex_pre = tex.."_"..TitanBarData[frame].name.."_" - -- TODO : have Short bars choose top ot bottom skin?? - local skin = "" - local rel_y = _G[frame]:GetTop() - if rel_y <= (TITAN_PANEL_BAR_HEIGHT * 2) then - skin = TITAN_BOTTOM - else - skin = TITAN_TOP - end - - local tex_path = "" - if TitanPanelGetVar("UseGlobalTexture") then -- apply new choice - tex_path = TitanPanelGetVar("TexturePath") - else - tex_path = TitanPanelGetVar("Texture"..TitanBarData[frame].name) - end - -- Create the path & file name to the texture - local texture_file = tex_path..tex..skin.."0" - local applied = 0 - -- include the normal bar (numOfTextures) and hider textures (numOfTexturesHider) - for i = 0, _G[frame].numOfTextures do - _G[tex_pre..i]:SetTexture(texture_file) - applied = applied + 1 + local tex = TitanBarData[frame].tex_name + if _G[tex] then + titanTexture = _G[tex] + else + titanTexture = _G[frame]:CreateTexture(tex, "BACKGROUND") end - + titanTexture:SetTexture() + _G[frame]:SetBackdrop({ + bgFile="", + }) + --[[ -print("_Set tex" +print("_Tex" .." "..tostring(TitanBarData[frame].name).."" -.." "..tostring(_G[frame].numOfTextures).."" -.." "..tostring(tex_path).."" -.." "..tostring(applied).."" +--.." "..tostring(tex).."" +.." "..tostring(titanTexture:GetName()).."" +--.." "..tostring(skin.path).."" +--.."\n "..tostring(edge).."" +--.." "..tostring(skin.alpha).."" +--.."\n "..tostring(tex:GetTexture()).."" +.." "..tostring(TitanBarDataVars["Global"].texure).."" +.." "..tostring(TitanBarDataVars[frame].texure).."" ) --]] + -- Use the texture / skin per user selectable options + if TitanBarDataVars["Global"].texure == TitanVars.SKIN then + Set_Skin(frame, titanTexture, TitanBarDataVars["Global"].skin) -- tex_path = TitanPanelGetVar("TexturePath") + elseif TitanBarDataVars["Global"].texure == TitanVars.COLOR then + Set_Color(frame, titanTexture, TitanBarDataVars["Global"].color) + elseif TitanBarDataVars[frame].texure == TitanVars.SKIN then + Set_Skin(frame, titanTexture, TitanBarDataVars[frame].skin) + elseif TitanBarDataVars[frame].texure == TitanVars.COLOR then + Set_Color(frame, titanTexture, TitanBarDataVars[frame].color) + end end -------------------------------------------------------------- @@ -1062,7 +1047,8 @@ function TitanPanelBarButton_OnLeave(self) local bar = (TitanBarData[frame] and TitanBarData[frame].name or nil) -- if auto hide is active then let the timer hide the bar - local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) + local hide = (bar and TitanBarDataVars[frame].auto_hide or nil) +-- local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) if hide then Titan_AutoHide_Timers(frame, "Leave") end @@ -1255,10 +1241,12 @@ NOTE: :NOTE --]] function TitanPanelBarButton_HideTopBars() - if TitanPanelGetVar("Bar_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar"].show then +-- if TitanPanelGetVar("Bar_Show") then TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar") end - if TitanPanelGetVar("Bar2_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar2"].show then +-- if TitanPanelGetVar("Bar2_Show") then TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar2") end end @@ -1274,10 +1262,12 @@ NOTE: :NOTE --]] function TitanPanelBarButton_HideBottomBars() - if TitanPanelGetVar("AuxBar_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"].show then +-- if TitanPanelGetVar("AuxBar_Show") then TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar") end - if TitanPanelGetVar("AuxBar2_Show") then + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"].show then +-- if TitanPanelGetVar("AuxBar2_Show") then TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2") end end @@ -1293,30 +1283,44 @@ NOTE: --]] function TitanPanelBarButton_Show(frame) local display = _G[frame]; - local bar = (TitanBarData[frame].name or nil) - local show = TitanBarData[frame] and TitanBarData[frame].show or nil + local bar = TitanBarData[frame].name - if bar and display + if display and TitanBarData[frame].name then + local x, y, w = TitanVariables_GetBarPos(frame) + local show = TitanBarData[frame].show + local bott = TitanBarData[frame].bott + -- Show the display bar if the user requested it - if (TitanPanelGetVar(bar.."_Show")) then + if TitanBarDataVars[frame].show then display:ClearAllPoints(); ---[[ -print("T_BBS" -.." "..tostring(frame).."" +--[===[ +local sx, sy = TitanUtils_ScreenSize(false) +print("TB_Show" +--.." "..tostring(frame).."" .." "..tostring(bar).."" -.." "..tostring(TitanPanelGetVar(bar.."_Show")).."" +.." "..tostring(TitanBarDataVars[frame].show).."" ) -print(">>>" +print(">>" --.." "..tostring(show.pt).."" --.." "..tostring(show.rel_fr).."" --.." "..tostring(show.rel_pt).."" -.." x:"..tostring(show.x).."" -.." y:"..tostring(show.y).."" -.." w:"..tostring(TitanBarData[frame].width).."" +.." x:"..tostring(format("%0.1f", x)).."" +.." y:"..tostring(format("%0.1f", y)).."" +.." w:"..tostring(format("%0.1f", w)).."" +.." sx:"..tostring(format("%0.1f", sx)).."" +.." sy:"..tostring(format("%0.1f", sy)).."" ) ---]] - display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y) +--]===] + if TitanBarData[frame].user_move then + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) + else + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) + local h = TITAN_PANEL_BAR_HEIGHT -- / UIParent:GetEffectiveScale() -- adjust scale so it is full height + display:SetPoint(bott.pt, bott.rel_fr, bott.rel_pt, x, y - h) + end + TitanPanel_SetBarTexture(frame) + if TitanBarData[frame].hider then _G[TitanBarData[frame].hider]:Hide() else @@ -1324,15 +1328,7 @@ print(">>>" end else -- The user has not elected to show this bar - display:ClearAllPoints(); - display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, (show.y)*-1) - if TitanBarData[frame].hider then - local hider = _G[TitanBarData[frame].hider] - hider:ClearAllPoints(); - hider:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y) - else - -- not allowed for this bar - end + TitanPanelBarButton_Hide(frame) end end end @@ -1352,27 +1348,38 @@ function TitanPanelBarButton_Hide(frame) local display = _G[frame] local data = TitanBarData[frame] - local bar = (data.name or nil) - local show = data.show or nil + if display and data + then + local x, y, w = TitanVariables_GetBarPos(frame) + -- This moves rather than hides. If we just hide then the plugins will still show. + -- Hide by ensuriing the Y offset is off the screen. + display:ClearAllPoints() + local h = (math.abs(y) + TITAN_PANEL_BAR_HEIGHT * 2) * (-1 * y) + local h = data.hide_y --[[ print("_Hide" -.." "..tostring(frame).."" -.." "..tostring(TitanPanelGetVar(bar.."_Show")).."" +--.." "..tostring(frame).."" +.." "..tostring(data.name).."" +.." "..tostring(TitanBarDataVars[frame].show).."" +.." "..tostring(h).."" ) --]] - if bar and display - then - -- This moves rather than hides. If we just hide then the plugins will still show. - -- Hide by ensuriing the Y offset is below the screen. - display:ClearAllPoints(); - display:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, (TITAN_PANEL_BAR_HEIGHT*2)*-1) + if TitanBarData[frame].user_move then + display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) + else + display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) + display:SetPoint(data.bott.pt, data.bott.rel_fr, data.bott.rel_pt, x, h - TITAN_PANEL_BAR_HEIGHT) + end + if TitanBarData[frame].hider then local hider = _G[data.hider] - if (TitanPanelGetVar(bar.."_Show")) and (TitanPanelGetVar(bar.."_Hide")) then + if TitanBarDataVars[frame].show + and TitanBarDataVars[frame].auto_hide then +-- if (TitanPanelGetVar(data.name.."_Show")) and (TitanPanelGetVar(data.name.."_Hide")) then -- Auto hide is requested so show the hider bar in the right place hider:ClearAllPoints(); - hider:SetPoint(show.pt, show.rel_fr, show.rel_pt, show.x, show.y); + hider:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, y); hider:Show() else -- The bar was not requested @@ -1394,25 +1401,8 @@ function TitanPanel_InitPanelBarButton() -- Set initial Panel Scale TitanPanel_SetScale(); - -- Reposition textures if needed - TitanPanel_CreateBarTextures() for idx,v in pairs (TitanBarData) do - local bar_tex = "" - if TitanPanelGetVar("UseGlobalTexture") then - bar_tex = "Path" - else - bar_tex = v.name - end - TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name, "Texture"..bar_tex); - end - - -- Set transparency of the bars - local bar = "" - local plugin = nil - for idx,v in pairs (TitanBarData) do - -- Set the transparency of each bar - bar = TitanBarData[idx].name - _G[idx]:SetAlpha(TitanPanelGetVar(bar.."_Transparency")) + TitanPanel_SetBarTexture(idx) end end @@ -1490,6 +1480,13 @@ function TitanPanel_InitPanelButtons() -- position the plugin relative to the prior plugin -- or the bar if it is the 1st l_prior = prior[TitanPanelSettings.Location[i]].left +--[===[ +print("Bar plugins" +.." "..tostring(i).."" +.." "..tostring(TitanPanelSettings.Location[i]).."" +.." "..tostring(id).."" +) +--]===] -- ========================= -- button:ClearAllPoints(); @@ -1622,7 +1619,7 @@ function TitanPanelButton_Justify() y_offset = TitanBarData[idx].plugin_y_offset x_offset = TitanBarData[idx].plugin_x_offset firstLeftButton = TitanUtils_GetButton(TitanPanelSettings.Buttons[TitanUtils_GetFirstButtonOnBar (bar, TITAN_LEFT)]) - align = TitanPanelGetVar(bar.."_Align") + align = TitanBarDataVars[idx].align --TitanPanelGetVar(bar.."_Align") leftWidth = 0; rightWidth = 0; counter = 0; @@ -1692,30 +1689,6 @@ end -------------------------------------------------------------- -- -- Local routines for Titan menu creation ---[[ local -NAME: TitanPanelRightClickMenu_BarOnClick -DESC: Show / hide a plugin. Used by the Titan (right click) menu. -VAR: self -VAR: frame_str - the Titan bar user clicked to build menu -VAR: plugin_id - the plugin clicked -OUT: None ---]] -local function TitanPanelRightClickMenu_BarOnClick(self, frame_str, plugin_id) - -- frame_str is the bar the user clicked to get the menu... - local bar = TitanBarData[frame_str].name - - if TitanPanel_IsPluginShown(plugin_id) then - TitanPanel_RemoveButton(plugin_id); - else - TitanUtils_AddButtonOnBar(bar, plugin_id) - end -end - -local function RightClick_HideMe(self, frame_str) - local bar = TitanBarData[frame_str].name - TitanPanelToggleVar(bar.."_Show") - TitanPanelBarButton_DisplayBarsWanted(bar.." user ckicked Hide") -end --[[ local NAME: TitanPanel_MainMenu @@ -1753,6 +1726,7 @@ local function TitanPanel_MainMenu(frame) info.text = L["TITAN_PANEL_MENU_CONFIGURATION"]; info.value = "Bars"; info.func = function() + TitanUpdateConfig("init") Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About) end TitanPanelRightClickMenu_AddButton(info); @@ -1817,7 +1791,10 @@ local function TitanPanel_MainMenu(frame) info.value = "" info.notCheckable = true info.arg1 = frame; - info.func = RightClick_HideMe + info.func = function(self, frame_str) + TitanBarDataVars[frame_str].show = not TitanBarDataVars[frame_str].show + TitanPanelBarButton_DisplayBarsWanted(frame_str.." user clicked Hide") + end info.keepShownOnClick = nil TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -2117,7 +2094,16 @@ local function TitanPanel_BuildOtherPluginsMenu(frame) info.value = id; -- for next level dropdown info.arg1 = frame; info.arg2 = id; - info.func = TitanPanelRightClickMenu_BarOnClick -- (self, info.arg1, info.arg2) + info.func = function(self, frame_str, plugin_id) -- (self, info.arg1, info.arg2) + -- frame_str is the bar the user clicked to get the menu... + local bar = TitanBarData[frame_str].name + + if TitanPanel_IsPluginShown(plugin_id) then + TitanPanel_RemoveButton(plugin_id); + else + TitanUtils_AddButtonOnBar(bar, plugin_id) + end + end info.checked = TitanPanel_IsPluginShown(id) or nil info.keepShownOnClick = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); diff --git a/Titan/TitanPanelTemplate.lua b/Titan/TitanPanelTemplate.lua index a5e9773..7080f6a 100644 --- a/Titan/TitanPanelTemplate.lua +++ b/Titan/TitanPanelTemplate.lua @@ -1148,44 +1148,124 @@ end --========================== -- Routines to handle moving and sizing of short bars -- + local function CheckBounds(self, width) local result = {} + local err = "" + local res = "" local f_name = self:GetName() + local bar_name = TitanBarData[f_name].name local locale_name = TitanBarData[f_name].locale_name - local min_w, min_h, max_w, max_h = self:GetResizeBounds() - local x_off = self:GetLeft() - local y_off = self:GetTop() - local screen_edge = GetScreenWidth() --* UIParent:GetEffectiveScale() - local err = "" - local orig_w = self:GetWidth() - local w = 0 - if TitanBarData[f_name] then - w = orig_w + width - if w < min_w then - -- do nothing - too small - err = "Size too small. Set to min width" - self:SetWidth(min_w) - TitanVariables_SetBarPos(self) - -- TODO : overkill - this will recalc all bars... - TitanPanelBarButton_DisplayBarsWanted("Bar width changed - "..tostring(f_name)) - elseif w > max_w then - err = "Size too big" -- do nothing - too big - elseif (x_off + w) > screen_edge then - err = "Off screen. Leaving as is." -- do nothing - off right side of UI - w = max_w - else - self:SetWidth(w) - TitanVariables_SetBarPos(self) - -- TODO : overkill - this will recalc all bars... - TitanPanelBarButton_DisplayBarsWanted("Bar width changed - "..tostring(f_name)) + + if TitanBarData[f_name].user_move then + -- Assumes BOTTOMLEFT of screen per Short bar defaults. +--[===[ +print("CheckBounds" +.." '"..tostring(bar_name).."'" +.." '"..tostring(width).."'" +.." "..(width == 0 and "drag" or "width").."" +) +--]===] + local min_w, min_h, max_w, max_h = self:GetResizeBounds() + local orig_w = self:GetWidth() --/ UIParent:GetEffectiveScale() -- take out scaling to get 'real' width + local l_off = self:GetLeft() -- * UIParent:GetEffectiveScale() + local r_off = self:GetRight() -- * UIParent:GetEffectiveScale() + local t_off = self:GetTop() -- * UIParent:GetEffectiveScale() + local b_off = self:GetBottom() -- * UIParent:GetEffectiveScale() + local screen_right, screen_top = TitanUtils_ScreenSize() + + local w = 0 + local x_off = 0 + local y_off = 0 + local w_off = 0 + if TitanBarData[f_name] then + if (width == 0) then -- drag and drop + -- Keep the width + w_off = orig_w + + if l_off < 0 then + err = "Off left side of screen, leaving on the edge." + x_off = 0 + y_off = b_off + res = "Off L" + elseif r_off > screen_right then + err = "Off right side of screen, leaving on the edge." + x_off = screen_right - orig_w + y_off = b_off + res = "Off R" + elseif t_off > screen_top then + err = "Off top of screen, leaving on the edge." + x_off = l_off + y_off = screen_top - TITAN_PANEL_BAR_HEIGHT + res = "Off T" + elseif b_off < 0 then + err = "Off bottom of screen, leaving on the edge." + x_off = l_off + y_off = 0 + res = "Off B" + else + -- all seems ok + x_off = l_off + y_off = b_off + res = "Ok" + end + else -- width change + -- Keep the X and Y + x_off = l_off + y_off = b_off + + w = orig_w + width + if w < min_w then + -- do nothing - too small + err = "Width too small. Set to min width." + w_off = min_w + res = "Too small" + elseif w > max_w then + err = "Width too big. Set to max width." -- too wide + w_off = max_w + res = "Too big" + elseif x_off + w > screen_right then + err = "Off right side of screen, leaving on the edge." + w_off = orig_w + res = "Off R" + else + w_off = w + res = "Ok" + end + self:SetSize(w_off, TITAN_PANEL_BAR_HEIGHT) + end end + +--[===[ +---[[ +print(">>CheckBounds" +.." '"..tostring(bar_name).."'" +.." '"..tostring(res).."'" +.."\n" +.." x "..tostring(format("%0.1f", l_off)).."" +.." => "..tostring(format("%0.1f", x_off)).."" +.."\n" +.." y "..tostring(format("%0.1f", b_off)).."" +.." => "..tostring(format("%0.1f", y_off)).."" +.."\n" +.." w "..tostring(format("%0.1f", orig_w)).."" +.." + "..tostring(format("%0.1f", width)).."" +.." = "..tostring(format("%0.1f", w_off)).."" +.."\n" +.." s "..tostring(format("%0.1f", screen_right)).."w" +.." x "..tostring(format("%0.1f", screen_top)).."h" +) +--]] +--]===] + + TitanVariables_SetBarPos(self, false, + x_off, y_off, w_off) +-- x_off / UIParent:GetEffectiveScale(), y_off / UIParent:GetEffectiveScale(), w_off) + else + -- Controlled with anchor points so no check is needed end - result.x = x_off - result.y = y_off - result.err = err - if err == "" then -- all is good result.ok = true @@ -1193,6 +1273,7 @@ local function CheckBounds(self, width) result.ok = false TitanPrint(locale_name.." "..err.."!!!!", "error") end + --[[ print("CheckBounds" .." '"..tostring(locale_name).."'" @@ -1217,16 +1298,19 @@ print(">>" end local function OnMoveStart(self) + if IsShiftKeyDown() then + if self:IsMovable() then + self.isMoving = true --[[ print("OnMoveStart" .." "..tostring(self:GetName()).."" .." "..tostring(IsShiftKeyDown()).."" .." "..tostring(IsAltKeyDown()).."" +.."\n" +.." x "..tostring(format("%0.1f", self:GetLeft())).."" +.." y "..tostring(format("%0.1f", self:GetTop())).."" ) --]] - if IsShiftKeyDown() then - if self:IsMovable() then - self.isMoving = true self:StartMoving() _G.GameTooltip:Hide() end @@ -1237,6 +1321,9 @@ end local function OnMovingStop(self) + self:StopMovingOrSizing() + self.isMoving = nil + local res = CheckBounds(self, 0) --[[ print("OnMovingStop" @@ -1246,17 +1333,13 @@ print("OnMovingStop" .." ok: "..tostring(res.ok).."" ) --]] - self:StopMovingOrSizing() - self.isMoving = nil if res.ok then - -- For now, honor the user move... - -- TODO : 'put back' if off any part of screen - TitanVariables_SetBarPos(self) else end - -- TODO : overkill - this will recalc all bars... - TitanPanelBarButton_DisplayBarsWanted("Bar moved - "..tostring(self:GetName())) - + -- Seems overkill - this will recalc all bars but recalc of textures could be needed... + TitanPanel_InitPanelBarButton("Check bounds") + -- The drag or width change occrred on screen but may need adjusting from user drop if bounds condition. + TitanPanelBarButton_DisplayBarsWanted("Short Bar change - "..(width == o and "width" or "drag").." - "..tostring(f_name)) end local function OnMouseWheel(self, d) @@ -1264,11 +1347,6 @@ local function OnMouseWheel(self, d) local old_w = self:GetWidth() local res = CheckBounds(self, d) if res.ok then - local w = self:GetWidth() + d - self:SetWidth(w) - TitanVariables_SetBarPos(self) - -- TODO : overkill - this will recalc all bars... - TitanPanel_InitPanelBarButton() end --[[ print("wheel" @@ -1278,9 +1356,17 @@ print("wheel" .." ok: "..tostring(res.ok).."" ) --]] + -- Seems overkill - this will recalc all bars but recalc of textures could be needed... + TitanPanel_InitPanelBarButton("Check bounds") + -- The drag or width change occrred on screen but may need adjusting from user drop if bounds condition. + TitanPanelBarButton_DisplayBarsWanted("Short Bar change - "..(width == o and "width" or "drag").." - "..tostring(f_name)) end end +-- +--========================== +-- Routines to handle creation of Titan bars +-- --[[ Titan NAME: TitanPanelButton_CreateBar(frame_str) DESC: Create a Titan bar that can show plugins. @@ -1294,34 +1380,32 @@ function TitanPanelButton_CreateBar(frame_str) local a_bar = CreateFrame("Button", this_bar, UIParent, "Titan_Bar__Display_Template") local bar_data = TitanBarData[this_bar] + + -- ====== + -- Scripts + a_bar:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) + a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) + a_bar:SetFrameStrata("DIALOG") + + local x, y, w = TitanVariables_GetBarPos(frame_str) + local sx, sy = TitanUtils_ScreenSize() --[[ print("_Create bar" .." "..tostring(bar_data.name).."" -.." "..tostring(bar_data.width).."" -.." "..tostring(TITAN_PANEL_BAR_HEIGHT).."" +.."\n " +.." "..tostring(bar_data.name).."" +.." "..tostring(bar_data.show.pt).."" +.." "..tostring(bar_data.show.rel_fr).."" +.." "..tostring(bar_data.show.rel_pt).."" +.."\n " +.." "..tostring(bar_data.name).."" +.." "..tostring(format("%0.1f", x)).."" +.." "..tostring(format("%0.1f", y)).."" +.." "..tostring(format("%0.1f", w)).."" ) --]] - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, bar_data.show.x, bar_data.show.y) - a_bar:SetFrameStrata("DIALOG") - a_bar:SetSize(bar_data.width, TITAN_PANEL_BAR_HEIGHT) - - -- ====== - -- Bounds only effective on Short bars for now - -- Min : No smaller than the padding & one icon - -- Max : No wider than the screen - -- does not seem to work to restrict size automatically... - a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, GetScreenWidth(), TITAN_PANEL_BAR_HEIGHT) - - -- ====== - -- Scripts - if bar_data.vert == TITAN_TOP - or bar_data.vert == TITAN_BOTTOM - then - -- Set script handlers for display - a_bar:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) - a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) - elseif bar_data.vert == TITAN_SHORT - then + if bar_data.user_move then + a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) a_bar:SetMovable(true) a_bar:SetResizable(true) a_bar:EnableMouse(true) @@ -1329,22 +1413,41 @@ print("_Create bar" a_bar:SetScript("OnDragStart", OnMoveStart) a_bar:SetScript("OnDragStop", OnMovingStop) a_bar:SetScript("OnMouseWheel", OnMouseWheel) + a_bar:SetSize(w, TITAN_PANEL_BAR_HEIGHT) + else + -- Static full width bar + a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) + a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y - TITAN_PANEL_BAR_HEIGHT) end + -- ====== + -- Bounds only effective on Short bars for now + -- Min : No smaller than the padding & one icon + -- Max : No wider than the screen + -- does not seem to work to restrict size automatically... + a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, sx, TITAN_PANEL_BAR_HEIGHT) + a_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); a_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) -- ====== - -- Frame for right clicke + -- Frame for right clicks f = CreateFrame("Frame", this_bar.."RightClickMenu", UIParent, "UIDropDownMenuTemplate") -- ====== -- Hider for auto hide feature local hide_bar_name = TITAN_PANEL_HIDE_PREFIX..bar_data.name if bar_data.hider then +--[[ +print("_Create hide bar" +.." "..tostring(bar_data.name).."" +.." "..tostring(hide_bar_name).."" +) +--]] + local hide_bar = CreateFrame("Button", hide_bar_name, UIParent, "TitanPanelBarButtonHiderTemplate") hide_bar:SetFrameStrata("DIALOG") - hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, bar_data.show.x, -bar_data.show.y) + hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, -y) -- Set script handlers for display hide_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); @@ -1353,8 +1456,7 @@ print("_Create bar" hide_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) hide_bar:SetFrameStrata("BACKGROUND") - hide_bar:SetWidth(bar_data.width) - hide_bar:SetSize(bar_data.width, TITAN_PANEL_BAR_HEIGHT) + hide_bar:SetSize(sx, TITAN_PANEL_BAR_HEIGHT) else -- Not allowed for this bar end diff --git a/Titan/TitanPanelTemplate.xml b/Titan/TitanPanelTemplate.xml index d46219d..7624d06 100644 --- a/Titan/TitanPanelTemplate.xml +++ b/Titan/TitanPanelTemplate.xml @@ -166,7 +166,8 @@ </Size> </Button> - <Button name="Titan_Bar__Display_Template" frameStrata="DIALOG" toplevel="true" movable="true" parent="UIParent" virtual="true"> + <Button name="Titan_Bar__Display_Template" frameStrata="DIALOG" inherits="BackdropTemplate" + toplevel="true" movable="true" parent="UIParent" virtual="true"> </Button> </Ui> diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index fcc2018..bc3243b 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -261,7 +261,7 @@ function TitanUtils_PickBar() for idx = 1, #bar_list do local bar_name = bar_list[idx].name - if TitanPanelGetVar(bar_name.."_Show") then + if TitanBarDataVars[idx].show then --if TitanPanelGetVar(bar_name.."_Show") then return bar_name end end @@ -1142,22 +1142,23 @@ function TitanUtils_AddButtonOnBar(bar, id) if (not bar) or (not id) or (not TitanPanelSettings) - or (not TitanPanelGetVar(bar.."_Show")) + or (not TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX..bar].show) --or (not TitanPanelGetVar(bar.."_Show")) then return; end local i = TitanPanel_GetButtonNumber(id) ---[[ -TitanDebug("AddB: "..(id or "?").." "..(bar or "?").." " -..(TitanPanelSettings and "T" or "F").." "..(TitanPanelGetVar(bar.."_Show") and "T" or "F").." " -..(i or "?").." " -) ---]] -- The _GetButtonNumber returns +1 if not found so it is 'safe' to -- update / add to the Location TitanPanelSettings.Buttons[i] = (id or "?") TitanPanelSettings.Location[i] = (bar or "Bar") +--[[ +TitanDebug("AddB:" +.." "..tostring(id).."" +.." "..tostring(bar).."" +.." "..tostring(i).."" +) +--]] TitanPanel_InitPanelButtons(); end @@ -1956,6 +1957,43 @@ function TitanUtils_SetGlobalProfile(glob, toon) TitanAllSetVar("GlobalProfileName", toon or TITAN_PROFILE_NONE) end +--[[ Titan +NAME: TitanUtils_ScreenSize +DESC: Return the screen size after scaling +VAR: +- output - boolean if true dump a lot of UI size info to chat +OUT: +- number - scaled X / width +- number - scaled Y / height +--]] +function TitanUtils_ScreenSize(output) + -- GetScreenWidth GetScreenHeight + local screen_x = UIParent:GetRight() -- * UIParent:GetEffectiveScale() + local screen_y = UIParent:GetTop() -- * UIParent:GetEffectiveScale() + + if output then + local x = UIParent:GetRight() + local y = UIParent:GetTop() + local s = UIParent:GetEffectiveScale() + local px, py = GetPhysicalScreenSize() + print("_ScreenSize" + .."\n" + .." UI - x:"..tostring(format("%0.1f", x)).."" + .." X y:"..tostring(format("%0.1f", y)).."" + .." scale:"..tostring(format("%0.6f", s)).."" + .."\n" + .." UI scaled - x:"..tostring(format("%0.1f", screen_x * UIParent:GetEffectiveScale())).."" + .." X y:"..tostring(format("%0.1f", screen_y * UIParent:GetEffectiveScale())).."" + .."\n" + .." screen - x:"..tostring(format("%0.1f",px)).."" + .." X y:"..tostring(format("%0.1f", py)).."" + ) + end + + return screen_x, screen_y +end + + -------------------------------------------------------------- -- Various debug routines --[[ diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index 73d98f2..9cb2f36 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -75,7 +75,6 @@ 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_DISPLAY_ID = "Id_" TITAN_PANEL_BACKGROUND_PREFIX = "TitanPanelBackground_" TITAN_PANEL_TEXT = "Text" TITAN_PANEL_TEXTURE_VAR = "Texture" @@ -101,6 +100,12 @@ 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 @@ -127,168 +132,352 @@ The short name is used to build names of the various saved variables, frames, and buttons used by Titan. :DESC -]] -local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() -local x_mid = GetScreenWidth() / 2 local SHORT_WIDTH = 200 +local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() +local x_max = GetScreenWidth() +local x_mid = (GetScreenWidth() / 2) - (SHORT_WIDTH / 2) + +local function Calc_Y(n) + return (GetScreenHeight() - (TITAN_PANEL_BAR_HEIGHT * n)) +end +local function Calc_X() + return (GetScreenWidth() / 2) - (SHORT_WIDTH / 2) +end --[[ --]] -TitanBarData = {} -TitanBarDataDefaults = { +TitanBarData = { [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = { locale_name = L["TITAN_PANEL_MENU_TOP"], name = "Bar", vert = TITAN_TOP, order = 1, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Bar", hider = TITAN_PANEL_HIDE_PREFIX.."Bar", + hide_y = (TITAN_PANEL_BAR_HEIGHT * 3), plugin_y_offset = 1, plugin_x_offset = 5, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=y_top-TITAN_PANEL_BAR_HEIGHT}, + show = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT",}, + bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT",}, user_move = false, - width = GetScreenWidth(), }, [TITAN_PANEL_DISPLAY_PREFIX.."Bar2"] = { locale_name = L["TITAN_PANEL_MENU_TOP2"], name = "Bar2", vert = TITAN_TOP, order = 2, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Bar2", hider = TITAN_PANEL_HIDE_PREFIX.."Bar2", + hide_y = (TITAN_PANEL_BAR_HEIGHT * 10), plugin_y_offset = 1, plugin_x_offset = 5, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=y_top-(TITAN_PANEL_BAR_HEIGHT*2)}, + show = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT",}, + bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT",}, user_move = false, - width = GetScreenWidth(), }, -- no idea why -1 is needed for the bottom... seems anchoring to bottom is off a pixel [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"] = { locale_name = L["TITAN_PANEL_MENU_BOTTOM2"], name = "AuxBar2", vert = TITAN_BOTTOM, order = 3, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."AuxBar2", hider = TITAN_PANEL_HIDE_PREFIX.."AuxBar2", + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 2), plugin_y_offset = 1, plugin_x_offset = 5, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=TITAN_PANEL_BAR_HEIGHT}, + show = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, + bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT",}, user_move = false, - width = GetScreenWidth(), }, [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"] = { locale_name = L["TITAN_PANEL_MENU_BOTTOM"], name = "AuxBar", vert = TITAN_BOTTOM, order = 4, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."AuxBar", hider = TITAN_PANEL_HIDE_PREFIX.."AuxBar", + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 3), plugin_y_offset = 1, plugin_x_offset = 5, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", x=0, y=0}, + position = {eff_x = 0, eff_y = 0, eff_width = 0}, + show = {pt="TOPLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, + bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT",}, user_move = false, - width = GetScreenWidth(), }, ----[[ [TITAN_PANEL_DISPLAY_PREFIX.."Short01"] = { locale_name = SHORT.." 01", name = "Short01", vert = TITAN_SHORT, order = 5, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short01", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 2) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short02"] = { locale_name = SHORT.." 02", name = "Short02", vert = TITAN_SHORT, order = 6, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short02", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 3) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short03"] = { locale_name = SHORT.." 03", name = "Short03", vert = TITAN_SHORT, order = 7, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short03", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 4) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short04"] = { locale_name = SHORT.." 04", name = "Short04", vert = TITAN_SHORT, order = 8, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short04", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 5) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short05"] = { locale_name = SHORT.." 05", name = "Short05", vert = TITAN_SHORT, order = 9, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short05", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 6) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short06"] = { locale_name = SHORT.." 06", name = "Short06", vert = TITAN_SHORT, order = 10, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short06", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 7) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short07"] = { locale_name = SHORT.." 07", name = "Short07", vert = TITAN_SHORT, order = 11, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short07", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 8) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short08"] = { locale_name = SHORT.." 08", name = "Short08", vert = TITAN_SHORT, order = 12, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short08", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 9) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short09"] = { locale_name = SHORT.." 09", name = "Short09", vert = TITAN_SHORT, order = 13, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short09", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 10) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, [TITAN_PANEL_DISPLAY_PREFIX.."Short10"] = { locale_name = SHORT.." 10", name = "Short10", vert = TITAN_SHORT, order = 14, + tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short10", hider = nil, + hide_y = -(TITAN_PANEL_BAR_HEIGHT * 4), plugin_y_offset = 1, plugin_x_offset = 10, - show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT", - x=x_mid - (SHORT_WIDTH / 2), y=(y_top - (TITAN_PANEL_BAR_HEIGHT* 10) -1)}, + show = {pt="BOTTOMLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, user_move = true, - width = SHORT_WIDTH, }, } +--[[ Titan +NAME: TitanBarPositions table. +DESC: +The table holds: +- the name of each Titan bar (as the index) +- the X and Y position of the bar +- the width of the bar + +The index must be matched to the TitanBarData table! +This table wil be saved under "Players" to rember the placement of Short bars. + +The cooresponding Defaults table holds the starting values. +The original Titan (full width) bars values are used for default X and Y +:DESC +-]] +TitanBarPositions = {} +TitanBarPositionsDefaults = { + [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = {off_x=0, off_y=0, off_w = x_max, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Bar2"] = {off_x=0, off_y=-(TITAN_PANEL_BAR_HEIGHT), off_w = x_max, }, + [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"] = {off_x=0, off_y=(TITAN_PANEL_BAR_HEIGHT * 2), off_w = x_max, }, + [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"] = {off_x=0, off_y=(TITAN_PANEL_BAR_HEIGHT), off_w = x_max, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short01"] = {off_x=x_mid, off_y=Calc_Y(3), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short02"] = {off_x=x_mid, off_y=Calc_Y(4), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short03"] = {off_x=x_mid, off_y=Calc_Y(5), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short04"] = {off_x=x_mid, off_y=Calc_Y(6), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short05"] = {off_x=x_mid, off_y=Calc_Y(7), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short06"] = {off_x=x_mid, off_y=Calc_Y(8), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short07"] = {off_x=x_mid, off_y=Calc_Y(9), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short08"] = {off_x=x_mid, off_y=Calc_Y(10), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short09"] = {off_x=x_mid, off_y=Calc_Y(11), off_w = SHORT_WIDTH, }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short10"] = {off_x=x_mid, off_y=Calc_Y(12), off_w = SHORT_WIDTH, }, +} +TitanBarDataVars = {} +TitanBarVarsDefaults = { + ["Global"] = -- holds 'global' user settings; NOT for use in the frame loop! + { + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.NONE, -- TitanVars.NONE or TitanVars.SKIN or TitanVars.COLOR + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = {off_x=0, off_y=0, off_w = x_max, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, -- or TitanVars.COLOR + show = true, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Bar2"] = {off_x=0, off_y=-(TITAN_PANEL_BAR_HEIGHT), off_w = x_max, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"] = {off_x=0, off_y=(TITAN_PANEL_BAR_HEIGHT * 2), off_w = x_max, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"] = {off_x=0, off_y=(TITAN_PANEL_BAR_HEIGHT), off_w = x_max, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short01"] = {off_x=x_mid, off_y=Calc_Y(3), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short02"] = {off_x=x_mid, off_y=Calc_Y(4), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short03"] = {off_x=x_mid, off_y=Calc_Y(5), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short04"] = {off_x=x_mid, off_y=Calc_Y(6), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short05"] = {off_x=x_mid, off_y=Calc_Y(7), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short06"] = {off_x=x_mid, off_y=Calc_Y(8), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short07"] = {off_x=x_mid, off_y=Calc_Y(9), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short08"] = {off_x=x_mid, off_y=Calc_Y(10), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short09"] = {off_x=x_mid, off_y=Calc_Y(11), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, + [TITAN_PANEL_DISPLAY_PREFIX.."Short10"] = {off_x=x_mid, off_y=Calc_Y(12), off_w = SHORT_WIDTH, + skin = {path = "Interface\\AddOns\\Titan\\Artwork\\", alpha = 0.7}, + color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, + texure = TitanVars.SKIN, + show = false, + auto_hide = false, + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + hide_in_combat = false, + }, +} + -- Timers used within Titan TitanTimers = {} @@ -330,8 +519,6 @@ TITAN_PANEL_SAVED_VARIABLES = { Buttons = {}, Location = {}, TexturePath = "Interface\\AddOns\\Titan\\Artwork\\", - UseGlobalTexture = false, - UseGlobal_HideInCombat = false, Transparency = 0.7, AuxTransparency = 0.7, Scale = 1, @@ -343,6 +530,11 @@ TITAN_PANEL_SAVED_VARIABLES = { FontName = TPC.FONT_NAME, FrameStrata = "LOW", FontSize = TPC.FONT_SIZE, + LogAdjust = false, + MinimapAdjust = false, + BagAdjust = 1, + TicketAdjust = 1, + Position = 1, ButtonAlign = 1, LockButtons = false, LockAutoHideInCombat = false, @@ -354,86 +546,18 @@ TITAN_PANEL_SAVED_VARIABLES = { Bar_Hide = false, Bar_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, Bar_Transparency = 0.7, - Bar_HideInCombat = false, Bar2_Show = false, Bar2_Hide = false, Bar2_Transparency = 0.7, - Bar2_HideInCombat = false, Bar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, AuxBar_Show = false, AuxBar_Hide = false, AuxBar_Transparency = 0.7, - AuxBar_HideInCombat = false, AuxBar_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, AuxBar2_Show = false, AuxBar2_Hide = false, AuxBar2_Transparency = 0.7, - AuxBar2_HideInCombat = false, AuxBar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short01_Show = false, - Short01_Hide = false, - Short01_Transparency = 0.7, - Short01_HideInCombat = false, - Short01_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short02_Show = false, - Short02_Hide = false, - Short02_Transparency = 0.7, - Short02_HideInCombat = false, - Short02_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short03_Show = false, - Short03_Hide = false, - Short03_Transparency = 0.7, - Short03_HideInCombat = false, - Short03_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short04_Show = false, - Short04_Hide = false, - Short04_Transparency = 0.7, - Short04_HideInCombat = false, - Short04_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short05_Show = false, - Short05_Hide = false, - Short05_Transparency = 0.7, - Short05_HideInCombat = false, - Short05_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short06_Show = false, - Short06_Hide = false, - Short06_Transparency = 0.7, - Short06_HideInCombat = false, - Short06_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short07_Show = false, - Short07_Hide = false, - Short07_Transparency = 0.7, - Short07_HideInCombat = false, - Short07_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short08_Show = false, - Short08_Hide = false, - Short08_Transparency = 0.7, - Short08_HideInCombat = false, - Short08_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short09_Show = false, - Short09_Hide = false, - Short09_Transparency = 0.7, - Short09_HideInCombat = false, - Short09_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - Short10_Show = false, - Short10_Hide = false, - Short10_Transparency = 0.7, - Short10_HideInCombat = false, - Short10_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, - TextureBar = "Interface\\AddOns\\Titan\\Artwork\\", - TextureBar2 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureAuxBar = "Interface\\AddOns\\Titan\\Artwork\\", - TextureAuxBar2 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort01 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort02 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort03 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort04 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort05 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort06 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort07 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort08 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort09 = "Interface\\AddOns\\Titan\\Artwork\\", - TextureShort10 = "Interface\\AddOns\\Titan\\Artwork\\", }; --[[ Titan @@ -555,6 +679,11 @@ local function Plugin_settings(reset) local plugin_list = {} if reset then -- use the default install list plugin_list = Default_Plugins +--[[ +print("plugins init" +.." "..tostring(reset).."" +) +--]] else -- use the current profile plugin_list = TitanPanelSettings.Buttons end @@ -564,10 +693,10 @@ local function Plugin_settings(reset) local id = default_plugin.id local loc = default_plugin.loc local plugin = TitanUtils_GetPlugin(id) ---TitanDebug("Plugin: "..(id or "?").." "..(plugin and "T" or "F")) +--TitanDebug("Plugin: "..tostring(id).." "..(plugin and "T" or "F")) -- See if plugin is registered if (plugin) then ---TitanDebug("__Plugin: "..(id or "?").." "..(loc or "?")) +--TitanDebug("__Plugin: "..tostring(id).." "..tostring(loc)) -- Synchronize registered and saved variables TitanVariables_SyncRegisterSavedVariables( plugin.savedVariables, TitanPluginSettings[id]) @@ -678,17 +807,6 @@ local function Set_Timers(reset) end end -local function Get_Saved_BarData(player) - if TitanSettings.Players[player].BarData then - -- All good - else - -- Set to defaults - TitanSettings.Players[player].BarData = TitanBarDataDefaults - end - -- Set pointer to saved data - return TitanSettings.Players[player].BarData -end - --[[ Titan NAME: TitanVariables_SyncPluginSettings DESC: Routine to sync plugin datas - current loaded (lua file) to any plugin saved vars (last save to disk). @@ -738,10 +856,6 @@ function TitanVariables_InitTitanSettings() if (TitanSettings) then -- all is good else -print("_InitTSettings" -.." "..tostring(player).."" -.." "..tostring("Reset of TitanSettings!!!!!").."" -) TitanSettings = {} end @@ -749,24 +863,14 @@ print("_InitTSettings" if TitanSettings.Players then -- all is good else -print("_InitTSettings" -.." "..tostring(player).."" -.." "..tostring("Reset of TitanSettings.Players!!!!!").."" -) TitanSettings.Players = {} -- empty saved vars. New install or wipe end if TitanSettings.Players[player] then -- all is good else -print("_InitTSettings" -.." "..tostring(player).."" -.." "..tostring("Reset of TitanSettings.Players[player]!!!!!").."" -) -TitanDumpPlayerList() -- Create the bare player tables so profile(s) can be added TitanSettings.Players[player] = {} - TitanSettings.Players[player].BarData = TitanBarDataDefaults TitanSettings.Players[player].Plugins = {} TitanSettings.Players[player].Panel = TITAN_PANEL_SAVED_VARIABLES TitanSettings.Players[player].Panel.Buttons = {} @@ -775,16 +879,40 @@ TitanDumpPlayerList() TitanPlayerSettings["Plugins"] = {} TitanPlayerSettings["Panel"] = {} TitanPlayerSettings["Register"] = {} + TitanPlayerSettings["BarData"] = TitanBarPositionsDefaults -- New Mar 2023 + TitanPlayerSettings["BarVars"] = TitanBarVarsDefaults -- New Mar 2023 new_toon = true end - - -- ============== Bar defaults - -- New Mar 2023 to hold Short bars - -- Set pointer to saved data - TitanBarData = Get_Saved_BarData(player) - + -- New Mar 2023 : TitanSettings.Players[player].BarData to hold Short bar data + if TitanSettings.Players[player].BarData then + -- All good + else + -- Set to defaults + TitanSettings.Players[player].BarData = TitanBarPositionsDefaults + 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 + end + + -- Set global variables + TitanPlayerSettings = TitanSettings.Players[player] + TitanPluginSettings = TitanPlayerSettings["Plugins"] + TitanPanelSettings = TitanPlayerSettings["Panel"] + TitanBarPositions = TitanPlayerSettings["BarData"] + TitanBarDataVars = TitanPlayerSettings["BarVars"] + --[[ + if new_toon then + Plugin_settings(true) + else + TitanVariables_PluginSettingsInit() + end + TitanDumpPlayerList() --]] @@ -800,8 +928,8 @@ end --[[ Titan NAME: TitanVariables_SetBarPos -DESC: Update local and saved vars to new bar pos per user -VAR: None +DESC: Update local and saved vars to new bar position per user +VAR: self - frame to save position OUT: None NOTE: - Called when Titan is loaded (ADDON_LOADED event) @@ -809,35 +937,50 @@ NOTE: - :GetPoint(1) results in incorrect values based on point used :NOTE --]] -function TitanVariables_SetBarPos(self, reset) +function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) -- Collect bar x & y and save so bar stays put. local bar_frame = self:GetName() - local off_x = self:GetLeft() - local off_y = self:GetBottom() - local width = self:GetWidth() +-- local off_x = self:GetLeft() +-- local off_y = self:GetBottom() +-- local width = self:GetWidth() local force_reset = reset or false ---[[ -print("_SetBarPos" -.." "..tostring(self:GetName()).."" -.." x: "..tostring(off_x).."" -.." y: "..tostring(off_y).."" -) ---]] - local bar_data = TitanBarData[bar_frame] - if bar_data then + if TitanBarPositions[bar_frame] then if reset then - TitanBarData[bar_frame].show = TitanBarDataDefaults[bar_frame].show - TitanBarData[bar_frame].width = TitanBarDataDefaults[bar_frame].width - TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - "..tostring(bar_data.name)) + -- Initial defaults calc on screen and scaling at that time - it could have changed! + TitanBarPositions[bar_frame].off_x = Calc_X() + TitanBarPositions[bar_frame].off_y = Calc_Y(TitanBarData[bar_frame].order-2) + TitanBarPositions[bar_frame].off_w = SHORT_WIDTH else -- local to show bars as needed - TitanBarData[bar_frame].show.x = off_x - TitanBarData[bar_frame].show.y = off_y - TitanBarData[bar_frame].width = width + TitanBarPositions[bar_frame].off_x = x_off + TitanBarPositions[bar_frame].off_y = y_off + TitanBarPositions[bar_frame].off_w = w_off end end +--[[ +print("_SetBarPos" +.." "..tostring(self:GetName()).."" +.." "..tostring(reset).."" +.." x: "..tostring(format("%0.1f", (TitanBarPositions[bar_frame].off_x or -1.0))).."" +.." y: "..tostring(format("%0.1f", (TitanBarPositions[bar_frame].off_y or -1.0))).."" +.." w: "..tostring(format("%0.1f", (TitanBarPositions[bar_frame].off_w or -1.0))).."" +) +--]] +end + +--[[ Titan +NAME: TitanVariables_GetBarPos +DESC: Retrieve saved vars of bar position +VAR: frame_str - frame name to retrieve positions from +OUT: X, Y, Width +--]] +function TitanVariables_GetBarPos(frame_str) + return + TitanBarPositions[frame_str].off_x, + TitanBarPositions[frame_str].off_y, + TitanBarPositions[frame_str].off_w end --[[ local @@ -875,29 +1018,6 @@ TitanDebug("_UseSettings " CleanupProfile () -- hide currently shown plugins ---[===[ done at addon loaded - -- Ensure the requested profile is at least an empty stub -print("_UseSettings player" -.." "..tostring(TitanSettings.Players).."" -.." : "..tostring(TitanSettings.Players[to_profile]).."" -) - if (not TitanSettings.Players[to_profile]) or reset then ----[[ -TitanDebug("_UseSettings player init" -) ---]] - TitanSettings.Players[to_profile] = {} - TitanSettings.Players[to_profile].Plugins = {} - TitanSettings.Players[to_profile].Panel = {} - TitanSettings.Players[to_profile].Panel.Buttons = {} - TitanSettings.Players[to_profile].Panel.Location = {} - TitanPlayerSettings = {} - TitanPlayerSettings["Plugins"] = {} - TitanPlayerSettings["Panel"] = {} - TitanPlayerSettings["Register"] = {} - end ---]===] - -- Set global variables TitanPlayerSettings = TitanSettings.Players[to_profile]; TitanPluginSettings = TitanPlayerSettings["Plugins"]; @@ -915,7 +1035,7 @@ TitanDebug("_UseSettings player init" -- The requested profile at least exists so we can copy to it -- Copy from the from_profile to profile - not anything in saved vars -- Get the bar data settings - TitanBarData = Get_Saved_BarData(from_profile) + TitanBarPositions = Get_Saved_BarData(from_profile) if from_profile and TitanSettings.Players[from_profile] then old_player = TitanSettings.Players[from_profile] @@ -1207,29 +1327,7 @@ TitanDebug("_UseSettings " .."action: "..action.." " ) --]] ---[[ done on addon loaded - -- sanity checks to ensure the base tables are set - if (TitanSettings) then - -- all is good - else - TitanSettings = {} - end - -- check for player list per issue #745 - if TitanSettings.Players then - -- all is good - else - -- Create the table so profile(s) can be added - TitanSettings.Players = {} - end - if (TitanAll) then - -- all is good - else - TitanAll = {}; - end - TitanVariables_SyncRegisterSavedVariables(TITAN_ALL_SAVED_VARIABLES, TitanAll) - TitanSettings.Version = TITAN_VERSION; ---]] local from_profile = nil if action == TITAN_PROFILE_USE then -- Grab the old profile currently in use