diff --git a/Titan/Titan.code-workspace b/Titan/Titan.code-workspace new file mode 100644 index 0000000..45392d3 --- /dev/null +++ b/Titan/Titan.code-workspace @@ -0,0 +1,239 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "../TitanAmmo" + }, + { + "path": "../TitanBag" + }, + { + "path": "../TitanClassic" + }, + { + "path": "../TitanClock" + }, + { + "path": "../TitanGold" + }, + { + "path": "../TitanLDB" + }, + { + "path": "../TitanLocation" + }, + { + "path": "../TitanLootType" + }, + { + "path": "../TitanPerformance" + }, + { + "path": "../TitanPlugin" + }, + { + "path": "../TitanRegen" + }, + { + "path": "../TitanRepair" + }, + { + "path": "../TitanVolume" + }, + { + "path": "../TitanXP" + } + ], + "settings": { + "Lua.diagnostics.globals": [ + "HIGHLIGHT_FONT_COLOR_CODE", + "GREEN_FONT_COLOR_CODE", + "DEFAULT_CHAT_FRAME", + "FONT_COLOR_CODE_CLOSE", + "ToggleAllBags", + "HIGHLIGHT_FONT_COLOR", + "NORMAL_FONT_COLOR", + "ORANGE_FONT_COLOR", + "RED_FONT_COLOR", + "UNKNOWN", + "NONE", + "GameTimeFrame", + "TimeManagerClockButton", + "ToggleCalendar", + "TIME_TWENTYFOURHOURS", + "TIME_TWELVEHOURAM", + "TIME_TWELVEHOURPM", + "WorldMapFrameCloseButton", + "WorldMapFrame", + "ToggleFrame", + "SANCTUARY_TERRITORY", + "CONTESTED_TERRITORY", + "ChatEdit_GetActiveWindow", + "FACTION_CONTROLLED_TERRITORY", + "VOLUME", + "OPTION_TOOLTIP_MASTER_VOLUME", + "OPTION_TOOLTIP_MUSIC_VOLUME", + "OPTION_TOOLTIP_FX_VOLUME", + "OPTION_TOOLTIP_ENABLE_AMBIENCE", + "OPTION_TOOLTIP_DIALOG_VOLUME", + "GREEN_FONT_COLOR", + "MouseIsOver", + "LIGHTYELLOW_FONT_COLOR_CODE", + "ReloadUI", + "NORMAL_FONT_COLOR_CODE", + "RED_FONT_COLOR_CODE", + "StaticPopupDialogs", + "StaticPopup_Show", + "ALL", + "ACCEPT", + "CANCEL", + "FACTION_ALLIANCE", + "FACTION_HORDE", + "FACTION_OTHER", + "CLASS_ICON_TCOORDS", + "ICON_TAG_LIST", + "MAX_RAID_MEMBERS", + "MAX_PARTY_MEMBERS", + "RANDOM_ROLL_RESULT", + "WHISPER", + "StaticPopup_Hide", + "YES", + "NO", + "ITEM_QUALITY0_DESC", + "FACTION_STANDING_LABEL5", + "FACTION_STANDING_LABEL6", + "FACTION_STANDING_LABEL7", + "FACTION_STANDING_LABEL8", + "MoneyFrame_Update", + "TooltipUtil", + "MerchantRepairAllButton", + "MerchantGuildBankRepairButton", + "GUILD", + "REPAIR_COST", + "WITHDRAW", + "UNLIMITED", + "AVAILABLE", + "GUILDBANK_REPAIR_INSUFFICIENT_FUNDS", + "FROM", + "YOU", + "SHOW", + "LOOT", + "SPECIALIZATION", + "LOOT_METHOD", + "SELECT_LOOT_SPECIALIZATION", + "SlashCmdList", + "Settings", + "TOOLTIP_DEFAULT_COLOR", + "HIDE", + "COLOR", + "USE", + "BACKGROUND", + "BATTLEGROUND", + "ARENA", + "LOW", + "HIGH", + "SecureUnitButton_OnClick", + "FCF_DockUpdate", + "UpdateContainerFrameAnchors", + "MainMenuBar", + "TicketStatusFrame", + "ContainerFrame1", + "MainMenuBarVehicleLeaveButton", + "MultiBarBottomLeft", + "ExtraActionBarFrame", + "MultiCastActionBarFrame", + "MultiBarBottomRight", + "DropDownList1", + "UIDropDownMenu_AddButton", + "UIDROPDOWNMENU_MENU_LEVEL", + "UIDropDownMenu_AddSeparator", + "UIDropDownMenu_AddSpace", + "TOOLTIP_DEFAULT_BACKGROUND_COLOR", + "ToggleDropDownMenu", + "UIDropDownMenu_Initialize", + "UKNOWNBEING", + "SHORT", + "UIDROPDOWNMENU_MAXLEVELS", + "ColorPickerFrame", + "ExecuteFrameScript", + "GameFontDisableSmallLeft", + "GameFontHighlightSmallLeft", + "DropDownMenuButtonMixin", + "GameFontNormalSmallLeft", + "VIDEO_QUALITY_LABEL6", + "TooltipBackdropTemplateMixin", + "SharedTooltip_SetBackdropStyle", + "GRAY_FONT_COLOR", + "GameTooltip_Hide", + "GameTooltip_AddErrorLine", + "SELECTED_CHAT_FRAME", + "GameFontNormal", + "GameFontHighlight", + "InterfaceOptions_AddCategory", + "GameFontHighlightLarge", + "GameFontHighlightSmall", + "CLOSE", + "PanelTemplates_TabResize", + "PanelTemplates_SetDisabledTabState", + "PanelTemplates_SelectTab", + "PanelTemplates_DeselectTab", + "SetDesaturation", + "OpacitySliderFrame", + "ChatFontNormal", + "OKAY", + "NOT_BOUND", + "GameFontDisableSmall", + "GameFontNormalSmall", + "BACKDROP_SLIDER_8_8", + "IGNORE", + "FACTION", + "CUSTOM", + "COMMAND", + "RESET_POSITION", + "HELP_LABEL", + "HISTORY", + "TitanUtils_*", + "NAME", + "_G", + "getfenv", + "CreateFrame", + "error", + "ipairs", + "pcall", + "string", + "tostring", + "type", + "UIParent", + "GameTooltip", + "IsShiftKeyDown", + "IsAltKeyDown", + "IsControlKeyDown", + "table", + "pairs", + "print", + "math", + "tonumber", + "C_PvP", + "C_AddOns", + "GetCursorPosition", + "UnitName", + "GetCVar", + "GetScreenWidth", + "GetPhysicalScreenSize", + "Constants", + "C_Container", + "GetInventoryItemLink", + "GetItemInfoInstant", + "format", + "GetRealmName", + "floor", + "mod", + "date", + "C_PetBattles", + "ID", + "UIParent_ManageFramePositions" + ] + } +} \ No newline at end of file diff --git a/Titan/Titan.lua b/Titan/Titan.lua index c2bce35..1984fb3 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ File NAME: TitanPanel.lua DESC: Contains the basic routines of Titan. All the event handler routines, initialization routines, Titan menu routines, and select plugin handler routines. @@ -7,15 +8,9 @@ DESC: Contains the basic routines of Titan. All the event handler routines, init local TPC = TITAN_PANEL_CONSTANTS -- shortcut local TITAN_PANEL_BUTTONS_INIT_FLAG = nil; -local TITAN_PANEL_FROM_TOP = -25; -local TITAN_PANEL_FROM_BOTTOM = 25; -local TITAN_PANEL_FROM_BOTTOM_MAIN = 1; -local TITAN_PANEL_FROM_TOP_MAIN = 1; - -local _G = getfenv(0); +local _G = _G --getfenv(0); local InCombatLockdown = _G.InCombatLockdown; local IsTitanPanelReset = nil; -local new_toon = false -- Library references local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -30,7 +25,7 @@ local AceConfigDialog = LibStub("AceConfigDialog-3.0") function TitanPanel_OkToReload() StaticPopupDialogs["TITAN_RESET_RELOAD"] = { text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) - .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], + .. "\n\n" .. L["TITAN_PANEL_RESET_WARNING"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) @@ -56,7 +51,7 @@ NOTE: function TitanPanel_ResetToDefault() StaticPopupDialogs["TITAN_RESET_BAR"] = { text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) - .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], + .. "\n\n" .. L["TITAN_PANEL_RESET_WARNING"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) @@ -82,7 +77,7 @@ NOTE: :NOTE --]] function TitanPanel_SaveCustomProfile() - -- Create the dialog box code we'll need... + -- Create the dialog box code we'll need... -- helper to actually write the profile to the Titan saved vars local function Write_profile(name) @@ -91,7 +86,7 @@ function TitanPanel_SaveCustomProfile() TitanSettings.Players[profileName] = TitanSettings.Players[currentprofilevalue] TitanPrint(L["TITAN_PANEL_MENU_PROFILE_SAVE_PENDING"] - .."'"..name.."'" + .. "'" .. name .. "'" , "info") end -- helper to ask the user to overwrite a profile @@ -106,10 +101,10 @@ function TitanPanel_SaveCustomProfile() local function Get_profile_name(self) local rawprofileName = self.editBox:GetText(); -- remove any spaces the user may have typed in the name - local conc2profileName = string.gsub( rawprofileName, " ", "" ); + local conc2profileName = string.gsub(rawprofileName, " ", ""); if conc2profileName == "" then return; end -- no '@' is allowed or it will mess with the Titan profile naming convention - local concprofileName = string.gsub( conc2profileName, TITAN_AT, "-" ); + local concprofileName = string.gsub(conc2profileName, TITAN_AT, "-"); local profileName = TitanUtils_CreateName(concprofileName, TITAN_CUSTOM_PROFILE_POSTFIX) if TitanSettings.Players[profileName] then -- Warn the user of an existing profile @@ -126,8 +121,8 @@ function TitanPanel_SaveCustomProfile() -- Dialog box to warn the user that the UI will be reloaded -- This ensures the profile is written to disk StaticPopupDialogs["TITAN_RELOADUI"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_MENU_PROFILE_RELOADUI"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_MENU_PROFILE_RELOADUI"], button1 = "OKAY", OnAccept = function(self) ReloadUI(); -- ensure profile is written to disk @@ -139,8 +134,8 @@ function TitanPanel_SaveCustomProfile() -- Dialog box to warn the user that an existing profile will be overwritten. StaticPopupDialogs["TITAN_OVERWRITE_CUSTOM_PROFILE"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_MENU_PROFILE_ALREADY_EXISTS"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_MENU_PROFILE_ALREADY_EXISTS"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self, data) @@ -156,8 +151,8 @@ function TitanPanel_SaveCustomProfile() -- Dialog box to save the profile. StaticPopupDialogs["TITAN_SAVE_CUSTOM_PROFILE"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_MENU_PROFILE_SAVE_CUSTOM_TITLE"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_MENU_PROFILE_SAVE_CUSTOM_TITLE"], button1 = ACCEPT, button2 = CANCEL, hasEditBox = 1, @@ -175,7 +170,7 @@ function TitanPanel_SaveCustomProfile() EditBoxOnEnterPressed = function(self) -- We need to get the parent because self refers to the edit box. Get_profile_name(self:GetParent()) - end, + end, EditBoxOnEscapePressed = function(self) self:GetParent():Hide(); end, @@ -188,10 +183,9 @@ function TitanPanel_SaveCustomProfile() StaticPopup_Show("TITAN_SAVE_CUSTOM_PROFILE"); -- Can NOT cleanup. Execution does not stop when a dialog box is invoked! --- StaticPopupDialogs["TITAN_RELOADUI"] = {} --- StaticPopupDialogs["TITAN_OVERWRITE_CUSTOM_PROFILE"] = {} --- StaticPopupDialogs["TITAN_SAVE_CUSTOM_PROFILE"] = {} - + -- StaticPopupDialogs["TITAN_RELOADUI"] = {} + -- StaticPopupDialogs["TITAN_OVERWRITE_CUSTOM_PROFILE"] = {} + -- StaticPopupDialogs["TITAN_SAVE_CUSTOM_PROFILE"] = {} end --[[ Titan @@ -208,23 +202,24 @@ function TitanSetPanelFont(fontname, fontsize) -- a couple of arg checks to avoid unpleasant things... if not fontname then fontname = TPC.FONT_NAME end if not fontsize then fontsize = TPC.FONT_SIZE end - local index,id; local newfont = media:Fetch("font", fontname) for index, id in pairs(TitanPluginsIndex) do - local button = TitanUtils_GetButton(id); - local buttonText = _G[button:GetName()..TITAN_PANEL_TEXT]; - if buttonText then - buttonText:SetFont(newfont, fontsize); - end - -- account for plugins with child buttons - local childbuttons = {button:GetChildren()}; - for _, child in ipairs(childbuttons) do - if child then - local bname = _G[child:GetName()] - if bname then - local childbuttonText = _G[child:GetName()..TITAN_PANEL_TEXT]; - if childbuttonText then - childbuttonText:SetFont(newfont, fontsize); + local button = TitanUtils_GetButton(id) + if button then + local buttonText = _G[button:GetName() .. TITAN_PANEL_TEXT]; + if buttonText then + buttonText:SetFont(newfont, fontsize); + end + -- account for plugins with child buttons + local childbuttons = { button:GetChildren() }; + for _, child in ipairs(childbuttons) do + if child then + local bname = _G[child:GetName()] + if bname then + local childbuttonText = _G[child:GetName() .. TITAN_PANEL_TEXT]; + if childbuttonText then + childbuttonText:SetFont(newfont, fontsize); + end end end end @@ -238,72 +233,22 @@ local function RegisterForEvents() -- show / hide of Bars before the Bars can be initialized... _G[TITAN_PANEL_CONTROL]:RegisterEvent("CVAR_UPDATE"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_LOGOUT"); - + -- For the pet battle - for now we'll hide the Titan bars... -- Cannot seem to move the 'top' part of the pet battle frame. _G[TITAN_PANEL_CONTROL]:RegisterEvent("PET_BATTLE_OPENING_START"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PET_BATTLE_CLOSE"); - + -- Hide Titan bars in combat (global or per bar); may be useful when using Short bars _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_ENABLED"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_DISABLED"); - + -- User request to hide Top bar(s) in BG or arena; more areas later? _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED_INDOORS"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED_NEW_AREA"); end ---[[ local -NAME: TitanPanel_CreateABar -DESC: Helper to add scripts to the Titan bar passed in. -VAR: frame - The frame name (string) of the Titan bar to create -OUT: None -NOTE: -- This also creates the hider bar in case the user want to use auto hide. -:NOTE ---]] -local function TitanPanel_CreateABar(frame) - if frame then - local bar_name = TitanBarData[frame].name - local bar_width = TitanBarData[frame].width - - if bar_name then - -- Set script handlers for display - _G[frame]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - _G[frame]:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) - _G[frame]:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) - _G[frame]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - _G[frame]:SetWidth(bar_width) - - local hide_name = TitanBarData[frame].hider - if hide_name then - -- Set script handlers for display - _G[hide_name]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - _G[hide_name]:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) - _G[hide_name]:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) - _G[hide_name]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - _G[hide_name]:SetFrameStrata("BACKGROUND") - _G[hide_name]:SetWidth(bar_width) - _G[hide_name]:SetHeight(TITAN_PANEL_BAR_HEIGHT/2); - end - - -- Set the display bar - local container = _G[frame] - container:SetHeight(TITAN_PANEL_BAR_HEIGHT); - -- Set local identifier - local container_text = _G[frame.."_Text"] - if container_text then -- was used for debug/creating of the independent bars - container_text:SetText(tostring(bar_name)) - -- for now show it - container:Show() - end - end - else - end -end - -------------------------------------------------------------- _G[TITAN_PANEL_CONTROL]:RegisterEvent("ADDON_LOADED"); -- @@ -324,7 +269,7 @@ NOTE: :NOTE --]] function TitanPanel_PlayerEnteringWorld(reload) ---[[ + --[[ print("PEW" .." "..tostring(Titan__InitializedPEW).."" ) @@ -333,7 +278,7 @@ print("PEW" -- Currently no additional steps needed else -- Get Profile and Saved Vars - new_toon = TitanVariables_InitTitanSettings(); + TitanVariables_InitTitanSettings(); if TitanAllGetVar("Silenced") then -- No header output else @@ -355,25 +300,28 @@ print("PEW" TitanPanelBottomAnchor:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0); -- Ensure the bars are created before the plugins are registered. - for idx, v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do TitanPanelButton_CreateBar(idx) end --- Titan_AutoHide_Create_Frames() - - local realmName = GetRealmName() - - if ServerTimeOffsets[realmName] then - TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", ServerTimeOffsets[realmName]) - elseif TitanGetVar(TITAN_CLOCK_ID, "OffsetHour") then - ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour") - end + -- Titan_AutoHide_Create_Frames() + + -- Set clock vars based on user setting + if TitanPlugins["Clock"] then + local realmName = GetRealmName() + if ServerTimeOffsets[realmName] then + TitanSetVar("Clock", "OffsetHour", ServerTimeOffsets[realmName]) + elseif TitanGetVar("Clock", "OffsetHour") then + ServerTimeOffsets[realmName] = TitanGetVar("Clock", "OffsetHour") + end - if ServerHourFormat[realmName] then - TitanSetVar(TITAN_CLOCK_ID, "Format", ServerHourFormat[realmName]) - elseif TitanGetVar(TITAN_CLOCK_ID, "Format") then - ServerHourFormat[realmName] = TitanGetVar(TITAN_CLOCK_ID, "Format") + if ServerHourFormat[realmName] then + TitanSetVar("Clock", "Format", ServerHourFormat[realmName]) + elseif TitanGetVar("Clock", "Format") then + ServerHourFormat[realmName] = TitanGetVar("Clock", "Format") + end end + --[[ With user able to move the UI around and short bars, remove this feature -- Check to see if we should kill off the OrderHallCommandBar if not TitanAllGetVar("OrderHall") then local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0") @@ -390,12 +338,12 @@ print("PEW" local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0") TitanPanelAce:Unhook("OrderHall_CheckCommandBar") end - +--]] -- Should be safe to register for events that could show / hide Bars RegisterForEvents() end local _ = nil - TitanSettings.Player,_,_ = TitanUtils_GetPlayer() + TitanSettings.Player, _, _ = TitanUtils_GetPlayer() -- Some addons wait to create their LDB component or a Titan addon could -- create additional buttons as needed. -- So we need to sync their variables and set them up @@ -412,7 +360,7 @@ print("PEW" if isfontvalid then TitanSetPanelFont(TitanPanelGetVar("FontName"), TitanPanelGetVar("FontSize")) else - -- if the selected font is not valid, revert to default (Friz Quadrata TT) + -- if the selected font is not valid, revert to default (Friz Quadrata TT) TitanPanelSetVar("FontName", TPC.FONT_NAME); TitanSetPanelFont(TPC.FONT_NAME, TitanPanelGetVar("FontSize")) end @@ -444,9 +392,9 @@ end local WoWClassicEra, WoWClassicTBC, WoWWOTLKC, WoWRetail if wowversion < 20000 then WoWClassicEra = true - elseif wowversion < 30000 then + elseif wowversion < 30000 then WoWClassicTBC = true - elseif wowversion < 40000 then + elseif wowversion < 40000 then WoWWOTLKC = true elseif wowversion > 90000 then WoWRetail = true @@ -456,14 +404,14 @@ end --]===] function TitanPanelBarButton:ADDON_LOADED(addon) if addon == TITAN_ID then ---[[ + --[[ print("ADDON_LOADED" .." "..tostring(addon).."" ) --]] - _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD") - TitanVariables_InitTitanSettings() -- Min table setup to start. ---[===[ + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD") + TitanVariables_InitTitanSettings() -- Min table setup to start. + --[===[ -- Determine WoW TOC Version local wowversion = select(4, GetBuildInfo()) if wowversion >= 100000 then -- Initialize Titan @@ -491,7 +439,7 @@ function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2) local call_success = nil local ret_val = nil ---[[ + --[[ print("PLAYER_ENTERING_WORLD" .." "..tostring(arg1).."" .." "..tostring(arg2).."" @@ -499,11 +447,11 @@ print("PLAYER_ENTERING_WORLD" --]] call_success, -- needed for pcall ret_val = -- actual return values - pcall (TitanPanel_PlayerEnteringWorld, arg2) + pcall(TitanPanel_PlayerEnteringWorld, arg2) -- pcall does not allow errors to propagate out. Any error -- is returned as text with the success / fail. -- Think of it as a try - catch block ---[[ + --[[ print("_PlayerEnteringWorld" .." "..tostring(call_success).."" ) @@ -513,7 +461,7 @@ print("_PlayerEnteringWorld" else -- something really bad occured... TitanPrint("Titan could not initialize!!!! Cleaning up...", "error") - TitanPrint("--"..ret_val, "error") + TitanPrint("--" .. ret_val, "error") -- Clean up best we can and tell the user to submit a ticket. -- This could be the 1st log in or a reload (reload, instance, boat, ...) @@ -534,10 +482,10 @@ end function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) if cvarname == "USE_UISCALE" - or cvarname == "WINDOWED_MODE" - or cvarname == "uiScale" then + or cvarname == "WINDOWED_MODE" + or cvarname == "uiScale" then if TitanPlayerSettings and TitanPanelGetVar("Scale") then - TitanPanel_InitPanelBarButton("CVAR_ "..tostring(cvarname)) + TitanPanel_InitPanelBarButton("CVAR_ " .. tostring(cvarname)) if TITAN_ID == "TitanClassic" then -- Adjust frame positions TitanPanel_AdjustFrames("PLAYER_REGEN_ENABLED") @@ -557,7 +505,7 @@ function TitanPanelBarButton:PLAYER_LOGOUT() TitanPanelRegister.TitanPlugins = TitanPlugins end end - Titan__InitializedPEW = nil + Titan__InitializedPEW = false end function TitanPanelBarButton:ZONE_CHANGED() @@ -597,26 +545,28 @@ function TitanPanelBarButton:PLAYER_REGEN_DISABLED() in_combat = true TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_DISABLED") end --- if TITAN_ID == "TitanClassic" then -function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED() - TitanMovable_AdjustTimer("DualSpec") -end + function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED() + -- Is this needed?? + -- TitanMovable_AdjustTimer("DualSpec") + end + + function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...) + TitanUtils_CloseAllControlFrames(); + TitanUtils_CloseRightClickMenu(); -function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...) - TitanUtils_CloseAllControlFrames(); - TitanUtils_CloseRightClickMenu(); + -- Needed because 8.0 made changes to the menu bar processing (see TitanMovable) + TitanMovable_MenuBar_Disable() + end - -- Needed because 8.0 made changes to the menu bar processing (see TitanMovable) - TitanMovable_MenuBar_Disable() -end -function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...) - -- A combat check will be done inside the adjust - TitanPanel_AdjustFrames(true) -end ---]] --- + function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...) + -- A combat check will be done inside the adjust + TitanPanel_AdjustFrames(true) + end + + --]] + -- else -- No need end @@ -634,7 +584,7 @@ NOTE: --]] function TitanPanelBarButton_OnClick(self, button) -- ensure that the right-click menu will not appear on "hidden" bottom bar(s) ---[[ + --[[ print("_OnClick" .." "..tostring(bar).."" ) @@ -664,10 +614,10 @@ NOTE: --]] local function TitanPanel_ParseSlashCmd(cmd) local words = {} - for w in string.gmatch (cmd, "%w+") do - words [#words + 1] = (w and string.lower(w) or "?") + for w in string.gmatch(cmd, "%w+") do + words[#words + 1] = (w and string.lower(w) or "?") end ---[[ + --[[ local tmp = "" for idx,v in pairs (words) do tmp = tmp.."'"..words[idx].."' " @@ -752,6 +702,7 @@ local function handle_reset_cmds(cmd_list) TitanPanelSetVar("TooltipFont", 1); GameTooltip:SetScale(TitanPanelGetVar("TooltipFont")); TitanPrint(L["TITAN_PANEL_SLASH_RESP1"], "info") + --[[ elseif p1 == "tipalpha" then TitanPanelSetVar("TooltipTrans", 1); local red, green, blue, _ = GameTooltip:GetBackdropColor(); @@ -759,6 +710,7 @@ local function handle_reset_cmds(cmd_list) GameTooltip:SetBackdropColor(red,green,blue,TitanPanelGetVar("TooltipTrans")); GameTooltip:SetBackdropBorderColor(red2,green2,blue2,TitanPanelGetVar("TooltipTrans")); TitanPrint(L["TITAN_PANEL_SLASH_RESP2"], "info") +--]] elseif p1 == "panelscale" then if not InCombatLockdown() then TitanPanelSetVar("Scale", 1); @@ -796,10 +748,9 @@ local function handle_giu_cmds(cmd_list) return end --- DF changed how options are called. The best I get is the Titan 'about', not deeper. + -- DF changed how options are called. The best I get is the Titan 'about', not deeper. Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About, TITAN_PANEL_CONFIG.topic.scale) --- so the below does not work as expected... - + -- so the below does not work as expected... end --[[ local @@ -845,10 +796,10 @@ local function handle_silent_cmds(cmd_list) if TitanAllGetVar("Silenced") then TitanAllSetVar("Silenced", false); - TitanPrint(L["TITAN_PANEL_MENU_SILENT_LOAD"].." ".. L["TITAN_PANEL_MENU_DISABLED"], "info") + TitanPrint(L["TITAN_PANEL_MENU_SILENT_LOAD"] .. " " .. L["TITAN_PANEL_MENU_DISABLED"], "info") else TitanAllSetVar("Silenced", true); - TitanPrint(L["TITAN_PANEL_MENU_SILENT_LOAD"].." ".. L["TITAN_PANEL_MENU_ENABLED"], "info") + TitanPrint(L["TITAN_PANEL_MENU_SILENT_LOAD"] .. " " .. L["TITAN_PANEL_MENU_ENABLED"], "info") end end @@ -868,15 +819,15 @@ local function handle_orderhall_cmds(cmd_list) if TitanAllGetVar("OrderHall") then TitanAllSetVar("OrderHall", false); - TitanPrint(L["TITAN_PANEL_MENU_HIDE_ORDERHALL"].." ".. L["TITAN_PANEL_MENU_ENABLED"], "info") + TitanPrint(L["TITAN_PANEL_MENU_HIDE_ORDERHALL"] .. " " .. L["TITAN_PANEL_MENU_ENABLED"], "info") StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_RELOAD"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) ReloadUI(); - end, + end, showAlert = 1, timeout = 0, whileDead = 1, @@ -885,15 +836,15 @@ local function handle_orderhall_cmds(cmd_list) StaticPopup_Show("TITAN_RELOAD"); else TitanAllSetVar("OrderHall", true); - TitanPrint(L["TITAN_PANEL_MENU_HIDE_ORDERHALL"].." ".. L["TITAN_PANEL_MENU_DISABLED"], "info") + TitanPrint(L["TITAN_PANEL_MENU_HIDE_ORDERHALL"] .. " " .. L["TITAN_PANEL_MENU_DISABLED"], "info") StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_RELOAD"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) ReloadUI(); - end, + end, showAlert = 1, timeout = 0, whileDead = 1, @@ -952,9 +903,7 @@ local function TitanPanel_RegisterSlashCmd(cmd_str) end end --------------------------------------------------------------- --- --- Register slash commands for Titan Panel +--====== Register slash commands for Titan Panel SlashCmdList["TitanPanel"] = TitanPanel_RegisterSlashCmd; SLASH_TitanPanel1 = "/titanpanel"; SLASH_TitanPanel2 = "/titan"; @@ -963,8 +912,7 @@ SLASH_TitanPanel2 = "/titan"; -- -- Texture routines local function Set_Color(frame, tex, color) - ---[[ + --[[ print("_Set bar color" .." "..tostring(TitanBarData[frame].tex_name).."" --.." "..tostring(tex:GetName()).."" @@ -975,13 +923,13 @@ print("_Set bar color" ) --]] _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", + 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 }, + -- insets = { left = 1, right = 1, top = 1, bottom = 1 }, tileSize = 8, edgeSize = 8, }) @@ -995,7 +943,7 @@ print("_Set bar color" color.g, color.b, color.alpha); ---[[ + --[[ -- Apply the texture to the bar, using the system repeat to fill it tex:SetColorTexture( color.r, @@ -1015,7 +963,7 @@ local function Set_Skin(frame, tex, skin) -- skins are in two parts - top & bottom... -- TODO : have Short bars choose top or bottom skin?? local edge = "" - if TitanBarData[frame].vert == TITAN_BOTTOM + if TitanBarData[frame].vert == TITAN_BOTTOM then edge = TITAN_BOTTOM else @@ -1023,8 +971,8 @@ local function Set_Skin(frame, tex, skin) end -- Apply the texture to the bar, using the system repeat to fill it - local texture_file = skin.path.."TitanPanelBackground"..edge.."0" ---[[ + local texture_file = skin.path .. "TitanPanelBackground" .. edge .. "0" + --[[ print("_Skin" .." "..tostring(TitanBarData[frame].tex_name.."" --.." "..tostring(tex:GetName()).."" @@ -1034,7 +982,7 @@ print("_Skin" --.."\n "..tostring(tex:GetTexture()).."" ) --]] ---[[ -- appears seeting image this way just smears image... + --[[ -- appears seeting image this way just smears image... _G[frame]:SetBackdrop({ bgFile=texture_file, -- edgeFile=nil, @@ -1045,12 +993,12 @@ print("_Skin" -- 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: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 @@ -1063,6 +1011,7 @@ function TitanPanel_SetBarTexture(frame) -- Create the path & file name to the texture local tex = TitanBarData[frame].tex_name + local titanTexture = {} if _G[tex] then titanTexture = _G[tex] else @@ -1070,10 +1019,10 @@ function TitanPanel_SetBarTexture(frame) end titanTexture:SetTexture() _G[frame]:SetBackdrop({ - bgFile="", + bgFile = "", }) - ---[[ + + --[[ print("_Tex" .." "..tostring(TitanBarData[frame].name).."" --.." "..tostring(tex).."" @@ -1087,13 +1036,13 @@ print("_Tex" ) --]] -- Use the texture / skin per user selectable options - if TitanBarDataVars["Global"].texure == Titan_Panel.SKIN then + if TitanBarDataVars["Global"].texure == Titan_Global.SKIN then Set_Skin(frame, titanTexture, TitanBarDataVars["Global"].skin) -- tex_path = TitanPanelGetVar("TexturePath") - elseif TitanBarDataVars["Global"].texure == Titan_Panel.COLOR then + elseif TitanBarDataVars["Global"].texure == Titan_Global.COLOR then Set_Color(frame, titanTexture, TitanBarDataVars["Global"].color) - elseif TitanBarDataVars[frame].texure == Titan_Panel.SKIN then + elseif TitanBarDataVars[frame].texure == Titan_Global.SKIN then Set_Skin(frame, titanTexture, TitanBarDataVars[frame].skin) - elseif TitanBarDataVars[frame].texure == Titan_Panel.COLOR then + elseif TitanBarDataVars[frame].texure == Titan_Global.COLOR then Set_Color(frame, titanTexture, TitanBarDataVars[frame].color) end end @@ -1113,7 +1062,7 @@ function TitanPanelBarButton_OnLeave(self) -- if auto hide is active then let the timer hide the bar local hide = (bar and TitanBarDataVars[frame].auto_hide or nil) --- local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) + -- local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) if hide then Titan_AutoHide_Timers(frame, "Leave") end @@ -1158,7 +1107,7 @@ function TitanPanelBarButtonHider_OnEnter(self) -- find the relevant bar data local frame = nil - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do if index == TitanBarData[idx].hider then frame = idx end @@ -1170,9 +1119,7 @@ function TitanPanelBarButtonHider_OnEnter(self) end end --------------------------------------------------------------- --- --- Titan Frames for CLASSIC versions +--====== Titan Frames for CLASSIC versions -- --========================== @@ -1186,7 +1133,7 @@ OUT: None --]] function TitanPanelBarButton_ToggleAlign(align) -- toggle between left or center - if ( TitanPanelGetVar(align) == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then + if (TitanPanelGetVar(align) == TITAN_PANEL_BUTTONS_ALIGN_CENTER) then TitanPanelSetVar(align, TITAN_PANEL_BUTTONS_ALIGN_LEFT); else TitanPanelSetVar(align, TITAN_PANEL_BUTTONS_ALIGN_CENTER); @@ -1240,11 +1187,7 @@ function TitanPanelBarButton_ToggleAuxScreenAdjust() TitanPanel_AdjustFrames(true) end - --------------------------------------------------------------- --- --- Titan Bar - +--====== Titan Bar -- --========================== -- Routines to handle moving and sizing of short bars @@ -1259,22 +1202,22 @@ OUT: None local function CheckBarBounds(self, width) local trace = false -- true false local result = {} - result.ok = true - result.err = "" + result.ok = true + result.err = "" local err = "" local f_name = self:GetName() local bar_name = TitanBarData[f_name].name local locale_name = TitanBarData[f_name].locale_name local escale = UIParent:GetEffectiveScale() - - if TitanBarData[f_name].user_move - and TitanBarDataVars[f_name].show + + if TitanBarData[f_name].user_move + and TitanBarDataVars[f_name].show then if trace then print("Bounds" - .." "..tostring(bar_name).."" - .." "..tostring(width).."" + .. " " .. tostring(bar_name) .. "" + .. " " .. tostring(width) .. "" ) end @@ -1287,8 +1230,8 @@ local function CheckBarBounds(self, width) local screen_right_t = screen.x * tscale local screen_top_t = screen.y * tscale - - -- Apply the Titan scaling to get 'real' position within WoW window; + + -- Apply the Titan scaling to get 'real' position within WoW window; -- Use floor to trunc decimal places where the side could be right on the edge of the screen. local orig_w = self:GetWidth() -- * tscale --math.floor(self:GetWidth() * tscale) local l_off = math.floor(self:GetLeft() * tscale) @@ -1299,25 +1242,25 @@ local function CheckBarBounds(self, width) if trace then print(">Bounds" - .."\n" - .." L "..tostring(format("%0.1f", l_off)).."" - .." R "..tostring(format("%0.1f", r_off)).."" - .." T "..tostring(format("%0.1f", t_off)).."" - .." B "..tostring(format("%0.1f", b_off)).."" - .." W "..tostring(format("%0.1f", orig_w)).."" - .." H "..tostring(format("%0.1f", hght)).."" - .."\n" - .." SR "..tostring(format("%0.1f", screen_right)).."" - .." ST "..tostring(format("%0.1f", screen_top)).."" - .." SR_t "..tostring(format("%0.1f", screen_right_t)).."" - .." ST_t "..tostring(format("%0.1f", screen_top_t)).."" + .. "\n" + .. " L " .. tostring(format("%0.1f", l_off)) .. "" + .. " R " .. tostring(format("%0.1f", r_off)) .. "" + .. " T " .. tostring(format("%0.1f", t_off)) .. "" + .. " B " .. tostring(format("%0.1f", b_off)) .. "" + .. " W " .. tostring(format("%0.1f", orig_w)) .. "" + .. " H " .. tostring(format("%0.1f", hght)) .. "" + .. "\n" + .. " SR " .. tostring(format("%0.1f", screen_right)) .. "" + .. " ST " .. tostring(format("%0.1f", screen_top)) .. "" + .. " SR_t " .. tostring(format("%0.1f", screen_right_t)) .. "" + .. " ST_t " .. tostring(format("%0.1f", screen_top_t)) .. "" ) end - local w = 0 - local x_off = 0 - local y_off = 0 - local w_off = 0 + local w = 0 + local x_off = 0 + local y_off = 0 + local w_off = 0 -- Assume all ok :) x_off = l_off @@ -1332,7 +1275,7 @@ local function CheckBarBounds(self, width) if l_off < 0 then x_off = 0 - err = "Off left of screen, snap to edge" + err = "Off left of screen, snap to edge" elseif (r_off) > screen_right then x_off = math.floor(screen_right - (r_off - l_off)) err = "Off right side of screen, snap to edge" @@ -1341,7 +1284,7 @@ local function CheckBarBounds(self, width) result.ok = false result.err = err if trace then - TitanPrint(locale_name.." "..err.."!!!!" + TitanPrint(locale_name .. " " .. err .. "!!!!" , "warning") end end @@ -1355,18 +1298,18 @@ local function CheckBarBounds(self, width) end if err ~= "" then result.ok = false - result.err = result.err.."\n"..err + result.err = result.err .. "\n" .. err if trace then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - , "warning") + TitanPrint(locale_name .. " " .. err .. "!!!!" + .. " [" .. tostring(format("%0.1f", x_off)) .. "]" + .. " [" .. tostring(format("%0.1f", y_off)) .. "]" + , "warning") end end else -- width change local min_w, min_h, max_w, max_h = self:GetResizeBounds() -- Keep the X and Y - w_new = orig_w + width + local w_new = orig_w + width if w_new < min_w then -- do nothing - too small w_off = min_w @@ -1382,27 +1325,27 @@ local function CheckBarBounds(self, width) end self:SetSize(w_off, TITAN_PANEL_BAR_HEIGHT) --- self:SetWidth(w_off) + -- self:SetWidth(w_off) end - -- Back out Titan scaling + -- Back out Titan scaling x_off = x_off / tscale y_off = y_off / tscale w_off = w_off --/ tscale TitanVariables_SetBarPos(self, false, x_off, y_off, w_off) - + if trace then print(">>Bounds" - .." "..tostring(result.ok).."" - .." X "..tostring(format("%0.1f", x_off)).."" - .." Y "..tostring(format("%0.1f", y_off)).."" - .." W "..tostring(format("%0.1f", w_off)).."" + .. " " .. tostring(result.ok) .. "" + .. " X " .. tostring(format("%0.1f", x_off)) .. "" + .. " Y " .. tostring(format("%0.1f", y_off)) .. "" + .. " W " .. tostring(format("%0.1f", w_off)) .. "" ) if err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - .." ["..tostring(format("%0.1f", w_off)).."]" + TitanPrint(locale_name .. " " .. err .. "!!!!" + .. " [" .. tostring(format("%0.1f", x_off)) .. "]" + .. " [" .. tostring(format("%0.1f", y_off)) .. "]" + .. " [" .. tostring(format("%0.1f", w_off)) .. "]" , "warning") end end @@ -1439,11 +1382,10 @@ VAR: self - the bar frame OUT: None --]] local function OnMovingStop(self) - self:StopMovingOrSizing() self.isMoving = nil - local res = CheckBarBounds(self, 0) + local res = CheckBarBounds(self, 0) if res.ok then -- placement ok else @@ -1475,7 +1417,7 @@ local function OnMouseWheel(self, d) local res = CheckBarBounds(self, delta) if res.ok then end ---[[ + --[[ print("wheel" .." "..tostring(self:GetName()).."" .." "..tostring(d).."" @@ -1484,7 +1426,7 @@ print("wheel" .." ok: "..tostring(res.ok).."" ) --]] --- TitanPanel_InitPanelBarButton("OnMouseWheel") + -- TitanPanel_InitPanelBarButton("OnMouseWheel") end end @@ -1495,27 +1437,29 @@ VAR: None OUT: None --]] function TitanPanelBarButton_ForceLDBLaunchersRight() - local plugin, index, id; + local plugin = {} for index, id in pairs(TitanPluginsIndex) do plugin = TitanUtils_GetPlugin(id); - if plugin.ldb == "launcher" - and not TitanGetVar(id, "DisplayOnRightSide") then + if plugin and plugin.ldb == "launcher" + and not TitanGetVar(id, "DisplayOnRightSide") then TitanToggleVar(id, "DisplayOnRightSide"); - local button = TitanUtils_GetButton(id); - local buttonText = _G[button:GetName()..TITAN_PANEL_TEXT]; - if not TitanGetVar(id, "ShowIcon") then - TitanToggleVar(id, "ShowIcon"); - end - TitanPanelButton_UpdateButton(id); - if buttonText then - buttonText:SetText("") - button:SetWidth(16); - TitanPlugins[id].buttonTextFunction = nil; - _G[TitanUtils_ButtonName(id)..TITAN_PANEL_TEXT] = nil; - if button:IsVisible() then - local bar = TitanUtils_GetWhichBar(id) - TitanPanel_RemoveButton(id); - TitanUtils_AddButtonOnBar(bar, id) + local button = TitanUtils_GetButton(id) + if button then + local buttonText = _G[button:GetName() .. TITAN_PANEL_TEXT]; + if not TitanGetVar(id, "ShowIcon") then + TitanToggleVar(id, "ShowIcon"); + end + TitanPanelButton_UpdateButton(id); + if buttonText then + buttonText:SetText("") + button:SetWidth(16); + TitanPlugins[id].buttonTextFunction = nil; + _G[TitanUtils_ButtonName(id) .. TITAN_PANEL_TEXT] = nil; + if button:IsVisible() then + local bar = TitanUtils_GetWhichBar(id) + TitanPanel_RemoveButton(id); + TitanUtils_AddButtonOnBar(bar, id) + end end end end @@ -1538,11 +1482,13 @@ local function TitanAnchors() anchor_top = anchor_top <= TITAN_WOW_SCREEN_TOP and anchor_top or TITAN_WOW_SCREEN_TOP anchor_bot = anchor_bot >= TITAN_WOW_SCREEN_BOT and anchor_bot or TITAN_WOW_SCREEN_BOT - local top_point, top_rel_to, top_rel_point, top_x, top_y = TitanPanelTopAnchor:GetPoint(TitanPanelTopAnchor:GetNumPoints()) - local bot_point, bot_rel_to, bot_rel_point, bot_x, bot_y = TitanPanelBottomAnchor:GetPoint(TitanPanelBottomAnchor:GetNumPoints()) + local top_point, top_rel_to, top_rel_point, top_x, top_y = TitanPanelTopAnchor:GetPoint(TitanPanelTopAnchor + :GetNumPoints()) + local bot_point, bot_rel_to, bot_rel_point, bot_x, bot_y = TitanPanelBottomAnchor:GetPoint(TitanPanelBottomAnchor + :GetNumPoints()) top_y = floor(tonumber(top_y) + 0.5) bot_y = floor(tonumber(bot_y) + 0.5) ---[[ + --[[ TitanDebug("Anc top: "..top_y.." bot: "..bot_y .." a_top: "..anchor_top.." a_bot: "..anchor_bot ) @@ -1550,12 +1496,10 @@ TitanDebug("Anc top: "..top_y.." bot: "..bot_y if top_y ~= anchor_top then TitanPanelTopAnchor:ClearAllPoints() TitanPanelTopAnchor:SetPoint(top_point, top_rel_to, top_rel_point, top_x, anchor_top); - end if bot_y ~= anchor_bot then TitanPanelBottomAnchor:ClearAllPoints() TitanPanelBottomAnchor:SetPoint(bot_point, bot_rel_to, bot_rel_point, bot_x, anchor_bot) - end end @@ -1569,12 +1513,12 @@ function TitanPanelBarButton_DisplayBarsWanted(reason) local trace = false if trace then print("_DisplayBarsWanted" - .." "..tostring(reason).."" + .. " " .. tostring(reason) .. "" ) end -- Check all bars to see if the user has requested they be shown - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do -- Show / hide plus kick auto hide, if needed Titan_AutoHide_Init(idx) end @@ -1601,50 +1545,50 @@ NOTE: :NOTE --]] function TitanPanelBarButton_HideAllBars() - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do TitanPanelBarButton_Hide(idx) end end local function showBar(frame_str) local flag = true -- only set false for known conditions - + if frame_str == TitanVariables_GetFrameName("Bar") - or frame_str == TitanVariables_GetFrameName("Bar2") + or frame_str == TitanVariables_GetFrameName("Bar2") then -- ===== Battleground or Arena : User selected if (TitanPanelGetVar("HideBarsInPVP")) - and (C_PvP.IsBattleground() - or C_PvP.IsArena() --- or GetZoneText() == "Stormwind City" --- or GetZoneText() == "Tempest Keep" + and (C_PvP.IsBattleground() + or C_PvP.IsArena() + -- or GetZoneText() == "Stormwind City" + -- or GetZoneText() == "Tempest Keep" ) then flag = false end end - + -- ===== In Combat : User selected if TitanBarDataVars[frame_str].hide_in_combat - or TitanPanelGetVar("HideBarsInCombat") then + or TitanPanelGetVar("HideBarsInCombat") then if in_combat then -- InCombatLockdown() too slow flag = false end end - + if TITAN_ID == "TitanClassic" then -- skip, no pet battles yet else - -- ===== In Pet Battle - if C_PetBattles.IsInBattle() then - if TitanBarData[frame_str].user_move then - -- leave as is - else - flag = false + -- ===== In Pet Battle + if C_PetBattles.IsInBattle() then + if TitanBarData[frame_str].user_move then + -- leave as is + else + flag = false + end end end - end ---[[ + --[[ print("showBar" --.." "..tostring(C_PetBattles.IsInBattle()).."" .." > "..tostring(flag).."" @@ -1658,24 +1602,24 @@ local function SetBar(frame) local trace = false local display = _G[frame]; --- local res = CheckBarBounds(display, 0) + -- local res = CheckBarBounds(display, 0) local x, y, w = TitanVariables_GetBarPos(frame) local tscale = TitanPanelGetVar("Scale") local show = TitanBarData[frame].show local bott = TitanBarData[frame].bott - - display:ClearAllPoints() + + display:ClearAllPoints() if trace then --- local screen = TitanUtils_ScreenSize() --- local sx = screen.scaled_x --- local sy = screen.scaled_y + -- local screen = TitanUtils_ScreenSize() + -- local sx = screen.scaled_x + -- local sy = screen.scaled_y print("SetBar" - .." "..tostring(TitanBarData[frame].name).."" - .." x:"..tostring(format("%0.1f", x)).."" - .." y:"..tostring(format("%0.1f", y)).."" - .." w:"..tostring(format("%0.1f", w)).."" + .. " " .. tostring(TitanBarData[frame].name) .. "" + .. " x:" .. tostring(format("%0.1f", x)) .. "" + .. " y:" .. tostring(format("%0.1f", y)) .. "" + .. " w:" .. tostring(format("%0.1f", w)) .. "" ) end @@ -1703,20 +1647,20 @@ function TitanPanelBarButton_Show(frame) if display and TitanBarData[frame].name then - if TitanBarDataVars[frame].show -- User requested - and showBar(frame) -- No preventing condition - then -- Place Bar + if TitanBarDataVars[frame].show -- User requested + and showBar(frame) -- No preventing condition + then -- Place Bar SetBar(frame) ----[[ + ---[[ -- The bar may need to be moved back onto the screen. - local res = CheckBarBounds(display, 0) + local res = CheckBarBounds(display, 0) if res.ok then -- placement ok else -- Need to 'snap' it to an edge SetBar(frame) end ---]] + --]] TitanPanel_SetBarTexture(frame) if TitanBarData[frame].hider then @@ -1755,7 +1699,7 @@ function TitanPanelBarButton_Hide(frame) display:ClearAllPoints() local h = (math.abs(y) + TITAN_PANEL_BAR_HEIGHT * 2) * (-1 * y) local h = data.hide_y ---[[ + --[[ print("_Hide" --.." "..tostring(frame).."" .." "..tostring(data.name).."" @@ -1772,15 +1716,15 @@ print("_Hide" if TitanBarData[frame].hider then local hider = _G[data.hider] - if TitanBarDataVars[frame].show - and TitanBarDataVars[frame].auto_hide then --- if (TitanPanelGetVar(data.name.."_Show")) and (TitanPanelGetVar(data.name.."_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(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, y); hider:Show() else - -- The bar was not requested + -- The bar was not requested hider:Hide() end else @@ -1809,7 +1753,7 @@ function TitanPanel_InitPanelButtons() -- Justify adjusts the left side start according to the user setting -- The effect is left side plugins has spacing on the right side and -- right side plugins have spacing on the left. - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do local bar = TitanBarData[idx].name local y_off = TitanBarData[idx].plugin_y_offset prior[bar] = { @@ -1818,73 +1762,75 @@ function TitanPanel_InitPanelButtons() anchor = "RIGHT", x = 5, -- Offset of first plugin to right side of screen y = y_off, - }, + }, left = { button = TitanVariables_GetFrameName(bar), anchor = "LEFT", x = 0, -- Justify adjusts - center or not y = y_off, - }, - } + }, + } end --- + -- TitanPanelBarButton_DisplayBarsWanted("TitanPanel_InitPanelButtons"); -- Position all the buttons for i = 1, table.maxn(TitanPanelSettings.Buttons) do - local id = TitanPanelSettings.Buttons[i]; - if ( TitanUtils_IsPluginRegistered(id) ) then + if (TitanUtils_IsPluginRegistered(id)) then local i = TitanPanel_GetButtonNumber(id); button = TitanUtils_GetButton(id); - -- If the plugin has asked to be on the right - if TitanUtils_ToRight(id) then - -- ========================= - -- position the plugin relative to the prior plugin - -- or the bar if it is the 1st - r_prior = prior[TitanPanelSettings.Location[i]].right - -- ========================= - button:ClearAllPoints(); - button:SetPoint("RIGHT", _G[r_prior.button]:GetName(), r_prior.anchor, (-(r_prior.x) * scale), r_prior.y); - - -- ========================= - -- capture the button for the next plugin - 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 - r_prior.y = 0 - -- ========================= - else - -- handle plugins on the left side of the bar - -- - -- ========================= - -- position the plugin relative to the prior plugin - -- or the bar if it is the 1st - l_prior = prior[TitanPanelSettings.Location[i]].left ---[===[ + if button then + -- If the plugin has asked to be on the right + if TitanUtils_ToRight(id) then + -- ========================= + -- position the plugin relative to the prior plugin + -- or the bar if it is the 1st + r_prior = prior[TitanPanelSettings.Location[i]].right + -- ========================= + button:ClearAllPoints(); + button:SetPoint("RIGHT", _G[r_prior.button]:GetName(), r_prior.anchor, (-(r_prior.x) * scale), + r_prior.y) + + -- ========================= + -- capture the button for the next plugin + 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 + r_prior.y = 0 + -- ========================= + else + -- handle plugins on the left side of the bar + -- + -- ========================= + -- 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(); - button:SetPoint("LEFT", _G[l_prior.button]:GetName(), l_prior.anchor, l_prior.x * scale, l_prior.y); - - -- ========================= - -- capture the next plugin - 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) - l_prior.y = 0 - -- ========================= + -- ========================= + -- + button:ClearAllPoints(); + button:SetPoint("LEFT", _G[l_prior.button]:GetName(), l_prior.anchor, l_prior.x * scale, l_prior.y); + + -- ========================= + -- capture the next plugin + 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) + l_prior.y = 0 + -- ========================= + end + button:Show() end - button:Show(); end end -- Set panel button init flag @@ -1900,7 +1846,7 @@ OUT: None --]] function TitanPanel_ReOrder(index) for i = index, table.getn(TitanPanelSettings.Buttons) do - TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i+1] + TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i + 1] end end @@ -1914,7 +1860,7 @@ NOTE: :NOTE --]] function TitanPanel_RemoveButton(id) - if ( not TitanPanelSettings ) then + if (not TitanPanelSettings) then return; end @@ -1922,11 +1868,11 @@ function TitanPanel_RemoveButton(id) local currentButton = TitanUtils_GetButton(id); -- safeguard ... - if id then AceTimer.CancelAllTimers("TitanPanel"..id) end + if id then AceTimer.CancelAllTimers("TitanPanel" .. id) end TitanPanel_ReOrder(i); table.remove(TitanPanelSettings.Buttons, TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons, id)); ---TitanDebug("_Remove: "..(id or "?").." "..(i or "?")) + --TitanDebug("_Remove: "..(id or "?").." "..(i or "?")) if currentButton then currentButton:Hide(); end @@ -1943,11 +1889,11 @@ OUT: index of the plugin in the Titan plugin list or the end of the list. The ro function TitanPanel_GetButtonNumber(id) if (TitanPanelSettings) then for i = 1, table.getn(TitanPanelSettings.Buttons) do - if(TitanPanelSettings.Buttons[i] == id) then + if (TitanPanelSettings.Buttons[i] == id) then return i; end end - return table.getn(TitanPanelSettings.Buttons)+1; + return table.getn(TitanPanelSettings.Buttons) + 1; else return 0; end @@ -1975,16 +1921,17 @@ OUT: None --]] function TitanPanelButton_Justify() -- Only the left side buttons are justified. - if ( not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings ) then + if (not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings) then return; end if InCombatLockdown() then ---TitanDebug("_Justify during combat!!!") + --TitanDebug("_Justify during combat!!!") return; -- Issue 856 where some taint is caused if the plugin size is updated during combat. Seems since Mists was released... end local bar + local x_offset local y_offset local firstLeftButton local scale = TitanPanelGetVar("Scale"); @@ -1997,25 +1944,26 @@ function TitanPanelButton_Justify() local center_offset = 0; -- Look at each bar for plugins. - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do bar = TitanBarData[idx].name y_offset = TitanBarData[idx].plugin_y_offset x_offset = TitanBarData[idx].plugin_x_offset - firstLeftButton = TitanUtils_GetButton(TitanPanelSettings.Buttons[TitanUtils_GetFirstButtonOnBar (bar, TITAN_LEFT)]) + firstLeftButton = TitanUtils_GetButton(TitanPanelSettings.Buttons + [TitanUtils_GetFirstButtonOnBar(bar, TITAN_LEFT)]) align = TitanBarDataVars[idx].align --TitanPanelGetVar(bar.."_Align") leftWidth = 0; rightWidth = 0; counter = 0; -- If there is a plugin on this bar then justify the first button. -- The other buttons are relative to the first. - if ( firstLeftButton ) then - if ( align == TITAN_PANEL_BUTTONS_ALIGN_LEFT ) then + if (firstLeftButton) then + if (align == TITAN_PANEL_BUTTONS_ALIGN_LEFT) then -- Now offset the plugins firstLeftButton:ClearAllPoints(); firstLeftButton:SetPoint("LEFT", idx, "LEFT", x_offset, y_offset); end -- Center if requested - if ( align == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then + if (align == TITAN_PANEL_BUTTONS_ALIGN_CENTER) then leftWidth = 0; rightWidth = 0; counter = 0; @@ -2040,7 +1988,7 @@ function TitanPanelButton_Justify() -- Now offset the plugins on the bar firstLeftButton:ClearAllPoints(); -- remove the last spacing otherwise the buttons appear justified too far left - center_offset = (0 - (leftWidth-button_spacing) / 2) + center_offset = (0 - (leftWidth - button_spacing) / 2) firstLeftButton:SetPoint("LEFT", idx, "CENTER", center_offset, y_offset); end end @@ -2050,7 +1998,6 @@ end -------------------------------------------------------------- -- -- Local routines for Titan menu creation - local R_ADDONS = "Addons_" local R_PLUGIN = "Plugin_" local R_SETTINGS = "Settings" @@ -2067,17 +2014,19 @@ local function BuildMainMenu(frame) local info = {}; ----------------- -- Menu title - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_TITLE"].." - "..locale_bar); + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_TITLE"] .. " - " .. locale_bar); TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PLUGINS"]); ----------------- -- Plugin Categories - for index, id in pairs(L["TITAN_PANEL_MENU_CATEGORIES"]) do + -- for index, id in pairs(L["TITAN_PANEL_MENU_CATEGORIES"]) do + for index = 1, 6, 1 do info = {}; info.notCheckable = true - info.text = L["TITAN_PANEL_MENU_CATEGORIES"][index]; + -- bit of a kludge but a decent way to handle something that rarely changes + info.text = L["TITAN_PANEL_MENU_CATEGORIES_" .. string.format("%02d", index)] info.value = R_ADDONS .. TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY[index]; info.hasArrow = 1; TitanPanelRightClickMenu_AddButton(info); @@ -2087,15 +2036,17 @@ local function BuildMainMenu(frame) ----------------- -- Options - just one button to open the first Titan option screen - info = {}; - info.notCheckable = true - info.text = L["TITAN_PANEL_MENU_CONFIGURATION"]; - info.value = "Bars"; - info.func = function() - TitanUpdateConfig("init") - Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About) + do + info = {}; + info.notCheckable = true + 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); end - TitanPanelRightClickMenu_AddButton(info); TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); @@ -2114,10 +2065,10 @@ local function BuildMainMenu(frame) if InCombatLockdown() then info.disabled = 1; info.hasArrow = nil; - info.text = info.text.." " - .._G["GREEN_FONT_COLOR_CODE"] - ..L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"]; - end + info.text = info.text .. " " + .. _G["GREEN_FONT_COLOR_CODE"] + .. L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"]; + end TitanPanelRightClickMenu_AddButton(info); ----------------- @@ -2130,17 +2081,17 @@ local function BuildMainMenu(frame) -- lock this menu in combat if InCombatLockdown() then info.disabled = 1; - info.text = info.text.." " - .._G["GREEN_FONT_COLOR_CODE"] - ..L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"]; - end + info.text = info.text .. " " + .. _G["GREEN_FONT_COLOR_CODE"] + .. L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"]; + end TitanPanelRightClickMenu_AddButton(info); --- TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + -- TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); local glob, toon, player, server = TitanUtils_GetGlobalProfile() info = {}; --- info.text = "Use Global Profile\n "..toon - info.text = L["TITAN_PANEL_GLOBAL_USE"].."\n "..toon; + -- info.text = "Use Global Profile\n "..toon + info.text = L["TITAN_PANEL_GLOBAL_USE"] .. "\n " .. toon; info.value = "Use Global Profile" info.func = function() TitanUtils_SetGlobalProfile(not glob, toon) @@ -2161,11 +2112,10 @@ local function BuildMainMenu(frame) info.arg1 = frame; info.func = function(self, frame_str) TitanBarDataVars[frame_str].show = not TitanBarDataVars[frame_str].show - TitanPanelBarButton_DisplayBarsWanted(frame_str.." user clicked Hide") + TitanPanelBarButton_DisplayBarsWanted(frame_str .. " user clicked Hide") end info.keepShownOnClick = nil TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end --[[ local @@ -2182,7 +2132,7 @@ local function BuildServerProfilesMenu() local s, e, ident; local setonce = 0; - if ( TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS ) then + if (TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS) then TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_SERVERS"], TitanPanelRightClickMenu_GetDropdownLevel()); -- Normal profile per toon @@ -2195,7 +2145,7 @@ local function BuildServerProfilesMenu() info = {}; info.notCheckable = true info.text = server; - info.value = R_PROFILE..server; + info.value = R_PROFILE .. server; info.hasArrow = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end @@ -2209,13 +2159,14 @@ local function BuildServerProfilesMenu() if server == TITAN_CUSTOM_PROFILE_POSTFIX then if setonce and setonce == 0 then TitanPanelRightClickMenu_AddTitle("", TitanPanelRightClickMenu_GetDropdownLevel()); - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_CUSTOM"], TitanPanelRightClickMenu_GetDropdownLevel()); - setonce = 1; + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_CUSTOM"], + TitanPanelRightClickMenu_GetDropdownLevel()); + setonce = 1; end info = {}; info.notCheckable = true info.text = player; - info.value = R_PROFILE..player; + info.value = R_PROFILE .. player; info.hasArrow = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end @@ -2240,7 +2191,7 @@ local function BuildPluginMenu() local plugin = TitanUtils_GetPlugin(id) local par_val = TitanPanelRightClickMenu_GetDropdMenuValue() local menu_plugin = string.gsub(par_val, R_PLUGIN, "") - if plugin.id and plugin.id == menu_plugin then + if plugin and plugin.id and plugin.id == menu_plugin then --title info = {}; info.text = TitanPlugins[plugin.id].menuText; @@ -2256,7 +2207,7 @@ local function BuildPluginMenu() info.value = plugin.id info.arg1 = plugin.id info.func = function(self, p_id) -- (self, info.arg1, info.arg2) - TitanPanelRightClickMenu_ToggleVar({p_id, "ShowIcon", nil}) + TitanPanelRightClickMenu_ToggleVar({ p_id, "ShowIcon", nil }) end info.keepShownOnClick = 1; info.checked = TitanGetVar(plugin.id, "ShowIcon"); @@ -2271,7 +2222,7 @@ local function BuildPluginMenu() info.value = plugin.id info.arg1 = plugin.id info.func = function(self, p_id) -- (self, info.arg1, info.arg2) - TitanPanelRightClickMenu_ToggleVar({p_id, "ShowLabelText", nil}) + TitanPanelRightClickMenu_ToggleVar({ p_id, "ShowLabelText", nil }) end info.keepShownOnClick = 1; info.checked = TitanGetVar(plugin.id, "ShowLabelText"); @@ -2286,7 +2237,7 @@ local function BuildPluginMenu() info.value = plugin.id info.arg1 = plugin.id info.func = function(self, p_id) -- (self, info.arg1, info.arg2) - TitanPanelRightClickMenu_ToggleVar({p_id, "ShowRegularText", nil}) + TitanPanelRightClickMenu_ToggleVar({ p_id, "ShowRegularText", nil }) end info.keepShownOnClick = 1; info.checked = TitanGetVar(plugin.id, "ShowRegularText"); @@ -2301,7 +2252,7 @@ local function BuildPluginMenu() info.value = plugin.id info.arg1 = plugin.id info.func = function(self, p_id) -- (self, info.arg1, info.arg2) - TitanPanelRightClickMenu_ToggleVar({p_id, "ShowColoredText", nil}) + TitanPanelRightClickMenu_ToggleVar({ p_id, "ShowColoredText", nil }) end info.keepShownOnClick = 1; info.checked = TitanGetVar(plugin.id, "ShowColoredText"); @@ -2316,7 +2267,7 @@ local function BuildPluginMenu() info.value = plugin.id info.arg1 = plugin.id info.func = function(self, p_id) -- (self, info.arg1, info.arg2) - TitanToggleVar(p_id, "DisplayOnRightSide", false) + TitanToggleVar(p_id, "DisplayOnRightSide") local bar = TitanUtils_GetWhichBar(p_id) TitanPanel_RemoveButton(p_id); TitanUtils_AddButtonOnBar(bar, p_id); @@ -2343,8 +2294,8 @@ local function BuildProfileMenu() -- -- Handle the profiles -- - for idx = 1, #Titan_Panel.players do - local index = Titan_Panel.players[idx] + for idx = 1, #Titan_Global.players do + local index = Titan_Global.players[idx] local player, server = TitanUtils_ParseName(index) local off = (index == TitanSettings.Player) or ((index == TitanAllGetVar("GlobalProfileUse")) and (TitanAllGetVar("GlobalProfileUse"))) @@ -2353,7 +2304,7 @@ local function BuildProfileMenu() -- handle custom profiles here if server == TITAN_CUSTOM_PROFILE_POSTFIX - and player == menu_val then + and player == menu_val then info = {}; info.notCheckable = true info.disabled = TitanAllGetVar("GlobalProfileUse") @@ -2373,11 +2324,11 @@ local function BuildProfileMenu() info.func = function(self, player) -- (self, info.arg1, info.arg2) if TitanSettings.Players[player] then TitanSettings.Players[player] = nil; - profname = TitanUtils_ParseName(index) + local profname = TitanUtils_ParseName(index) TitanPrint( L["TITAN_PANEL_MENU_PROFILE"] - .." '"..profname.."' " - ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] + .. " '" .. profname .. "' " + .. L["TITAN_PANEL_MENU_PROFILE_DELETED"] , "info") TitanPanelRightClickMenu_Close(); end @@ -2389,7 +2340,8 @@ local function BuildProfileMenu() if server == menu_val then -- Set the label once if setonce and setonce == 0 then - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_CHARS"], TitanPanelRightClickMenu_GetDropdownLevel()); + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_CHARS"], + TitanPanelRightClickMenu_GetDropdownLevel()); setonce = 1; end info = {}; @@ -2434,8 +2386,8 @@ local function BuildAProfileMenu() TitanSettings.Players[info.value] = nil; TitanPrint( L["TITAN_PANEL_MENU_PROFILE"] - .." '"..info.value.."' " - ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] + .. " '" .. info.value .. "' " + .. L["TITAN_PANEL_MENU_PROFILE_DELETED"] , "info") TitanPanelRightClickMenu_Close(); end @@ -2454,66 +2406,59 @@ local function BuildPluginCategoryMenu(frame) local plugin; for index, id in pairs(TitanPluginsIndex) do - plugin = TitanUtils_GetPlugin(id); - if not plugin.category then - plugin.category = "General"; - end - if ( TitanPanelRightClickMenu_GetDropdMenuValue() == R_ADDONS .. plugin.category ) then - if not TitanGetVar(id, "ForceBar") - or (TitanGetVar(id, "ForceBar") == TitanBarData[frame].name) then - info = {}; ---[[ - if plugin.version ~= nil and TitanPanelGetVar("VersionShown") then - info.text = plugin.menuText - ..TitanUtils_GetGreenText(" (v"..plugin.version..")") - else - info.text = plugin.menuText; - end ---]] - local ver = plugin.version - if TitanPanelGetVar("VersionShown") then - if ver == nil or ver == "" then - ver = "" -- safety in case of nil + plugin = TitanUtils_GetPlugin(id) + if plugin then -- add the plugin to the menu + plugin.category = plugin and plugin.category or "General"; + if (TitanPanelRightClickMenu_GetDropdMenuValue() == R_ADDONS .. plugin.category) then + if not TitanGetVar(id, "ForceBar") + or (TitanGetVar(id, "ForceBar") == TitanBarData[frame].name) then + info = {}; + local ver = plugin and plugin.version or "" + if TitanPanelGetVar("VersionShown") then + if ver == nil or ver == "" then + ver = "" -- safety in case of nil + else + ver = TitanUtils_GetGreenText(" (" .. ver .. ")") + end else - ver = TitanUtils_GetGreenText(" ("..ver..")") + ver = "" -- not requested end - else - ver = "" -- not requested - end - info.text = plugin.menuText..ver + info.text = plugin and plugin.menuText .. ver or "" - -- Add Bar - local internal_bar, which_bar = TitanUtils_GetWhichBar(id) - if which_bar == nil then - -- Plugin not shown - else - if internal_bar == TitanBarData[frame].name then - info.text = info.text..TitanUtils_GetGreenText(" ("..which_bar..")") + -- Add Bar + local internal_bar, which_bar = TitanUtils_GetWhichBar(id) + if which_bar == nil then + -- Plugin not shown else - info.text = info.text..TitanUtils_GetGoldText(" ("..which_bar..")") + if internal_bar == TitanBarData[frame].name then + info.text = info.text .. TitanUtils_GetGreenText(" (" .. which_bar .. ")") + else + info.text = info.text .. TitanUtils_GetGoldText(" (" .. which_bar .. ")") + end end - end - - if plugin.controlVariables then - info.hasArrow = 1; - end - info.value = R_PLUGIN..id; -- for next level dropdown - info.arg1 = frame; - info.arg2 = id; - 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) + + if plugin.controlVariables then + info.hasArrow = 1; + end + info.value = R_PLUGIN .. id; -- for next level dropdown + info.arg1 = frame; + info.arg2 = id; + 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()); end - info.checked = TitanPanel_IsPluginShown(id) or nil - info.keepShownOnClick = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end + else end end end @@ -2529,10 +2474,10 @@ NOTE: --]] function TitanPanelRightClickMenu_PrepareBarMenu(self) -- Determine which bar was clicked on --- local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); - local s, e, frame = string.find(self:GetName(), "(.*)"..TITAN_PANEL_CLICK_MENU_SUFFIX); + -- local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); + local s, e, frame = string.find(self:GetName(), "(.*)" .. TITAN_PANEL_CLICK_MENU_SUFFIX); local lev = (TitanPanelRightClickMenu_GetDropdownLevel() or 1) ---[[ + --[[ print("_prep R click" .." "..tostring(frame).."" .." "..tostring(lev).."" @@ -2565,12 +2510,12 @@ print("_prep R click" -- Plugin Categories => Plugins in that category -- OR -- Profiles => Server / Realm list - if ( lev == 2 ) then + if (lev == 2) then if string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_ADDONS) then BuildPluginCategoryMenu(frame) end - if ( TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS ) then + if (TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS) then BuildServerProfilesMenu() end return; @@ -2580,7 +2525,7 @@ print("_prep R click" -- Plugin Categories => Plugins in that category => Plugin defined options -- OR -- Profiles > Server / Realm list > Character on realm list - if ( lev == 3 ) then + if (lev == 3) then if string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_PLUGIN) then BuildPluginMenu() end @@ -2592,11 +2537,10 @@ print("_prep R click" -- Level 4 -- Profiles > Server / Realm list > Character on realm list > Load / Delete - if ( lev == 4 ) then + if (lev == 4) then BuildAProfileMenu() return; end - end --[[ Titan @@ -2606,7 +2550,7 @@ VAR: id - plugin name (string) OUT: int - index of the plugin or nil --]] function TitanPanel_IsPluginShown(id) - if ( id and TitanPanelSettings ) then + if (id and TitanPanelSettings) then return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id); end end @@ -2618,7 +2562,7 @@ VAR: id - plugin name (string) OUT: string - "Right" or "Left" --]] function TitanPanel_GetPluginSide(id) - if ( TitanGetVar(id, "DisplayOnRightSide") ) then + if (TitanGetVar(id, "DisplayOnRightSide")) then return TITAN_RIGHT; else return TITAN_LEFT; @@ -2642,10 +2586,16 @@ DESC: Set the scale, texture (graphic), and transparancy of all the Titan bars b VAR: None OUT: None --]] -function TitanPanel_InitPanelBarButton() +function TitanPanel_InitPanelBarButton(reason) -- Set initial Panel Scale TitanPanel_SetScale(); ---[===[ + --[[ +print("_InitPanelBarButton" +.." "..tostring(reason).."" +) +--]] + + --[===[ for idx,v in pairs (TitanBarData) do CheckBarBounds(_G[idx], 0) TitanPanel_SetBarTexture(idx) @@ -2678,9 +2628,9 @@ function TitanPanelButton_CreateBar(frame_str) a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) a_bar:SetFrameStrata("DIALOG") --- local x, y, w = TitanVariables_GetBarPos(frame_str) --- local tscale = TitanPanelGetVar("Scale") ---[[ + -- local x, y, w = TitanVariables_GetBarPos(frame_str) + -- local tscale = TitanPanelGetVar("Scale") + --[[ print("_Create bar" .." "..tostring(bar_data.name).."" .."\n " @@ -2696,7 +2646,7 @@ print("_Create bar" ) --]] 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: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) @@ -2704,33 +2654,43 @@ print("_Create bar" a_bar:SetScript("OnDragStart", OnMoveStart) a_bar:SetScript("OnDragStop", OnMovingStop) a_bar:SetScript("OnMouseWheel", OnMouseWheel) --- a_bar:SetSize(w / tscale, TITAN_PANEL_BAR_HEIGHT) + -- a_bar:SetSize(w / tscale, 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) + -- 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 + -- Min : No smaller than the padding & one icon -- Max : No wider than the screen -- does not seem to work to restrict size automatically... local screen = TitanUtils_ScreenSize() - a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, screen.x, TITAN_PANEL_BAR_HEIGHT) - + a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, screen.x, + TITAN_PANEL_BAR_HEIGHT) a_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); a_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) -- ====== -- Frame for right clicks - f = CreateFrame("Frame", this_bar..TITAN_PANEL_CLICK_MENU_SUFFIX, UIParent, "UIDropDownMenuTemplate") - + -- Use one bar to rule them all + -- Use the plugin naming scheme + -- 2024 Feb : Change to match plugin right click menu scheme so one routine can be used. + local f = CreateFrame("Frame", this_bar .. TITAN_PANEL_CLICK_MENU_SUFFIX, UIParent, "UIDropDownMenuTemplate") + --[[ + local tool_tip = Titan_Panel.plugin.PRE.."Bar"..Titan_Panel.plugin.POST + if _G[tool_tip] then + -- already created + else + f = CreateFrame("Frame", tool_tip, UIParent, "UIDropDownMenuTemplate") + end +--]] -- ====== -- Hider for auto hide feature - local hide_bar_name = TITAN_PANEL_HIDE_PREFIX..bar_data.name + 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).."" @@ -2739,7 +2699,7 @@ print("_Create hide bar" 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, x, -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"); @@ -2754,3 +2714,57 @@ print("_Create hide bar" end end +--====== deprecated / Unused +--[====[ + +--[[ local +NAME: TitanPanel_CreateABar +DESC: Helper to add scripts to the Titan bar passed in. +VAR: frame - The frame name (string) of the Titan bar to create +OUT: None +NOTE: +- This also creates the hider bar in case the user want to use auto hide. +:NOTE +--]] +local function TitanPanel_CreateABar(frame) + if frame then + local bar_name = TitanBarData[frame].name + local bar_width = TitanBarData[frame].width + + if bar_name then + -- Set script handlers for display + _G[frame]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + _G[frame]:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) + _G[frame]:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) + _G[frame]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + _G[frame]:SetWidth(bar_width) + + local hide_name = TitanBarData[frame].hider + if hide_name then + -- Set script handlers for display + _G[hide_name]:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + _G[hide_name]:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) + _G[hide_name]:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) + _G[hide_name]:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) + + _G[hide_name]:SetFrameStrata("BACKGROUND") + _G[hide_name]:SetWidth(bar_width) + _G[hide_name]:SetHeight(TITAN_PANEL_BAR_HEIGHT/2); + end + + -- Set the display bar + local container = _G[frame] + container:SetHeight(TITAN_PANEL_BAR_HEIGHT); + -- Set local identifier + local container_text = _G[frame.."_Text"] + if container_text then -- was used for debug/creating of the independent bars + container_text:SetText(tostring(bar_name)) + -- for now show it + container:Show() + end + end + else + end +end + +--]====] diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index aab633d..89ae465 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -1,9 +1,9 @@ --[[ File NAME: TitanConfig.lua DESC: This file contains routines used by Titan to show and process the Titan options. -Titan uses Ace libraries to place the Titan options within the Blizzard option screens. +Titan uses Ace libraries to place the Titan options within the Blizzard option screens. -Most routines in this file are local because they create the Titan options. +Most routines in this file are local because they create the Titan options. These routines are called first when Titan processes the 'player entering world' event. If an options list (skins, extra, etc) is changed by the user then the Ace table needs to be updated and WoW server informed to 'redraw'. :DESC @@ -28,70 +28,72 @@ Highlight - notes. tips. and details --]] local notes = "" do -notes = notes - ..TitanUtils_GetGoldText("Downgrade from 8.x for ANY WoW version:\n") - ..TitanUtils_GetHighlightText("" - .."- Titan Panel : Should DELETE Titan either manually or via addon manager.\n" - .."- Titan Panel saved variables : Should be fine for Retail; For CLassic (Wrath or Era) should DELETE Titan saved variables either manually or via addon manager.\n" - ) - ..TitanUtils_GetGoldText("Notes:\n") - ..TitanUtils_GetHighlightText("" - .."- Changing Titan Scaling : Short bars will move on screen. They should not go off screen. If Short bars move then drag to desired location. You may have to Reset the Short bar or temporarily disable top or bottom bars to drag the Short bar.\n" - ) - ..TitanUtils_GetGoldText("Known Issues:\n") - ..TitanUtils_GetHighlightText("" - .."- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" - ) -end + notes = notes + .. TitanUtils_GetGoldText("Downgrade from 8.x for ANY WoW version:\n") + .. TitanUtils_GetHighlightText("" + .. "- Titan Panel : Should DELETE Titan either manually or via addon manager.\n" + .. + "- Titan Panel saved variables : Should be fine for Retail; For CLassic (Wrath or Era) should DELETE Titan saved variables either manually or via addon manager.\n" + ) + .. TitanUtils_GetGoldText("Notes:\n") + .. TitanUtils_GetHighlightText("" + .. + "- Changing Titan Scaling : Short bars will move on screen. They should not go off screen. If Short bars move then drag to desired location. You may have to Reset the Short bar or temporarily disable top or bottom bars to drag the Short bar.\n" + ) + .. TitanUtils_GetGoldText("Known Issues:\n") + .. TitanUtils_GetHighlightText("" + .. "- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" + ) +end local changes = "" do -- recent change history -changes = changes - ..TitanUtils_GetGoldText("8.0.2 : 2024/01/14\n") - ..TitanUtils_GetGreenText("Location : \n") - ..TitanUtils_GetHighlightText("" - .."- Fix for ticket #1381, error on opening map when Location is hidden.\n" - .."- Refactor to save cycles when user selected no coords on map.\n" + changes = changes + .. TitanUtils_GetGoldText("8.0.2 : 2024/01/14\n") + .. TitanUtils_GetGreenText("Location : \n") + .. TitanUtils_GetHighlightText("" + .. "- Fix for ticket #1381, error on opening map when Location is hidden.\n" + .. "- Refactor to save cycles when user selected no coords on map.\n" ) - ..TitanUtils_GetGreenText("Config : \n") - ..TitanUtils_GetHighlightText("" - .."- Update many locale / translated strings.\n" + .. TitanUtils_GetGreenText("Config : \n") + .. TitanUtils_GetHighlightText("" + .. "- Update many locale / translated strings.\n" ) - .."\n\n" - ..TitanUtils_GetGoldText("8.0.1 : 2024/01/01\n") - ..TitanUtils_GetGreenText("Titan : \n") - ..TitanUtils_GetHighlightText("" - .."- In right click menu, do not show 'v' if no version found.\n" + .. "\n\n" + .. TitanUtils_GetGoldText("8.0.1 : 2024/01/01\n") + .. TitanUtils_GetGreenText("Titan : \n") + .. TitanUtils_GetHighlightText("" + .. "- In right click menu, do not show 'v' if no version found.\n" ) - ..TitanUtils_GetGreenText("Clock : \n") - ..TitanUtils_GetHighlightText("" - .."- Remove 24 hour checkbox from slider frame.\n" + .. TitanUtils_GetGreenText("Clock : \n") + .. TitanUtils_GetHighlightText("" + .. "- Remove 24 hour checkbox from slider frame.\n" ) - ..TitanUtils_GetGreenText("Location : \n") - ..TitanUtils_GetHighlightText("" - .."- Classic (Wrath and Era) put coords on bottom of small and large maps, if user selected.\n" + .. TitanUtils_GetGreenText("Location : \n") + .. TitanUtils_GetHighlightText("" + .. "- Classic (Wrath and Era) put coords on bottom of small and large maps, if user selected.\n" ) - ..TitanUtils_GetGreenText("Repair All : \n") - ..TitanUtils_GetHighlightText("" - .."- Add back option to show / hide most damaged equipped item.\n" - .."- New option to show / hide total % and cost.\n" - .."- Scan of equipped items rewritten.\n" + .. TitanUtils_GetGreenText("Repair All : \n") + .. TitanUtils_GetHighlightText("" + .. "- Add back option to show / hide most damaged equipped item.\n" + .. "- New option to show / hide total % and cost.\n" + .. "- Scan of equipped items rewritten.\n" ) - .."\n\n" - ..TitanUtils_GetGoldText("8.0.0 : 2023/12/23\n") - ..TitanUtils_GetGreenText("Titan single release version : \n") - ..TitanUtils_GetHighlightText("" - .."- Titan : Combined Retail and Classic versions for maintainability.\n" - .." This makes most retail / DF features available in Classic versions.\n" - .."- Titan built-in plugins : Merged retail and Classic versions.\n" + .. "\n\n" + .. TitanUtils_GetGoldText("8.0.0 : 2023/12/23\n") + .. TitanUtils_GetGreenText("Titan single release version : \n") + .. TitanUtils_GetHighlightText("" + .. "- Titan : Combined Retail and Classic versions for maintainability.\n" + .. " This makes most retail / DF features available in Classic versions.\n" + .. "- Titan built-in plugins : Merged retail and Classic versions.\n" ) - .."\n\n" - ..TitanUtils_GetGoldText("7.01.04.100200 : 2023/11/11\n") - ..TitanUtils_GetGreenText("Titan : \n") - ..TitanUtils_GetHighlightText("" - .."- Titan : TOC update only.\n" + .. "\n\n" + .. TitanUtils_GetGoldText("7.01.04.100200 : 2023/11/11\n") + .. TitanUtils_GetGreenText("Titan : \n") + .. TitanUtils_GetHighlightText("" + .. "- Titan : TOC update only.\n" ) - .."\n\n" + .. "\n\n" end local function TitanPanel_ScreenAdjustReload() @@ -101,14 +103,14 @@ local function TitanPanel_ScreenAdjustReload() else -- if NOT set then need a reload - the screen will NOT adjust StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_RELOAD"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) TitanPanelToggleVar("ScreenAdjust"); ReloadUI(); - end, + end, showAlert = 1, timeout = 0, whileDead = 1, @@ -124,15 +126,15 @@ local function TitanPanel_AuxScreenAdjustReload() else -- if NOT set then need a reload - the screen will NOT adjust StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_RELOAD"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) TitanPanelToggleVar("AuxScreenAdjust"); ReloadUI(); --- TitanPanelBarButton_ToggleAuxScreenAdjust(); - end, + -- TitanPanelBarButton_ToggleAuxScreenAdjust(); + end, showAlert = 1, timeout = 0, whileDead = 1, @@ -144,27 +146,27 @@ end TITAN_PANEL_CONFIG = { topic = { - About = L["TITAN_PANEL"], - top = L["TITAN_PANEL_MENU_OPTIONS_BARS"], - globals = L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"], - bottom = L["TITAN_PANEL_MENU_BOTTOM_BARS"], - plugins = L["TITAN_PANEL_MENU_PLUGINS"], - profiles = L["TITAN_PANEL_MENU_PROFILES"], - tooltips = L["TITAN_PANEL_MENU_OPTIONS_SHORT"], - scale = L["TITAN_PANEL_UISCALE_MENU_TEXT_SHORT"], - trans = L["TITAN_PANEL_TRANS_MENU_TEXT_SHORT"], - skins = L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"], - skinscust = L["TITAN_PANEL_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"], - adjust = "Frame Adjustment", - adjust_classic = "Frame Adjustment - Classic", - } + About = L["TITAN_PANEL"], + top = L["TITAN_PANEL_MENU_OPTIONS_BARS"], + globals = L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"], + bottom = L["TITAN_PANEL_MENU_BOTTOM_BARS"], + plugins = L["TITAN_PANEL_MENU_PLUGINS"], + profiles = L["TITAN_PANEL_MENU_PROFILES"], + tooltips = L["TITAN_PANEL_MENU_OPTIONS_SHORT"], + scale = L["TITAN_PANEL_UISCALE_MENU_TEXT_SHORT"], + trans = L["TITAN_PANEL_TRANS_MENU_TEXT_SHORT"], + skins = L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"], + skinscust = L["TITAN_PANEL_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"], + adjust = "Frame Adjustment", + adjust_classic = "Frame Adjustment - Classic", } +} -- Titan local helper funcs local function TitanPanel_GetTitle() @@ -198,84 +200,36 @@ end -- helper functions if TITAN_ID == "TitanClassic" then - ---[[ local + --[[ local NAME: TitanAdjustPanelScale DESC: Set the Tian 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) - Titan_AdjustScale() + local function TitanAdjustPanelScale(scale) + Titan_AdjustScale() - -- Adjust frame positions - TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true) -end + -- Adjust frame positions + TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH) + end --- helper functions ---[[ local + -- 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) - TitanPanelBarButton_ToggleScreenAdjust() - ReloadUI(); - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RELOAD"); -end - -local function TitanPanel_ScreenAdjustReload() - if TitanPanelGetVar("ScreenAdjust") then - -- if set then clear it - the screen will adjust - TitanPanelBarButton_ToggleScreenAdjust() - else - -- if NOT set then need a reload - the screen will NOT adjust + local function TitanPanel_TicketReload() StaticPopupDialogs["TITAN_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n" - ..L["TITAN_PANEL_RELOAD"], + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) .. "\n\n" + .. L["TITAN_PANEL_RELOAD"], button1 = ACCEPT, button2 = CANCEL, OnAccept = function(self) - TitanPanelToggleVar("ScreenAdjust"); + TitanPanelBarButton_ToggleScreenAdjust() ReloadUI(); - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RELOAD"); - end -end -local function TitanPanel_AuxScreenAdjustReload() - if TitanPanelGetVar("AuxScreenAdjust") then - -- if set then clear it - the screen will adjust - TitanPanelBarButton_ToggleAuxScreenAdjust() - else - -- if NOT set then need a reload - the screen will NOT adjust - 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("AuxScreenAdjust"); - ReloadUI(); --- TitanPanelBarButton_ToggleAuxScreenAdjust(); - end, + end, showAlert = 1, timeout = 0, whileDead = 1, @@ -283,8 +237,54 @@ local function TitanPanel_AuxScreenAdjustReload() }; StaticPopup_Show("TITAN_RELOAD"); end -end + local function TitanPanel_ScreenAdjustReload() + if TitanPanelGetVar("ScreenAdjust") then + -- if set then clear it - the screen will adjust + TitanPanelBarButton_ToggleScreenAdjust() + else + -- if NOT set then need a reload - the screen will NOT adjust + 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("ScreenAdjust"); + ReloadUI(); + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RELOAD"); + end + end + local function TitanPanel_AuxScreenAdjustReload() + if TitanPanelGetVar("AuxScreenAdjust") then + -- if set then clear it - the screen will adjust + TitanPanelBarButton_ToggleAuxScreenAdjust() + else + -- if NOT set then need a reload - the screen will NOT adjust + 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("AuxScreenAdjust"); + ReloadUI(); + -- TitanPanelBarButton_ToggleAuxScreenAdjust(); + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RELOAD"); + end + end end --============= Titan Panel entry -- @@ -300,95 +300,103 @@ local titan_entry = { confgendesc = { name = "Description", order = 1, - type = "group", inline = true, + type = "group", + inline = true, args = { confdesc = { - order = 1, - type = "description", - name = "" - .."Titan Panel is an Interface Enhancement addon which allows you to add short display bars to the UI as well as bars to 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 + 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 bars to the top and bottom of your game screen." + .. "\n\n" + .. + "This addon does not interfere with, enhance, or replace any of your actual gameplay within the game. Titan Panel is meant to give you a quick visual point or click-on access to see the data related to your character without having to open other dialog boxes in the game or, in some cases, other addons." + .. "\n\n" + .. "Our main program allows you to add bars to the UI as well as the top and bottom of your game screen." + .. "\n\n" + .. + "Over the years, we have been able to add some other features, but only if they do not interfere with your actual game experience.", + cmdHidden = true }, } }, confnotes = { name = "Notes", order = 3, - type = "group", inline = true, + type = "group", + inline = true, args = { confversiondesc = { - order = 1, - type = "description", - name = "" - ..notes, - cmdHidden = true + order = 1, + type = "description", + name = "" + .. notes, + cmdHidden = true }, } }, confthanks = { name = "Thank You", order = 5, - type = "group", inline = true, + type = "group", + inline = true, args = { confversiondesc = { - order = 1, - type = "description", - name = "" - .."We would like to thank all of the users of TitanPanel." - .."\n" - .."We understand you have many choices on which addons to enhance your World of Warcraft experience." - .." Our Mission has always been to provide you with a tool to help add and improve your experience without impeding your enjoyment of the game. ", - cmdHidden = true + order = 1, + type = "description", + name = "" + .. "We would like to thank all of the users of TitanPanel." + .. "\n" + .. "We understand you have many choices on which addons to enhance your World of Warcraft experience." + .. + " Our Mission has always been to provide you with a tool to help add and improve your experience without impeding your enjoyment of the game. ", + cmdHidden = true }, } }, confinfodesc = { name = L["TITAN_PANEL_ABOUT"], order = 7, - type = "group", inline = true, + type = "group", + inline = true, args = { confversiondesc = { - order = 1, - type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_VERSION"]..": " - .._G["GREEN_FONT_COLOR_CODE"]..TitanPanel_GetVersion(), - cmdHidden = true + order = 1, + type = "description", + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_VERSION"] .. ": " + .. _G["GREEN_FONT_COLOR_CODE"] .. TitanPanel_GetVersion(), + cmdHidden = true }, confauthordesc = { order = 2, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_AUTHOR"]..": " - .."|cffff8c00"..TitanPanel_GetAuthor(), + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_AUTHOR"] .. ": " + .. "|cffff8c00" .. TitanPanel_GetAuthor(), cmdHidden = true }, confcreditsdesc = { order = 3, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_CREDITS"]..": " - .._G["HIGHLIGHT_FONT_COLOR_CODE"]..TitanPanel_GetCredits(), + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_CREDITS"] .. ": " + .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetCredits(), cmdHidden = true }, confcatdesc = { order = 4, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_CATEGORY"]..": " - .._G["HIGHLIGHT_FONT_COLOR_CODE"]..TitanPanel_GetCategory(), + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_CATEGORY"] .. ": " + .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetCategory(), cmdHidden = true }, confemaildesc = { order = 5, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_EMAIL"]..": " - .._G["HIGHLIGHT_FONT_COLOR_CODE"]..TitanPanel_GetEmail(), + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_EMAIL"] .. ": " + .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetEmail(), cmdHidden = true }, ---[[ has not been updated in quite a while... + --[[ has not been updated in quite a while... confwebsitedesc = { order = 6, type = "description", @@ -400,8 +408,8 @@ local titan_entry = { conflicensedesc = { order = 7, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_LICENSE"]..": " - .._G["HIGHLIGHT_FONT_COLOR_CODE"]..TitanPanel_GetLicense(), + name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_LICENSE"] .. ": " + .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetLicense(), cmdHidden = true }, } @@ -414,8 +422,8 @@ local titan_entry = { -- --[[ local NAME: optionsAdjust -DESC: Bar control for the main (top) bars: -Each bar: +DESC: Bar control for the main (top) bars: +Each bar: - Show - Auto hide - Center text (plugins) @@ -426,7 +434,7 @@ Main (top) controls: :DESC --]] local optionsAdjust = { - name = TITAN_PANEL_CONFIG.topic.adjust, + name = TITAN_PANEL_CONFIG.topic.adjust, type = "group", args = { } @@ -434,10 +442,10 @@ local optionsAdjust = { local function ColorAdjShown(frame_str) local res = "" - if TitanAdjustSettings[frame_str].adjust then + if TitanAdjustSettings[frame_str].adjust then res = frame_str -- leave as is - else - res = "|cff808080"..frame_str.._G["FONT_COLOR_CODE_CLOSE"] + else + res = "|cff808080" .. frame_str .. _G["FONT_COLOR_CODE_CLOSE"] end return res @@ -457,7 +465,7 @@ local function TitanUpdateAdj(t, pos) -- sort the bar data by their intended order local bar_list = {} local i = 0 - for idx, v in pairs (Titan_Panel.AdjList) do + for idx, v in pairs(Titan_Global.AdjList) do i = i + 1 bar_list[i] = v end @@ -474,7 +482,7 @@ local function TitanUpdateAdj(t, pos) local f_name = bar_list[idx].frame_name local v = TitanAdjustSettings[f_name] -- process this frame position = position + 1 - args[f_name] = { + args[f_name] = { type = "group", name = ColorAdjShown(f_name), order = position, @@ -486,57 +494,65 @@ local function TitanUpdateAdj(t, pos) args[f_name].args.title = { type = "header", name = bar_list[idx].purpose, - order = position, width = "full", + order = position, + width = "full", } - position = position + 1 -- Show toggle + position = position + 1 -- Show toggle args[f_name].args.show = { - type = "toggle", width = .75, --"fill", + type = "toggle", + width = .75, --"fill", name = USE or "Use", --L["TITAN_PANEL_MENU_DISPLAY_BAR"], order = position, - get = function(info) - local frame_str = info[1] - return TitanAdjustSettings[frame_str].adjust - end, - set = function(info, val) - local frame_str = info[1] + get = function(info) + local frame_str = info[1] + return TitanAdjustSettings[frame_str].adjust + end, + set = function(info, val) + local frame_str = info[1] TitanAdjustSettings[frame_str].adjust = not TitanAdjustSettings[frame_str].adjust - TitanPanel_AdjustFrame(frame_str, "Adjust show changed : "..tostring(TitanAdjustSettings[frame_str].adjust)) + TitanPanel_AdjustFrame(frame_str, + "Adjust show changed : " .. tostring(TitanAdjustSettings[frame_str].adjust)) TitanUpdateAdj(optionsAdjust.args, 1000) - end, + end, } -- ====== position = position + 1 -- offset args[f_name].args.offset = { - type = "range", width = "full", + type = "range", + width = "full", name = "Vertical Adjustment", --L["TITAN_PANEL_TRANS_MENU_TEXT_SHORT"], order = position, - min = -200, max = 0, step = 1, + min = -200, + max = 0, + step = 1, get = function(info) - local frame_str = info[1] + local frame_str = info[1] return TitanAdjustSettings[frame_str].offset - end, + end, set = function(info, a) - local frame_str = info[1] + local frame_str = info[1] TitanAdjustSettings[frame_str].offset = a ---[[ + --[[ print("Cfg Adj" .." '"..tostring(frame_str).."'" .." "..tostring(a).."" ) --]] - TitanPanel_AdjustFrame(frame_str, "Adjust offset changed : "..tostring(a)) - end, + TitanPanel_AdjustFrame(frame_str, "Adjust offset changed : " .. tostring(a)) + end, } position = position + 1 -- spacer args[f_name].args.colorspacer = { - order = position, type = "description", width = "full", + order = position, + type = "description", + width = "full", name = " ", - } + } end -- Config Tables changed! AceConfigRegistry:NotifyChange("Titan Panel Bars") ---[===[ + --[===[ print("Color new:" .." "..tostring(format("%0.1f", r)).."" .." "..tostring(format("%0.1f", g)).."" @@ -556,8 +572,8 @@ end -- --[[ local NAME: optionsBars -DESC: Bar control for the main (top) bars: -Each bar: +DESC: Bar control for the main (top) bars: +Each bar: - Show - Auto hide - Center text (plugins) @@ -568,7 +584,7 @@ Main (top) controls: :DESC --]] local optionsBars = { - name = TITAN_PANEL_CONFIG.topic.top, + name = TITAN_PANEL_CONFIG.topic.top, type = "group", args = { } @@ -577,10 +593,10 @@ local optionsBars = { local function ColorShown(bar) local res = bar.locale_name local frame_str = bar.frame_name - if TitanBarDataVars[frame_str].show then + if TitanBarDataVars[frame_str].show then -- leave as is - else - res = "|cff808080"..res.._G["FONT_COLOR_CODE_CLOSE"] + else + res = "|cff808080" .. res .. _G["FONT_COLOR_CODE_CLOSE"] end return res @@ -599,7 +615,7 @@ local function TitanUpdateConfigBars(t, pos) -- sort the bar data by their intended order local bar_list = {} - for _,v in pairs (TitanBarData) do + for _, v in pairs(TitanBarData) do bar_list[v.order] = v end table.sort(bar_list, function(a, b) @@ -616,7 +632,7 @@ local function TitanUpdateConfigBars(t, pos) -- 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] = { + args[v.name] = { type = "group", name = ColorShown(v), order = position, @@ -628,50 +644,54 @@ local function TitanUpdateConfigBars(t, pos) args[v.name].args.title = { type = "header", name = v.locale_name, - order = position, width = "full", + order = position, + width = "full", } - position = position + 1 -- Show toggle + position = position + 1 -- Show toggle args[v.name].args.show = { - type = "toggle", width = .75, --"fill", + type = "toggle", + width = .75, --"fill", 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]) + 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)) + TitanPanelBarButton_DisplayBarsWanted(info[1] .. "Show " .. tostring(val)) TitanUpdateConfigBars(optionsBars.args, 1000) - end, - } - position = position + 1 -- Auto hide toggle + end, + } + position = position + 1 -- Auto hide toggle args[v.name].args.autohide = { - type = "toggle", width = .75, --"fill", + type = "toggle", + width = .75, --"fill", 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) + 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 + end, + } + position = position + 1 -- Center toggle args[v.name].args.center = { - type = "toggle", width = .75, --"fill", + type = "toggle", + width = .75, --"fill", name = L["TITAN_PANEL_MENU_CENTER_TEXT"], order = position, - get = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) + get = function(info) + local frame_str = TitanVariables_GetFrameName(info[1]) return (TitanBarDataVars[frame_str].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER) - end, + end, set = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - if (TitanBarDataVars[frame_str].align == TITAN_PANEL_BUTTONS_ALIGN_CENTER ) then + 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 @@ -679,191 +699,213 @@ local function TitanUpdateConfigBars(t, pos) -- Justify button position TitanPanelButton_Justify(); - end, - } - position = position + 1 -- Combat hide toggle + end, + } + position = position + 1 -- Combat hide toggle args[v.name].args.hideincombat = { - type = "toggle", width = .75, --"fill", + 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]) + get = function(info) + local frame_str = TitanVariables_GetFrameName(info[1]) return TitanBarDataVars[frame_str].hide_in_combat - end, + end, set = function(info) - local frame_str = TitanVariables_GetFrameName(info[1]) - TitanBarDataVars[frame_str].hide_in_combat = + local frame_str = TitanVariables_GetFrameName(info[1]) + TitanBarDataVars[frame_str].hide_in_combat = not TitanBarDataVars[frame_str].hide_in_combat - end, - } + end, + } position = position + 1 -- spacer args[v.name].args.transpacer1 = { - order = position, type = "description", width = "full", + order = position, + type = "description", + width = "full", name = " ", - } + } position = position + 1 -- spacer args[v.name].args.resetposspacer = { - order = position, type = "description", width = "full", + order = position, + type = "description", + width = "full", name = " ", - } + } position = position + 1 -- reset pos args[v.name].args.resetbar = { - type = "execute", width = "Full", + 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]) + local frame_str = TitanVariables_GetFrameName(info[1]) TitanVariables_SetBarPos(_G[frame_str], true) - TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - "..tostring(info[1])) + TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - " .. tostring(info[1])) 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 = { - [Titan_Panel.SKIN] = L["TITAN_PANEL_SKINS_TITLE"], - [Titan_Panel.COLOR] = COLOR, - }, - } - position = position + 1 -- Title divider - args[v.name].args.skintitle = { - type = "header", - name = L["TITAN_PANEL_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 - 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 + -- ====== + -- 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 = { + [Titan_Global.SKIN] = L["TITAN_PANEL_SKINS_TITLE"], + [Titan_Global.COLOR] = COLOR, + }, + } + position = position + 1 -- Title divider + args[v.name].args.skintitle = { + type = "header", + name = L["TITAN_PANEL_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 - -- Use it as is + Skinlist[val.path] = "|cffffff9a" .. val.name .. "|r" end - return TitanBarDataVars[frame_str].skin.path.."TitanPanelBackground"..vert.."0" - 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_PANEL_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 - end, - set = function(info, a) - local frame_str = TitanVariables_GetFrameName(info[1]) - _G[frame_str]:SetAlpha(a) - TitanBarDataVars[frame_str].skin.alpha = 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.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 + table.sort(Skinlist, function(a, b) + return string.lower(TitanSkins[a].name) + < string.lower(TitanSkins[b].name) + end) + return Skinlist + end, + } + position = position + 1 -- spacer + args[v.name].args.skinspacer = { + order = position, + type = "description", + width = "5", + name = " ", + } + position = position + 1 -- selected skin + args[v.name].args.skinselected = { + name = "", + image = function(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" + 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_PANEL_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 + end, + set = function(info, a) + local frame_str = TitanVariables_GetFrameName(info[1]) + _G[frame_str]:SetAlpha(a) + TitanBarDataVars[frame_str].skin.alpha = 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.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)).."" @@ -882,46 +924,52 @@ end --============= Bars - All local optionsGlobals = { - name = TITAN_PANEL_CONFIG.topic.globals, + name = TITAN_PANEL_CONFIG.topic.globals, type = "group", args = { confdesc = { - order = 10, width = "full", + 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", + 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) + set = function(_, v) TitanBarDataVars["Global"].texure = v - for idx, val in pairs (TitanBarData) do + for idx, val in pairs(TitanBarData) do TitanPanel_SetBarTexture(idx) end end, values = { - [Titan_Panel.SKIN] = L["TITAN_PANEL_SKINS_TITLE"], - [Titan_Panel.COLOR] = COLOR, - [Titan_Panel.NONE] = NONE, + [Titan_Global.SKIN] = L["TITAN_PANEL_SKINS_TITLE"], + [Titan_Global.COLOR] = COLOR, + [Titan_Global.NONE] = NONE, }, }, confskindesc = { - order = 20, width = "full", + order = 20, + width = "full", type = "description", name = L["TITAN_PANEL_SKINS_TITLE"], }, setskinglobal = { - order = 21, type = "select", width = "30", + order = 21, + type = "select", + width = "30", name = " ", --L["TITAN_PANEL_SKINS_LIST_TITLE"], desc = L["TITAN_PANEL_SKINS_SET_DESC"], get = function() return TitanBarDataVars["Global"].skin.path end, - set = function(_,v) + set = function(_, v) TitanBarDataVars["Global"].skin.path = v --TitanPanelSetVar("TexturePath", v); - if TitanBarDataVars["Global"].texure == Titan_Panel.SKIN then - for idx, val in pairs (TitanBarData) do + if TitanBarDataVars["Global"].texure == Titan_Global.SKIN then + for idx, val in pairs(TitanBarData) do TitanPanel_SetBarTexture(idx) end end @@ -929,11 +977,11 @@ local optionsGlobals = { values = function() local Skinlist = {} local v; - for _,v in pairs (TitanSkins) do + for _, v in pairs(TitanSkins) do if v.path ~= TitanBarDataVars["Global"].skin.path then --TitanPanelGetVar("TexturePath") then - Skinlist[v.path] = "|cff19ff19"..v.name.."|r" + Skinlist[v.path] = "|cff19ff19" .. v.name .. "|r" else - Skinlist[v.path] = "|cffffff9a"..v.name.."|r" + Skinlist[v.path] = "|cffffff9a" .. v.name .. "|r" end end table.sort(Skinlist, function(a, b) @@ -946,34 +994,40 @@ local optionsGlobals = { show_skin_top_desc = { type = "description", name = "", - order = 30, width = "10", + order = 30, + width = "10", }, show_skin_global_top = { type = "description", name = "", - image = function() - return TitanBarDataVars["Global"].skin.path.."TitanPanelBackgroundTop0" --- return TitanPanelGetVar("TexturePath").."TitanPanelBackgroundTop0" - end, + image = function() + return TitanBarDataVars["Global"].skin.path .. "TitanPanelBackgroundTop0" + -- return TitanPanelGetVar("TexturePath").."TitanPanelBackgroundTop0" + end, imageWidth = 256, - order = 31, width = "60", + order = 31, + width = "60", }, confcolorspacer = { -- spacer - order = 50, type = "description", width = "full", + order = 50, + type = "description", + width = "full", name = " ", - }, + }, confcolordesc = { - order = 51, width = "full", + order = 51, + width = "full", type = "description", name = COLOR, }, show_skin_color_picker = { - type = "color", width = "Full", + 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), + -- disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), hasAlpha = true, - get = function() + get = function() local color = TitanBarDataVars["Global"].color return color.r, color.g, @@ -981,7 +1035,7 @@ local optionsGlobals = { color.alpha end, set = function(info, r, g, b, a) ---[===[ + --[===[ print("Color new:" .." "..tostring(format("%0.1f", r)).."" .." "..tostring(format("%0.1f", g)).."" @@ -993,85 +1047,105 @@ print("Color new:" TitanBarDataVars["Global"].color.g = g TitanBarDataVars["Global"].color.b = b TitanBarDataVars["Global"].color.alpha = a - if TitanBarDataVars["Global"].texure == Titan_Panel.COLOR then - for idx, val in pairs (TitanBarData) do + if TitanBarDataVars["Global"].texure == Titan_Global.COLOR then + for idx, val in pairs(TitanBarData) do TitanPanel_SetBarTexture(idx) end end end, }, hidecombatspacer = { -- spacer - order = 100, type = "description", width = "full", + order = 100, + type = "description", + width = "full", name = " ", - }, + }, confcombatdesc = { - order = 101, width = "full", + 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", + 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", + order = 200, + type = "description", + width = "full", name = " ", - }, + }, confarenadesc = { - order = 201, width = "full", + order = 201, + width = "full", type = "header", - name = BATTLEGROUND.." / "..ARENA, + name = BATTLEGROUND .. " / " .. ARENA, }, setarenauseglobal = { - name = HIDE.." "..L["TITAN_PANEL_MENU_TOP_BARS"] - .." - "..BATTLEGROUND.." / "..ARENA , + 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", + .. " " .. TitanBarData[TitanVariables_GetFrameName("Bar")].locale_name + .. " and" + .. " " .. TitanBarData[TitanVariables_GetFrameName("Bar2")].locale_name + .. " in " .. BATTLEGROUND .. " / " .. ARENA, + order = 205, + type = "toggle", + width = "full", disabled = (TITAN_ID == "TitanClassic"), get = function() return TitanPanelGetVar("HideBarsInPVP") end, - set = function() + set = function() TitanPanelToggleVar("HideBarsInPVP") TitanPanelBarButton_DisplayBarsWanted("HideBarsInPVP" - .." "..tostring(TitanPanelGetVar("HideBarsInPVP"))) - end, + .. " " .. tostring(TitanPanelGetVar("HideBarsInPVP"))) + end, }, topbarspacer = { -- spacer - order = 300, type = "description", width = "full", + order = 300, + type = "description", + width = "full", name = " ", - }, + }, conftopbardesc = { - order = 301, width = "full", + order = 301, + width = "full", type = "header", - name = L["TITAN_PANEL_MENU_TOP_BARS"], + name = L["TITAN_PANEL_MENU_TOP_BARS"], }, settopbar = { - name = L["TITAN_PANEL_MENU_DISABLE_PUSH"] , + name = L["TITAN_PANEL_MENU_DISABLE_PUSH"], desc = L["TITAN_PANEL_MENU_DISABLE_PUSH"], - order = 305, type = "toggle", width = "full", + order = 305, + type = "toggle", + width = "full", disabled = (TITAN_ID == "Titan"), get = function() return TitanPanelGetVar("ScreenAdjust") end, set = function() TitanPanel_ScreenAdjustReload() end, }, bottombarspacer = { -- spacer - order = 400, type = "description", width = "full", + order = 400, + type = "description", + width = "full", name = " ", - }, + }, confbottombardesc = { - order = 401, width = "full", + order = 401, + width = "full", type = "header", - name = L["TITAN_PANEL_MENU_BOTTOM_BARS"], + name = L["TITAN_PANEL_MENU_BOTTOM_BARS"], }, setbottombar = { - name = L["TITAN_PANEL_MENU_DISABLE_PUSH"] , + name = L["TITAN_PANEL_MENU_DISABLE_PUSH"], desc = L["TITAN_PANEL_MENU_DISABLE_PUSH"], - order = 405, type = "toggle", width = "full", + order = 405, + type = "toggle", + width = "full", disabled = (TITAN_ID == "Titan"), get = function() return TitanPanelGetVar("AuxScreenAdjust") end, set = function() TitanPanel_AuxScreenAdjustReload() end, @@ -1094,12 +1168,12 @@ local optionsAddons = { local function ColorVisible(id, name) local res = "?" - if TitanPanel_IsPluginShown(id) then + if TitanPanel_IsPluginShown(id) then res = (name or "") - else - res = "|cff808080"..name.._G["FONT_COLOR_CODE_CLOSE"] + else + res = "|cff808080" .. name .. _G["FONT_COLOR_CODE_CLOSE"] end - + return res end @@ -1136,7 +1210,7 @@ local function TitanUpdateConfigAddons() plug_in = TitanUtils_GetPlugin(TitanPluginsIndex[idx]) if plug_in then if plug_in.version then - plug_version = TitanUtils_GetGreenText(" ("..plug_in.version..")") + plug_version = TitanUtils_GetGreenText(" (" .. plug_in.version .. ")") else plug_version = "" end @@ -1147,7 +1221,7 @@ local function TitanUpdateConfigAddons() args = { name = { type = "header", - name = ((plug_in.menuText or "")..plug_version), + name = ((plug_in.menuText or "") .. plug_version), order = 1, }, show = { @@ -1155,7 +1229,7 @@ local function TitanUpdateConfigAddons() name = L["TITAN_PANEL_MENU_SHOW"], order = 3, get = function(info) return (TitanPanel_IsPluginShown(info[1])) end, - set = function(info, v) + set = function(info, v) local name = info[1] if v then -- Show / add local bar = (TitanGetVar(name, "ForceBar") or TitanUtils_PickBar()) @@ -1164,11 +1238,11 @@ local function TitanUpdateConfigAddons() TitanPanel_RemoveButton(name) end TitanUpdateConfigAddons() - end, + end, }, } } - + --ShowIcon if plug_in.controlVariables and plug_in.controlVariables.ShowIcon then args[plug_in.id].args.icon = @@ -1177,10 +1251,10 @@ local function TitanUpdateConfigAddons() name = L["TITAN_PANEL_MENU_SHOW_ICON"], order = 4, get = function(info) return (TitanGetVar(info[1], "ShowIcon")) end, - set = function(info, v) + set = function(info, v) TitanToggleVar(info[1], "ShowIcon"); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end @@ -1191,7 +1265,7 @@ local function TitanUpdateConfigAddons() name = L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"], order = 5, get = function(info) return (TitanGetVar(info[1], "ShowLabelText")) end, - set = function(info, v) + set = function(info, v) TitanToggleVar(info[1], "ShowLabelText"); TitanPanelButton_UpdateButton(info[1]) end, @@ -1206,10 +1280,10 @@ local function TitanUpdateConfigAddons() name = L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"], order = 6, get = function(info) return (TitanGetVar(info[1], "ShowRegularText")) end, - set = function(info, v) + set = function(info, v) TitanToggleVar(info[1], "ShowRegularText"); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end @@ -1220,7 +1294,7 @@ local function TitanUpdateConfigAddons() name = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"], order = 7, get = function(info) return (TitanGetVar(info[1], "ShowColoredText")) end, - set = function(info, v) + set = function(info, v) TitanToggleVar(info[1], "ShowColoredText"); TitanPanelButton_UpdateButton(info[1]) end, @@ -1251,7 +1325,7 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.shift_left = { type = "execute", - name = "< "..L["TITAN_PANEL_SHIFT_LEFT"].." ", + name = "< " .. L["TITAN_PANEL_SHIFT_LEFT"] .. " ", order = 51, func = function(info, arg1) local name = info[1] @@ -1262,7 +1336,7 @@ local function TitanUpdateConfigAddons() } args[plug_in.id].args.shift_right = { type = "execute", - name = "> "..L["TITAN_PANEL_SHIFT_RIGHT"], + name = "> " .. L["TITAN_PANEL_SHIFT_RIGHT"], order = 52, func = function(info, arg1) local name = info[1] @@ -1278,12 +1352,14 @@ local function TitanUpdateConfigAddons() } if not TitanVarExists(plug_in.id, "ForceBar") then args[plug_in.id].args.top_bottom = { - order = 54, type = "select", + order = 54, + type = "select", name = L["TITAN_PANEL_MENU_BAR"], desc = L["TITAN_PANEL_MENU_DISPLAY_ON_BAR"], - get = function(info) - return TitanUtils_GetWhichBar(info[1]) end, - set = function(info,v) + get = function(info) + return TitanUtils_GetWhichBar(info[1]) + end, + set = function(info, v) local name = info[1] if TitanPanel_IsPluginShown(name) then TitanUtils_AddButtonOnBar(v, name) @@ -1292,9 +1368,9 @@ local function TitanUpdateConfigAddons() values = function() local Locationlist = {} local v - for idx,v in pairs (TitanBarData) do + 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 @@ -1305,7 +1381,8 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.top_bottom = { order = 54, type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_MENU_BAR_ALWAYS"].." "..TitanGetVar(plug_in.id, "ForceBar")), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_MENU_BAR_ALWAYS"] .. + " " .. TitanGetVar(plug_in.id, "ForceBar")), cmdHidden = true, } end @@ -1324,22 +1401,20 @@ local function TitanUpdateConfigAddons() if plug_in.notes then args[plug_in.id].args.notes = { type = "description", - name = L["TITAN_PANEL_MENU_ADV_NOTES"], order = 61, - name = "" - .._G["GREEN_FONT_COLOR_CODE"]..plug_in.notes.."|r", - cmdHidden = true, + name = "" + .. _G["GREEN_FONT_COLOR_CODE"] .. plug_in.notes .. "|r", + cmdHidden = true, } else args[plug_in.id].args.notes = { type = "description", - name = L["TITAN_PANEL_MENU_ADV_NOTES"], order = 61, - name = _G["GREEN_FONT_COLOR_CODE"]..L["TITAN_PANEL_NONE"].."|r", - cmdHidden = true, + name = _G["GREEN_FONT_COLOR_CODE"] .. L["TITAN_PANEL_NONE"] .. "|r", + cmdHidden = true, } end - -- + -- -- Custom Labels 1 - 4 local num_labels = tonumber(TitanGetVar(plug_in.id, "NumLabelsSeen") or 1) @@ -1347,11 +1422,11 @@ local function TitanUpdateConfigAddons() args[plug_in.id].args.custom_labels = { order = 70, type = "header", - name = L["TITAN_PANEL_MENU_ADV_LABEL"], + name = L["TITAN_PANEL_MENU_ADV_LABEL"], } args[plug_in.id].args.custom_label_show = { type = "toggle", - name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"].." 1", + name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 1", order = 71, get = function(info) return (TitanGetVar(info[1], "CustomLabelTextShow") or false) end, set = function(info, v) @@ -1363,18 +1438,19 @@ local function TitanUpdateConfigAddons() order = 72, name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabelText") or "") end, - set = function(info,v) + set = function(info, v) TitanSetVar(info[1], "CustomLabelText", v); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end 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 = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 2", order = 73, get = function(info) return (TitanGetVar(info[1], "CustomLabel2TextShow") or false) end, set = function(info, v) @@ -1386,18 +1462,19 @@ local function TitanUpdateConfigAddons() order = 74, name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel2Text") or "") end, - set = function(info,v) + set = function(info, v) TitanSetVar(info[1], "CustomLabel2Text", v); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end 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 = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 3", order = 75, get = function(info) return (TitanGetVar(info[1], "CustomLabel3TextShow") or false) end, set = function(info, v) @@ -1409,18 +1486,19 @@ local function TitanUpdateConfigAddons() order = 76, name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel3Text") or "") end, - set = function(info,v) + set = function(info, v) TitanSetVar(info[1], "CustomLabel3Text", v); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end 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 = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 4", order = 77, get = function(info) return (TitanGetVar(info[1], "CustomLabel4TextShow") or false) end, set = function(info, v) @@ -1432,12 +1510,13 @@ local function TitanUpdateConfigAddons() order = 78, name = L["TITAN_PANEL_MENU_ADV_CUSTOM"], desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function(info) return (TitanGetVar(info[1], "CustomLabel4Text") or "") end, - set = function(info,v) + set = function(info, v) TitanSetVar(info[1], "CustomLabel4Text", v); TitanPanelButton_UpdateButton(info[1]) - end, + end, } end end @@ -1488,20 +1567,20 @@ local function TitanUpdateChars() args["desc"] = { order = 1, type = "description", - name = L["TITAN_PANEL_CHARS_DESC"].."\n", + name = L["TITAN_PANEL_CHARS_DESC"] .. "\n", cmdHidden = true, } args["custom_header"] = { order = 10, type = "header", - name = L["TITAN_PANEL_MENU_PROFILE_CUSTOM"].."\n", + name = L["TITAN_PANEL_MENU_PROFILE_CUSTOM"] .. "\n", cmdHidden = true, } args["custom_save"] = { order = 11, type = "execute", - name = L["TITAN_PANEL_MENU_SAVE_SETTINGS"].."\n", - func = function(info, v) + name = L["TITAN_PANEL_MENU_SAVE_SETTINGS"] .. "\n", + func = function(info, v) TitanPanel_SaveCustomProfile() TitanUpdateChars() -- rebuild the toons end, @@ -1519,7 +1598,9 @@ local function TitanUpdateChars() cmdHidden = true, } args["global_use"] = { - order = 21, type = "toggle", width = "full", + order = 21, + type = "toggle", + width = "full", name = L["TITAN_PANEL_GLOBAL_USE"], desc = L["TITAN_PANEL_GLOBAL_USE_DESC"], get = function() return TitanAllGetVar("GlobalProfileUse") end, @@ -1530,8 +1611,11 @@ local function TitanUpdateChars() end, } args["global_name"] = { - order = 22, type = "description", width = "full", - name = L["TITAN_PANEL_GLOBAL_PROFILE"]..": "..TitanUtils_GetGoldText(TitanAllGetVar("GlobalProfileName") or "?"), + order = 22, + type = "description", + width = "full", + name = L["TITAN_PANEL_GLOBAL_PROFILE"] .. + ": " .. TitanUtils_GetGoldText(TitanAllGetVar("GlobalProfileName") or "?"), } args["sp_20"] = { type = "description", @@ -1542,7 +1626,7 @@ local function TitanUpdateChars() args["profile_header"] = { order = 30, type = "header", - name = L["TITAN_PANEL_MENU_PROFILES"].."\n", + name = L["TITAN_PANEL_MENU_PROFILES"] .. "\n", cmdHidden = true } for idx, value in pairs(players) do @@ -1552,8 +1636,8 @@ local function TitanUpdateChars() local disallow = false disallow = -- looks weird but we need to force a true or Ace complains ((name == TitanSettings.Player) - or ((name == TitanAllGetVar("GlobalProfileName")) - and (TitanAllGetVar("GlobalProfileUse"))) + or ((name == TitanAllGetVar("GlobalProfileName")) + and (TitanAllGetVar("GlobalProfileUse"))) ) and true or false if name then @@ -1588,8 +1672,10 @@ local function TitanUpdateChars() }, optionload = { name = L["TITAN_PANEL_MENU_LOAD_SETTINGS"], - order = 20, type = "execute", width = "full", - func = function(info, v) + order = 20, + type = "execute", + width = "full", + func = function(info, v) TitanVariables_UseSettings(info[1], TITAN_PROFILE_USE) end, -- does not make sense to load current character profile or global profile @@ -1603,15 +1689,17 @@ local function TitanUpdateChars() }, optionreset = { name = L["TITAN_PANEL_MENU_DELETE_SETTINGS"], - order = 30, type = "execute", width = "full", - func = function(info, v) + order = 30, + type = "execute", + width = "full", + func = function(info, v) TitanSettings.Players[info[1]] = nil -- delete the config entry TitanPrint( L["TITAN_PANEL_MENU_PROFILE"] - ..info[1] - ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] + .. info[1] + .. L["TITAN_PANEL_MENU_PROFILE_DELETED"] , "info") - if name == TitanAllGetVar("GlobalProfileName") then + if name == TitanAllGetVar("GlobalProfileName") then TitanAllSetVar("GlobalProfileName", TITAN_PROFILE_NONE) end TitanUpdateChars() -- rebuild the toons @@ -1639,14 +1727,16 @@ local function TitanUpdateChars() cmdHidden = true, }, use_as_global = { - order = 41, type = "toggle", width = "full", + order = 41, + type = "toggle", + width = "full", name = L["TITAN_PANEL_GLOBAL_USE_AS"], get = function() return TitanPanelGetVar("GlobalProfileName") == name end, - set = function() - if TitanPanelGetVar("GlobalProfileName") == name then + set = function() + if TitanPanelGetVar("GlobalProfileName") == name then -- Was unchecked so clear the saved var TitanAllSetVar("GlobalProfileName", TITAN_PROFILE_NONE) - else + else -- Was checked so set the saved var TitanAllSetVar("GlobalProfileName", name) end @@ -1658,11 +1748,11 @@ local function TitanUpdateChars() TitanVariables_UseSettings(TitanAllGetVar("GlobalProfileName"), TITAN_PROFILE_USE) TitanPrint( L["TITAN_PANEL_MENU_PROFILE"] - ..":"..(TitanAllGetVar("GlobalProfileName") or "?") - ..": "..L["TITAN_PANEL_GLOBAL_RESET_PART"].."..." + .. ":" .. (TitanAllGetVar("GlobalProfileName") or "?") + .. ": " .. L["TITAN_PANEL_GLOBAL_RESET_PART"] .. "..." , "info") else - -- + -- end TitanUpdateChars() AceConfigRegistry:NotifyChange("Titan Panel Addon Chars") @@ -1690,8 +1780,8 @@ end --[[ local NAME: optionsFrames -DESC: Show the general Tian options that hte user can change: -Tooltips: +DESC: Show the general Tian options that hte user can change: +Tooltips: - Hide in combat - Show (or not) Frames (bars): @@ -1714,21 +1804,26 @@ local optionsFrames = { }, optiontooltip = { name = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN"], --- desc = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN"], - order = 201, type = "toggle", width = "full", + -- desc = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN"], + order = 201, + type = "toggle", + width = "full", get = function() return TitanPanelGetVar("ToolTipsShown") end, set = function() TitanPanelToggleVar("ToolTipsShown"); end, }, optiontooltipcombat = { name = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN_IN_COMBAT"], --- desc = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN_IN_COMBAT"], - order = 210, type = "toggle", width = "full", + -- desc = L["TITAN_PANEL_MENU_TOOLTIPS_SHOWN_IN_COMBAT"], + order = 210, + type = "toggle", + width = "full", get = function() return TitanPanelGetVar("HideTipsInCombat") end, set = function() TitanPanelToggleVar("HideTipsInCombat"); end, }, conftooltipdesc = { name = "Tooltip Modifier", - type = "group", inline = true, + type = "group", + inline = true, order = 220, args = { confdesc = { @@ -1736,11 +1831,13 @@ local optionsFrames = { type = "description", name = "", cmdHidden = true, - }, + }, advname = { name = L["TITAN_PANEL_MENU_TOOLTIP_MOD"], desc = "", -- L[""], - order = 120, type = "toggle", width = "full", + order = 120, + type = "toggle", + width = "full", get = function() return TitanAllGetVar("UseTooltipModifer") end, set = function(_, a) TitanAllSetVar("UseTooltipModifer", a); @@ -1748,13 +1845,15 @@ local optionsFrames = { }, tooltipmod = { name = "", - type = "group", inline = true, + type = "group", + inline = true, order = 140, args = { alt_key = { name = _G["ALT_KEY_TEXT"], desc = _G["ALT_KEY"], - order = 110, type = "toggle", --width = "full", + order = 110, + type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferAlt") end, set = function(_, a) TitanAllSetVar("TooltipModiferAlt", a); @@ -1763,7 +1862,8 @@ local optionsFrames = { ctrl_key = { name = _G["CTRL_KEY_TEXT"], desc = _G["CTRL_KEY"], - order = 120, type = "toggle", --width = "full", + order = 120, + type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferCtrl") end, set = function(_, a) TitanAllSetVar("TooltipModiferCtrl", a); @@ -1772,7 +1872,8 @@ local optionsFrames = { shift_key = { name = _G["SHIFT_KEY_TEXT"], desc = _G["SHIFT_KEY"], - order = 130, type = "toggle", --width = "full", + order = 130, + type = "toggle", --width = "full", get = function() return TitanAllGetVar("TooltipModiferShift") end, set = function(_, a) TitanAllSetVar("TooltipModiferShift", a); @@ -1789,19 +1890,25 @@ local optionsFrames = { }, optionlock = { name = L["TITAN_PANEL_MENU_LOCK_BUTTONS"], - order = 301, type = "toggle", width = "full", + 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"], - order = 302, type = "toggle", width = "full", + 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"], - order = 303, type = "toggle", width = "full", + order = 303, + type = "toggle", + width = "full", get = function() return TitanPanelGetVar("LockAutoHideInCombat") end, set = function() TitanPanelToggleVar("LockAutoHideInCombat") end, }, @@ -1813,7 +1920,9 @@ local optionsFrames = { }, optionlaunchers = { name = L["TITAN_PANEL_MENU_LDB_FORCE_LAUNCHER"], - order = 401, type = "execute", width = "full", + order = 401, + type = "execute", + width = "full", func = function() TitanPanelBarButton_ForceLDBLaunchersRight() end, }, space_500_1 = { @@ -1825,7 +1934,9 @@ local optionsFrames = { pluginreset = { name = L["TITAN_PANEL_MENU_PLUGIN_RESET"], desc = L["TITAN_PANEL_MENU_PLUGIN_RESET_DESC"], - order = 501, type = "execute", width = "full", + order = 501, + type = "execute", + width = "full", func = function() TitanPanel_InitPanelButtons() end, }, space_600_1 = { @@ -1835,22 +1946,24 @@ local optionsFrames = { cmdHidden = true, }, optionreset = { - name = L["TITAN_PANEL_MENU_RESET"].." " - .._G["GREEN_FONT_COLOR_CODE"] - ..L["TITAN_PANEL_MENU_RELOADUI"], - order = 601, type = "execute", width = "full", + name = L["TITAN_PANEL_MENU_RESET"] .. " " + .. _G["GREEN_FONT_COLOR_CODE"] + .. L["TITAN_PANEL_MENU_RELOADUI"], + order = 601, + type = "execute", + width = "full", func = function() TitanPanel_ResetToDefault() end, } } - } +} ------------- --============= Scale and Font --[[ local NAME: optionsUIScale -DESC: Local table to hold the Titan options that allow a user to adjust: -- UI scale +DESC: Local table to hold the Titan options that allow a user to adjust: +- UI scale - Titan scale for bars - Spacing between Titan plugins (right side) - Spacing between Titan icons (left side) @@ -1868,30 +1981,37 @@ local optionsUIScale = { confdesc = { order = 1, type = "description", - name = L["TITAN_PANEL_UISCALE_MENU_DESC"].."\n", + name = L["TITAN_PANEL_UISCALE_MENU_DESC"] .. "\n", cmdHidden = true }, uiscale = { name = L["TITAN_PANEL_UISCALE_CONTROL_TITLE_UI"], desc = L["TITAN_PANEL_UISCALE_SLIDER_DESC"], - order = 2, type = "range", width = "full", - min = 0.64, max = 1, step = 0.01, + order = 2, + type = "range", + width = "full", + min = 0.64, + max = 1, + step = 0.01, get = function() return UIParent:GetScale() end, set = function(_, a) SetCVar("useUiScale", 1); - SetCVar("uiScale", a, "uiScale"); + SetCVar("uiScale", a); end, }, panelscale = { name = L["TITAN_PANEL_UISCALE_CONTROL_TITLE_PANEL"], desc = L["TITAN_PANEL_UISCALE_PANEL_SLIDER_DESC"], - order = 3, type = "range", width = "full", - min = 0.75, max = 1.25, step = 0.01, + order = 3, + type = "range", + width = "full", + 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) + TitanPanel_InitPanelBarButton("Config scale change " .. a) end, disabled = function() if InCombatLockdown() then @@ -1904,8 +2024,12 @@ local optionsUIScale = { buttonspacing = { name = L["TITAN_PANEL_UISCALE_CONTROL_TITLE_BUTTON"], desc = L["TITAN_PANEL_UISCALE_BUTTON_SLIDER_DESC"], - order = 4, type = "range", width = "full", - min = 5, max = 80, step = 1, + order = 4, + type = "range", + width = "full", + min = 5, + max = 80, + step = 1, get = function() return TitanPanelGetVar("ButtonSpacing") end, set = function(_, a) TitanPanelSetVar("ButtonSpacing", a); @@ -1915,8 +2039,12 @@ local optionsUIScale = { iconspacing = { -- right side plugins name = L["TITAN_PANEL_UISCALE_CONTROL_TITLE_ICON"], desc = L["TITAN_PANEL_UISCALE_ICON_SLIDER_DESC"], - order = 5, type = "range", width = "full", - min = 0, max = 20, step = 1, + order = 5, + type = "range", + width = "full", + min = 0, + max = 20, + step = 1, get = function() return TitanPanelGetVar("IconSpacing") end, set = function(_, a) TitanPanelSetVar("IconSpacing", a); @@ -1925,19 +2053,26 @@ local optionsUIScale = { }, spacer01 = { type = "description", - name = "\n\n", imageHeight = 0, - order = 10, width = "full", + name = "\n\n", + imageHeight = 0, + order = 10, + width = "full", }, tooltipdesc = { - order = 20, width = "full", + order = 20, + width = "full", type = "header", name = "Tooltip", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TITLE"], }, tooltipfont = { name = L["TITAN_PANEL_UISCALE_CONTROL_TOOLTIP_TOOLTIPFONT"], desc = L["TITAN_PANEL_UISCALE_TOOLTIP_SLIDER_DESC"], - order = 21, type = "range", width = "full", - min = 0.5, max = 1.3, step = 0.01, + order = 21, + type = "range", + width = "full", + min = 0.5, + max = 1.3, + step = 0.01, get = function() return TitanPanelGetVar("TooltipFont") end, set = function(_, a) TitanPanelSetVar("TooltipFont", a); @@ -1946,21 +2081,26 @@ local optionsUIScale = { tooltipfontdisable = { name = L["TITAN_PANEL_UISCALE_TOOLTIP_DISABLE_TEXT"], desc = L["TITAN_PANEL_UISCALE_DISABLE_TOOLTIP_DESC"], - order = 22, 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", + 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 = 31, + type = "select", + width = "40", dialogControl = "LSM30_Font", get = function() return TitanPanelGetVar("FontName") @@ -1972,14 +2112,20 @@ local optionsUIScale = { values = AceGUIWidgetLSMlists.font, }, fontspacer = { - order = 32, type = "description", width = "20", + 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", - min = 7, max = 15, step = 1, + order = 33, + type = "range", + width = "40", + min = 7, + max = 15, + step = 1, get = function() return TitanPanelGetVar("FontSize") end, set = function(_, v) TitanPanelSetVar("FontSize", v); @@ -1987,14 +2133,16 @@ local optionsUIScale = { end, }, paneldesc = { - order = 40, width = "full", + 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 = 41, + type = "select", get = function() return TitanPanelGetVar("FrameStrata") end, @@ -2003,25 +2151,25 @@ local optionsUIScale = { TitanVariables_SetPanelStrata(v) end, values = { - ["BACKGROUND"] = "BACKGROUND", - ["LOW"] = "LOW", - ["MEDIUM"] = "MEDIUM", - ["HIGH"] = "HIGH", - ["DIALOG"] = "DIALOG", - ["FULLSCREEN"] = "FULLSCREEN", + ["BACKGROUND"] = "BACKGROUND", + ["LOW"] = "LOW", + ["MEDIUM"] = "MEDIUM", + ["HIGH"] = "HIGH", + ["DIALOG"] = "DIALOG", + ["FULLSCREEN"] = "FULLSCREEN", }, }, panelstrataorder = { - order = 42, - type = "description", - name = "Order of Strata\n" - .."- BACKGROUND\n" - .."- LOW - default\n" - .."- MEDIUM\n" - .."- HIGH\n" - .."- DIALOG\n" - .."- FULLSCREEN\n", - cmdHidden = true + order = 42, + type = "description", + name = "Order of Strata\n" + .. "- BACKGROUND\n" + .. "- LOW - default\n" + .. "- MEDIUM\n" + .. "- HIGH\n" + .. "- DIALOG\n" + .. "- FULLSCREEN\n", + cmdHidden = true }, } } @@ -2034,86 +2182,95 @@ 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, - type = "group", - args = { - } + name = TITAN_PANEL_CONFIG.topic.skins, + type = "group", + args = { + } } 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 skin = "Skin" - for idx, v in pairs (TitanSkins) do - + for idx, v in pairs(TitanSkins) do position = position + 1 -- spacer - t[skin..position] = { + t[skin .. position] = { type = "header", name = "", - order = position, width = "full", + order = position, + width = "full", } position = position + 1 -- Name of skin (col 1) - t[skin..position] = { + t[skin .. position] = { type = "description", - name = "|cff19ff19"..v.name.."|r", - order = position, width = "30", + name = "|cff19ff19" .. v.name .. "|r", + order = position, + width = "30", } position = position + 1 -- Top image (col 2) - t[skin..position] = { + t[skin .. position] = { type = "description", name = "", - image = v.path.."TitanPanelBackgroundTop0", + image = v.path .. "TitanPanelBackgroundTop0", imageWidth = 256, - order = position, width = "50", + order = position, + width = "50", } position = position + 1 -- spacer - t[skin..position] = { + t[skin .. position] = { type = "description", - name = "", imageHeight = 0, - order = position, width = "full", + name = "", + imageHeight = 0, + order = position, + width = "full", } position = position + 1 -- Bottom (col 1) - t[skin..position] = { + t[skin .. position] = { type = "description", name = "", - order = position, width = "30", + order = position, + width = "30", } position = position + 1 -- Bottom image (col 2) - t[skin..position] = { + t[skin .. position] = { type = "description", name = "", - image = v.path.."TitanPanelBackgroundBottom0", + image = v.path .. "TitanPanelBackgroundBottom0", imageWidth = 256, - order = position, width = "50", + order = position, + width = "50", } position = position + 1 -- final spacer - bottom of config - t[skin..position] = { + t[skin .. position] = { type = "description", - name = "", imageHeight = 0, - order = position, width = "full", + name = "", + imageHeight = 0, + order = position, + width = "full", } end - + position = position + 1 -- final spacer - bottom of config - t[skin..position] = { + t[skin .. position] = { type = "description", name = "", - order = position, width = "full", + 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") end @@ -2134,15 +2291,15 @@ NOTE: local function TitanPanel_AddNewSkin(skinname, skinpath) -- name and path must be provided if not skinname or not skinpath then return end - + -- name cannot be empty or "None", path cannot be empty if skinname == "" or skinname == L["TITAN_PANEL_NONE"] or skinpath == "" then - return - end - + return + end + -- Assume the skin is already in the Titan saved variables list local found - for _,i in pairs(TitanSkins) do + for _, i in pairs(TitanSkins) do if i.name == skinname or i.path == skinpath then found = true break @@ -2150,18 +2307,17 @@ local function TitanPanel_AddNewSkin(skinname, skinpath) end -- The skin is new so add it to the Titan saved variables list - if not found then - table.insert(TitanSkins, {name = skinname, path = skinpath }) + if not found then + table.insert(TitanSkins, { name = skinname, path = skinpath }) end - - BuildSkins() + BuildSkins() end --[[ local NAME: optionsSkinsCustom -DESC: Local table to hold the Titan custom skins options that allow a user to add or delete skins. -- You may not remove the currently used skin +DESC: Local table to hold the Titan custom skins options that allow a user to add or delete skins. +- You may not remove the currently used skin - or the default one - or a Titan default skin (it would only come back...) :DESC @@ -2173,7 +2329,7 @@ local optionsSkinsCustom = { confdesc = { order = 1, type = "description", - name = L["TITAN_PANEL_SKINS_MAIN_DESC"].."\n", + name = L["TITAN_PANEL_SKINS_MAIN_DESC"] .. "\n", cmdHidden = true }, nulloption1 = { @@ -2191,22 +2347,25 @@ local optionsSkinsCustom = { order = 11, name = L["TITAN_PANEL_SKINS_NAME_TITLE"], desc = L["TITAN_PANEL_SKINS_NAME_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function() return TitanSkinName end, - set = function(_,v) TitanSkinName = v end, + set = function(_, v) TitanSkinName = v end, }, newskinpath = { order = 12, name = L["TITAN_PANEL_SKINS_PATH_TITLE"], desc = L["TITAN_PANEL_SKINS_PATH_DESC"], - type = "input", width = "full", + type = "input", + width = "full", get = function() return TitanSkinPath end, - set = function(_,v) TitanSkinPath = TitanSkinsCustomPath..v..TitanSkinsPathEnd end, + set = function(_, v) TitanSkinPath = TitanSkinsCustomPath .. v .. TitanSkinsPathEnd end, }, addnewskin = { order = 13, - name = L["TITAN_PANEL_SKINS_ADD_HEADER"], type = "execute", + name = L["TITAN_PANEL_SKINS_ADD_HEADER"], + type = "execute", desc = L["TITAN_PANEL_SKINS_ADD_DESC"], func = function() if TitanSkinName ~= "" and TitanSkinPath ~= "" then @@ -2230,47 +2389,50 @@ local optionsSkinsCustom = { name = L["TITAN_PANEL_SKINS_REMOVE_HEADER"], }, removeskinlist = { - order = 21, type = "select", width = "full", + order = 21, + type = "select", + width = "full", name = L["TITAN_PANEL_SKINS_REMOVE_HEADER"], desc = L["TITAN_PANEL_SKINS_REMOVE_DESC"], get = function() return TitanSkinToRemove end, - set = function(_,v) + set = function(_, v) TitanSkinToRemove = v end, values = function() - local Skinlist = {} - local v; - for _,v in pairs (TitanSkins) do - if v.path ~= TitanPanelGetVar("TexturePath") - and v.path ~= "Interface\\AddOns\\Titan\\Artwork\\" - and v.titan ~= true + local Skinlist = {} + local v; + for _, v in pairs(TitanSkins) do + if v.path ~= TitanPanelGetVar("TexturePath") + and v.path ~= "Interface\\AddOns\\Titan\\Artwork\\" + and v.titan ~= true then - Skinlist[v.path] = "|cff19ff19"..v.name.."|r" + Skinlist[v.path] = "|cff19ff19" .. v.name .. "|r" end if v.path == TitanSkinToRemove then - Skinlist[v.path] = "|cffffff9a"..v.name.."|r" + Skinlist[v.path] = "|cffffff9a" .. v.name .. "|r" end end if TitanSkinToRemove ~= "None" then - Skinlist["None"] = "|cff19ff19"..L["TITAN_PANEL_NONE"].."|r" + Skinlist["None"] = "|cff19ff19" .. L["TITAN_PANEL_NONE"] .. "|r" else - Skinlist["None"] = "|cffffff9a"..L["TITAN_PANEL_NONE"].."|r" + Skinlist["None"] = "|cffffff9a" .. L["TITAN_PANEL_NONE"] .. "|r" end table.sort(Skinlist, function(a, b) - return string.lower(TitanSkins[a].name) + return string.lower(TitanSkins[a].name) < string.lower(TitanSkins[b].name) end) - return Skinlist + return Skinlist end, }, removeskin = { - order = 22, type = "execute", + order = 22, + type = "execute", name = L["TITAN_PANEL_SKINS_REMOVE_BUTTON"], desc = L["TITAN_PANEL_SKINS_REMOVE_BUTTON_DESC"], func = function() - if TitanSkinToRemove == "None" then return end - local k, v; - for k, v in pairs (TitanSkins) do + if TitanSkinToRemove == "None" then return end + local k, v; + for k, v in pairs(TitanSkins) do if v.path == TitanSkinToRemove then table.remove(TitanSkins, k) TitanSkinToRemove = "None" @@ -2287,24 +2449,25 @@ local optionsSkinsCustom = { name = " ", cmdHidden = true }, - resetskinhdear = { + resetskinhdear = { order = 200, type = "header", name = L["TITAN_PANEL_SKINS_RESET_HEADER"], - }, - defaultskins = { - order = 201, - name = L["TITAN_PANEL_SKINS_RESET_DEFAULTS_TITLE"], type = "execute", - desc = L["TITAN_PANEL_SKINS_RESET_DEFAULTS_DESC"], - func = function() - TitanSkins = TitanSkinsDefault; - BuildSkins() - end, - }, + }, + defaultskins = { + order = 201, + name = L["TITAN_PANEL_SKINS_RESET_DEFAULTS_TITLE"], + type = "execute", + desc = L["TITAN_PANEL_SKINS_RESET_DEFAULTS_DESC"], + func = function() + TitanSkins = TitanSkinsDefault; + BuildSkins() + end, + }, notes_delete = { order = 999, type = "description", - name = "\n\n"..L["TITAN_PANEL_SKINS_REMOVE_NOTES"].."\n", + name = "\n\n" .. L["TITAN_PANEL_SKINS_REMOVE_NOTES"] .. "\n", cmdHidden = true }, } @@ -2344,7 +2507,7 @@ local function TitanUpdateExtras() args["desc"] = { order = 1, type = "description", - name = L["TITAN_PANEL_EXTRAS_DESC"].."\n", + name = L["TITAN_PANEL_EXTRAS_DESC"] .. "\n", cmdHidden = true } for idx, value in pairs(TitanPluginExtras) do @@ -2353,7 +2516,7 @@ local function TitanUpdateExtras() local name = TitanPluginExtras[idx].id args[name] = { type = "group", - name = TitanUtils_GetGoldText(tostring(num)..": "..(name or "?")), + name = TitanUtils_GetGoldText(tostring(num) .. ": " .. (name or "?")), order = idx, args = { name = { @@ -2364,14 +2527,16 @@ local function TitanUpdateExtras() }, optionreset = { name = L["TITAN_PANEL_EXTRAS_DELETE_BUTTON"], - order = 15, type = "execute", width = "full", - func = function(info, v) + order = 15, + type = "execute", + width = "full", + func = function(info, v) TitanPluginSettings[info[1]] = nil -- delete the config entry TitanPrint( - " '"..info[1].."' "..L["TITAN_PANEL_EXTRAS_DELETE_MSG"] + " '" .. info[1] .. "' " .. L["TITAN_PANEL_EXTRAS_DELETE_MSG"] , "info") - TitanVariables_ExtraPluginSettings() -- rebuild the list - TitanUpdateExtras() -- rebuild the options config + -- TitanVariables_ExtraPluginSettings() -- rebuild the list + TitanUpdateExtras() -- rebuild the options config AceConfigRegistry:NotifyChange("Titan Panel Addon Extras") -- tell Ace to redraw end, }, @@ -2379,7 +2544,7 @@ local function TitanUpdateExtras() } end end - + AceConfigRegistry:NotifyChange("Titan Panel Addon Extras") end ------------- @@ -2420,7 +2585,7 @@ local function TitanUpdateAddonAttempts() cmdHidden = true } for idx, value in pairs(TitanPluginToBeRegistered) do - if TitanPluginToBeRegistered[idx] + if TitanPluginToBeRegistered[idx] then local num = tostring(idx) local button = TitanPluginToBeRegistered[idx].button @@ -2437,11 +2602,11 @@ local function TitanUpdateAddonAttempts() title = TitanUtils_GetRedText(title) issue = TitanUtils_GetRedText(issue) end - + if isChild then -- Do not show. A child is part of (within) another plugin -- showing it here would be confusing to the 'normal' user. - -- A plugin in author would know to look at the + -- A plugin in author would know to look at the -- TitanPluginToBeRegistered array directly. else args[num] = { @@ -2449,27 +2614,27 @@ local function TitanUpdateAddonAttempts() name = title, order = idx, args = { - name ={ + name = { type = "description", - name = TitanUtils_GetGoldText("")..name, + name = TitanUtils_GetGoldText("") .. name, cmdHidden = true, order = 1, }, reason = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_STATUS"]..": ")..reason, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_STATUS"] .. ": ") .. reason, cmdHidden = true, order = 2, }, issue = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_ISSUE"]..": \n")..issue, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_ISSUE"] .. ": \n") .. issue, cmdHidden = true, order = 3, }, notes = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_NOTES"]..": \n")..notes, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_NOTES"] .. ": \n") .. notes, cmdHidden = true, order = 4, }, @@ -2481,25 +2646,25 @@ local function TitanUpdateAddonAttempts() }, category = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_CATEGORY"]..": ")..category, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_CATEGORY"] .. ": ") .. category, cmdHidden = true, order = 10, }, ptype = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TYPE"]..": ")..ptype, --.." "..btype, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TYPE"] .. ": ") .. ptype, --.." "..btype, cmdHidden = true, order = 11, }, button = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_BUTTON"]..": ")..button, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_BUTTON"] .. ": ") .. button, cmdHidden = true, order = 12, }, num_val = { type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TABLE"]..": ")..num, + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TABLE"] .. ": ") .. num, cmdHidden = true, order = 13, }, @@ -2517,65 +2682,79 @@ end --============= Advanced local conftimerdesc = { - name = L["TITAN_PANEL_MENU_ADV_TIMER"], - type = "group", inline = true, - order = 1, - args = { - confdesc = { - order = 10, - type = "description", - name = L["TITAN_PANEL_MENU_ADV_TIMER_DESC"], - cmdHidden = true - }, - advtimerpew = { - name = L["TITAN_PANEL_MENU_ADV_PEW"], - desc = L["TITAN_PANEL_MENU_ADV_PEW_DESC"], - order = 20, type = "range", width = "full", - min = 1, max = 10, step = 0.5, - get = function() return TitanAllGetVar("TimerPEW") end, - set = function(_, a) - TitanAllSetVar("TimerPEW", a); - TitanTimers["EnterWorld"].delay = a - end, - }, - advtimervehicle = { - name = L["TITAN_PANEL_MENU_ADV_VEHICLE"], - desc = L["TITAN_PANEL_MENU_ADV_VEHICLE_DESC"], - order = 50, type = "range", width = "full", - min = 1, max = 10, step = 0.5, - get = function() return TitanAllGetVar("TimerVehicle") end, - set = function(_, a) - TitanAllSetVar("TimerVehicle", a); - TitanTimers["Vehicle"].delay = a - end, - }, - }, - } + name = L["TITAN_PANEL_MENU_ADV_TIMER"], + type = "group", + inline = true, + order = 1, + args = { + confdesc = { + order = 10, + type = "description", + name = L["TITAN_PANEL_MENU_ADV_TIMER_DESC"], + cmdHidden = true + }, + advtimerpew = { + name = L["TITAN_PANEL_MENU_ADV_PEW"], + desc = L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 20, + type = "range", + width = "full", + min = 1, + max = 10, + step = 0.5, + get = function() return TitanAllGetVar("TimerPEW") end, + set = function(_, a) + TitanAllSetVar("TimerPEW", a); + TitanTimers["EnterWorld"].delay = a + end, + }, + advtimervehicle = { + name = L["TITAN_PANEL_MENU_ADV_VEHICLE"], + desc = L["TITAN_PANEL_MENU_ADV_VEHICLE_DESC"], + order = 50, + type = "range", + width = "full", + min = 1, + max = 10, + step = 0.5, + get = function() return TitanAllGetVar("TimerVehicle") end, + set = function(_, a) + TitanAllSetVar("TimerVehicle", a); + TitanTimers["Vehicle"].delay = a + end, + }, + }, +} local confbuffdesc = { - name = L["TITAN_PANEL_MENU_ADV_BUFF"], - type = "group", inline = true, - order = 2, - args = { - confbuffdesc = { - order = 110, - type = "description", - name = L["TITAN_PANEL_MENU_ADV_BUFF_DESC"], - cmdHidden = true - }, - advbuffadj = { - name = "Buff", --L["TITAN_PANEL_MENU_ADV_PEW"], - desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], - order = 120, type = "range", width = "full", - min = -100, max = 100, step = 1, - get = function() return TitanPanelGetVar("BuffIconVerticalAdj") end, - set = function(_, a) - TitanPanelSetVar("BuffIconVerticalAdj", a); - -- Adjust frame positions - TitanPanel_AdjustFrames(true, "BuffIconVerticalAdj") - end, - }, - }, - } + name = L["TITAN_PANEL_MENU_ADV_BUFF"], + type = "group", + inline = true, + order = 2, + args = { + confbuffdesc = { + order = 110, + type = "description", + name = L["TITAN_PANEL_MENU_ADV_BUFF_DESC"], + cmdHidden = true + }, + advbuffadj = { + name = "Buff", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 120, + type = "range", + width = "full", + min = -100, + max = 100, + step = 1, + get = function() return TitanPanelGetVar("BuffIconVerticalAdj") end, + set = function(_, a) + TitanPanelSetVar("BuffIconVerticalAdj", a); + -- Adjust frame positions + TitanPanel_AdjustFrames(true, "BuffIconVerticalAdj") + end, + }, + }, +} --[[ local NAME: optionsAdvanced @@ -2591,7 +2770,8 @@ local optionsAdvanced = { args = { confoutputdesc = { name = L["TITAN_PANEL_MENU_ADV_OUTPUT"], - type = "group", inline = true, + type = "group", + inline = true, order = 3, args = { confdesc = { @@ -2599,11 +2779,13 @@ local optionsAdvanced = { type = "description", name = L["TITAN_PANEL_MENU_ADV_OUTPUT_DESC"], cmdHidden = true - }, + }, advname = { name = L["TITAN_PANEL_MENU_ADV_NAME"], desc = L["TITAN_PANEL_MENU_ADV_NAME_DESC"], - order = 120, type = "toggle", width = "full", + order = 120, + type = "toggle", + width = "full", get = function() return not TitanAllGetVar("Silenced") end, -- yes, we did it to ourselves... set = function(_, a) TitanAllSetVar("Silenced", not a); @@ -2612,7 +2794,9 @@ local optionsAdvanced = { advplugins = { name = L["TITAN_PANEL_MENU_ADV_PLUGINS"], desc = L["TITAN_PANEL_MENU_ADV_PLUGINS_DESC"], - order = 120, type = "toggle", width = "full", + order = 120, + type = "toggle", + width = "full", get = function() return TitanAllGetVar("Registered") end, set = function(_, a) TitanAllSetVar("Registered", a); @@ -2651,13 +2835,14 @@ local changeHistory = { confchanges = { order = 7, name = " ", --CHANGES_COLON, - type = "group", inline = true, + type = "group", + inline = true, args = { confversiondesc = { - order = 1, - type = "description", - name = ""..changes, - cmdHidden = true + order = 1, + type = "description", + name = "" .. changes, + cmdHidden = true }, } }, @@ -2679,49 +2864,50 @@ local slashHelp = { confslash = { name = (HELP or "Help"), order = 3, - type = "group", inline = true, + type = "group", + inline = true, args = { confversiondesc = { - order = 1, - type = "description", - name = "" - ..TitanUtils_GetGoldText("reset\n") - ..L["TITAN_PANEL_SLASH_RESET_0"].."\n" - ..L["TITAN_PANEL_SLASH_RESET_1"].."\n" - ..L["TITAN_PANEL_SLASH_RESET_2"].."\n" - ..L["TITAN_PANEL_SLASH_RESET_3"].."\n" - ..L["TITAN_PANEL_SLASH_RESET_4"].."\n" - ..L["TITAN_PANEL_SLASH_RESET_5"].."\n" - .."\n" - ..TitanUtils_GetGoldText("gui\n") - ..L["TITAN_PANEL_SLASH_GUI_0"].."\n" - ..L["TITAN_PANEL_SLASH_GUI_1"].."\n" - ..L["TITAN_PANEL_SLASH_GUI_2"].."\n" - ..L["TITAN_PANEL_SLASH_GUI_3"].."\n" - .."\n" - ..TitanUtils_GetGoldText("profile\n") - ..L["TITAN_PANEL_SLASH_PROFILE_0"].."\n" - ..L["TITAN_PANEL_SLASH_PROFILE_1"].."\n" - ..L["TITAN_PANEL_SLASH_PROFILE_2"].."\n" - ..L["TITAN_PANEL_SLASH_PROFILE_3"].."\n" - .."\n" - ..TitanUtils_GetGoldText("silent\n") - ..L["TITAN_PANEL_SLASH_SILENT_0"].."\n" - ..L["TITAN_PANEL_SLASH_SILENT_1"].."\n" - .."\n" - ..TitanUtils_GetGoldText("orderhall\n") - ..L["TITAN_PANEL_SLASH_ORDERHALL_0"].."\n" - ..L["TITAN_PANEL_SLASH_ORDERHALL_1"].."\n" - .."\n" - ..TitanUtils_GetGoldText("help\n") - ..L["TITAN_PANEL_SLASH_HELP_0"].."\n" - ..L["TITAN_PANEL_SLASH_HELP_1"].."\n" - .."\n" - ..TitanUtils_GetGoldText("all\n") - ..L["TITAN_PANEL_SLASH_ALL_0"].."\n" - ..L["TITAN_PANEL_SLASH_ALL_1"].."\n" - .."", - cmdHidden = true + order = 1, + type = "description", + name = "" + .. TitanUtils_GetGoldText("reset\n") + .. L["TITAN_PANEL_SLASH_RESET_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_RESET_1"] .. "\n" + .. L["TITAN_PANEL_SLASH_RESET_2"] .. "\n" + .. L["TITAN_PANEL_SLASH_RESET_3"] .. "\n" + .. L["TITAN_PANEL_SLASH_RESET_4"] .. "\n" + .. L["TITAN_PANEL_SLASH_RESET_5"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("gui\n") + .. L["TITAN_PANEL_SLASH_GUI_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_GUI_1"] .. "\n" + .. L["TITAN_PANEL_SLASH_GUI_2"] .. "\n" + .. L["TITAN_PANEL_SLASH_GUI_3"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("profile\n") + .. L["TITAN_PANEL_SLASH_PROFILE_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_PROFILE_1"] .. "\n" + .. L["TITAN_PANEL_SLASH_PROFILE_2"] .. "\n" + .. L["TITAN_PANEL_SLASH_PROFILE_3"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("silent\n") + .. L["TITAN_PANEL_SLASH_SILENT_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_SILENT_1"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("orderhall\n") + .. L["TITAN_PANEL_SLASH_ORDERHALL_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_ORDERHALL_1"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("help\n") + .. L["TITAN_PANEL_SLASH_HELP_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_HELP_1"] .. "\n" + .. "\n" + .. TitanUtils_GetGoldText("all\n") + .. L["TITAN_PANEL_SLASH_ALL_0"] .. "\n" + .. L["TITAN_PANEL_SLASH_ALL_1"] .. "\n" + .. "", + cmdHidden = true }, } }, @@ -2733,87 +2919,93 @@ local slashHelp = { local help_text = "" do -- set help_text -help_text = "" - ..TitanUtils_GetGreenText("Plugins: \n") - ..TitanUtils_GetGoldText("Show / Hide Plugins :") - ..TitanUtils_GetHighlightText("" - .." Use one of the methods below:\n" - .."- Open the right-click Bar menu; find the plugin in a category then click to toggle Show on the plugin.\n" - .."- Open Titan Configuration > Plugins then select the plugin by name then toggle Show. Uuse the Bar dropdown to select the Bar the plugin should be on.\n" + help_text = "" + .. TitanUtils_GetGreenText("Plugins: \n") + .. TitanUtils_GetGoldText("Show / Hide Plugins :") + .. TitanUtils_GetHighlightText("" + .. " Use one of the methods below:\n" + .. "- Open the right-click Bar menu; find the plugin in a category then click to toggle Show on the plugin.\n" + .. + "- Open Titan Configuration > Plugins then select the plugin by name then toggle Show. Uuse the Bar dropdown to select the Bar the plugin should be on.\n" ) - ..TitanUtils_GetGoldText("Moving Plugins :") - ..TitanUtils_GetHighlightText("" - .." Use one of the methods below:\n" - .."- Open the right-click Bar menu of the Bar you want the plugin on; find the plugin in a category then toggle Show. If plugin is already shown on another Bar then toggle again to have it appear in this Bar.\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 toggle Show. Use the Bar dropdown and Right / Left buttons to place the plugin as desired.\n" + .. TitanUtils_GetGoldText("Moving Plugins :") + .. TitanUtils_GetHighlightText("" + .. " Use one of the methods below:\n" + .. + "- Open the right-click Bar menu of the Bar you want the plugin on; find the plugin in a category then toggle Show. If plugin is already shown on another Bar then toggle again to have it appear in this Bar.\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 toggle Show. Use the Bar dropdown and Right / Left buttons to place the plugin as desired.\n" ) - .."\n\n" - ..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" - .."- Titan does not restrict plugins to fit within the visible width (background). 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 (background); and may overlap with left or center aligned plugins.\n" + .. "\n\n" + .. 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" + .. + "- Titan does not restrict plugins to fit within the visible width (background). 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 (background); and may overlap with left or center aligned plugins.\n" ) - ..TitanUtils_GetGoldText("Enable :\n") - ..TitanUtils_GetHighlightText("" - .."- 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" + .. TitanUtils_GetGoldText("Enable :\n") + .. TitanUtils_GetHighlightText("" + .. "- 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" ) - ..TitanUtils_GetGoldText("Change Size :\n") - ..TitanUtils_GetHighlightText("" - .."- Change width by 1 : Use Shift + mouse wheel.\n" - .."- Change width by 10: Use Shift + Ctrl + mouse wheel.\n" - .."- WIll not go beyond right side of screen.\n" + .. TitanUtils_GetGoldText("Change Size :\n") + .. TitanUtils_GetHighlightText("" + .. "- Change width by 1 : Use Shift + mouse wheel.\n" + .. "- Change width by 10: Use Shift + Ctrl + mouse wheel.\n" + .. "- WIll not go beyond right side of screen.\n" ) - ..TitanUtils_GetGoldText("Move :\n") - ..TitanUtils_GetHighlightText("" - .."- Use Shift + left mouse on Bar, not plugins, and drag.\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" + .. TitanUtils_GetGoldText("Move :\n") + .. TitanUtils_GetHighlightText("" + .. "- Use Shift + left mouse on Bar, not plugins, and drag.\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" ) - ..TitanUtils_GetGoldText("Reset :\n") - ..TitanUtils_GetHighlightText("" - .." In case a Short bar gets messed up, use Config > Bar > <Pick the Bar> then click Reset Position to place it at original position and width.\n" + .. TitanUtils_GetGoldText("Reset :\n") + .. TitanUtils_GetHighlightText("" + .. + " In case a Short bar gets messed up, use Config > Bar > <Pick the Bar> then click Reset Position to place it at original position and width.\n" ) - ..TitanUtils_GetGoldText("Skin :\n") - ..TitanUtils_GetHighlightText("" - .."- Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" + .. TitanUtils_GetGoldText("Skin :\n") + .. TitanUtils_GetHighlightText("" + .. "- Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" ) - ..TitanUtils_GetGoldText("Limitations :\n") - ..TitanUtils_GetHighlightText("" - .."- Min width : Left side padding plus one icon width.\n" - .."- Max width : Screen width.\n" - .."- There is no 'snap together' or grid for placing Short Bars.\n" - .."\n" + .. TitanUtils_GetGoldText("Limitations :\n") + .. TitanUtils_GetHighlightText("" + .. "- Min width : Left side padding plus one icon width.\n" + .. "- Max width : Screen width.\n" + .. "- There is no 'snap together' or grid for placing Short Bars.\n" + .. "\n" ) - ..TitanUtils_GetGreenText("All Bars: \n") - ..TitanUtils_GetHighlightText("" - .."- Bar Right click menu shows the name of the Bar in the menu title. Same name in configuration options.\n" - .."- Hide any Titan bar by using the Bar Right click menu then click Hide.\n" + .. TitanUtils_GetGreenText("All Bars: \n") + .. TitanUtils_GetHighlightText("" + .. "- Bar Right click menu shows the name of the Bar in the menu title. Same name in configuration options.\n" + .. "- Hide any Titan bar by using the Bar Right click menu then click Hide.\n" ) - ..TitanUtils_GetGoldText("Skins :\n") - ..TitanUtils_GetHighlightText("" - .."- Select per Titan bar.\n" - .."- Select a skin for all Titan bars. This does NOT change the individual Titan bar skin settings.\n" + .. TitanUtils_GetGoldText("Skins :\n") + .. TitanUtils_GetHighlightText("" + .. "- Select per Titan bar.\n" + .. "- Select a skin for all Titan bars. This does NOT change the individual Titan bar skin settings.\n" ) - ..TitanUtils_GetGoldText("Hide in Combat :\n") - ..TitanUtils_GetHighlightText("" - .."- Select per Titan bar.\n" - .."- Hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" + .. TitanUtils_GetGoldText("Hide in Combat :\n") + .. TitanUtils_GetHighlightText("" + .. "- Select per Titan bar.\n" + .. "- Hide all Titan bars during combat. This does NOT change the individual Titan bar hide in combat settings.\n" ) - ..TitanUtils_GetGoldText("Bar Order (English) :") - ..TitanUtils_GetHighlightText("" - .." 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" + .. TitanUtils_GetGoldText("Bar Order (English) :") + .. TitanUtils_GetHighlightText("" + .. " 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" + .. "\n\n" end --[[ local NAME: helpBars @@ -2821,19 +3013,20 @@ DESC: Help for the Titan Panel user :DESC --]] local helpBars = { - name = TITAN_PANEL_CONFIG.topic.help, + name = TITAN_PANEL_CONFIG.topic.help, type = "group", args = { confgendesc = { name = "Help", order = 1, - type = "group", inline = true, + type = "group", + inline = true, args = { confdesc = { - order = 1, - type = "description", - name = help_text, - cmdHidden = true + order = 1, + type = "description", + name = help_text, + cmdHidden = true }, } }, @@ -2872,10 +3065,10 @@ function TitanUpdateConfig(action) TitanPrint("-- Clearing Titan options...", "warning") -- Use the same group as below!! --- AceConfig:RegisterOptionsTable("Titan Panel Main", nuked) + -- 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) @@ -2891,7 +3084,6 @@ function TitanUpdateConfig(action) end end - --[[ Register the options tables with Ace then register the options with Blizz so the user can use them. --]] @@ -2931,7 +3123,7 @@ AceConfigDialog:AddToBlizOptions("Titan Panel Addon Chars", optionsChars.name, t AceConfigDialog:AddToBlizOptions("Titan Panel Frames", optionsFrames.name, titan_entry.name) AceConfigDialog:AddToBlizOptions("Titan Panel Panel Control", optionsUIScale.name, titan_entry.name) AceConfigDialog:AddToBlizOptions("Titan Panel Skin Control", optionsSkins.name, titan_entry.name) -AceConfigDialog:AddToBlizOptions("Titan Panel Skin Custom", optionsSkinsCustom.name, titan_entry.name) +AceConfigDialog:AddToBlizOptions("Titan Panel Skin Custom", optionsSkinsCustom.name, titan_entry.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Extras", optionsExtras.name, titan_entry.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Attempts", optionsAddonAttempts.name, titan_entry.name) AceConfigDialog:AddToBlizOptions("Titan Panel Addon Advanced", optionsAdvanced.name, titan_entry.name) diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index 5b4326d..859fe16 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -1,12 +1,14 @@ --[[ File NAME: TitanGlobal.lua -DESC: This file contains the global variables and constants used throughout Titan. +DESC: This file contains the global variables and constants used throughout Titan Panel. :DESC --]] +---@meta + -- Global variables -Titan_Panel = {} -- begin the slow journey to a smaller _G footprint +Titan_Global = {} -- begin the slow journey to a smaller _G footprint TITAN_PANEL_DEBUG_ARRAY_MAX = 100 @@ -18,7 +20,7 @@ TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"].."Not_Registered_Yet".._G["FONT 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__InitializedPEW = false Titan__Initialized_Settings = nil TITAN_AT = "@" @@ -57,9 +59,9 @@ TITAN_PANEL_BUTTONS_ALIGN_LEFT = 1; TITAN_PANEL_BUTTONS_ALIGN_CENTER = 2; -- Titan plugins are in the form of TitanPanel<id>Button -Titan_Panel.plugin = {} -Titan_Panel.plugin.PRE = "TitanPanel" -Titan_Panel.plugin.POST = "Button" +Titan_Global.plugin = {} +Titan_Global.plugin.PRE = "TitanPanel" +Titan_Global.plugin.POST = "Button" TITAN_PANEL_CONTROL = "TitanPanelBarButton" @@ -94,16 +96,52 @@ TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = {"Built-ins","General","Combat","Information","Interface","Profession"} -- Bar background types -Titan_Panel.SKIN = "skin" -Titan_Panel.COLOR = "color" -Titan_Panel.NONE = "none" +Titan_Global.SKIN = "skin" +Titan_Global.COLOR = "color" +Titan_Global.NONE = "none" -- For debug across Titan Panel -Titan_Panel.debug = {} -Titan_Panel.debug.movable = false -Titan_Panel.debug.events = false -Titan_Panel.debug.ldb_setup = false -Titan_Panel.debug.tool_tips = false -Titan_Panel.debug.plugin_register = false -Titan_Panel.debug.plugin_register_deep = false - +Titan_Global.debug = {} +Titan_Global.debug.movable = false +Titan_Global.debug.events = false +Titan_Global.debug.ldb_setup = false +Titan_Global.debug.tool_tips = false +Titan_Global.debug.plugin_register = false +Titan_Global.debug.plugin_register_deep = false +Titan_Global.debug.movable = false + +-- For WoW localized strings / literals we are using +Titan_Global.literals = { + low = LOW, + high = HIGH, + } + +-- type for plugin registry +---@class PluginRegistryType +---@field id string The unique name of the plugin +---@field category? string The Titan menu category where this plugin will be placed +---@field version? string Plugin version +---@field menuText? string Localized string for the menu (right click) +---@field menuTextFunction? string | function Plugin function to call on right click +---@field buttonTextFunction? string | function Function to call when updating button display +---@field tooltipTitle? string Localized string for the menu +---@field tooltipTextFunction? string | function Function to call for a simple tooltip (OnEnter) +---@field tooltipCustomFunction? function Function to call for a complex tooltip (OnEnter) +---@field icon? string Path to the plugin icon +---@field iconWidth? integer Path to the plugin icon +---@field notes? string Brief description shown in Titan > Config > Plugins when this plugin is selected +---@field controlVariables? table Show or not on menu - set to true or false - ShowIcon ShowLabelText ShowColoredText DisplayOnRightSide +---@field savedVariables? table Initial value of any saved variables for this plugin; should include control variables + +--[[ API -- for IDE +NAME: Titan_Global.NewRegistry +DESC: Return an empty registry - only the id is set. +This routine is mainly for use with an IDE with Intellisense that supports Lua. +:DESC +--]] +---@param id string The unique name of the plugin +---@return PluginRegistryType +Titan_Global.NewRegistry = function(id) + local reg = {id = id} ---@type PluginRegistryType + return reg + end diff --git a/Titan/TitanIDE.lua b/Titan/TitanIDE.lua new file mode 100644 index 0000000..683a7ea --- /dev/null +++ b/Titan/TitanIDE.lua @@ -0,0 +1,189 @@ +--[[ IDE + This file is NOT to be included in the TOC file! + This is intended to be used for IDE Intellisense. + + Tools used: + Visual Studio Code - https://code.visualstudio.com/ + Other IDEs accept Lua Language Server, see if your prefered IDE will accept LLS + + Lua Language Server (LLS) - https://marketplace.visualstudio.com/items?itemName=sumneko.lua + https://github.com/LuaLS/lua-language-server + WoW API - LLS extension - https://marketplace.visualstudio.com/items?itemName=ketho.wow-api + https://github.com/Ketho/vscode-wow-api + + This file is to remove errors and warnings thrown by the tools used. + It declares variables and tables : + - That are not readily available to the IDE + - That are declared via indirection as the drop down lib is + - When Lua 'best practice' parser is stricter than Lua is + - When Titan is checking for an addon the user may or may not have loaded + + Titan may contain IDE annotations. + These are ---@<tag> to help the parser understand the intent of the code. + + Some Titan files may contain lines beginning with +---@diagnostic + These remove LLS errors where + - Titan is handling Classic versions that use deprecated routines + - Possibly the WoW extension is out of date or the Blizz documentation is wrong + + Note the diagnostic could be by line, file, or workspace / project. +--]] + +--====== Frames from Titan Template XML +TitanPanelButtonTemplate = {} +TitanPanelChildButtonTemplate = {} +TitanPanelTextTemplate = {} +TitanPanelIconTemplate = {} +TitanPanelComboTemplate = {} +TitanOptionsSliderTemplate = {} +TitanPanelTooltip = {} +TitanPanelBarButtonHiderTemplate = {} +TitanPanelBarButton = {} +Titan_Bar__Display_Template = {} + +--====== Frames from Titan XML +TitanPanelTopAnchor = {} +TitanPanelBottomAnchor = {} + +--====== Frames from Titan plugins created in XML or in Titan code +TitanPanelAmmoButton = {} + +TitanRepairTooltip = {} + +TitanPanelLocationButton = {} +TitanMapPlayerLocation = {} +TitanMapCursorLocation = {} + +TitanPanelLootTypeFrame = {} +TitanPanelLootTypeButton = {} +TitanPanelLootTypeMainWindow = {} +TitanPanelLootTypeFrameClearButton = {} +TitanPanelLootTypeFrameAnnounceButton = {} +TitanPanelLootTypeFrameNotRolledButton = {} +TitanPanelLootTypeFrameRollButton = {} +TitanPanelLootTypeFramePassButton = {} +RollTrackerRollText = {} +TitanPanelLootTypeFrameStatusText = {} +TitanPanelLootTypeFrameHelperButton = {} +TitanPanelLootTypeMainWindowTitle = {} + +TitanPanelPerfControlFrame = {} + +TitanPanelMasterVolumeControlSlider = {} +TitanPanelAmbienceVolumeControlSlider = {} +TitanPanelDialogVolumeControlSlider = {} +TitanPanelSoundVolumeControlSlider = {} +TitanPanelMusicVolumeControlSlider = {} + +TitanPanelXPButton = {} +TitanPanelXPButtonIcon = {} + +--====== Libs that may exist or adjusting for libs +AceLibrary = {} +Tablet20Frame = {} +---@class AceAddon + +AceHook = {} +-- @param obj string | function The object or frame to unhook from +-- @param method function The name of the method, function or script to unhook from. +function AceHook:IsHooked(obj, method) + -- Ace does a parameter shift if obj is a string + -- But the param does not reflect this... +end + +--====== WoW localized globals +HELP = "" +CHANGE = "" + +--====== WoW frames +PetActionBarFrame = {} +StanceBarFrame = {} +PossessBarFrame = {} +MinimapBorderTop = {} +MinimapZoneTextButton = {} +MiniMapWorldMapButton = {} +VideoOptionsFrame = {} + +---@class FrameSizeBorder + +--====== WoW tables or routines +UIPARENT_MANAGED_FRAME_POSITIONS = {} +FCF_UpdateDockPosition = {} +TargetFrame_Update = {} +VideoOptionsFrameOkay_OnClick = {} + +--====== Convince IDE we know what we are doing +-- Lua allows table updates but the IDE complains about 'injecting' a field it does not know about. +-- Adding a function or variable to a frame in this case. + +-- LDB +---@class Frame +---@field TitanLDBSetOwnerPosition function Anchor tooltip +---@field TitanLDBSetTooltip function Fill tooltip +---@field TitanLDBHandleScripts function Set frame scripts +---@field TitanLDBTextUpdate function Update plugin text +---@field TitanLDBIconUpdate function Update plugin icon +---@field TitanLDBCreateObject function Create plugin +---@field TitanCreatedBy string +---@field TitanType string +---@field TitanName string +---@field TitanAction string +---@field bar_name string +---@field registry table LDB or any plugin + +--====== WoW Drop down menu +UIDROPDOWNMENU_MENU_VALUE = 1 + +---@class LibUIDropDownMenu-4.0 +---@field UIDropDownMenu_InitializeHelper function +---@field Create_UIDropDownMenu function +---@field UIDropDownMenu_Initialize function +---@field UIDropDownMenu_SetInitializeFunction function +---@field UIDropDownMenu_SetDisplayMode function +---@field UIDropDownMenu_RefreshDropDownSize function +---@field UIDropDownMenu_StartCounting function +---@field UIDropDownMenu_StopCounting function +---@field UIDropDownMenu_CreateInfo function +---@field UIDropDownMenu_CreateFrames function +---@field UIDropDownMenu_AddSeparator function +---@field UIDropDownMenu_AddSpace function +---@field UIDropDownMenu_AddButton function +---@field UIDropDownMenu_CheckAddCustomFrame function +---@field UIDropDownMenu_RegisterCustomFrame function +---@field UIDropDownMenu_GetMaxButtonWidth function +---@field UIDropDownMenu_GetButtonWidth function +---@field UIDropDownMenu_Refresh function +---@field UIDropDownMenu_RefreshAll function +---@field UIDropDownMenu_SetIconImage function +---@field UIDropDownMenu_SetSelectedName function +---@field UIDropDownMenu_SetSelectedValue function +---@field UIDropDownMenu_GetSelectedName function +---@field UIDropDownMenu_GetSelectedID function +---@field UIDropDownMenu_SetSelectedID function +---@field UIDropDownMenu_GetSelectedValue function +---@field HideDropDownMenu function +---@field ToggleDropDownMenu function +---@field CloseDropDownMenus function +---@field UIDropDownMenu_SetWidth function +---@field UIDropDownMenu_SetButtonWidth function +---@field UIDropDownMenu_SetText function +---@field UIDropDownMenu_GetText function +---@field UIDropDownMenu_ClearAll function +---@field UIDropDownMenu_JustifyText function +---@field UIDropDownMenu_SetAnchor function +---@field UIDropDownMenu_GetCurrentDropDown function +---@field UIDropDownMenuButton_GetChecked function +---@field UIDropDownMenuButton_GetName function +---@field UIDropDownMenuButton_OpenColorPicker function +---@field UIDropDownMenu_DisableButton function +---@field UIDropDownMenu_EnableButton function +---@field UIDropDownMenu_SetButtonText function +---@field UIDropDownMenu_SetButtonNotClickable function +---@field UIDropDownMenu_SetButtonClickable function +---@field UIDropDownMenu_DisableDropDown function +---@field UIDropDownMenu_EnableDropDown function +---@field UIDropDownMenu_IsEnabled function +---@field UIDropDownMenu_GetValue function +---@field OpenColorPicker function +---@field ColorPicker_GetPreviousValues function diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index f0a7df9..1755dd1 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -104,7 +104,7 @@ local ldb = LibStub:GetLibrary("LibDataBroker-1.1") local Tablet, LibQTip = nil, nil local media = LibStub("LibSharedMedia-3.0") -- generic icon in case the DO does not provide one -local iconTitanDefault = "Interface\\PVPFrame\\\PVP-ArenaPoints-Icon"; +local iconTitanDefault = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"; -- Events we want for LDBToTitan LDBToTitan:RegisterEvent("PLAYER_LOGIN") @@ -192,7 +192,7 @@ function LDBToTitan:TitanLDBSetTooltip(name, frame, func) rel_pt = "TOP" end - if _G[bar] then + if _G[bar] and button then self:TitanLDBSetOwnerPosition(button, pt.."LEFT", button:GetName(), rel_pt.."LEFT", -10, 0, frame); -- y 4 * scale -- Adjust frame position if it's off the screen @@ -470,14 +470,14 @@ function TitanLDBShowText(name) else -- return values will be empty strings end - + if lab1 == "" then - lab1 = nil + -- just empty else lab1 = TitanUtils_GetNormalText(lab1) end if val1 == "" then - val1 = nil + -- just empty else val1 = TitanGetVar(name, "ShowColoredText") and TitanUtils_GetGreenText(val1) or TitanUtils_GetHighlightText(val1) @@ -562,7 +562,7 @@ NOTE: --]] function TitanLDBCreateObject(self, name_str, obj) local name = name_str - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug(tostring(name).." : Attempting to register "); end @@ -574,7 +574,7 @@ function TitanLDBCreateObject(self, name_str, obj) local issue = "LDB request name " .." '"..tostring(name).."'" .." unrecognizable !!!!" - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug(issue); end error (issue) -- get out @@ -592,7 +592,7 @@ function TitanLDBCreateObject(self, name_str, obj) .." '"..tostring(name).."'" .." "..tostring(object).."" .." !!!!" - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug(issue); end error (issue) -- get out @@ -615,7 +615,7 @@ function TitanLDBCreateObject(self, name_str, obj) -- Create enough of a plugin to tell the user / developer -- that this plugin failed miserably local issue = "Unsupported LDB type '"..tostring(obj.type).."'" - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug(TITAN_REGISTER_FAILED.." "..issue); end error (issue) @@ -743,7 +743,7 @@ function TitanLDBCreateObject(self, name_str, obj) iconG = (obj.iconG or nil), }; - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug("" .." type: '"..tostring(registry.ldb).."' " ) @@ -815,7 +815,7 @@ print("LDB macrotext" .." "..tostring(obj.commandtext).."" ) --]] - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug("" .." macrotext cmd: '"..tostring(obj.commandtext).."' " ) @@ -885,7 +885,7 @@ print("LDB macrotext" TitanVariables_SyncSinglePluginSettings(registry.id) TitanPanel_InitPanelButtons() -- Show it... end - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug("LDB create" .." "..tostring(pew).."" .." '"..tostring(registry.id).."'" @@ -935,7 +935,7 @@ function LDBToTitan:TitanLDBCreateObject(sender, name, obj) TitanUtils_PluginFail(plugin) end - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug("LDB Create:" -- .." "..tostring(sender).."" .." "..tostring(name).."" @@ -988,7 +988,7 @@ LDBToTitan:SetScript("OnEvent", function(self, event, ...) TitanUtils_PluginFail(plugin) end - if Titan_Panel.debug.ldb_setup then + if Titan_Global.debug.ldb_setup then TitanDebug("LDB" .." "..tostring(name).."" .." "..tostring(call_success).."" diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index 76bf0bd..db28d41 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: param-type-mismatch --[[ File NAME: TitanMovable.lua DESC: DragonFlight introduced an Edit Mode for the user to move various frames where they want them. @@ -14,6 +15,7 @@ Titan still only allows vertical adjust - not move anywhere. -- Locals local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; +local AceHook = LibStub("AceHook-3.0") --[[ API @@ -241,7 +243,7 @@ Declare the Ace routines Be careful that the 'self' is proper to cancel timers!!! --]] -local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanel", "AceHook-3.0", "AceTimer-3.0") +--local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanel", "AceHook-3.0", "AceTimer-3.0") --Determines the optimal magic number based on resolution --local menuBarTop = 55; @@ -483,14 +485,12 @@ OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or --]] local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force) local frame = _G[frame_ptr] - local adj = false if frame and DoAdjust(top_bottom, force) then local yOffset = TitanMovable_GetPanelYOffset(top_bottom) -- includes scale adjustment - xOfs = TitanPanelGetVar("MainMenuBarXAdj") + local xOfs = TitanPanelGetVar("MainMenuBarXAdj") SetPosition(frame, "BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset) - adj = true else -- Unknown frame... end @@ -585,7 +585,7 @@ local function Titan_ContainerFrames_Relocate() local right_x = 0 for index, frameName in ipairs(ContainerFrame1.bags) do - frame = _G[frameName]; + local frame = _G[frameName]; if frame:GetBottom() then bottom_y = frame:GetBottom() end if ( bottom_y < off_y ) then -- Start a new column @@ -603,9 +603,11 @@ end local function has_pet_bar() local hasPetBar = false - if ( ( PetActionBarFrame and PetActionBarFrame:IsShown() ) or ( StanceBarFrame and StanceBarFrame:IsShown() ) or - ( MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() ) or ( PossessBarFrame and PossessBarFrame:IsShown() ) or - ( MainMenuBarVehicleLeaveButton and MainMenuBarVehicleLeaveButton:IsShown() ) ) then + if ( ( PetActionBarFrame and PetActionBarFrame:IsShown() ) + or ( StanceBarFrame and StanceBarFrame:IsShown() ) + or ( MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() ) + or ( PossessBarFrame and PossessBarFrame:IsShown() ) + or ( MainMenuBarVehicleLeaveButton and MainMenuBarVehicleLeaveButton:IsShown() ) ) then hasPetBar = true; end return hasPetBar @@ -712,6 +714,7 @@ local MData = { addonAdj = false, }, } +--[==[ --[[ Titan NAME: TitanMovable_AdjustTimer DESC: Cancel then add the given timer. The timer must be in TitanTimers. @@ -725,6 +728,7 @@ function TitanMovable_AdjustTimer(ttype) TitanPanelAce.ScheduleTimer(timer.obj, timer.callback, timer.delay) end end +--]==] --[[ Titan NAME: TitanMovable_AddonAdjust @@ -816,11 +820,14 @@ OUT: None NOTE: :NOTE --]] -function TitanPanel_AdjustFrames(force) +function TitanPanel_AdjustFrames(force, reason) -- force is passed to cover cases where Titan should always adjust -- such as when the user has just de/selected top or bottom bars local f = force or false -- do not require the parameter - + local str = reason or "?" + if Titan_Global.debug.movable then + TitanDebug("Adj: "..str) + end -- Adjust frame positions top and bottom based on user choices if hooks_done then TitanMovableFrame_MoveFrames(f) @@ -841,14 +848,14 @@ function Titan_AdjustScale() if Titan__InitializedPEW then TitanPanel_SetScale(); - TitanPanel_ClearAllBarTextures() - TitanPanel_CreateBarTextures() - +-- TitanPanel_ClearAllBarTextures() +-- TitanPanel_CreateBarTextures() +--[[ for idx,v in pairs (TitanBarData) do TitanPanel_SetTexture(TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name , TITAN_PANEL_PLACE_TOP); end - +--]] TitanMovableFrame_MoveFrames() -- TitanPanelBarButton_DisplayBarsWanted() TitanPanel_RefreshPanelButtons(); @@ -866,37 +873,38 @@ NOTE: :NOTE --]] function TitanMovable_SecureFrames() - if not TitanPanelAce:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then - TitanPanelAce:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame + if not AceHook:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then + AceHook:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame end - if not TitanPanelAce:IsHooked("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) then - TitanPanelAce:SecureHook("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) -- UIParent.lua + if not AceHook:IsHooked("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) then + AceHook:SecureHook("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) -- UIParent.lua TitanPanel_AdjustFrames() end - if not TitanPanelAce:IsHooked(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) then - TitanPanelAce:SecureHook(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook(TicketStatusFrame, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook("TargetFrame_Update", TitanPanel_AdjustFrames) -- TargetFrame.lua --- TitanPanelAce:SecureHook(MainMenuBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml --- TitanPanelAce:SecureHook(MainMenuBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml --- TitanPanelAce:SecureHook(OverrideActionBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml --- TitanPanelAce:SecureHook(OverrideActionBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua --- TitanPanelAce:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", TitanPanel_AdjustFrames) -- WorldMapFrame.lua --- TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames) +-- if not AceHook:IsHooked(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) then + if not AceHook:IsHooked(TicketStatusFrame, "Show") then + AceHook:SecureHook(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml + AceHook:SecureHook(TicketStatusFrame, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml + AceHook:SecureHook("TargetFrame_Update", TitanPanel_AdjustFrames) -- TargetFrame.lua +-- AceHook:SecureHook(MainMenuBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml +-- AceHook:SecureHook(MainMenuBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml +-- AceHook:SecureHook(OverrideActionBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml +-- AceHook:SecureHook(OverrideActionBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml + AceHook:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua +-- AceHook:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", TitanPanel_AdjustFrames) -- WorldMapFrame.lua +-- AceHook:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames) end - if not TitanPanelAce:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then + if not AceHook:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then -- Properly Adjust UI Scale if set -- Note: These are the least intrusive hooks we could think of, to properly adjust the Titan Bar(s) -- without having to resort to a SetCvar secure hook. Any addon using SetCvar should make sure to use the 3rd -- argument in the API call and trigger the CVAR_UPDATE event with an appropriate argument so that other addons -- can detect this behavior and fire their own functions (where applicable). - TitanPanelAce:SecureHook("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) -- VideoOptionsFrame.lua - TitanPanelAce:SecureHook(VideoOptionsFrame, "Hide", Titan_AdjustUIScale) -- VideoOptionsFrame.xml + AceHook:SecureHook("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) -- VideoOptionsFrame.lua + AceHook:SecureHook(VideoOptionsFrame, "Hide", Titan_AdjustUIScale) -- VideoOptionsFrame.xml end - + -- Check for other addons that control UI frames. -- Tell Titan to back off of the frames these addons could control -- Look in this routine for any special code or directions @@ -908,7 +916,7 @@ function TitanMovable_Unhook_SecureFrames() --[[ This is a debug attempt to fix an issue when a player is dumped from a vehicle while still in combat. --]] - TitanPanelAce:UnhookAll() + AceHook:UnhookAll() end end diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index 0ef8258..f04548c 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -56,7 +56,7 @@ local TITAN_PANEL_DROPOFF_ADDON = nil; -- Library instances local LibQTip = nil local _G = getfenv(0); -local InCombatLockdown = _G.InCombatLockdown; +local InCombatLockdown = _G.InCombatLockdown; local media = LibStub("LibSharedMedia-3.0") --========================== @@ -71,7 +71,7 @@ function TitanPanel_SetScale() local scale = TitanPanelGetVar("Scale"); -- Set all the Titan bars - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do _G[idx]:SetScale(scale) end -- Set all the registered plugins @@ -92,18 +92,18 @@ NOTE: :NOTE --]] local function TitanTooltip_AddTooltipText(text) - if ( text ) then + if (text) then -- Append a "\n" to the end - if ( string.sub(text, -1, -1) ~= "\n" ) then - text = text.."\n"; + if (string.sub(text, -1, -1) ~= "\n") then + text = text .. "\n"; end -- See if the string is intended for a double column for text1, text2 in string.gmatch(text, "([^\t\n]*)\t?([^\t\n]*)\n") do - if ( text2 ~= "" ) then + if (text2 ~= "") then -- Add as double wide GameTooltip:AddDoubleLine(text1, text2); - elseif ( text1 ~= "" ) then + elseif (text1 ~= "") then -- Add single column line GameTooltip:AddLine(text1); else @@ -140,8 +140,8 @@ local function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFram -- set font size for the Game Tooltip if not TitanPanelGetVar("DisableTooltipFont") then if TitanTooltipScaleSet < 1 then - TitanTooltipOrigScale = frame:GetScale(); - TitanTooltipScaleSet = TitanTooltipScaleSet + 1; + TitanTooltipOrigScale = frame:GetScale(); + TitanTooltipScaleSet = TitanTooltipScaleSet + 1; end frame:SetScale(TitanPanelGetVar("TooltipFont")); end @@ -158,18 +158,18 @@ NOTE: :NOTE --]] local function TitanTooltip_SetGameTooltip(self) - if ( self.tooltipCustomFunction ) then ---[ + if (self.tooltipCustomFunction) then + --[ local tmp_txt = "" local call_success call_success, -- for pcall - tmp_txt = pcall (self.tooltipCustomFunction) ---]] --- self.tooltipCustomFunction(); - elseif ( self.tooltipTitle ) then + tmp_txt = pcall(self.tooltipCustomFunction) + --]] + -- self.tooltipCustomFunction(); + elseif (self.tooltipTitle) then GameTooltip:SetText(self.tooltipTitle, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); - if ( self.tooltipText ) then + if (self.tooltipText) then TitanTooltip_AddTooltipText(self.tooltipText); end end @@ -188,34 +188,39 @@ OUT: None local function TitanTooltip_SetPanelTooltip(self, id, frame) -- sanity checks if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then return end + or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + return + end if not self.tooltipCustomFunction and not self.tooltipTitle then return end -- Set GameTooltip local button = TitanUtils_GetButton(id); - -- Adjust the Y offset as needed - local rel_y = self:GetTop() - GameTooltip:GetHeight() - if rel_y > 0 then - pt = "TOP"; - rel_pt = "BOTTOM"; - else - -- too close to bottom of screen - pt = "BOTTOM"; - rel_pt = "TOP"; - end - local rel_x = self:GetLeft() + GameTooltip:GetHeight() - if ( rel_x < GetScreenWidth() ) then - -- menu will fit - pt = pt.."LEFT"; - rel_pt = rel_pt.."LEFT"; - else - pt = pt.."RIGHT"; - rel_pt = rel_pt.."RIGHT"; - end + if button then + -- Adjust the Y offset as needed + local rel_y = self:GetTop() - GameTooltip:GetHeight() + local pt = "" + local rel_pt = "" + if rel_y > 0 then + pt = "TOP"; + rel_pt = "BOTTOM"; + else + -- too close to bottom of screen + pt = "BOTTOM"; + rel_pt = "TOP"; + end + local rel_x = self:GetLeft() + GameTooltip:GetHeight() + if (rel_x < GetScreenWidth()) then + -- menu will fit + pt = pt .. "LEFT"; + rel_pt = rel_pt .. "LEFT"; + else + pt = pt .. "RIGHT"; + rel_pt = rel_pt .. "RIGHT"; + end ---[[ + --[[ print("_tooltip" .." "..tostring(self:GetName()).."" .." "..tostring(pt).."" @@ -224,8 +229,9 @@ print("_tooltip" .." "..tostring(format("%0.1f", GameTooltip:GetHeight())).."" ) --]] - TitanTooltip_SetOwnerPosition(button, pt, button:GetName(), rel_pt, 0, 0, frame) - TitanTooltip_SetGameTooltip(self); + TitanTooltip_SetOwnerPosition(button, pt, button:GetName(), rel_pt, 0, 0, frame) + TitanTooltip_SetGameTooltip(self) + end end --[[ local @@ -245,11 +251,11 @@ local function TitanPanelButton_SetTooltip(self, id) local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") local use_shift = TitanAllGetVar("TooltipModiferShift") local ok = false - + if use_mod then if (use_alt and IsAltKeyDown()) - or (use_ctrl and IsControlKeyDown()) - or (use_shift and IsShiftKeyDown()) + or (use_ctrl and IsControlKeyDown()) + or (use_shift and IsShiftKeyDown()) then ok = true end @@ -259,34 +265,35 @@ local function TitanPanelButton_SetTooltip(self, id) self.tooltipCustomFunction = nil; if ok and (id and TitanUtils_IsPluginRegistered(id)) then - local plugin = TitanUtils_GetPlugin(id); - if ( plugin.tooltipCustomFunction ) then - self.tooltipCustomFunction = plugin.tooltipCustomFunction; - TitanTooltip_SetPanelTooltip(self, id); - elseif ( plugin.tooltipTitle ) then --- local tooltipTextFunc = _G[plugin.tooltipTextFunction]; - local tooltipTextFunc = {} - local tt_func = plugin.tooltipTextFunction - - if type(tt_func) == 'string' then - -- Function MUST be in global namespace - tooltipTextFunc = _G[tt_func] - elseif type(tt_func) == 'function' then - -- Can be global or local to the plugin - tooltipTextFunc = tt_func - else - return -- silently leave... - end - - if ( tooltipTextFunc ) then + local plugin = TitanUtils_GetPlugin(id) + if plugin then + if (plugin.tooltipCustomFunction) then + self.tooltipCustomFunction = plugin.tooltipCustomFunction; + TitanTooltip_SetPanelTooltip(self, id); + elseif (plugin.tooltipTitle) then + -- local tooltipTextFunc = _G[plugin.tooltipTextFunction]; + local tooltipTextFunc = {} ---@type function + local tt_func = plugin.tooltipTextFunction + + if type(tt_func) == 'string' then + -- Function MUST be in global namespace + tooltipTextFunc = _G[tt_func] + elseif type(tt_func) == 'function' then + -- Can be global or local to the plugin + tooltipTextFunc = tt_func + else + return -- silently leave... + end - if ok then -- display the tooltip - self.tooltipTitle = plugin.tooltipTitle; - call_success, -- for pcall - tmp_txt = pcall (tooltipTextFunc); - self.tooltipText = tmp_txt - -- self.tooltipText = tooltipTextFunc(); - TitanTooltip_SetPanelTooltip(self, id); + if (tooltipTextFunc) then + if ok then -- display the tooltip + self.tooltipTitle = plugin.tooltipTitle; + call_success, -- for pcall + tmp_txt = pcall(tooltipTextFunc); + self.tooltipText = tmp_txt + -- self.tooltipText = tooltipTextFunc(); + TitanTooltip_SetPanelTooltip(self, id); + end end end end @@ -363,7 +370,7 @@ local function TitanPanelButton_OnDragStart(self, ChildButton) end -- Clear button positions or we'll grab the button and all buttons 'after' - local i,j; + local i, j; for i, j in pairs(TitanPanelSettings.Buttons) do local pluginid = _G[TitanUtils_ButtonName(TitanPanelSettings.Buttons[i])]; if pluginid then @@ -392,10 +399,10 @@ local function TitanPanelButton_OnDragStart(self, ChildButton) for key, tip in LibQTip:IterateTooltips() do if tip then local _, relativeTo = tip:GetPoint() - if relativeTo and relativeTo:GetName() == self:GetName() then - tip:Hide() - break - end + if relativeTo and relativeTo:GetName() == self:GetName() then + tip:Hide() + break + end end end end @@ -450,11 +457,11 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) -- eventually there could be several reasons to not allow -- the plugin to move if ok_to_move then - local i,j; + local i, j; for i, j in pairs(TitanPanelSettings.Buttons) do local pluginid = _G[TitanUtils_ButtonName(TitanPanelSettings.Buttons[i])]; --- _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; + -- _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; if (pluginid and MouseIsOver(pluginid)) and frname ~= pluginid then TITAN_PANEL_DROPOFF_ADDON = TitanPanelSettings.Buttons[i]; end @@ -473,7 +480,7 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) local bar local tbar = nil -- Find which bar it was dropped on - for idx,v in pairs(TitanBarData) do + for idx, v in pairs(TitanBarData) do bar = idx if (bar and MouseIsOver(_G[bar])) then tbar = bar @@ -489,14 +496,14 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) else -- plugin was dropped on another plugin - swap (for now) local dropoff = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons - ,TITAN_PANEL_DROPOFF_ADDON); + , TITAN_PANEL_DROPOFF_ADDON); local pickup = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons - ,TITAN_PANEL_MOVE_ADDON); + , TITAN_PANEL_MOVE_ADDON); local dropoffbar = TitanUtils_GetWhichBar(TITAN_PANEL_DROPOFF_ADDON); local pickupbar = TitanUtils_GetWhichBar(TITAN_PANEL_MOVE_ADDON); if dropoff ~= nil and dropoff ~= "" then - -- TODO: Change to 'insert' rather than swap + -- TODO: Change to 'insert' rather than swap TitanPanelSettings.Buttons[dropoff] = TITAN_PANEL_MOVE_ADDON; TitanPanelSettings.Location[dropoff] = dropoffbar; TitanPanelSettings.Buttons[pickup] = TITAN_PANEL_DROPOFF_ADDON; @@ -574,13 +581,13 @@ function TitanPanelPluginHandle_OnUpdate(table, oldarg) -- Used by plugins -- id is required if id then if updateType == TITAN_PANEL_UPDATE_BUTTON - or updateType == TITAN_PANEL_UPDATE_ALL then + or updateType == TITAN_PANEL_UPDATE_ALL then TitanPanelButton_UpdateButton(id) end if (updateType == TITAN_PANEL_UPDATE_TOOLTIP - or updateType == TITAN_PANEL_UPDATE_ALL) - and MouseIsOver(_G[TitanUtils_ButtonName(id)]) then + or updateType == TITAN_PANEL_UPDATE_ALL) + and MouseIsOver(_G[TitanUtils_ButtonName(id)]) then if TitanPanelRightClickMenu_IsVisible() or TITAN_PANEL_MOVING == 1 then return end @@ -609,8 +616,8 @@ function TitanPanelDetectPluginMethod(id, isChildButton) -- Set the OnDragStart script TitanPluginframe:SetScript("OnDragStart", function(self) if not IsShiftKeyDown() - and not IsControlKeyDown() - and not IsAltKeyDown() then + and not IsControlKeyDown() + and not IsAltKeyDown() then if isChildButton then TitanPanelButton_OnDragStart(self, true); else @@ -665,7 +672,7 @@ function TitanPanelButton_OnClick(self, button, isChildButton) -- Used by plugin TitanUtils_GetButtonID(self:GetName())); end ---[[ + --[[ if self.TitanType == "macro" then print("TPB OnClick" .." "..tostring(self:GetName()).." " @@ -679,7 +686,7 @@ end if id then local controlFrame = TitanUtils_GetControlFrame(id); - if (button == "LeftButton") then + if controlFrame and (button == "LeftButton") then local isControlFrameShown; if (not controlFrame) then isControlFrameShown = false; @@ -694,10 +701,9 @@ end local position = TitanUtils_GetWhichBar(id) if (isControlFrameShown) then - -- Note: This uses anchor points to place the control frame relative to the plugin on the screen. local parent = self:GetName() -- plugin with the control frame - local point = "" -- point of the control frame + local point = "" -- point of the control frame local rel_point = "" -- The middle - top or bottom edge - of the plugin to anchor to --[[ Mar 2023 : removed reference to Titan bar reference Instead use the relative position on the screen to show the control (plugin) @@ -705,7 +711,7 @@ end NOTE: If Titan bars need a left click to show a control frame the offset will need to be changed to use the cursor position like right click menu!! --]] - if (self:GetTop() - controlFrame:GetHeight()) > 0 then + if (self:GetTop() - controlFrame:GetHeight()) > 0 then point = "TOP" rel_point = "BOTTOM" else -- below screen @@ -715,18 +721,18 @@ end local x = 0 local y = 0 - + controlFrame:ClearAllPoints(); - controlFrame:SetPoint(point.."LEFT", parent, rel_point, 0, 0) -- default left of plugin - + controlFrame:SetPoint(point .. "LEFT", parent, rel_point, 0, 0) -- default left of plugin + -- Adjust control frame position if it's off the screen local offscreenX, offscreenY = TitanUtils_GetOffscreen(controlFrame); - if ( offscreenX == -1 ) then + if (offscreenX == -1) then -- Off to left of screen which should not happen... - elseif ( offscreenX == 1 ) then + elseif (offscreenX == 1) then -- off to right of screen, flip to right of plugin controlFrame:ClearAllPoints(); - controlFrame:SetPoint(point.."RIGHT", parent, rel_point, 0, 0) + controlFrame:SetPoint(point .. "RIGHT", parent, rel_point, 0, 0) end controlFrame:Show(); @@ -816,11 +822,12 @@ VAR: id - string name of the plugin NOTE: - The plugin is expected to tell Titan what routine is to be called in <self>.registry.buttonTextFunction. - The text routine is called in protected mode (pcall) to ensure the Titan main routines still run. +- There are several places that return in this routine. Not best practice but more readable here. :NOTE --]] local format_with_label = { [0] = "" } -for idx = 1, 4 do - format_with_label[idx] = "%s%s"..(TITAN_PANEL_LABEL_SEPARATOR.."%s%s"):rep(idx - 1) +for idx = 1, 4 do + format_with_label[idx] = "%s%s" .. (TITAN_PANEL_LABEL_SEPARATOR .. "%s%s"):rep(idx - 1) end local function TitanPanelButton_SetButtonText(id) if (id and TitanUtils_IsPluginRegistered(id)) then @@ -828,23 +835,24 @@ local function TitanPanelButton_SetButtonText(id) else -- return silently; The plugin is not registered! -- output here could be a lot and really annoy the user... - return + return end local pdata = TitanUtils_GetPlugin(id) -- get plugin data - - local bFunction = pdata.buttonTextFunction - local buttonTextFunction = {} - if type(bFunction) == 'string' then - -- Function MUST be in global namespace - buttonTextFunction = _G[bFunction] - elseif type(bFunction) == 'function' then - -- Can be global or local to the plugin - buttonTextFunction = bFunction - else - return -- silently leave... - end ---[[ + local buttonTextFunction = {} ---@type function + + if pdata then + local bFunction = pdata.buttonTextFunction + if type(bFunction) == 'string' then + -- Function MUST be in global namespace + buttonTextFunction = _G[bFunction] + elseif type(bFunction) == 'function' then + -- Can be global or local to the plugin + buttonTextFunction = bFunction + else + return -- silently leave... + end + --[[ print("B text" .." "..tostring(id).."" .." "..tostring(type(bFunction)).."" @@ -852,113 +860,125 @@ print("B text" .." '"..tostring(buttonTextFunction).."'" ) --]] - --- buttonTextFunction = bFunction - if not buttonTextFunction then return end - local button = TitanUtils_GetButton(id) -- get plugin frame - local buttonText = _G[button:GetName()..TITAN_PANEL_TEXT]; - - local newfont = media:Fetch("font", TitanPanelGetVar("FontName")) - if newfont then - buttonText:SetFont(newfont, TitanPanelGetVar("FontSize")) - end - - -- We'll be paranoid here and call the button text in protected mode. - -- In case the button text fails it will not take Titan with it... - local call_success, -- for pcall - label1, value1, label2, value2, label3, value3, label4, value4 = - pcall(buttonTextFunction, id) - - if call_success then - -- All is good else - buttonText:SetText("<?>") ---[[ - local msg = tostring(id).." '"..label1.."'" - TitanPrint(msg, "error") ---]] - return + return -- silently leave... end - --===================================== - -- Determine the label value pairs : 1 - 4 - -- Each could be custom per user - -- - -- NummLabelsSeen - used for the config to avoid confusing user - -- Plugin MUST have been shown at least once. - - -- In the case of first label only (no value), set the button and return. - if label1 and - not (label2 or label3 or label4 - or value1 or value2 or value3 or value4) then - buttonText:SetText(label1) - - TitanSetVar(id, "NumLabelsSeen", 1) + if buttonTextFunction then + local label1, value1, label2, value2, label3, value3, label4, value4 + local call_success = false + local button = TitanUtils_GetButton(id) -- get plugin frame + local buttonText = {} - return - end + if button then + buttonText = _G[button:GetName() .. TITAN_PANEL_TEXT]; + local newfont = media:Fetch("font", TitanPanelGetVar("FontName")) + if newfont then + buttonText:SetFont(newfont, TitanPanelGetVar("FontSize")) + end + + -- We'll be paranoid here and call the button text in protected mode. + -- In case the button text fails it will not take Titan with it... + call_success, -- for pcall + label1, value1, label2, value2, label3, value3, label4, value4 = + pcall(buttonTextFunction, id) - local show_label = TitanGetVar(id, "ShowLabelText") - local values = 0 - if label1 or value1 then - values = 1 - if show_label then - if TitanGetVar(id, "CustomLabelTextShow") then - -- override the label per the user - label1 = TitanGetVar(id, "CustomLabelText") + if call_success then + -- All is good else + buttonText:SetText("<?>") + return end else - label1 = "" + return + end + + --===================================== + -- Determine the label value pairs : 1 - 4 + -- Each could be custom per user + -- + -- NumLabelsSeen - used for the config to avoid confusing user + -- Plugin MUST have been shown at least once. + + -- In the case of first label only (no value), set the button and return. + if label1 and + not (label2 or label3 or label4 + or value1 or value2 or value3 or value4) then + buttonText:SetText(label1) + + TitanSetVar(id, "NumLabelsSeen", 1) + + return end - if label2 or value2 then - values = 2 - if show_label then - if TitanGetVar(id, "CustomLabel2TextShow") then + + + local show_label = TitanGetVar(id, "ShowLabelText") + local values = 0 + if label1 or value1 then + values = 1 + if show_label then + if TitanGetVar(id, "CustomLabelTextShow") then -- override the label per the user - label2 = TitanGetVar(id, "CustomLabel2Text") + label1 = TitanGetVar(id, "CustomLabelText") else end else - label2 = "" + label1 = "" end - if label3 or value3 then - if show_label then - if TitanGetVar(id, "CustomLabel3TextShow") then + if label2 or value2 then + values = 2 + if show_label then + if TitanGetVar(id, "CustomLabel2TextShow") then -- override the label per the user - label3 = TitanGetVar(id, "CustomLabel3Text") + label2 = TitanGetVar(id, "CustomLabel2Text") else end else - label3 = "" + label2 = "" end - values = 3 - if label4 or value4 then - values = 4 - if show_label then - if TitanGetVar(id, "CustomLabel43TextShow") then + if label3 or value3 then + if show_label then + if TitanGetVar(id, "CustomLabel3TextShow") then -- override the label per the user - label4 = TitanGetVar(id, "CustomLabel4Text") + label3 = TitanGetVar(id, "CustomLabel3Text") else end else - label4 = "" + label3 = "" + end + values = 3 + if label4 or value4 then + values = 4 + if show_label then + if TitanGetVar(id, "CustomLabel43TextShow") then + -- override the label per the user + label4 = TitanGetVar(id, "CustomLabel4Text") + else + end + else + label4 = "" + end end end end + else + -- no label or value + -- Do nothing, it could be the right action for the plugin end - end - TitanSetVar(id, "NumLabelsSeen", values) - - -- values tells which format to use from the array - buttonText:SetFormattedText(format_with_label[values], - label1 or "", value1 or "", - label2 or "", value2 or "", - label3 or "", value3 or "", - label4 or "", value4 or "" - ) + TitanSetVar(id, "NumLabelsSeen", values) + + -- values tells which format to use from the array + buttonText:SetFormattedText(format_with_label[values], + label1 or "", value1 or "", + label2 or "", value2 or "", + label3 or "", value3 or "", + label4 or "", value4 or "" + ) + else + -- no valid routine to update the plugin text + end end --[[ local @@ -972,15 +992,21 @@ NOTE: --]] local function TitanPanelButton_SetTextButtonWidth(id, setButtonWidth) if (id) then - local button = TitanUtils_GetButton(id); - local text = _G[button:GetName()..TITAN_PANEL_TEXT]; - if ( setButtonWidth - or button:GetWidth() == 0 - or button:GetWidth() - text:GetWidth() > TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE - or button:GetWidth() - text:GetWidth() < -TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE ) then - button:SetWidth(text:GetWidth()); - TitanPanelButton_Justify(); + local button = TitanUtils_GetButton(id) + if button then + local text = _G[button:GetName() .. TITAN_PANEL_TEXT]; + if (setButtonWidth + or button:GetWidth() == 0 + or button:GetWidth() - text:GetWidth() > TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE + or button:GetWidth() - text:GetWidth() < -TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE) then + button:SetWidth(text:GetWidth()); + TitanPanelButton_Justify(); + end + else + -- no plugin registered, be silent end + else + -- no plugin received, be silent end end @@ -994,10 +1020,14 @@ NOTE: --]] local function TitanPanelButton_SetIconButtonWidth(id) if (id) then - local button = TitanUtils_GetButton(id); - if ( TitanUtils_GetPlugin(id).iconButtonWidth ) then + local button = TitanUtils_GetButton(id) + if button and (TitanUtils_GetPlugin(id).iconButtonWidth) then button:SetWidth(TitanUtils_GetPlugin(id).iconButtonWidth); + else + -- no plugin registered, be silent end + else + -- no plugin received, be silent end end @@ -1015,19 +1045,19 @@ local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) local button = TitanUtils_GetButton(id) if not button then return end -- sanity check - local text = _G[button:GetName()..TITAN_PANEL_TEXT]; - local icon = _G[button:GetName().."Icon"]; + local text = _G[button:GetName() .. TITAN_PANEL_TEXT]; + local icon = _G[button:GetName() .. "Icon"]; local iconWidth, iconButtonWidth, newButtonWidth; -- Get icon button width iconButtonWidth = 0; - if ( TitanUtils_GetPlugin(id).iconButtonWidth ) then + if (TitanUtils_GetPlugin(id).iconButtonWidth) then iconButtonWidth = TitanUtils_GetPlugin(id).iconButtonWidth; - elseif ( icon:GetWidth() ) then + elseif (icon:GetWidth()) then iconButtonWidth = icon:GetWidth(); end - if ( TitanGetVar(id, "ShowIcon") and ( iconButtonWidth ~= 0 ) ) then + if (TitanGetVar(id, "ShowIcon") and (iconButtonWidth ~= 0)) then icon:Show(); text:ClearAllPoints(); text:SetPoint("LEFT", icon:GetName(), "RIGHT", 2, 1); @@ -1041,10 +1071,10 @@ local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) newButtonWidth = text:GetWidth(); end - if ( setButtonWidth - or button:GetWidth() == 0 - or button:GetWidth() - newButtonWidth > TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE - or button:GetWidth() - newButtonWidth < -TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE ) + if (setButtonWidth + or button:GetWidth() == 0 + or button:GetWidth() - newButtonWidth > TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE + or button:GetWidth() - newButtonWidth < -TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE) then button:SetWidth(newButtonWidth); TitanPanelButton_Justify(); @@ -1058,35 +1088,34 @@ DESC: Update the display of the given Titan plugin. VAR: id - string name of the plugin VAR: setButtonWidth - new width --]] -function TitanPanelButton_UpdateButton(id, setButtonWidth) -- Used by plugins - local button, id = TitanUtils_GetButton(id); +function TitanPanelButton_UpdateButton(id, setButtonWidth) -- Used by plugins + -- local button, id = TitanUtils_GetButton(id); local plugin = TitanUtils_GetPlugin(id) -- safeguard to avoid errors - if not TitanUtils_IsPluginRegistered(id) then return end - - if ( TitanPanelButton_IsText(id) ) then - -- Update textButton - TitanPanelButton_SetButtonText(id); - TitanPanelButton_SetTextButtonWidth(id, setButtonWidth); - - elseif ( TitanPanelButton_IsIcon(id) ) then - -- Update iconButton - TitanPanelButton_SetButtonIcon(id, (plugin.iconCoords or nil), - (plugin.iconR or nil),(plugin.iconG or nil),(plugin.iconB or nil) + if plugin and TitanUtils_IsPluginRegistered(id) then + if (TitanPanelButton_IsText(id)) then + -- Update textButton + TitanPanelButton_SetButtonText(id); + TitanPanelButton_SetTextButtonWidth(id, setButtonWidth); + elseif (TitanPanelButton_IsIcon(id)) then + -- Update iconButton + TitanPanelButton_SetButtonIcon(id, (plugin.iconCoords or nil), + (plugin.iconR or nil), (plugin.iconG or nil), (plugin.iconB or nil) ); - TitanPanelButton_SetIconButtonWidth(id); - - elseif ( TitanPanelButton_IsCombo(id) ) then - -- Update comboButton - TitanPanelButton_SetButtonText(id); - TitanPanelButton_SetButtonIcon(id, (plugin.iconCoords or nil), - (plugin.iconR or nil),(plugin.iconG or nil),(plugin.iconB or nil) + TitanPanelButton_SetIconButtonWidth(id); + elseif (TitanPanelButton_IsCombo(id)) then + -- Update comboButton + TitanPanelButton_SetButtonText(id); + TitanPanelButton_SetButtonIcon(id, (plugin.iconCoords or nil), + (plugin.iconR or nil), (plugin.iconG or nil), (plugin.iconB or nil) ); - TitanPanelButton_SetComboButtonWidth(id, setButtonWidth); + TitanPanelButton_SetComboButtonWidth(id, setButtonWidth); + end + else + return end end - --[[ API NAME: TitanPanelButton_UpdateTooltip DESC: Update the tooltip of the given Titan plugin. @@ -1112,24 +1141,28 @@ VAR: iconB - if given, this is the Blue (RBG) setting of the icon --]] function TitanPanelButton_SetButtonIcon(id, iconCoords, iconR, iconG, iconB) if (id and TitanUtils_IsPluginRegistered(id)) then - local button = TitanUtils_GetButton(id); - local icon = _G[button:GetName().."Icon"]; - local iconTexture = TitanUtils_GetPlugin(id).icon; - local iconWidth = TitanUtils_GetPlugin(id).iconWidth; + local button = TitanUtils_GetButton(id) + if button then + local icon = _G[button:GetName() .. "Icon"]; + local iconTexture = TitanUtils_GetPlugin(id).icon; + local iconWidth = TitanUtils_GetPlugin(id).iconWidth; - if (iconTexture) and icon then - icon:SetTexture(iconTexture); - end - if (iconWidth) and icon then - icon:SetWidth(iconWidth); - end + if (iconTexture) and icon then + icon:SetTexture(iconTexture); + end + if (iconWidth) and icon then + icon:SetWidth(iconWidth); + end - -- support for iconCoords, iconR, iconG, iconB attributes - if iconCoords and icon then - icon:SetTexCoord(unpack(iconCoords)) - end - if iconR and iconG and iconB and icon then - icon:SetVertexColor(iconR, iconG, iconB) + -- support for iconCoords, iconR, iconG, iconB attributes + if iconCoords and icon then + icon:SetTexCoord(unpack(iconCoords)) + end + if iconR and iconG and iconB and icon then + icon:SetVertexColor(iconR, iconG, iconB) + end + else + -- plugin not registered end end end @@ -1145,30 +1178,30 @@ NOTE: --]] function TitanPanelButton_GetType(id) -- id is required - if (not id) then - return; - end - - local button = TitanUtils_GetButton(id); - local type; - if button then - local text = _G[button:GetName()..TITAN_PANEL_TEXT]; - local icon = _G[button:GetName().."Icon"]; - - if (text and icon) then + local type = 0 -- unknown + if id then + local button = TitanUtils_GetButton(id); + if button then + local text = _G[button:GetName() .. TITAN_PANEL_TEXT]; + local icon = _G[button:GetName() .. "Icon"]; + + if (text and icon) then + type = TITAN_PANEL_BUTTON_TYPE_COMBO; + elseif (text and not icon) then + type = TITAN_PANEL_BUTTON_TYPE_TEXT; + elseif (not text and icon) then + type = TITAN_PANEL_BUTTON_TYPE_ICON; + elseif (not text and not icon) then + type = TITAN_PANEL_BUTTON_TYPE_CUSTOM; + end + else type = TITAN_PANEL_BUTTON_TYPE_COMBO; - elseif (text and not icon) then - type = TITAN_PANEL_BUTTON_TYPE_TEXT; - elseif (not text and icon) then - type = TITAN_PANEL_BUTTON_TYPE_ICON; - elseif (not text and not icon) then - type = TITAN_PANEL_BUTTON_TYPE_CUSTOM; end else - type = TITAN_PANEL_BUTTON_TYPE_COMBO; + -- no id... end - return type; + return type end --[[ Titan @@ -1200,17 +1233,17 @@ DESC: Loads the Backdrop for TitanOptionsSliderTemplate with new 9.0 API VAR: self - The frame --]] function TitanOptionsSliderTemplate_OnLoad(self) - self:SetBackdrop({ - bgFile="Interface\\Buttons\\UI-SliderBar-Background", - edgeFile="Interface\\Buttons\\UI-SliderBar-Border", - tile = true, - insets = { - left = 6, - right = 6, - top = 3, - bottom = 3, - }, - tileSize = 8, - edgeSize = 8, - }) + self:SetBackdrop({ + bgFile = "Interface\\Buttons\\UI-SliderBar-Background", + edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", + tile = true, + insets = { + left = 6, + right = 6, + top = 3, + bottom = 3, + }, + tileSize = 8, + edgeSize = 8, + }) end diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index a4207a8..7fb148f 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -8,8 +8,9 @@ local _G = getfenv(0); local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local media = LibStub("LibSharedMedia-3.0") -local drop_down_1 = "" -- +local drop_down_1 = "" -- changes if using Blizz drop down (retail) or lib (Classic) +--====== Set the default drop down menu per retail or Classic if TITAN_ID == "TitanClassic" then drop_down_1 = "L_DropDownList1" -- The LibUIDropDownMenu lib is used over the Blizzard frame else @@ -17,7 +18,8 @@ else drop_down_1 = "DropDownList1" -- Boo!! Per hard-coded Blizz UIDropDownMenu.lua end ---[[ ================================================== +--====== Classic routines for a drop down menu lib +--[[ ====== Classic routines for a drop down menu lib Messy but declare the lib routines used in the Classic versions --]] if TITAN_ID == "TitanClassic" then @@ -134,7 +136,7 @@ function L_UIDropDownMenu_SetWidth(frame, width, padding) DDM:UIDropDownMenu_SetWidth(frame, width, padding) end function L_UIDropDownMenu_SetButtonWidth(frame, width) - DDMUIDropDownMenu_SetButtonWidth(frame, width) + DDM:UIDropDownMenu_SetButtonWidth(frame, width) end function L_UIDropDownMenu_SetText(frame, text) DDM:UIDropDownMenu_SetText(frame, text) @@ -196,7 +198,7 @@ end function L_ColorPicker_GetPreviousValues() return DDM:ColorPicker_GetPreviousValues() end -else +else -- only retail (may change as Blizz expands API to Classic versions) --[[ API NAME: TitanUtils_GetMinimapAdjust @@ -237,17 +239,11 @@ function TitanUtils_AddonAdjust(frame, bool) -- Used by addons TitanMovable_AddonAdjust(frame, bool) end -end ---[[ ================================================== -End Classic versions ---]] - +end -- Retail versus retail routines --- --- The routines labeled API are useable by addon developers --- +--====== The routines labeled API are useable by addon developers ---[[ API +--[[ API -- Used by addons NAME: TitanUtils_GetBarAnchors DESC: Get the anchors of the bottom most top bar and the top most bottom bar. Intended for addons that modify the UI so they can adjust for Titan. @@ -260,7 +256,7 @@ NOTE: - The two anchors are implemented as 2 frames that are moved by Titan depending on which bars are shown. :NOTE --]] -function TitanUtils_GetBarAnchors() -- Used by addons +function TitanUtils_GetBarAnchors() return TitanPanelTopAnchor, TitanPanelBottomAnchor end @@ -276,28 +272,28 @@ OUT: string - The button / frame name --]] function TitanUtils_ButtonName(id) if (id) then - return Titan_Panel.plugin.PRE..id..Titan_Panel.plugin.POST + return Titan_Global.plugin.PRE..id..Titan_Global.plugin.POST else return nil end end ---[[ API +--[[ API : Used by plugins 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 -OUT: string - The id of the plugin --]] -function TitanUtils_GetButton(id) -- Used by plugins +---@param id string Unique ID of the plugin +---@return table? frame Frame of the plugin +---@return string? id Unique ID of the plugin +function TitanUtils_GetButton(id) if (id) then - return _G[Titan_Panel.plugin.PRE..id..Titan_Panel.plugin.POST], id; + return _G[Titan_Global.plugin.PRE..id..Titan_Global.plugin.POST], id; else return nil, nil; end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetRealPosition DESC: Return whether the plugin is on the top or bottom bar. VAR: id - is the id of the plugin @@ -306,7 +302,7 @@ NOTE: - This returns top or bottom NOT which bar (1-4) the plugin is on. :NOTE --]] -function TitanUtils_GetRealPosition(id) -- Used by plugins +function TitanUtils_GetRealPosition(id) -- This will return top / bottom but it is a compromise. -- With the introduction of independent bars there is -- more than just top / bottom. @@ -330,7 +326,7 @@ OUT: string - plugin id or nil --]] function TitanUtils_GetButtonID(name) if name then - local s, e, id = string.find(name, Titan_Panel.plugin.PRE.."(.*)"..Titan_Panel.plugin.POST); + local s, e, id = string.find(name, Titan_Global.plugin.PRE.."(.*)"..Titan_Global.plugin.POST); return id; else return nil; @@ -362,6 +358,7 @@ NOTE: --]] function TitanUtils_GetButtonIDFromMenu(self) local ret = nil + local temp if self and self:GetParent() then local name = self:GetParent():GetName() if name == "UIParent" then @@ -402,9 +399,9 @@ end --[[ API NAME: TitanUtils_GetPlugin DESC: Return the plugin itself (table and all). -VAR: id - is the id of the plugin -OUT: table - plugin or nil --]] +---@param id string Unique ID of the plugin +---@return table? table plugin data function TitanUtils_GetPlugin(id) if (id) then return TitanPlugins[id]; @@ -494,12 +491,9 @@ function TitanUtils_ToRight(id) return found end --------------------------------------------------------------- --- --- General util routines --- +--====== General util routines ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_Ternary DESC: Return b or c if true or false respectively VAR: a - value to determine true or false @@ -507,7 +501,7 @@ VAR: b - value to use if true VAR: c - value to use if false or nil OUT: value - b (true) or c (false) --]] -function TitanUtils_Ternary(a, b, c) -- Used by plugins +function TitanUtils_Ternary(a, b, c) if (a) then return b; else @@ -515,13 +509,13 @@ function TitanUtils_Ternary(a, b, c) -- Used by plugins end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_Toggle DESC: Flip the value assuming it is true or false VAR: value - value to start with OUT: bool - true or false --]] -function TitanUtils_Toggle(value) -- Used by plugins +function TitanUtils_Toggle(value) if (value == 1 or value == true) then return nil; else @@ -589,7 +583,7 @@ local function GetTimeParts(s) local minutes = 0 local seconds = 0 if not s or (s < 0) then - seconds = L["TITAN_PANEL_NA"] + seconds = -1 else days = floor(s/24/60/60); s = mod(s, 24*60*60); hours = floor(s/60/60); s = mod(s, 60*60); @@ -611,7 +605,7 @@ function TitanUtils_GetEstTimeText(s) local days, hours, minutes, seconds = GetTimeParts(s) local fracdays = days + (hours/24); local frachours = hours + (minutes/60); - if seconds == L["TITAN_PANEL_NA"] then + if seconds == -1 then timeText = L["TITAN_PANEL_NA"]; else if (days ~= 0) then @@ -646,13 +640,13 @@ function TitanUtils_GetFullTimeText(s) end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetAbbrTimeText DESC: break the seconds (s) into days, hours, minutes, and seconds VAR: s - a time value in seconds OUT: string - string with localized days, hours, minutes, and seconds using spaces and including zeroes --]] -function TitanUtils_GetAbbrTimeText(s) -- Used by plugins +function TitanUtils_GetAbbrTimeText(s) local timeText = ""; local days, hours, minutes, seconds = GetTimeParts(s) if seconds == L["TITAN_PANEL_NA"] then @@ -675,12 +669,9 @@ end --[[ API NAME: TitanUtils_GetControlFrame DESC: return the control frame, if one was created. -VAR: id - id of the plugin -OUT: frame - nil or the control frame -NOTE -- This may not be used anymore. -:NOTE --]] +---@param id string Unique ID of the plugin +---@return table? frame Frame of the menu (right click) function TitanUtils_GetControlFrame(id) if (id) then return _G["TitanPanel"..id.."ControlFrame"]; @@ -758,13 +749,13 @@ function TitanUtils_PrintArray(array) end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetRedText DESC: Make the given text red. VAR: text - text to color OUT: string - Red string with proper start and end font encoding --]] -function TitanUtils_GetRedText(text) -- Used by plugins +function TitanUtils_GetRedText(text) if (text) then return _G["RED_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; end @@ -782,13 +773,13 @@ function TitanUtils_GetGoldText(text) end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetGreenText DESC: Make the given text green. VAR: text - text to color OUT: string - Green string with proper start and end font encoding --]] -function TitanUtils_GetGreenText(text) -- Used by plugins +function TitanUtils_GetGreenText(text) if (text) then return _G["GREEN_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; end @@ -806,38 +797,38 @@ function TitanUtils_GetBlueText(text) end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetNormalText DESC: Make the given text normal (gray-white). VAR: text - text to color OUT: string - Normal string with proper start and end font encoding --]] -function TitanUtils_GetNormalText(text) -- Used by plugins +function TitanUtils_GetNormalText(text) if (text) then return _G["NORMAL_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetHighlightText DESC: Make the given text highlight (brighter white). VAR: text - text to color OUT: string - Highlight string with proper start and end font encoding --]] -function TitanUtils_GetHighlightText(text) -- Used by plugins +function TitanUtils_GetHighlightText(text) if (text) then return _G["HIGHLIGHT_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetColoredText DESC: Make the given text a custom color. VAR: text - text to color VAR: color - color is the color table with r, b, g values set. OUT: string - Custom color string with proper start and end font encoding --]] -function TitanUtils_GetColoredText(text, color) -- Used by plugins +function TitanUtils_GetColoredText(text, color) if (text and color) then local redColorCode = format("%02x", color.r * 255); local greenColorCode = format("%02x", color.g * 255); @@ -847,14 +838,14 @@ function TitanUtils_GetColoredText(text, color) -- Used by plugins end end ---[[ API +--[[ API -- Used by plugins NAME: TitanUtils_GetHexText DESC: Make the given text a custom color. VAR: text - text to color VAR: hex - color as a 6 char hex code OUT: string - Custom color string with proper start and end font encoding --]] -function TitanUtils_GetHexText(text, hex) -- Used by plugins +function TitanUtils_GetHexText(text, hex) if (text and hex) then return "|cff"..tostring(hex)..text.._G["FONT_COLOR_CODE_CLOSE"]; end @@ -922,10 +913,7 @@ local function Add_button(info, level) end end --------------------------------------------------------------- --- --- Right click menu routines - Retail dropdown menu --- +--====== Right click menu routines - Retail dropdown menu --[[ Right click menu routines for plugins The expected global function name in the plugin is: @@ -964,10 +952,10 @@ function TitanPanelRightClickMenu_GetDropdownFrame() local res = "" if TITAN_ID == "TitanClassic" then - res = "L_DropDownList1" -- The LibUIDropDownMenu lib is used over the Blizzard frame + res = "L_DropDownList"..tostring(L_UIDROPDOWNMENU_MENU_LEVEL) else -- The LibUIDropDownMenu lib is used over the Blizzard frame - res = "DropDownList1" -- Boo!! Per hard-coded Blizz UIDropDownMenu.lua + res = "DropDownList"..tostring(UIDROPDOWNMENU_MENU_LEVEL) end return res @@ -1030,7 +1018,7 @@ OUT: None --]] function TitanPanelRightClickMenu_AddToggleRightSide(id, level) local plugin = TitanUtils_GetPlugin(id) - if plugin.controlVariables and plugin.controlVariables.DisplayOnRightSide then + if plugin and plugin.controlVariables and plugin.controlVariables.DisplayOnRightSide then -- copy of TitanPanelRightClickMenu_AddToggleVar adding a remove button local info = {}; info.text = L["TITAN_CLOCK_MENU_DISPLAY_ON_RIGHT_SIDE"]; @@ -1080,10 +1068,26 @@ function TitanPanelRightClickMenu_AddCommand(text, value, functionName, level) info.text = text; info.value = value; info.func = function() - local callback = _G[functionName]; --- callback must be a function else do nothing (spank developer) - if callback and type(callback)== "function" then - callback(value) + if functionName then + local callback = functionName + + if type(callback) == 'string' then + -- Function MUST be in global namespace + callback = _G[callback] + elseif type(callback) == 'function' then + -- Can be global or local to the plugin + else + -- silently leave... + end + -- Redundant but the given string may not be a function + if type(callback)== "function" then + -- No return expected... + callback(value) + else + -- Must be a function - spank developer + end + else + -- Leave, no function given end end Add_button(info, level); @@ -1158,7 +1162,7 @@ OUT: None --]] function TitanPanelRightClickMenu_AddToggleIcon(id, level) local plugin = TitanUtils_GetPlugin(id) - if plugin.controlVariables and plugin.controlVariables.ShowIcon then + if plugin and plugin.controlVariables and plugin.controlVariables.ShowIcon then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_ICON"], id, "ShowIcon", nil, level); end end @@ -1172,7 +1176,7 @@ OUT: None --]] function TitanPanelRightClickMenu_AddToggleLabelText(id, level) local plugin = TitanUtils_GetPlugin(id) - if plugin.controlVariables and plugin.controlVariables.ShowLabelText then + if plugin and plugin.controlVariables and plugin.controlVariables.ShowLabelText then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"], id, "ShowLabelText", nil, level); end end @@ -1186,7 +1190,7 @@ OUT: None --]] function TitanPanelRightClickMenu_AddToggleColoredText(id, level) local plugin = TitanUtils_GetPlugin(id) - if plugin.controlVariables and plugin.controlVariables.ShowColoredText then + if plugin and plugin.controlVariables and plugin.controlVariables.ShowColoredText then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"], id, "ShowColoredText", nil, level); end end @@ -1633,6 +1637,7 @@ 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) +---@diagnostic disable-next-line: deprecated local GetMeta = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata local call_success, ret_val @@ -1694,7 +1699,7 @@ function TitanUtils_PluginToRegister(self, isChildButton) } -- Debug - if Titan_Panel.debug.plugin_register then + if Titan_Global.debug.plugin_register then TitanDebug("Queue Plugin" -- .." '"..tostring(self:GetName()).."'" .." '"..tostring(TitanUtils_GetButtonID(self:GetName())).."'" @@ -1748,23 +1753,6 @@ local function NoColor(name) return no_color end -local function AddCustomPluginVars(reg) - -- These are added to EACH plugin for various Titan controlled features - - --================== - -- Custom labels - reg.savedVariables.CustomLabelTextShow = false - reg.savedVariables.CustomLabelText = "" - reg.savedVariables.CustomLabel2TextShow = false - reg.savedVariables.CustomLabel2Text = "" - reg.savedVariables.CustomLabel3TextShow = false - reg.savedVariables.CustomLabel3Text = "" - reg.savedVariables.CustomLabel4TextShow = false - reg.savedVariables.CustomLabel4Text = "" - -- Number of labels seen - make config less confusing - reg.savedVariables.NumLabelsSeen = 1 -- assume at least one label -end - --[[ local NAME: TitanUtils_RegisterPluginProtected DESC: This routine is intended to be called in a protected manner (pcall) by Titan when it attempts to register a plugin. @@ -1869,7 +1857,7 @@ local function TitanUtils_RegisterPluginProtected(plugin) end result = TITAN_REGISTERED -- determine the plugin category - cat = (self.registry.category or nil) + cat = (self.registry.category or "General") ptype = TITAN_ID -- Assume it is created for Titan if self.registry.ldb then -- Override the type with the LDB type @@ -1901,7 +1889,7 @@ local function TitanUtils_RegisterPluginProtected(plugin) end -- Debug - if Titan_Panel.debug.plugin_register then + if Titan_Global.debug.plugin_register then TitanDebug("Plugin RegProt" -- .." '"..tostring(self:GetName()).."'" .." '"..tostring(id).."'" @@ -1981,7 +1969,7 @@ function TitanUtils_RegisterPlugin(plugin) end -- Debug - if Titan_Panel.debug.plugin_register then + if Titan_Global.debug.plugin_register then local status = plugin.status if plugin.status == TITAN_REGISTER_FAILED then status = TitanUtils_GetRedText(status) @@ -2043,8 +2031,7 @@ function TitanUtils_IsPluginRegistered(id) end end --------------------------------------------------------------- --- Right click menu routines for Titan Panel bars and plugins +--====== Right click menu routines for Titan Panel bars and plugins --[[ Titan NAME: TitanUtils_CloseRightClickMenu @@ -2058,43 +2045,6 @@ function TitanUtils_CloseRightClickMenu() end end ---[[ local Classic -NAME: TitanRightClick_UIScale -DESC: Scale the right click menu to the user requested value. -VAR: None -OUT: -- float - x scaled -- float - y scaled -- float - scale used - ---]] -local function TitanRightClick_UIScale() - -- take UI Scale into consideration - local listFrame = _G[drop_down_1]; - local listframeScale = listFrame:GetScale(); - - local uiScale; - local uiParentScale = UIParent:GetScale(); - - local x, y = GetCursorPosition(UIParent) - - if ( GetCVar("useUIScale") == "1" ) then - uiScale = tonumber(GetCVar("uiscale")); - if ( uiParentScale < uiScale ) then - uiScale = uiParentScale; - end - else - uiScale = uiParentScale; - end - - x = x/uiScale; - y = y/uiScale; - - listFrame:SetScale(uiScale); - - return x, y, uiScale -end - --[[ local NAME: TitanRightClickMenu_OnLoad DESC: Prepare the plugin right click menu using the function given by the plugin or Titan bar. @@ -2126,7 +2076,7 @@ print("RC* _OnLoad" --.." "..tostring(frame.menuTextFunction).."" ) --]] - local prepareFunction = {} -- function to call + local prepareFunction -- function to call if frame and frame.menuTextFunction then prepareFunction = frame.menuTextFunction -- Newer method 2024 Feb @@ -2161,7 +2111,7 @@ print("RC* _OnLoad" .."'"..(self:GetName() or "?").."'. " end - if Titan_Panel.debug.tool_tips then + if Titan_Global.debug.tool_tips then if err == "" then -- all is good else @@ -2294,8 +2244,7 @@ function TitanPanelRightClickMenu_Close() end end --------------------------------------------------------------- --- Titan utility routines +--====== Titan utility routines --[[ Titan NAME: TitanUtils_ParseName @@ -2427,7 +2376,7 @@ function TitanUtils_ScreenSize(output) screen.y = UIParent:GetTop() screen.scaled_x = UIParent:GetRight() * UIParent:GetEffectiveScale() screen.scaled_y = UIParent:GetTop() * UIParent:GetEffectiveScale() - + if output then local x = UIParent:GetRight() local y = UIParent:GetTop() @@ -2438,8 +2387,8 @@ function TitanUtils_ScreenSize(output) .." UI - x:"..tostring(format("%0.1f", x)).."" .." X y:"..tostring(format("%0.1f", y)).."" .."\n" - .." UI scaled - x:"..tostring(format("%0.1f", screen_x * UIParent:GetEffectiveScale())).."" - .." X y:"..tostring(format("%0.1f", screen_y * UIParent:GetEffectiveScale())).."" + .." UI scaled - x:"..tostring(format("%0.1f", screen.x * UIParent:GetEffectiveScale())).."" + .." X y:"..tostring(format("%0.1f", screen.y * UIParent:GetEffectiveScale())).."" .."\n" .." Scale: UI"..tostring(format("%0.6f", s)).."" .." Titan "..tostring(format("%0.1f", TitanPanelGetVar("Scale"))).."" @@ -2452,7 +2401,6 @@ function TitanUtils_ScreenSize(output) return screen end - -------------------------------------------------------------- -- Various debug routines --[[ @@ -2472,6 +2420,7 @@ OUT: function TitanPanel_GetVersion() return tostring(TitanUtils_GetAddOnMetadata(TITAN_ID, "Version")) or L["TITAN_PANEL_NA"]; end + --[[ Titan NAME: TitanPrint DESC: Output a message to the user in a consistent format. @@ -2542,6 +2491,14 @@ function TitanDebug(debug_message, debug_type) --date("%m/%d/%y %H:%M:%S") end +function TitanPluginDebug(id, debug_message) + msg = + TitanUtils_GetGoldText("<"..tostring(id).."> "..date("%H:%M:%S")) + .." "..TitanUtils_GetHexText(tostring(debug_message), "1DA6C5") + + _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) +end + function TitanDumpPluginList() -- Just dump the current list of plugins local plug_in = {} @@ -2642,67 +2599,8 @@ function TitanDumpTable(tb, level) end end - --------------------------------------------------------------- --- --- Deprecated routines +--====== 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 a4782fa..103364a 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -1,13 +1,13 @@ --[[ File NAME: TitanVariables.lua -DESC: This file contains the routines to initialize, get, and set the basic data structures used by Titan. +DESC: This file contains the routines to initialize, get, and set the basic data structures used by Titan. It also sets the global variables and constants used by Titan. TitanBarData ^^: Titan static bar reference and placement info TitanAll is used for settings used for Titan itself such as use global profile, tootip modifier, etc. TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat are the structures saved to disk (listed in toc). TitanSettings : is the table that holds the Titan variables by character and the plugins used by that character. -TitanSkins : holds the list of Titan and custom skins available to the user. +TitanSkins : holds the list of Titan and custom skins available to the user. It is assumed that the skins are in the proper folder on the hard drive. Blizzard does not allow addons to access the disk. ServerTimeOffsets and ServerHourFormat: are the tables that hold the user selected hour offset and display format per realm (server). @@ -20,12 +20,12 @@ TitanPanelRegister = TitanSettings.Players[toon].Register : .registry of all pl TitanBarDataVars ^^= TitanSettings.Players[toon].BarVars : Titan user selected placement info TitanAdjustSettings = TitanSettings.Players[toon].Adjust : List of frames Titan can adjust, vertically only -** : +** : - Has Plugin placement data under Location and Buttons - Bar settings Show / Hide, transparency, skins, etc - Per character Titan settings plugin spacing, global skin, etc -^^ : +^^ : - The index is the string name of the Titan Bar to coordinate staic and user selected bar data :DESC --]] @@ -40,39 +40,33 @@ if (GetLocale() == "ruRU") then end local TPC = TITAN_PANEL_CONSTANTS -- shortcut -Titan = {} -Titan.literals = { - low = LOW, - high = HIGH, - } - --[[ Titan NAME: Titan bar overview DESC: --- 3 button frames are used to create a Titan bar: --- the 'display' button frame - the bar itself, --- the 'hider' which is a blank 1/2 height bar to capture the cursor moving to the bar, +-- 3 button frames are used to create a Titan bar: +-- the 'display' button frame - the bar itself, +-- the 'hider' which is a blank 1/2 height bar to capture the cursor moving to the bar, -- and the 'auto hide' plugin displaying the 'push pin' button. :DESC --]] --[[ Titan -NAME: TitanBarData table. +NAME: TitanBarData table. DESC: The table holds: - the name of each Titan bar (as the index) -- the short name of the bar +- the short name of the bar - whether the bar is relative - top or bottom or short (user placed) - the order they should be considered - SetPoint values for show / hide -- short bar specific values - +- short bar specific values + The short name is used to build names of the various saved variables, frames, and buttons used by Titan. :DESC -]] local SHORT_WIDTH = 200 -local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() +local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() local x_max = GetScreenWidth() local x_mid = (GetScreenWidth() / 2) - (SHORT_WIDTH / 2) @@ -86,189 +80,217 @@ end --[[ --]] TitanBarData = { - [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Bar", + [TITAN_PANEL_DISPLAY_PREFIX .. "Bar"] = { + frame_name = 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", + 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="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT",}, - bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT",}, + show = { pt = "TOPLEFT", rel_fr = "UIParent", rel_pt = "TOPLEFT", }, + bott = { pt = "BOTTOMRIGHT", rel_fr = "UIParent", rel_pt = "TOPRIGHT", }, user_move = false, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Bar2"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Bar2", + [TITAN_PANEL_DISPLAY_PREFIX .. "Bar2"] = { + frame_name = 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", + 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="TOPLEFT", rel_fr="UIParent", rel_pt="TOPLEFT",}, - bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="TOPRIGHT",}, + show = { pt = "TOPLEFT", rel_fr = "UIParent", rel_pt = "TOPLEFT", }, + bott = { pt = "BOTTOMRIGHT", rel_fr = "UIParent", rel_pt = "TOPRIGHT", }, user_move = false, }, - [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2", + [TITAN_PANEL_DISPLAY_PREFIX .. "AuxBar2"] = { + frame_name = 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", + 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="TOPLEFT", rel_fr="UIParent", rel_pt="BOTTOMLEFT",}, - bott = {pt="BOTTOMRIGHT", rel_fr="UIParent", rel_pt="BOTTOMRIGHT",}, + show = { pt = "TOPLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, + bott = { pt = "BOTTOMRIGHT", rel_fr = "UIParent", rel_pt = "BOTTOMRIGHT", }, user_move = false, }, - [TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."AuxBar", + [TITAN_PANEL_DISPLAY_PREFIX .. "AuxBar"] = { + frame_name = 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", + 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, - 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",}, + 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, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short01"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short01", - locale_name = SHORT.." 01", - name = "Short01", vert = TITAN_SHORT, order = 5, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short01", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short01"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short02"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short02", - locale_name = SHORT.." 02", - name = "Short02", vert = TITAN_SHORT, order = 6, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short02", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short02"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short03"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short03", - locale_name = SHORT.." 03", - name = "Short03", vert = TITAN_SHORT, order = 7, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short03", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short03"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short04"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short04", - locale_name = SHORT.." 04", - name = "Short04", vert = TITAN_SHORT, order = 8, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short04", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short04"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short05"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short05", - locale_name = SHORT.." 05", - name = "Short05", vert = TITAN_SHORT, order = 9, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short05", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short05"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short06"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short06", - locale_name = SHORT.." 06", - name = "Short06", vert = TITAN_SHORT, order = 10, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short06", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short06"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short07"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short07", - locale_name = SHORT.." 07", - name = "Short07", vert = TITAN_SHORT, order = 11, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short07", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short07"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short08"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short08", - locale_name = SHORT.." 08", - name = "Short08", vert = TITAN_SHORT, order = 12, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short08", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short08"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short09"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short09", - locale_name = SHORT.." 09", - name = "Short09", vert = TITAN_SHORT, order = 13, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short09", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short09"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, - [TITAN_PANEL_DISPLAY_PREFIX.."Short10"] = { - frame_name = TITAN_PANEL_DISPLAY_PREFIX.."Short10", - locale_name = SHORT.." 10", - name = "Short10", vert = TITAN_SHORT, order = 14, - tex_name = TITAN_PANEL_BACKGROUND_PREFIX.."Short10", + [TITAN_PANEL_DISPLAY_PREFIX .. "Short10"] = { + frame_name = 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",}, + show = { pt = "BOTTOMLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, user_move = true, }, } --[[ Titan -NAME: TitanBarPositions table. +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 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. @@ -279,154 +301,196 @@ The original Titan (full width) bars values are used for default X and Y TitanBarDataVars = {} TitanSkinsDefaultPath = "Interface\\AddOns\\Titan\\Artwork\\" -TitanSkinsCustomPath = TitanSkinsDefaultPath.."Custom\\" +TitanSkinsCustomPath = TitanSkinsDefaultPath .. "Custom\\" TitanSkinsPathEnd = "\\" TitanBarVarsDefaults = { ["Global"] = -- holds 'global' user settings; NOT for use in the frame loop! - { - skin = {path = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.NONE, -- Titan_Panel.NONE or Titan_Panel.SKIN or Titan_Panel.COLOR + { + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.NONE, -- Titan_Global.NONE or Titan_Global.SKIN or Titan_Global.COLOR hide_in_combat = false, - }, - [TITAN_PANEL_DISPLAY_PREFIX.."Bar"] = {off_x=0, off_y=0, off_w = x_max, - skin = {path = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, -- or Titan_Panel.COLOR + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Bar"] = { + off_x = 0, + off_y = 0, + off_w = x_max, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, -- or Titan_Global.COLOR show = true, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Bar2"] = { + off_x = 0, + off_y = -(TITAN_PANEL_BAR_HEIGHT), + off_w = x_max, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "AuxBar2"] = { + off_x = 0, + off_y = (TITAN_PANEL_BAR_HEIGHT * 2), + off_w = x_max, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "AuxBar"] = { + off_x = 0, + off_y = (TITAN_PANEL_BAR_HEIGHT), + off_w = x_max, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short01"] = { + off_x = x_mid, + off_y = Calc_Y(3), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short02"] = { + off_x = x_mid, + off_y = Calc_Y(4), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short03"] = { + off_x = x_mid, + off_y = Calc_Y(5), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short04"] = { + off_x = x_mid, + off_y = Calc_Y(6), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short05"] = { + off_x = x_mid, + off_y = Calc_Y(7), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short06"] = { + off_x = x_mid, + off_y = Calc_Y(8), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short07"] = { + off_x = x_mid, + off_y = Calc_Y(9), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short08"] = { + off_x = x_mid, + off_y = Calc_Y(10), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short09"] = { + off_x = x_mid, + off_y = Calc_Y(11), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + 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 = TitanSkinsDefaultPath, alpha = 0.7}, - color = {r = 1.0, g = .5, b = 1.0, alpha = 1.0}, - texure = Titan_Panel.SKIN, + }, + [TITAN_PANEL_DISPLAY_PREFIX .. "Short10"] = { + off_x = x_mid, + off_y = Calc_Y(12), + off_w = SHORT_WIDTH, + skin = { path = TitanSkinsDefaultPath, alpha = 0.7 }, + color = { r = 1.0, g = .5, b = 1.0, alpha = 1.0 }, + texure = Titan_Global.SKIN, show = false, auto_hide = false, - align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER + align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, -- TITAN_PANEL_BUTTONS_ALIGN_CENTER hide_in_combat = false, - }, + }, } local TitanAdjDefaults = { - adjust = false, - offset = 0, + adjust = false, + offset = 0, } -Titan_Panel.AdjList = { -- TODO : localize +Titan_Global.AdjList = { -- TODO : localize ["UIWidgetTopCenterContainerFrame"] = { frame_name = "UIWidgetTopCenterContainerFrame", purpose = "Status for BG / Dungeon", - }, + }, } TitanAdjustSettings = {} -- holds frames that Titan allows user to adjust @@ -455,14 +519,14 @@ TitanPluginExtrasNum = 0 TitanPanel_DropMenu = nil local Default_Plugins = { - {id = "Location", loc = "Bar"}, - {id = "XP", loc = "Bar"}, - {id = "Gold", loc = "Bar"}, - {id = "Clock", loc = "Bar"}, - {id = "Volume", loc = "Bar"}, - {id = "AutoHide_Bar", loc = "Bar"}, - {id = "Bag", loc = "Bar"}, - {id = "Repair", loc = "Bar"}, + { id = "Location", loc = "Bar" }, + { id = "XP", loc = "Bar" }, + { id = "Gold", loc = "Bar" }, + { id = "Clock", loc = "Bar" }, + { id = "Volume", loc = "Bar" }, + { id = "AutoHide_Bar", loc = "Bar" }, + { id = "Bag", loc = "Bar" }, + { id = "Repair", loc = "Bar" }, } --[[ Titan TITAN_PANEL_SAVED_VARIABLES table holds the Titan Panel Default SavedVars. @@ -529,7 +593,7 @@ TITAN_ALL_SAVED_VARIABLES = { -- Global profile GlobalProfileUse = false, GlobalProfileName = TITAN_PROFILE_NONE, - Silenced = false,-- Silent Load : name and version + Silenced = false, -- Silent Load : name and version Registered = false, -- for debug -- OrderHallCommandBar Status OrderHall = true, @@ -547,27 +611,27 @@ TITAN_ALL_SAVED_VARIABLES = { -- The skins released with Titan TitanSkinsDefault = { - { name = "Titan Default", titan=true, path = TitanSkinsDefaultPath}, - { name = "AllBlack", titan=true, path = TitanSkinsCustomPath.."AllBlack Skin"..TitanSkinsPathEnd}, - { name = "BlackPlusOne", titan=true, path = TitanSkinsCustomPath.."BlackPlusOne Skin"..TitanSkinsPathEnd}, - { name = "Christmas", titan=true, path = TitanSkinsCustomPath.."Christmas Skin"..TitanSkinsPathEnd}, - { name = "Charcoal Metal", titan=true, path = TitanSkinsCustomPath.."Charcoal Metal"..TitanSkinsPathEnd}, - { name = "Crusader", titan=true, path = TitanSkinsCustomPath.."Crusader Skin"..TitanSkinsPathEnd}, - { name = "Cursed Orange", titan=true, path = TitanSkinsCustomPath.."Cursed Orange Skin"..TitanSkinsPathEnd}, - { name = "Dark Wood", titan=true, path = TitanSkinsCustomPath.."Dark Wood Skin"..TitanSkinsPathEnd}, - { name = "Deep Cave", titan=true, path = TitanSkinsCustomPath.."Deep Cave Skin"..TitanSkinsPathEnd}, - { name = "Elfwood", titan=true, path = TitanSkinsCustomPath.."Elfwood Skin"..TitanSkinsPathEnd}, - { name = "Engineer", titan=true, path = TitanSkinsCustomPath.."Engineer Skin"..TitanSkinsPathEnd}, - { name = "Frozen Metal", titan=true, path = TitanSkinsCustomPath.."Frozen Metal Skin"..TitanSkinsPathEnd}, - { name = "Graphic", titan=true, path = TitanSkinsCustomPath.."Graphic Skin"..TitanSkinsPathEnd}, - { name = "Graveyard", titan=true, path = TitanSkinsCustomPath.."Graveyard Skin"..TitanSkinsPathEnd}, - { name = "Hidden Leaf", titan=true, path = TitanSkinsCustomPath.."Hidden Leaf Skin"..TitanSkinsPathEnd}, - { name = "Holy Warrior", titan=true, path = TitanSkinsCustomPath.."Holy Warrior Skin"..TitanSkinsPathEnd}, - { name = "Nightlife", titan=true, path = TitanSkinsCustomPath.."Nightlife Skin"..TitanSkinsPathEnd}, - { name = "Orgrimmar", titan=true, path = TitanSkinsCustomPath.."Orgrimmar Skin"..TitanSkinsPathEnd}, - { name = "Plate", titan=true, path = TitanSkinsCustomPath.."Plate Skin"..TitanSkinsPathEnd}, - { name = "Tribal", titan=true, path = TitanSkinsCustomPath.."Tribal Skin"..TitanSkinsPathEnd}, - { name = "X-Perl", titan=true, path = TitanSkinsCustomPath.."X-Perl"..TitanSkinsPathEnd}, + { name = "Titan Default", titan = true, path = TitanSkinsDefaultPath }, + { name = "AllBlack", titan = true, path = TitanSkinsCustomPath .. "AllBlack Skin" .. TitanSkinsPathEnd }, + { name = "BlackPlusOne", titan = true, path = TitanSkinsCustomPath .. "BlackPlusOne Skin" .. TitanSkinsPathEnd }, + { name = "Christmas", titan = true, path = TitanSkinsCustomPath .. "Christmas Skin" .. TitanSkinsPathEnd }, + { name = "Charcoal Metal", titan = true, path = TitanSkinsCustomPath .. "Charcoal Metal" .. TitanSkinsPathEnd }, + { name = "Crusader", titan = true, path = TitanSkinsCustomPath .. "Crusader Skin" .. TitanSkinsPathEnd }, + { name = "Cursed Orange", titan = true, path = TitanSkinsCustomPath .. "Cursed Orange Skin" .. TitanSkinsPathEnd }, + { name = "Dark Wood", titan = true, path = TitanSkinsCustomPath .. "Dark Wood Skin" .. TitanSkinsPathEnd }, + { name = "Deep Cave", titan = true, path = TitanSkinsCustomPath .. "Deep Cave Skin" .. TitanSkinsPathEnd }, + { name = "Elfwood", titan = true, path = TitanSkinsCustomPath .. "Elfwood Skin" .. TitanSkinsPathEnd }, + { name = "Engineer", titan = true, path = TitanSkinsCustomPath .. "Engineer Skin" .. TitanSkinsPathEnd }, + { name = "Frozen Metal", titan = true, path = TitanSkinsCustomPath .. "Frozen Metal Skin" .. TitanSkinsPathEnd }, + { name = "Graphic", titan = true, path = TitanSkinsCustomPath .. "Graphic Skin" .. TitanSkinsPathEnd }, + { name = "Graveyard", titan = true, path = TitanSkinsCustomPath .. "Graveyard Skin" .. TitanSkinsPathEnd }, + { name = "Hidden Leaf", titan = true, path = TitanSkinsCustomPath .. "Hidden Leaf Skin" .. TitanSkinsPathEnd }, + { name = "Holy Warrior", titan = true, path = TitanSkinsCustomPath .. "Holy Warrior Skin" .. TitanSkinsPathEnd }, + { name = "Nightlife", titan = true, path = TitanSkinsCustomPath .. "Nightlife Skin" .. TitanSkinsPathEnd }, + { name = "Orgrimmar", titan = true, path = TitanSkinsCustomPath .. "Orgrimmar Skin" .. TitanSkinsPathEnd }, + { name = "Plate", titan = true, path = TitanSkinsCustomPath .. "Plate Skin" .. TitanSkinsPathEnd }, + { name = "Tribal", titan = true, path = TitanSkinsCustomPath .. "Tribal Skin" .. TitanSkinsPathEnd }, + { name = "X-Perl", titan = true, path = TitanSkinsCustomPath .. "X-Perl" .. TitanSkinsPathEnd }, }; TitanSkins = {} @@ -576,7 +640,7 @@ local fullversion = TitanUtils_GetAddOnMetadata(TITAN_ID, "Version") if fullversion then local pos = string.find(fullversion, " -", 1, true); if pos then - TITAN_VERSION = string.sub(fullversion,1,pos-1); + TITAN_VERSION = string.sub(fullversion, 1, pos - 1); end end @@ -586,25 +650,26 @@ DESC: Add the saved variable data of an unloaded plugin to the 'extra' list in c VAR: id - the name of the plugin (string) OUT: None --]] -local function TitanRegisterExtra(id) +local function TitanRegisterExtra(id) TitanPluginExtrasNum = TitanPluginExtrasNum + 1 - TitanPluginExtras[TitanPluginExtrasNum] = - {num=TitanPluginExtrasNum, - id = (id or "?"), - } + TitanPluginExtras[TitanPluginExtrasNum] = + { + num = TitanPluginExtrasNum, + id = (id or "?"), + } end -- routines to sync toon data -local function CleanupProfile () +local function CleanupProfile() if TitanPanelSettings and TitanPanelSettings["Buttons"] then -- Hide the current set of plugins to prevent overlap (creates a very messy bar!) for index, id in pairs(TitanPanelSettings["Buttons"]) do - local currentButton = + local currentButton = TitanUtils_GetButton(TitanPanelSettings["Buttons"][index]); -- safeguard if currentButton then - currentButton:Hide(); - end + currentButton:Hide(); + end end end TitanPanelRightClickMenu_Close(); @@ -621,7 +686,7 @@ local function TitanVariables_SyncRegisterSavedVariables(registeredVariables, sa if (registeredVariables and savedVariables) then -- Init registeredVariables for index, value in pairs(registeredVariables) do ---[[ + --[[ print("_sync" .." "..tostring(index).."" .." : "..tostring(value).."" @@ -631,7 +696,7 @@ print("_sync" savedVariables[index] = value; end end - + -- Remove out-of-date savedVariables for index, value in pairs(savedVariables) do if (not TitanUtils_TableContainsIndex(registeredVariables, index)) then @@ -643,7 +708,7 @@ end --[[ local NAME: Plugin_settings -DESC: Give the curent profile the default plugins - if they are registered. +DESC: Give the curent profile the default plugins - if they are registered. VAR: reset - boolean OUT: None NOTE: @@ -656,7 +721,7 @@ 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).."" ) @@ -664,16 +729,16 @@ print("plugins init" else -- use the current profile plugin_list = TitanPanelSettings.Buttons end - + -- Init each and every default plugin for idx, default_plugin in pairs(plugin_list) do local id = default_plugin.id local loc = default_plugin.loc local plugin = TitanUtils_GetPlugin(id) ---TitanDebug("Plugin: "..tostring(id).." "..(plugin and "T" or "F")) + --TitanDebug("Plugin: "..tostring(id).." "..(plugin and "T" or "F")) -- See if plugin is registered if (plugin) then ---TitanDebug("__Plugin: "..tostring(id).." "..tostring(loc)) + --TitanDebug("__Plugin: "..tostring(id).." "..tostring(loc)) -- Synchronize registered and saved variables TitanVariables_SyncRegisterSavedVariables( plugin.savedVariables, TitanPluginSettings[id]) @@ -685,7 +750,7 @@ end --[[ local NAME: TitanVariables_PluginSettingsInit -DESC: Give the curent profile the default plugins - if they are registered. +DESC: Give the curent profile the default plugins - if they are registered. VAR: None OUT: None NOTE: @@ -695,7 +760,7 @@ NOTE: - The plugins that are not registered will NOT be removed from the saved list. This allows different a single saved display list to be used for toons that have different plugins enabled. :NOTE --]] -local function TitanVariables_PluginSettingsInit() +local function TitanVariables_PluginSettingsInit() -- Loop through the user's displayed plugins and see what is -- actually registered for idx, display_plugin in pairs(TitanPanelSettings.Buttons) do @@ -729,11 +794,11 @@ local function TitanVariables_SyncSkins() local skins = {} -- insert all the Titan defaults for idx, v in pairs(TitanSkinsDefault) do - table.insert (skins, TitanSkinsDefault[idx]) --- table.sort(skins, function(a, b) --- return string.lower(skins[a] and skins[a].name or "") --- < string.lower(skins[b] and skins[b].name or "") --- end) + table.insert(skins, TitanSkinsDefault[idx]) + -- table.sort(skins, function(a, b) + -- return string.lower(skins[a] and skins[a].name or "") + -- < string.lower(skins[b] and skins[b].name or "") + -- end) end -- search through the saved vars and compare against the defaults @@ -753,11 +818,11 @@ local function TitanVariables_SyncSkins() -- old Titan skin - let it drop else -- assume it is a user installed skin - table.insert (skins, TitanSkins[index]) --- table.sort(skins, function(a, b) --- return string.lower(skins[a] and skins[a].name or "") --- < string.lower(skins[b] and skins[b].name or "") --- end) + table.insert(skins, TitanSkins[index]) + -- table.sort(skins, function(a, b) + -- return string.lower(skins[a] and skins[a].name or "") + -- < string.lower(skins[b] and skins[b].name or "") + -- end) end end end @@ -771,17 +836,17 @@ DESC: Routine to reset / sync Titan settings. VAR: None OUT: None --]] -local function Set_Timers(reset) +local function Set_Timers(reset) -- Titan is loaded so set the timers we want to use TitanTimers = { - ["LDBRefresh"] = {obj = "LDB", callback = TitanLDBRefreshButton, delay = 2,}, + ["LDBRefresh"] = { obj = "LDB", callback = TitanLDBRefreshButton, delay = 2, }, -- Classic - ["EnterWorld"] = {obj = "PEW", callback = TitanPanel_AdjustFrames, delay = 4,}, - ["DualSpec"] = {obj = "SpecSwitch", callback = TitanPanel_AdjustFrames, delay = 2,}, - ["Adjust"] = {obj = "MoveAdj", callback = TitanPanel_AdjustFrames, delay = 1,}, - ["Vehicle"] = {obj = "Vehicle", callback = TitanPanel_AdjustFrames, delay = 1,}, + ["EnterWorld"] = { obj = "PEW", callback = TitanPanel_AdjustFrames, delay = 4, }, + ["DualSpec"] = { obj = "SpecSwitch", callback = TitanPanel_AdjustFrames, delay = 2, }, + ["Adjust"] = { obj = "MoveAdj", callback = TitanPanel_AdjustFrames, delay = 1, }, + ["Vehicle"] = { obj = "Vehicle", callback = TitanPanel_AdjustFrames, delay = 1, }, } - + if reset then TitanAllSetVar("TimerLDB", TitanTimers["LDBRefresh"].delay) -- Classic @@ -805,7 +870,7 @@ DESC: Routine to sync one plugin - current loaded (lua file) to its plugin saved VAR: id : plugin name OUT: None --]] -function TitanVariables_SyncSinglePluginSettings(id) +function TitanVariables_SyncSinglePluginSettings(id) -- Init this plugin local plugin = TitanPlugins[id] if (plugin and plugin.savedVariables) then @@ -814,26 +879,26 @@ function TitanVariables_SyncSinglePluginSettings(id) -- exists else TitanPluginSettings = {}; - end + end if TitanPluginSettings[id] then -- exists else TitanPluginSettings[id] = {}; - end - + end + -- Synchronize registered and saved variables TitanVariables_SyncRegisterSavedVariables( plugin.savedVariables, TitanPluginSettings[id]); end end ---[[ Titan +--[[ Titan -- one plugin uses this 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 +function TitanVariables_SyncPluginSettings() -- Init / sync every plugin for id, plugin in pairs(TitanPlugins) do if (plugin and plugin.savedVariables) then @@ -842,25 +907,25 @@ function TitanVariables_SyncPluginSettings() -- one plugin uses this -- Remove plugin savedVariables table if there's one if (TitanPluginSettings[id]) then TitanPluginSettings[id] = nil; - end + end end end end local function Titan_SyncAdjList() -- Using Titan list, walk saved vars to add adjustable frames - for frame, v in pairs(Titan_Panel.AdjList) do - if TitanAdjustSettings[frame] then + for frame, v in pairs(Titan_Global.AdjList) do + if TitanAdjustSettings[frame] then -- No action needed -- If default adds more elements (more data), they will need to be coded here. else TitanAdjustSettings[frame] = TitanAdjDefaults -- Init the saved vars end end - + -- Using saved vars, walk Titan list to remove frames no longer adjustable for frame, v in pairs(TitanAdjustSettings) do - if Titan_Panel.AdjList[frame] then + if Titan_Global.AdjList[frame] then -- No action needed -- frame is adjustable else @@ -880,10 +945,9 @@ NOTE: --]] function TitanVariables_InitTitanSettings() local trace = false - local new_toon = false local player = TitanUtils_GetPlayer() if trace then - TitanDebug("_Init begin "..tostring(player)) + TitanDebug("_Init begin " .. tostring(player)) end if (TitanSettings) then @@ -913,22 +977,22 @@ function TitanVariables_InitTitanSettings() TitanVariables_SyncRegisterSavedVariables(TITAN_ALL_SAVED_VARIABLES, TitanAll) if trace then - TitanDebug("_Init end "..tostring(player)) + TitanDebug("_Init end " .. tostring(player)) end -- Current Titan list known - all toons player has profiles for -- Sort in alphabetical order. -- Used for menus. - Titan_Panel.players = {} - for idx, v in pairs (TitanSettings.Players) do - table.insert(Titan_Panel.players, idx) + Titan_Global.players = {} + for idx, v in pairs(TitanSettings.Players) do + table.insert(Titan_Global.players, idx) end - table.sort(Titan_Panel.players, function(a, b) + table.sort(Titan_Global.players, function(a, b) return a < b end) ---[===[ -for idx = 1, #Titan_Panel.players do - print("["..idx.."] : '"..Titan_Panel.players[idx].."'") + --[===[ +for idx = 1, #Titan_Global.players do + print("["..idx.."] : '"..Titan_Global.players[idx].."'") end --]===] @@ -956,7 +1020,7 @@ function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) if reset then -- Initial defaults calc to screen size and scaling at that time - it could have changed! TitanBarDataVars[bar_frame].off_x = Calc_X() - TitanBarDataVars[bar_frame].off_y = Calc_Y(TitanBarData[bar_frame].order-2) + TitanBarDataVars[bar_frame].off_y = Calc_Y(TitanBarData[bar_frame].order - 2) TitanBarDataVars[bar_frame].off_w = SHORT_WIDTH else -- local to show bars as needed @@ -965,7 +1029,7 @@ function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) TitanBarDataVars[bar_frame].off_w = w_off end end ---[[ + --[[ print("_SetBarPos" .." "..tostring(self:GetName()).."" .." "..tostring(reset).."" @@ -984,7 +1048,7 @@ OUT: X, Y, Width --]] function TitanVariables_GetBarPos(frame_str) local tscale = TitanPanelGetVar("Scale") ---[[ + --[[ print("_GetBarPos f" .." '"..tostring(frame_str).."'" .." '"..tostring(TitanBarData[frame_str].name).."'" @@ -996,9 +1060,9 @@ print("_GetBarPos" .." '"..tostring(format("%0.1f", TitanBarDataVars[frame_str].off_w)).."'" ) --]] - return - TitanBarDataVars[frame_str].off_x, --/ tscale, -- / tscale, - TitanBarDataVars[frame_str].off_y, --/ tscale, -- / tscale, + return + TitanBarDataVars[frame_str].off_x, --/ tscale, -- / tscale, + TitanBarDataVars[frame_str].off_y, --/ tscale, -- / tscale, TitanBarDataVars[frame_str].off_w -- / tscale end @@ -1009,23 +1073,23 @@ VAR: bar_str - frame name to retrieve positions from OUT: frame string --]] function TitanVariables_GetFrameName(bar_str) - return TITAN_PANEL_DISPLAY_PREFIX..bar_str + return TITAN_PANEL_DISPLAY_PREFIX .. bar_str end -- lua-users.org/wiki/CopyTable local function deepcopy(orig) - local orig_type = type(orig) - local copy - if orig_type == 'table' then - copy = {} - for orig_key, orig_value in next, orig, nil do - copy[deepcopy(orig_key)] = deepcopy(orig_value) - end - setmetatable(copy, deepcopy(getmetatable(orig))) - else -- number, string, boolean, etc - copy = orig - end - return copy + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + setmetatable(copy, deepcopy(getmetatable(orig))) + else -- number, string, boolean, etc + copy = orig + end + return copy end local function Set_bar_vars(to_profile, trace) @@ -1044,26 +1108,26 @@ local function Set_bar_vars(to_profile, trace) -- Set to defaults TitanSettings.Players[to_profile].BarVars = TitanBarVarsDefaults local BV = TitanSettings.Players[to_profile].BarVars - + -- Cannot assume profile is current / cannot use Get Var routines. local panel = TitanSettings.Players[to_profile].Panel local tex = panel["TexturePath"]:gsub("TitanClassic", "Titan") if tracer then - print("tex path '"..tex.."'") + print("tex path '" .. tex .. "'") end -- Bring original Titan bar optionss to the current user settings. -- If this is a new toon or new saved vars then it will just get defaults. - for idx, v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do if v.user_move == false then -- 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"] + 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 = Titan_Panel.SKIN - BV[idx].skin.alpha = panel[v.name.."_Transparency"] + BV[idx].texure = Titan_Global.SKIN + BV[idx].skin.alpha = panel[v.name .. "_Transparency"] BV[idx].skin.path = tex end end @@ -1092,21 +1156,21 @@ NOTE: --]] local function Init_player_settings(from_profile, to_profile, action) local trace = false - + local old_player = {} local old_panel = {} local old_plugins = {} local reset = (action == TITAN_PROFILE_RESET) - + if trace then print("Init_player_settings" - .." from: "..tostring(from_profile).."" - .." to: "..tostring(to_profile).."" - .." action: "..tostring(action).."" + .. " from: " .. tostring(from_profile) .. "" + .. " to: " .. tostring(to_profile) .. "" + .. " action: " .. tostring(action) .. "" ) end - CleanupProfile () -- hide currently shown plugins + CleanupProfile() -- hide currently shown plugins if TitanSettings.Players[to_profile] then -- all is good @@ -1125,9 +1189,7 @@ local function Init_player_settings(from_profile, to_profile, action) TitanPlayerSettings["Panel"] = {} TitanPlayerSettings["Register"] = {} TitanPlayerSettings["BarVars"] = TitanBarVarsDefaults -- New Mar 2023 - TitanPlayerSettings["Adjust"] = {} -- New May 2023 - - new_toon = true + TitanPlayerSettings["Adjust"] = {} -- New May 2023 end -- Set global variables TitanPlayerSettings = TitanSettings.Players[to_profile]; @@ -1137,7 +1199,7 @@ local function Init_player_settings(from_profile, to_profile, action) -- ====== New May 2023 : Back to adjusting a couple frames per user settings -- Could be new toon / ... - if TitanPlayerSettings["Adjust"] then + if TitanPlayerSettings["Adjust"] then -- No action needed else TitanPlayerSettings["Adjust"] = {} @@ -1145,11 +1207,11 @@ local function Init_player_settings(from_profile, to_profile, action) TitanAdjustSettings = TitanPlayerSettings["Adjust"] Titan_SyncAdjList() -- The player settings are known, init the adjustable frames - for idx, v in pairs (Titan_Panel.AdjList) do + for idx, v in pairs(Titan_Global.AdjList) do TitanPanel_AdjustFrameInit(idx) end -- ====== - + -- ====== New Mar 2023 : TitanSettings.Players[player].BarData to hold Short bar data Set_bar_vars(to_profile, trace) -- ====== @@ -1178,23 +1240,23 @@ local function Init_player_settings(from_profile, to_profile, action) if trace then -- Apply the new bar positions - for idx, v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do print("BarVars " - .." "..tostring(v.name).."" - .." "..tostring(TitanSettings.Players[from_profile]["BarVars"][idx].show).."" - .." "..tostring(TitanSettings.Players[to_profile]["BarVars"][idx].show).."" + .. " " .. tostring(v.name) .. "" + .. " " .. tostring(TitanSettings.Players[from_profile]["BarVars"][idx].show) .. "" + .. " " .. tostring(TitanSettings.Players[to_profile]["BarVars"][idx].show) .. "" ) end end -- Copy the panel settings for index, id in pairs(old_panel) do - TitanPanelSetVar(index, old_panel[index]); + TitanPanelSetVar(index, old_panel[index]); end -- Copy the plugin settings for plugin, i in pairs(old_plugins) do - for var, id in pairs(old_plugins[plugin]) do + for var, id in pairs(old_plugins[plugin]) do TitanSetVar(plugin, var, old_plugins[plugin][var]) end end @@ -1213,11 +1275,11 @@ local function Init_player_settings(from_profile, to_profile, action) TitanVariables_PluginSettingsInit() end end - + TitanSkins = TitanVariables_SyncSkins() Set_Timers(reset) - + -- for debug if a user needs to send in the Titan saved vars if TitanPlayerSettings["Register"] then -- From WoW saved vars @@ -1226,7 +1288,7 @@ local function Init_player_settings(from_profile, to_profile, action) TitanPlayerSettings["Register"] = {} end TitanPanelRegister = TitanPlayerSettings["Register"] - + TitanSettings.Profile = to_profile end @@ -1243,8 +1305,8 @@ NOTE: function TitanGetVar(id, var) if (id and var and TitanPluginSettings and TitanPluginSettings[id]) then -- compatibility check - if TitanPluginSettings[id][var] == "Titan Nil" then - TitanPluginSettings[id][var] = false + if TitanPluginSettings[id][var] == "Titan Nil" then + TitanPluginSettings[id][var] = false end return TitanPluginSettings[id][var]; --return TitanUtils_Ternary(TitanPluginSettings[id][var] == false, nil, TitanPluginSettings[id][var]); @@ -1265,9 +1327,9 @@ NOTE: function TitanVarExists(id, var) -- We need to check for existance not true! -- If the value is nil then it will not exist... - if (id and var and TitanPluginSettings and TitanPluginSettings[id] - and (TitanPluginSettings[id][var] - or TitanPluginSettings[id][var] == false) ) + if (id and var and TitanPluginSettings and TitanPluginSettings[id] + and (TitanPluginSettings[id][var] + or TitanPluginSettings[id][var] == false)) then return true else @@ -1319,9 +1381,9 @@ NOTE: --]] function TitanPanelGetVar(var) if (var and TitanPanelSettings) then - if TitanPanelSettings[var] == "Titan Nil" then - TitanPanelSettings[var] = false - end + if TitanPanelSettings[var] == "Titan Nil" then + TitanPanelSettings[var] = false + end return TitanUtils_Ternary(TitanPanelSettings[var] == false, nil, TitanPanelSettings[var]); end end @@ -1337,7 +1399,7 @@ NOTE: :NOTE --]] function TitanPanelSetVar(var, value) - if (var and TitanPanelSettings) then + if (var and TitanPanelSettings) then TitanPanelSettings[var] = TitanUtils_Ternary(value, value, false); end end @@ -1368,8 +1430,8 @@ NOTE: --]] function TitanAllGetVar(var) if (var and TitanAll) then - if TitanAll[var] == "Titan Nil" then - TitanAll[var] = false + if TitanAll[var] == "Titan Nil" then + TitanAll[var] = false end return TitanUtils_Ternary(TitanAll[var] == false, nil, TitanAll[var]); end @@ -1419,8 +1481,8 @@ function TitanVariables_GetPanelStrata(value) local index; local indexpos = 5 -- DIALOG - local StrataTypes = {"BACKGROUND", "LOW", "MEDIUM", "HIGH", - "DIALOG", "FULLSCREEN", "FULLSCREEN_DIALOG"} + local StrataTypes = { "BACKGROUND", "LOW", "MEDIUM", "HIGH", + "DIALOG", "FULLSCREEN", "FULLSCREEN_DIALOG" } for index in ipairs(StrataTypes) do if value == StrataTypes[index] then @@ -1428,7 +1490,7 @@ function TitanVariables_GetPanelStrata(value) break end end - + return StrataTypes[indexpos + 1], StrataTypes[indexpos] end @@ -1440,15 +1502,16 @@ OUT: None --]] function TitanVariables_SetPanelStrata(value) local plugins, bars = TitanVariables_GetPanelStrata(value) - local idx, v -- Set all the Titan bars - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do _G[idx]:SetFrameStrata(bars) end -- Set all the registered plugins for idx, v in pairs(TitanPluginsIndex) do - local button = TitanUtils_GetButton(v); - button:SetFrameStrata(plugins) + local button = TitanUtils_GetButton(v) + if button then + button:SetFrameStrata(plugins) + end end end @@ -1459,11 +1522,11 @@ VAR: profile - profile to use for this toon : <name>@<server> OUT: None NOTE: - Called from the Titan right click menu -- profile is compared as 'lower' so the case of profile does not matter +- profile is compared as 'lower' so the case of profile does not matter :NOTE --]] function TitanVariables_UseSettings(profile, action) ---[[ + --[[ print("_UseSettings " .."profile: "..(profile or "?").." " .."action: "..action.." " @@ -1475,12 +1538,12 @@ print("_UseSettings " -- Grab the old profile currently in use from_profile = profile or nil end - + local _ = nil local glob, name, player, server = TitanUtils_GetGlobalProfile() -- Get the profile according to the user settings if glob then - profile = name -- Use global toon + profile = name -- Use global toon else profile, _, _ = TitanUtils_GetPlayer() -- Use current toon end @@ -1499,15 +1562,15 @@ print("_UseSettings " -- And it needs to be created action = TITAN_PROFILE_RESET end - + -- Now that we know what profile to use - act on the data Init_player_settings(from_profile, new_profile, action) - + -- set strata in case it has changed TitanVariables_SetPanelStrata(TitanPanelGetVar("FrameStrata")) -- show the new profile - TitanPanel_InitPanelBarButton(); + TitanPanel_InitPanelBarButton("UseSettings"); TitanPanel_InitPanelButtons(); end @@ -1528,4 +1591,4 @@ function TitanSetVarTable(id, var, position, value) end end ---]] \ No newline at end of file +--]] diff --git a/Titan/Titan_Mainline.toc b/Titan/Titan_Mainline.toc index b5b9f75..fc127e0 100644 --- a/Titan/Titan_Mainline.toc +++ b/Titan/Titan_Mainline.toc @@ -1,7 +1,7 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.5|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.6|r ## Author: Titan Panel Dev Team -## Version: 8.0.5 +## Version: 8.0.6 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## Notes: Adds display bars to show and control information/launcher plugins. ## X-Credits: TitanMod, Dark Imakuni, Adsertor, Titan Dev Team diff --git a/TitanAmmo/TitanAmmo_Vanilla.toc b/TitanAmmo/TitanAmmo_Vanilla.toc index 865d571..7580de8 100644 --- a/TitanAmmo/TitanAmmo_Vanilla.toc +++ b/TitanAmmo/TitanAmmo_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.1|r -## Version: 8.0.1 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds an ammo monitor to Titan Panel - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanAmmo/TitanAmmo_Wrath.toc b/TitanAmmo/TitanAmmo_Wrath.toc index bb46973..29852be 100644 --- a/TitanAmmo/TitanAmmo_Wrath.toc +++ b/TitanAmmo/TitanAmmo_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.1|r -## Version: 8.0.1 +## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds an ammo monitor to Titan Panel - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanAmmo/TitanClassicAmmo.lua b/TitanAmmo/TitanClassicAmmo.lua index 5685037..ea9869c 100644 --- a/TitanAmmo/TitanClassicAmmo.lua +++ b/TitanAmmo/TitanClassicAmmo.lua @@ -46,8 +46,8 @@ local TITAN_AMMO_THRESHOLD_TABLE = { -- Use ammo stack and threshold limits abov }; -- ******************************** Variables ******************************* -local ammoSlotID = GetInventorySlotInfo("AmmoSlot") -local rangedSlotID = GetInventorySlotInfo("RangedSlot") +local ammoSlotID = GetInventorySlotInfo("AMMOSLOT") +local rangedSlotID = GetInventorySlotInfo("RANGEDSLOT") -- Info to show on the plugin local display = { @@ -76,8 +76,8 @@ local function debug_msg(Message) local msg = "" local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S") local milli = GetTime() -- seconds with millisecond precision (float) - milli = string.format("%0.2F", milli - math.modf(milli)) - msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_AMMO_ID..": ") + local milli_str = string.format("%0.2F", milli - math.modf(milli)) + msg = msg..TitanUtils_GetGoldText(stamp..milli_str.." "..TITAN_AMMO_ID..": ") msg = msg..TitanUtils_GetGreenText(Message) DEFAULT_CHAT_FRAME:AddMessage(msg) -- DEFAULT_CHAT_FRAME:AddMessage(TITAN_AMMO_ID..": " .. Message, 1.00, 0.49, 0.04) @@ -292,47 +292,12 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelAmmoButton_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** ---]] -local function OnLoad(self) - self.registry = { - id = TITAN_AMMO_ID, - --builtIn = 1, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_AMMO_MENU_TEXT"], - buttonTextFunction = "TitanPanelAmmoButton_GetButtonText", - tooltipTitle = L["TITAN_AMMO_TOOLTIP"], - tooltipTextFunction = "TitanPanelAmmoButton_GetTooltipText", - icon = "Interface\\AddOns\\TitanAmmo\\TitanClassicThrown", - iconWidth = 16, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = true, - DisplayOnRightSide = true - }, - savedVariables = { - ShowIcon = 1, - ShowLabelText = 1, - ShowColoredText = 1, - ShowAmmoName = false, - DisplayOnRightSide = false, - } - } -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelAmmoButton_GetButtonText(id) +-- NAME : GetButtonText(id) -- DESC : Calculate ammo/thrown logic then put on button -- VARS : id = button ID -- ************************************************************************** --]] -function TitanPanelAmmoButton_GetButtonText(id) +function GetButtonText(id) local labelText, ammoText, ammoRichText, color; @@ -363,11 +328,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelRightClickMenu_PrepareAmmoMenu() +-- NAME : CreateMenu() -- DESC : Display rightclick menu options -- ************************************************************************** --]] -function TitanPanelRightClickMenu_PrepareAmmoMenu() +function CreateMenu() TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_AMMO_ID].menuText); local info = {}; @@ -390,7 +355,7 @@ function TitanPanelRightClickMenu_PrepareAmmoMenu() TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], TITAN_AMMO_ID, TITAN_PANEL_MENU_FUNC_HIDE); end -function TitanPanelAmmoButton_GetTooltipText() +function GetTooltipText() local txt = display.tool_tip if display.mismatch then txt = txt @@ -402,7 +367,43 @@ function TitanPanelAmmoButton_GetTooltipText() return txt end -local function OnShow() +--[[ +-- ************************************************************************** +-- NAME : TitanPanelAmmoButton_OnLoad() +-- DESC : Registers the plugin upon it loading +-- ************************************************************************** +--]] +local function OnLoad(self) + self.registry = { + id = TITAN_AMMO_ID, + --builtIn = 1, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_AMMO_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_AMMO_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + icon = "Interface\\AddOns\\TitanAmmo\\TitanClassicThrown", + iconWidth = 16, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = true, + DisplayOnRightSide = true + }, + savedVariables = { + ShowIcon = 1, + ShowLabelText = 1, + ShowColoredText = 1, + ShowAmmoName = false, + DisplayOnRightSide = false, + } + } +end + +local function OnShow(self) ClrAmmoInfo() if IsAmmoClass() then @@ -418,7 +419,7 @@ local function OnShow() TitanPanelButton_UpdateButton(TITAN_AMMO_ID); end -local function OnHide() +local function OnHide(self) ClrAmmoInfo() Events("unregister", "OnHide") @@ -439,17 +440,17 @@ end local function OnEvent(self, event, arg1, arg2, ...) if event == "PLAYER_ENTERING_WORLD" then if arg1 == true then -- login - EnterWorld() + -- EnterWorld() end if arg2 == true then -- reload / zoning - UpdateDisplay(); + UpdateDisplay() end elseif event == "UNIT_INVENTORY_CHANGED" then if arg1 == "player" then - UpdateDisplay(); + UpdateDisplay() end elseif event == "MERCHANT_CLOSED" then - UpdateDisplay(); + UpdateDisplay() end end diff --git a/TitanBag/TitanBag.lua b/TitanBag/TitanBag.lua index 3f724c6..970ca0b 100644 --- a/TitanBag/TitanBag.lua +++ b/TitanBag/TitanBag.lua @@ -57,7 +57,7 @@ local function IsProfessionBagID(slot) -- The info needed is available using GetItemInfoInstant; only the bag / item id is required -- itemType : warcraft.wiki.gg/wiki/itemType local res = false - local style = "" + local style = 0 local info, itemId, itemType, itemSubType, itemEquipLoc, itemTexture, classID, subclassID local inv_id = C_Container.ContainerIDToInventoryID(slot) @@ -113,35 +113,6 @@ TitanDebug("T isP 0:" return res, style end -local function IsProfessionBag(class, subclass) - local prof = false - local style = "" - if class == 1 then -- is a container - if subclass == 0 then style = "" - elseif subclass == 1 then style = "SOUL" - elseif subclass == 2 then style = "HERBALISM" - elseif subclass == 3 then style = "ENCHANTING" - elseif subclass == 4 then style = "ENGINEERING" - elseif subclass == 5 then style = "JEWELCRAFTING" - elseif subclass == 6 then style = "MINING" - elseif subclass == 7 then style = "LEATHERWORKING" - elseif subclass == 8 then style = "INSCRIPTION" - elseif subclass == 9 then style = "FISHING" - elseif subclass == 10 then style = "COOKING" - else - end - if subclass >= 1 - and subclass <= 10 - then prof = true - else - end - else - -- Not even a bag - end - - return prof, style -end - local function ToggleBags() if TitanGetVar(TITAN_BAG_ID, "OpenBags") then ToggleAllBags() diff --git a/TitanBag/TitanBag_Mainline.toc b/TitanBag/TitanBag_Mainline.toc index f08f5f9..e705136 100644 --- a/TitanBag/TitanBag_Mainline.toc +++ b/TitanBag/TitanBag_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanBag/TitanBag_Vanilla.toc b/TitanBag/TitanBag_Vanilla.toc index 0ae831a..1cd6b6e 100644 --- a/TitanBag/TitanBag_Vanilla.toc +++ b/TitanBag/TitanBag_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanBag/TitanBag_Wrath.toc b/TitanBag/TitanBag_Wrath.toc index 460f454..b75ab15 100644 --- a/TitanBag/TitanBag_Wrath.toc +++ b/TitanBag/TitanBag_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClassic/TitanClassic_Vanilla.toc b/TitanClassic/TitanClassic_Vanilla.toc index 0bf6de4..eb5533f 100644 --- a/TitanClassic/TitanClassic_Vanilla.toc +++ b/TitanClassic/TitanClassic_Vanilla.toc @@ -1,7 +1,7 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.5|r +## Interface: 11500 +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.6|r ## Author: Titan Panel Dev Team -## Version: 8.0.5 +## Version: 8.0.6 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds display bars to show and control information/launcher plugins. diff --git a/TitanClassic/TitanClassic_Wrath.toc b/TitanClassic/TitanClassic_Wrath.toc index 6a70fc4..06893c3 100644 --- a/TitanClassic/TitanClassic_Wrath.toc +++ b/TitanClassic/TitanClassic_Wrath.toc @@ -1,7 +1,7 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.5|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.6|r ## Author: Titan Panel Dev Team -## Version: 8.0.5 +## Version: 8.0.6 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds display bars to show and control information/launcher plugins. diff --git a/TitanClock/TitanClock.lua b/TitanClock/TitanClock.lua index 262a66e..7c8cdf3 100644 --- a/TitanClock/TitanClock.lua +++ b/TitanClock/TitanClock.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanClock.lua @@ -8,7 +9,7 @@ -- ******************************** Constants ******************************* TITAN_CLOCK_ID = "Clock"; -local TITAN_BUTTON = "TitanPanel"..TITAN_CLOCK_ID.."Button" +local TITAN_BUTTON = "TitanPanel" .. TITAN_CLOCK_ID .. "Button" local TITAN_CLOCK_FORMAT_12H = "12H"; local TITAN_CLOCK_FORMAT_24H = "24H"; @@ -17,52 +18,11 @@ local _G = getfenv(0); -- ******************************** Variables ******************************* local AceTimer = LibStub("AceTimer-3.0") local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -local ClockTimer = nil; -local updateTable = {TITAN_CLOCK_ID, TITAN_PANEL_UPDATE_ALL }; +local ClockTimer = {} +local updateTable = { TITAN_CLOCK_ID, TITAN_PANEL_UPDATE_ALL }; local realmName = GetRealmName(); -- ******************************** Functions ******************************* - ---[[ --- ************************************************************************** --- NAME : TitanPanelClockButton_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** ---]] -function TitanPanelClockButton_OnLoad(self) - local notes = "" - .."Adds a clock to Titan Panel.\n" - .."- Select server time / local time / both server and local time.\n" - self.registry = { - id = TITAN_CLOCK_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_CLOCK_MENU_TEXT"], - buttonTextFunction = "TitanPanelClockButton_GetButtonText", - tooltipTitle = L["TITAN_CLOCK_TOOLTIP"], - tooltipTextFunction = "TitanPanelClockButton_GetTooltipText", - notes = notes, - controlVariables = { - ShowIcon = false, - ShowLabelText = true, - ShowColoredText = true, - DisplayOnRightSide = true, - }, - savedVariables = { - OffsetHour = 0, - Format = TITAN_CLOCK_FORMAT_12H, - TimeMode = "Server", - ShowIcon = true, - ShowLabelText = false, - ShowColoredText = false, - DisplayOnRightSide = 1, - HideGameTimeMinimap = false, - HideMapTime = false, - } - }; - self:RegisterEvent("PLAYER_ENTERING_WORLD"); -end - -local function TitanPanelClockButton_GetColored(text) +local function SetColor(text) local label = ""; if (TitanGetVar(TITAN_CLOCK_ID, "ShowColoredText")) then label = TitanUtils_GetGreenText(text) @@ -72,122 +32,26 @@ local function TitanPanelClockButton_GetColored(text) return label; end ---[[ --- ************************************************************************** --- NAME : TitanPanelClockButton_OnShow() --- DESC : Create repeating timer when plugin is visible --- ************************************************************************** ---]] -function TitanPanelClockButton_OnShow() - if not ClockTimer then - ClockTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelClock", TitanPanelPluginHandle_OnUpdate, 30, updateTable) - end -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelClockButton_OnHide() --- DESC : Destroy repeating timer when plugin is hidden --- ************************************************************************** ---]] -function TitanPanelClockButton_OnHide() - AceTimer.CancelTimer("TitanPanelClock", ClockTimer, true) - ClockTimer = nil; -end - -function TitanPanelClockButton_OnEvent(self, event, ...) - if (event == "PLAYER_ENTERING_WORLD") then - -- If the user wants the minimap clock or calendar hidden then hide them - if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then - if GameTimeFrame then GameTimeFrame:Hide() end - end - if TimeManagerClockButton and TimeManagerClockButton:GetName() then - if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then - TimeManagerClockButton:Hide() - else - TimeManagerClockButton:Show() - end - end - end -end - -function TitanPanelClockButton_OnClick(self, button) - if button == "LeftButton" and IsShiftKeyDown() then - TitanUtils_CloseAllControlFrames(); - if (TitanPanelRightClickMenu_IsVisible()) then - TitanPanelRightClickMenu_Close(); - end - ToggleCalendar() - elseif button == "LeftButton" then - else - TitanPanelButton_OnClick(self, button); - end -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelClockButton_GetButtonText() --- DESC : Display time on button based on set variables --- ************************************************************************** ---]] -function TitanPanelClockButton_GetButtonText() - local clocktime = ""; - local labeltext = ""; - local clocktime2 = nil; - local labeltext2 = nil; - local _ = nil - if TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" then - _,clocktime = TitanPanelClockButton_GetTime("Server", 0) - labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(S) ") or "" - elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" then - _,clocktime = TitanPanelClockButton_GetTime ("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) - labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(A) ") or "" - elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" then - _,clocktime = TitanPanelClockButton_GetTime ("Local", 0) - labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(L) ") or "" - elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerLocal" then - local _, s = TitanPanelClockButton_GetTime ("Server", 0) - local _, l = TitanPanelClockButton_GetTime ("Local", 0) - sl = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(S) ") or "" - ll = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(L) ") or "" - clocktime = s - labeltext = sl - clocktime2 = l - labeltext2 = ll - elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjustedLocal" then - local _, s = TitanPanelClockButton_GetTime ("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) - local _, l = TitanPanelClockButton_GetTime ("Local", 0) - sl = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(A) ") or "" - ll = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(L) ") or "" - clocktime = s - labeltext = sl - clocktime2 = l - labeltext2 = ll - elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" then - _,clocktime = TitanPanelClockButton_GetTime ("Local", 0) - labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and TitanPanelClockButton_GetColored("(L) ") or "" - end - return labeltext, clocktime, labeltext2, clocktime2 -end - -function TitanPanelClockButton_GetTime(displaytype, offset) +local function TitanPanelClockButton_GetTime(displaytype, offset) -- Calculate the hour/minutes considering the offset local hour, minute = GetGameTime(); local twentyfour = ""; local offsettime = string.format("%s", offset); local offsethour = 0; + local hour_str = "" local offsetmin = 0; + local min_str = "" local s, e, id = string.find(offsettime, '%.5'); if displaytype == "Server" then if (s ~= nil) then - offsethour = string.sub(offsettime, 1, s); - offsetmin = string.sub(offsettime, s+1); - if offsetmin == "" or offsetmin == nil then offsetmin = "0"; end - if offsethour == "" or offsethour == nil then offsethour = "0"; end - offsethour = tonumber(offsethour); - if (tonumber(offsettime) < 0) then offsetmin = tonumber("-" .. offsetmin); end - minute = minute + (offsetmin*6); + hour_str = string.sub(offsettime, 1, s); + min_str = string.sub(offsettime, s + 1); + if min_str == "" or min_str == nil then min_str = "0"; end + if hour_str == "" or hour_str == nil then hour_str = "0"; end + offsethour = tonumber(hour_str); + if (tonumber(offsettime) < 0) then offsetmin = tonumber("-" .. min_str); end + minute = minute + (offsetmin * 6); if (minute > 59) then minute = minute - 60; offsethour = offsethour + 1; @@ -236,44 +100,323 @@ function TitanPanelClockButton_GetTime(displaytype, offset) end return nil, twentyfour; end +end +--[[ +-- ************************************************************************** +-- NAME : GetButtonText() +-- DESC : Display time on button based on set variables +-- ************************************************************************** +--]] +local function GetButtonText() + local clocktime = ""; + local labeltext = ""; + local clocktime2 = nil; + local labeltext2 = nil; + local _ = nil + if TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" then + _, clocktime = TitanPanelClockButton_GetTime("Server", 0) + labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(S) ") or "" + elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" then + _, clocktime = TitanPanelClockButton_GetTime("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) + labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(A) ") or "" + elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" then + _, clocktime = TitanPanelClockButton_GetTime("Local", 0) + labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(L) ") or "" + elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerLocal" then + local _, s = TitanPanelClockButton_GetTime("Server", 0) + local _, l = TitanPanelClockButton_GetTime("Local", 0) + local sl = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(S) ") or "" + local ll = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(L) ") or "" + clocktime = s + labeltext = sl + clocktime2 = l + labeltext2 = ll + elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjustedLocal" then + local _, s = TitanPanelClockButton_GetTime("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) + local _, l = TitanPanelClockButton_GetTime("Local", 0) + local sl = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(A) ") or "" + local ll = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(L) ") or "" + clocktime = s + labeltext = sl + clocktime2 = l + labeltext2 = ll + elseif TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" then + _, clocktime = TitanPanelClockButton_GetTime("Local", 0) + labeltext = TitanGetVar(TITAN_CLOCK_ID, "ShowLabelText") and SetColor("(L) ") or "" + end + return labeltext, clocktime, labeltext2, clocktime2 end --[[ -- ************************************************************************** --- NAME : TitanPanelClockButton_GetTooltipText() +-- NAME : TitanPanelClock_GetOffsetText(offset) +-- DESC : Get hour offset value and return +-- VARS : offset = hour offset from server time +-- ************************************************************************** +--]] +local function TitanPanelClock_GetOffsetText(offset) + if (offset > 0) then + return TitanUtils_GetGreenText("+" .. tostring(offset)); + elseif (offset < 0) then + return TitanUtils_GetRedText(tostring(offset)); + else + return TitanUtils_GetHighlightText(tostring(offset)); + end +end + +--[[ +-- ************************************************************************** +-- NAME : GetTooltipText() -- DESC : Display tooltip text -- ************************************************************************** --]] -function TitanPanelClockButton_GetTooltipText() - local _, clockTimeLocal = TitanPanelClockButton_GetTime ("Local", 0) - local _, clockTimeServer = TitanPanelClockButton_GetTime ("Server", 0) - local _, clockTimeServerAdjusted = TitanPanelClockButton_GetTime ("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) - local clockTimeLocalLabel = L["TITAN_CLOCK_TOOLTIP_LOCAL_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeLocal) - local clockTimeServerLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeServer) - local clockTimeServerAdjustedLabel = ""; - if TitanGetVar(TITAN_CLOCK_ID, "OffsetHour") ~= 0 then - clockTimeServerAdjustedLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_ADJUSTED_TIME"].."\t"..TitanUtils_GetHighlightText(clockTimeServerAdjusted).."\n" - end - local clockText = TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")); - return "".. - clockTimeLocalLabel.."\n".. - clockTimeServerLabel.."\n".. - clockTimeServerAdjustedLabel.. - L["TITAN_CLOCK_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(clockText).."\n".. - TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT1"]).."\n".. - TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT2"]).."\n".. +local function GetTooltipText() + local _, clockTimeLocal = TitanPanelClockButton_GetTime("Local", 0) + local _, clockTimeServer = TitanPanelClockButton_GetTime("Server", 0) + local _, clockTimeServerAdjusted = TitanPanelClockButton_GetTime("Server", TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")) + local clockTimeLocalLabel = L["TITAN_CLOCK_TOOLTIP_LOCAL_TIME"] .. "\t" .. + TitanUtils_GetHighlightText(clockTimeLocal) + local clockTimeServerLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_TIME"] .. + "\t" .. TitanUtils_GetHighlightText(clockTimeServer) + local clockTimeServerAdjustedLabel = ""; + if TitanGetVar(TITAN_CLOCK_ID, "OffsetHour") ~= 0 then + clockTimeServerAdjustedLabel = L["TITAN_CLOCK_TOOLTIP_SERVER_ADJUSTED_TIME"] .. + "\t" .. TitanUtils_GetHighlightText(clockTimeServerAdjusted) .. "\n" + end + local clockText = TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour")); + return "" .. + clockTimeLocalLabel .. "\n" .. + clockTimeServerLabel .. "\n" .. + clockTimeServerAdjustedLabel .. + L["TITAN_CLOCK_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(clockText) .. "\n" .. + TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT1"]) .. "\n" .. + TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT2"]) .. "\n" .. TitanUtils_GetGreenText(L["TITAN_CLOCK_TOOLTIP_HINT3"]); end +local function ToggleGameTimeFrameShown() + TitanToggleVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); + if GameTimeFrame and GameTimeFrame:GetName() then + if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then + GameTimeFrame:Hide() + else + GameTimeFrame:Show() + end + end +end + +local function ToggleMapTime() + TitanToggleVar(TITAN_CLOCK_ID, "HideMapTime"); + if TimeManagerClockButton and TimeManagerClockButton:GetName() then + if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then + TimeManagerClockButton:Hide() + else + TimeManagerClockButton:Show() + end + else + print("TitanClock: no time widget") + end +end + --[[ -- ************************************************************************** --- NAME : TitanPanelClockControlSlider_OnEnter() +-- NAME : CreateMenu() +-- DESC : Generate clock right click menu options +-- ************************************************************************** +--]] +local function CreateMenu() + TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_CLOCK_ID].menuText); + + local info = {}; + info.text = L["TITAN_CLOCK_MENU_LOCAL_TIME"]; + info.func = function() + TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Local") + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_SERVER_TIME"]; + info.func = function() + TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Server") + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_SERVER_ADJUSTED_TIME"]; + info.func = function() + TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerAdjusted") + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_SERVER_TIME"] .. " & " .. L["TITAN_CLOCK_MENU_LOCAL_TIME"] + info.func = function() + TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerLocal") + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerLocal" end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_SERVER_ADJUSTED_TIME"] .. " & " .. L["TITAN_CLOCK_MENU_LOCAL_TIME"] + info.func = function() + TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerAdjustedLocal") + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjustedLocal" end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; -- 12 or 24 hour format + info.text = L["TITAN_CLOCK_CHECKBUTTON"] + info.func = function() + if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_12H) then + TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_24H); + else + TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_12H); + end + if (ServerHourFormat[realmName]) then + ServerHourFormat[realmName] = TitanGetVar(TITAN_CLOCK_ID, "Format"); + end + + TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) + end + info.checked = function() + if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_24H) then + return true + else + return false + end + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + TitanPanelRightClickMenu_AddSpacer(); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_HIDE_MAPTIME"]; + info.func = ToggleMapTime; + info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideMapTime"); + info.keepShownOnClick = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_CLOCK_MENU_HIDE_CALENDAR"]; + info.func = ToggleGameTimeFrameShown; + info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); + info.keepShownOnClick = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + TitanPanelRightClickMenu_AddControlVars(TITAN_CLOCK_ID) +end + +--[[ +-- ************************************************************************** +-- NAME : OnLoad() +-- DESC : Registers the plugin upon it loading +-- ************************************************************************** +--]] +local function OnLoad(self) + local notes = "" + .. "Adds a clock to Titan Panel.\n" + .. "- Select server time / local time / both server and local time.\n" + self.registry = { + id = TITAN_CLOCK_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_CLOCK_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_CLOCK_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + notes = notes, + controlVariables = { + ShowIcon = false, + ShowLabelText = true, + ShowColoredText = true, + DisplayOnRightSide = true, + }, + savedVariables = { + OffsetHour = 0, + Format = TITAN_CLOCK_FORMAT_12H, + TimeMode = "Server", + ShowIcon = true, + ShowLabelText = false, + ShowColoredText = false, + DisplayOnRightSide = 1, + HideGameTimeMinimap = false, + HideMapTime = false, + } + }; + self:RegisterEvent("PLAYER_ENTERING_WORLD"); +end + +--[[ +-- ************************************************************************** +-- NAME : OnShow() +-- DESC : Create repeating timer when plugin is visible +-- ************************************************************************** +--]] +local function OnShow(self) + if ClockTimer == {} then + ClockTimer = AceTimer:ScheduleRepeatingTimer(TitanPanelPluginHandle_OnUpdate, 30, updateTable) + end +end + +--[[ +-- ************************************************************************** +-- NAME : OnHide() +-- DESC : Destroy repeating timer when plugin is hidden +-- ************************************************************************** +--]] +local function OnHide(self) + AceTimer:CancelTimer(ClockTimer) + ClockTimer = nil; +end + +local function OnEvent(self, event, ...) + if (event == "PLAYER_ENTERING_WORLD") then + -- If the user wants the minimap clock or calendar hidden then hide them + if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then + if GameTimeFrame then GameTimeFrame:Hide() end + end + if TimeManagerClockButton and TimeManagerClockButton:GetName() then + if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then + TimeManagerClockButton:Hide() + else + TimeManagerClockButton:Show() + end + end + end +end + +local function OnClick(self, button) + if button == "LeftButton" and IsShiftKeyDown() then + TitanUtils_CloseAllControlFrames(); + if (TitanPanelRightClickMenu_IsVisible()) then + TitanPanelRightClickMenu_Close(); + end + ToggleCalendar() + elseif button == "LeftButton" then + else + TitanPanelButton_OnClick(self, button); + end +end + +--[[ +-- ************************************************************************** +-- NAME : Slider_OnEnter() -- DESC : Display slider tooltip -- ************************************************************************** --]] -function TitanPanelClockControlSlider_OnEnter(self) - self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); +local function Slider_OnEnter(self) + self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], + TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); @@ -281,11 +424,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelClockControlSlider_OnLeave() +-- NAME : Slider_OnLeave() -- DESC : Hide slider tooltip -- ************************************************************************** --]] -function TitanPanelClockControlSlider_OnLeave(self) +local function Slider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_CLOCK_FRAME_SHOW_TIME); @@ -293,15 +436,15 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelClockControlSlider_OnShow() +-- NAME : Slider_OnShow() -- DESC : Display slider tooltip options -- ************************************************************************** --]] -function TitanPanelClockControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); - _G[self:GetName().."High"]:SetText(L["TITAN_CLOCK_CONTROL_LOW"]); - _G[self:GetName().."Low"]:SetText(L["TITAN_CLOCK_CONTROL_HIGH"]); --- self:SetThumbTexture("Interface\Buttons\UI-SliderBar-Button-Vertical") +local function Slider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); + _G[self:GetName() .. "High"]:SetText(L["TITAN_CLOCK_CONTROL_LOW"]); + _G[self:GetName() .. "Low"]:SetText(L["TITAN_CLOCK_CONTROL_HIGH"]); + -- self:SetThumbTexture("Interface\Buttons\UI-SliderBar-Button-Vertical") self:SetMinMaxValues(-12, 12); self:SetValueStep(0.5); self:SetObeyStepOnDrag(true) -- since 5.4.2 (Mists of Pandaria) @@ -310,13 +453,13 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelClockControlSlider_OnValueChanged(arg1) +-- NAME : Slider_OnValueChanged(arg1) -- DESC : Display slider tooltip text -- VARS : arg1 = positive or negative change to apply -- ************************************************************************** --]] -function TitanPanelClockControlSlider_OnValueChangedWheel(self, a1) - _G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(0 - self:GetValue())); +local function Slider_OnValueChangedWheel(self, a1) + _G[self:GetName() .. "Text"]:SetText(TitanPanelClock_GetOffsetText(0 - self:GetValue())); local tempval = self:GetValue(); if a1 == -1 then @@ -328,61 +471,46 @@ function TitanPanelClockControlSlider_OnValueChangedWheel(self, a1) end TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", 0 - self:GetValue()); - if ( ServerTimeOffsets[realmName] ) then + if (ServerTimeOffsets[realmName]) then ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"); end TitanPanelButton_UpdateButton(TITAN_CLOCK_ID); -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); + self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], + TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -function TitanPanelClockControlSlider_OnValueChanged(self, a1) +local function Slider_OnValueChanged(self, a1) local step = self:GetValue() - _G[self:GetName().."Text"]:SetText(TitanPanelClock_GetOffsetText(0 - step)); + _G[self:GetName() .. "Text"]:SetText(TitanPanelClock_GetOffsetText(0 - step)); TitanSetVar(TITAN_CLOCK_ID, "OffsetHour", 0 - step); - if ( ServerTimeOffsets[realmName] ) then + if (ServerTimeOffsets[realmName]) then ServerTimeOffsets[realmName] = TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"); end TitanPanelButton_UpdateButton(TITAN_CLOCK_ID); -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); + self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_CLOCK_CONTROL_TOOLTIP"], + TitanPanelClock_GetOffsetText(TitanGetVar(TITAN_CLOCK_ID, "OffsetHour"))); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end --[[ -- ************************************************************************** --- NAME : TitanPanelClock_GetOffsetText(offset) --- DESC : Get hour offset value and return --- VARS : offset = hour offset from server time --- ************************************************************************** ---]] -function TitanPanelClock_GetOffsetText(offset) - if (offset > 0) then - return TitanUtils_GetGreenText("+" .. tostring(offset)); - elseif (offset < 0) then - return TitanUtils_GetRedText(tostring(offset)); - else - return TitanUtils_GetHighlightText(tostring(offset)); - end -end - ---[[ --- ************************************************************************** -- NAME : TitanPanelClockControlFrame_OnLoad() -- DESC : Create clock option frame -- ************************************************************************** --]] -function TitanPanelClockControlFrame_OnLoad(self) - _G[self:GetName().."Title"]:SetText(L["TITAN_CLOCK_CONTROL_TITLE"]); ---[[ +local function TitanPanelClockControlFrame_OnLoad(self) + _G[self:GetName() .. "Title"]:SetText(L["TITAN_CLOCK_CONTROL_TITLE"]); + --[[ Blizzard decided to remove direct Backdrop API in 9.0 (Shadowlands) so inherit the template (XML) and set the values in the code (Lua) @@ -394,169 +522,54 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelClockControlFrame_OnUpdate(elapsed) +-- NAME : Control_OnUpdate(elapsed) -- DESC : If dropdown is visible, see if its timer has expired. If so, hide frame -- VARS : elapsed = <research> -- ************************************************************************** --]] -function TitanPanelClockControlFrame_OnUpdate(self, elapsed) +local function Control_OnUpdate(self, elapsed) TitanUtils_CheckFrameCounting(self, elapsed); end ---[[ --- ************************************************************************** --- NAME : TitanPanelRightClickMenu_PrepareClockMenu() --- DESC : Generate clock right click menu options --- ************************************************************************** ---]] -function TitanPanelRightClickMenu_PrepareClockMenu() - TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_CLOCK_ID].menuText); - - local info = {}; - info.text = L["TITAN_CLOCK_MENU_LOCAL_TIME"]; - info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Local") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end - info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Local" end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_SERVER_TIME"]; - info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "Server") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end - info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "Server" end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_SERVER_ADJUSTED_TIME"]; - info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerAdjusted") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end - info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjusted" end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_SERVER_TIME"].." & "..L["TITAN_CLOCK_MENU_LOCAL_TIME"] - info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerLocal") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end - info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerLocal" end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_SERVER_ADJUSTED_TIME"].." & "..L["TITAN_CLOCK_MENU_LOCAL_TIME"] - info.func = function() TitanSetVar(TITAN_CLOCK_ID, "TimeMode", "ServerAdjustedLocal") TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) end - info.checked = function() return TitanGetVar(TITAN_CLOCK_ID, "TimeMode") == "ServerAdjustedLocal" end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; -- 12 or 24 hour format - info.text = L["TITAN_CLOCK_CHECKBUTTON"] - info.func = function() - if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_12H) then - TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_24H); - else - TitanSetVar(TITAN_CLOCK_ID, "Format", TITAN_CLOCK_FORMAT_12H); - end - if ( ServerHourFormat[realmName] ) then - ServerHourFormat[realmName] = TitanGetVar(TITAN_CLOCK_ID, "Format"); - end - - TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) - end - info.checked = function() - if (TitanGetVar(TITAN_CLOCK_ID, "Format") == TITAN_CLOCK_FORMAT_24H) then - return true - else - return false - end - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - TitanPanelRightClickMenu_AddSpacer(); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_HIDE_MAPTIME"]; - info.func = TitanPanelClockButton_ToggleMapTime; - info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideMapTime"); - info.keepShownOnClick = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.text = L["TITAN_CLOCK_MENU_HIDE_CALENDAR"]; - info.func = TitanPanelClockButton_ToggleGameTimeFrameShown; - info.checked = TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); - info.keepShownOnClick = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - TitanPanelRightClickMenu_AddControlVars(TITAN_CLOCK_ID) -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelClockButton_ToggleRightSideDisplay() --- DESC : Add clock button to bar --- ************************************************************************** ---]] -function TitanPanelClockButton_ToggleRightSideDisplay() - TitanToggleVar(TITAN_CLOCK_ID, "DisplayOnRightSide"); - TitanPanel_RemoveButton(TITAN_CLOCK_ID); - --TitanPanel_AddButton(TITAN_CLOCK_ID); -end - -function TitanPanelClockButton_ToggleGameTimeFrameShown() - TitanToggleVar(TITAN_CLOCK_ID, "HideGameTimeMinimap"); - if GameTimeFrame and GameTimeFrame:GetName() then - if TitanGetVar(TITAN_CLOCK_ID, "HideGameTimeMinimap") then - GameTimeFrame:Hide() - else - GameTimeFrame:Show() - end - end -end - -function TitanPanelClockButton_ToggleMapTime() - TitanToggleVar(TITAN_CLOCK_ID, "HideMapTime"); - if TimeManagerClockButton and TimeManagerClockButton:GetName() then - if TitanGetVar(TITAN_CLOCK_ID, "HideMapTime") then - TimeManagerClockButton:Hide() - else - TimeManagerClockButton:Show() - end - end -end - -- ====== Create needed frames local function Create_Frames() if _G[TITAN_BUTTON] then return -- if already created end - + -- general container frame local f = CreateFrame("Frame", nil, UIParent) --- f:Hide() + -- f:Hide() -- Titan plugin button local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelTextTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelClockButton_OnLoad(window); --- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... - + OnLoad(window); + -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... + window:SetScript("OnShow", function(self) - TitanPanelClockButton_OnShow() + OnShow(self) TitanPanelButton_OnShow(self) end) window:SetScript("OnHide", function(self) - TitanPanelClockButton_OnHide() + OnHide(self) end) window:SetScript("OnEvent", function(self, event, ...) - TitanPanelClockButton_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) window:SetScript("OnClick", function(self, button) - TitanPanelClockButton_OnClick(self, button) + OnClick(self, button) TitanPanelButton_OnClick(self, button) end) ----[===[ + ---[===[ -- Config screen local cname = "TitanPanelClockControlFrame" local config = CreateFrame("Frame", cname, f, BackdropTemplateMixin and "BackdropTemplate") config:SetFrameStrata("FULLSCREEN") -- FULLSCREEN - config:Hide() -- + config:Hide() -- config:SetWidth(90) config:SetHeight(200) @@ -569,13 +582,13 @@ local function Create_Frames() TitanUtils_StartFrameCounting(self, 0.5) end) config:SetScript("OnUpdate", function(self, elapsed) - TitanPanelClockControlFrame_OnUpdate(self, elapsed) + Control_OnUpdate(self, elapsed) end) - + -- Config Title local str = nil local style = "GameFontNormalSmall" - str = config:CreateFontString(cname.."Title", "ARTWORK", style) + str = config:CreateFontString(cname .. "Title", "ARTWORK", style) str:SetPoint("TOP", config, 0, -10) -- Config slider sections @@ -586,25 +599,25 @@ local function Create_Frames() local offset = CreateFrame("Slider", "TitanPanelClockControlSlider", config, inherit) offset:SetPoint("TOP", config, 0, -40) offset:SetScript("OnShow", function(self) - TitanPanelClockControlSlider_OnShow(self) + Slider_OnShow(self) end) - offset:SetScript("OnValueChanged", function(self) - TitanPanelClockControlSlider_OnValueChanged(self, value) + offset:SetScript("OnValueChanged", function(self, value, userInput) + Slider_OnValueChanged(self, value) end) - offset:SetScript("OnMouseWheel", function(self) - TitanPanelClockControlSlider_OnValueChangedWheel(self, delta) + offset:SetScript("OnMouseWheel", function(self, delta) + Slider_OnValueChangedWheel(self, delta) end) offset:SetScript("OnEnter", function(self) - TitanPanelClockControlSlider_OnEnter(self) + Slider_OnEnter(self) end) offset:SetScript("OnLeave", function(self) - TitanPanelClockControlSlider_OnLeave(self) + Slider_OnLeave(self) end) -- Now that the parts exist, initialize TitanPanelClockControlFrame_OnLoad(config) ---]===] + --]===] end Create_Frames() -- do the work diff --git a/TitanClock/TitanClock_Mainline.toc b/TitanClock/TitanClock_Mainline.toc index 4acd6c5..1879d02 100644 --- a/TitanClock/TitanClock_Mainline.toc +++ b/TitanClock/TitanClock_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClock/TitanClock_Vanilla.toc b/TitanClock/TitanClock_Vanilla.toc index 89a7c84..87f09b2 100644 --- a/TitanClock/TitanClock_Vanilla.toc +++ b/TitanClock/TitanClock_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClock/TitanClock_Wrath.toc b/TitanClock/TitanClock_Wrath.toc index 18a0a58..860e480 100644 --- a/TitanClock/TitanClock_Wrath.toc +++ b/TitanClock/TitanClock_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua index d262821..c0fdccc 100644 --- a/TitanGold/TitanGold.lua +++ b/TitanGold/TitanGold.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanGold.lua @@ -25,9 +26,10 @@ local GOLD_SESS_STATUS; local GOLD_PERHOUR_STATUS; local GOLD_STARTINGGOLD; local GOLD_SESSIONSTART; -local TitanGold = LibStub("AceAddon-3.0"):NewAddon("TitanGold", "AceTimer-3.0") +local TitanGold = LibStub("AceAddon-3.0"):NewAddon("TitanGold") +local AceTimer = LibStub("AceTimer-3.0") local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -local GoldTimer = nil; +local GoldTimer = {}; local _G = getfenv(0); local realmName = GetRealmName(); local realmNames = GetAutoCompleteRealms(); @@ -42,6 +44,11 @@ local FACTION_HORDE = "Horde_debug" --]] -- ******************************** Functions ******************************* +local function GetIndexInfo(info) + local character, charserver, char_faction = string.match(info, '(.*)_(.*)::(.*)') + return character, charserver, char_faction +end + --[[ Add commas or period in the value given as needed --]] @@ -167,436 +174,262 @@ SC.Print("Acc cash:" return outstr, cash, gold, silver, copper end ---[[ --- ************************************************************************** --- NAME : TitanPanelGoldButton_OnLoad() --- DESC : Registers the add on upon it loading --- ************************************************************************** ---]] -function TitanPanelGoldButton_OnLoad(self) - local notes = "" - .."Keeps track of all gold held by a player's toons.\n" - .."- Can show by server / merged servers / all servers.\n" - .."- Can show by faction.\n" - self.registry = { - id = TITAN_GOLD_ID, - category = "Built-ins", - version = TITAN_GOLD_VERSION, - menuText = L["TITAN_GOLD_MENU_TEXT"], - tooltipTitle = L["TITAN_GOLD_TOOLTIP"], - tooltipTextFunction = "TitanPanelGoldButton_GetTooltipText", - buttonTextFunction = "TitanPanelGoldButton_FindGold", - icon = "Interface\\AddOns\\TitanGold\\Artwork\\TitanGold", - iconWidth = 16, - notes = notes, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = false, - DisplayOnRightSide = true, - }, - savedVariables = { - Initialized = true, - DisplayGoldPerHour = true, - ShowCoinNone = false, - ShowCoinLabels = true, - ShowCoinIcons = false, - ShowGoldOnly = false, - SortByName = true, - ViewAll = true, - ShowIcon = true, - ShowLabelText = false, - ShowColoredText = true, - DisplayOnRightSide = false, - UseSeperatorComma = true, - UseSeperatorPeriod = false, - MergeServers = false, - SeparateServers = true, - AllServers = false, - IgnoreFaction = false, - GroupByRealm = false, - gold = { total = "112233", neg = false }, - ShowSessionInfo = true - } - }; - - self:RegisterEvent("PLAYER_ENTERING_WORLD"); - - if (not GoldSave) then - GoldSave={}; +local function ShowMenuButtons(faction) + local info = {}; + local name = GetUnitName("player"); + local server = realmName; + for index, money in pairs(GoldSave) do + local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); + if character + and (char_faction == faction) + then + info.text = character.." - "..charserver; + info.value = character; + info.keepShownOnClick = true; + info.checked = function() + local rementry = character.."_"..charserver.."::"..faction; + return GoldSave[rementry].show + end + info.func = function() + local rementry = character.."_"..charserver.."::"..faction; + GoldSave[rementry].show = not GoldSave[rementry].show; + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end end - - -- Faction is English to use as index NOT display - GOLD_INDEX = UnitName("player").."_"..realmName.."::"..UnitFactionGroup("Player"); end ---[[ --- ************************************************************************** --- NAME : TitanPanelGoldButton_OnShow() --- DESC : Create repeating timer when plugin is visible --- ************************************************************************** ---]] -function TitanPanelGoldButton_OnShow(self) - self:RegisterEvent("PLAYER_MONEY"); - if not GoldTimer and GoldSave and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then - GoldTimer = TitanGold:ScheduleRepeatingTimer(TitanPanelPluginHandle_OnUpdate, 1, updateTable) +local function DeleteMenuButtons(faction) + local info = {}; + local name = GetUnitName("player"); + local server = realmName; + for index, money in pairs(GoldSave) do + local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); + info.notCheckable = true + if character + and (char_faction == faction) + then + info.text = character.." - "..charserver; + info.value = character; + info.func = function() + local rementry = character.."_"..charserver.."::"..faction; + GoldSave[rementry] = nil; + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) + end + -- cannot delete current character + if name == character and server == charserver then + info.disabled = 1; + else + info.disabled = nil; + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end end end ---[[ --- ************************************************************************** --- NAME : TitanPanelGoldButton_OnHide() --- DESC : Destroy repeating timer when plugin is hidden --- ************************************************************************** ---]] -function TitanPanelGoldButton_OnHide(self) - self:UnregisterEvent("PLAYER_MONEY"); - TitanGold:CancelTimer(GoldTimer, true) - GoldTimer = nil; -end - ---[[ --- ************************************************************************** --- NAME : TitanGold_OnEvent() --- DESC : This section will grab the events registered to the add on and act on them --- ************************************************************************** ---]] -function TitanGold_OnEvent(self, event, ...) ---[[ -print("_OnEvent" -.." "..tostring(event).."" -) ---]] - if (event == "PLAYER_MONEY") then - if (GOLD_INITIALIZED) then - GoldSave[GOLD_INDEX].gold = GetMoney("player") - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) - end - return; +local function ShowProperLabels(chosen) + if chosen == "ShowCoinNone" then + TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", true); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", false); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", false); end - - if (event == "PLAYER_ENTERING_WORLD") then - if (not GOLD_INITIALIZED) then - TitanPanelGoldButton_Initialize_Array(self); - end - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) - return; + if chosen == "ShowCoinLabels" then + TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", false); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", true); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", false); + end + if chosen == "ShowCoinIcons" then + TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", false); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", false); + TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", true); end + TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end -local function GetToonInfo(info) - return info.name, info.realm, info.faction +local function Seperator(chosen) + if chosen == "UseSeperatorComma" then + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", true); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", false); + end + if chosen == "UseSeperatorPeriod" then + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", false); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", true); + end + TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end -local function GetIndexInfo(info) - local character, charserver, char_faction = string.match(info, '(.*)_(.*)::(.*)') - return character, charserver, char_faction +local function Merger(chosen) + if chosen == "MergeServers" then + TitanSetVar(TITAN_GOLD_ID, "MergeServers", true); + TitanSetVar(TITAN_GOLD_ID, "SeparateServers", false); + TitanSetVar(TITAN_GOLD_ID, "AllServers", false); + end + if chosen == "SeparateServers" then + TitanSetVar(TITAN_GOLD_ID, "MergeServers", false); + TitanSetVar(TITAN_GOLD_ID, "SeparateServers", true); + TitanSetVar(TITAN_GOLD_ID, "AllServers", false); + end + if chosen == "AllServers" then + TitanSetVar(TITAN_GOLD_ID, "MergeServers", false); + TitanSetVar(TITAN_GOLD_ID, "SeparateServers", false); + TitanSetVar(TITAN_GOLD_ID, "AllServers", true); + end + TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end --[[ -- ******************************************************************************************* --- NAME: TitanPanelGoldButton_GetTooltipText() --- DESC: Gets the tool-tip text, what appears when we hover over Gold on the Titan bar. +-- NAME: TitanPanelGoldGPH_Toggle() +-- DESC: This toggles if the player wants to see the gold/hour stats -- ******************************************************************************************* --]] -function TitanPanelGoldButton_GetTooltipText() - local GoldSaveSorted = {}; - local currentMoneyRichText = ""; - local final_text = "" - local countelements = 0; - local faction, faction_locale = UnitFactionGroup("Player") -- get localized faction - local ignore_faction = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction") - - for _ in pairs (realmNames) do - countelements = countelements + 1 +function TitanPanelGoldGPH_Toggle() + TitanToggleVar(TITAN_GOLD_ID, "DisplayGoldPerHour") + + if not GoldTimer and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then + GoldTimer = AceTimer:ScheduleRepeatingTimer(TitanPanelPluginHandle_OnUpdate, 1, updateTable) + elseif GoldTimer and not TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then + AceTimer:CancelTimer(GoldTimer) + GoldTimer = nil; end +end --- if countelements == 0 or TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then - -- The check for no connected realms was confusing so use the 'merge' format - -- if requested. - -- insert all keys from hash into the GoldSaveSorted array - - if TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then - -- Parse the database and display characters from this server - GoldSave[GOLD_INDEX].gold = GetMoney("player") - local coin_str = "" - local character, charserver = "", "" - local ttlgold = 0 - local show_labels = (TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels") - or TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons")) +local function DisplayOptions() - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - if (character) then - if (charserver == realmName) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end - end - end - end - elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then - -- Parse the database and display characters from merged / connected servers - for ms = 1, countelements do - local server = realmNames[ms] - GoldSave[GOLD_INDEX].gold = GetMoney("player") - local coin_str = "" - local character, charserver = "", "" - local char_faction = "" - local ttlgold = 0 - local show_labels = (TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels") - or TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons")) + local info = {}; + info.notCheckable = true + info.text = L["TITAN_GOLD_SORT_BY"]; + info.value = "Sorting"; + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - -- GetAutoCompleteRealms removes spaces, idk why... - if (charserver) then - charserver = string.gsub(charserver, "%s", ""); - end - - if (character) then - if (charserver == server) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end - end - end - end - end - elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then - -- Parse the database and display characters from all servers - GoldSave[GOLD_INDEX].gold = GetMoney("player") - local coin_str = "" - local character, charserver = "", "" - local char_faction = "" - local ttlgold = 0 - local show_labels = (TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels") - or TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons")) + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + -- Which characters to show + -- - Separate : this server + -- - Merge : connected / merged servers + -- - All : any server + local info = {}; + info.text = L["TITAN_GOLD_SEPARATE"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "SeparateServers"); + info.func = function() + Merger("SeparateServers") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetToonInfo(GoldSave[index]) - if (character) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end - end - end + local info = {}; + info.text = L["TITAN_GOLD_MERGE"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "MergeServers"); + info.func = function() + Merger("MergeServers") end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") - -- This section will sort the array based on user preference - -- * by name or by gold amount descending - -- * grouping by realm if selected - if TitanGetVar(TITAN_GOLD_ID, "SortByName") then - table.sort(GoldSaveSorted, function (key1, key2) - if by_realm then - if GoldSave[key1].realm ~= GoldSave[key2].realm then - return GoldSave[key1].realm < GoldSave[key2].realm - end - end - - return GoldSave[key1].name < GoldSave[key2].name - end) - else - table.sort(GoldSaveSorted, function (key1, key2) - if by_realm then - if GoldSave[key1].realm ~= GoldSave[key2].realm then - return GoldSave[key1].realm < GoldSave[key2].realm - end - end - - return GoldSave[key1].gold > GoldSave[key2].gold - end) + local info = {}; + info.text = L["TITAN_GOLD_ALL"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "AllServers"); + info.func = function() + Merger("AllServers") end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - -- Array holds all characters to display, nicely sorted. - currentMoneyRichText = "" - local coin_str = "" - local faction_text = "" - local curr_realm = "" - local show_dash = false - local show_realm = true - local character, charserver, char_faction - for i = 1, getn(GoldSaveSorted) do - character, charserver, char_faction = GetIndexInfo(GoldSaveSorted[i]) --GetToonInfo(GoldSave[GoldSaveSorted[i]]) - coin_str = NiceCash(GoldSave[GoldSaveSorted[i]].gold, false, false) - show_dash = false - show_realm = true + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - if (TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) then --- charserver = "" -- do not repeat the server on each line - show_realm = false - elseif (TitanGetVar(TITAN_GOLD_ID, "MergeServers")) then - show_dash = true --- charserver = "-"..charserver - elseif (TitanGetVar(TITAN_GOLD_ID, "AllServers")) then - show_dash = true - end + -- Option to ignore faction - per 9.2.5 changes + local info = {}; + info.text = L["TITAN_GOLD_IGNORE_FACTION"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction"); + info.func = function() + TitanToggleVar(TITAN_GOLD_ID, "IgnoreFaction"); + TitanPanelButton_UpdateButton(TITAN_GOLD_ID); + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - if by_realm then - -- Set a realm header - if charserver ~= curr_realm then - currentMoneyRichText = currentMoneyRichText.."\n" - .."-- "..charserver - curr_realm = charserver - end - show_dash = false --- charserver = "" -- do not repeat the server on each line - show_realm = false - end + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - if ignore_faction then - if char_faction == TITAN_ALLIANCE then - faction_text = "-".."|cff5b92e5" - ..GoldSave[GoldSaveSorted[i]].faction - .._G["FONT_COLOR_CODE_CLOSE"] - elseif char_faction == TITAN_HORDE then - faction_text = "-"..TitanUtils_GetHexText(GoldSave[GoldSaveSorted[i]].faction, "d42447") - end - end - - currentMoneyRichText = currentMoneyRichText.."\n" - ..character - ..(show_dash and "-" or "") - ..(show_realm and charserver or "") - ..faction_text - .."\t"..coin_str + -- What labels to show next to money none / text / icon + local info = {}; + info.text = L["TITAN_GOLD_COIN_NONE"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinNone"); + info.func = function() + ShowProperLabels("ShowCoinNone") end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); ---[[ -print("TG" -.." "..tostring(counter) -.." "..tostring(x0) -.." "..tostring(x1) -.." "..tostring(getn(GoldSaveSorted)) -.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) -.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "MergeServers")) -.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "AllServers")) -.." "..tostring(TITANPANEL_TOOLTIP) ---.." "..tostring(TITANPANEL_TOOLTIP_X) -) ---]] + local info = {}; + info.text = L["TITAN_GOLD_COIN_LABELS"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels"); + info.func = function() + ShowProperLabels("ShowCoinLabels") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - coin_str = "" - -- Display total gold - coin_str = NiceCash(TitanPanelGoldButton_TotalGold(), false, false) - currentMoneyRichText = currentMoneyRichText.."\n" - ..TITAN_GOLD_SPACERBAR.."\n" - ..L["TITAN_GOLD_TTL_GOLD"].."\t"..coin_str + local info = {}; + info.text = L["TITAN_GOLD_COIN_ICONS"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons"); + info.func = function() + ShowProperLabels("ShowCoinIcons") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - -- find session earnings and earning per hour - local sesstotal = GetMoney("player") - GOLD_STARTINGGOLD; - local negative = false; - if (sesstotal < 0) then - sesstotal = math.abs(sesstotal); - negative = true; + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + + -- Show gold only option - no silver, no copper + info = {}; + info.text = L["TITAN_GOLD_ONLY"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly"); + info.func = function() + TitanToggleVar(TITAN_GOLD_ID, "ShowGoldOnly"); + TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - local sesslength = GetTime() - GOLD_SESSIONSTART; - local perhour = math.floor(sesstotal / sesslength * 3600); + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - coin_str = NiceCash(GOLD_STARTINGGOLD, false, false) - - local sessionMoneyRichText = "" - if TitanGetVar(TITAN_GOLD_ID, "ShowSessionInfo") then - sessionMoneyRichText = "\n\n"..TitanUtils_GetHighlightText(L["TITAN_GOLD_STATS_TITLE"]) - .."\n"..L["TITAN_GOLD_START_GOLD"].."\t"..coin_str.."\n" + -- Use comma or period as separater on gold + local info = {}; + info.text = L["TITAN_PANEL_USE_COMMA"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma"); + info.func = function() + Seperator("UseSeperatorComma") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - if (negative) then - GOLD_COLOR = TITAN_GOLD_RED; - GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_LOST"]; - GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_LOST"]; - else - GOLD_COLOR = TITAN_GOLD_GREEN; - GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_EARNED"]; - GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_EARNED"]; - end + local info = {}; + info.text = L["TITAN_PANEL_USE_PERIOD"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod"); + info.func = function() + Seperator("UseSeperatorPeriod") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - coin_str = NiceCash(sesstotal, true, true) - -- ..TitanUtils_GetColoredText(GOLD_SESS_STATUS,GOLD_COLOR) - sessionMoneyRichText = sessionMoneyRichText - ..TitanUtils_GetColoredText(GOLD_SESS_STATUS,GOLD_COLOR) - .."\t"..coin_str.."\n"; + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - if TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then - coin_str = NiceCash(perhour, true, true) - sessionMoneyRichText = sessionMoneyRichText - ..TitanUtils_GetColoredText(GOLD_PERHOUR_STATUS,GOLD_COLOR) - .."\t"..coin_str.."\n"; - end - else - -- Do not display session info + -- Show session info + info = {}; + info.text = L["TITAN_GOLD_SHOW_STATS_TITLE"]; + info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowSessionInfo"); + info.func = function() + TitanToggleVar(TITAN_GOLD_ID, "ShowSessionInfo"); end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - local final_tooltip = TitanUtils_GetGoldText(L["TITAN_GOLD_TOOLTIPTEXT"].." : ") + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - local final_server = "" - if realmNames == nil or TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then - final_server = realmName - elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then - final_server = L["TITAN_GOLD_MERGED"] - elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then - final_server = ALL + -- Function to toggle gold per hour sort + info = {}; + info.text = L["TITAN_GOLD_TOGGLE_GPH_SHOW"] + info.checked = TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour"); + info.func = function() + TitanPanelGoldGPH_Toggle() end - final_server = TitanUtils_GetGoldText(final_server.." : ") - - local final_faction = "" - if ignore_faction then - final_faction = TitanUtils_GetGoldText(ALL) - elseif faction == TITAN_ALLIANCE then - final_faction = "|cff5b92e5"..FACTION_ALLIANCE.._G["FONT_COLOR_CODE_CLOSE"] --- final_faction = TitanUtils_GetGreenText(FACTION_ALLIANCE) - -- "|cff0000ff"..text.._G["FONT_COLOR_CODE_CLOSE"] - elseif faction == TITAN_HORDE then - final_faction = TitanUtils_GetRedText(FACTION_HORDE) - end - - return "" - ..currentMoneyRichText.."\n" - ..TITAN_GOLD_SPACERBAR.."\n" - ..final_tooltip..final_server..final_faction.."\n" - ..sessionMoneyRichText -end - ---[[ --- ******************************************************************************************* --- NAME: TitanPanelGoldButton_FindGold() --- DESC: This routines determines which gold total the ui wants (server or player) then calls it and returns it --- ******************************************************************************************* ---]] -function TitanPanelGoldButton_FindGold() - if (not GOLD_INITIALIZED) then - -- in case there is no db entry for this toon, return blank. - -- When Gold is ready it will init - return "" - end - - local ret_str = "" - local ttlgold = 0; - - GoldSave[GOLD_INDEX].gold = GetMoney("player") - - if TitanGetVar(TITAN_GOLD_ID, "ViewAll") then - ttlgold = TitanPanelGoldButton_TotalGold() - else - ttlgold = GetMoney("player"); - end - - ret_str = NiceCash(ttlgold, true, false) - - return L["TITAN_GOLD_MENU_TEXT"]..": "..FONT_COLOR_CODE_CLOSE, ret_str -end - -local function ToonAdd(show, amount, total) - local new_total = 0 + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + +end + +local function ToonAdd(show, amount, total) + local new_total = 0 if show then new_total = total + amount @@ -609,11 +442,11 @@ end --[[ -- ******************************************************************************************* --- NAME: TitanPanelGoldButton_TotalGold() +-- NAME: TotalGold() -- DESC: Calculates total gold for display per user selections -- ******************************************************************************************* --]] -function TitanPanelGoldButton_TotalGold() +local function TotalGold() local ttlgold = 0; local cnt = 0; local countelements = 0; @@ -629,7 +462,7 @@ function TitanPanelGoldButton_TotalGold() if TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then -- Parse the database and display all characters on this server - GoldSave[GOLD_INDEX].gold = GetMoney("player") + GoldSave[GOLD_INDEX].gold = GetMoney() for index, money in pairs(GoldSave) do character, charserver, char_faction = GetIndexInfo(index) @@ -646,7 +479,7 @@ function TitanPanelGoldButton_TotalGold() elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then -- Parse the database and display characters on merged / connected servers for ms = 1, countelements do - GoldSave[GOLD_INDEX].gold = GetMoney("player") + GoldSave[GOLD_INDEX].gold = GetMoney() for index, money in pairs(GoldSave) do character, charserver, char_faction = GetIndexInfo(index) @@ -668,7 +501,7 @@ function TitanPanelGoldButton_TotalGold() end elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then -- Parse the database and display characters on all servers - GoldSave[GOLD_INDEX].gold = GetMoney("player") + GoldSave[GOLD_INDEX].gold = GetMoney() for index, money in pairs(GoldSave) do character, charserver, char_faction = GetIndexInfo(index) @@ -687,266 +520,411 @@ function TitanPanelGoldButton_TotalGold() return ttlgold; end -local function ShowMenuButtons(faction) - local info = {}; - local name = GetUnitName("player"); - local server = realmName; - for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); - if character - and (char_faction == faction) - then - info.text = character.." - "..charserver; - info.value = character; - info.keepShownOnClick = true; - info.checked = function() - local rementry = character.."_"..charserver.."::"..faction; - return GoldSave[rementry].show - end - info.func = function() - local rementry = character.."_"..charserver.."::"..faction; - GoldSave[rementry].show = not GoldSave[rementry].show; - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - end +-- ====== Tool tip routines +local function GetToonInfo(info) + return info.name, info.realm, info.faction end -local function DeleteMenuButtons(faction) - local info = {}; - local name = GetUnitName("player"); - local server = realmName; - for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); - info.notCheckable = true - if character - and (char_faction == faction) - then - info.text = character.." - "..charserver; - info.value = character; - info.func = function() - local rementry = character.."_"..charserver.."::"..faction; - GoldSave[rementry] = nil; - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) +--[[ +-- ******************************************************************************************* +-- NAME: GetTooltipText() +-- DESC: Gets the tool-tip text, what appears when we hover over Gold on the Titan bar. +-- ******************************************************************************************* +--]] +local function GetTooltipText() + local GoldSaveSorted = {}; + local currentMoneyRichText = ""; + local countelements = 0; + local faction, faction_locale = UnitFactionGroup("Player") -- get localized faction + local ignore_faction = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction") + + for _ in pairs (realmNames) do + countelements = countelements + 1 + end + +-- if countelements == 0 or TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then + -- The check for no connected realms was confusing so use the 'merge' format + -- if requested. + -- insert all keys from hash into the GoldSaveSorted array + + if TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then + -- Parse the database and display characters from this server + GoldSave[GOLD_INDEX].gold = GetMoney() + local char_faction = "" + local character, charserver = "", "" + + for index, money in pairs(GoldSave) do + character, charserver, char_faction = GetIndexInfo(index) + if (character) then + if (charserver == realmName) then + if ignore_faction or (char_faction == faction) then + if GoldSave[index].show then + table.insert(GoldSaveSorted, index); + end + end + end end - -- cannot delete current character - if name == character and server == charserver then - info.disabled = 1; - else - info.disabled = nil; + end + elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then + -- Parse the database and display characters from merged / connected servers + for ms = 1, countelements do + local server = realmNames[ms] + GoldSave[GOLD_INDEX].gold = GetMoney() + local character, charserver = "", "" + local char_faction = "" + + for index, money in pairs(GoldSave) do + character, charserver, char_faction = GetIndexInfo(index) + -- GetAutoCompleteRealms removes spaces, idk why... + if (charserver) then + charserver = string.gsub(charserver, "%s", ""); + end + + if (character) then + if (charserver == server) then + if ignore_faction or (char_faction == faction) then + if GoldSave[index].show then + table.insert(GoldSaveSorted, index); + end + end + end + end end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end - end -end + elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then + -- Parse the database and display characters from all servers + GoldSave[GOLD_INDEX].gold = GetMoney() + local character, charserver = "", "" + local char_faction = "" -local function ShowProperLabels(chosen) - if chosen == "ShowCoinNone" then - TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", true); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", false); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", false); - end - if chosen == "ShowCoinLabels" then - TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", false); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", true); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", false); - end - if chosen == "ShowCoinIcons" then - TitanSetVar(TITAN_GOLD_ID, "ShowCoinNone", false); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinLabels", false); - TitanSetVar(TITAN_GOLD_ID, "ShowCoinIcons", true); + for index, money in pairs(GoldSave) do + character, charserver, char_faction = GetToonInfo(GoldSave[index]) + if (character) then + if ignore_faction or (char_faction == faction) then + if GoldSave[index].show then + table.insert(GoldSaveSorted, index); + end + end + end + end end - TitanPanelButton_UpdateButton(TITAN_GOLD_ID); -end -local function Seperator(chosen) + local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") + -- This section will sort the array based on user preference + -- * by name or by gold amount descending + -- * grouping by realm if selected + if TitanGetVar(TITAN_GOLD_ID, "SortByName") then + table.sort(GoldSaveSorted, function (key1, key2) + if by_realm then + if GoldSave[key1].realm ~= GoldSave[key2].realm then + return GoldSave[key1].realm < GoldSave[key2].realm + end + end ---TitanDebug("Seperator: "..(chosen or "?").." ") + return GoldSave[key1].name < GoldSave[key2].name + end) + else + table.sort(GoldSaveSorted, function (key1, key2) + if by_realm then + if GoldSave[key1].realm ~= GoldSave[key2].realm then + return GoldSave[key1].realm < GoldSave[key2].realm + end + end - if chosen == "UseSeperatorComma" then - TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", true); - TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", false); - end - if chosen == "UseSeperatorPeriod" then - TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", false); - TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", true); + return GoldSave[key1].gold > GoldSave[key2].gold + end) end - TitanPanelButton_UpdateButton(TITAN_GOLD_ID); -end -local function Merger(chosen) + -- Array holds all characters to display, nicely sorted. + currentMoneyRichText = "" + local coin_str = "" + local faction_text = "" + local curr_realm = "" + local show_dash = false + local show_realm = true + local character, charserver, char_faction + for i = 1, getn(GoldSaveSorted) do + character, charserver, char_faction = GetIndexInfo(GoldSaveSorted[i]) --GetToonInfo(GoldSave[GoldSaveSorted[i]]) + coin_str = NiceCash(GoldSave[GoldSaveSorted[i]].gold, false, false) + show_dash = false + show_realm = true ---TitanDebug("Merge: "..(chosen or "?").." ") + if (TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) then +-- charserver = "" -- do not repeat the server on each line + show_realm = false + elseif (TitanGetVar(TITAN_GOLD_ID, "MergeServers")) then + show_dash = true +-- charserver = "-"..charserver + elseif (TitanGetVar(TITAN_GOLD_ID, "AllServers")) then + show_dash = true + end - if chosen == "MergeServers" then - TitanSetVar(TITAN_GOLD_ID, "MergeServers", true); - TitanSetVar(TITAN_GOLD_ID, "SeparateServers", false); - TitanSetVar(TITAN_GOLD_ID, "AllServers", false); - end - if chosen == "SeparateServers" then - TitanSetVar(TITAN_GOLD_ID, "MergeServers", false); - TitanSetVar(TITAN_GOLD_ID, "SeparateServers", true); - TitanSetVar(TITAN_GOLD_ID, "AllServers", false); - end - if chosen == "AllServers" then - TitanSetVar(TITAN_GOLD_ID, "MergeServers", false); - TitanSetVar(TITAN_GOLD_ID, "SeparateServers", false); - TitanSetVar(TITAN_GOLD_ID, "AllServers", true); - end - TitanPanelButton_UpdateButton(TITAN_GOLD_ID); -end + if by_realm then + -- Set a realm header + if charserver ~= curr_realm then + currentMoneyRichText = currentMoneyRichText.."\n" + .."-- "..charserver + curr_realm = charserver + end + show_dash = false +-- charserver = "" -- do not repeat the server on each line + show_realm = false + end -local function DisplayOptions() + if ignore_faction then + if char_faction == TITAN_ALLIANCE then + faction_text = "-".."|cff5b92e5" + ..GoldSave[GoldSaveSorted[i]].faction + .._G["FONT_COLOR_CODE_CLOSE"] + elseif char_faction == TITAN_HORDE then + faction_text = "-"..TitanUtils_GetHexText(GoldSave[GoldSaveSorted[i]].faction, "d42447") + end + end + + currentMoneyRichText = currentMoneyRichText.."\n" + ..character + ..(show_dash and "-" or "") + ..(show_realm and charserver or "") + ..faction_text + .."\t"..coin_str + end - info = {}; - info.notCheckable = true - info.text = L["TITAN_GOLD_SORT_BY"]; - info.value = "Sorting"; - info.hasArrow = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +--[[ +print("TG" +.." "..tostring(counter) +.." "..tostring(x0) +.." "..tostring(x1) +.." "..tostring(getn(GoldSaveSorted)) +.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) +.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "MergeServers")) +.." "..tostring(TitanGetVar(TITAN_GOLD_ID, "AllServers")) +.." "..tostring(TITANPANEL_TOOLTIP) +--.." "..tostring(TITANPANEL_TOOLTIP_X) +) +--]] - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + coin_str = "" + -- Display total gold + coin_str = NiceCash(TotalGold(), false, false) + currentMoneyRichText = currentMoneyRichText.."\n" + ..TITAN_GOLD_SPACERBAR.."\n" + ..L["TITAN_GOLD_TTL_GOLD"].."\t"..coin_str - -- Which characters to show - -- - Separate : this server - -- - Merge : connected / merged servers - -- - All : any server - local info = {}; - info.text = L["TITAN_GOLD_SEPARATE"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "SeparateServers"); - info.func = function() - Merger("SeparateServers") + -- find session earnings and earning per hour + local sesstotal = GetMoney() - GOLD_STARTINGGOLD; + local negative = false; + if (sesstotal < 0) then + sesstotal = math.abs(sesstotal); + negative = true; end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - local info = {}; - info.text = L["TITAN_GOLD_MERGE"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "MergeServers"); - info.func = function() - Merger("MergeServers") - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + local sesslength = GetTime() - GOLD_SESSIONSTART; + local perhour = math.floor(sesstotal / sesslength * 3600); - local info = {}; - info.text = L["TITAN_GOLD_ALL"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "AllServers"); - info.func = function() - Merger("AllServers") - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + coin_str = NiceCash(GOLD_STARTINGGOLD, false, false) + + local sessionMoneyRichText = "" + if TitanGetVar(TITAN_GOLD_ID, "ShowSessionInfo") then + sessionMoneyRichText = "\n\n"..TitanUtils_GetHighlightText(L["TITAN_GOLD_STATS_TITLE"]) + .."\n"..L["TITAN_GOLD_START_GOLD"].."\t"..coin_str.."\n" - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + if (negative) then + GOLD_COLOR = TITAN_GOLD_RED; + GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_LOST"]; + GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_LOST"]; + else + GOLD_COLOR = TITAN_GOLD_GREEN; + GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_EARNED"]; + GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_EARNED"]; + end - -- Option to ignore faction - per 9.2.5 changes - local info = {}; - info.text = L["TITAN_GOLD_IGNORE_FACTION"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction"); - info.func = function() - TitanToggleVar(TITAN_GOLD_ID, "IgnoreFaction"); - TitanPanelButton_UpdateButton(TITAN_GOLD_ID); + coin_str = NiceCash(sesstotal, true, true) + -- ..TitanUtils_GetColoredText(GOLD_SESS_STATUS,GOLD_COLOR) + sessionMoneyRichText = sessionMoneyRichText + ..TitanUtils_GetColoredText(GOLD_SESS_STATUS,GOLD_COLOR) + .."\t"..coin_str.."\n"; + + if TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then + coin_str = NiceCash(perhour, true, true) + sessionMoneyRichText = sessionMoneyRichText + ..TitanUtils_GetColoredText(GOLD_PERHOUR_STATUS,GOLD_COLOR) + .."\t"..coin_str.."\n"; + end + else + -- Do not display session info end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + local final_tooltip = TitanUtils_GetGoldText(L["TITAN_GOLD_TOOLTIPTEXT"].." : ") - -- What labels to show next to money none / text / icon - local info = {}; - info.text = L["TITAN_GOLD_COIN_NONE"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinNone"); - info.func = function() - ShowProperLabels("ShowCoinNone") + local final_server = "" + if realmNames == nil or TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then + final_server = realmName + elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then + final_server = L["TITAN_GOLD_MERGED"] + elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then + final_server = ALL end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - local info = {}; - info.text = L["TITAN_GOLD_COIN_LABELS"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels"); - info.func = function() - ShowProperLabels("ShowCoinLabels") + final_server = TitanUtils_GetGoldText(final_server.." : ") + + local final_faction = "" + if ignore_faction then + final_faction = TitanUtils_GetGoldText(ALL) + elseif faction == TITAN_ALLIANCE then + final_faction = "|cff5b92e5"..FACTION_ALLIANCE.._G["FONT_COLOR_CODE_CLOSE"] +-- final_faction = TitanUtils_GetGreenText(FACTION_ALLIANCE) + -- "|cff0000ff"..text.._G["FONT_COLOR_CODE_CLOSE"] + elseif faction == TITAN_HORDE then + final_faction = TitanUtils_GetRedText(FACTION_HORDE) end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + return "" + ..currentMoneyRichText.."\n" + ..TITAN_GOLD_SPACERBAR.."\n" + ..final_tooltip..final_server..final_faction.."\n" + ..sessionMoneyRichText +end +-- ====== - local info = {}; - info.text = L["TITAN_GOLD_COIN_ICONS"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons"); - info.func = function() - ShowProperLabels("ShowCoinIcons") - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +-- ====== Right click menu routines +--[[ +-- ******************************************************************************************* +-- NAME: ViewAll_Toggle() +-- DESC: This toggles whether or not the player wants to view total gold on the button, or player gold. +-- ******************************************************************************************* +--]] +local function ViewAll_Toggle() + TitanToggleVar(TITAN_GOLD_ID, "ViewAll") + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) +end - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); +--[[ +-- ******************************************************************************************* +-- NAME: Sort_Toggle() +-- DESC: This toggles how the player wants the display to be sorted - by name or gold amount +-- ******************************************************************************************* +--]] +local function Sort_Toggle() + TitanToggleVar(TITAN_GOLD_ID, "SortByName") +end - -- Show gold only option - no silver, no copper - info = {}; - info.text = L["TITAN_GOLD_ONLY"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly"); - info.func = function() - TitanToggleVar(TITAN_GOLD_ID, "ShowGoldOnly"); - TitanPanelButton_UpdateButton(TITAN_GOLD_ID); - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +--[[ +-- ******************************************************************************************* +-- NAME: ResetSession() +-- DESC: Resets the current session +-- ******************************************************************************************* +--]] +local function ResetSession() + GOLD_STARTINGGOLD = GetMoney(); + GOLD_SESSIONSTART = GetTime(); + DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_SESSION_RESET"])); +end - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); +--[[ +-- ************************************************************************** +-- NAME : Initialize_Array() +-- DESC : Build the gold array for the server/faction +-- ************************************************************************** +--]] +local function Initialize_Array(self) + if (GOLD_INITIALIZED) then return; end - -- Use comma or period as separater on gold - local info = {}; - info.text = L["TITAN_PANEL_USE_COMMA"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma"); - info.func = function() - Seperator("UseSeperatorComma") - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + self:UnregisterEvent("VARIABLES_LOADED"); - local info = {}; - info.text = L["TITAN_PANEL_USE_PERIOD"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod"); - info.func = function() - Seperator("UseSeperatorPeriod") + -- See if this is a new to toon to Gold + if (GoldSave[GOLD_INDEX] == nil) then + GoldSave[GOLD_INDEX] = {} + GoldSave[GOLD_INDEX] = {gold = GetMoney(), name = UnitName("player")} + end + + -- Ensure the saved vars are usable + for index, money in pairs(GoldSave) do + local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, '(.*)_(.*)::(.*)') + + -- Could be a new toon to Gold or an updated Gold + local show_toon = GoldSave[index].show + if show_toon == nil then + show_toon = true + end + GoldSave[index].show = show_toon + GoldSave[index].realm = charserver -- added July 2022 + + -- added Aug 2022 for #1332. + -- Faction in index was not set for display in tool tip. + -- Created localized faction as a field; set every time in case user changes languages + if char_faction == TITAN_ALLIANCE then + GoldSave[index].faction = FACTION_ALLIANCE + elseif char_faction == TITAN_HORDE then + GoldSave[index].faction = FACTION_HORDE + else + GoldSave[index].faction = FACTION_OTHER + end +--[[ + if character == UnitName("player") and charserver == realmName then + local rementry = character.."_"..charserver.."::"..UnitFactionGroup("Player"); + local showCharacter = GoldSave[rementry].show + if showCharacter == nil then showCharacter = true end + GoldSave[GOLD_INDEX] = {gold = GetMoney("player"), show = showCharacter, name = UnitName("player")} + end +--]] end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + GOLD_STARTINGGOLD = GetMoney(); + GOLD_SESSIONSTART = GetTime(); + GOLD_INITIALIZED = true; - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + -- AFTER we say init is done or we'll never show the gold! + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) +end - -- Show session info - info = {}; - info.text = L["TITAN_GOLD_SHOW_STATS_TITLE"]; - info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowSessionInfo"); - info.func = function() - TitanToggleVar(TITAN_GOLD_ID, "ShowSessionInfo"); - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +--[[ +-- ************************************************************************** +-- NAME : ClearData() +-- DESC : This will allow the user to clear all the data and rebuild the array +-- ************************************************************************** +--]] +local function ClearData(self) + GOLD_INITIALIZED = false; - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + GoldSave = {}; + Initialize_Array(self); - -- Function to toggle gold per hour sort - info = {}; - info.text = L["TITAN_GOLD_TOGGLE_GPH_SHOW"] - info.checked = TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour"); - info.func = function() - TitanPanelGoldGPH_Toggle() - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_DB_CLEARED"])); +end +local function TitanGold_ClearDB() + StaticPopupDialogs["TITANGOLD_CLEAR_DATABASE"] = { + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"].." " + ..L["TITAN_GOLD_MENU_TEXT"]).."\n\n"..L["TITAN_GOLD_CLEAR_DATA_WARNING"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) + local frame = _G["TitanPanelGoldButton"] + ClearData(frame) + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITANGOLD_CLEAR_DATABASE"); end --[[ -- ******************************************************************************************* --- NAME: TitanPanelRightClickMenu_PrepareGoldMenu +-- NAME: CreateMenu -- DESC: Builds the right click config menu -- ******************************************************************************************* --]] -function TitanPanelRightClickMenu_PrepareGoldMenu() +local function CreateMenu() if TitanPanelRightClickMenu_GetDropdownLevel() == 1 then -- Menu title TitanPanelRightClickMenu_AddTitle(L["TITAN_GOLD_ITEMNAME"]); -- Function to toggle button gold view - info = {}; + local info = {}; info.text = L["TITAN_GOLD_TOGGLE_ALL_TEXT"] info.checked = TitanGetVar(TITAN_GOLD_ID, "ViewAll"); info.func = function() - TitanPanelGoldButton_Toggle() + ViewAll_Toggle() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -954,16 +932,9 @@ function TitanPanelRightClickMenu_PrepareGoldMenu() info.text = L["TITAN_GOLD_TOGGLE_PLAYER_TEXT"] info.checked = not TitanGetVar(TITAN_GOLD_ID, "ViewAll"); info.func = function() - TitanPanelGoldButton_Toggle() + ViewAll_Toggle() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); ---[[ - if TitanGetVar(TITAN_GOLD_ID, "ViewAll") then - TitanPanelRightClickMenu_AddCommand(L["TITAN_GOLD_TOGGLE_PLAYER_TEXT"], TITAN_GOLD_ID,"TitanPanelGoldButton_Toggle"); - else - TitanPanelRightClickMenu_AddCommand(L["TITAN_GOLD_TOGGLE_ALL_TEXT"], TITAN_GOLD_ID,"TitanPanelGoldButton_Toggle"); - end ---]] TitanPanelRightClickMenu_AddSeparator(); -- Display options @@ -1000,7 +971,7 @@ function TitanPanelRightClickMenu_PrepareGoldMenu() info.func = TitanGold_ClearDB; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - TitanPanelRightClickMenu_AddCommand(L["TITAN_GOLD_RESET_SESS_TEXT"], TITAN_GOLD_ID, "TitanPanelGoldButton_ResetSession"); + TitanPanelRightClickMenu_AddCommand(L["TITAN_GOLD_RESET_SESS_TEXT"], TITAN_GOLD_ID, ResetSession); TitanPanelRightClickMenu_AddControlVars(TITAN_GOLD_ID) end @@ -1039,7 +1010,7 @@ function TitanPanelRightClickMenu_PrepareGoldMenu() info.text = L["TITAN_GOLD_TOGGLE_SORT_GOLD"] info.checked = not TitanGetVar(TITAN_GOLD_ID, "SortByName"); info.func = function() - TitanPanelGoldSort_Toggle() + Sort_Toggle() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -1047,7 +1018,7 @@ function TitanPanelRightClickMenu_PrepareGoldMenu() info.text = L["TITAN_GOLD_TOGGLE_SORT_NAME"] info.checked = TitanGetVar(TITAN_GOLD_ID, "SortByName"); info.func = function() - TitanPanelGoldSort_Toggle() + Sort_Toggle() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -1078,145 +1049,155 @@ function TitanPanelRightClickMenu_PrepareGoldMenu() end --[[ --- ************************************************************************** --- NAME : TitanPanelGoldButton_ClearData() --- DESC : This will allow the user to clear all the data and rebuild the array --- ************************************************************************** +-- ******************************************************************************************* +-- NAME: FindGold() +-- DESC: This routines determines which gold total the ui wants (server or player) then calls it and returns it +-- ******************************************************************************************* --]] -function TitanPanelGoldButton_ClearData(self) - GOLD_INITIALIZED = false; +local function FindGold() + if (not GOLD_INITIALIZED) then + -- in case there is no db entry for this toon, return blank. + -- When Gold is ready it will init + return "" + end - GoldSave = {}; - TitanPanelGoldButton_Initialize_Array(self); + local ret_str = "" + local ttlgold = 0; - DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_DB_CLEARED"])); + GoldSave[GOLD_INDEX].gold = GetMoney() + + if TitanGetVar(TITAN_GOLD_ID, "ViewAll") then + ttlgold = TotalGold() + else + ttlgold = GetMoney(); + end + + ret_str = NiceCash(ttlgold, true, false) + + return L["TITAN_GOLD_MENU_TEXT"]..": "..FONT_COLOR_CODE_CLOSE, ret_str end --[[ -- ************************************************************************** --- NAME : TitanPanelGoldButton_Initialize_Array() --- DESC : Build the gold array for the server/faction +-- NAME : OnLoad() +-- DESC : Registers the add on upon it loading -- ************************************************************************** --]] -function TitanPanelGoldButton_Initialize_Array(self) - if (GOLD_INITIALIZED) then return; end +local function OnLoad(self) + local notes = "" + .."Keeps track of all gold held by a player's toons.\n" + .."- Can show by server / merged servers / all servers.\n" + .."- Can show by faction.\n" + self.registry = { + id = TITAN_GOLD_ID, + category = "Built-ins", + version = TITAN_GOLD_VERSION, + menuText = L["TITAN_GOLD_MENU_TEXT"], + menuTextFunction = CreateMenu, + tooltipTitle = L["TITAN_GOLD_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + buttonTextFunction = FindGold, + icon = "Interface\\AddOns\\TitanGold\\Artwork\\TitanGold", + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = false, + DisplayOnRightSide = true, + }, + savedVariables = { + Initialized = true, + DisplayGoldPerHour = true, + ShowCoinNone = false, + ShowCoinLabels = true, + ShowCoinIcons = false, + ShowGoldOnly = false, + SortByName = true, + ViewAll = true, + ShowIcon = true, + ShowLabelText = false, + ShowColoredText = true, + DisplayOnRightSide = false, + UseSeperatorComma = true, + UseSeperatorPeriod = false, + MergeServers = false, + SeparateServers = true, + AllServers = false, + IgnoreFaction = false, + GroupByRealm = false, + gold = { total = "112233", neg = false }, + ShowSessionInfo = true + } + }; - self:UnregisterEvent("VARIABLES_LOADED"); + self:RegisterEvent("PLAYER_ENTERING_WORLD"); - -- See if this is a new to toon to Gold - if (GoldSave[GOLD_INDEX] == nil) then - GoldSave[GOLD_INDEX] = {} - GoldSave[GOLD_INDEX] = {gold = GetMoney("player"), name = UnitName("player")} + if (not GoldSave) then + GoldSave={}; end - -- Ensure the saved vars are usable - for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, '(.*)_(.*)::(.*)') - - -- Could be a new toon to Gold or an updated Gold - local show_toon = GoldSave[index].show - if show_toon == nil then - show_toon = true - end - GoldSave[index].show = show_toon - GoldSave[index].realm = charserver -- added July 2022 - - -- added Aug 2022 for #1332. - -- Faction in index was not set for display in tool tip. - -- Created localized faction as a field; set every time in case user changes languages - if char_faction == TITAN_ALLIANCE then - GoldSave[index].faction = FACTION_ALLIANCE - elseif char_faction == TITAN_HORDE then - GoldSave[index].faction = FACTION_HORDE - else - GoldSave[index].faction = FACTION_OTHER - end ---[[ - if character == UnitName("player") and charserver == realmName then - local rementry = character.."_"..charserver.."::"..UnitFactionGroup("Player"); - local showCharacter = GoldSave[rementry].show - if showCharacter == nil then showCharacter = true end - GoldSave[GOLD_INDEX] = {gold = GetMoney("player"), show = showCharacter, name = UnitName("player")} - end ---]] - end - GOLD_STARTINGGOLD = GetMoney("player"); - GOLD_SESSIONSTART = GetTime(); - GOLD_INITIALIZED = true; - - -- AFTER we say init is done or we'll never show the gold! - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) + -- Faction is English to use as index NOT display + GOLD_INDEX = UnitName("player").."_"..realmName.."::"..UnitFactionGroup("Player"); end --[[ --- ******************************************************************************************* --- NAME: TitanPanelGoldButton_Toggle() --- DESC: This toggles whether or not the player wants to view total gold on the button, or player gold. --- ******************************************************************************************* +-- ************************************************************************** +-- NAME : OnShow() +-- DESC : Create repeating timer when plugin is visible +-- ************************************************************************** --]] -function TitanPanelGoldButton_Toggle() - TitanToggleVar(TITAN_GOLD_ID, "ViewAll") - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) +local function OnShow(self) + self:RegisterEvent("PLAYER_MONEY"); + if GoldTimer == {} and GoldSave and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then + GoldTimer = AceTimer:ScheduleRepeatingTimer(TitanPanelPluginHandle_OnUpdate, 1, updateTable) + else + -- timer running or user does not want gold per hour + end end --[[ --- ******************************************************************************************* --- NAME: TitanPanelGoldSort_Toggle() --- DESC: This toggles how the player wants the display to be sorted - by name or gold amount --- ******************************************************************************************* +-- ************************************************************************** +-- NAME : OnHide() +-- DESC : Destroy repeating timer when plugin is hidden +-- ************************************************************************** --]] -function TitanPanelGoldSort_Toggle() - TitanToggleVar(TITAN_GOLD_ID, "SortByName") +local function OnHide(self) + self:UnregisterEvent("PLAYER_MONEY"); + AceTimer:CancelTimer(GoldTimer) + GoldTimer = {}; end --[[ --- ******************************************************************************************* --- NAME: TitanPanelGoldGPH_Toggle() --- DESC: This toggles if the player wants to see the gold/hour stats --- ******************************************************************************************* +-- ************************************************************************** +-- NAME : OnEvent() +-- DESC : This section will grab the events registered to the add on and act on them +-- ************************************************************************** --]] -function TitanPanelGoldGPH_Toggle() - TitanToggleVar(TITAN_GOLD_ID, "DisplayGoldPerHour") - - if not GoldTimer and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then - GoldTimer = TitanGold:ScheduleRepeatingTimer(TitanPanelPluginHandle_OnUpdate, 1, updateTable) - elseif GoldTimer and not TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then - TitanGold:CancelTimer(GoldTimer, true) - GoldTimer = nil; - end -end - +local function OnEvent(self, event, ...) --[[ --- ******************************************************************************************* --- NAME: TitanPanelGoldButton_ResetSession() --- DESC: Resets the current session --- ******************************************************************************************* +print("_OnEvent" +.." "..tostring(event).."" +) --]] -function TitanPanelGoldButton_ResetSession() - GOLD_STARTINGGOLD = GetMoney("player"); - GOLD_SESSIONSTART = GetTime(); - DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_SESSION_RESET"])); -end + if (event == "PLAYER_MONEY") then + if (GOLD_INITIALIZED) then + GoldSave[GOLD_INDEX].gold = GetMoney() + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) + end + return; + end -function TitanGold_ClearDB() - StaticPopupDialogs["TITANGOLD_CLEAR_DATABASE"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"].." " - ..L["TITAN_GOLD_MENU_TEXT"]).."\n\n"..L["TITAN_GOLD_CLEAR_DATA_WARNING"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - local frame = _G["TitanPanelGoldButton"] - TitanPanelGoldButton_ClearData(frame) - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITANGOLD_CLEAR_DATABASE"); + if (event == "PLAYER_ENTERING_WORLD") then + if (not GOLD_INITIALIZED) then + Initialize_Array(self); + end + TitanPanelButton_UpdateButton(TITAN_GOLD_ID) + return; + end end --- ====== Create needed frames local function Create_Frames() if _G[TITAN_BUTTON] then return -- if already created @@ -1230,18 +1211,18 @@ local function Create_Frames() local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelComboTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelGoldButton_OnLoad(window); + OnLoad(window); -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... window:SetScript("OnShow", function(self) - TitanPanelGoldButton_OnShow(self); + OnShow(self); TitanPanelButton_OnShow(self); end) window:SetScript("OnHide", function(self) - TitanPanelGoldButton_OnHide(self); + OnHide(self); end) window:SetScript("OnEvent", function(self, event, ...) - TitanGold_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) end diff --git a/TitanGold/TitanGold_Mainline.toc b/TitanGold/TitanGold_Mainline.toc index a501f2f..d474dc5 100644 --- a/TitanGold/TitanGold_Mainline.toc +++ b/TitanGold/TitanGold_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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 diff --git a/TitanGold/TitanGold_Vanilla.toc b/TitanGold/TitanGold_Vanilla.toc index 5de2c77..0108636 100644 --- a/TitanGold/TitanGold_Vanilla.toc +++ b/TitanGold/TitanGold_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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 diff --git a/TitanGold/TitanGold_Wrath.toc b/TitanGold/TitanGold_Wrath.toc index d197acb..472e6e9 100644 --- a/TitanGold/TitanGold_Wrath.toc +++ b/TitanGold/TitanGold_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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 diff --git a/TitanLDB/Artwork/Starter.tga b/TitanLDB/Artwork/Starter.tga new file mode 100644 index 0000000..6a7ddda Binary files /dev/null and b/TitanLDB/Artwork/Starter.tga differ diff --git a/TitanLDB/Starter.tga b/TitanLDB/Starter.tga new file mode 100644 index 0000000..6a7ddda Binary files /dev/null and b/TitanLDB/Starter.tga differ diff --git a/TitanLDB/StarterLDB.lua b/TitanLDB/StarterLDB.lua new file mode 100644 index 0000000..6924bdb --- /dev/null +++ b/TitanLDB/StarterLDB.lua @@ -0,0 +1,299 @@ +--[[ +StarterLDB.lua +This is a simplistic example of a LDB (LibDataBroker) Addon. +It is assumed that you understand the Blizzard addon basics. +It is based loosely on the Titan Bag addon but is not Titan specific. + +It is not required that a display addon exist for your addon to run; Such as Titan :-) +However your addon will need to enable command line commands or the user will not be able to see or do anything. + +If running this example, it shows up in the Titan right click menu > General > LDBStarter + +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example to just run this as is, remove the 'Example' from the folder name then start or reload WoW. +This is explained in more detail below in 'Folder Structure'. + +Enjoy! +By: The Titan Development Team +--]] + +--[[ Folder Structure +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example, to just run this as is, remove the 'Example' from the folder name then start or reload WoW. +This is explained in more detail below. + + +This plugin folder must be added to the Addon folder to be considered for loading into WoW. +Inside this folder you will notice : +- three .toc files +- one .lua file +- one .tga file. + +There are sites (wowhead or wow wiki as examples) that have deeper explainations on addon development. +Please use these sites for more general addon information. + +=== .toc +The folder and the .toc files MUST have the same name! +Sort of... the name prior to the underscore(_) must be the same. The name after that (postfix) has meaning to WoW. +WoW has three versions represented by the three postix values. +_Mainline : current retail version +_Wrath : Wrath of the Lich King version. +_Vanilla : Classic Era version +These values may change as the versions evolve, say Cata is added to Wrath. +Or they may not :). Years from now we may wonder why Wrath represents Dragonflight! + +If your plugin is only for Classic Era then delete or rename the 'mainline' and 'wrath' .toc files. +Changing the filename will prevent WoW from loading the addon into that version of the game. + +Titan uses this method. Notice Titan folder has no 'wrath' or 'vanilla' .toc. +TitanClassic has has both 'wrath' and 'vanilla' .toc but no 'mainline' .toc. +This allows Titan plugins intended for Classic versions to run without change. + +NOTE: The ## Interface value should match the current interface value of the coorsponding WoW version. +In BattleNet this typcially shown below the 'Play' button. +DragonFlight 10.02.05 is represented without dots - 100205 - in the .toc. + +If the interface value is close (but lower) WoW will complain that you are running 'older' addons. +If WoW finds a Classic Era value (say 11500) in a 'mainline' .toc, it will just ignore it (not load). +The reverse (a higher value) is true as well. + +=== .lua +This is the code for the plugin - and this file. + +=== .tga +This file is the icon used by the plugin. +It is specified in the .obj created for the LDB init routine. +WoW can use several different types of icons. This discussion is outside the scope of this example. + +=== libs +This file implementing the LDB functions. +See https://github.com/tekkub/libdatabroker-1-1/wiki/ for an API description. +LibDataBroker-1.1.lua at https://github.com/tekkub/libdatabroker-1-1/ +It *should* be included in the LDB compliant display addon. +It *should* included in the display addon. + + +Anyone can extract the code and art from WoW. This can be handy to get code examples. +And to grab icons to use for a plugin. My undestanding is any icon can be used within WoW without violating the ToS. +WoW icons tend to be .blp files. These files are NOT easy to look at or manipulate!! +You will need to research third party tools to manipulate .blp files. +--]] + +-- ******************************** Constants ******************************* +local ADDON_NAME = ... +-- Set the name we want in the global name space. Ensure the name is unique across all addons. +StarterLDB = {} + +local id = "LDBStarter"; -- What the user will see as the name +local addon = ADDON_NAME -- addon name / folder name / toc name + +-- Localized strings are outside the scope of this example. + +--[[ +The artwork path must start with Interface\\AddOns +Then the name of the plugin +Then any additional folder(s) to your artwork / icons. +--]] +local artwork_path = "Interface\\AddOns\\TitanPlugin\\Artwork" +---@diagnostic disable-next-line: deprecated +local GetAddOnMetadata = C_AddOns.GetAddOnMetadata or GetAddOnMetadata + +-- Get data from the TOC file. +local version = tostring(GetAddOnMetadata(addon, "Version")) or "Unknown" +local author = GetAddOnMetadata(addon, "Author") or "Unknown" +-- NOTE: GetAddOnMetadata expects the addon name : +-- The addon folder name or .toc name needs to be the same. +-- ******************************** Variables ******************************* +local trace = false -- toggle to show / hide debug statements in this addon + +-- ******************************** Functions ******************************* +local function Debug(debug_message, debug_type) + if trace then + local dtype = "" + local time_stamp = "" + local msg = "" + if debug_type == "error" then + dtype = "Error: " + elseif debug_type == "warning" then + dtype = "Warning: " + end + if debug_type == "normal" then + time_stamp = "" + else + time_stamp = date("%H:%M:%S") .. ": " + end + + msg = + "Debug" .. " " + .. time_stamp + .. dtype + .. debug_message + + _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) + else + -- not requested + end + --date("%m/%d/%y %H:%M:%S") +end + +-- Calculate bag space then return text and icon to display +local function GetBagSlotInfo() + local totalSlots, usedSlots, availableSlots, icon + totalSlots = 0; + usedSlots = 0; + for bag = 0, 4 do + local size = C_Container.GetContainerNumSlots(bag); + if (size and size > 0) then + totalSlots = totalSlots + size; + local free = C_Container.GetContainerNumFreeSlots(bag) + local used = size - free + usedSlots = usedSlots + used; + end + end + availableSlots = totalSlots - usedSlots; + + local i, r = math.modf(availableSlots / 2) + if (r == 0) then + icon = artwork_path .. "Starter.tga" + else + icon = "Interface\\PetPaperDollFrame\\UI-PetHappiness" --PET_DISMISS_TEXTURE + end + + local bagText + bagText = format("%d/%d", availableSlots, totalSlots); + + bagText = HIGHLIGHT_FONT_COLOR_CODE .. bagText .. FONT_COLOR_CODE_CLOSE + + return bagText, icon + --]] +end + +-- Create the tooltip +local function LDB_OnTooltipShow(tooltip) + tooltip = tooltip or GameTooltip + local tt_str = "" + + --[[ + print("LDB OTS" + .." "..tostring(id).."" + ) + --]] + tt_str = + GREEN_FONT_COLOR_CODE + .. id .. " Info" + .. FONT_COLOR_CODE_CLOSE + tooltip:AddLine(tt_str) + + local text, icon = GetBagSlotInfo() + tt_str = "Available bag slots" + .. " " .. text .. "\n" + .. "\n" .. "Hint: Left-click to open all bags." + + tooltip:AddLine(tt_str) +end + +local function LDB_Init(LDB_frame) + Debug(id .. " Init ..."); + --[[ + Initialize the Data Broker 'button'. + This is the heart of a LDB plugin. It determines how the display addon is to treat this addon. + + Setting the type is required so the LDB lib and display addon know what to do. See the LDB spec. + --]] + -- The .obj is the key link to the display addon!! + LDB_frame.obj = + LibStub("LibDataBroker-1.1"):NewDataObject(id, { + type = "data source", -- required + -- SDK: The two options are: + -- "data source" - A data source is expected to show some type of info + -- "launcher" - Expected to open another window or perform some action + icon = artwork_path .. "Starter.tga", -- The icon to display on the display addon + label = id, -- label is the text the user will use to find this addon in the display addon. + text = "nyl", -- will be updated later + OnTooltipShow = function(tooltip) + LDB_OnTooltipShow(tooltip) + end, + OnClick = function(self, button) + if (button == "LeftButton") then + -- Just a simple action to illustrate an LDB addon. + ToggleAllBags(); + elseif (button == "RightButton") then + -- There is no action to take in this example. + --[[ Add code here if your addon needs to do something on right click. + Typically an options menu which is outside the scope of this example. + --]] + end + end, + }) + Debug(id .. " Init fini."); + --]===] +end + +-- Update the Bags Data Broker 'button' +local function LDB_Update(LDB_frame) + local text, icon = GetBagSlotInfo() + LDB_frame.obj.text = text + LDB_frame.obj.icon = icon +end + +-- Parse events registered to plugin and act on them +local function Button_OnEvent(self, event, ...) + Debug("OnEvent" + .. " " .. tostring(event) .. "" + ) + if (event == "PLAYER_ENTERING_WORLD") then + -- Do any additional set up needed + -- + --[[ + print("" + .." "..tostring(id).."" + .." "..tostring(version).."" + .." by "..tostring(author).."" + ) + --]] + -- Now that events have settled, register the one(s) we really want. + -- This may not be needed but it could reduce churn and possible timing issues. + self:RegisterEvent("BAG_UPDATE"); + + -- Unregister events no longer needed. + -- Good practice although this event is only fired on login + self:UnregisterEvent("PLAYER_ENTERING_WORLD"); + end + if event == "BAG_UPDATE" then + LDB_Update(self) + end +end + +-- ====== Create needed frames +local function Create_Frames() + -- general container frame + -- The frame pointer is passed as a parameter rather than an addon local. + local window = CreateFrame("Frame", "StarterLDBExample", UIParent) + -- window:Hide() + + -- Set strata as desired + window:SetFrameStrata("FULLSCREEN") + -- Using SetScript("OnLoad", does not work + + window:SetScript("OnEvent", function(self, event, ...) + Button_OnEvent(self, event, ...) + end) + + -- Tell Blizzard this frame needs player entering world event. + window:RegisterEvent("PLAYER_ENTERING_WORLD"); + + -- Any other addon specific "on load" code here + LDB_Init(window) + -- Update the text (bag numbers) + LDB_Update(window) + + -- shamelessly print a load message to chat window + DEFAULT_CHAT_FRAME:AddMessage( + GREEN_FONT_COLOR_CODE + .. addon .. id .. " " .. version + .. " by " + .. FONT_COLOR_CODE_CLOSE + .. "|cFFFFFF00" .. author .. FONT_COLOR_CODE_CLOSE); +end + +Create_Frames() -- do the work diff --git a/TitanLDB/TitanLDB_Mainline.toc b/TitanLDB/TitanLDB_Mainline.toc new file mode 100644 index 0000000..ed50362 --- /dev/null +++ b/TitanLDB/TitanLDB_Mainline.toc @@ -0,0 +1,13 @@ +## Interface: 100205 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLDB/TitanLDB_Vanilla.toc b/TitanLDB/TitanLDB_Vanilla.toc new file mode 100644 index 0000000..4a1ad2f --- /dev/null +++ b/TitanLDB/TitanLDB_Vanilla.toc @@ -0,0 +1,13 @@ +## Interface: 11500 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLDB/TitanLDB_Wrath.toc b/TitanLDB/TitanLDB_Wrath.toc new file mode 100644 index 0000000..368ecd3 --- /dev/null +++ b/TitanLDB/TitanLDB_Wrath.toc @@ -0,0 +1,13 @@ +## Interface: 30403 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLDB/libs/LibDataBroker-1.1.lua b/TitanLDB/libs/LibDataBroker-1.1.lua new file mode 100644 index 0000000..f47c0cd --- /dev/null +++ b/TitanLDB/libs/LibDataBroker-1.1.lua @@ -0,0 +1,90 @@ + +assert(LibStub, "LibDataBroker-1.1 requires LibStub") +assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0") + +local lib, oldminor = LibStub:NewLibrary("LibDataBroker-1.1", 4) +if not lib then return end +oldminor = oldminor or 0 + + +lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib) +lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {} +local attributestorage, namestorage, callbacks = lib.attributestorage, lib.namestorage, lib.callbacks + +if oldminor < 2 then + lib.domt = { + __metatable = "access denied", + __index = function(self, key) return attributestorage[self] and attributestorage[self][key] end, + } +end + +if oldminor < 3 then + lib.domt.__newindex = function(self, key, value) + if not attributestorage[self] then attributestorage[self] = {} end + if attributestorage[self][key] == value then return end + attributestorage[self][key] = value + local name = namestorage[self] + if not name then return end + callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value, self) + callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value, self) + callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value, self) + callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value, self) + end +end + +if oldminor < 2 then + function lib:NewDataObject(name, dataobj) + if self.proxystorage[name] then return end + + if dataobj then + assert(type(dataobj) == "table", "Invalid dataobj, must be nil or a table") + self.attributestorage[dataobj] = {} + for i,v in pairs(dataobj) do + self.attributestorage[dataobj][i] = v + dataobj[i] = nil + end + end + dataobj = setmetatable(dataobj or {}, self.domt) + self.proxystorage[name], self.namestorage[dataobj] = dataobj, name + self.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj) + return dataobj + end +end + +if oldminor < 1 then + function lib:DataObjectIterator() + return pairs(self.proxystorage) + end + + function lib:GetDataObjectByName(dataobjectname) + return self.proxystorage[dataobjectname] + end + + function lib:GetNameByDataObject(dataobject) + return self.namestorage[dataobject] + end +end + +if oldminor < 4 then + local next = pairs(attributestorage) + function lib:pairs(dataobject_or_name) + local t = type(dataobject_or_name) + assert(t == "string" or t == "table", "Usage: ldb:pairs('dataobjectname') or ldb:pairs(dataobject)") + + local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name + assert(attributestorage[dataobj], "Data object not found") + + return next, attributestorage[dataobj], nil + end + + local ipairs_iter = ipairs(attributestorage) + function lib:ipairs(dataobject_or_name) + local t = type(dataobject_or_name) + assert(t == "string" or t == "table", "Usage: ldb:ipairs('dataobjectname') or ldb:ipairs(dataobject)") + + local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name + assert(attributestorage[dataobj], "Data object not found") + + return ipairs_iter, attributestorage[dataobj], 0 + end +end diff --git a/TitanLocation/TitanLocation.lua b/TitanLocation/TitanLocation.lua index 536fa3a..9da7842 100755 --- a/TitanLocation/TitanLocation.lua +++ b/TitanLocation/TitanLocation.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanLocation.lua @@ -20,9 +21,9 @@ local cachedX = 0; local cachedY = 0; local updateTable = {TITAN_LOCATION_ID, TITAN_PANEL_UPDATE_BUTTON}; -- ******************************** Variables ******************************* -local L = {} -- For AceLocale -local AceTimer = {} -local LocationTimer = nil; +local AceTimer = LibStub("AceTimer-3.0") +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +local LocationTimer = {}; local debug_flow = false @@ -38,8 +39,8 @@ local function debug_msg(Message) local msg = "" local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S") local milli = GetTime() -- seconds with millisecond precision (float) - milli = string.format("%0.2F", milli - math.modf(milli)) - msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_LOCATION_ID..": ") + local milli_str = string.format("%0.2F", milli - math.modf(milli)) + msg = msg..TitanUtils_GetGoldText(stamp..milli_str.." "..TITAN_LOCATION_ID..": ") msg = msg..TitanUtils_GetGreenText(Message) DEFAULT_CHAT_FRAME:AddMessage(msg) -- DEFAULT_CHAT_FRAME:AddMessage(TITAN_LOCATION_ID..": " .. Message, 1.00, 0.49, 0.04) @@ -59,64 +60,6 @@ local function RegEvent(plugin, event) end end ---[[ --- ************************************************************************** --- NAME : TitanPanelLocationButton_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** ---]] -function TitanPanelLocationButton_OnLoad(self) - local notes = "" - .."Adds coordinates and location information to Titan Panel.\n" --- .."- xxx.\n" - self.registry = { - id = TITAN_LOCATION_ID, - category = "Built-ins", - version = (TitanUtils_GetAddOnMetadata(TITAN_LOCATION_ID, "Version")) or "", - menuText = L["TITAN_LOCATION_MENU_TEXT"], - buttonTextFunction = "TitanPanelLocationButton_GetButtonText", - tooltipTitle = L["TITAN_LOCATION_TOOLTIP"], - tooltipTextFunction = "TitanPanelLocationButton_GetTooltipText", - icon = "Interface\\AddOns\\TitanLocation\\TitanLocation", - iconWidth = 16, - notes = notes, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = true, - DisplayOnRightSide = true, - }, - savedVariables = { - ShowZoneText = 1, - ShowSubZoneText = true, - ShowCoordsText = true, - ShowCoordsOnMap = true, - ShowCursorOnMap = true, - ShowLocOnMiniMap = 1, - ShowIcon = 1, - ShowLabelText = 1, - ShowColoredText = 1, - CoordsFormat = L["TITAN_LOCATION_FORMAT"], - UpdateWorldmap = false, - MapLocation = "TOPRIGHT", - DisplayOnRightSide = false, - } - }; - - RegEvent(self, "PLAYER_ENTERING_WORLD") - - if debug_flow then - local msg = - "_OnLoad" --- .." "..tostring(reason).."" - debug_msg(msg) - else - -- not requested - end - -end - --[[ local -- ************************************************************************** -- NAME : Events() @@ -151,20 +94,6 @@ local function Events(action, reason) end end -local function ZoneUpdate(self) - - local _ = nil - self.zoneText = GetZoneText(); - self.subZoneText = GetSubZoneText(); - self.pvpType, _, self.factionName = GetZonePVPInfo(); - - TitanPanelPluginHandle_OnUpdate(updateTable); - - if TitanPanelLocationButton:IsVisible() and not LocationTimer then - LocationTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelLocation", TitanPanelLocationButton_CheckForUpdate, 0.5) - end -end - --[[ local -- ************************************************************************** -- NAME : GetPlayerMapPosition() @@ -186,6 +115,40 @@ local function GetPlayerMapPosition() end end +--[[ +-- ************************************************************************** +-- NAME : CheckForPositionUpdate() +-- DESC : Function to throttle down unnecessary updates +-- ************************************************************************** +--]] +local function CheckForPositionUpdate() + local mapID = C_Map.GetBestMapForUnit("player") + local tempx, tempy = GetPlayerMapPosition(); + if tempx ~= cachedX or tempy ~= cachedY then + TitanPanelPluginHandle_OnUpdate(updateTable); + end +end + +local function ZoneUpdate(self) + +--[==[ +print("TLoc ZoneUpdate" +.." c "..tostring(self).." " +.." p "..tostring(self:GetName()).." " +) +--]==] + local _ = nil + self.zoneText = GetZoneText(); + self.subZoneText = GetSubZoneText(); + self.pvpType, _, self.factionName = GetZonePVPInfo(); + + TitanPanelPluginHandle_OnUpdate(updateTable); + + if TitanPanelLocationButton:IsVisible() and LocationTimer == {} then + LocationTimer = AceTimer:ScheduleRepeatingTimer(CheckForPositionUpdate, 0.5) + end +end + local function SetCoordText(player, cursor) local playerLocationText = player or "" local cursorLocationText = cursor or "" @@ -247,16 +210,75 @@ local function LocOnMiniMap(reason) end --[[ +-- ************************************************************************** +-- NAME : TitanMapFrame_OnUpdate() +-- DESC : Update coordinates on map +-- ************************************************************************** +--]] +local function TitanMapFrame_OnUpdate(self, elapsed) + -- Determine the text to show for player coords + + local cursorLocationText = "" + local playerLocationText = "" + + if debug_flow then + cursorLocationText = "-C-" + playerLocationText = "-P-" + else + -- use default + end + + if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap")) then + self.px, self.py = GetPlayerMapPosition(); + if self.px == nil then self.px = 0 end + if self.py == nil then self.py = 0 end + if self.px == 0 and self.py == 0 then + playerLocationText = L["TITAN_LOCATION_NO_COORDS"] + else + playerLocationText = format(TitanGetVar(TITAN_LOCATION_ID, "CoordsFormat"), 100 * self.px, 100 * self.py); + end + playerLocationText = (format(L["TITAN_LOCATION_MAP_PLAYER_COORDS_TEXT"], TitanUtils_GetHighlightText(playerLocationText))); + + -- Determine the text to show for cursor coords + local cx, cy = GetCursorPosition(); + + -- use the global cursor position to confirm the cursor is over the map, but then use a normalized cursor position to account for map zooming + local left, bottom, width, height = WorldMapFrame.ScrollContainer:GetScaledRect(); + if (cx > left and cy > bottom and cx < left + width and cy < bottom+ height) then + cx, cy = WorldMapFrame:GetNormalizedCursorPosition(); + cx, cy = cx or 0, cy or 0; + else + cx, cy = 0, 0 + end + + -- per the user requested format + cursorLocationText = format(TitanGetVar(TITAN_LOCATION_ID, "CoordsFormat"), 100 * cx, 100 * cy) + cursorLocationText = (format(L["TITAN_LOCATION_MAP_CURSOR_COORDS_TEXT"], + TitanUtils_GetHighlightText(cursorLocationText))) + else + -- use defaults, saving a few cpu cycles + end +--[==[ +print("TLoc" +.." c "..tostring(cursorLocationText).." " +.." p "..tostring(playerLocationText).." " +) +--]==] + SetCoordText(playerLocationText, cursorLocationText) + +end + +--[[ -- Set the coordinates text for player and cursor -- Used on update to refresh and on hide to clear the text --]] local function CoordFrames(action) + local show_on_map = (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap") and true or false) if addon_conflict then -- do not attempt coords else local frame = _G[TITAN_MAP_FRAME] - local show_on_map = (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap") and true or false) if show_on_map then if action == "start" then local function updateFunc() @@ -345,11 +367,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_OnShow() +-- NAME : OnShow() -- DESC : Display button when plugin is visible -- ************************************************************************** --]] -function TitanPanelLocationButton_OnShow(self) +local function OnShow(self) if debug_flow then local msg = @@ -373,13 +395,13 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_OnHide() +-- NAME : OnHide() -- DESC : Destroy repeating timer when plugin is hidden -- ************************************************************************** --]] -function TitanPanelLocationButton_OnHide() - AceTimer.CancelTimer("TitanPanelLocation", LocationTimer, true) - LocationTimer = nil; +local function OnHide(self) + AceTimer:CancelTimer(LocationTimer) + LocationTimer = {}; Events("unregister", "_OnHide") CoordFrames("stop") -- stop coords on map, if requested @@ -387,19 +409,18 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_GetButtonText(id) +-- NAME : GetButtonText(id) -- DESC : Calculate coordinates and then display data on button -- VARS : id = button ID -- ************************************************************************** --]] -function TitanPanelLocationButton_GetButtonText(id) - local button, id = TitanUtils_GetButton(id, true); +local function GetButtonText(id) + local button, id = TitanUtils_GetButton(id); local locationText = "" -- Coordinates text, if requested - if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsText")) then + if button and TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsText") then button.px, button.py = GetPlayerMapPosition(); - -- cache coordinates for update checking later on cachedX = button.px; cachedY = button.py; if button.px == nil then button.px = 0 end @@ -415,7 +436,7 @@ function TitanPanelLocationButton_GetButtonText(id) end -- Zone text, if requested - if (TitanGetVar(TITAN_LOCATION_ID, "ShowZoneText")) then + if button and TitanGetVar(TITAN_LOCATION_ID, "ShowZoneText") then if (TitanUtils_ToString(button.subZoneText) == '') then if (button.zoneText == '') then local Map_unit = C_Map.GetBestMapForUnit -- DF change of API @@ -428,7 +449,7 @@ function TitanPanelLocationButton_GetButtonText(id) locationText = TitanUtils_ToString(button.subZoneText)..' '..locationText; end else - if button.px == 0 and button.py == 0 then + if button and button.px == 0 and button.py == 0 then locationText = L["TITAN_LOCATION_NO_COORDS"]; end end @@ -456,11 +477,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_GetTooltipText() +-- NAME : GetTooltipText() -- DESC : Display tooltip text -- ************************************************************************** --]] -function TitanPanelLocationButton_GetTooltipText() +local function GetTooltipText() local pvpInfoRichText; pvpInfoRichText = ""; @@ -499,11 +520,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_OnEvent() +-- NAME : OnEvent() -- DESC : Parse events registered to plugin and act on them -- ************************************************************************** --]] -function TitanPanelLocationButton_OnEvent(self, event, ...) +local function OnEvent(self, event, ...) -- DF TODO See if we can turn off zone on minimap --[=[ --]=] @@ -538,26 +559,12 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelLocationButton_CheckForUpdate() --- DESC : Function to throttle down unnecessary updates --- ************************************************************************** ---]] -function TitanPanelLocationButton_CheckForUpdate() - local mapID = C_Map.GetBestMapForUnit("player") - local tempx, tempy = GetPlayerMapPosition(); - if tempx ~= cachedX or tempy ~= cachedY then - TitanPanelPluginHandle_OnUpdate(updateTable); - end -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelLocationButton_OnClick(button) +-- NAME : OnClick(button) -- DESC : Copies coordinates to chat line for shift-LeftClick -- VARS : button = value of action -- ************************************************************************** --]] -function TitanPanelLocationButton_OnClick(self, button) +local function OnClick(self, button) if (button == "LeftButton") then if (IsShiftKeyDown()) then local activeWindow = ChatEdit_GetActiveWindow(); @@ -572,7 +579,7 @@ function TitanPanelLocationButton_OnClick(self, button) end end -function TitanPanelRightClickMenu_PrepareLocationMenu() +local function CreateMenu() local info -- level 2 @@ -701,60 +708,60 @@ end --[[ -- ************************************************************************** --- NAME : TitanMapFrame_OnUpdate() --- DESC : Update coordinates on map +-- NAME : OnLoad() +-- DESC : Registers the plugin upon it loading -- ************************************************************************** --]] -function TitanMapFrame_OnUpdate(self, elapsed) - -- Determine the text to show for player coords - - local cursorLocationText = "" - local playerLocationText = "" +local function OnLoad(self) + local notes = "" + .."Adds coordinates and location information to Titan Panel.\n" +-- .."- xxx.\n" + self.registry = { + id = TITAN_LOCATION_ID, + category = "Built-ins", + version = (TitanUtils_GetAddOnMetadata(TITAN_LOCATION_ID, "Version")) or "", + menuText = L["TITAN_LOCATION_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_LOCATION_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + icon = "Interface\\AddOns\\TitanLocation\\TitanLocation", + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = true, + DisplayOnRightSide = true, + }, + savedVariables = { + ShowZoneText = 1, + ShowSubZoneText = true, + ShowCoordsText = true, + ShowCoordsOnMap = true, + ShowCursorOnMap = true, + ShowLocOnMiniMap = 1, + ShowIcon = 1, + ShowLabelText = 1, + ShowColoredText = 1, + CoordsFormat = L["TITAN_LOCATION_FORMAT"], + UpdateWorldmap = false, + MapLocation = "TOPRIGHT", + DisplayOnRightSide = false, + } + }; + RegEvent(self, "PLAYER_ENTERING_WORLD") + if debug_flow then - cursorLocationText = "-C-" - playerLocationText = "-P-" - else - -- use default - end - - if (TitanGetVar(TITAN_LOCATION_ID, "ShowCoordsOnMap")) then - self.px, self.py = GetPlayerMapPosition(); - if self.px == nil then self.px = 0 end - if self.py == nil then self.py = 0 end - if self.px == 0 and self.py == 0 then - playerLocationText = L["TITAN_LOCATION_NO_COORDS"] - else - playerLocationText = format(TitanGetVar(TITAN_LOCATION_ID, "CoordsFormat"), 100 * self.px, 100 * self.py); - end - playerLocationText = (format(L["TITAN_LOCATION_MAP_PLAYER_COORDS_TEXT"], TitanUtils_GetHighlightText(playerLocationText))); - - -- Determine the text to show for cursor coords - local cx, cy = GetCursorPosition(); - - -- use the global cursor position to confirm the cursor is over the map, but then use a normalized cursor position to account for map zooming - local left, bottom, width, height = WorldMapFrame.ScrollContainer:GetScaledRect(); - if (cx > left and cy > bottom and cx < left + width and cy < bottom+ height) then - cx, cy = WorldMapFrame:GetNormalizedCursorPosition(); - cx, cy = cx or 0, cy or 0; - else - cx, cy = 0, 0 - end - - -- per the user requested format - cursorLocationText = format(TitanGetVar(TITAN_LOCATION_ID, "CoordsFormat"), 100 * cx, 100 * cy) - cursorLocationText = (format(L["TITAN_LOCATION_MAP_CURSOR_COORDS_TEXT"], - TitanUtils_GetHighlightText(cursorLocationText))) + local msg = + "_OnLoad" +-- .." "..tostring(reason).."" + debug_msg(msg) else - -- use defaults, saving a few cpu cycles + -- not requested end ---[==[ -print("TLoc" -.." c "..tostring(cursorLocationText).." " -.." p "..tostring(playerLocationText).." " -) ---]==] - SetCoordText(playerLocationText, cursorLocationText) end @@ -772,26 +779,24 @@ local function Create_Frames() local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelComboTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelLocationButton_OnLoad(window); + OnLoad(window); -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... window:SetScript("OnShow", function(self) - TitanPanelLocationButton_OnShow(self); + OnShow(self); TitanPanelButton_OnShow(self); end) window:SetScript("OnHide", function(self) - TitanPanelLocationButton_OnHide(self) + OnHide(self) end) window:SetScript("OnEvent", function(self, event, ...) - TitanPanelLocationButton_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) window:SetScript("OnClick", function(self, button) - TitanPanelLocationButton_OnClick(self, button); + OnClick(self, button); TitanPanelButton_OnClick(self, button); end) end -AceTimer = LibStub("AceTimer-3.0") -L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) Create_Frames() diff --git a/TitanLocation/TitanLocation_Mainline.toc b/TitanLocation/TitanLocation_Mainline.toc index ce6916b..c3dd488 100644 --- a/TitanLocation/TitanLocation_Mainline.toc +++ b/TitanLocation/TitanLocation_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLocation/TitanLocation_Vanilla.toc b/TitanLocation/TitanLocation_Vanilla.toc index 0451b50..218d789 100644 --- a/TitanLocation/TitanLocation_Vanilla.toc +++ b/TitanLocation/TitanLocation_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLocation/TitanLocation_Wrath.toc b/TitanLocation/TitanLocation_Wrath.toc index e862c00..8283bd2 100644 --- a/TitanLocation/TitanLocation_Wrath.toc +++ b/TitanLocation/TitanLocation_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLootType/TitanClassicLootType.lua b/TitanLootType/TitanClassicLootType.lua index 181850f..63feee5 100644 --- a/TitanLootType/TitanClassicLootType.lua +++ b/TitanLootType/TitanClassicLootType.lua @@ -1,6 +1,6 @@ --[[ File NAME: TitanLootType.lua -DESC: +DESC: This Titan plugin will show group type and loot type in the button text. A roll tracker is used to show rolls in party to help make passing out loot and chests. This is a simplistic roll helper! It is NOT intended as a loot tracker! @@ -16,52 +16,55 @@ The left-click it will depend whether the user is group leader or loot master : Once a leader initiates a roll, the tracker will pop for other Titan users who are using LootType. :DESC --]] -TitanPanelLootType = {} -- declare name space -local LT = TitanPanelLootType -- save some typing... +TitanPanelLootType = {} -- declare name space +local LT = TitanPanelLootType -- save some typing... + -- ******************************** Constants ******************************* -local TITAN_LOOTTYPE_ID = "LootType"; -local _G = getfenv(0); -local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -local TitanLootMethod = {}; -local updateTable = {TITAN_LOOTTYPE_ID, TITAN_PANEL_UPDATE_ALL}; -TitanLootMethod["freeforall"] = {text = L["TITAN_LOOTTYPE_FREE_FOR_ALL"]}; -TitanLootMethod["roundrobin"] = {text = L["TITAN_LOOTTYPE_ROUND_ROBIN"]}; -TitanLootMethod["master"] = {text = L["TITAN_LOOTTYPE_MASTER_LOOTER"]}; -TitanLootMethod["group"] = {text = L["TITAN_LOOTTYPE_GROUP_LOOT"]}; -TitanLootMethod["needbeforegreed"] = {text = L["TITAN_LOOTTYPE_NEED_BEFORE_GREED"]}; +local TITAN_LOOTTYPE_ID = "LootType"; +local _G = getfenv(0); +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +local TitanLootMethod = {}; +local updateTable = { TITAN_LOOTTYPE_ID, TITAN_PANEL_UPDATE_ALL }; +TitanLootMethod["freeforall"] = { text = L["TITAN_LOOTTYPE_FREE_FOR_ALL"] }; +TitanLootMethod["roundrobin"] = { text = L["TITAN_LOOTTYPE_ROUND_ROBIN"] }; +TitanLootMethod["master"] = { text = L["TITAN_LOOTTYPE_MASTER_LOOTER"] }; +TitanLootMethod["group"] = { text = L["TITAN_LOOTTYPE_GROUP_LOOT"] }; +TitanLootMethod["needbeforegreed"] = { text = L["TITAN_LOOTTYPE_NEED_BEFORE_GREED"] }; --TitanLootMethod["personalloot"] = {text = L["TITAN_LOOTTYPE_PERSONAL"]}; -local TOCNAME = "TitanLootType" -local Track = {} +local TOCNAME = "TitanLootType" +local Track = {} +Track.DB = {} + -- High level constants -Track.IconDice= "Interface\\Buttons\\UI-GroupLoot-Dice-Up" +Track.IconDice = "Interface\\Buttons\\UI-GroupLoot-Dice-Up" --Track.IconGreed= "Interface\\Buttons\\UI-GroupLoot-Coin-Up" -Track.IconPass= "Interface\\Buttons\\UI-GroupLoot-Pass-Up" -Track.IconLoot= "Interface\\GroupFrame\\UI-Group-MasterLooter" -Track.TxtEscapePicture="|T%s:0|t" -Track.TxtEscapeIcon="|T%s:0:0:0:0:64:64:4:60:4:60|t" +Track.IconPass = "Interface\\Buttons\\UI-GroupLoot-Pass-Up" +Track.IconLoot = "Interface\\GroupFrame\\UI-Group-MasterLooter" +Track.TxtEscapePicture = "|T%s:0|t" +Track.TxtEscapeIcon = "|T%s:0:0:0:0:64:64:4:60:4:60|t" -- These are encoded 'messages' this addon searches for to start and end the roll process -Track.MSGPREFIX="Titan LootType Roller: " -- also frame title -Track.MSGPREFIX_START=Track.MSGPREFIX..">>: " -Track.MSGPREFIX_END =Track.MSGPREFIX.."<<: " -Track.MSGPREFIX_CLOSE=Track.MSGPREFIX.."__: " +Track.MSGPREFIX = "Titan LootType Roller: " -- also frame title +Track.MSGPREFIX_START = Track.MSGPREFIX .. ">>: " +Track.MSGPREFIX_END = Track.MSGPREFIX .. "<<: " +Track.MSGPREFIX_CLOSE = Track.MSGPREFIX .. "__: " -- This will be debugged real-time so put the debug on 'switches' -- Also useful when debugging 'solo' -LT.Debug = { +LT.Debug = { -- Used when creating dummy player list (see flags) or solo debug to get 'self' -- And debug output - on = false, - - show = { -- for LootDebug messages - events = false, -- show debug for events - players = false, -- show debug for players + on = false, + + show = { -- for LootDebug messages + events = false, -- show debug for events + players = false, -- show debug for players -- nil will show regardless }, flags = { -- solo debug - force_leader = false, + force_leader = false, force_master = false, force_loot_master = false, -- These 3 are used when creating dummy player list WITH 'on' = true @@ -71,9 +74,9 @@ LT.Debug = { }, } --[[ -The commands (use WoWLua addon) below will +The commands (use WoWLua addon) below will - set debug depending on what you want to test -- create a player list (via GetPlayerList on start roll) to play with +- create a player list (via GetPlayerList on start roll) to play with AND add_players is true is_raid will make a 40 player list... is_party will make a 5 player list @@ -99,51 +102,52 @@ VAR: msg - message to be output VAR: mtype - the type of message OUT: None --]] -local function LootDebug (msg, mtype) +local function LootDebug(msg, mtype) local show = false - if mtype == nil then show = true -- just show it - elseif mtype == "events" and LT.Debug.show.events then show = true - elseif mtype == "players" and LT.Debug.show.players then show = true + if mtype == nil then + show = true -- just show it + elseif mtype == "events" and LT.Debug.show.events then + show = true + elseif mtype == "players" and LT.Debug.show.players then + show = true end - + if show then --- DEFAULT_CHAT_FRAME:AddMessage((msg or "nyl")) - TitanDebug((msg or "nyl")) -- do not 'crash' if a nil is received + TitanPluginDebug(tostring(msg)) end - end -- Tools for the tracker local Tool = {} -Tool.IconClassTexture="Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES" -Tool.IconClassTextureWithoutBorder="Interface\\WorldStateFrame\\ICONS-CLASSES" -Tool.IconClassTextureCoord=CLASS_ICON_TCOORDS -Tool.IconClass={ - ["WARRIOR"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:0:64|t", - ["MAGE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:0:64|t", - ["ROGUE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:0:64|t", - ["DRUID"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:0:64|t", - ["HUNTER"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:64:128|t", - ["SHAMAN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:64:128|t", - ["PRIEST"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:64:128|t", - ["WARLOCK"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:64:128|t", - ["PALADIN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:128:192|t", - } -Tool.IconClassBig={ - ["WARRIOR"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:0:64|t", - ["MAGE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:0:64|t", - ["ROGUE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:0:64|t", - ["DRUID"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:0:64|t", - ["HUNTER"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:64:128|t", - ["SHAMAN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:64:128|t", - ["PRIEST"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:64:128|t", - ["WARLOCK"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:64:128|t", - ["PALADIN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:128:192|t", - } - -Tool.RaidIconNames=ICON_TAG_LIST -Tool.RaidIcon={ +Tool.IconClassTexture = "Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES" +Tool.IconClassTextureWithoutBorder = "Interface\\WorldStateFrame\\ICONS-CLASSES" +Tool.IconClassTextureCoord = CLASS_ICON_TCOORDS +Tool.IconClass = { + ["WARRIOR"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:0:64|t", + ["MAGE"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:0:64|t", + ["ROGUE"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:0:64|t", + ["DRUID"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:0:64|t", + ["HUNTER"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:64:128|t", + ["SHAMAN"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:64:128|t", + ["PRIEST"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:64:128|t", + ["WARLOCK"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:64:128|t", + ["PALADIN"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:128:192|t", +} +Tool.IconClassBig = { + ["WARRIOR"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:0:64|t", + ["MAGE"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:0:64|t", + ["ROGUE"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:0:64|t", + ["DRUID"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:0:64|t", + ["HUNTER"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:64:128|t", + ["SHAMAN"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:64:128|t", + ["PRIEST"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:64:128|t", + ["WARLOCK"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:64:128|t", + ["PALADIN"] = "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:128:192|t", +} + +Tool.RaidIconNames = ICON_TAG_LIST +Tool.RaidIcon = { "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1:0|t", -- [1] "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2:0|t", -- [2] "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3:0|t", -- [3] @@ -152,11 +156,11 @@ Tool.RaidIcon={ "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6:0|t", -- [6] "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7:0|t", -- [7] "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8:0|t", -- [8] - } - -Tool.Classes=CLASS_SORT_ORDER -Tool.ClassName=LOCALIZED_CLASS_NAMES_MALE -Tool.ClassColor=RAID_CLASS_COLORS +} + +Tool.Classes = CLASS_SORT_ORDER +Tool.ClassName = LOCALIZED_CLASS_NAMES_MALE +Tool.ClassColor = RAID_CLASS_COLORS Tool.ButtonFontObj = {} Tool.Font = "" @@ -168,20 +172,20 @@ VAR: pattern - string to be parsed VAR: maximize - do min or max substitution OUT: None --]] -function Tool.CreatePattern(pattern,maximize) +function Tool.CreatePattern(pattern, maximize) pattern = string.gsub(pattern, "[%(%)%-%+%[%]]", "%%%1") - if not maximize then + if not maximize then pattern = string.gsub(pattern, "%%s", "(.-)") else pattern = string.gsub(pattern, "%%s", "(.+)") end pattern = string.gsub(pattern, "%%d", "%(%%d-%)") - if not maximize then + if not maximize then pattern = string.gsub(pattern, "%%%d%$s", "(.-)") else pattern = string.gsub(pattern, "%%%d%$s", "(.+)") end - pattern = string.gsub(pattern, "%%%d$d", "%(%%d-%)") + pattern = string.gsub(pattern, "%%%d$d", "%(%%d-%)") --pattern = string.gsub(pattern, "%[", "%|H%(%.%-%)%[") --pattern = string.gsub(pattern, "%]", "%]%|h") return pattern @@ -192,57 +196,68 @@ NAME: Sizing routines DESC: These allow the frame to be resized as needed. OUT: None --]] -local ResizeCursor -local SizingStop=function(self,button) +---@class ResizeCursorType +---@field Texture? table +local ResizeCursor = {} ---@type Frame +local SizingStop = function(self, button) self:GetParent():StopMovingOrSizing() if self.GPI_DoStop then self.GPI_DoStop(self:GetParent()) end end -local SizingStart=function(self,button) +local SizingStart = function(self, button) self:GetParent():StartSizing(self.GPI_SIZETYPE) if self.GPI_DoStart then self.GPI_DoStart(self:GetParent()) end end -local SizingEnter=function(self) +local SizingEnter = function(self) if not (GetCursorInfo()) then ResizeCursor:Show() ResizeCursor.Texture:SetTexture(self.GPI_Cursor) --- ResizeCursor.Texture:SetRotation(math.rad(self.GPI_Rotation),0.5,0.5) - ResizeCursor.Texture:SetRotation(math.rad(self.GPI_Rotation)) + ResizeCursor.Texture:SetRotation(math.rad(self.GPI_Rotation), { 0.5, 0.5 }) end end -local SizingLeave=function(self,button) +local SizingLeave = function(self, button) ResizeCursor:Hide() end -local sizecount=0 -local CreateSizeBorder=function(frame,name,a1,x1,y1,a2,x2,y2,cursor,rot,OnStart,OnStop) - local FrameSizeBorder - sizecount=sizecount+1 - FrameSizeBorder=CreateFrame("Frame",(frame:GetName() or TOCNAME..sizecount).."_size_"..name,frame) +-- Titan Loot + +---@class FrameSizeBorder +---@field GPI_SIZETYPE string +---@field GPI_Cursor string +---@field GPI_Rotation string +---@field GPI_DoStart string +---@field GPI_DoStop string +local FrameSizeBorder ---@type Frame +local sizecount = 0 +local CreateSizeBorder = function(frame, name, a1, x1, y1, a2, x2, y2, cursor, rot, OnStart, OnStop) + sizecount = sizecount + 1 + FrameSizeBorder = CreateFrame("Frame", (frame:GetName() or TOCNAME .. sizecount) .. "_size_" .. name, frame) FrameSizeBorder:SetPoint("TOPLEFT", frame, a1, x1, y1) - FrameSizeBorder:SetPoint("BOTTOMRIGHT", frame, a2, x2,y2 ) - FrameSizeBorder.GPI_SIZETYPE=name + FrameSizeBorder:SetPoint("BOTTOMRIGHT", frame, a2, x2, y2) + FrameSizeBorder.GPI_SIZETYPE = name FrameSizeBorder.GPI_Cursor = cursor FrameSizeBorder.GPI_Rotation = rot - FrameSizeBorder.GPI_DoStart=OnStart - FrameSizeBorder.GPI_DoStop=OnStop + FrameSizeBorder.GPI_DoStart = OnStart + FrameSizeBorder.GPI_DoStop = OnStop FrameSizeBorder:SetScript("OnMouseDown", SizingStart) FrameSizeBorder:SetScript("OnMouseUp", SizingStop) FrameSizeBorder:SetScript("OnEnter", SizingEnter) - FrameSizeBorder:SetScript("OnLeave", SizingLeave) + FrameSizeBorder:SetScript("OnLeave", SizingLeave) return FrameSizeBorder end -local ResizeCursor_Update=function(self) +local ResizeCursor_Update = function(self) local X, Y = GetCursorPosition() local Scale = self:GetEffectiveScale() self:SetPoint("CENTER", UIParent, "BOTTOMLEFT", X / Scale, Y / Scale) end -function Tool.EnableSize(frame,border,OnStart,OnStop) - if not ResizeCursor then +function Tool.EnableSize(frame, border, OnStart, OnStop) + if ResizeCursor == {} then + -- use existing frame + else ResizeCursor = CreateFrame("Frame", nil, UIParent) ResizeCursor:Hide() ResizeCursor:SetWidth(24) @@ -252,23 +267,30 @@ function Tool.EnableSize(frame,border,OnStart,OnStop) ResizeCursor.Texture:SetAllPoints() ResizeCursor:SetScript("OnUpdate", ResizeCursor_Update) end - border=border or 8 - - + border = border or 8 + frame:EnableMouse(true) - frame:SetResizable(true) - - path= "Interface\\AddOns\\".. TOCNAME .. "\\Resize\\" - - CreateSizeBorder(frame,"BOTTOM","BOTTOMLEFT", border, border, "BOTTOMRIGHT", -border, 0,"Interface\\CURSOR\\UI-Cursor-SizeLeft",45,OnStart,OnStop) - CreateSizeBorder(frame,"TOP","TOPLEFT", border, 0, "TOPRIGHT", -border, -border,"Interface\\CURSOR\\UI-Cursor-SizeLeft",45,OnStart,OnStop) - CreateSizeBorder(frame,"LEFT","TOPLEFT", 0,-border, "BOTTOMLEFT", border, border,"Interface\\CURSOR\\UI-Cursor-SizeRight",45,OnStart,OnStop) - CreateSizeBorder(frame,"RIGHT","TOPRIGHT",-border,-border, "BOTTOMRIGHT", 0, border,"Interface\\CURSOR\\UI-Cursor-SizeRight",45,OnStart,OnStop) - - CreateSizeBorder(frame,"TOPLEFT","TOPLEFT", 0,0, "TOPLEFT", border, -border,"Interface\\CURSOR\\UI-Cursor-SizeRight",0,OnStart,OnStop) - CreateSizeBorder(frame,"BOTTOMLEFT","BOTTOMLEFT", 0,0, "BOTTOMLEFT", border, border, "Interface\\CURSOR\\UI-Cursor-SizeLeft",0,OnStart,OnStop) - CreateSizeBorder(frame,"TOPRIGHT","TOPRIGHT", 0,0, "TOPRIGHT", -border, -border, "Interface\\CURSOR\\UI-Cursor-SizeLeft",0,OnStart,OnStop) - CreateSizeBorder(frame,"BOTTOMRIGHT","BOTTOMRIGHT", 0,0, "BOTTOMRIGHT", -border, border, "Interface\\CURSOR\\UI-Cursor-SizeRight",0,OnStart,OnStop) + frame:SetResizable(true) + +-- path = "Interface\\AddOns\\" .. TOCNAME .. "\\Resize\\" + + CreateSizeBorder(frame, "BOTTOM", "BOTTOMLEFT", border, border, "BOTTOMRIGHT", -border, 0, + "Interface\\CURSOR\\UI-Cursor-SizeLeft", 45, OnStart, OnStop) + CreateSizeBorder(frame, "TOP", "TOPLEFT", border, 0, "TOPRIGHT", -border, -border, + "Interface\\CURSOR\\UI-Cursor-SizeLeft", 45, OnStart, OnStop) + CreateSizeBorder(frame, "LEFT", "TOPLEFT", 0, -border, "BOTTOMLEFT", border, border, + "Interface\\CURSOR\\UI-Cursor-SizeRight", 45, OnStart, OnStop) + CreateSizeBorder(frame, "RIGHT", "TOPRIGHT", -border, -border, "BOTTOMRIGHT", 0, border, + "Interface\\CURSOR\\UI-Cursor-SizeRight", 45, OnStart, OnStop) + + CreateSizeBorder(frame, "TOPLEFT", "TOPLEFT", 0, 0, "TOPLEFT", border, -border, + "Interface\\CURSOR\\UI-Cursor-SizeRight", 0, OnStart, OnStop) + CreateSizeBorder(frame, "BOTTOMLEFT", "BOTTOMLEFT", 0, 0, "BOTTOMLEFT", border, border, + "Interface\\CURSOR\\UI-Cursor-SizeLeft", 0, OnStart, OnStop) + CreateSizeBorder(frame, "TOPRIGHT", "TOPRIGHT", 0, 0, "TOPRIGHT", -border, -border, + "Interface\\CURSOR\\UI-Cursor-SizeLeft", 0, OnStart, OnStop) + CreateSizeBorder(frame, "BOTTOMRIGHT", "BOTTOMRIGHT", 0, 0, "BOTTOMRIGHT", -border, border, + "Interface\\CURSOR\\UI-Cursor-SizeRight", 0, OnStart, OnStop) end --[[ local @@ -287,36 +309,17 @@ local function MovingStop(self) end end -function Tool.EnableMoving(frame,callback) - frame:SetMovable(true) +function Tool.EnableMoving(frame, callback) + frame:SetMovable(true) frame:EnableMouse(true) frame:RegisterForDrag("LeftButton") - frame:SetScript("OnDragStart",MovingStart) - frame:SetScript("OnDragStop",MovingStop) - frame._GPIPRIVAT_MovingStopCallback=callback + frame:SetScript("OnDragStart", MovingStart) + frame:SetScript("OnDragStop", MovingStop) + frame._GPIPRIVAT_MovingStopCallback = callback end function Tool.SetButtonFont(button) --- Just Return. This changed WAY too much... ---[[ - if button then - local font_instance = button:GetNormalFontObject() - if font_instance then - font_instance:SetFont(Tool.Font, Tool.FontSize, nil) - else - TitanDebug("SetButtonFont" - .." "..(button:GetName() or "nyl") - .." no font instance" - ) - end - else - TitanDebug("SetButtonFont" - .." "..(button or "nyl") - .." no button!?" - ) - end ---]] --- button:SetFont(Tool.Font, Tool.FontSize, nil) + -- Just Return. This changed WAY too much... end --[[ local @@ -328,49 +331,49 @@ function Tool.Split(inputstr, sep) if sep == nil then sep = "%s" end - local t={} - for str in string.gmatch(inputstr, "([^"..sep.."]+)") do - if tContains(t, str)==false then + local t = {} + for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do + if tContains(t, str) == false then table.insert(t, str) end end return t end -function Tool.RGBtoEscape(r, g, b,a) - if type(r)=="table" then - a=r.a - g=r.g - b=r.b - r=r.r +function Tool.RGBtoEscape(r, g, b, a) + if type(r) == "table" then + a = r.a + g = r.g + b = r.b + r = r.r end - - r = r~=nil and r <= 1 and r >= 0 and r or 1 - g = g~=nil and g <= 1 and g >= 0 and g or 1 - b = b~=nil and b <= 1 and b >= 0 and b or 1 - a = a~=nil and a <= 1 and a >= 0 and a or 1 - return string.format("|c%02x%02x%02x%02x", a*255, r*255, g*255, b*255) --- return "" + + r = r ~= nil and r <= 1 and r >= 0 and r or 1 + g = g ~= nil and g <= 1 and g >= 0 and g or 1 + b = b ~= nil and b <= 1 and b >= 0 and b or 1 + a = a ~= nil and a <= 1 and a >= 0 and a or 1 + return string.format("|c%02x%02x%02x%02x", a * 255, r * 255, g * 255, b * 255) + -- return "" end -function Tool.Combine(t,sep,first,last) - if type(t)~="table" then return "" end - sep=sep or " " - first=first or 1 - last= last or #t - - local ret="" - for i=first,last do - ret=ret..sep..tostring(t[i]) +function Tool.Combine(t, sep, first, last) + if type(t) ~= "table" then return "" end + sep = sep or " " + first = first or 1 + last = last or #t + + local ret = "" + for i = first, last do + ret = ret .. sep .. tostring(t[i]) end - return string.sub(ret,string.len(sep)+1) + return string.sub(ret, string.len(sep) + 1) end -- Routines for the 'track' rolls feature --[[ local NAME: IsRoll DESC: Determine if the roll is valid. -VAR: roll - string +VAR: roll - string VAR: low - low end VAR: high - high end OUT: valid_roll - true / false @@ -379,21 +382,21 @@ OUT: ro - numeric roll OUT: lo - numeric low OUT: hi - numeric high --]] -local function IsRoll(roll,low,high) +local function IsRoll(roll, low, high) local lo = tonumber(low) local hi = tonumber(high) local ro = tonumber(roll) - + local valid_roll = false local valid_bounds = false - + if (lo == 1 and hi == 100) then valid_bounds = true end if (ro >= 0) and (ro <= 100) then -- allows a pass as valid valid_roll = true end - + if valid_bounds then -- all is good else @@ -401,55 +404,55 @@ local function IsRoll(roll,low,high) valid_roll = false ro = 0 end - - local str = " >>" - .." vr'"..tostring(valid_roll).."'" - .." vb'"..tostring(valid_bounds).."'" - .." r'"..tostring(ro).."'" - .." l'"..tostring(lo).."'" - .." h'"..tostring(hi).."'" - LootDebug (str, "players") - + + local str = " >>" + .. " vr'" .. tostring(valid_roll) .. "'" + .. " vb'" .. tostring(valid_bounds) .. "'" + .. " r'" .. tostring(ro) .. "'" + .. " l'" .. tostring(lo) .. "'" + .. " h'" .. tostring(hi) .. "'" + LootDebug(str, "players") + return valid_roll, valid_bounds, ro, lo, hi end --[[ local NAME: GetPlayer DESC: Get name, class, guild rank (if in same guild) a the given player. -VAR: id - id of player +VAR: id - id of player OUT: name - name of the player OUT: rank - guild rank OUT: englishClass - English class name --]] local function GetPlayer(id) - local name=GetUnitName(id) + local name = GetUnitName(id) local localizedClass, englishClass, classIndex = UnitClass(id) - - local rank="" - if IsInGuild() and UnitIsInMyGuild(id) then - rank="<".. GuildControlGetRankName( C_GuildInfo.GetGuildRankOrder( UnitGUID(id) ) )..">" - else + + local rank = "" + if IsInGuild() and UnitIsInMyGuild(id) then + rank = "<" .. GuildControlGetRankName(C_GuildInfo.GetGuildRankOrder(UnitGUID(id))) .. ">" + else local guildName, guildRankName, guildRankIndex, realm = GetGuildInfo(id) if guildName and guildRankName then - rank="<"..guildName.." / "..guildRankName..">" + rank = "<" .. guildName .. " / " .. guildRankName .. ">" end end - + return name, rank, englishClass end --[[ local NAME: IsLead DESC: Determine whether the player is the leader of the group. -VAR: None +VAR: None OUT: true / false --]] local function IsLead() ---[[ + --[[ lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod() -lootmethod +lootmethod String (LootMethod) - One of 'freeforall', 'roundrobin', 'master', 'group', 'needbeforegreed'. Appears to be 'freeforall' if you are not grouped.: At least as of 7.3 the possible return values appear to be "freeforall", "master", "group" and "personalloot". "roundrobin" and "needbeforegreed" appear to be deprecated. -masterlooterPartyID +masterlooterPartyID Number - Returns 0 if player is the mater looter, 1-4 if party member is master looter (corresponding to party1-4) and nil if the master looter isn't in the player's party or master looting is not used. -masterlooterRaidID +masterlooterRaidID Number - Returns index of the master looter in the raid (corresponding to a raidX unit), or nil if the player is not in a raid or master looting is not used. raidIndex = UnitInRaid("unit") @@ -459,11 +462,11 @@ isTrue = UnitInParty("arg1") inGroup = IsInGroup([groupType]) isTrue = UnitIsGroupLeader("unit"[, groupType]) -isLeader = IsRaidLeader() +isLeader = IsRaidLeader() isLeader = UnitIsGroupLeader("unit" or "player name") -- may need in later patches? --]] ---[[ + --[[ if IsInRaid() and IsRaidLeader() then return true end @@ -500,67 +503,67 @@ This routine will generate group lists (5 or 40) for debug based on debug flags. :DESC VAR: unsort - if true sort by class then name OUT: ret - indexed table of players in the group -OUT: retName - table of player names pointing into ret +OUT: retName - table of player names pointing into ret --]] local function OutPlayer(player) - if LT.Debug.on then -- - if player then - TitanDebug("GetPlayerList:" - .." p'"..(player.name or "nyl").."'" - .." r'"..(player.rank or "nyl").."'" - .." c'"..(player.class or "nyl").."'" + if LT.Debug.on then -- + if player then + TitanPluginDebug("GetPlayerList:" + .. " p'" .. (player.name or "nyl") .. "'" + .. " r'" .. (player.rank or "nyl") .. "'" + .. " c'" .. (player.class or "nyl") .. "'" ) - end + end end end function Track.GetPlayerList(unsort) - local count,start + local count, start local prefix - local ret={} - local retName={} - + local ret = {} + local retName = {} + if IsInRaid() or LT.Debug.flags.is_raid then - prefix="raid" - count=MAX_RAID_MEMBERS - start=1 + prefix = "raid" + count = MAX_RAID_MEMBERS + start = 1 elseif IsInGroup() or LT.Debug.flags.is_group then - prefix="party" - count=MAX_PARTY_MEMBERS - start=0 + prefix = "party" + count = MAX_PARTY_MEMBERS + start = 0 else - prefix="solo" - count=0 - start=0 + prefix = "solo" + count = 0 + start = 0 end if LT.Debug.on then -- safety... if LT.Debug.flags.add_players then -- player list has already been created, just return - elseif prefix == "solo" then + elseif prefix == "solo" then local name, rank, englishClass = GetPlayer("player") - if name~=nil then - local entry={ - ["name"]=name, - ["rank"]=rank, - ["class"]=englishClass, - } - tinsert(ret,entry) - retName[name]=entry + if name ~= nil then + local entry = { + ["name"] = name, + ["rank"] = rank, + ["class"] = englishClass, + } + tinsert(ret, entry) + retName[name] = entry end else local class = 0 - for index = start,count do + for index = start, count do local guildName, guildRankName, guildRankIndex, realm local id - if index>0 then - id=prefix..index + if index > 0 then + id = prefix .. index if class >= 9 then class = 1 else class = class + 1 end else - id="player" + id = "player" end -- handle name and class local name = id @@ -568,74 +571,72 @@ function Track.GetPlayerList(unsort) if index == 0 then -- get the real player info localizedClass, englishClass, classIndex = UnitClass(id) elseif class == 1 then - englishClass = "WARRIOR" + englishClass = "WARRIOR" elseif class == 2 then - englishClass = "PALADIN" + englishClass = "PALADIN" elseif class == 3 then - englishClass = "HUNTER" + englishClass = "HUNTER" elseif class == 4 then - englishClass = "ROGUE" + englishClass = "ROGUE" elseif class == 5 then - englishClass = "PRIEST" + englishClass = "PRIEST" elseif class == 6 then - englishClass = "MAGE" + englishClass = "MAGE" elseif class == 7 then - englishClass = "WARLOCK" + englishClass = "WARLOCK" elseif class == 8 then - englishClass = "DRUID" + englishClass = "DRUID" elseif class == 9 then - englishClass = "WARRIOR" + englishClass = "WARRIOR" end - + -- Guild section assume this works... :) - local rank="" - - if name~=nil then - local entry={ - ["name"]=name, - ["rank"]=rank, - ["class"]=englishClass, - } - tinsert(ret,entry) - retName[name]=entry + local rank = "" + + if name ~= nil then + local entry = { + ["name"] = name, + ["rank"] = rank, + ["class"] = englishClass, + } + tinsert(ret, entry) + retName[name] = entry OutPlayer(entry) end - end end else -- normal operation - for index = start,count do + for index = start, count do local guildName, guildRankName, guildRankIndex, realm local id - if index>0 then - id=prefix..index + if index > 0 then + id = prefix .. index else - id="player" + id = "player" end if UnitInParty(id) then local name, rank, englishClass = GetPlayer(id) - if name~=nil then - - local entry={ - ["name"]=name, - ["rank"]=rank, - ["class"]=englishClass, - } - tinsert(ret,entry) - retName[name]=entry + if name ~= nil then + local entry = { + ["name"] = name, + ["rank"] = rank, + ["class"] = englishClass, + } + tinsert(ret, entry) + retName[name] = entry OutPlayer(entry) end end end end - + if unsort then - sort(ret,function(a,b) return (a.class<b.class or (a.class==b.class and a.name < b.name)) end) + sort(ret, function(a, b) return (a.class < b.class or (a.class == b.class and a.name < b.name)) end) end - return ret,retName + return ret, retName end --[[ local @@ -652,7 +653,7 @@ function Track.GetAutoChannel() channel = "RAID" elseif IsInGroup() then channel = "PARTY" - else + else channel = "SAY" end return channel @@ -666,11 +667,12 @@ VAR: msg - string message to send OUT: None --]] function Track.AddChat(msg) - if msg~=nil and msg~="" then + if msg ~= nil and msg ~= "" then if IsInGroup() or IsInRaid() then - SendChatMessage(msg , Track.GetAutoChannel()) + SendChatMessage(msg, Track.GetAutoChannel()) else - DEFAULT_CHAT_FRAME:AddMessage(msg ,Track.DB.ColorChat.r ,Track.DB.ColorChat.g ,Track.DB.ColorChat.b ,Track.DB.ColorChat.a) + DEFAULT_CHAT_FRAME:AddMessage(msg, Track.DB.ColorChat.r, Track.DB.ColorChat.g, Track.DB.ColorChat.b, + Track.DB.ColorChat.a) end end end @@ -691,7 +693,7 @@ end --[[ local NAME: Track.ShowWindow -DESC: +DESC: - Enable buttons - Show window - Update the player list with any rolls @@ -715,7 +717,7 @@ end --[[ local NAME: Track.ResetWindow -DESC: +DESC: - Reset window to default position and size :DESC VAR: None @@ -732,8 +734,8 @@ end --[[ local NAME: Track.HideWindow -DESC: -- Hide the main tracker window +DESC: +- Hide the main tracker window :DESC VAR: None OUT: None @@ -741,42 +743,41 @@ OUT: None function Track.HideWindow() TitanPanelLootTypeMainWindow:Hide() end - + --[[ local NAME: Track.Init -DESC: +DESC: - Initialize variables -- Get last position and size of main frame +- Get last position and size of main frame - Register for needed events :DESC VAR: None OUT: None --]] function Track.Init() - -- Add color - Track.DB.ColorChat = {a=1,r=1,g=1,b=1} - Track.DB.ColorNormal = {a=1,r=1,g=1,b=1} - Track.DB.ColorCheat = {a=1,r=1,g=.8,b=.8} - Track.DB.ColorGuild = {a=1,r=.2,g=1,b=.2} - Track.DB.ColorInfo = {a=1,r=.6,g=.6,b=.6} - Track.DB.ColorScroll = {a=1,r=.8,g=.8,b=.8} - + Track.DB.ColorChat = { a = 1, r = 1, g = 1, b = 1 } + Track.DB.ColorNormal = { a = 1, r = 1, g = 1, b = 1 } + Track.DB.ColorCheat = { a = 1, r = 1, g = .8, b = .8 } + Track.DB.ColorGuild = { a = 1, r = .2, g = 1, b = .2 } + Track.DB.ColorInfo = { a = 1, r = .6, g = .6, b = .6 } + Track.DB.ColorScroll = { a = 1, r = .8, g = .8, b = .8 } + -- For now, hard code some options - Track.DB.ClearOnStart = true - Track.DB.OpenOnStart = true + Track.DB.ClearOnStart = true + Track.DB.OpenOnStart = true Track.DB.ShowNotRolled = true Track.DB.ShowGuildRank = true - Track.DB.tie_breaker = 0 + Track.DB.tie_breaker = 0 + + Track.rollArray = {} + Track.rollNames = {} - Track.rollArray = {} - Track.rollNames = {} - - Track.allRolled = false + Track.allRolled = false --- TitanPanelLootTypeMainWindow:SetMinResize(194,170) - TitanPanelLootTypeMainWindow:SetResizeBounds(225,250,225,250) + -- TitanPanelLootTypeMainWindow:SetMinResize(194,170) + TitanPanelLootTypeMainWindow:SetResizeBounds(225, 250, 225, 250) local x, y, w, h = Track.DB.X, Track.DB.Y, Track.DB.Width, Track.DB.Height if not x or not y or not w or not h then Track.SaveAnchors() @@ -789,49 +790,50 @@ function Track.Init() -- using strings from GlobalStrings.lua Track.PatternRoll = Tool.CreatePattern(RANDOM_ROLL_RESULT) - + local media = LibStub("LibSharedMedia-3.0") local newfont = media:Fetch("font", TitanPanelGetVar("FontName")) Tool.Font = newfont Tool.FontSize = TitanPanelGetVar("FontSize") - --- TitanPanelLootTypeMainWindowTitle:SetFont(Tool.Font, Tool.FontSize) + + -- TitanPanelLootTypeMainWindowTitle:SetFont(Tool.Font, Tool.FontSize) TitanPanelLootTypeMainWindowTitle:SetText( - string.format(Track.TxtEscapePicture,Track.IconDice) - .." "..Track.MSGPREFIX - ) + string.format(Track.TxtEscapePicture, Track.IconDice) + .. " " .. Track.MSGPREFIX + ) Tool.SetButtonFont(TitanPanelLootTypeFrameRollButton) -- sets all buttons... - - TitanPanelLootTypeFrameRollButton:SetText(string.format(Track.TxtEscapePicture,Track.IconDice).. L["TITAN_LOOTTYPE_TRACKER_BTNROLL"]) - TitanPanelLootTypeFramePassButton:SetText(string.format(Track.TxtEscapePicture,Track.IconPass)..L["TITAN_LOOTTYPE_TRACKER_BTNPASS"]) - + + TitanPanelLootTypeFrameRollButton:SetText(string.format(Track.TxtEscapePicture, Track.IconDice) .. + L["TITAN_LOOTTYPE_TRACKER_BTNROLL"]) + TitanPanelLootTypeFramePassButton:SetText(string.format(Track.TxtEscapePicture, Track.IconPass) .. + L["TITAN_LOOTTYPE_TRACKER_BTNPASS"]) + TitanPanelLootTypeFrameAnnounceButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNANNOUNCE"]) TitanPanelLootTypeFrameNotRolledButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNNOTROLLED"]) TitanPanelLootType.ResizeButtons() - TitanPanelLootTypeFrameClearButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNCLEAR"]) + TitanPanelLootTypeFrameClearButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNCLEAR"]) - Tool.EnableSize (TitanPanelLootTypeMainWindow, 8, nil, Track.SaveAnchors) - Tool.EnableMoving (TitanPanelLootTypeMainWindow, Track.SaveAnchors) + Tool.EnableSize(TitanPanelLootTypeMainWindow, 8, nil, Track.SaveAnchors) + Tool.EnableMoving(TitanPanelLootTypeMainWindow, Track.SaveAnchors) TitanPanelLootTypeFrame:Show() local str = ".Init" - .." register for events" - LootDebug (str, "events") + .. " register for events" + LootDebug(str, "events") -- Should be ready for events we are interested in - TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_SYSTEM", TitanPanelLootTypeButton_OnEvent) - - TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_PARTY", TitanPanelLootTypeButton_OnEvent) - TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_PARTY_LEADER", TitanPanelLootTypeButton_OnEvent) - TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_RAID", TitanPanelLootTypeButton_OnEvent) - TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_RAID_LEADER", TitanPanelLootTypeButton_OnEvent) + TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_SYSTEM", TitanPanelLootTypeButton_OnEvent) + TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_PARTY", TitanPanelLootTypeButton_OnEvent) + TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_PARTY_LEADER", TitanPanelLootTypeButton_OnEvent) + TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_RAID", TitanPanelLootTypeButton_OnEvent) + TitanPanelLootTypeButton:RegisterEvent("CHAT_MSG_RAID_LEADER", TitanPanelLootTypeButton_OnEvent) end --[[ local NAME: Track.Close -DESC: -- Stop the -- Get last position and size of main frame +DESC: +- Stop the +- Get last position and size of main frame - Register for needed events :DESC VAR: None @@ -847,28 +849,28 @@ end --[[ local NAME: Track.Event_CHAT_MSG_SYSTEM -DESC: +DESC: - Monitor system chat for player rolls; add the roll when one is found :DESC VAR: arg1 - the message sent OUT: None --]] -function Track.Event_CHAT_MSG_SYSTEM (arg1) +function Track.Event_CHAT_MSG_SYSTEM(arg1) local str = "Event_CHAT_MSG_SYSTEM" - .." m'"..tostring(arg1).."'" - LootDebug (str, "events") + .. " m'" .. tostring(arg1) .. "'" + LootDebug(str, "events") - if Track.DB.RollInProcess then + if Track.DB.RollInProcess then for name, roll, low, high in string.gmatch(arg1, Track.PatternRoll) do --print(".."..name.." "..roll.." "..low.." "..high) - Track.AddRoll(name,roll,low,high) + Track.AddRoll(name, roll, low, high) end end end --[[ local NAME: Track.Event_Generic_CHAT_MSG -DESC: +DESC: - Monitor general chat for: - a pass ('pass' or localized version) - Roll start @@ -878,47 +880,46 @@ VAR: msg - the message sent VAR: name - player that sent the message OUT: None --]] -function Track.Event_Generic_CHAT_MSG(msg,name) +function Track.Event_Generic_CHAT_MSG(msg, name) local str = "Event_Generic_CHAT_MSG" - .." '"..tostring(name).."'" - .." m'"..tostring(roll).."'" - LootDebug (str, "events") + .. " '" .. tostring(name) .. "'" + .. " m'" .. tostring(msg) .. "'" + LootDebug(str, "events") -- prevent 'random' rolls from popping windows - if Track.DB.RollInProcess then + if Track.DB.RollInProcess then if msg == L["TITAN_LOOTTYPE_TRACKER_TEXTPASS"] or msg == "pass" then - name=Tool.Split(name, "-")[1] - Track.AddRoll(name,"0","1","100") - end - end - + name = Tool.Split(name, "-")[1] + Track.AddRoll(name, "0", "1", "100") + end + end + -- Assume a 'leader' requested a roll so pop the window - if string.sub(msg,1,string.len(Track.MSGPREFIX_START))==Track.MSGPREFIX_START then + if string.sub(msg, 1, string.len(Track.MSGPREFIX_START)) == Track.MSGPREFIX_START then Track.DB.RollInProcess = true - if Track.DB.ClearOnStart then + if Track.DB.ClearOnStart then Track.ClearRolls() end - if Track.DB.OpenOnStart then + if Track.DB.OpenOnStart then Track.ShowWindow() end - end + end -- Check for the 'end' of the roll - if string.sub(msg,1,string.len(Track.MSGPREFIX_END))==Track.MSGPREFIX_END then + if string.sub(msg, 1, string.len(Track.MSGPREFIX_END)) == Track.MSGPREFIX_END then Track.DB.RollInProcess = false - if Track.DB.ClearOnStart then + if Track.DB.ClearOnStart then Track.ClearRolls() end end -- Check for the 'close' of the roll - if string.sub(msg,1,string.len(Track.MSGPREFIX_CLOSE))==Track.MSGPREFIX_CLOSE then + if string.sub(msg, 1, string.len(Track.MSGPREFIX_CLOSE)) == Track.MSGPREFIX_CLOSE then Track.Close() end - end --[[ local NAME: Track.AddRoll -DESC: +DESC: Process the roll the player made - A pass has a roll of "0" - Only the first roll is marked as valid / invalid @@ -932,13 +933,13 @@ VAR: low - low value player used - string VAR: high - high player used - string OUT: None --]] -function Track.AddRoll(name,roll,low,high) +function Track.AddRoll(name, roll, low, high) local act = "nyl" local valid = false - - local valid_ro, valid_bounds, ro, lo, hi = IsRoll(roll,low,high) -- numeric - if Track.rollNames[name]==nil then - Track.DB.tie_breaker = Track.DB.tie_breaker + 1 -- only count the first roll for each player + + local valid_ro, valid_bounds, ro, lo, hi = IsRoll(roll, low, high) -- numeric + if Track.rollNames[name] == nil then + Track.DB.tie_breaker = Track.DB.tie_breaker + 1 -- only count the first roll for each player act = "insert" Track.rollNames[name] = Track.rollNames[name] and Track.rollNames[name] + 1 or 1 -- mark player as having rolled table.insert(Track.rollArray, { @@ -952,29 +953,30 @@ function Track.AddRoll(name,roll,low,high) Valid_bounds = valid_bounds, }) local str = "AddRoll >>" - .." '"..tostring(act).."'" - .." '"..tostring(name).."'" - .." r'"..tostring(roll).."'" - .." l'"..tostring(low).."'" - .." h'"..tostring(high).."'" - .." #'"..tostring(Track.rollNames[name]).."'" - LootDebug (str, "players") + .. " '" .. tostring(act) .. "'" + .. " '" .. tostring(name) .. "'" + .. " r'" .. tostring(roll) .. "'" + .. " l'" .. tostring(low) .. "'" + .. " h'" .. tostring(high) .. "'" + .. " #'" .. tostring(Track.rollNames[name]) .. "'" + LootDebug(str, "players") else -- check for re-rolls. >1 if rolled before act = "update" - Track.rollNames[name] = Track.rollNames[name] and Track.rollNames[name] + 1 or 1 -- mark player as having rolled again - for i,p in ipairs(Track.rollArray) do + Track.rollNames[name] = Track.rollNames[name] and Track.rollNames[name] + 1 or + 1 -- mark player as having rolled again + for i, p in ipairs(Track.rollArray) do if p.Name == name then -- Only first roll is valid, Ignore additional rolls but count them for display p.Count = Track.rollNames[name] local str = "AddRoll >>" - .." '"..tostring(act).."'" - .." '"..tostring(name).."'" - .." r'"..tostring(roll).."'" - .." l*'"..tostring(low).."'" - .." h*'"..tostring(high).."'" - .." #*'"..tostring(Track.rollNames[name]).."'" - LootDebug (str, "players") + .. " '" .. tostring(act) .. "'" + .. " '" .. tostring(name) .. "'" + .. " r'" .. tostring(roll) .. "'" + .. " l*'" .. tostring(low) .. "'" + .. " h*'" .. tostring(high) .. "'" + .. " #*'" .. tostring(Track.rollNames[name]) .. "'" + LootDebug(str, "players") end end end @@ -983,7 +985,7 @@ end --[[ local NAME: Track.SortRolls -DESC: +DESC: Sort ascending by name then place :DESC VAR: a - player a roll info @@ -991,7 +993,7 @@ VAR: b - player b roll info OUT: true / false --]] function Track.SortRolls(a, b) --- return a.Roll < b.Roll + -- return a.Roll < b.Roll if a.Roll ~= b.Roll then return a.Roll < b.Roll elseif a.Roll == b.Roll then @@ -1001,7 +1003,7 @@ end --[[ local NAME: Track.SortRollsRev -DESC: +DESC: Sort descending by name then place :DESC VAR: a - player a roll info @@ -1009,7 +1011,7 @@ VAR: b - player b roll info OUT: true / false --]] function Track.SortRollsRev(a, b) --- return a.Roll > b.Roll + -- return a.Roll > b.Roll if a.Roll ~= b.Roll then return a.Roll > b.Roll elseif a.Roll == b.Roll then @@ -1019,7 +1021,7 @@ end --[[ local NAME: Track.FormatRollText -DESC: +DESC: Format the given roll for display :DESC VAR: roll - numeric @@ -1028,43 +1030,42 @@ VAR: partyName - given player list entry OUT: String to use --]] function Track.FormatRollText(roll, party, partyName) - local colorTied= Tool.RGBtoEscape(Track.DB.ColorNormal) - local colorCheat=((roll.Low ~= 1 or roll.High ~= 100) + local colorTied = Tool.RGBtoEscape(Track.DB.ColorNormal) + local colorCheat = ((roll.Low ~= 1 or roll.High ~= 100) or (roll.Count > 1)) and Tool.RGBtoEscape(Track.DB.ColorCheat) or colorTied - local txtRange=(not roll.Valid_bounds) and format(" (%d-%d)", roll.Low, roll.High) or "" - + local txtRange = (not roll.Valid_bounds) and format(" (%d-%d)", roll.Low, roll.High) or "" + local colorName local iconClass - local colorRank=Tool.RGBtoEscape(Track.DB.ColorGuild) - local rank="" - + local colorRank = Tool.RGBtoEscape(Track.DB.ColorGuild) + local rank = "" + if partyName[roll.Name] and partyName[roll.Name].class then - colorName="|c"..RAID_CLASS_COLORS[partyName[roll.Name].class].colorStr - iconClass=Tool.IconClass[partyName[roll.Name].class] + colorName = "|c" .. RAID_CLASS_COLORS[partyName[roll.Name].class].colorStr + iconClass = Tool.IconClass[partyName[roll.Name].class] end - if colorName==nil or Track.DB.ColorName==false then colorName=colorCheat end - if iconClass==nil or Track.DB.ShowClassIcon==false then iconClass="" end - if Track.DB.ColorName==false then colorRank=colorCheat end - + if colorName == nil or Track.DB.ColorName == false then colorName = colorCheat end + if iconClass == nil or Track.DB.ShowClassIcon == false then iconClass = "" end + if Track.DB.ColorName == false then colorRank = colorCheat end + if Track.DB.ShowGuildRank and partyName[roll.Name] and partyName[roll.Name].rank then - rank=" "..partyName[roll.Name].rank + rank = " " .. partyName[roll.Name].rank end - - local txtCount=roll.Count > 1 and format(" [%d]", roll.Count) or "" - - return "|Hplayer:"..roll.Name.."|h".. - string.format("%3d",roll.Roll)..": ".. - iconClass..colorName.. roll.Name ..colorRank.. rank.."|r ".. - colorCheat..txtRange.."|r ".. - colorCheat..txtCount.."|h".. --- colorCheat..roll.Place.."|h".. - "\n" + local txtCount = roll.Count > 1 and format(" [%d]", roll.Count) or "" + + return "|Hplayer:" .. roll.Name .. "|h" .. + string.format("%3d", roll.Roll) .. ": " .. + iconClass .. colorName .. roll.Name .. colorRank .. rank .. "|r " .. + colorCheat .. txtRange .. "|r " .. + colorCheat .. txtCount .. "|h" .. + -- colorCheat..roll.Place.."|h".. + "\n" end --[[ local NAME: Track.UpdateRollList -DESC: +DESC: Create the player list for display including rolls, 'cheats', guild rank (if in same guild) Rolls are above the line; no rolls yet are below the line :DESC @@ -1073,93 +1074,95 @@ OUT: None --]] function Track.UpdateRollList() local rollText = "" - - local party,partyName = Track.GetPlayerList() - + + local party, partyName = Track.GetPlayerList() + table.sort(Track.rollArray, Track.SortRolls) - + -- format and print rolls, check for ties for i, roll in pairs(Track.rollArray) do - rollText=Track.FormatRollText(roll,party,partyName) .. rollText + rollText = Track.FormatRollText(roll, party, partyName) .. rollText end --if IsInGroup() or IsInRaid() then - rollText = rollText.. Tool.RGBtoEscape(Track.DB.ColorInfo) .. L["TITAN_LOOTTYPE_TRACKER_TXTLINE"] .. "\n" - local gtxt=Tool.RGBtoEscape(Track.DB.ColorInfo) - local missClasses={} - allRolled=true - for i,p in ipairs(party) do - if Track.rollNames[p.name]==nil or Track.rollNames[p.name]==0 then - local iconClass=Tool.IconClass[partyName[p.name].class] - local rank="" - if iconClass==nil or Track.DB.ShowClassIcon==false then - iconClass="" + rollText = rollText .. Tool.RGBtoEscape(Track.DB.ColorInfo) .. L["TITAN_LOOTTYPE_TRACKER_TXTLINE"] .. "\n" + local gtxt = Tool.RGBtoEscape(Track.DB.ColorInfo) + local missClasses = {} + Track.allRolled = true + for i, p in ipairs(party) do + if Track.rollNames[p.name] == nil or Track.rollNames[p.name] == 0 then + local iconClass = Tool.IconClass[partyName[p.name].class] + local rank = "" + if iconClass == nil or Track.DB.ShowClassIcon == false then + iconClass = "" else - missClasses[partyName[p.name].class]=missClasses[partyName[p.name].class] and missClasses[partyName[p.name].class]+1 or 1 + missClasses[partyName[p.name].class] = missClasses[partyName[p.name].class] and + missClasses[partyName[p.name].class] + 1 or 1 end if Track.DB.ShowGuildRank and partyName[p.name] and partyName[p.name].rank then - rank=" "..partyName[p.name].rank + rank = " " .. partyName[p.name].rank end - gtxt = gtxt.. "|Hplayer:"..p.name.."|h".. iconClass .. p.name ..rank .."|h\n" - allRolled=false + gtxt = gtxt .. "|Hplayer:" .. p.name .. "|h" .. iconClass .. p.name .. rank .. "|h\n" + Track.allRolled = false end end - local ctxt="" - if IsInRaid() then - local isHorde=(UnitFactionGroup("player"))=="Horde" - for i,class in pairs (Tool.Classes) do - --for class,count in pairs(missClasses) do - if not(isHorde and class=="PALADIN") and not(not isHorde and class=="SHAMAN") then - ctxt=ctxt..Tool.IconClass[class]..(missClasses[class] or 0).." " + local ctxt = "" + if IsInRaid() then + local isHorde = (UnitFactionGroup("player")) == "Horde" + for i, class in pairs(Tool.Classes) do + --for class,count in pairs(missClasses) do + if not (isHorde and class == "PALADIN") and not (not isHorde and class == "SHAMAN") then + ctxt = ctxt .. Tool.IconClass[class] .. (missClasses[class] or 0) .. " " end end - if ctxt~="" then ctxt=ctxt.."\n" .. L["TxtLine"] .. "\n" end + if ctxt ~= "" then ctxt = ctxt .. "\n" .. L["TxtLine"] .. "\n" end end - if LT.Debug.on then -- - TitanDebug("UpdateRollList" - .." '"..(rollText or "nyl").."'" - .." '"..(ctxt or "nyl").."'" - .." '"..(gtxt or "nyl").."'" - ) + if LT.Debug.on then -- + TitanPluginDebug("UpdateRollList" + .. " '" .. (rollText or "nyl") .. "'" + .. " '" .. (ctxt or "nyl") .. "'" + .. " '" .. (gtxt or "nyl") .. "'" + ) end - - rollText=rollText..ctxt..gtxt - LootDebug (rollText, "rolls") - + + rollText = rollText .. ctxt .. gtxt + LootDebug(rollText, "rolls") + --end - --- RollTrackerRollText:SetFont(Tool.Font, Tool.FontSize) + + -- RollTrackerRollText:SetFont(Tool.Font, Tool.FontSize) RollTrackerRollText:SetText(rollText) - --- TitanPanelLootTypeFrameStatusText:SetFont(Tool.Font, Tool.FontSize) - TitanPanelLootTypeFrameStatusText:SetText(string.format(L["TITAN_LOOTTYPE_TRACKER_MSGNBROLLS"], table.getn(Track.rollArray))) --- TitanPanelLootTypeFrameClearButton:SetFont(Tool.Font, Tool.FontSize) + -- TitanPanelLootTypeFrameStatusText:SetFont(Tool.Font, Tool.FontSize) + TitanPanelLootTypeFrameStatusText:SetText(string.format(L["TITAN_LOOTTYPE_TRACKER_MSGNBROLLS"], + table.getn(Track.rollArray))) + + -- TitanPanelLootTypeFrameClearButton:SetFont(Tool.Font, Tool.FontSize) TitanPanelLootTypeFrameClearButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNCLEAR"]) end --[[ local NAME: Track.ClearRolls -DESC: +DESC: Clear the player list of any rolls rolls :DESC VAR: None OUT: None --]] function Track.ClearRolls() - if #Track.rollArray>0 then + if #Track.rollArray > 0 then Track.rollArray = {} - Track.rollNames = {} + Track.rollNames = {} end - + Track.DB.tie_breaker = 0 Track.UpdateRollList() end --[[ local NAME: Track.NotRolled -DESC: +DESC: - Send a nag message via whisper to players who have not rolled - Send a message to group that reminders were sent - Only an IsLead can do this! @@ -1167,28 +1170,29 @@ DESC: VAR: None OUT: None --]] -function Track.NotRolled () +function Track.NotRolled() if IsLead() then - local party,partyName = Track.GetPlayerList() - local names="" - + local party, partyName = Track.GetPlayerList() + local names = "" + local group = "" if IsInRaid() then group = L["TITAN_LOOTTYPE_TRACKER_RAIDPASS"] elseif IsInGroup() then group = L["TITAN_LOOTTYPE_TRACKER_PARTYPASS"] - else + else group = "" end - for i,p in ipairs(party) do - if Track.rollNames[p.name]==nil or Track.rollNames[p.name]==0 then - SendChatMessage(Track.MSGPREFIX .. L["TITAN_LOOTTYPE_TRACKER_NOTROLLEDNAG"]..group, WHISPER, nil, p.name) + for i, p in ipairs(party) do + if Track.rollNames[p.name] == nil or Track.rollNames[p.name] == 0 then + SendChatMessage(Track.MSGPREFIX .. L["TITAN_LOOTTYPE_TRACKER_NOTROLLEDNAG"] .. group, WHISPER, nil, + p.name) names = "send" end end - - if names == "send" then + + if names == "send" then Track.AddChat(Track.MSGPREFIX .. L["TITAN_LOOTTYPE_TRACKER_MSGNOTROLLED"]) end end @@ -1196,7 +1200,7 @@ end --[[ local NAME: Track.StartRoll -DESC: +DESC: - Pop the main frame - Clear all rolls for a new set - Start a new roll process @@ -1206,17 +1210,18 @@ DESC: VAR: None OUT: None --]] -function Track.StartRoll () +function Track.StartRoll() Track.ShowWindow() Track.ClearRolls() Track.DB.RollInProcess = true - Track.AddChat(Track.MSGPREFIX_START .. "{circle} "..string.format(L["TITAN_LOOTTYPE_TRACKER_MSGSTART"],L["TITAN_LOOTTYPE_TRACKER_TEXTPASS"])) + Track.AddChat(Track.MSGPREFIX_START .. + "{circle} " .. string.format(L["TITAN_LOOTTYPE_TRACKER_MSGSTART"], L["TITAN_LOOTTYPE_TRACKER_TEXTPASS"])) Track.AddChat(L["TITAN_LOOTTYPE_TRACKER_MSGBAR"]) -end +end --[[ local NAME: Track.RollAnnounce -DESC: +DESC: - Send a message to the group of the winner - Stop the roll process so new rolls are not processed - Only an IsLead can do this! @@ -1225,55 +1230,56 @@ VAR: None OUT: None --]] function Track.RollAnnounce() - local winName="" + local winName = "" local winRoll = 0 - local addPrefix="" - local msg="" - local list={} - + local addPrefix = "" + local msg = "" + local list = {} + table.sort(Track.rollArray, Track.SortRollsRev) - + for i, roll in pairs(Track.rollArray) do local str = "AddRoll >>" - .." '"..roll.Name.."'" - .." r'"..tostring(roll.Roll).."'" - LootDebug (str, "players") + .. " '" .. roll.Name .. "'" + .. " r'" .. tostring(roll.Roll) .. "'" + LootDebug(str, "players") if roll.Valid_roll then - winName= roll.Name - winRoll= roll.Roll - break -- sort breaks ties, grab first one + winName = roll.Name + winRoll = roll.Roll + break -- sort breaks ties, grab first one end end - - if winName == "" then - msg= Track.MSGPREFIX_END .. addPrefix .. "{circle} No winners" + + if winName == "" then + msg = Track.MSGPREFIX_END .. addPrefix .. "{circle} No winners" else - msg= Track.MSGPREFIX_END .. addPrefix .. "{circle} ".. string.format(L["TITAN_LOOTTYPE_TRACKER_MSGANNOUNCE"] ,winName, winRoll) + msg = Track.MSGPREFIX_END .. + addPrefix .. "{circle} " .. string.format(L["TITAN_LOOTTYPE_TRACKER_MSGANNOUNCE"], winName, winRoll) end - + Track.AddChat(msg) - + Track.DB.RollInProcess = false end --[[ TitanPanelLootType NAME: TitanPanelLootType.ResizeButtons DESC: Determine the size of the buttons so they fill the line on the main frame. -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.ResizeButtons() local w = TitanPanelLootTypeFrameHelperButton:GetWidth() - TitanPanelLootTypeFrameRollButton:SetWidth(w/2) - TitanPanelLootTypeFramePassButton:SetWidth(w/2) - + TitanPanelLootTypeFrameRollButton:SetWidth(w / 2) + TitanPanelLootTypeFramePassButton:SetWidth(w / 2) + if Track.DB.ShowNotRolled then - TitanPanelLootTypeFrameAnnounceButton:SetWidth(w/3) - TitanPanelLootTypeFrameClearButton:SetWidth(w/3) + TitanPanelLootTypeFrameAnnounceButton:SetWidth(w / 3) + TitanPanelLootTypeFrameClearButton:SetWidth(w / 3) TitanPanelLootTypeFrameNotRolledButton:Show() else - TitanPanelLootTypeFrameAnnounceButton:SetWidth(w/2) - TitanPanelLootTypeFrameClearButton:SetWidth(w/2) + TitanPanelLootTypeFrameAnnounceButton:SetWidth(w / 2) + TitanPanelLootTypeFrameClearButton:SetWidth(w / 2) TitanPanelLootTypeFrameNotRolledButton:Hide() end end @@ -1282,21 +1288,21 @@ end NAME: TitanPanelLootType.BtnClose DESC: On click of the main frame 'X': Close the main frame; clear rolls; end current roll process -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnClose() Track.Close() - + if IsLead() then - Track.AddChat(Track.MSGPREFIX_CLOSE..L["TITAN_LOOTTYPE_TRACKER_MSGCLOSING"]) + Track.AddChat(Track.MSGPREFIX_CLOSE .. L["TITAN_LOOTTYPE_TRACKER_MSGCLOSING"]) end end --[[ TitanPanelLootType NAME: TitanPanelLootType.BtnRoll DESC: On click of the main frame Roll: Send the roll to be processed -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnRoll() @@ -1306,12 +1312,12 @@ end --[[ TitanPanelLootType NAME: TitanPanelLootType.BtnPass DESC: On click of the main frame Pass: Send the pass to be processed -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnPass() Track.AddChat(L["TITAN_LOOTTYPE_TRACKER_TEXTPASS"]) - --[[ + --[[ Note: When in solo debug mode, this just does a /say pass which is NOT picked up by an event. This only monitors party & raid chat... --]] @@ -1322,14 +1328,14 @@ NAME: TitanPanelLootType.BtnClearRolls DESC: On click of the main frame Clear: - Clear all rolls - Start a new roll process -- Only an IsLead can do this! +- Only an IsLead can do this! This handled by enable / disable of buttons when the main frame is created. :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnClearRolls() - if #Track.rollArray>0 then + if #Track.rollArray > 0 then Track.ClearRolls() if Track.DB.CloseOnClear then Track.HideWindow() @@ -1345,7 +1351,7 @@ DESC: On click of the main frame "start": - Only an IsLead can do this! This handled by enable / disable of buttons when the main frame is created. :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnAnnounce(button) @@ -1365,7 +1371,7 @@ DESC: On click of the main frame "remind": - Only an IsLead can do this! This handled by enable / disable of buttons when the main frame is created. :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootType.BtnNotRolled() @@ -1374,28 +1380,28 @@ end -- Debug!!! function TitanPanelLootType.AddAllRollsDebug() -- rolls for all players - local party,partyName = Track.GetPlayerList() - + local party, partyName = Track.GetPlayerList() + -- walk the player list, adding rolls - for i,p in ipairs(party) do + for i, p in ipairs(party) do -- 0 (zero) allows a 'pass' - Track.AddRoll(p.name, tostring(random(0,100)), "1", "100") + Track.AddRoll(p.name, tostring(random(0, 100)), "1", "100") end -- Now show the results Track.UpdateRollList() end + function TitanPanelLootType.AddRollDebug(...) -- single roll Track.AddRoll(...) end - --[[ TitanPanelLootType NAME: TitanPanelLootTypeButton_OnLoad DESC: On load of this addon: - Get Titan registry values - Get addon saved variable values :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootTypeButton_OnLoad(self) @@ -1422,36 +1428,29 @@ function TitanPanelLootTypeButton_OnLoad(self) RandomRoll = 100, DB = {}, DisplayOnRightSide = false, --- ShowDungeonDiff = false, --- DungeonDiffType = "AUTO", + -- ShowDungeonDiff = false, + -- DungeonDiffType = "AUTO", } }; - self:RegisterEvent("PLAYER_ENTERING_WORLD", TitanPanelLootTypeButton_OnEvent) + self:RegisterEvent("PLAYER_ENTERING_WORLD", TitanPanelLootTypeButton_OnEvent) self:RegisterEvent("GROUP_ROSTER_UPDATE"); self:RegisterEvent("RAID_ROSTER_UPDATE"); self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED"); self:RegisterEvent("CHAT_MSG_SYSTEM"); - - if not TitanLootTypeSaved then -- first time or clean install - Track.DB = {} - else - Track.DB = TitanLootTypeSaved - end end --[[ TitanPanelLootType NAME: TitanPanelLootTypeButton_OnEvent DESC: Parse events registered to plugin and act on them -VAR: None +VAR: None OUT: None --]] function TitanPanelLootTypeButton_OnEvent(self, event, ...) - - LootDebug (event, "events") -- could generate a lot of messages... + LootDebug(event, "events") -- could generate a lot of messages... if (event == "CHAT_MSG_SYSTEM") then - Track.Event_CHAT_MSG_SYSTEM (...) + Track.Event_CHAT_MSG_SYSTEM(...) end if (event == "CHAT_MSG_PARTY") then @@ -1480,13 +1479,13 @@ end --[[ TitanPanelLootType NAME: TitanPanelLootTypeButton_GetButtonText DESC: Determine loot type and then display on button -VAR: None +VAR: None OUT: None --]] function TitanPanelLootTypeButton_GetButtonText(id) local lootTypeText, lootThreshold, color --- if (GetNumSubgroupMembers() > 0) or (GetNumGroupMembers() > 0) then + -- if (GetNumSubgroupMembers() > 0) or (GetNumGroupMembers() > 0) then if IsInRaid() or IsInGroup() then lootTypeText = TitanLootMethod[GetLootMethod()].text; @@ -1501,37 +1500,37 @@ end --[[ TitanPanelLootType NAME: TitanPanelLootTypeButton_GetTooltipText -DESC: +DESC: Prepare the tool tip text. The tool tip is determined by whether the player is in a group or not. :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootTypeButton_GetTooltipText() --- if (GetNumSubgroupMembers() > 0) or (GetNumGroupMembers() > 0) then + -- if (GetNumSubgroupMembers() > 0) or (GetNumGroupMembers() > 0) then if IsInRaid() or IsInGroup() then local lootTypeText = TitanLootMethod[GetLootMethod()].text; local lootThreshold = GetLootThreshold(); - local itemQualityDesc = _G["ITEM_QUALITY"..lootThreshold.."_DESC"]; + local itemQualityDesc = _G["ITEM_QUALITY" .. lootThreshold .. "_DESC"]; local color = _G["ITEM_QUALITY_COLORS"][lootThreshold]; - return "".. - _G["LOOT_METHOD"]..": \t"..TitanUtils_GetHighlightText(lootTypeText).."\n".. - _G["LOOT_THRESHOLD"]..": \t"..TitanUtils_GetColoredText(itemQualityDesc, color).."\n".. - TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT1"]).."\n" --- ..TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT2"]) + return "" .. + _G["LOOT_METHOD"] .. ": \t" .. TitanUtils_GetHighlightText(lootTypeText) .. "\n" .. + _G["LOOT_THRESHOLD"] .. ": \t" .. TitanUtils_GetColoredText(itemQualityDesc, color) .. "\n" .. + TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT1"]) .. "\n" + -- ..TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT2"]) else return --TitanUtils_GetNormalText(_G["ERR_NOT_IN_GROUP"]).."\n".. - TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT1"]).."\n" --- TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT2"]); + TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT1"]) .. "\n" + -- TitanUtils_GetGreenText(L["TITAN_LOOTTYPE_TOOLTIP_HINT2"]); end end --[[ TitanPanelLootType NAME: TitanPanelRightClickMenu_PrepareLootTypeMenu -DESC: +DESC: Display rightclick menu options. :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelRightClickMenu_PrepareLootTypeMenu() @@ -1550,13 +1549,13 @@ end --[[ TitanPanelLootType NAME: TitanPanelLootTypeButton_OnClick -DESC: +DESC: On left click: If isLead then start a new roll If not isLead then do a roll :DESC -VAR: None +VAR: None OUT: None --]] function TitanPanelLootTypeButton_OnClick(self, button) diff --git a/TitanLootType/TitanLootType.lua b/TitanLootType/TitanLootType.lua index 32c11c0..20b02d6 100644 --- a/TitanLootType/TitanLootType.lua +++ b/TitanLootType/TitanLootType.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanLootType.lua @@ -9,6 +10,7 @@ -- ******************************** Constants ******************************* local TITAN_LOOTTYPE_ID = "LootType"; local TITAN_BUTTON = "TitanPanel"..TITAN_LOOTTYPE_ID.."Button" + local _G = getfenv(0); local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local TitanLootMethod = {}; @@ -201,7 +203,7 @@ function TitanPanelLootTypeButton_GetButtonText(id) current_spec = name -- for tool tip -- Determine loot spec - local loot_label = (LOOT.." "..SPECIALIZATION or "Loot Spec")..": " + local loot_label = ((LOOT.." "..SPECIALIZATION) or "Loot Spec")..": " local loot_spec = GetLootSpecialization() if loot_spec == 0 then -- 0 means current spec else -- Id means user has set diff --git a/TitanLootType/TitanLootType_Mainline.toc b/TitanLootType/TitanLootType_Mainline.toc index c86a381..3fbee4a 100644 --- a/TitanLootType/TitanLootType_Mainline.toc +++ b/TitanLootType/TitanLootType_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.00.0|r -## Version: 8.0.5 +## Version: 8.0.6 ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLootType/TitanLootType_Vanilla.toc b/TitanLootType/TitanLootType_Vanilla.toc index 033cd39..82844e6 100644 --- a/TitanLootType/TitanLootType_Vanilla.toc +++ b/TitanLootType/TitanLootType_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: TitanClassicLootTypeSaved diff --git a/TitanLootType/TitanLootType_Wrath.toc b/TitanLootType/TitanLootType_Wrath.toc index 9a044b1..1604951 100644 --- a/TitanLootType/TitanLootType_Wrath.toc +++ b/TitanLootType/TitanLootType_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: TitanClassicLootTypeSaved diff --git a/TitanPerformance/TitanPerformance.lua b/TitanPerformance/TitanPerformance.lua index 62efe64..8cfb84c 100644 --- a/TitanPerformance/TitanPerformance.lua +++ b/TitanPerformance/TitanPerformance.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field -- ************************************************************************** -- * TitanPerformance.lua -- * @@ -7,22 +8,31 @@ -- ******************************** Constants ******************************* local TITAN_PERFORMANCE_ID = "Performance"; local TITAN_BUTTON = "TitanPanel"..TITAN_PERFORMANCE_ID.."Button" + local TITAN_PERF_FRAME_SHOW_TIME = 0.5; local updateTable = {TITAN_PERFORMANCE_ID, TITAN_PANEL_UPDATE_ALL}; local APP_MIN = 1 local APP_MAX = 40 +---@diagnostic disable-next-line: deprecated +local NumAddons = C_AddOns.GetNumAddOns or GetNumAddOns +---@diagnostic disable-next-line: deprecated +local AddOnInfo = C_AddOns.GetAddOnInfo or GetAddOnInfo +---@diagnostic disable-next-line: deprecated +local IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded local TITAN_FPS_THRESHOLD_TABLE = { Values = { 20, 30 }, Colors = { RED_FONT_COLOR, NORMAL_FONT_COLOR, GREEN_FONT_COLOR }, } + -- #1369 - PERFORMANCEBAR_LOW_LATENCY, PERFORMANCEBAR_MEDIUM_LATENCY no longer defined by WoW local TITAN_LATENCY_THRESHOLD_TABLE = { Values = { 300, 600 }, Colors = { GREEN_FONT_COLOR, NORMAL_FONT_COLOR, RED_FONT_COLOR }, } + local TITAN_MEMORY_RATE_THRESHOLD_TABLE = { Values = { 1, 2 }, Colors = { GREEN_FONT_COLOR, NORMAL_FONT_COLOR, RED_FONT_COLOR }, @@ -33,9 +43,9 @@ local _G = getfenv(0); local topAddOns; local memUsageSinceGC = {}; local counter = 1; --counter for active addons -local L = {} -- For AceLocale -local AceTimer = {} -local PerfTimer = nil; +local AceTimer = LibStub("AceTimer-3.0") +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +local PerfTimer = {} -- ******************************** Functions ******************************* local function CalcAppNum(val) local new_val = 1 -- always monitor at least one @@ -48,204 +58,13 @@ local function CalcAppNum(val) end return new_val end --- ************************************************************************** --- NAME : TitanPanelPerformanceButton_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** -function TitanPanelPerformanceButton_OnLoad(self) - local notes = "" - .."Adds FPS (Frames Per Second) and Garbage collection information to Titan Panel.\n" --- .."- xxx.\n" - self.registry = { - id = TITAN_PERFORMANCE_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_PERFORMANCE_MENU_TEXT"], - buttonTextFunction = "TitanPanelPerformanceButton_GetButtonText"; - tooltipCustomFunction = TitanPanelPerformanceButton_SetTooltip; - icon = "Interface\\AddOns\\TitanPerformance\\TitanPerformance", - iconWidth = 16, - notes = notes, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = true, - DisplayOnRightSide = true, - }, - savedVariables = { - ShowFPS = 1, - ShowLatency = 1, - ShowWorldLatency = 1, - ShowMemory = 1, - ShowAddonMemory = false, - ShowAddonIncRate = false, - NumOfAddons = 5, - AddonMemoryType = 1, - ShowIcon = 1, - ShowLabelText = false, - ShowColoredText = 1, - DisplayOnRightSide = false, - } - }; - - self.fpsSampleCount = 0; - self:RegisterEvent("PLAYER_ENTERING_WORLD"); -end - -function TitanPanelPerformanceButton_OnShow() - if not PerfTimer then - PerfTimer = AceTimer.ScheduleRepeatingTimer("TitanPanelPerformance", TitanPanelPerformanceButtonHandle_OnUpdate, 1.5 ) - end -end - -function TitanPanelPerformanceButton_OnHide() - AceTimer.CancelTimer("TitanPanelPerformance", PerfTimer, true) - PerfTimer = nil; -end - --- ************************************************************************** --- NAME : TitanPanelPerformanceButton_OnUpdate(elapsed) --- DESC : Update button data --- VARS : elapsed = <research> --- ************************************************************************** -function TitanPanelPerformanceButtonHandle_OnUpdate() - TitanPanelPluginHandle_OnUpdate(updateTable); - if not (TitanPanelRightClickMenu_IsVisible()) and _G["TitanPanelPerfControlFrame"]:IsVisible() and not (MouseIsOver(_G["TitanPanelPerfControlFrame"])) then - _G["TitanPanelPerfControlFrame"]:Hide(); - end -end -function TitanPanelPerformanceButton_OnEvent(self, event, ...) - if event == "PLAYER_ENTERING_WORLD" then - local i; - topAddOns = {} - -- scan how many addons are active - local count = GetNumAddOns(); - local ActiveAddons = 0; - local NumOfAddons = TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons"); --[[ -Urnati - This was a kludge as I believe there was a conflict with other addons Ace3 -libraries as TitanGetVar is misbehaving. As such, I added the local NumOfAddons above -and added the following four lines of code looking for a nil when it shouldn't return -as the value defaults to 5. -I also added NumOfAddons below the TitanDebug to avoid the problem later on. -]] - if NumOfAddons == nil then - NumOfAddons = 5; - TitanSetVar(TITAN_PERFORMANCE_ID, "NumOfAddons", 5); - end - for i=1, count do - if IsAddOnLoaded(i) then - ActiveAddons = ActiveAddons + 1; - end - end ---TitanDebug("NumOfAddons: " .. TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")); - if ActiveAddons < NumOfAddons then - counter = ActiveAddons; - else - counter = NumOfAddons; - end - --set the counter to the proper number of active addons that are being monitored - for i=1, counter do - topAddOns[i] = {name = '', value = 0} - end - end -end - --- ************************************************************************** --- NAME : TitanPanelPerformanceButton_GetButtonText(id) --- DESC : Calculate performance based logic for button text --- VARS : id = button ID --- ************************************************************************** -function TitanPanelPerformanceButton_GetButtonText(id) - local button = _G["TitanPanelPerformanceButton"]; - local color, fpsRichText, latencyRichText, memoryRichText; - local showFPS = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowFPS"); - local showLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowLatency"); - local showWorldLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowWorldLatency") - local showMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowMemory"); - - -- Update real time data - TitanPanelPerformanceButton_UpdateData() - - -- FPS text - if ( showFPS ) then - local fpsText = format(L["TITAN_PANEL_PERFORMANCE_FPS_FORMAT"], button.fps); - if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then - color = TitanUtils_GetThresholdColor(TITAN_FPS_THRESHOLD_TABLE, button.fps); - fpsRichText = TitanUtils_GetColoredText(fpsText, color); - else - fpsRichText = TitanUtils_GetHighlightText(fpsText); - end - end - - -- Latency text - latencyRichText = "" - if ( showLatency ) then - local latencyText = format(L["TITAN_PANEL_PERFORMANCE_LATENCY_FORMAT"], button.latencyHome); - if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then - color = TitanUtils_GetThresholdColor(TITAN_LATENCY_THRESHOLD_TABLE, button.latencyHome); - latencyRichText = TitanUtils_GetColoredText(latencyText, color); - else - latencyRichText = TitanUtils_GetHighlightText(latencyText) - end - end - - if ( showWorldLatency ) then - local latencyWorldText = format(L["TITAN_PANEL_PERFORMANCE_LATENCY_FORMAT"], button.latencyWorld); - if ( showLatency ) then - latencyRichText = latencyRichText.."/" - end - if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then - color = TitanUtils_GetThresholdColor(TITAN_LATENCY_THRESHOLD_TABLE, button.latencyWorld); - latencyRichText = latencyRichText..TitanUtils_GetColoredText(latencyWorldText, color); - else - latencyRichText = latencyRichText..TitanUtils_GetHighlightText(latencyWorldText); - end - end - - -- Memory text - if ( showMemory ) then - local memoryText = format(L["TITAN_PANEL_PERFORMANCE_MEMORY_FORMAT"], button.memory/1024); - memoryRichText = TitanUtils_GetHighlightText(memoryText); - end - - if ( showFPS ) then - if ( showLatency or showWorldLatency ) then - if ( showMemory ) then - return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; - else - return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText; - end - else - if ( showMemory ) then - return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; - else - return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText; - end - end - else - if ( showLatency or showWorldLatency ) then - if ( showMemory ) then - return L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; - else - return L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText; - end - else - if ( showMemory ) then - return L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; - else - return; - end - end - end -end - -- ************************************************************************** -- NAME : Stats_UpdateAddonsList(self, watchingCPU) -- DESC : Execute garbage collection for Leftclick on button -- ************************************************************************** +--]] local function Stats_UpdateAddonsList(self, watchingCPU) if(watchingCPU) then UpdateAddOnCPUUsage() @@ -254,11 +73,9 @@ local function Stats_UpdateAddonsList(self, watchingCPU) end local total = 0 - local i,j,k; local showAddonRate = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowAddonIncRate"); - for i=1, GetNumAddOns() do + for i=1, NumAddons() do local value = (watchingCPU and GetAddOnCPUUsage(i)) or GetAddOnMemoryUsage(i) - local name = GetAddOnInfo(i) total = total + value for j,addon in ipairs(topAddOns) do @@ -266,7 +83,7 @@ local function Stats_UpdateAddonsList(self, watchingCPU) for k = counter, 1, -1 do if(k == j) then topAddOns[k].value = value - topAddOns[k].name = GetAddOnInfo(i) + topAddOns[k].name = AddOnInfo(i) break elseif(k ~= 1) then topAddOns[k].value = topAddOns[k-1].value @@ -360,11 +177,13 @@ local function Stats_UpdateAddonsList(self, watchingCPU) end end +--[[ -- ************************************************************************** --- NAME : TitanPanelPerformanceButton_SetTooltip() +-- NAME : SetTooltip() -- DESC : Display tooltip text -- ************************************************************************** -function TitanPanelPerformanceButton_SetTooltip() +--]] +local function SetTooltip() local button = _G["TitanPanelPerformanceButton"]; local showFPS = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowFPS"); local showLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowLatency"); @@ -434,17 +253,178 @@ function TitanPanelPerformanceButton_SetTooltip() i.name = ''; i.value = 0; end - Stats_UpdateAddonsList(self, GetCVar('scriptProfile') == '1' and not IsModifierKeyDown()) + Stats_UpdateAddonsList(_G[TITAN_BUTTON], GetCVar('scriptProfile') == '1' and not IsModifierKeyDown()) end GameTooltip:AddLine(TitanUtils_GetGreenText(L["TITAN_PERFORMANCE_TOOLTIP_HINT"])); end +--[[ +-- ************************************************************************** +-- NAME : UpdateData() +-- DESC : Update button data +-- ************************************************************************** +--]] +local function UpdateData() + local button = _G["TitanPanelPerformanceButton"]; + local showFPS = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowFPS"); + local showLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowLatency"); + local showWorldLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowWorldLatency") + local showMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowMemory"); + local showAddonMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowAddonMemory"); + + -- FPS Data + if ( showFPS ) then + button.fps = GetFramerate(); + button.fpsSampleCount = button.fpsSampleCount + 1; + if (button.fpsSampleCount == 1) then + button.minFPS = button.fps; + button.maxFPS = button.fps; + button.avgFPS = button.fps; + else + if (button.fps < button.minFPS) then + button.minFPS = button.fps; + elseif (button.fps > button.maxFPS) then + button.maxFPS = button.fps; + end + button.avgFPS = (button.avgFPS * (button.fpsSampleCount - 1) + button.fps) / button.fpsSampleCount; + end + end + + -- Latency Data + if ( showLatency or showWorldLatency ) then + -- bandwidthIn, bandwidthOut, latencyHome, latencyWorld = GetNetStats(); + button.bandwidthIn, button.bandwidthOut, button.latencyHome, button.latencyWorld = GetNetStats(); + end + + -- Memory data + if ( showMemory ) or (showAddonMemory == 1) then + local previousMemory = button.memory; + button.memory, button.gcThreshold = gcinfo(); + if ( not button.startSessionTime ) then + -- Initial data + local i; + button.startSessionTime = time(); + button.initialMemory = button.memory; + + for i = 1, NumAddons() do + memUsageSinceGC[AddOnInfo(i)] = GetAddOnMemoryUsage(i) + end + elseif (previousMemory and button.memory and previousMemory > button.memory) then + -- Reset data after garbage collection + local k,i; + button.startSessionTime = time(); + button.initialMemory = button.memory; + + for k in pairs(memUsageSinceGC) do + memUsageSinceGC[k] = nil + end + + for i = 1, NumAddons() do + memUsageSinceGC[AddOnInfo(i)] = GetAddOnMemoryUsage(i) + end + end + end +end + +--[[ +-- ************************************************************************** +-- NAME : GetButtonText(id) +-- DESC : Calculate performance based logic for button text +-- VARS : id = button ID +-- ************************************************************************** +--]] +local function GetButtonText(id) + local button = _G["TitanPanelPerformanceButton"]; + local color, fpsRichText, latencyRichText, memoryRichText; + local showFPS = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowFPS"); + local showLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowLatency"); + local showWorldLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowWorldLatency") + local showMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowMemory"); + + -- Update real time data + UpdateData() + + -- FPS text + if ( showFPS ) then + local fpsText = format(L["TITAN_PANEL_PERFORMANCE_FPS_FORMAT"], button.fps); + if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then + color = TitanUtils_GetThresholdColor(TITAN_FPS_THRESHOLD_TABLE, button.fps); + fpsRichText = TitanUtils_GetColoredText(fpsText, color); + else + fpsRichText = TitanUtils_GetHighlightText(fpsText); + end + end + + -- Latency text + latencyRichText = "" + if ( showLatency ) then + local latencyText = format(L["TITAN_PANEL_PERFORMANCE_LATENCY_FORMAT"], button.latencyHome); + if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then + color = TitanUtils_GetThresholdColor(TITAN_LATENCY_THRESHOLD_TABLE, button.latencyHome); + latencyRichText = TitanUtils_GetColoredText(latencyText, color); + else + latencyRichText = TitanUtils_GetHighlightText(latencyText) + end + end + + if ( showWorldLatency ) then + local latencyWorldText = format(L["TITAN_PANEL_PERFORMANCE_LATENCY_FORMAT"], button.latencyWorld); + if ( showLatency ) then + latencyRichText = latencyRichText.."/" + end + if ( TitanGetVar(TITAN_PERFORMANCE_ID, "ShowColoredText") ) then + color = TitanUtils_GetThresholdColor(TITAN_LATENCY_THRESHOLD_TABLE, button.latencyWorld); + latencyRichText = latencyRichText..TitanUtils_GetColoredText(latencyWorldText, color); + else + latencyRichText = latencyRichText..TitanUtils_GetHighlightText(latencyWorldText); + end + end + + -- Memory text + if ( showMemory ) then + local memoryText = format(L["TITAN_PANEL_PERFORMANCE_MEMORY_FORMAT"], button.memory/1024); + memoryRichText = TitanUtils_GetHighlightText(memoryText); + end + + if ( showFPS ) then + if ( showLatency or showWorldLatency ) then + if ( showMemory ) then + return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; + else + return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText; + end + else + if ( showMemory ) then + return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; + else + return L["TITAN_PANEL_PERFORMANCE_FPS_BUTTON_LABEL"], fpsRichText; + end + end + else + if ( showLatency or showWorldLatency ) then + if ( showMemory ) then + return L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText, L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; + else + return L["TITAN_PANEL_PERFORMANCE_LATENCY_BUTTON_LABEL"], latencyRichText; + end + else + if ( showMemory ) then + return L["TITAN_PANEL_PERFORMANCE_MEMORY_BUTTON_LABEL"], memoryRichText; + else + return; + end + end + end +end + +--[[ -- ************************************************************************** --- NAME : TitanPanelRightClickMenu_PreparePerformanceMenu() +-- NAME : CreateMenu() -- DESC : Display rightclick menu options -- ************************************************************************** -function TitanPanelRightClickMenu_PreparePerformanceMenu() +--]] +local function CreateMenu() local info --[[ @@ -564,13 +544,13 @@ print("TPref" TitanPanelRightClickMenu_AddTitle(L["TITAN_PERFORMANCE_MENU_CPUPROF_LABEL"]..": "..GREEN_FONT_COLOR_CODE..L["TITAN_PANEL_MENU_ENABLED"], TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_PERFORMANCE_MENU_CPUPROF_LABEL_OFF"]..GREEN_FONT_COLOR_CODE..L["TITAN_PANEL_MENU_RELOADUI"]; - info.func = function() SetCVar("scriptProfile", "0", 1) ReloadUI() end + info.func = function() SetCVar("scriptProfile", "0") ReloadUI() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); else TitanPanelRightClickMenu_AddTitle(L["TITAN_PERFORMANCE_MENU_CPUPROF_LABEL"]..": "..RED_FONT_COLOR_CODE..L["TITAN_PANEL_MENU_DISABLED"], TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_PERFORMANCE_MENU_CPUPROF_LABEL_ON"]..GREEN_FONT_COLOR_CODE..L["TITAN_PANEL_MENU_RELOADUI"]; - info.func = function() SetCVar("scriptProfile", "1", 1) ReloadUI() end + info.func = function() SetCVar("scriptProfile", "1") ReloadUI() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end end @@ -611,72 +591,117 @@ print("TPref" TitanPanelRightClickMenu_AddControlVars(TITAN_PERFORMANCE_ID) end +--[[ -- ************************************************************************** --- NAME : TitanPanelPerformanceButton_UpdateData() --- DESC : Update button data +-- NAME : OnLoad() +-- DESC : Registers the plugin upon it loading -- ************************************************************************** -function TitanPanelPerformanceButton_UpdateData() - local button = _G["TitanPanelPerformanceButton"]; - local showFPS = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowFPS"); - local showLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowLatency"); - local showWorldLatency = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowWorldLatency") - local showMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowMemory"); - local showAddonMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowAddonMemory"); +--]] +local function OnLoad(self) + local notes = "" + .."Adds FPS (Frames Per Second) and Garbage collection information to Titan Panel.\n" +-- .."- xxx.\n" + self.registry = { + id = TITAN_PERFORMANCE_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_PERFORMANCE_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText; + tooltipCustomFunction = SetTooltip; + icon = "Interface\\AddOns\\TitanPerformance\\TitanPerformance", + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = true, + DisplayOnRightSide = true, + }, + savedVariables = { + ShowFPS = 1, + ShowLatency = 1, + ShowWorldLatency = 1, + ShowMemory = 1, + ShowAddonMemory = false, + ShowAddonIncRate = false, + NumOfAddons = 5, + AddonMemoryType = 1, + ShowIcon = 1, + ShowLabelText = false, + ShowColoredText = 1, + DisplayOnRightSide = false, + } + }; - -- FPS Data - if ( showFPS ) then - button.fps = GetFramerate(); - button.fpsSampleCount = button.fpsSampleCount + 1; - if (button.fpsSampleCount == 1) then - button.minFPS = button.fps; - button.maxFPS = button.fps; - button.avgFPS = button.fps; - else - if (button.fps < button.minFPS) then - button.minFPS = button.fps; - elseif (button.fps > button.maxFPS) then - button.maxFPS = button.fps; - end - button.avgFPS = (button.avgFPS * (button.fpsSampleCount - 1) + button.fps) / button.fpsSampleCount; - end - end + self.fpsSampleCount = 0; + self:RegisterEvent("PLAYER_ENTERING_WORLD"); +end - -- Latency Data - if ( showLatency or showWorldLatency ) then - -- bandwidthIn, bandwidthOut, latencyHome, latencyWorld = GetNetStats(); - button.bandwidthIn, button.bandwidthOut, button.latencyHome, button.latencyWorld = GetNetStats(); - end +function OnHide() + AceTimer:CancelTimer(PerfTimer) + PerfTimer = {} +end - -- Memory data - if ( showMemory ) or (showAddonMemory == 1) then - local previousMemory = button.memory; - button.memory, button.gcThreshold = gcinfo(); - if ( not button.startSessionTime ) then - -- Initial data - local i; - button.startSessionTime = time(); - button.initialMemory = button.memory; +--[[ +-- ************************************************************************** +-- NAME : TitanPanelPerformanceButton_OnUpdate(elapsed) +-- DESC : Update button data +-- VARS : elapsed = <research> +-- ************************************************************************** +--]] +function TitanPanelPerformanceButtonHandle_OnUpdate() + TitanPanelPluginHandle_OnUpdate(updateTable); + if not (TitanPanelRightClickMenu_IsVisible()) and _G["TitanPanelPerfControlFrame"]:IsVisible() and not (MouseIsOver(_G["TitanPanelPerfControlFrame"])) then + _G["TitanPanelPerfControlFrame"]:Hide(); + end +end - for i = 1, GetNumAddOns() do - memUsageSinceGC[GetAddOnInfo(i)] = GetAddOnMemoryUsage(i) - end - elseif (previousMemory and button.memory and previousMemory > button.memory) then - -- Reset data after garbage collection - local k,i; - button.startSessionTime = time(); - button.initialMemory = button.memory; +local function OnShow() + if PerfTimer == {} then + PerfTimer = AceTimer:ScheduleRepeatingTimer(TitanPanelPerformanceButtonHandle_OnUpdate, 1.5 ) + end +end - for k in pairs(memUsageSinceGC) do - memUsageSinceGC[k] = nil +local function OnEvent(self, event, ...) + if event == "PLAYER_ENTERING_WORLD" then + local i; + topAddOns = {} + -- scan how many addons are active + local count = NumAddons(); + local ActiveAddons = 0; + local NumOfAddons = TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons"); +--[[ +Urnati - This was a kludge as I believe there was a conflict with other addons loading Ace3 +libraries as TitanGetVar is misbehaving. As such, I added the local NumOfAddons above +and added the following four lines of code looking for a nil when it shouldn't return +as the value defaults to 5. +I also added NumOfAddons below the TitanDebug to avoid the problem later on. +]] + if NumOfAddons == nil then + NumOfAddons = 5; + TitanSetVar(TITAN_PERFORMANCE_ID, "NumOfAddons", 5); + end + for i=1, count do + if IsAddOnLoaded(i) then + ActiveAddons = ActiveAddons + 1; end + end - for i = 1, GetNumAddOns() do - memUsageSinceGC[GetAddOnInfo(i)] = GetAddOnMemoryUsage(i) - end + if ActiveAddons < NumOfAddons then + counter = ActiveAddons; + else + counter = NumOfAddons; + end + --set the counter to the proper number of active addons that are being monitored + for i=1, counter do + topAddOns[i] = {name = '', value = 0} end end end +--[[ -- ************************************************************************** -- NAME : TitanPanelPerformanceButton_ResetMemory() -- DESC : Reset the memory monitoring values @@ -687,6 +712,7 @@ end --button.initialMemory = button.memory; --button.startSessionTime = time(); --end +--]] --[[ -- ************************************************************************** @@ -694,17 +720,19 @@ end -- DESC : Execute garbage collection for Leftclick on button -- ************************************************************************** --]] -function TitanPanelPerformanceButton_OnClick(self, button) +local function OnClick(self, button) if button == "LeftButton" then collectgarbage('collect'); end end +--[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlSlider_OnEnter() +-- NAME : Slider_OnEnter() -- DESC : Display tooltip on entering slider -- ************************************************************************** -function TitanPanelPerfControlSlider_OnEnter(self) +--]] +local function Slider_OnEnter(self) self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_PERFORMANCE_CONTROL_TOOLTIP"], TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")); GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); @@ -712,22 +740,22 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlSlider_OnLeave() +-- NAME : Slider_OnLeave() -- DESC : Hide tooltip after leaving slider -- ************************************************************************** --]] -function TitanPanelPerfControlSlider_OnLeave(self) +local function Slider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); end --[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlSlider_OnShow() +-- NAME : Slider_OnShow() -- DESC : Display slider tooltip -- ************************************************************************** --]] -function TitanPanelPerfControlSlider_OnShow(self) +local function Slider_OnShow(self) _G[self:GetName().."Text"]:SetText(TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")); _G[self:GetName().."High"]:SetText(L["TITAN_PERFORMANCE_CONTROL_LOW"]); @@ -736,25 +764,11 @@ function TitanPanelPerfControlSlider_OnShow(self) self:SetValueStep(1); self:SetObeyStepOnDrag(true) -- since 5.4.2 (Mists of Pandaria) self:SetValue(CalcAppNum(TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons"))); --- self:SetValue((TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons"))); --- TitanPanelPerfControlFrame:SetBackdropColor(0, 0, 0, 1) ---[[ -TitanDebug("Slider_OnShow:" -.." : "..(self:GetValue() or "?") -.." : "..(self:GetValueStep() or "?") -); ---]] local lev = TitanPanelRightClickMenu_GetDropdownLevel() - 1 - local dds = "L_DropDownList"..tostring(lev) ---[[ -print("TPref dd" -.." "..tostring(lev).."" -.." "..tostring(dds).."" -) ---]] + local dds = TitanPanelRightClickMenu_GetDropdownFrameBase()..tostring(lev) local drop_down = _G[dds] - local scale = TitanPanelPerfControlFrame:GetScale() +-- local scale = TitanPanelPerfControlFrame:GetScale() TitanPanelPerfControlFrame:ClearAllPoints(); TitanPanelPerfControlFrame:SetPoint("LEFT", drop_down, "RIGHT", 0, 0); local offscreenX, offscreenY = TitanUtils_GetOffscreen(TitanPanelPerfControlFrame); @@ -766,9 +780,9 @@ print("TPref dd" TitanPanelPerfControlFrame:SetPoint("RIGHT", drop_down, "LEFT", 0, 0); end +--[[ local top_point, top_rel_to, top_rel_point, top_x, top_y = TitanPanelPerfControlFrame:GetPoint(TitanPanelPerfControlFrame:GetNumPoints()) ---[[ print("TPref" .." "..tostring(drop_down:GetName()).."" .." "..tostring(offscreenX).."" @@ -784,20 +798,16 @@ print("TPref" --]] end +--[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlSlider_OnValueChanged(arg1) +-- NAME : Slider_OnValueChanged(arg1) -- DESC : Display slider tooltip text -- VARS : arg1 = positive or negative change to apply -- ************************************************************************** -function TitanPanelPerfControlSlider_OnValueChanged(self, a1) +--]] +local function Slider_OnValueChanged(self, a1) local val = CalcAppNum(self:GetValue()) -- grab new value ---[[ -TitanDebug("Slider_OnValueChanged:" -.." : "..(self:GetValue() or "?") -.." : "..(val or "?") -); ---]] _G[self:GetName().."Text"]:SetText(val); --[[ if a1 == -1 then @@ -813,7 +823,7 @@ TitanDebug("Slider_OnValueChanged:" local i; topAddOns = {}; -- scan how many addons are active - local count = GetNumAddOns(); + local count = NumAddons(); local ActiveAddons = 0; for i=1, count do if IsAddOnLoaded(i) then @@ -839,16 +849,17 @@ TitanDebug("Slider_OnValueChanged:" end end +--[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlFrame_OnLoad() +-- NAME : Control_OnLoad() -- DESC : Create performance option frame -- ************************************************************************** -function TitanPanelPerfControlFrame_OnLoad(self) +--]] +local function Control_OnLoad(self) _G[self:GetName().."Title"]:SetText(L["TITAN_PERFORMANCE_CONTROL_TITLE"]); --[[ Blizzard decided to remove direct Backdrop API in 9.0 (Shadowlands) -so inherit the template (XML) -and set the values in the code (Lua) +so inherit the template (XML) and set the values in the code (Lua) 9.5 The tooltip template was removed from the GameTooltip. --]] @@ -857,12 +868,12 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelPerfControlFrame_OnUpdate(elapsed) +-- NAME : Control_OnUpdate(elapsed) -- DESC : If dropdown is visible, see if its timer has expired. If so, hide frame -- VARS : elapsed = <research> -- ************************************************************************** --]] -function TitanPanelPerfControlFrame_OnUpdate(self, elapsed) +local function Control_OnUpdate(self, elapsed) local drop_down = TitanPanelRightClickMenu_GetDropdownFrame() if not MouseIsOver(_G["TitanPanelPerfControlFrame"]) @@ -887,21 +898,21 @@ local function Create_Frames() local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelComboTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelPerformanceButton_OnLoad(window); + OnLoad(window); -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... window:SetScript("OnShow", function(self) - TitanPanelPerformanceButton_OnShow() + OnShow() TitanPanelButton_OnShow(self) end) window:SetScript("OnHide", function(self) - TitanPanelPerformanceButton_OnHide() + OnHide() end) window:SetScript("OnEvent", function(self, event, ...) - TitanPanelPerformanceButton_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) window:SetScript("OnClick", function(self, button) - TitanPanelPerformanceButton_OnClick(self, button) + OnClick(self, button) TitanPanelButton_OnClick(self, button) end) @@ -922,7 +933,7 @@ local function Create_Frames() TitanUtils_StartFrameCounting(self, 0.5) end) config:SetScript("OnUpdate", function(self, elapsed) - TitanPanelPerfControlFrame_OnUpdate(self, elapsed) + Control_OnUpdate(self, elapsed) end) -- Config Title @@ -939,30 +950,28 @@ local function Create_Frames() local offset = CreateFrame("Slider", "TitanPanelPerfControlSlider", config, inherit) offset:SetPoint("TOP", config, 0, -40) offset:SetScript("OnShow", function(self) - TitanPanelPerfControlSlider_OnShow(self) + Slider_OnShow(self) end) - offset:SetScript("OnValueChanged", function(self) - TitanPanelPerfControlSlider_OnValueChanged(self, value) + offset:SetScript("OnValueChanged", function(self, value) + Slider_OnValueChanged(self, value) end) - offset:SetScript("OnMouseWheel", function(self) - TitanPanelPerfControlSlider_OnValueChanged(self, delta) + offset:SetScript("OnMouseWheel", function(self, delta) + Slider_OnValueChanged(self, delta) end) offset:SetScript("OnEnter", function(self) - TitanPanelPerfControlSlider_OnEnter(self) + Slider_OnEnter(self) end) offset:SetScript("OnLeave", function(self) - TitanPanelPerfControlSlider_OnLeave(self) + Slider_OnLeave(self) end) -- Now that the parts exist, initialize - TitanPanelPerfControlFrame_OnLoad(config) + Control_OnLoad(config) --]===] end if TITAN_ID then -- it exists - AceTimer = LibStub("AceTimer-3.0") - L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) Create_Frames() -- do the work end diff --git a/TitanPerformance/TitanPerformance_Mainline.toc b/TitanPerformance/TitanPerformance_Mainline.toc index 91d69f4..7db4bbf 100644 --- a/TitanPerformance/TitanPerformance_Mainline.toc +++ b/TitanPerformance/TitanPerformance_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanPerformance/TitanPerformance_Vanilla.toc b/TitanPerformance/TitanPerformance_Vanilla.toc index 93c3894..bc50a48 100644 --- a/TitanPerformance/TitanPerformance_Vanilla.toc +++ b/TitanPerformance/TitanPerformance_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanPerformance/TitanPerformance_Wrath.toc b/TitanPerformance/TitanPerformance_Wrath.toc index 0f1b884..c1479f6 100644 --- a/TitanPerformance/TitanPerformance_Wrath.toc +++ b/TitanPerformance/TitanPerformance_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRegen/TitanClassicRegen.lua b/TitanRegen/TitanClassicRegen.lua new file mode 100644 index 0000000..cb578a4 --- /dev/null +++ b/TitanRegen/TitanClassicRegen.lua @@ -0,0 +1,316 @@ +-- ************************************************************************** +-- * TitanClassicRegen.lua +-- * +-- * By: TitanMod, Dark Imakuni, Adsertor and the Titan Panel Development Team +-- ************************************************************************** + +-- ******************************** Constants ******************************* +local TITAN_REGEN_ID = "Regen" +local TITAN_REGEN_HP_FORMAT = "%d"; +local TITAN_REGEN_HP_FORMAT_PERCENT = "%.2f"; +local TITAN_REGEN_MP_FORMAT = "%d"; +local TITAN_REGEN_MP_FORMAT_PERCENT = "%.2f"; +local updateTable = {TITAN_REGEN_ID, TITAN_PANEL_UPDATE_ALL}; +-- ******************************** Variables ******************************* +local TITAN_RegenCurrHealth = 0; +local TITAN_RegenCurrMana = 0; +local TITAN_RegenMP = 0; +local TITAN_RegenHP = 0; +local TITAN_RegenCheckedManaState = 0; +local TITAN_RegenMaxHPRate = 0; +local TITAN_RegenMinHPRate = 9999; +local TITAN_RegenMaxMPRate = 0; +local TITAN_RegenMinMPRate = 9999; +local TITAN_RegenMPDuringCombat = 0; +local TITAN_RegenMPCombatTrack = 0; +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +-- ******************************** Functions ******************************* + +-- ************************************************************************** +-- NAME : TitanRegenTemp_GetColoredTextRGB(text, r, g, b) +-- DESC : Define colors for colored text and display +-- VARS : text = text to display, r = red value, g = green value, b = blue value +-- ************************************************************************** +local function TitanRegenTemp_GetColoredTextRGB(text, r, g, b) + if (text and r and g and b) then + local redColorCode = format("%02x", r * 255); + local greenColorCode = format("%02x", g * 255); + local blueColorCode = format("%02x", b * 255); + local colorCode = "|cff"..redColorCode..greenColorCode..blueColorCode; + return colorCode..text..FONT_COLOR_CODE_CLOSE; + end +end + +-- ************************************************************************** +-- NAME : TitanPanelRegenButton_OnLoad() +-- DESC : Registers the plugin upon it loading +-- ************************************************************************** +function TitanPanelRegenButton_OnLoad(self) + self.registry = { + id = TITAN_REGEN_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_REGEN_MENU_TEXT"], + buttonTextFunction = "TitanPanelRegenButton_GetButtonText", + tooltipTitle = L["TITAN_REGEN_MENU_TOOLTIP_TITLE"], + tooltipTextFunction = "TitanPanelRegenButton_GetTooltipText", + controlVariables = { + ShowIcon = false, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = false, + DisplayOnRightSide = true, + }, + savedVariables = { + ShowLabelText = 1, + ShowHPRegen = 1, + ShowPercentage = false, + ShowColoredText = false, + DisplayOnRightSide = false, + } + }; + + self:RegisterEvent("UNIT_HEALTH"); + self:RegisterEvent("UNIT_POWER_UPDATE"); + self:RegisterEvent("PLAYER_ENTERING_WORLD"); + self:RegisterEvent("PLAYER_REGEN_DISABLED"); + self:RegisterEvent("PLAYER_REGEN_ENABLED"); +end + +-- ************************************************************************** +-- NAME : TitanPanelXPButton_OnEvent +-- DESC : Parse events registered to addon and act on them +-- ************************************************************************** +function TitanPanelRegenButton_OnEvent(self, event, a1, a2, ...) + if ( event == "PLAYER_ENTERING_WORLD") then + end + + if ( event == "PLAYER_REGEN_DISABLED") then + TITAN_RegenMPDuringCombat = 0; + TITAN_RegenMPCombatTrack = 1; + end + + if ( event == "PLAYER_REGEN_ENABLED") then + TITAN_RegenMPCombatTrack = 0; + end + + local currHealth = 0; + local currMana = 0; + local runUpdate = 0; + + if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then + if ( event == "UNIT_HEALTH" and a1 == "player") then + currHealth = UnitHealth("player"); + runUpdate = 1; + if ( currHealth > TITAN_RegenCurrHealth and TITAN_RegenCurrHealth ~= 0 ) then + TITAN_RegenHP = currHealth-TITAN_RegenCurrHealth; + + if (TITAN_RegenHP > TITAN_RegenMaxHPRate) then + TITAN_RegenMaxHPRate = TITAN_RegenHP; + end + if (TITAN_RegenHP < TITAN_RegenMinHPRate or TITAN_RegenMinHPRate == 9999) then + TITAN_RegenMinHPRate = TITAN_RegenHP; + end + end + TITAN_RegenCurrHealth = currHealth; + end + end + + local pval, ptype = UnitPowerType("player") + if (pval == 0) then -- Mana + if ( event == "UNIT_POWER_UPDATE" and a1 == "player" and a2 == "MANA") then + currMana = UnitPower("player"); + runUpdate = 1; + if ( currMana > TITAN_RegenCurrMana and TITAN_RegenCurrMana ~= 0 ) then + TITAN_RegenMP = currMana-TITAN_RegenCurrMana; + + if (TITAN_RegenMPCombatTrack == 1) then + TITAN_RegenMPDuringCombat = TITAN_RegenMPDuringCombat + TITAN_RegenMP; + end + + if (TITAN_RegenMP > TITAN_RegenMaxMPRate) then + TITAN_RegenMaxMPRate = TITAN_RegenMP; + end + if (TITAN_RegenMP < TITAN_RegenMinMPRate or TITAN_RegenMinMPRate == 9999) then + TITAN_RegenMinMPRate = TITAN_RegenMP; + end + end + TITAN_RegenCurrMana = currMana; + end + end + + if (runUpdate == 1) then + TitanPanelPluginHandle_OnUpdate(updateTable) + end +end + +-- ************************************************************************** +-- NAME : TitanPanelRegenButton_GetButtonText(id) +-- DESC : Calculate regeneration logic for button text +-- VARS : id = button ID +-- ************************************************************************** +function TitanPanelRegenButton_GetButtonText(id) + local labelTextHP = ""; + local valueTextHP = ""; + local labelTextMP = ""; + local valueTextMP = ""; + local OutputStr = ""; + + if UnitHealth("player") == UnitHealthMax("player") then + TITAN_RegenHP = 0; + end + if UnitPower("player") == UnitPowerMax("player", 0) then + TITAN_RegenMP = 0; + end + + -- safety in case both are off, then cant ever turn em on + if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then + TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1); + end + + if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then + labelTextHP = L["TITAN_REGEN_BUTTON_TEXT_HP"]; + if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then + valueTextHP = format(TITAN_REGEN_HP_FORMAT_PERCENT, (TITAN_RegenHP/UnitHealthMax("player"))*100); + else + valueTextHP = format(TITAN_REGEN_HP_FORMAT, TITAN_RegenHP); + end + if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then + valueTextHP = TitanUtils_GetGreenText(valueTextHP); + else + valueTextHP = TitanUtils_GetHighlightText(valueTextHP); + end + end + + local pval, ptype = UnitPowerType("player") + if (pval == 0) then -- Mana only + labelTextMP = L["TITAN_REGEN_BUTTON_TEXT_MP"]; + if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then + valueTextMP = format(TITAN_REGEN_MP_FORMAT_PERCENT, (TITAN_RegenMP/UnitPowerMax("player", 0))*100); + else + valueTextMP = format(TITAN_REGEN_MP_FORMAT, TITAN_RegenMP); + end + if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then + valueTextMP = TitanRegenTemp_GetColoredTextRGB(valueTextMP, 0.0, 0.0, 1.0); + else + valueTextMP = TitanUtils_GetHighlightText(valueTextMP); + end + end + + -- supports turning off labels + return labelTextHP, valueTextHP, labelTextMP, valueTextMP; +end + +-- ************************************************************************** +-- NAME : TitanPanelRegenButton_GetTooltipText() +-- DESC : Display tooltip text +-- ************************************************************************** +function TitanPanelRegenButton_GetTooltipText() + local minHP = TITAN_RegenMinHPRate; + local minMP = TITAN_RegenMinMPRate; + + if minHP == 9999 then minHP = 0 end; + if minMP == 9999 then minMP = 0 end; + + local txt = "" + + txt = txt.. + format(L["TITAN_REGEN_TOOLTIP1"], UnitHealth("player"),UnitHealthMax("player"),UnitHealthMax("player")-UnitHealth("player")).."\n".. + format(L["TITAN_REGEN_TOOLTIP3"], TITAN_RegenMaxHPRate).."\n".. + format(L["TITAN_REGEN_TOOLTIP4"], minHP).."\n" + + local pval, ptype = UnitPowerType("player") + if (pval == 0) then + local regenPercent = 0 + regenPercent = (TITAN_RegenMPDuringCombat/UnitPowerMax("player", 0))*100; + + txt = txt.."\n".. + format(L["TITAN_REGEN_TOOLTIP2"], UnitPower("player"),UnitPowerMax("player", 0),UnitPowerMax("player", 0)-UnitPower("player")).."\n".. + format(L["TITAN_REGEN_TOOLTIP5"], TITAN_RegenMaxMPRate).."\n".. + format(L["TITAN_REGEN_TOOLTIP6"], minMP).."\n".. + format(L["TITAN_REGEN_TOOLTIP7"], TITAN_RegenMPDuringCombat, regenPercent).."\n" + else + -- L["TITAN_REGEN_TOOLTIP2"] = "Mana: \t"..GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." ("..RED_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE..")"; + POWER = GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE + txt = txt.."\n".. + ptype.." \t".. + format(POWER, UnitPower("player"),UnitPowerMax("player", pval)).."\n" + -- Energy : The formula is (energyRegen)*(1+hastePercent) + end + + return txt +end + +-- ************************************************************************** +-- NAME : TitanPanelRightClickMenu_PrepareTitanRegenMenu() +-- DESC : Display rightclick menu options +-- ************************************************************************** +function TitanPanelRightClickMenu_PrepareRegenMenu() + local id = TITAN_REGEN_ID; + local info; + + TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText); + + info = {}; + info.text = L["TITAN_REGEN_MENU_HP"]; + info.func = TitanRegen_ShowHPRegen; + info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen"); + L_UIDropDownMenu_AddButton(info); + + info = {}; + info.text = L["TITAN_REGEN_MENU_PERCENT"]; + info.func = TitanRegen_ShowPercentage; + info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowPercentage"); + L_UIDropDownMenu_AddButton(info); + + TitanPanelRightClickMenu_AddSpacer(); + + info = {}; + info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"]; + info.func = TitanRegen_ShowColoredText; + info.checked = TitanGetVar(TITAN_REGEN_ID, "ShowColoredText"); + L_UIDropDownMenu_AddButton(info); + + TitanPanelRightClickMenu_AddToggleLabelText(TITAN_REGEN_ID); + TitanPanelRightClickMenu_AddToggleRightSide(TITAN_REGEN_ID); + TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], id, TITAN_PANEL_MENU_FUNC_HIDE); +end + +-- ************************************************************************** +-- NAME : TitanRegen_UpdateSettings() +-- DESC : Update button text on setting change +-- ************************************************************************** +function TitanRegen_UpdateSettings() + -- safety in case both are off, then cant ever turn em on + if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then + TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1); + end + TitanPanelButton_UpdateButton(TITAN_REGEN_ID); +end + +-- ************************************************************************** +-- NAME : TitanRegen_ShowHPRegen() +-- DESC : Show HP regeneration option on button +-- ************************************************************************** +function TitanRegen_ShowHPRegen() + TitanToggleVar(TITAN_REGEN_ID, "ShowHPRegen"); + TitanRegen_UpdateSettings(); +end + +-- ************************************************************************** +-- NAME : TitanRegen_ShowPercentage() +-- DESC : Show values as percentage option on button +-- ************************************************************************** +function TitanRegen_ShowPercentage() + TitanToggleVar(TITAN_REGEN_ID, "ShowPercentage"); + TitanRegen_UpdateSettings(); +end + +-- ************************************************************************** +-- NAME : TitanRegen_ShowColoredText() +-- DESC : Show colored text option on button +-- ************************************************************************** +function TitanRegen_ShowColoredText() + TitanToggleVar(TITAN_REGEN_ID, "ShowColoredText"); + TitanRegen_UpdateSettings(); +end \ No newline at end of file diff --git a/TitanRegen/TitanClassicRegen.xml b/TitanRegen/TitanClassicRegen.xml new file mode 100644 index 0000000..aa88003 --- /dev/null +++ b/TitanRegen/TitanClassicRegen.xml @@ -0,0 +1,19 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ +..\FrameXML\UI.xsd"> + <Script file="TitanClassicRegen.lua"/> + <Frame parent="UIParent"> + <Frames> + <Button name="TitanPanelRegenButton" inherits="TitanPanelTextTemplate" frameStrata="FULLSCREEN" toplevel="true"> + <Scripts> + <OnLoad> + TitanPanelRegenButton_OnLoad(self); + TitanPanelButton_OnLoad(self); + </OnLoad> + <OnEvent> + TitanPanelRegenButton_OnEvent(self, event, ...); + </OnEvent> + </Scripts> + </Button> + </Frames> + </Frame> +</Ui> \ No newline at end of file diff --git a/TitanRegen/TitanRegen_Vanilla.toc b/TitanRegen/TitanRegen_Vanilla.toc index 9bece1b..b79feff 100644 --- a/TitanRegen/TitanRegen_Vanilla.toc +++ b/TitanRegen/TitanRegen_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a regen monitor to Titan Panel to show HP/MANA regen - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRegen/TitanRegen_Wrath.toc b/TitanRegen/TitanRegen_Wrath.toc index 6f5fdd6..60f2b64 100644 --- a/TitanRegen/TitanRegen_Wrath.toc +++ b/TitanRegen/TitanRegen_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a regen monitor to Titan Panel to show HP/MANA regen - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRepair/TitanRepair.lua b/TitanRepair/TitanRepair.lua index d319785..b3265e0 100644 --- a/TitanRepair/TitanRepair.lua +++ b/TitanRepair/TitanRepair.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanRepair.lua @@ -9,18 +10,16 @@ -- ******************************** Constants ******************************* local TITAN_REPAIR_ID = "Repair"; local TITAN_BUTTON = "TitanPanel"..TITAN_REPAIR_ID.."Button" -local TITAN_TOOLTIP = "Titan"..TITAN_REPAIR_ID.."Tooltip" -local NYL = "nyl" -local L = {} -- For AceLocale -local TitanRepair = {} -- for LibStub("AceAddon-3.0")... set on create frames +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +local TitanRepair = {} local _G = getfenv(0); local TR = TitanRepair TR.ITEM_STATUS = {}; TR.ITEM_BAG = {}; local AceTimer = LibStub("AceTimer-3.0") -local TR_Timer = nil +local TR_Timer = {} local TR_Timer_active = false local parse_item = @@ -115,8 +114,8 @@ local function debug_msg(Message) local msg = "" local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S") local milli = GetTime() -- seconds with millisecond precision (float) - milli = string.format("%0.2F", milli - math.modf(milli)) - msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_REPAIR_ID..": ") + local milli_str = string.format("%0.2F", milli - math.modf(milli)) + msg = msg..TitanUtils_GetGoldText(stamp..milli_str.." "..TITAN_REPAIR_ID..": ") msg = msg..TitanUtils_GetGreenText(Message) DEFAULT_CHAT_FRAME:AddMessage(msg) -- DEFAULT_CHAT_FRAME:AddMessage(TITAN_REPAIR_ID..": " .. Message, 1.00, 0.49, 0.04) @@ -310,10 +309,6 @@ print local slotName = slots[slotID].name local scan_slots = tostring(slotName)..":"..tostring(GetInventorySlotInfo(slotName)) - local hasItem = {} - local repairCost = 0 - local dbg_str_01 = "" - local _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, reforging, Name local itemName, itemQuality @@ -335,8 +330,8 @@ print scan_slots = scan_slots .." id:"..tostring(Id).."" .." '"..tostring(itemName).."'" - - if Id == nil or itemName == nil then -- item data should be good + + if Id == nil or itemName == nil then -- item data should be good -- likely entering world, server has not fully sent data to use if (TR.show_debug or TR.show_debug_scan) then scan_slots = scan_slots @@ -348,7 +343,7 @@ print -- Let the existing timer run -- else TR_Timer_active = true - TR_Timer = AceTimer.ScheduleTimer(TITAN_BUTTON, TitanRepair_ScanShell, 1.0) + TR_Timer = AceTimer:ScheduleTimer(TitanRepair_ScanShell, 1.0) -- end return -- harsh but best... else @@ -703,9 +698,8 @@ Realized the Disable also changes the button so the DeSat is redundent if TitanGetVar(TITAN_REPAIR_ID,"AutoRepairReport") then -- report repair cost to chat (optional) DEFAULT_CHAT_FRAME:AddMessage(_G["GREEN_FONT_COLOR_CODE"]..L["TITAN_REPAIR"]..": ".."|r" - ..format(L["TITAN_REPAIR_REPORT_COST_CHAT_GUILD"], GetTextGSC(cost)).."\n") --- ..L["TITAN_REPAIR_REPORT_COST_CHAT"]..GetTextGSC(cost).."|r" --- .." "..FROM.." "..GUILD..".") + ..L["TITAN_REPAIR_REPORT_COST_CHAT"]..GetTextGSC(cost).."|r" + .." "..FROM.." "..GUILD..".") end -- disable repair all icon in merchant MerchantRepairAllButton:Disable(); @@ -731,9 +725,8 @@ Realized the Disable also changes the button so the DeSat is redundent -- report repair cost to chat (optional) if TitanGetVar(TITAN_REPAIR_ID,"AutoRepairReport") then DEFAULT_CHAT_FRAME:AddMessage(_G["GREEN_FONT_COLOR_CODE"]..L["TITAN_REPAIR"]..": ".."|r" - ..format(L["TITAN_REPAIR_REPORT_COST_CHAT_YOU"], GetTextGSC(cost)).."\n") --- ..L["TITAN_REPAIR_REPORT_COST_CHAT"]..GetTextGSC(cost) --- .." "..FROM.." "..YOU..".") + ..L["TITAN_REPAIR_REPORT_COST_CHAT"]..GetTextGSC(cost) + .." "..FROM.." "..YOU..".") end -- disable repair all icon in merchant MerchantRepairAllButton:Disable(); @@ -829,71 +822,11 @@ end --[[ Titan -- ************************************************************************** --- NAME : TitanPanelRepairButton_OnLoad(self) --- DESC : Registers the plugin upon loading; OnShow to start; OnHide to stop --- ************************************************************************** ---]] -function TitanPanelRepairButton_OnLoad(self) - local notes = "" - .."Provides a configurable durability display. Adds the ability to auto repair items and inventory at vendors.\n" - .."- Shift + Left - Click forces a scan.\n" - .."- Left - Click now sells ALL gray items - use with CAUTION!\n" - .."- Option to auto sell ALL gray items - use with CAUTION!\n" - .."May 2023 : New option to display cost in gold only.\n" - self.registry = { - id = TITAN_REPAIR_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_REPAIR_LOCALE_MENU"], - buttonTextFunction = "TitanPanelRepairButton_GetButtonText", - tooltipTitle = L["TITAN_REPAIR_LOCALE_TOOLTIP"], - tooltipTextFunction = "TitanPanelRepairButton_GetTooltipText", - icon = "Interface\\AddOns\\TitanRepair\\TitanRepair", - iconWidth = 16, - notes = notes, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowColoredText = true, - DisplayOnRightSide = true, - }, - savedVariables = { - ShowIcon = 1, - ShowLabelText = 1, - ShowMostDamaged = false, - ShowTotals = true, - ShowUndamaged = false, - ShowPopup = false, - AutoRepair = false, - DiscountFriendly = false, - DiscountHonored = false, - DiscountRevered = false, - DiscountExalted = false, - ShowPercentage = false, - ShowColoredText = false, - ShowInventory = false, - ShowRepairCost = 1, - ShowMostDmgPer = 1, - UseGuildBank = false, - AutoRepairReport = false, - ShowItems = true, - ShowDiscounts = true, - ShowCosts = true, - DisplayOnRightSide = false, - ShowGray = false, - SellAllGray = false, - ShowCostGoldOnly = false, - } - }; -end - ---[[ Titan --- ************************************************************************** --- NAME : TitanPanelRepairButton_OnEvent(self, event, a1, ...) +-- NAME : OnEvent(self, event, a1, ...) -- DESC : This section will grab the events registered to the add on and act on them -- ************************************************************************** --]] -function TitanPanelRepairButton_OnEvent(self, event, a1, ...) +local function OnEvent(self, event, a1, ...) if TR.show_debug then local msg = "Event" @@ -934,7 +867,7 @@ function TitanPanelRepairButton_OnEvent(self, event, a1, ...) self:RegisterEvent("PLAYER_MONEY") -- this prevents extra scan requests on looting... if TitanGetVar(TITAN_REPAIR_ID,"ShowPopup") == 1 then if (TR.repair_total > 0) then - TR.MONEY = repairCost; + TR.MONEY = TR.repair_total; StaticPopup_Show("REPAIR_CONFIRMATION"); end end @@ -964,7 +897,7 @@ function TitanPanelRepairButton_OnEvent(self, event, a1, ...) end end -function TitanPanelRepairButton_OnClick(self, button) +local function OnClick(self, button) if button == "LeftButton" and IsShiftKeyDown() then TitanUtils_CloseAllControlFrames(); if (TitanPanelRightClickMenu_IsVisible()) then @@ -982,8 +915,8 @@ function TitanPanelRepairButton_OnClick(self, button) end local function GetDiscountCost(sum) - local costStr = 0; - local discountlabel = ""; + local costStr = "" + local discountlabel = "" -- show cost per the user choice if (sum > 0 and TitanGetVar(TITAN_REPAIR_ID,"ShowRepairCost")) then @@ -1014,7 +947,7 @@ end --[[ Titan -- ************************************************************************** --- NAME : TitanPanelRepairButton_GetButtonText(id) +-- NAME : GetButtonText(id) -- DESC : Determine the plugin button text based on last scan values and user preferences -- VARS : id = plugin id (Repair) -- OUT : @@ -1022,7 +955,7 @@ end -- string : plugin text / values -- ************************************************************************** --]] -function TitanPanelRepairButton_GetButtonText(id) +local function GetButtonText(id) local itemNamesToShow = "" local itemPercent = 0 local itemCost = 0 @@ -1043,6 +976,7 @@ function TitanPanelRepairButton_GetButtonText(id) -- supports turning off labels + local text = "" if TR.scan_running then res = text.." ("..L["TITAN_REPAIR_LOCALE_WHOLESCANINPROGRESS"]..")" @@ -1055,10 +989,9 @@ function TitanPanelRepairButton_GetButtonText(id) -- ====== -- Get repair totals local text_label = "" - local text = "" if (TitanGetVar(TITAN_REPAIR_ID,"ShowTotals")) then text_label = L["TITAN_REPAIR_LOCALE_BUTTON"] - dura_total = TR.dur_total + local dura_total = TR.dur_total text = string.format("%d%%", dura_total) text = AutoHighlight(dura_total, text) text = text.." " -- total % @@ -1114,11 +1047,11 @@ end --[[ Titan -- ************************************************************************** --- NAME : TitanPanelRepairButton_GetTooltipText() +-- NAME : GetTooltipText() -- DESC : Create the Repair tool tip based on last scan and user preferences -- ************************************************************************** --]] -function TitanPanelRepairButton_GetTooltipText() +local function GetTooltipText() local out = ""; local cost = 0; local sum = TR.repair_total @@ -1147,7 +1080,7 @@ function TitanPanelRepairButton_GetTooltipText() local valueText = "" ---[[ if TR.show_debug_tooltip then - msg = "" + local msg = "" .." '"..tostring(slotName).."'" .." '"..tostring(TR.equip_list[slotName].name).."'" .." "..tostring(TR.equip_list[slotName].quality) @@ -1155,7 +1088,7 @@ function TitanPanelRepairButton_GetTooltipText() .." "..tostring(TR.equip_list[slotName].dur_per).."%" .." "..tostring(TR.equip_list[slotName].dur_cur) .."/"..tostring(TR.equip_list[slotName].dur_max) - debug_msg(msg, TR.show_debug_tooltip) + debug_msg(msg) end --]] if (TitanGetVar(TITAN_REPAIR_ID,"ShowPercentage")) then @@ -1270,16 +1203,16 @@ function TitanPanelRepairButton_GetTooltipText() out = out.."\t"..TitanUtils_GetGreenText("Only while merchant is open ".."\n") out = out..TitanUtils_GetGreenText("Hint: Shift + Left click to force a scan of repair info.") - return out, itemLabel + return out end --[[ Titan -- ************************************************************************** --- NAME : TitanPanelRightClickMenu_PrepareRepairMenu() +-- NAME : CreateMenu() -- DESC : Create the Repair right click menu -- ************************************************************************** --]] -function TitanPanelRightClickMenu_PrepareRepairMenu() +local function CreateMenu() local info; -- level 2 @@ -1543,6 +1476,67 @@ function TitanPanelRightClickMenu_PrepareRepairMenu() TitanPanelRightClickMenu_AddControlVars(TITAN_REPAIR_ID) end +--[[ Titan +-- ************************************************************************** +-- NAME : OnLoad(self) +-- DESC : Registers the plugin upon loading; OnShow to start; OnHide to stop +-- ************************************************************************** +--]] +local function OnLoad(self) + local notes = "" + .."Provides a configurable durability display. Adds the ability to auto repair items and inventory at vendors.\n" + .."- Shift + Left - Click forces a scan.\n" + .."- Left - Click now sells ALL gray items - use with CAUTION!\n" + .."- Option to auto sell ALL gray items - use with CAUTION!\n" + .."May 2023 : New option to display cost in gold only.\n" + self.registry = { + id = TITAN_REPAIR_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_REPAIR_LOCALE_MENU"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_REPAIR_LOCALE_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + icon = "Interface\\AddOns\\TitanRepair\\TitanRepair", + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowColoredText = true, + DisplayOnRightSide = true, + }, + savedVariables = { + ShowIcon = 1, + ShowLabelText = 1, + ShowMostDamaged = false, + ShowTotals = true, + ShowUndamaged = false, + ShowPopup = false, + AutoRepair = false, + DiscountFriendly = false, + DiscountHonored = false, + DiscountRevered = false, + DiscountExalted = false, + ShowPercentage = false, + ShowColoredText = false, + ShowInventory = false, + ShowRepairCost = 1, + ShowMostDmgPer = 1, + UseGuildBank = false, + AutoRepairReport = false, + ShowItems = true, + ShowDiscounts = true, + ShowCosts = true, + DisplayOnRightSide = false, + ShowGray = false, + SellAllGray = false, + ShowCostGoldOnly = false, + } + }; +end + --[[ local -- ************************************************************************** -- NAME : Create_Frames() @@ -1569,14 +1563,14 @@ local function Create_Frames() local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelComboTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelRepairButton_OnLoad(window); + OnLoad(window); -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... window:SetScript("OnEvent", function(self, event, ...) - TitanPanelRepairButton_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) window:SetScript("OnClick", function(self, button) - TitanPanelRepairButton_OnClick(self, button) + OnClick(self, button) TitanPanelButton_OnClick(self, button) end) window:SetScript("OnShow", function(self, button) @@ -1605,8 +1599,5 @@ local function Create_Frames() end if TITAN_ID then -- it exists - L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) - TitanRepair = LibStub("AceAddon-3.0"):NewAddon(TITAN_REPAIR_ID, "AceHook-3.0", "AceTimer-3.0") - TR_Timer = LibStub("AceTimer-3.0") Create_Frames() -- do the work end diff --git a/TitanRepair/TitanRepair_Mainline.toc b/TitanRepair/TitanRepair_Mainline.toc index a72b702..8477ee7 100644 --- a/TitanRepair/TitanRepair_Mainline.toc +++ b/TitanRepair/TitanRepair_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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: diff --git a/TitanRepair/TitanRepair_Vanilla.toc b/TitanRepair/TitanRepair_Vanilla.toc index cddb6da..f7446a6 100644 --- a/TitanRepair/TitanRepair_Vanilla.toc +++ b/TitanRepair/TitanRepair_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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: diff --git a/TitanRepair/TitanRepair_Wrath.toc b/TitanRepair/TitanRepair_Wrath.toc index afae4e3..7da9b86 100644 --- a/TitanRepair/TitanRepair_Wrath.toc +++ b/TitanRepair/TitanRepair_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## 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: diff --git a/TitanVolume/TitanVolume.lua b/TitanVolume/TitanVolume.lua index 567de1b..0808a29 100644 --- a/TitanVolume/TitanVolume.lua +++ b/TitanVolume/TitanVolume.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanBag.lua @@ -7,297 +8,284 @@ --]] local TITAN_VOLUME_ID = "Volume"; -local TITAN_VOLUME_BUTTON = "TitanPanel"..TITAN_VOLUME_ID.."Button" +local TITAN_VOLUME_BUTTON = "TitanPanel" .. TITAN_VOLUME_ID .. "Button" local TITAN_VOLUME_FRAME_SHOW_TIME = 0.5; local TITAN_VOLUME_ARTWORK_PATH = "Interface\\AddOns\\TitanVolume\\Artwork\\"; local _G = getfenv(0); local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -function TitanPanelVolumeButton_OnLoad(self) - local notes = "" - .."Adds a volume control icon on your Titan Bar.\n" --- .."- xxx.\n" - self.registry = { - id = TITAN_VOLUME_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_VOLUME_MENU_TEXT"], - tooltipTitle = VOLUME, --L["TITAN_VOLUME_TOOLTIP"], - tooltipTextFunction = "TitanPanelVolumeButton_GetTooltipText", - iconWidth = 32, - iconButtonWidth = 18, - notes = notes, - controlVariables = { - ShowIcon = false, - ShowLabelText = false, - ShowColoredText = false, - DisplayOnRightSide = true, - }, - savedVariables = { - OverrideBlizzSettings = false, - VolumeMaster = 1, - VolumeAmbience = 0.5, - VolumeDialog = 0.5, - VolumeSFX = 0.5, - VolumeMusic = 0.5, --- VolumeOutboundChat = 1, --- VolumeInboundChat = 1, - DisplayOnRightSide = 1, - } - }; - self:RegisterEvent("PLAYER_ENTERING_WORLD"); +local function GetVolumeText(volume) + return tostring(floor(100 * volume + 0.5)) .. "%"; +end + +local function SetVolumeIcon() + local icon = _G["TitanPanelVolumeButtonIcon"]; + local masterVolume = tonumber(GetCVar("Sound_MasterVolume")); + if (masterVolume <= 0) then + icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeMute"); + elseif (masterVolume < 0.33) then + icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeLow"); + elseif (masterVolume < 0.66) then + icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeMedium"); + else + icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeHigh"); + end end -function TitanPanelVolumeButton_OnEvent(self, event, a1, ...) +local function OnEvent(self, event, a1, ...) if event == "PLAYER_ENTERING_WORLD" and TitanGetVar(TITAN_VOLUME_ID, "OverrideBlizzSettings") then -- Override Blizzard's volume CVar settings - if TitanGetVar(TITAN_VOLUME_ID, "VolumeMaster") then SetCVar("Sound_MasterVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeMaster")) TitanPanelVolume_SetVolumeIcon() end - if TitanGetVar(TITAN_VOLUME_ID, "VolumeAmbience") then SetCVar("Sound_AmbienceVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeAmbience")) end - if TitanGetVar(TITAN_VOLUME_ID, "VolumeDialog") then SetCVar("Sound_DialogVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeDialog")) end - if TitanGetVar(TITAN_VOLUME_ID, "VolumeSFX") then SetCVar("Sound_SFXVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeSFX")) end - if TitanGetVar(TITAN_VOLUME_ID, "VolumeMusic") then SetCVar("Sound_MusicVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeMusic")) end --- if TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat") then SetCVar("OutboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat")) end --- if TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat") then SetCVar("InboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat")) end + if TitanGetVar(TITAN_VOLUME_ID, "VolumeMaster") then + SetCVar("Sound_MasterVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeMaster")) + SetVolumeIcon() + end + if TitanGetVar(TITAN_VOLUME_ID, "VolumeAmbience") then SetCVar("Sound_AmbienceVolume", + TitanGetVar(TITAN_VOLUME_ID, "VolumeAmbience")) end + if TitanGetVar(TITAN_VOLUME_ID, "VolumeDialog") then SetCVar("Sound_DialogVolume", + TitanGetVar(TITAN_VOLUME_ID, "VolumeDialog")) end + if TitanGetVar(TITAN_VOLUME_ID, "VolumeSFX") then SetCVar("Sound_SFXVolume", + TitanGetVar(TITAN_VOLUME_ID, "VolumeSFX")) end + if TitanGetVar(TITAN_VOLUME_ID, "VolumeMusic") then SetCVar("Sound_MusicVolume", + TitanGetVar(TITAN_VOLUME_ID, "VolumeMusic")) end + -- if TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat") then SetCVar("OutboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat")) end + -- if TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat") then SetCVar("InboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat")) end end end -function TitanPanelVolumeButton_OnShow() - TitanPanelVolume_SetVolumeIcon(); +local function OnShow() + SetVolumeIcon(); end -function TitanPanelVolumeButton_OnEnter() +local function OnEnter() -- Confirm master volume value TitanPanelMasterVolumeControlSlider:SetValue(1 - GetCVar("Sound_MasterVolume")); TitanPanelAmbienceVolumeControlSlider:SetValue(1 - GetCVar("Sound_AmbienceVolume")); TitanPanelDialogVolumeControlSlider:SetValue(1 - GetCVar("Sound_DialogVolume")); TitanPanelSoundVolumeControlSlider:SetValue(1 - GetCVar("Sound_SFXVolume")); TitanPanelMusicVolumeControlSlider:SetValue(1 - GetCVar("Sound_MusicVolume")); --- TitanPanelMicrophoneVolumeControlSlider:SetValue(1 - GetCVar("OutboundChatVolume")); --- TitanPanelSpeakerVolumeControlSlider:SetValue(1 - GetCVar("InboundChatVolume")); - TitanPanelVolume_SetVolumeIcon(); + -- TitanPanelMicrophoneVolumeControlSlider:SetValue(1 - GetCVar("OutboundChatVolume")); + -- TitanPanelSpeakerVolumeControlSlider:SetValue(1 - GetCVar("InboundChatVolume")); + SetVolumeIcon(); end -- 'Master' -function TitanPanelMasterVolumeControlSlider_OnEnter(self) --- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MASTER_VOLUME, TitanPanelVolume_GetVolumeText(GetCVar("Sound_MasterVolume"))); +local function MasterSlider_OnEnter(self) + -- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MASTER_VOLUME, GetVolumeText(GetCVar("Sound_MasterVolume"))); self.tooltipText = "" GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); end -function TitanPanelMasterVolumeControlSlider_OnLeave(self) +local function MasterSlider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); end -function TitanPanelMasterVolumeControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(GetCVar("Sound_MasterVolume"))); - _G[self:GetName().."High"]:SetText(Titan.literals.low); - _G[self:GetName().."Low"]:SetText(Titan.literals.high); +local function MasterSlider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(GetCVar("Sound_MasterVolume"))); + _G[self:GetName() .. "High"]:SetText(Titan_Global.literals.low); + _G[self:GetName() .. "Low"]:SetText(Titan_Global.literals.high); self:SetMinMaxValues(0, 1); self:SetValueStep(0.01); self:SetObeyStepOnDrag(true) -- since 5.4.2 (Mists of Pandaria) self:SetValue(1 - GetCVar("Sound_MasterVolume")); end -function TitanPanelMasterVolumeControlSlider_OnValueChanged(self, a1) -_G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(1 - self:GetValue())); +local function MasterSlider_OnValueChanged(self, a1) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(1 - self:GetValue())); SetCVar("Sound_MasterVolume", 1 - self:GetValue()); TitanSetVar(TITAN_VOLUME_ID, "VolumeMaster", 1 - self:GetValue()) - TitanPanelVolume_SetVolumeIcon(); + SetVolumeIcon(); -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MASTER_VOLUME, TitanPanelVolume_GetVolumeText(1 - self:GetValue())); + self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MASTER_VOLUME, GetVolumeText(1 - self:GetValue())); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -function TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, a1) +local function OnMouseWheel(self, a1) local tempval = self:GetValue(); if a1 < 0 then - self:SetValue(tempval + 0.01); + self:SetValue(tempval + 0.01); end if a1 > 0 then - self:SetValue(tempval - 0.01); + self:SetValue(tempval - 0.01); end end -- 'Music' -function TitanPanelMusicVolumeControlSlider_OnEnter(self) --- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MUSIC_VOLUME, TitanPanelVolume_GetVolumeText(GetCVar("Sound_MusicVolume"))); +local function MusicSlider_OnEnter(self) + -- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MUSIC_VOLUME, GetVolumeText(GetCVar("Sound_MusicVolume"))); self.tooltipText = "" GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); end -function TitanPanelMusicVolumeControlSlider_OnLeave(self) +local function MusicSlider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); end -function TitanPanelMusicVolumeControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(GetCVar("Sound_MusicVolume"))); - _G[self:GetName().."High"]:SetText(Titan.literals.low); - _G[self:GetName().."Low"]:SetText(Titan.literals.high); +local function MusicSlider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(GetCVar("Sound_MusicVolume"))); + _G[self:GetName() .. "High"]:SetText(Titan_Global.literals.low); + _G[self:GetName() .. "Low"]:SetText(Titan_Global.literals.high); self:SetMinMaxValues(0, 1); self:SetValueStep(0.01); self:SetValue(1 - GetCVar("Sound_MusicVolume")); end -function TitanPanelMusicVolumeControlSlider_OnValueChanged(self, a1) -_G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(1 - self:GetValue())); +local function MusicSlider_OnValueChanged(self, a1) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(1 - self:GetValue())); SetCVar("Sound_MusicVolume", 1 - self:GetValue()); TitanSetVar(TITAN_VOLUME_ID, "VolumeMusic", 1 - self:GetValue()) -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MUSIC_VOLUME, TitanPanelVolume_GetVolumeText(1 - self:GetValue())); + self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_MUSIC_VOLUME, GetVolumeText(1 - self:GetValue())); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -- 'Sound Effects' -function TitanPanelSoundVolumeControlSlider_OnEnter(self) --- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_FX_VOLUME, TitanPanelVolume_GetVolumeText(GetCVar("Sound_SFXVolume"))); +local function SoundSlider_OnEnter(self) + -- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_FX_VOLUME, GetVolumeText(GetCVar("Sound_SFXVolume"))); self.tooltipText = "" GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); end -function TitanPanelSoundVolumeControlSlider_OnLeave(self) +local function SoundSlider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); end -function TitanPanelSoundVolumeControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(GetCVar("Sound_SFXVolume"))); - _G[self:GetName().."High"]:SetText(Titan.literals.low); - _G[self:GetName().."Low"]:SetText(Titan.literals.high); +local function SoundSlider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(GetCVar("Sound_SFXVolume"))); + _G[self:GetName() .. "High"]:SetText(Titan_Global.literals.low); + _G[self:GetName() .. "Low"]:SetText(Titan_Global.literals.high); self:SetMinMaxValues(0, 1); self:SetValueStep(0.01); self:SetValue(1 - GetCVar("Sound_SFXVolume")); end -function TitanPanelSoundVolumeControlSlider_OnValueChanged(self, a1) -_G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(1 - self:GetValue())); +local function SoundSlider_OnValueChanged(self, a1) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(1 - self:GetValue())); SetCVar("Sound_SFXVolume", 1 - self:GetValue()); TitanSetVar(TITAN_VOLUME_ID, "VolumeSFX", 1 - self:GetValue()) -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_FX_VOLUME, TitanPanelVolume_GetVolumeText(1 - self:GetValue())); + self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_FX_VOLUME, GetVolumeText(1 - self:GetValue())); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -- 'Ambience' -function TitanPanelAmbienceVolumeControlSlider_OnEnter(self) --- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_AMBIENCE_VOLUME, TitanPanelVolume_GetVolumeText(GetCVar("Sound_AmbienceVolume"))); +local function AmbienceSlider_OnEnter(self) + -- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_AMBIENCE_VOLUME, GetVolumeText(GetCVar("Sound_AmbienceVolume"))); self.tooltipText = "" GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); end -function TitanPanelAmbienceVolumeControlSlider_OnLeave(self) +local function AmbienceSlider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); end -function TitanPanelAmbienceVolumeControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(GetCVar("Sound_AmbienceVolume"))); - _G[self:GetName().."High"]:SetText(Titan.literals.low); - _G[self:GetName().."Low"]:SetText(Titan.literals.high); +local function AmbienceSlider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(GetCVar("Sound_AmbienceVolume"))); + _G[self:GetName() .. "High"]:SetText(Titan_Global.literals.low); + _G[self:GetName() .. "Low"]:SetText(Titan_Global.literals.high); self:SetMinMaxValues(0, 1); self:SetValueStep(0.01); self:SetValue(1 - GetCVar("Sound_AmbienceVolume")); end -function TitanPanelAmbienceVolumeControlSlider_OnValueChanged(self, a1) -_G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(1 - self:GetValue())); -local tempval = self:GetValue(); +local function AmbienceSlider_OnValueChanged(self, a1) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(1 - self:GetValue())); + local tempval = self:GetValue(); SetCVar("Sound_AmbienceVolume", 1 - self:GetValue()); TitanSetVar(TITAN_VOLUME_ID, "VolumeAmbience", 1 - self:GetValue()) -- Update GameTooltip if (self.tooltipText) then --- self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_VOLUME_CONTROL_TOOLTIP"], TitanPanelVolume_GetVolumeText(1 - self:GetValue())); - self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_ENABLE_AMBIENCE, TitanPanelVolume_GetVolumeText(1 - self:GetValue())); + -- self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_VOLUME_CONTROL_TOOLTIP"], GetVolumeText(1 - self:GetValue())); + self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_ENABLE_AMBIENCE, + GetVolumeText(1 - self:GetValue())); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -- 'Dialog' -function TitanPanelDialogVolumeControlSlider_OnEnter(self) --- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_DIALOG_VOLUME, TitanPanelVolume_GetVolumeText(GetCVar("Sound_DialogVolume"))); +local function DialogSlider_OnEnter(self) + -- self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_DIALOG_VOLUME, GetVolumeText(GetCVar("Sound_DialogVolume"))); self.tooltipText = "" GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); TitanUtils_StopFrameCounting(self:GetParent()); end -function TitanPanelDialogVolumeControlSlider_OnLeave(self) +local function DialogSlider_OnLeave(self) self.tooltipText = nil; GameTooltip:Hide(); TitanUtils_StartFrameCounting(self:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); end -function TitanPanelDialogVolumeControlSlider_OnShow(self) - _G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(GetCVar("Sound_DialogVolume"))); - _G[self:GetName().."High"]:SetText(Titan.literals.low); - _G[self:GetName().."Low"]:SetText(Titan.literals.high); +local function DialogSlider_OnShow(self) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(GetCVar("Sound_DialogVolume"))); + _G[self:GetName() .. "High"]:SetText(Titan_Global.literals.low); + _G[self:GetName() .. "Low"]:SetText(Titan_Global.literals.high); self:SetMinMaxValues(0, 1); self:SetValueStep(0.01); self:SetValue(1 - GetCVar("Sound_DialogVolume")); end -function TitanPanelDialogVolumeControlSlider_OnValueChanged(self, a1) -_G[self:GetName().."Text"]:SetText(TitanPanelVolume_GetVolumeText(1 - self:GetValue())); -local tempval = self:GetValue(); +local function DialogSlider_OnValueChanged(self, a1) + _G[self:GetName() .. "Text"]:SetText(GetVolumeText(1 - self:GetValue())); + local tempval = self:GetValue(); SetCVar("Sound_DialogVolume", 1 - self:GetValue()); TitanSetVar(TITAN_VOLUME_ID, "VolumeDialog", 1 - self:GetValue()) -- Update GameTooltip if (self.tooltipText) then --- self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_VOLUME_CONTROL_TOOLTIP"], TitanPanelVolume_GetVolumeText(1 - self:GetValue())); - self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_DIALOG_VOLUME, TitanPanelVolume_GetVolumeText(1 - self:GetValue())); + -- self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_VOLUME_CONTROL_TOOLTIP"], GetVolumeText(1 - self:GetValue())); + self.tooltipText = TitanOptionSlider_TooltipText(OPTION_TOOLTIP_DIALOG_VOLUME, GetVolumeText(1 - self:GetValue())); GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end -function TitanPanelVolume_GetVolumeText(volume) - return tostring(floor(100 * volume + 0.5)) .. "%"; -end - -function TitanPanelVolumeControlFrame_OnLoad(self) - _G[self:GetName().."Title"]:SetText(L["TITAN_VOLUME_CONTROL_TITLE"]); -- VOLUME - _G[self:GetName().."MasterTitle"]:SetText(L["TITAN_VOLUME_MASTER_CONTROL_TITLE"]); --MASTER_VOLUME - _G[self:GetName().."MusicTitle"]:SetText(L["TITAN_VOLUME_MUSIC_CONTROL_TITLE"]); - _G[self:GetName().."SoundTitle"]:SetText(L["TITAN_VOLUME_SOUND_CONTROL_TITLE"]); -- FX_VOLUME - _G[self:GetName().."AmbienceTitle"]:SetText(L["TITAN_VOLUME_AMBIENCE_CONTROL_TITLE"]); - _G[self:GetName().."DialogTitle"]:SetText(L["TITAN_VOLUME_DIALOG_CONTROL_TITLE"]); --- _G[self:GetName().."MicrophoneTitle"]:SetText(L["TITAN_VOLUME_MICROPHONE_CONTROL_TITLE"]); --- _G[self:GetName().."SpeakerTitle"]:SetText(L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"]); ---[[ +local function ControlFrame_OnLoad(self) + _G[self:GetName() .. "Title"]:SetText(L["TITAN_VOLUME_CONTROL_TITLE"]); -- VOLUME + _G[self:GetName() .. "MasterTitle"]:SetText(L["TITAN_VOLUME_MASTER_CONTROL_TITLE"]); --MASTER_VOLUME + _G[self:GetName() .. "MusicTitle"]:SetText(L["TITAN_VOLUME_MUSIC_CONTROL_TITLE"]); + _G[self:GetName() .. "SoundTitle"]:SetText(L["TITAN_VOLUME_SOUND_CONTROL_TITLE"]); -- FX_VOLUME + _G[self:GetName() .. "AmbienceTitle"]:SetText(L["TITAN_VOLUME_AMBIENCE_CONTROL_TITLE"]); + _G[self:GetName() .. "DialogTitle"]:SetText(L["TITAN_VOLUME_DIALOG_CONTROL_TITLE"]); + -- _G[self:GetName().."MicrophoneTitle"]:SetText(L["TITAN_VOLUME_MICROPHONE_CONTROL_TITLE"]); + -- _G[self:GetName().."SpeakerTitle"]:SetText(L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"]); + --[[ Blizzard decided to remove direct Backdrop API in 9.0 (Shadowlands) so inherit the template (XML) and set the values in the code (Lua) @@ -307,45 +295,27 @@ and set the values in the code (Lua) TitanPanelRightClickMenu_SetCustomBackdrop(self) end -function TitanPanelVolumeControlFrame_OnUpdate(self, elapsed) - TitanUtils_CheckFrameCounting(self, elapsed); -end - -function TitanPanelVolume_SetVolumeIcon() - local icon = _G["TitanPanelVolumeButtonIcon"]; - local masterVolume = tonumber(GetCVar("Sound_MasterVolume")); - if (masterVolume <= 0) then - icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH.."TitanVolumeMute"); - elseif (masterVolume < 0.33) then - icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH.."TitanVolumeLow"); - elseif (masterVolume < 0.66) then - icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH.."TitanVolumeMedium"); - else - icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH.."TitanVolumeHigh"); - end -end - -function TitanPanelVolumeButton_GetTooltipText() - local volumeMasterText = TitanPanelVolume_GetVolumeText(GetCVar("Sound_MasterVolume")); - local volumeSoundText = TitanPanelVolume_GetVolumeText(GetCVar("Sound_SFXVolume")); - local volumeMusicText = TitanPanelVolume_GetVolumeText(GetCVar("Sound_MusicVolume")); - local volumeAmbienceText = TitanPanelVolume_GetVolumeText(GetCVar("Sound_AmbienceVolume")); - local volumeDialogText = TitanPanelVolume_GetVolumeText(GetCVar("Sound_DialogVolume")); --- local volumeMicrophoneText = TitanPanelVolume_GetVolumeText(GetCVar("OutboundChatVolume")); --- local volumeSpeakerText = TitanPanelVolume_GetVolumeText(GetCVar("InboundChatVolume")); - return "".. - L["TITAN_VOLUME_MASTER_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMasterText).."\n".. - L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeSoundText).."\n".. - L["TITAN_VOLUME_MUSIC_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMusicText).."\n".. - L["TITAN_VOLUME_AMBIENCE_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeAmbienceText).."\n".. - L["TITAN_VOLUME_DIALOG_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeDialogText).."\n".. --- L["TITAN_VOLUME_MICROPHONE_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMicrophoneText).."\n".. --- L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeSpeakerText).."\n".. - TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT1"]).."\n".. +local function GetTooltipText() + local volumeMasterText = GetVolumeText(GetCVar("Sound_MasterVolume")); + local volumeSoundText = GetVolumeText(GetCVar("Sound_SFXVolume")); + local volumeMusicText = GetVolumeText(GetCVar("Sound_MusicVolume")); + local volumeAmbienceText = GetVolumeText(GetCVar("Sound_AmbienceVolume")); + local volumeDialogText = GetVolumeText(GetCVar("Sound_DialogVolume")); + -- local volumeMicrophoneText = GetVolumeText(GetCVar("OutboundChatVolume")); + -- local volumeSpeakerText = GetVolumeText(GetCVar("InboundChatVolume")); + return "" .. + L["TITAN_VOLUME_MASTER_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMasterText) .. "\n" .. + L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeSoundText) .. "\n" .. + L["TITAN_VOLUME_MUSIC_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMusicText) .. "\n" .. + L["TITAN_VOLUME_AMBIENCE_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeAmbienceText) .. "\n" .. + L["TITAN_VOLUME_DIALOG_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeDialogText) .. "\n" .. + -- L["TITAN_VOLUME_MICROPHONE_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMicrophoneText).."\n".. + -- L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeSpeakerText).."\n".. + TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT1"]) .. "\n" .. TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT2"]); end -function TitanPanelRightClickMenu_PrepareVolumeMenu() +function CreateMenu() TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_VOLUME_ID].menuText); local info = {}; @@ -353,7 +323,7 @@ function TitanPanelRightClickMenu_PrepareVolumeMenu() info.text = L["TITAN_VOLUME_MENU_AUDIO_OPTIONS_LABEL"]; info.func = function() ShowUIPanel(VideoOptionsFrame); - end + end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info.text = L["TITAN_VOLUME_MENU_OVERRIDE_BLIZZ_SETTINGS"]; @@ -367,43 +337,79 @@ function TitanPanelRightClickMenu_PrepareVolumeMenu() TitanPanelRightClickMenu_AddControlVars(TITAN_VOLUME_ID) end +local function OnLoad(self) + local notes = "" + .. "Adds a volume control icon on your Titan Bar.\n" + -- .."- xxx.\n" + self.registry = { + id = TITAN_VOLUME_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_VOLUME_MENU_TEXT"], + menuTextFunction = CreateMenu, + tooltipTitle = VOLUME, --L["TITAN_VOLUME_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + iconWidth = 32, + iconButtonWidth = 18, + notes = notes, + controlVariables = { + ShowIcon = false, + ShowLabelText = false, + ShowColoredText = false, + DisplayOnRightSide = true, + }, + savedVariables = { + OverrideBlizzSettings = false, + VolumeMaster = 1, + VolumeAmbience = 0.5, + VolumeDialog = 0.5, + VolumeSFX = 0.5, + VolumeMusic = 0.5, + -- VolumeOutboundChat = 1, + -- VolumeInboundChat = 1, + DisplayOnRightSide = 1, + } + }; + self:RegisterEvent("PLAYER_ENTERING_WORLD"); +end + -- ====== Create needed frames local function Create_Frames() if _G[TITAN_VOLUME_BUTTON] then return -- if already created end - + -- general container frame local f = CreateFrame("Frame", nil, UIParent) --- f:Hide() + -- f:Hide() -- Titan plugin button local window = CreateFrame("Button", TITAN_VOLUME_BUTTON, f, "TitanPanelIconTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelVolumeButton_OnLoad(window); --- TitanPanelButton_OnLoad(window); -- Titan XML template calls this...w - + OnLoad(window); + -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this...w + window:SetScript("OnShow", function(self) - TitanPanelVolumeButton_OnShow() + OnShow() TitanPanelButton_OnShow(self) end) window:SetScript("OnEnter", function(self) - TitanPanelVolumeButton_OnEnter() + OnEnter() TitanPanelButton_OnEnter(self) end) window:SetScript("OnEvent", function(self, event, ...) - TitanPanelVolumeButton_OnEvent(self, event, ...) --- ... not allowed here so grab the potential args that may be needed --- TitanPanelVolumeButton_OnEvent(self, event, arg1, arg2, arg3, arg4) + OnEvent(self, event, ...) + -- ... not allowed here so grab the potential args that may be needed + -- OnEvent(self, event, arg1, arg2, arg3, arg4) end) ----[===[ + ---[===[ -- Config screen local cname = "TitanPanelVolumeControlFrame" local config = CreateFrame("Frame", cname, f, BackdropTemplateMixin and "BackdropTemplate") - config:SetFrameStrata("FULLSCREEN") -- + config:SetFrameStrata("FULLSCREEN") -- config:Hide() config:SetWidth(400) config:SetHeight(200) @@ -415,29 +421,28 @@ local function Create_Frames() TitanUtils_StartFrameCounting(self, 0.5) end) config:SetScript("OnUpdate", function(self, elapsed) --- TitanPanelVolumeControlFrame_OnUpdate(self, elapsed) TitanUtils_CheckFrameCounting(self, elapsed) end) - + -- Config font sections local str = nil local style = "GameFontNormalSmall" - str = config:CreateFontString(cname.."Title", "ARTWORK", style) + str = config:CreateFontString(cname .. "Title", "ARTWORK", style) str:SetPoint("TOP", config, 0, -10) - str = config:CreateFontString(cname.."MasterTitle", "ARTWORK", style) + str = config:CreateFontString(cname .. "MasterTitle", "ARTWORK", style) str:SetPoint("TOP", config, -160, -30) - str = config:CreateFontString(cname.."SoundTitle", "ARTWORK", style) + str = config:CreateFontString(cname .. "SoundTitle", "ARTWORK", style) str:SetPoint("TOP", config, -90, -30) - str = config:CreateFontString(cname.."MusicTitle", "ARTWORK", style) + str = config:CreateFontString(cname .. "MusicTitle", "ARTWORK", style) str:SetPoint("TOP", config, -20, -30) - str = config:CreateFontString(cname.."AmbienceTitle", "ARTWORK", style) + str = config:CreateFontString(cname .. "AmbienceTitle", "ARTWORK", style) str:SetPoint("TOP", config, 50, -30) - str = config:CreateFontString(cname.."DialogTitle", "ARTWORK", style) + str = config:CreateFontString(cname .. "DialogTitle", "ARTWORK", style) str:SetPoint("TOP", config, 130, -30) -- Config slider sections @@ -448,101 +453,101 @@ local function Create_Frames() local master = CreateFrame("Slider", "TitanPanelMasterVolumeControlSlider", config, inherit) master:SetPoint("TOP", config, -160, -60) master:SetScript("OnShow", function(self) - TitanPanelMasterVolumeControlSlider_OnShow(self) + MasterSlider_OnShow(self) end) - master:SetScript("OnValueChanged", function(self) - TitanPanelMasterVolumeControlSlider_OnValueChanged(self, value) + master:SetScript("OnValueChanged", function(self, value) + MasterSlider_OnValueChanged(self, value) end) master:SetScript("OnMouseWheel", function(self, delta) - TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, delta) + OnMouseWheel(self, delta) end) master:SetScript("OnEnter", function(self) - TitanPanelMasterVolumeControlSlider_OnEnter(self) + MasterSlider_OnEnter(self) end) master:SetScript("OnLeave", function(self) - TitanPanelMasterVolumeControlSlider_OnLeave(self) + MasterSlider_OnLeave(self) end) -- Sound local sound = CreateFrame("Slider", "TitanPanelSoundVolumeControlSlider", config, inherit) sound:SetPoint("TOP", config, -90, -60) sound:SetScript("OnShow", function(self) - TitanPanelSoundVolumeControlSlider_OnShow(self) + SoundSlider_OnShow(self) end) - sound:SetScript("OnValueChanged", function(self) - TitanPanelSoundVolumeControlSlider_OnValueChanged(self, value) + sound:SetScript("OnValueChanged", function(self, value) + SoundSlider_OnValueChanged(self, value) end) sound:SetScript("OnMouseWheel", function(self, delta) - TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, delta) + OnMouseWheel(self, delta) end) sound:SetScript("OnEnter", function(self) - TitanPanelSoundVolumeControlSlider_OnEnter(self) + SoundSlider_OnEnter(self) end) sound:SetScript("OnLeave", function(self) - TitanPanelSoundVolumeControlSlider_OnLeave(self) + SoundSlider_OnLeave(self) end) -- Music local music = CreateFrame("Slider", "TitanPanelMusicVolumeControlSlider", config, inherit) music:SetPoint("TOP", config, -20, -60) music:SetScript("OnShow", function(self) - TitanPanelMusicVolumeControlSlider_OnShow(self) + MusicSlider_OnShow(self) end) - music:SetScript("OnValueChanged", function(self) - TitanPanelMusicVolumeControlSlider_OnValueChanged(self, value) + music:SetScript("OnValueChanged", function(self, value) + MusicSlider_OnValueChanged(self, value) end) music:SetScript("OnMouseWheel", function(self, delta) - TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, delta) + OnMouseWheel(self, delta) end) music:SetScript("OnEnter", function(self) - TitanPanelMusicVolumeControlSlider_OnEnter(self) + MusicSlider_OnEnter(self) end) music:SetScript("OnLeave", function(self) - TitanPanelMusicVolumeControlSlider_OnLeave(self) + MusicSlider_OnLeave(self) end) -- Ambience local ambience = CreateFrame("Slider", "TitanPanelAmbienceVolumeControlSlider", config, inherit) ambience:SetPoint("TOP", config, 50, -60) ambience:SetScript("OnShow", function(self) - TitanPanelAmbienceVolumeControlSlider_OnShow(self) + AmbienceSlider_OnShow(self) end) - ambience:SetScript("OnValueChanged", function(self) - TitanPanelAmbienceVolumeControlSlider_OnValueChanged(self, value) + ambience:SetScript("OnValueChanged", function(self, value) + AmbienceSlider_OnValueChanged(self, value) end) ambience:SetScript("OnMouseWheel", function(self, delta) - TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, delta) + OnMouseWheel(self, delta) end) ambience:SetScript("OnEnter", function(self) - TitanPanelAmbienceVolumeControlSlider_OnEnter(self) + AmbienceSlider_OnEnter(self) end) ambience:SetScript("OnLeave", function(self) - TitanPanelAmbienceVolumeControlSlider_OnLeave(self) + AmbienceSlider_OnLeave(self) end) -- Dialog local dialog = CreateFrame("Slider", "TitanPanelDialogVolumeControlSlider", config, inherit) dialog:SetPoint("TOP", config, 130, -60) dialog:SetScript("OnShow", function(self) - TitanPanelDialogVolumeControlSlider_OnShow(self) + DialogSlider_OnShow(self) end) - dialog:SetScript("OnValueChanged", function(self) - TitanPanelDialogVolumeControlSlider_OnValueChanged(self, value) + dialog:SetScript("OnValueChanged", function(self, value) + DialogSlider_OnValueChanged(self, value) end) dialog:SetScript("OnMouseWheel", function(self, delta) - TitanPanelUnifiedVolumeControlSlider_OnMouseWheel(self, delta) + OnMouseWheel(self, delta) end) dialog:SetScript("OnEnter", function(self) - TitanPanelDialogVolumeControlSlider_OnEnter(self) + DialogSlider_OnEnter(self) end) dialog:SetScript("OnLeave", function(self) - TitanPanelDialogVolumeControlSlider_OnLeave(self) + DialogSlider_OnLeave(self) end) -- Now that the parts exist, initialize - TitanPanelVolumeControlFrame_OnLoad(config) + ControlFrame_OnLoad(config) ---]===] + --]===] end Create_Frames() -- do the work diff --git a/TitanVolume/TitanVolume_Mainline.toc b/TitanVolume/TitanVolume_Mainline.toc index 747d3a0..052f58d 100644 --- a/TitanVolume/TitanVolume_Mainline.toc +++ b/TitanVolume/TitanVolume_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume_Vanilla.toc b/TitanVolume/TitanVolume_Vanilla.toc index 4321660..8d10a37 100644 --- a/TitanVolume/TitanVolume_Vanilla.toc +++ b/TitanVolume/TitanVolume_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume_Wrath.toc b/TitanVolume/TitanVolume_Wrath.toc index 5ef848b..3c8e0dc 100644 --- a/TitanVolume/TitanVolume_Wrath.toc +++ b/TitanVolume/TitanVolume_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP.lua b/TitanXP/TitanXP.lua index 919e90f..cf0c98a 100644 --- a/TitanXP/TitanXP.lua +++ b/TitanXP/TitanXP.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field --[[ -- ************************************************************************** -- * TitanXP.lua @@ -9,18 +10,38 @@ -- ******************************** Constants ******************************* local TITAN_XP_ID = "XP"; local TITAN_XP_BUTTON = "TitanPanel"..TITAN_XP_ID.."Button" - local _G = getfenv(0); local TITAN_XP_FREQUENCY = 1; local updateTable = {TITAN_XP_ID, TITAN_PANEL_UPDATE_ALL}; -- ******************************** Variables ******************************* -local TitanPanelXPButton_ButtonAdded = nil; -local found = nil; local lastMobXP, lastXP, XPGain = 0, 0, 0 -local L = {} -- For AceLocale +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local trace = false +local trace_update = false + -- ******************************** Functions ******************************* +--[[ +-- ************************************************************************** +-- NAME : SetIcon() +-- DESC : Define icon based on faction +-- ************************************************************************** +--]] +local function SetIcon() + local icon = TitanPanelXPButtonIcon; + local factionGroup, factionName = UnitFactionGroup("player"); + + if (factionGroup == "Alliance") then + icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-Alliance"); + icon:SetTexCoord(0.046875, 0.609375, 0.03125, 0.59375); + elseif (factionGroup == "Horde") then + icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-Horde"); + icon:SetTexCoord(0.046875, 0.609375, 0.015625, 0.578125); + else + icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA"); + icon:SetTexCoord(0.046875, 0.609375, 0.03125, 0.59375); + end +end --[[ Add commas or period in the value given as needed @@ -41,61 +62,16 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelXP_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** ---]] -function TitanPanelXPButton_OnLoad(self) - local notes = "" - .."Adds information to Titan Panel about XP earned and time to level.\n" --- .."- xxx.\n" - self.registry = { - id = TITAN_XP_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_XP_MENU_TEXT"], - buttonTextFunction = "TitanPanelXPButton_GetButtonText", - tooltipTitle = L["TITAN_XP_TOOLTIP"], - tooltipTextFunction = "TitanPanelXPButton_GetTooltipText", - iconWidth = 16, - notes = notes, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowColoredText = false, - DisplayOnRightSide = true - }, - savedVariables = { - DisplayType = "ShowXPPerHourSession", - ShowIcon = 1, - ShowLabelText = 1, - ShowSimpleRested = false, - ShowSimpleToLevel = false, - ShowSimpleNumOfKills = false, - ShowSimpleNumOfGains = false, - UseSeperatorComma = true, - UseSeperatorPeriod = false, - DisplayOnRightSide = false, - } - }; --- self:RegisterEvent("PLAYER_ENTERING_WORLD"); -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_OnShow() +-- NAME : OnShow() -- DESC : Display the icon in the bar --- NOTE : For a lack of better check at the moment TitanPanelXPButton_ButtonAdded --- is a global variable set to true only when a button has just been --- added to the panel -- ************************************************************************** --]] -function TitanPanelXPButton_OnShow(self) - local ttext = "" +local function OnShow(self) + local txt = "" if (not self.sessionTime) then -- initial login / PEW self.sessionTime = time(); - ttext = ttext.."Sess reset" + txt = txt.."Sess reset" end if (not self.initXP) then -- initial login / PEW self.initXP = UnitXP("player"); @@ -103,61 +79,49 @@ function TitanPanelXPButton_OnShow(self) self.sessionXP = 0; self.startSessionTime = time(); lastXP = self.initXP; - ttext = ttext.." | Init" + txt = txt.." | Init" end self:RegisterEvent("TIME_PLAYED_MSG"); self:RegisterEvent("PLAYER_XP_UPDATE"); self:RegisterEvent("PLAYER_LEVEL_UP"); self:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); - TitanPanelXPButton_SetIcon(); - ttext = ttext.." | Events" + SetIcon(); + txt = txt.." | Events" - found = nil; - if not TitanPanelXPButton_ButtonAdded then - RequestTimePlayed(); - TitanPanelXPButton_ButtonAdded = true; - ttext = ttext.." | Time played" - end + -- Time played received attached to an event + RequestTimePlayed(); + txt = txt.." | Time played" if trace then - print("XP _OnShow" - .." "..tostring(ttext).."" - ) + local dbg = "XP _OnShow" + .." "..tostring(txt).."" + TitanPluginDebug(TITAN_XP_ID, dbg) end end - -function TitanPanelXPButton_OnHide(self) +local function OnHide(self) self:UnregisterEvent("TIME_PLAYED_MSG"); self:UnregisterEvent("PLAYER_XP_UPDATE"); self:UnregisterEvent("PLAYER_LEVEL_UP"); self:UnregisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); - - if (TitanPanelSettings) then - for i = 1, table.getn(TitanPanelSettings.Buttons) do - if(TitanPanelSettings.Buttons[i] == TITAN_XP_ID) then - found = true; - end - end - if not found then - TitanPanelXPButton_ButtonAdded = nil - end - end end --[[ -- ************************************************************************** --- NAME : TitanPanelXPButton_OnEvent(arg1, arg2) +-- NAME : OnEvent(arg1, arg2) -- DESC : Parse events registered to addon and act on them -- VARS : arg1 = <research> , arg2 = <research> -- ************************************************************************** --]] -function TitanPanelXPButton_OnEvent(self, event, a1, a2, ...) +local function OnEvent(self, event, a1, a2, ...) + local txt = "" if trace then - print("XP _OnEvent" + txt = "_OnEvent" .." "..tostring(event).."" - ) +-- .." "..tostring(a1).."" +-- .." "..tostring(a2).."" + TitanPluginDebug(TITAN_XP_ID, txt) end if (event == "PLAYER_ENTERING_WORLD") then @@ -180,11 +144,11 @@ function TitanPanelXPButton_OnEvent(self, event, a1, a2, ...) if XPGain < 0 then XPGain = 0 end self.sessionXP = UnitXP("player") - self.initXP + self.accumXP; if trace then - print("XP Ev " + txt = "XP Ev " .." unit "..tostring(format("%0.1f", UnitXP("player"))).."" .." init "..tostring(format("%0.1f", self.initXP)).."" .." acc "..tostring(format("%0.1f", self.accumXP)).."" - ) + TitanPluginDebug(TITAN_XP_ID, txt) end elseif (event == "PLAYER_LEVEL_UP") then self.levelTime = 0; @@ -199,12 +163,12 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelXPButton_OnUpdate(elapsed) +-- NAME : OnUpdate(elapsed) -- DESC : Update button data -- VARS : elapsed = <research> -- ************************************************************************** --]] -function TitanPanelXPButton_OnUpdate(self, elapsed) +local function OnUpdate(self, elapsed) TITAN_XP_FREQUENCY = TITAN_XP_FREQUENCY - elapsed; if (TITAN_XP_FREQUENCY <=0) then TITAN_XP_FREQUENCY = 1; @@ -216,41 +180,56 @@ function TitanPanelXPButton_OnUpdate(self, elapsed) end end +--[[ +-- ************************************************************************** +-- NAME : ShowXPPerHourLevel() +-- DESC : Display per hour to level data in bar if set +-- ************************************************************************** +--]] +local function ShowXPPerHourLevel() + TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPPerHourLevel"); + TitanPanelButton_UpdateButton(TITAN_XP_ID); + TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); +end --[[ -- ************************************************************************** --- NAME : TitanPanelXPButton_GetButtonText(id) +-- NAME : GetButtonText(id) -- DESC : Calculate time based logic for button text -- VARS : id = button ID -- NOTE : Because the panel gets loaded before XP we need to check whether -- the variables have been initialized and take action if they haven't -- ************************************************************************** --]] -function TitanPanelXPButton_GetButtonText(id) +local function GetButtonText(id) + local txt = "" if (TitanPanelXPButton.startSessionTime == nil) then if trace then - print("XP " + txt = "XP " .." "..tostring("start not set - too early").."" - ) + TitanPluginDebug(TITAN_XP_ID, txt) end return else - local button, id = TitanUtils_GetButton(id, true); + local button, id = TitanUtils_GetButton(id); local totalXP = UnitXPMax("player"); local currentXP = UnitXP("player"); local toLevelXP = totalXP - currentXP; - local sessionXP = button.sessionXP; + local sessionXP = button and button.sessionXP; local xpPerHour, xpPerHourText, timeToLevel, timeToLevelText; local sessionTime = time() - TitanPanelXPButton.startSessionTime; local levelTime = TitanPanelXPButton.levelTime; local numofkills, numofgains; if lastMobXP ~= 0 then numofkills = math.ceil(toLevelXP / lastMobXP) else numofkills = _G["UNKNOWN"] end if XPGain ~= 0 then numofgains = math.ceil(toLevelXP / XPGain) else numofgains = _G["UNKNOWN"] end - if trace then - print("XP / Hr" - .." sxp"..tostring(format("%0.1f", button.sessionXP)).."" + if trace_update then + txt = "XP / Hr" + .." sxp"..tostring(format("%0.1f", sessionXP)).."" .." st"..tostring(format("%0.1f", TitanPanelXPButton.startSessionTime)).."" - ) + TitanPluginDebug(TITAN_XP_ID, txt) end if (levelTime) then @@ -262,14 +241,13 @@ function TitanPanelXPButton_GetButtonText(id) xpPerHourText = comma_value(math.floor(xpPerHour+0.5)); timeToLevelText = TitanUtils_GetEstTimeText(timeToLevel); - if trace then - print("XP / Hr" + if trace_update then + txt = "XP / Hr" .." hr: "..tostring(format("%0.1f", xpPerHour)).."" .." '"..tostring(xpPerHourText).."'" .." lvl: "..tostring(format("%0.1f", timeToLevel)).."" .." '"..tostring(timeToLevelText).."'" - .." '"..tostring(res).."'" - ) + TitanPluginDebug(TITAN_XP_ID, txt) end return L["TITAN_XP_BUTTON_LABEL_XPHR_SESSION"], TitanUtils_GetHighlightText(xpPerHourText), L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"], TitanUtils_GetHighlightText(timeToLevelText); @@ -321,10 +299,8 @@ function TitanPanelXPButton_GetButtonText(id) end end else - if trace then - print("XP " - .."("..L["TITAN_XP_UPDATE_PENDING"]..")" - ) + if trace_update then + TitanPluginDebug(TITAN_XP_ID, "pending") end return "("..L["TITAN_XP_UPDATE_PENDING"]..")"; end @@ -333,11 +309,11 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelXPButton_GetTooltipText() +-- NAME : GetTooltipText() -- DESC : Display tooltip text -- ************************************************************************** --]] -function TitanPanelXPButton_GetTooltipText() +local function GetTooltipText() local totalTime = TitanPanelXPButton.totalTime; local sessionTime = time() - TitanPanelXPButton.startSessionTime; local levelTime = TitanPanelXPButton.levelTime; @@ -377,34 +353,7 @@ function TitanPanelXPButton_GetTooltipText() L["TITAN_XP_TOOLTIP_TOLEVEL_SESSION"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisSession)); end ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_SetIcon() --- DESC : Define icon based on faction --- ************************************************************************** ---]] -function TitanPanelXPButton_SetIcon() - local icon = TitanPanelXPButtonIcon; - local factionGroup, factionName = UnitFactionGroup("player"); - - if (factionGroup == "Alliance") then - icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-Alliance"); - icon:SetTexCoord(0.046875, 0.609375, 0.03125, 0.59375); - elseif (factionGroup == "Horde") then - icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-Horde"); - icon:SetTexCoord(0.046875, 0.609375, 0.015625, 0.578125); - else - icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA"); - icon:SetTexCoord(0.046875, 0.609375, 0.03125, 0.59375); - end -end - local function Seperator(chosen) ---[[ -TitanDebug("Sep: " -..(chosen or "?").." " -) ---]] if chosen == "UseSeperatorComma" then TitanSetVar(TITAN_XP_ID, "UseSeperatorComma", true); TitanSetVar(TITAN_XP_ID, "UseSeperatorPeriod", false); @@ -418,11 +367,76 @@ end --[[ -- ************************************************************************** +-- NAME : ShowXPPerHourSession() +-- DESC : Display per hour in session data in bar if set +-- ************************************************************************** +--]] +local function ShowXPPerHourSession() + TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPPerHourSession"); + TitanPanelButton_UpdateButton(TITAN_XP_ID); + TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); +end + +--[[ +-- ************************************************************************** +-- NAME : ShowSessionTime() +-- DESC : Display session time in bar if set +-- ************************************************************************** +--]] +local function ShowSessionTime() + TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowSessionTime"); + TitanPanelButton_UpdateButton(TITAN_XP_ID); + TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); +end + +--[[ +-- ************************************************************************** +-- NAME : ShowXPSimple() +-- DESC : Display simple XP data (% level, rest, xp to level) in bar if set +-- ************************************************************************** +--]] +local function ShowXPSimple() + TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPSimple"); + TitanPanelButton_UpdateButton(TITAN_XP_ID); + end + +--[[ +-- ************************************************************************** +-- NAME : ResetSession() +-- DESC : Reset session and accumulated variables +-- ************************************************************************** +--]] +local function ResetSession() + TitanPanelXPButton.initXP = UnitXP("player"); + TitanPanelXPButton.accumXP = 0; + TitanPanelXPButton.sessionXP = 0; + TitanPanelXPButton.startSessionTime = time(); + lastXP = TitanPanelXPButton.initXP; +end + +--[[ +-- ************************************************************************** +-- NAME : RefreshPlayed() +-- DESC : Get total time played +-- ************************************************************************** +--]] +local function RefreshPlayed() + RequestTimePlayed(); +end + +--[[ +-- ************************************************************************** -- NAME : TitanPanelRightClickMenu_PrepareXPMenu() -- DESC : Display rightclick menu options -- ************************************************************************** --]] -function TitanPanelRightClickMenu_PrepareXPMenu() +local function CreateMenu() local info = {}; if TitanPanelRightClickMenu_GetDropdownLevel() == 2 then @@ -458,32 +472,32 @@ function TitanPanelRightClickMenu_PrepareXPMenu() TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_XP_ID].menuText); info = {}; info.text = L["TITAN_XP_MENU_SHOW_XPHR_THIS_SESSION"]; - info.func = TitanPanelXPButton_ShowXPPerHourSession; + info.func = ShowXPPerHourSession; info.checked = TitanUtils_Ternary("ShowXPPerHourSession" == TitanGetVar(TITAN_XP_ID, "DisplayType"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SHOW_XPHR_THIS_LEVEL"]; - info.func = TitanPanelXPButton_ShowXPPerHourLevel; + info.func = ShowXPPerHourLevel; info.checked = TitanUtils_Ternary("ShowXPPerHourLevel" == TitanGetVar(TITAN_XP_ID, "DisplayType"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SHOW_SESSION_TIME"]; - info.func = TitanPanelXPButton_ShowSessionTime; + info.func = ShowSessionTime; info.checked = TitanUtils_Ternary("ShowSessionTime" == TitanGetVar(TITAN_XP_ID, "DisplayType"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SHOW_RESTED_TOLEVELUP"]; - info.func = TitanPanelXPButton_ShowXPSimple; + info.func = ShowXPSimple; info.hasArrow = 1; info.checked = TitanUtils_Ternary("ShowXPSimple" == TitanGetVar(TITAN_XP_ID, "DisplayType"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); TitanPanelRightClickMenu_AddSpacer(); - TitanPanelRightClickMenu_AddCommand(L["TITAN_XP_MENU_RESET_SESSION"], TITAN_XP_ID, "TitanPanelXPButton_ResetSession"); - TitanPanelRightClickMenu_AddCommand(L["TITAN_XP_MENU_REFRESH_PLAYED"], TITAN_XP_ID, "TitanPanelXPButton_RefreshPlayed"); + TitanPanelRightClickMenu_AddCommand(L["TITAN_XP_MENU_RESET_SESSION"], TITAN_XP_ID, ResetSession); + TitanPanelRightClickMenu_AddCommand(L["TITAN_XP_MENU_REFRESH_PLAYED"], TITAN_XP_ID, RefreshPlayed); end TitanPanelRightClickMenu_AddSpacer(); @@ -508,83 +522,45 @@ end --[[ -- ************************************************************************** --- NAME : TitanPanelXPButton_ShowSessionTime() --- DESC : Display session time in bar if set --- ************************************************************************** ---]] -function TitanPanelXPButton_ShowSessionTime() - TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowSessionTime"); - TitanPanelButton_UpdateButton(TITAN_XP_ID); - TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); -end - - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_ShowXPPerHourSession() --- DESC : Display per hour in session data in bar if set --- ************************************************************************** ---]] -function TitanPanelXPButton_ShowXPPerHourSession() - TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPPerHourSession"); - TitanPanelButton_UpdateButton(TITAN_XP_ID); - TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_ShowXPPerHourLevel() --- DESC : Display per hour to level data in bar if set --- ************************************************************************** ---]] -function TitanPanelXPButton_ShowXPPerHourLevel() - TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPPerHourLevel"); - TitanPanelButton_UpdateButton(TITAN_XP_ID); - TitanSetVar(TITAN_XP_ID, "ShowSimpleRested", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleToLevel", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false); - TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false); -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_ShowXPSimple() --- DESC : Display simple XP data (% level, rest, xp to level) in bar if set --- ************************************************************************** ---]] -function TitanPanelXPButton_ShowXPSimple() - TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPSimple"); - TitanPanelButton_UpdateButton(TITAN_XP_ID); - end - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_ResetSession() --- DESC : Reset session and accumulated variables --- ************************************************************************** ---]] -function TitanPanelXPButton_ResetSession() - TitanPanelXPButton.initXP = UnitXP("player"); - TitanPanelXPButton.accumXP = 0; - TitanPanelXPButton.sessionXP = 0; - TitanPanelXPButton.startSessionTime = time(); - lastXP = TitanPanelXPButton.initXP; -end - ---[[ --- ************************************************************************** --- NAME : TitanPanelXPButton_RefreshPlayed() --- DESC : Get total time played +-- NAME : OnLoad() +-- DESC : Registers the plugin upon it loading -- ************************************************************************** --]] -function TitanPanelXPButton_RefreshPlayed() - RequestTimePlayed(); +local function OnLoad(self) + local notes = "" + .."Adds information to Titan Panel about XP earned and time to level.\n" +-- .."- xxx.\n" + self.registry = { + id = TITAN_XP_ID, + category = "Built-ins", + version = TITAN_VERSION, + menuText = L["TITAN_XP_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_XP_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowColoredText = false, + DisplayOnRightSide = true + }, + savedVariables = { + DisplayType = "ShowXPPerHourSession", + ShowIcon = 1, + ShowLabelText = 1, + ShowSimpleRested = false, + ShowSimpleToLevel = false, + ShowSimpleNumOfKills = false, + ShowSimpleNumOfGains = false, + UseSeperatorComma = true, + UseSeperatorPeriod = false, + DisplayOnRightSide = false, + } + }; +-- self:RegisterEvent("PLAYER_ENTERING_WORLD"); end -- ====== Create needed frames @@ -601,26 +577,25 @@ local function Create_Frames() local window = CreateFrame("Button", TITAN_XP_BUTTON, f, "TitanPanelComboTemplate") window:SetFrameStrata("FULLSCREEN") -- Using SetScript("OnLoad", does not work - TitanPanelXPButton_OnLoad(window); + OnLoad(window); -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... window:SetScript("OnShow", function(self) - TitanPanelXPButton_OnShow(self) + OnShow(self) TitanPanelButton_OnShow(self) end) window:SetScript("OnHide", function(self) - TitanPanelXPButton_OnHide(self) + OnHide(self) end) window:SetScript("OnEvent", function(self, event, ...) - TitanPanelXPButton_OnEvent(self, event, ...) + OnEvent(self, event, ...) end) window:SetScript("OnUpdate", function(self, elapsed) - TitanPanelXPButton_OnUpdate(self, elapsed) + OnUpdate(self, elapsed) end) end if TITAN_ID then -- it exists - L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) Create_Frames() -- do the work end diff --git a/TitanXP/TitanXP_Mainline.toc b/TitanXP/TitanXP_Mainline.toc index 7ca0c26..ccfebab 100644 --- a/TitanXP/TitanXP_Mainline.toc +++ b/TitanXP/TitanXP_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100205 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP_Vanilla.toc b/TitanXP/TitanXP_Vanilla.toc index 576251c..b559415 100644 --- a/TitanXP/TitanXP_Vanilla.toc +++ b/TitanXP/TitanXP_Vanilla.toc @@ -1,6 +1,6 @@ -## Interface: 11501 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Interface: 11500 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP_Wrath.toc b/TitanXP/TitanXP_Wrath.toc index 9f77d62..a3de9ea 100644 --- a/TitanXP/TitanXP_Wrath.toc +++ b/TitanXP/TitanXP_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.5|r -## Version: 8.0.5 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.6|r +## Version: 8.0.6 ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: