From 75e50ba487afa894cef7ea07436a9fdf13d6eff5 Mon Sep 17 00:00:00 2001 From: urnati Date: Wed, 12 Apr 2023 22:11:58 -0400 Subject: [PATCH] - Rename files to be Titan<> (remove Panel); LDBToTitan now TitanLDB - TOC expanded - removed embed XML - Move Ace to libs/Ace; LDB lib to libs - Utils : fix for Config > Plugins > Show not working properly - Titan : Bunch of Right click menu changes to use the drop down API properly; streamline; and cleanup - Titan R click menu : Players listed in Profile menu now in alpha order --- Titan/LDBToTitan.lua | 922 -------- Titan/LibDataBroker-1.1.lua | 90 - Titan/Titan.lua | 2215 ++++++++++++++++++++ Titan/Titan.toc | 23 +- Titan/TitanLDB.lua | 922 ++++++++ Titan/TitanPanel.lua | 2188 ------------------- Titan/TitanPanelTemplate.lua | 1550 -------------- Titan/TitanPanelTemplate.xml | 173 -- Titan/TitanTemplate.lua | 1550 ++++++++++++++ Titan/TitanTemplate.xml | 172 ++ Titan/TitanUtils.lua | 7 +- Titan/TitanVariables.lua | 30 + Titan/_Titan_Lib_Notes.txt | 11 + Titan/embeds.xml | 15 - Titan/libs/Ace/Ace3.lua | 110 + Titan/libs/Ace/Ace3.toc | 27 + Titan/libs/Ace/AceAddon-3.0/AceAddon-3.0.lua | 653 ++++++ Titan/libs/Ace/AceAddon-3.0/AceAddon-3.0.xml | 4 + Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua | 58 + Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.xml | 8 + .../AceConfigCmd-3.0/AceConfigCmd-3.0.lua | 794 +++++++ .../AceConfigCmd-3.0/AceConfigCmd-3.0.xml | 4 + .../AceConfigDialog-3.0/AceConfigDialog-3.0.lua | 2015 ++++++++++++++++++ .../AceConfigDialog-3.0/AceConfigDialog-3.0.xml | 4 + .../AceConfigRegistry-3.0.lua | 371 ++++ .../AceConfigRegistry-3.0.xml | 4 + .../AceGUI-3.0-SharedMediaWidgets.toc | 16 + .../BackgroundWidget.lua | 235 +++ .../AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua | 230 ++ .../AceGUI-3.0-SharedMediaWidgets/FontWidget.lua | 216 ++ .../AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua | 264 +++ .../StatusbarWidget.lua | 233 ++ .../AceGUI-3.0-SharedMediaWidgets/prototypes.lua | 266 +++ .../AceGUI-3.0-SharedMediaWidgets/widget.xml | 9 + .../Ace/AceGUI-3.0-SharedMediaWidgets/CHANGES.txt | 12 + .../Libs/AceGUI-3.0/AceGUI-3.0.lua | 1026 +++++++++ .../Libs/AceGUI-3.0/AceGUI-3.0.xml | 28 + .../widgets/AceGUIContainer-BlizOptionsGroup.lua | 138 ++ .../widgets/AceGUIContainer-DropDownGroup.lua | 157 ++ .../AceGUI-3.0/widgets/AceGUIContainer-Frame.lua | 316 +++ .../widgets/AceGUIContainer-InlineGroup.lua | 103 + .../widgets/AceGUIContainer-ScrollFrame.lua | 215 ++ .../widgets/AceGUIContainer-SimpleGroup.lua | 69 + .../widgets/AceGUIContainer-TabGroup.lua | 349 +++ .../widgets/AceGUIContainer-TreeGroup.lua | 715 +++++++ .../AceGUI-3.0/widgets/AceGUIContainer-Window.lua | 336 +++ .../AceGUI-3.0/widgets/AceGUIWidget-Button.lua | 103 + .../AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua | 296 +++ .../widgets/AceGUIWidget-ColorPicker.lua | 190 ++ .../widgets/AceGUIWidget-DropDown-Items.lua | 471 +++++ .../AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua | 737 +++++++ .../AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 263 +++ .../AceGUI-3.0/widgets/AceGUIWidget-Heading.lua | 78 + .../Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 140 ++ .../widgets/AceGUIWidget-InteractiveLabel.lua | 94 + .../AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua | 249 +++ .../Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 179 ++ .../widgets/AceGUIWidget-MultiLineEditBox.lua | 366 ++++ .../AceGUI-3.0/widgets/AceGUIWidget-Slider.lua | 284 +++ .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 239 +++ .../CallbackHandler-1.0/CallbackHandler-1.0.xml | 4 + .../Libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 300 +++ .../Libs/LibSharedMedia-3.0/lib.xml | 4 + .../Libs/LibStub/LibStub.lua | 30 + .../Libs/LibStub/LibStub.toc | 9 + .../Ace/AceGUI-3.0-SharedMediaWidgets/widget.xml | 4 + Titan/libs/Ace/AceGUI-3.0/AceGUI-3.0.lua | 1020 +++++++++ Titan/libs/Ace/AceGUI-3.0/AceGUI-3.0.xml | 28 + .../widgets/AceGUIContainer-BlizOptionsGroup.lua | 143 ++ .../widgets/AceGUIContainer-DropDownGroup.lua | 157 ++ .../AceGUI-3.0/widgets/AceGUIContainer-Frame.lua | 318 +++ .../widgets/AceGUIContainer-InlineGroup.lua | 103 + .../widgets/AceGUIContainer-ScrollFrame.lua | 215 ++ .../widgets/AceGUIContainer-SimpleGroup.lua | 69 + .../widgets/AceGUIContainer-TabGroup.lua | 535 +++++ .../widgets/AceGUIContainer-TreeGroup.lua | 719 +++++++ .../AceGUI-3.0/widgets/AceGUIContainer-Window.lua | 336 +++ .../Ace/AceGUI-3.0/widgets/AceGUIWidget-Button.lua | 103 + .../AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua | 292 +++ .../widgets/AceGUIWidget-ColorPicker.lua | 186 ++ .../widgets/AceGUIWidget-DropDown-Items.lua | 471 +++++ .../AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua | 732 +++++++ .../AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 259 +++ .../AceGUI-3.0/widgets/AceGUIWidget-Heading.lua | 78 + .../Ace/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 140 ++ .../widgets/AceGUIWidget-InteractiveLabel.lua | 94 + .../AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua | 245 +++ .../Ace/AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 179 ++ .../widgets/AceGUIWidget-MultiLineEditBox.lua | 369 ++++ .../Ace/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua | 280 +++ Titan/libs/Ace/AceHook-3.0/AceHook-3.0.lua | 511 +++++ Titan/libs/Ace/AceHook-3.0/AceHook-3.0.xml | 4 + Titan/libs/Ace/AceLocale-3.0/AceLocale-3.0.lua | 137 ++ Titan/libs/Ace/AceLocale-3.0/AceLocale-3.0.xml | 4 + Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua | 278 +++ Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.xml | 4 + Titan/libs/Ace/Bindings.xml | 5 + Titan/libs/Ace/CHANGES.txt | 93 + .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 212 ++ .../CallbackHandler-1.0/CallbackHandler-1.0.xml | 4 + Titan/libs/Ace/LICENSE.txt | 29 + Titan/libs/Ace/LibQTip-1.0/CHANGES.txt | 10 + Titan/libs/Ace/LibQTip-1.0/LICENSE.txt | 29 + Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua | 1551 ++++++++++++++ Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc | 14 + Titan/libs/Ace/LibQTip-1.0/LibStub/LibStub.lua | 51 + Titan/libs/Ace/LibQTip-1.0/lib.xml | 4 + Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt | 29 + .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 212 ++ .../Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc | 18 + .../LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 300 +++ .../LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml | 4 + .../Ace/LibSharedMedia-3.0/LibStub/LibStub.lua | 51 + Titan/libs/Ace/LibSharedMedia-3.0/lib.xml | 5 + Titan/libs/Ace/LibStub/LibStub.lua | 30 + Titan/libs/Ace/changelog.txt | 435 ++++ Titan/libs/Ace3.lua | 110 - Titan/libs/Ace3.toc | 27 - Titan/libs/AceAddon-3.0/AceAddon-3.0.lua | 653 ------ Titan/libs/AceAddon-3.0/AceAddon-3.0.xml | 4 - Titan/libs/AceConfig-3.0/AceConfig-3.0.lua | 58 - Titan/libs/AceConfig-3.0/AceConfig-3.0.xml | 8 - .../AceConfigCmd-3.0/AceConfigCmd-3.0.lua | 794 ------- .../AceConfigCmd-3.0/AceConfigCmd-3.0.xml | 4 - .../AceConfigDialog-3.0/AceConfigDialog-3.0.lua | 2015 ------------------ .../AceConfigDialog-3.0/AceConfigDialog-3.0.xml | 4 - .../AceConfigRegistry-3.0.lua | 371 ---- .../AceConfigRegistry-3.0.xml | 4 - .../AceGUI-3.0-SharedMediaWidgets.toc | 16 - .../BackgroundWidget.lua | 235 --- .../AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua | 230 -- .../AceGUI-3.0-SharedMediaWidgets/FontWidget.lua | 216 -- .../AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua | 264 --- .../StatusbarWidget.lua | 233 -- .../AceGUI-3.0-SharedMediaWidgets/prototypes.lua | 266 --- .../AceGUI-3.0-SharedMediaWidgets/widget.xml | 9 - .../libs/AceGUI-3.0-SharedMediaWidgets/CHANGES.txt | 12 - .../Libs/AceGUI-3.0/AceGUI-3.0.lua | 1026 --------- .../Libs/AceGUI-3.0/AceGUI-3.0.xml | 28 - .../widgets/AceGUIContainer-BlizOptionsGroup.lua | 138 -- .../widgets/AceGUIContainer-DropDownGroup.lua | 157 -- .../AceGUI-3.0/widgets/AceGUIContainer-Frame.lua | 316 --- .../widgets/AceGUIContainer-InlineGroup.lua | 103 - .../widgets/AceGUIContainer-ScrollFrame.lua | 215 -- .../widgets/AceGUIContainer-SimpleGroup.lua | 69 - .../widgets/AceGUIContainer-TabGroup.lua | 349 --- .../widgets/AceGUIContainer-TreeGroup.lua | 715 ------- .../AceGUI-3.0/widgets/AceGUIContainer-Window.lua | 336 --- .../AceGUI-3.0/widgets/AceGUIWidget-Button.lua | 103 - .../AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua | 296 --- .../widgets/AceGUIWidget-ColorPicker.lua | 190 -- .../widgets/AceGUIWidget-DropDown-Items.lua | 471 ----- .../AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua | 737 ------- .../AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 263 --- .../AceGUI-3.0/widgets/AceGUIWidget-Heading.lua | 78 - .../Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 140 -- .../widgets/AceGUIWidget-InteractiveLabel.lua | 94 - .../AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua | 249 --- .../Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 179 -- .../widgets/AceGUIWidget-MultiLineEditBox.lua | 366 ---- .../AceGUI-3.0/widgets/AceGUIWidget-Slider.lua | 284 --- .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 239 --- .../CallbackHandler-1.0/CallbackHandler-1.0.xml | 4 - .../Libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 300 --- .../Libs/LibSharedMedia-3.0/lib.xml | 4 - .../Libs/LibStub/LibStub.lua | 30 - .../Libs/LibStub/LibStub.toc | 9 - .../libs/AceGUI-3.0-SharedMediaWidgets/widget.xml | 4 - Titan/libs/AceGUI-3.0/AceGUI-3.0.lua | 1020 --------- Titan/libs/AceGUI-3.0/AceGUI-3.0.xml | 28 - .../widgets/AceGUIContainer-BlizOptionsGroup.lua | 143 -- .../widgets/AceGUIContainer-DropDownGroup.lua | 157 -- .../AceGUI-3.0/widgets/AceGUIContainer-Frame.lua | 318 --- .../widgets/AceGUIContainer-InlineGroup.lua | 103 - .../widgets/AceGUIContainer-ScrollFrame.lua | 215 -- .../widgets/AceGUIContainer-SimpleGroup.lua | 69 - .../widgets/AceGUIContainer-TabGroup.lua | 535 ----- .../widgets/AceGUIContainer-TreeGroup.lua | 719 ------- .../AceGUI-3.0/widgets/AceGUIContainer-Window.lua | 336 --- .../AceGUI-3.0/widgets/AceGUIWidget-Button.lua | 103 - .../AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua | 292 --- .../widgets/AceGUIWidget-ColorPicker.lua | 186 -- .../widgets/AceGUIWidget-DropDown-Items.lua | 471 ----- .../AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua | 732 ------- .../AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua | 259 --- .../AceGUI-3.0/widgets/AceGUIWidget-Heading.lua | 78 - .../libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 140 -- .../widgets/AceGUIWidget-InteractiveLabel.lua | 94 - .../AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua | 245 --- .../libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 179 -- .../widgets/AceGUIWidget-MultiLineEditBox.lua | 369 ---- .../AceGUI-3.0/widgets/AceGUIWidget-Slider.lua | 280 --- Titan/libs/AceHook-3.0/AceHook-3.0.lua | 511 ----- Titan/libs/AceHook-3.0/AceHook-3.0.xml | 4 - Titan/libs/AceLocale-3.0/AceLocale-3.0.lua | 137 -- Titan/libs/AceLocale-3.0/AceLocale-3.0.xml | 4 - Titan/libs/AceTimer-3.0/AceTimer-3.0.lua | 278 --- Titan/libs/AceTimer-3.0/AceTimer-3.0.xml | 4 - Titan/libs/Bindings.xml | 5 - Titan/libs/CHANGES.txt | 93 - .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 212 -- .../CallbackHandler-1.0/CallbackHandler-1.0.xml | 4 - Titan/libs/LICENSE.txt | 29 - Titan/libs/LibDataBroker-1.1.lua | 90 + Titan/libs/LibQTip-1.0/CHANGES.txt | 10 - Titan/libs/LibQTip-1.0/LICENSE.txt | 29 - Titan/libs/LibQTip-1.0/LibQTip-1.0.lua | 1551 -------------- Titan/libs/LibQTip-1.0/LibQTip-1.0.toc | 14 - Titan/libs/LibQTip-1.0/LibStub/LibStub.lua | 51 - Titan/libs/LibQTip-1.0/lib.xml | 4 - Titan/libs/LibSharedMedia-3.0/CHANGES.txt | 29 - .../CallbackHandler-1.0/CallbackHandler-1.0.lua | 212 -- .../libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc | 18 - .../LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 300 --- .../LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml | 4 - Titan/libs/LibSharedMedia-3.0/LibStub/LibStub.lua | 51 - Titan/libs/LibSharedMedia-3.0/lib.xml | 5 - Titan/libs/LibStub/LibStub.lua | 30 - Titan/libs/_Titan_Lib_Notes.txt | 8 - Titan/libs/changelog.txt | 435 ---- 220 files changed, 29130 insertions(+), 29076 deletions(-) delete mode 100644 Titan/LDBToTitan.lua delete mode 100644 Titan/LibDataBroker-1.1.lua create mode 100644 Titan/Titan.lua create mode 100644 Titan/TitanLDB.lua delete mode 100644 Titan/TitanPanel.lua delete mode 100644 Titan/TitanPanelTemplate.lua delete mode 100644 Titan/TitanPanelTemplate.xml create mode 100644 Titan/TitanTemplate.lua create mode 100644 Titan/TitanTemplate.xml create mode 100644 Titan/_Titan_Lib_Notes.txt delete mode 100644 Titan/embeds.xml create mode 100644 Titan/libs/Ace/Ace3.lua create mode 100644 Titan/libs/Ace/Ace3.toc create mode 100644 Titan/libs/Ace/AceAddon-3.0/AceAddon-3.0.lua create mode 100644 Titan/libs/Ace/AceAddon-3.0/AceAddon-3.0.xml create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.xml create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua create mode 100644 Titan/libs/Ace/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets.toc create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/prototypes.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/widget.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/CHANGES.txt create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/AceGUI-3.0.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/AceGUI-3.0.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/LibSharedMedia-3.0/lib.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/LibStub/LibStub.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/Libs/LibStub/LibStub.toc create mode 100644 Titan/libs/Ace/AceGUI-3.0-SharedMediaWidgets/widget.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0/AceGUI-3.0.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/AceGUI-3.0.xml create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIContainer-Window.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Button.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Label.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua create mode 100644 Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua create mode 100644 Titan/libs/Ace/AceHook-3.0/AceHook-3.0.lua create mode 100644 Titan/libs/Ace/AceHook-3.0/AceHook-3.0.xml create mode 100644 Titan/libs/Ace/AceLocale-3.0/AceLocale-3.0.lua create mode 100644 Titan/libs/Ace/AceLocale-3.0/AceLocale-3.0.xml create mode 100644 Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua create mode 100644 Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.xml create mode 100644 Titan/libs/Ace/Bindings.xml create mode 100644 Titan/libs/Ace/CHANGES.txt create mode 100644 Titan/libs/Ace/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Titan/libs/Ace/CallbackHandler-1.0/CallbackHandler-1.0.xml create mode 100644 Titan/libs/Ace/LICENSE.txt create mode 100644 Titan/libs/Ace/LibQTip-1.0/CHANGES.txt create mode 100644 Titan/libs/Ace/LibQTip-1.0/LICENSE.txt create mode 100644 Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua create mode 100644 Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc create mode 100644 Titan/libs/Ace/LibQTip-1.0/LibStub/LibStub.lua create mode 100644 Titan/libs/Ace/LibQTip-1.0/lib.xml create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/LibStub/LibStub.lua create mode 100644 Titan/libs/Ace/LibSharedMedia-3.0/lib.xml create mode 100644 Titan/libs/Ace/LibStub/LibStub.lua create mode 100644 Titan/libs/Ace/changelog.txt delete mode 100755 Titan/libs/Ace3.lua delete mode 100755 Titan/libs/Ace3.toc delete mode 100755 Titan/libs/AceAddon-3.0/AceAddon-3.0.lua delete mode 100755 Titan/libs/AceAddon-3.0/AceAddon-3.0.xml delete mode 100755 Titan/libs/AceConfig-3.0/AceConfig-3.0.lua delete mode 100755 Titan/libs/AceConfig-3.0/AceConfig-3.0.xml delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua delete mode 100755 Titan/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets.toc delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/prototypes.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/AceGUI-3.0-SharedMediaWidgets/widget.xml delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/CHANGES.txt delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/AceGUI-3.0.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/AceGUI-3.0.xml delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/LibSharedMedia-3.0/lib.xml delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/LibStub/LibStub.lua delete mode 100644 Titan/libs/AceGUI-3.0-SharedMediaWidgets/Libs/LibStub/LibStub.toc delete mode 100755 Titan/libs/AceGUI-3.0-SharedMediaWidgets/widget.xml delete mode 100755 Titan/libs/AceGUI-3.0/AceGUI-3.0.lua delete mode 100755 Titan/libs/AceGUI-3.0/AceGUI-3.0.xml delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua delete mode 100755 Titan/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua delete mode 100755 Titan/libs/AceHook-3.0/AceHook-3.0.lua delete mode 100755 Titan/libs/AceHook-3.0/AceHook-3.0.xml delete mode 100755 Titan/libs/AceLocale-3.0/AceLocale-3.0.lua delete mode 100755 Titan/libs/AceLocale-3.0/AceLocale-3.0.xml delete mode 100755 Titan/libs/AceTimer-3.0/AceTimer-3.0.lua delete mode 100755 Titan/libs/AceTimer-3.0/AceTimer-3.0.xml delete mode 100755 Titan/libs/Bindings.xml delete mode 100755 Titan/libs/CHANGES.txt delete mode 100755 Titan/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua delete mode 100755 Titan/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml delete mode 100755 Titan/libs/LICENSE.txt create mode 100644 Titan/libs/LibDataBroker-1.1.lua delete mode 100755 Titan/libs/LibQTip-1.0/CHANGES.txt delete mode 100755 Titan/libs/LibQTip-1.0/LICENSE.txt delete mode 100755 Titan/libs/LibQTip-1.0/LibQTip-1.0.lua delete mode 100755 Titan/libs/LibQTip-1.0/LibQTip-1.0.toc delete mode 100755 Titan/libs/LibQTip-1.0/LibStub/LibStub.lua delete mode 100755 Titan/libs/LibQTip-1.0/lib.xml delete mode 100644 Titan/libs/LibSharedMedia-3.0/CHANGES.txt delete mode 100755 Titan/libs/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua delete mode 100755 Titan/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc delete mode 100755 Titan/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua delete mode 100755 Titan/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml delete mode 100755 Titan/libs/LibSharedMedia-3.0/LibStub/LibStub.lua delete mode 100755 Titan/libs/LibSharedMedia-3.0/lib.xml delete mode 100755 Titan/libs/LibStub/LibStub.lua delete mode 100644 Titan/libs/_Titan_Lib_Notes.txt delete mode 100755 Titan/libs/changelog.txt diff --git a/Titan/LDBToTitan.lua b/Titan/LDBToTitan.lua deleted file mode 100644 index 03c3560..0000000 --- a/Titan/LDBToTitan.lua +++ /dev/null @@ -1,922 +0,0 @@ ---[[ File -NAME: LibDataBrokerToTitan.lua -DESC: A "bridge" module to ensure proper registration and communication of LDB plugins with Titan Panel ---]] ---[[ API -NAME: Titan LDB overview -DESC: Titan will automatically convert a LDB type addon to a Titan plugin. -Only LDB types listed in the LDB 1.1 spec are supported. Custom types are not supported. - -Supported type -- "launcher" become "icon" plugins - icon* - always shown - OnClick* - - label^ - - right side^ - default - tooltip -- "data source" become "combo" plugins with icon; a tooltip/Click; and optional label - icon^ - - OnClick - - text*^ - or value & suffix - label^ - - OnEnter - - OnLeave - - tooltip - OnTooltipShow - - -- "macro" become "combo" plugins with icon; a tooltip/Click; and optional label - icon^ - - commandtext^ - - label^ - - OnEnter - - OnLeave - - tooltip - OnTooltipShow - - -* required by LDB spec -^ user controlled show / hide -:DESC ---]] - ---[[ doc ------------------------------------------------------------------ --- By Titan Dev team --- Originally by Tristanian aka "TristTitan" as a Titan member --- Created and initially commited on : July 29th, 2008 ------------------------------------------------------------------ ---]] -local xcategories = { --- Titan categories mapping to match addon metadata information - ["Combat"] = "Combat", - ["General"] = "General", - ["Information"] = "Information", - ["Interface"] = "Interface", - ["Profession"] = "Profession", --- Ace2 table mapping to Titan categories in order to match --- addon metadata information - ["Action Bars"] = "Interface", - ["Auction"] = "Information", - ["Audio"] = "Interface", - ["Battlegrounds/PvP"] = "Information", - ["Buffs"] = "Information", - ["Chat/Communication"] = "Interface", - ["Druid"] = "Information", - ["Hunter"] = "Information", - ["Mage"] = "Information", - ["Paladin"] = "Information", - ["Priest"] = "Information", - ["Rogue"] = "Information", - ["Shaman"] = "Information", - ["Warlock"] = "Information", - ["Warrior"] = "Information", - ["Healer"] = "Information", - ["Tank"] = "Information", - ["Caster"] = "Information", --- ["Combat"] = "Combat", - ["Compilations"] = "General", - ["Data Export"] = "General", - ["Development Tools "] = "General", - ["Guild"] = "Information", - ["Frame Modification"] = "Interface", - ["Interface Enhancements"] = "Interface", - ["Inventory"] = "Information", - ["Library"] = "General", - ["Map"] = "Interface", - ["Mail"] = "Information", - ["Miscellaneous"] = "General", - ["Misc"] = "General", - ["Quest"] = "Information", - ["Raid"] = "Information", - ["Tradeskill"] = "Profession", - ["UnitFrame"] = "Interface", -} -local LAUNCHER = "launcher" -local DATA_SOURCE = "data source" -local SupportedDOTypes = {DATA_SOURCE, LAUNCHER, "macro"} -- in the 1.1 spec - --- constants & variables -local CALLBACK_PREFIX = "LibDataBroker_AttributeChanged_" -local NAME_PREFIX = "" --"LDBT_" -local _G = getfenv(0); -local InCombatLockdown = _G.InCombatLockdown; --- Create control frame so we can get events -local LDBToTitan = CreateFrame("Frame", "LDBTitan") -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"; - --- Events we want for LDBToTitan -LDBToTitan:RegisterEvent("PLAYER_LOGIN") ---LDBToTitan:RegisterEvent("PLAYER_ENTERING_WORLD") - -local function If_Show_Tooltip() - local use_mod = TitanAllGetVar("UseTooltipModifer") - local use_alt = TitanAllGetVar("TooltipModiferAlt") - local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") - local use_shift = TitanAllGetVar("TooltipModiferShift") - local ok = false - local tmp_txt = "" - if use_mod then - if (use_alt and IsAltKeyDown()) - or (use_ctrl and IsControlKeyDown()) - or (use_shift and IsShiftKeyDown()) - then - ok = true - end - else - ok = true - end - return ok -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBSetOwnerPosition -DESC: Properly anchor tooltips of the Titan (LDB) plugin -VAR: parent -VAR: anchorPoint -VAR: relativeToFrame -VAR: relativePoint -VAR: xOffset -VAR: yOffset -VAR: frame ---]] -function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) - if frame:GetName() == "GameTooltip" then - -- Changes for 9.1.5 Removed the background template from the GameTooltip - -- Making changes to it difficult and possibly changing the tooltip globally. - - frame:SetOwner(parent, "ANCHOR_NONE"); - - -- set font size for the Game Tooltip - if not TitanPanelGetVar("DisableTooltipFont") then - if TitanTooltipScaleSet < 1 then - TitanTooltipOrigScale = GameTooltip:GetScale(); - TitanTooltipScaleSet = TitanTooltipScaleSet + 1; - end - frame:SetScale(TitanPanelGetVar("TooltipFont")); - end - end - frame:ClearAllPoints(); - frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBSetTooltip -DESC: Fill in the tooltip for the Titan (LDB) plugin -VAR: name - Titan id of the plugin -VAR: frame - tooltip frame -VAR: func - tooltip function to be run -OUT: None ---]] -function LDBToTitan:TitanLDBSetTooltip(name, frame, func) --- Check to see if we allow tooltips to be shown - if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then - return - end - - local button = TitanUtils_GetButton(name); - local scale = TitanPanelGetVar("Scale"); - local offscreenX, offscreenY; - local i = TitanPanel_GetButtonNumber(name); - local bar = TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(name) - local vert = TitanBarData[bar].vert - -- Get TOP or BOTTOM for the anchor and relative anchor - local rel_pt, pt - if vert == TITAN_TOP then - pt = "TOP" - rel_pt = "BOTTOM" - else - pt = "BOTTOM" - rel_pt = "TOP" - end - - if _G[bar] 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 - offscreenX, offscreenY = TitanUtils_GetOffscreen(frame); - if ( offscreenX == -1 ) then - self:TitanLDBSetOwnerPosition(button, pt.."LEFT", bar, - rel_pt.."LEFT", 0, 0, frame); - elseif ( offscreenX == 1 ) then - self:TitanLDBSetOwnerPosition(button, pt.."RIGHT", bar, - rel_pt.."RIGHT", 0, 0, frame); - end - else - end - - if func and If_Show_Tooltip() then func(frame) end; -- TODO: use pcall?? - frame:Show(); -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBHandleScripts -DESC: Script Handler for the Titan (LDB) plugin -VAR: event - event to process -VAR: name - id of the plugin -VAR: _ - not used -VAR: func - function to be run -VAR: obj - LDB object -OUT: None -NOTE: -- This implementation will work fine for a static tooltip but may have implications for dynamic ones so for now, we'll only set it once (no callback) and see what happens -:NOTE ---]] -function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) - local TitanPluginframe = _G["TitanPanel"..NAME_PREFIX..name.."Button"]; - - -- tooltip - if event:find("tooltip") and not event:find("OnTooltipShow") then - local pluginframe = _G[obj.tooltip] or obj.tooltip - if pluginframe then - TitanPluginframe:SetScript("OnEnter", function(self) - TitanPanelButton_OnEnter(self); - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) - end - ) - - TitanPluginframe:SetScript("OnMouseDown", function(self) - pluginframe:Hide(); - end - ) - - if pluginframe:GetScript("OnLeave") then - -- do nothing - else - TitanPluginframe:SetScript("OnLeave", function(self) - if obj.OnLeave then - obj.OnLeave(self) - end - pluginframe:Hide(); - TitanPanelButton_OnLeave(self); - end - ) - end - - if pluginframe:GetName()~="GameTooltip" then - if pluginframe:GetScript("OnShow") then - -- do nothing - else - pluginframe:SetScript("OnShow", function(self) - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) - end - ) - end - end - end - - -- OnTooltipShow - elseif event:find("OnTooltipShow") then - TitanPluginframe:SetScript("OnEnter", function(self) - if TITAN_PANEL_MOVING == 0 and func then - LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, GameTooltip, func); - end - TitanPanelButton_OnEnter(self); - end - ) - TitanPluginframe:SetScript("OnLeave", function(self) - GameTooltip:Hide(); - TitanPanelButton_OnLeave(self); - end - ) - - -- OnDoubleClick - elseif event:find("OnDoubleClick") and not event:find("OnClick") then - TitanPluginframe:SetScript("OnDoubleClick", function(self, button) - if TITAN_PANEL_MOVING == 0 then - func(self, button) - end - end - ) - - -- OnClick - elseif event:find("OnClick") then - TitanPluginframe:SetScript("OnClick", function(self, button) - if TITAN_PANEL_MOVING == 0 then - func(self, button) - end - -- implement a safeguard, since the DO may actually use - -- Blizzy dropdowns ! - if not TitanPanelRightClickMenu_IsVisible() then - TitanPanelButton_OnClick(self, button); - else - TitanUtils_CloseAllControlFrames(); - end - end - ) - -- OnEnter - else - TitanPluginframe:SetScript("OnEnter", function(self) - -- Check for tooltip libs without embedding them - if AceLibrary and AceLibrary:HasInstance("Tablet-2.0") then - Tablet = AceLibrary("Tablet-2.0") - end - LibQTip = LibStub("LibQTip-1.0", true) - -- Check to see if we allow tooltips to be shown - if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then - -- if a plugin is using tablet, then detach and close the tooltip - if Tablet and Tablet:IsRegistered(TitanPluginframe) - and Tablet:IsAttached(TitanPluginframe) then - Tablet:Detach(TitanPluginframe); - Tablet:Close(TitanPluginframe); - end - return; - else - -- if a plugin is using tablet, then re-attach the tooltip - -- (it will auto-open on mouseover) - if Tablet and Tablet:IsRegistered(TitanPluginframe) - and not Tablet:IsAttached(TitanPluginframe) then - Tablet:Attach(TitanPluginframe); - end - end - -- if a plugin is using tablet then set its transparency - -- and font size accordingly - if Tablet and Tablet:IsRegistered(TitanPluginframe) then - Tablet:SetTransparency(TitanPluginframe, TitanPanelGetVar("TooltipTrans")) - if not TitanPanelGetVar("DisableTooltipFont") then - Tablet:SetFontSizePercent(TitanPluginframe, TitanPanelGetVar("TooltipFont")) - elseif TitanPanelGetVar("DisableTooltipFont") - and Tablet:GetFontSizePercent(TitanPluginframe)~=1 then - Tablet:SetFontSizePercent(TitanPluginframe, 1) - end - end - -- set original tooltip scale for GameTooltip - if not TitanPanelGetVar("DisableTooltipFont") then - TitanTooltipOrigScale = GameTooltip:GetScale(); - end - -- call OnEnter on LDB Object - if TITAN_PANEL_MOVING == 0 and func and If_Show_Tooltip() then - func(self) - end - - TitanPanelButton_OnEnter(self); - -- LibQTip-1.0 support code - if LibQTip then - local tt = nil - local key, tip - for key, tip in LibQTip:IterateTooltips() do - if tip then - local _, relativeTo = tip:GetPoint() - if relativeTo - and relativeTo:GetName() == TitanPluginframe:GetName() then - tt = tip - break - end - end - end - if tt then - -- set transparency - local red, green, blue, _ = tt:GetBackdropColor() - local red2, green2, blue2, _ = tt:GetBackdropBorderColor() - tt:SetBackdropColor(red,green,blue, - TitanPanelGetVar("TooltipTrans")) - tt:SetBackdropBorderColor(red2,green2,blue2, - TitanPanelGetVar("TooltipTrans")) - end - end - -- /LibQTip-1.0 support code - end - ) - - -- OnLeave - TitanPluginframe:SetScript("OnLeave", function(self) - if obj.OnLeave then - obj.OnLeave(self) - end - TitanPanelButton_OnLeave(self); - end - ) - end -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBTextUpdate -DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text of the LDB object -VAR: _ - not used -VAR: name - id of the plugin -VAR: event - event to process -VAR: attr - LDB obj attribute (field) that changed -VAR: value - new value of attr -VAR: dataobj - LDB object -OUT: None ---]] -function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) - -- just in case the LDB is active before Titan can register it... - if not Titan__InitializedPEW then - -- plugins have not been registered yet. - return - end - -- This check is overkill but just in case... - local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) - local ldb = plugin and plugin.LDBVariables - if not ldb then - -- This plugin has not been registered - return - end - - -- Accept the various display elements and update the Titan plugin - if attr == "value" then ldb.value = value end - if attr == "suffix" then ldb.suffix = value end - if attr == "text" then ldb.text = value end - if attr == "label" then ldb.label = value end - - -- Now update the button with the change - TitanPanelButton_UpdateButton(NAME_PREFIX..name) -end - ---[[ Titan -NAME: TitanLDBShowText -DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text -VAR: name - id of the plugin -OUT: label of text to show -OUT: text to show ---]] -function TitanLDBShowText(name) - -- Set 'label1' and 'value1' for the Titan button display - local nametrim = string.gsub (name, "LDBT_", ""); - local fontstring = _G["TitanPanel"..NAME_PREFIX..nametrim..TITAN_PANEL_BUTTON_TEXT]; - local separator = ": " - local lab1, val1 = "", "" - local plugin = TitanUtils_GetPlugin(name) - local ldb = plugin and plugin.LDBVariables - - if ldb then -- sanity check - -- Check for display label - if TitanGetVar(name, "ShowLabelText") then - lab1 = (ldb.label or "") - else - lab1 = "" - end - - if lab1 == "" then - -- leave alone - else - lab1 = lab1..separator - end - - -- Check for display text - -- Check for display text - -- .text is required to show - -- .value is the text of the value - 100.0 in 100.0 FPS - -- .suffix is the text after the value - FPS in 100.0 FPS - if TitanGetVar(name, "ShowRegularText") then - val1 = (ldb.text or "") - else - val1 = "" - end - else - -- return values will be empty strings - end - - if lab1 == "" then - lab1 = nil - else - lab1 = TitanUtils_GetNormalText(lab1) - end - if val1 == "" then - val1 = nil - else - val1 = TitanGetVar(name, "ShowColoredText") - and TitanUtils_GetGreenText(val1) or TitanUtils_GetHighlightText(val1) - end - return lab1, val1 -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBTextUpdate -DESC: Icon callback for the Titan (LDB) plugin when the LDB addon changes the icon of the LDB object -VAR: _ - not used -VAR: name - id of the plugin -VAR: attr - LDB obj attribute (field) that changed -VAR: value - new value of attr -VAR: dataobj - LDB object -OUT: None ---]] -function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) - -- just in case the LDB is active before Titan can register it... - if not Titan__InitializedPEW then - -- no plugins are registered yet - return - end - -- This check is overkill but just in case... - local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) - local ldb = plugin and plugin.LDBVariables - if not ldb then - -- This plugin is not registered yet - return - end - - if attr == "icon" then - TitanPlugins[NAME_PREFIX..name].icon = value; - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name); - end - - -- support for iconCoords, iconR, iconG, iconB attributes - if attr == "iconCoords" then - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, value); - end - - if attr == "iconR" or attr == "iconB" or attr == "iconG" then - TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, nil, - dataobj.iconR, dataobj.iconG, dataobj.iconB); - end -end - ---[[ Titan -NAME: TitanLDBRefreshButton -DESC: Refresh all text & icon for LDB addons that were successfully registered -VAR: None -OUT: None -NOTE: -- Ensure all the LDB buttons are updated. -- This is called once x seconds after PEW. This helps close the gap where LDB addons set their text on their PEW event -:NOTE ---]] -function TitanLDBRefreshButton() --- TitanDebug("LDB: RefreshButton") - for name, obj in ldb:DataObjectIterator() do - if obj then - local unused = nil - LDBToTitan:TitanLDBTextUpdate(unused, name, "text", (obj.text or ""), obj) - LDBToTitan:TitanLDBIconUpdate(unused, name, "icon", (obj.icon or iconTitanDefault), obj) - else --- TitanDebug("LDB: '"..name.."' no refresh") - end - end -end - ---[[ Titan -NAME: LDBToTitan:TitanLDBCreateObject -DESC: New DO (Data Object) gets created here -VAR: _ - not used -VAR: name - id of the plugin -VAR: obj - LDB object -OUT: None -NOTE: -- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object)and creates a Titan plugin. -- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended. -:NOTE ---]] -function LDBToTitan:TitanLDBCreateObject(_, name, obj) - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug(tostring(name).." Attempting to register "); - end - - -- couple sanity checks - if not obj or not name then - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("LDB request to create Titan plugin was unrecognizable!!!!"); - end - return - end - - -- anything to pass to the developer / user - local notes = "" - - -- sanity check for supported types - obj.type = obj.type or "Unknown" - local supported = false -- assume failure - for idx in ipairs(SupportedDOTypes) do - if obj.type and obj.type == SupportedDOTypes[idx] then - supported = true - end - end - if supported then - -- all is good - continue plugin creation - else - -- Create enough of a plugin to tell the user / developer - -- that this plugin failed miserably - local issue = "Unsupported LDB type '"..tostring(obj.type).."'" - local plugin = - { - self = nil, - button = nil, - isChild = nil, - name = (name or "?"), - issue = issue, - notes = "", - status = TITAN_REGISTER_FAILED, - category = "", - plugin_type = (obj.type or ""), - } - TitanUtils_PluginFail(plugin) - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug(TITAN_REGISTER_FAILED.." "..issue); - end - return -- get out, there is nothing more that can be done - end - - -- - -- Handle the display attributes of the DO and register the appropriate callbacks - -- - -- Init the display elements of the plugin - local ldb__label = obj.label or "" - local ldb__suffix = obj.suffix or "" - local ldb__value = obj.value or "" - local ldb__text = obj.text or "" - local ldb__icon = obj.icon or iconTitanDefault - - -- if .icon exists honor it and assume the addon may change it - if obj.icon then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_icon", "TitanLDBIconUpdate") - end - - -- LAUNCHER text display elements - if obj.type == LAUNCHER then - if obj.label then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") - elseif obj.text then - -- This is a 'be nice' check. It technically violates the 1.1 spec. - -- Blank the .text so the rest of the routines work - ldb__label = obj.text - obj.text = "" - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") - notes = notes.."\n" - .."This is a LDB '"..LAUNCHER - .."' without .label using .text instead!!!!" - end - end - if Titan__InitializedPEW then - notes = notes.."\n" - .."Will be registered as single LDB plugin after the normal registration." - end - -- DATA_SOURCE text display elements - if obj.type == DATA_SOURCE then - -- .text so always allow it - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") - if obj.label then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") - end - if obj.suffix then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_suffix", "TitanLDBTextUpdate") - end - if obj.value then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_value", "TitanLDBTextUpdate") - end - end - - -- - -- These are icon extensions listed within the 1.1 spec - -- - -- support for iconCoords, iconR, iconG, iconB attributes - -- Due to the callbacks being fired these can easily affect - -- performance, BEWARE when using them ! - -- - -- capture the icon coords & color for the Titan plugin - if obj.iconCoords then - self:TitanLDBIconUpdate(nil, name, "iconCoords", obj.iconCoords, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconCoords", "TitanLDBIconUpdate") - end - if obj.iconR and obj.iconG and obj.iconB then - self:TitanLDBIconUpdate(nil, name, "iconR", obj.iconR, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconR", "TitanLDBIconUpdate") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconG", "TitanLDBIconUpdate") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconB", "TitanLDBIconUpdate") - end - - -- - -- Setup the Titan plugin for this LDB addon - -- - - -- Create the appropriate Titan registry for the DO - local registry = { - id = NAME_PREFIX..name, - ldb = tostring(obj.type), - -- per 1.1 spec if .label exists use it else use data object's name - menuText = obj.label or name, - buttonTextFunction = "TitanLDBShowText", - icon = ldb__icon, - iconWidth = 16, - controlVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = false, - DisplayOnRightSide = true - }, - savedVariables = { - ShowIcon = true, - ShowLabelText = true, - ShowRegularText = true, - ShowColoredText = false, - DisplayOnRightSide = false - }, - LDBVariables = { - value = ldb__value, - suffix = ldb__suffix, - text = ldb__text, - label = ldb__label, - name = name, - type = (obj.type or ""), - }, - notes = notes, - iconCoords = (obj.iconCoords or nil), - iconR = (obj.iconR or nil), - iconB = (obj.iconB or nil), - iconG = (obj.iconG or nil), - }; - - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." type: '"..tostring(registry.ldb).."' " - ) - end - - -- Set the plugin category, if it exists, else default to "General" - -- Per the 1.1 LDB spec we check for a tocname attrib first, - -- if found we use it, if not we assume that the DO "name" - -- attribute is the same as the actual - -- addon name, which might not always be the case. - -- Titan defaults again to "General" if no categoy is found - -- via a check in the menu implementation, later on. - local addoncategory, addonversion; - local tempname = obj.tocname or name; - - -- This was a sanity check but does not allow for multiple - -- LDB to be within an addon yet act as their own addon. --- if IsAddOnLoaded(tempname) then - addoncategory = GetAddOnMetadata(tempname, "X-Category"); - registry["category"]= (addoncategory and xcategories[addoncategory]) - or (obj.category) - or nil - addonversion = GetAddOnMetadata(tempname, "Version") - or (obj.version) - or "" - registry["version"]= addonversion; --- end - - -- Depending on the LDB type set the control and saved Variables appropriately - if obj.type == LAUNCHER then - -- controls - -- one interpretation of the LDB spec is launchers - -- should always have an icon. - registry["controlVariables"].ShowIcon = true; - registry["controlVariables"].ShowRegularText = false; -- no text - -- defaults - registry["savedVariables"].ShowRegularText = false; - registry["savedVariables"].DisplayOnRightSide = true; -- start on right side - end - - if obj.type == DATA_SOURCE then - -- controls - registry["controlVariables"].ShowRegularText = true; - -- defaults - registry["savedVariables"].ShowRegularText = true; - end - - -- - -- Create the Titan frame for this LDB addon - -- Titan _OnLoad will be used to request the plugin be registered by Titan - local newTitanFrame -- a frame - if obj.type == "macro" then -- custom - newTitanFrame = CreateFrame("Button", - "TitanPanel"..NAME_PREFIX..name.."Button", - UIParent, "TitanPanelComboTemplate") --- UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") - newTitanFrame:RegisterForClicks("AnyUp", "AnyDown") - newTitanFrame:SetMouseClickEnabled(true) - newTitanFrame:SetAttribute("type", "macro") --- newTitanFrame:SetAttribute("macro", obj.commandtext) - newTitanFrame:SetAttribute("macrotext", obj.commandtext) - newTitanFrame:SetScript("OnClick", function(self, button, down) - SecureUnitButton_OnClick(self, button, down) - --TitanPanelBarButton_OnClick(self, button) - end) ---[[ -print("LDB macrotext" -.." "..tostring(obj.commandtext).."" -) ---]] - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." macrotext cmd: '"..tostring(obj.commandtext).."' " - ) - end - else - newTitanFrame = CreateFrame("Button", - "TitanPanel"..NAME_PREFIX..name.."Button", - UIParent, "TitanPanelComboTemplate") - end - - newTitanFrame.TitanCreatedBy = "LDB" - newTitanFrame.TitanType = "macro" - newTitanFrame.TitanName = (name or "?") - newTitanFrame.TitanAction = (obj.commandtext or "None") - - newTitanFrame.registry = registry - newTitanFrame:SetFrameStrata("FULLSCREEN"); - newTitanFrame:SetToplevel(true); - newTitanFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - - -- Use the routines given by the DO in this precedence - -- tooltip > OnEnter > OnTooltipShow > - -- or register a callback in case it is created later. Per the 1.1 LDB spec - if obj.tooltip then - self:TitanLDBHandleScripts("tooltip", name, nil, obj.tooltip, obj) - elseif obj.OnEnter then - self:TitanLDBHandleScripts("OnEnter", name, nil, obj.OnEnter, obj) - elseif obj.OnTooltipShow then - self:TitanLDBHandleScripts("OnTooltipShow", name, nil, obj.OnTooltipShow, obj) - else - self:TitanLDBHandleScripts("OnEnter", name, nil, nil, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnEnter", "TitanLDBHandleScripts") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnTooltipShow", "TitanLDBHandleScripts") - end - - -- Use the OnClick given by the DO - -- or register a callback in case it is created later. - if obj.OnClick then - self:TitanLDBHandleScripts("OnClick", name, nil, obj.OnClick) - else - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnClick", "TitanLDBHandleScripts") - end - - -- - -- OnDoubleClick is UNDOCUMENTED in the 1.1 spec - -- but was implemented by the original developer - -- - -- Use the OnDoubleClick given by the DO - -- or register a callback in case it is created later. - if obj.OnDoubleClick then - self:TitanLDBHandleScripts("OnDoubleClick", name, nil, obj.OnDoubleClick) - else - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnDoubleClick", "TitanLDBHandleScripts") - end - - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." id: '"..tostring(registry.id).."' " - .." type: '"..tostring(registry.ldb).."' " - .." type: '"..tostring(registry.ldb).."' " - ) - end - if TITAN_PANEL_VARS.debug.ldb_setup then - TitanDebug("" - .." id: '"..tostring(registry.id).."' " - .." registered" - ) - end - - -- If plugins have already been registered and loaded then get this one loaded - -- This works because the .registry is now set - if Titan__InitializedPEW then ---[[ -print("LDB late" -.." id: '"..tostring(registry.id).."' " -) ---]] - TitanUtils_RegisterPluginList() --- TitanPanel_PlayerEnteringWorld() - end -end - ---[[ Titan -NAME: LDBToTitan:SetScript -DESC: OnEvent handler for LDBToTitan -VAR: event - string -VAR: function -OUT: None -NOTE: -- PLAYER_LOGIN - Read through all the LDB object created so far and create cooresponding Titan plugins. -:NOTE ---]] -LDBToTitan:SetScript("OnEvent", function(self, event, ...) - if (event == "PLAYER_LOGIN") then - self:UnregisterEvent("PLAYER_LOGIN") - -- In case a LDB plugin is created later... - ldb.RegisterCallback(self, - "LibDataBroker_DataObjectCreated", "TitanLDBCreateObject") - - -- Register the LDB plugins that have been created so far - for name, obj in ldb:DataObjectIterator() do - self:TitanLDBCreateObject(nil, name, obj) - --TitanDebug("Registered "..name.."."); - end - end - ---[[ - if (event == "PLAYER_ENTERING_WORLD") then - self:UnregisterEvent("PLAYER_ENTERING_WORLD") - end ---]] -end -) \ No newline at end of file diff --git a/Titan/LibDataBroker-1.1.lua b/Titan/LibDataBroker-1.1.lua deleted file mode 100644 index 4182f2e..0000000 --- a/Titan/LibDataBroker-1.1.lua +++ /dev/null @@ -1,90 +0,0 @@ - -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/Titan/Titan.lua b/Titan/Titan.lua new file mode 100644 index 0000000..8169034 --- /dev/null +++ b/Titan/Titan.lua @@ -0,0 +1,2215 @@ +--[[ 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. +--]] + +-- Locals +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 InCombatLockdown = _G.InCombatLockdown; +local IsTitanPanelReset = nil; +local new_toon = false + +-- Library references +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) +local AceTimer = LibStub("AceTimer-3.0") +local media = LibStub("LibSharedMedia-3.0") +local AceConfigDialog = LibStub("AceConfigDialog-3.0") + +-- TitanDebug (cmd.." : "..p1.." "..p2.." "..p3.." "..#cmd_list) + +-------------------------------------------------------------- +-- +function TitanPanel_OkToReload() + StaticPopupDialogs["TITAN_RESET_RELOAD"] = { + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) + .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) + ReloadUI() + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RESET_RELOAD"); +end + +--[[ Titan +NAME: TitanPanel_ResetToDefault +DESC: Give the user a 'are you sure'. If the user accepts then reset current toon back to default Titan settings. +VAR: None +OUT: None +NOTE: +- Even if the user was using global profiles they will not when this is done. +:NOTE +--]] +function TitanPanel_ResetToDefault() + StaticPopupDialogs["TITAN_RESET_BAR"] = { + text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) + .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) + TitanVariables_UseSettings(TitanSettings.Player, TITAN_PROFILE_RESET); + IsTitanPanelReset = true; + ReloadUI() + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RESET_BAR"); +end + +--[[ Titan +NAME: TitanPanel_SaveCustomProfile +DESC: The user wants to save a custom Titan profile. Show the user the dialog boxes to make it happen. +VAR: None +OUT: None +NOTE: +- The profile is written to the Titan saved variables. A reload of the UI is needed to ensure the profile is written to disk for the user to load later. +:NOTE +--]] +function TitanPanel_SaveCustomProfile() + -- Create the dialog box code we'll need... + + -- helper to actually write the profile to the Titan saved vars + local function Write_profile(name) + local currentprofilevalue, _, _ = TitanUtils_GetPlayer() + local profileName = TitanUtils_CreateName(name, TITAN_CUSTOM_PROFILE_POSTFIX) + TitanSettings.Players[profileName] = + TitanSettings.Players[currentprofilevalue] + TitanPrint(L["TITAN_PANEL_MENU_PROFILE_SAVE_PENDING"] + .."'"..name.."'" + , "info") + end + -- helper to ask the user to overwrite a profile + local function Overwrite_profile(name) + local dialogFrame = + StaticPopup_Show("TITAN_OVERWRITE_CUSTOM_PROFILE", name); + if dialogFrame then + dialogFrame.data = name; + end + end + -- helper to handle getting the profile name from the user + 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, " ", "" ); + 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 profileName = TitanUtils_CreateName(concprofileName, TITAN_CUSTOM_PROFILE_POSTFIX) + if TitanSettings.Players[profileName] then + -- Warn the user of an existing profile + Overwrite_profile(rawprofileName) + self:Hide(); + return; + else + -- Save the requested profile + Write_profile(rawprofileName) + self:Hide(); + StaticPopup_Show("TITAN_RELOADUI"); + end + end + -- 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"], + button1 = "OKAY", + OnAccept = function(self) + ReloadUI(); -- ensure profile is written to disk + end, + showAlert = 1, + whileDead = 1, + timeout = 0, + }; + + -- 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"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self, data) + Write_profile(data) + self:Hide(); + StaticPopup_Show("TITAN_RELOADUI"); + end, + showAlert = 1, + whileDead = 1, + timeout = 0, + hideOnEscape = 1 + }; + + -- 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"], + button1 = ACCEPT, + button2 = CANCEL, + hasEditBox = 1, + maxLetters = 20, + OnAccept = function(self) + -- self refers to this frame with the Accept button + Get_profile_name(self) + end, + OnShow = function(self) + self.editBox:SetFocus(); + end, + OnHide = function(self) + self.editBox:SetText(""); + end, + EditBoxOnEnterPressed = function(self) + -- We need to get the parent because self refers to the edit box. + Get_profile_name(self:GetParent()) + end, + EditBoxOnEscapePressed = function(self) + self:GetParent():Hide(); + end, + timeout = 0, + exclusive = 1, + whileDead = 1, + hideOnEscape = 1 + }; + + 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"] = {} + +end + +--[[ Titan +NAME: TitanSetPanelFont +DESC: Set or change the font and font size of text on the Titan bar. This affects ALL plugins. +VAR: fontname - The text name of the font to use. Defaults to Titan default if none given. +VAR: fontsize - The size of the font to use. Defaults to Titan default if none given. +OUT: None +NOTE: +- Each registered plugin will have its font updated. Then all plugins will be refreshed to show the new font. +:NOTE +--]] +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); + end + end + end + end + end + TitanPanel_RefreshPanelButtons(); +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"); +-- +-- Event routine : redirects to TitanPanelBarButton: routines below. +_G[TITAN_PANEL_CONTROL]:SetScript("OnEvent", function(_, event, ...) + _G[TITAN_PANEL_CONTROL][event](_G[TITAN_PANEL_CONTROL], ...) +end) + + +--[[ Titan +NAME: TitanPanel_PlayerEnteringWorld +DESC: Do all the setup needed when a user logs in / reload UI / enter or leave an instance. +VAR: None +OUT: None +NOTE: +- This is called after the 'player entering world' event is fired by Blizz. +- This is also used when a LDB plugin is created after Titan runs the 'player entering world' code. +:NOTE +--]] +function TitanPanel_PlayerEnteringWorld(reload) +--[[ +print("PEW" +.." "..tostring(Titan__InitializedPEW).."" +) +--]] + if Titan__InitializedPEW then + -- Currently no additional steps needed + else + -- Get Profile and Saved Vars + new_toon = TitanVariables_InitTitanSettings(); + if TitanAllGetVar("Silenced") then + -- No header output + else + TitanPrint("", "header") + end + + if not ServerTimeOffsets then + ServerTimeOffsets = {}; + end + if not ServerHourFormat then + ServerHourFormat = {}; + end + + -- Set the two anchors in their default positions + -- until the Titan bars are drawn + TitanPanelTopAnchor:ClearAllPoints(); + TitanPanelTopAnchor:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0); + TitanPanelBottomAnchor:ClearAllPoints(); + TitanPanelBottomAnchor:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0); + + -- Ensure the bars are created before the plugins are registered. + 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 + + 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") + end + + -- 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") + TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", + function() + if OrderHallCommandBar then + OrderHallCommandBar:Hide() + OrderHallCommandBar:UnregisterAllEvents() + OrderHallCommandBar.Show = function () end + end + end + ) + else + local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0") + TitanPanelAce:Unhook("OrderHall_CheckCommandBar") + end + + end + local _ = nil + 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 + TitanUtils_RegisterPluginList() + + -- Init detailed settings only after plugins are registered! + local profile_action = nil + if new_toon then + profile_action = TITAN_PROFILE_RESET + else + profile_action = TITAN_PROFILE_INIT + end + + TitanVariables_UseSettings(nil, profile_action) + + -- all addons are loaded so update the config (options) + -- some could have registered late... + TitanUpdateConfig("init") + + -- Init panel font + local isfontvalid = media:IsValid("font", TitanPanelGetVar("FontName")) + if isfontvalid then + TitanSetPanelFont(TitanPanelGetVar("FontName"), TitanPanelGetVar("FontSize")) + else + -- 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 + + -- Init panel frame strata + TitanVariables_SetPanelStrata(TitanPanelGetVar("FrameStrata")) + + -- Titan Panel has initialized its variables and registered plugins. + -- Allow Titan - and others - to adjust the bars + Titan__InitializedPEW = true + + -- Move frames +-- TitanMovable_SecureFrames() + + -- Also sync LDB object text with their created Titan plugin + TitanLDBRefreshButton() +end + +-------------------------------------------------------------- +-- +-- Event handlers +-- +--[===[ + local WoWClassicEra, WoWClassicTBC, WoWWOTLKC, WoWRetail + if wowversion < 20000 then + WoWClassicEra = true + elseif wowversion < 30000 then + WoWClassicTBC = true + elseif wowversion < 40000 then + WoWWOTLKC = true + elseif wowversion > 90000 then + WoWRetail = true + else + -- n/a + end +--]===] +function TitanPanelBarButton:ADDON_LOADED(addon) + if addon == TITAN_ID then + -- Determine WoW TOC Version + local wowversion = select(4, GetBuildInfo()) + if wowversion >= 100000 then -- Initialize Titan + -- Event registration + _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD"); + _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"); + else + -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era + -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. + TitanPrint("Titan did not initialize!!!!" + , "error") + TitanPrint("This version needs API released with " + .." "..tostring(EXPANSION_NAME9).."" + .." (10.00.xx)" + , "error") + end + -- Unregister event - saves a few event calls. + self:UnregisterEvent("ADDON_LOADED"); + self.ADDON_LOADED = nil + end +end + +function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2) + local call_success = nil + local ret_val = nil + +--[[ +print("PLAYER_ENTERING_WORLD" +.." "..tostring(arg1).."" +.." "..tostring(arg2).."" +) +--]] + call_success, -- needed for pcall + ret_val = -- actual return values + pcall (TitanPanel_PlayerEnteringWorld, 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 + if call_success then + -- Titan initialized properly + else + -- something really bad occured... + TitanPrint("Titan could not initialize!!!! Cleaning up...", "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, ...) + + -- Hide the bars. At times they are there but at 0% transparency. + -- They can be over the Blizz action bars creating havoc. + TitanPrint("-- Hiding Titan bars...", "warning") + TitanPanelBarButton_HideAllBars() + + -- Remove the options pages + TitanUpdateConfig("nuke") + -- What else to clean up??? + + -- raise the error to WoW for display, if display errors is set. + -- This *must be* the last statement of the routine! + error(ret_val, 1) + end +end + +function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) + if cvarname == "USE_UISCALE" + or cvarname == "WINDOWED_MODE" + or cvarname == "uiScale" then + if TitanPlayerSettings and TitanPanelGetVar("Scale") then + TitanPanel_InitPanelBarButton() -- TitanPanel_SetScale() + end + end +end + +function TitanPanelBarButton:PLAYER_LOGOUT() + if not IsTitanPanelReset then + -- for debug + if TitanPanelRegister then + TitanPanelRegister.ToBe = TitanPluginToBeRegistered + TitanPanelRegister.ToBeNum = TitanPluginToBeRegisteredNum + TitanPanelRegister.TitanPlugins = TitanPlugins + end + end + Titan__InitializedPEW = nil +end + +function TitanPanelBarButton:ZONE_CHANGED() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED") +end + +function TitanPanelBarButton:ZONE_CHANGED_INDOORS() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_INDOORS") +end + +function TitanPanelBarButton:ZONE_CHANGED_NEW_AREA() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_NEW_AREA") +end + +function TitanPanelBarButton:PET_BATTLE_OPENING_START() +--print("PET_BATTLE_OPENING_START") + TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_OPENING_START") +end + +function TitanPanelBarButton:PET_BATTLE_CLOSE() +--print("PET_BATTLE_CLOSE") + TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_CLOSE") +end + +local in_combat = false -- seems InCombatLockdown may not be set fast enough to reliably hide bars... +function TitanPanelBarButton:PLAYER_REGEN_ENABLED() + in_combat = false + TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_ENABLED") +end + +function TitanPanelBarButton:PLAYER_REGEN_DISABLED() + in_combat = true + TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_DISABLED") +end +-- + +--[[ Titan +NAME: TitanPanelBarButton_OnClick +DESC: Handle the button clicks on any Titan bar. +VAR: self - expected to be a Titan bar +VAR: button - which mouse button was clicked +OUT: None +NOTE: +- This only reacts to the right or left mouse click without modifiers. +- Used in the set script for the Titan display and hider frames +:NOTE +--]] +function TitanPanelBarButton_OnClick(self, button) + -- ensure that the right-click menu will not appear on "hidden" bottom bar(s) +--[[ +print("_OnClick" +.." "..tostring(bar).."" +) +--]] + if (button == "LeftButton") then + TitanUtils_CloseAllControlFrames(); + TitanUtils_CloseRightClickMenu(); + elseif (button == "RightButton") then + TitanUtils_CloseAllControlFrames(); + TitanPanelRightClickMenu_Close(); + -- Show RightClickMenu anyway + TitanPanelRightClickMenu_Toggle(self) + end +end + +-- +-- Slash command handler +-- +--[[ local +NAME: TitanPanel_ParseSlashCmd +DESC: Helper to parse the user commands. +VAR: cmd - user string from the command 'window' +OUT: table - table of 'words' the user typed in +NOTE: +- each 'word' in words table is made lower case for comparison simplicity +: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 "?") + end +--[[ + local tmp = "" + for idx,v in pairs (words) do + tmp = tmp.."'"..words[idx].."' " + end + + TitanDebug (tmp.." : "..#words) +--]] + return words +end + +--[[ local +NAME: handle_slash_help +DESC: Helper to tell the user the relevant Titan commands. +VAR: cmd - string 'all' | 'reset' | 'gui' | 'silent' +OUT: None +NOTE: +- Depending on cmd put to chat the appropriate help +:NOTE +--]] +local function handle_slash_help(cmd) + cmd = cmd or "all" + + -- Give the user the general help if we can not figure out what they want + TitanPrint("", "header") + -- Cannot count registered plugins after initial registration TitanUtils_RegisterPluginList() + + if cmd == "reset" then + TitanPrint(L["TITAN_PANEL_SLASH_RESET_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_RESET_1"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_RESET_2"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_RESET_3"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_RESET_4"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_RESET_5"], "plain") + end + if cmd == "gui" then + TitanPrint(L["TITAN_PANEL_SLASH_GUI_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_GUI_1"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_GUI_2"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_GUI_3"], "plain") + end + if cmd == "profile" then + TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_1"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_2"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_3"], "plain") + end + if cmd == "silent" then + TitanPrint(L["TITAN_PANEL_SLASH_SILENT_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_SILENT_1"], "plain") + end + if cmd == "orderhall" then + TitanPrint(L["TITAN_PANEL_SLASH_ORDERHALL_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_ORDERHALL_1"], "plain") + end + if cmd == "help" then + TitanPrint(L["TITAN_PANEL_SLASH_HELP_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_HELP_1"], "plain") + end + if cmd == "all" then + TitanPrint(L["TITAN_PANEL_SLASH_ALL_0"], "plain") + TitanPrint(L["TITAN_PANEL_SLASH_ALL_1"], "plain") + end +end + +--[[ local +NAME: handle_reset_cmds +DESC: Helper to execute the various reset commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_reset_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + -- sanity check + if (not cmd == "reset") then + return + end + + if p1 == nil then + TitanPanel_ResetToDefault(); + elseif p1 == "tipfont" then + 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(); + local red2, green2, blue2, _ = GameTooltip:GetBackdropBorderColor(); + 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); + TitanPanel_InitPanelBarButton() -- TitanPanel_SetScale() + TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info") + else + TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning") + end + elseif p1 == "spacing" then + TitanPanelSetVar("ButtonSpacing", 20); + TitanPanel_InitPanelButtons(); + TitanPrint(L["TITAN_PANEL_SLASH_RESP4"], "info") + else + handle_slash_help("reset") + end +end + +--[[ local +NAME: handle_giu_cmds +DESC: Helper to execute the gui related commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_giu_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + -- sanity check + if (not cmd == "gui") then + return + end + +-- 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... + +end + +--[[ local +NAME: handle_profile_cmds +DESC: Helper to execute the profile related commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_profile_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + local p2 = cmd_list[3] or nil + local p3 = cmd_list[4] or nil + -- sanity check + if (not cmd == "profile") then + return + end + + if p1 == "use" and p2 and p3 then + if TitanAllGetVar("GlobalProfileUse") then + TitanPrint(L["TITAN_PANEL_GLOBAL_ERR_1"], "info") + else + TitanVariables_UseSettings(TitanUtils_CreateName(p2, p3), TITAN_PROFILE_USE) + end + else + handle_slash_help("profile") + end +end + +--[[ local +NAME: handle_silent_cmds +DESC: Helper to execute the silent commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_silent_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + -- sanity check + if (not cmd == "silent") then + return + end + + if TitanAllGetVar("Silenced") then + TitanAllSetVar("Silenced", false); + 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") + end +end + +--[[ local +NAME: handle_orderhall_cmds +DESC: Helper to execute the orderhall commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_orderhall_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + -- sanity check + if (not cmd == "orderhall") then + return + end + + if TitanAllGetVar("OrderHall") then + TitanAllSetVar("OrderHall", false); + 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"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) + ReloadUI(); + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RELOAD"); + else + TitanAllSetVar("OrderHall", true); + 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"], + button1 = ACCEPT, + button2 = CANCEL, + OnAccept = function(self) + ReloadUI(); + end, + showAlert = 1, + timeout = 0, + whileDead = 1, + hideOnEscape = 1 + }; + StaticPopup_Show("TITAN_RELOAD"); + end +end + +--[[ local +NAME: handle_help_cmds +DESC: Helper to execute the help commands from the user. +VAR: cmd_list - A table containing the list of 'words' the user typed in +OUT: None +--]] +local function handle_help_cmds(cmd_list) + local cmd = cmd_list[1] + local p1 = cmd_list[2] or nil + -- sanity check + if (not cmd == "help") then + return + end + + handle_slash_help(p1 or "all") +end + +--[[ local +NAME: TitanPanel_RegisterSlashCmd +DESC: Helper to parse and execute all the Titan slash commands from the user. +VAR: cmd - The command (string) the user typed in +OUT: None +--]] +local function TitanPanel_RegisterSlashCmd(cmd_str) + local cmd_list = {} + -- parse what the user typed + cmd_list = TitanPanel_ParseSlashCmd(cmd_str) + local cmd = cmd_list[1] or "" + local p1 = cmd_list[2] or "" + local p2 = cmd_list[3] or "" + local p3 = cmd_list[4] or "" + + if (cmd == "reset") then + handle_reset_cmds(cmd_list) + elseif (cmd == "gui") then + handle_giu_cmds(cmd_list) + elseif (cmd == "profile") then + handle_profile_cmds(cmd_list) + elseif (cmd == "silent") then + handle_silent_cmds(p1) + elseif (cmd == "orderhall") then + handle_orderhall_cmds(p1) + elseif (cmd == "help") then + handle_slash_help(p1) + else + handle_slash_help("all") + end +end + +-------------------------------------------------------------- +-- +-- Register slash commands for Titan Panel +SlashCmdList["TitanPanel"] = TitanPanel_RegisterSlashCmd; +SLASH_TitanPanel1 = "/titanpanel"; +SLASH_TitanPanel2 = "/titan"; + +-------------------------------------------------------------- +-- +-- Texture routines +local function Set_Color(frame, tex, color) + +--[[ +print("_Set bar color" +.." "..tostring(TitanBarData[frame].tex_name).."" +--.." "..tostring(tex:GetName()).."" +.." "..tostring(format("%0.1f", color.r)).."" +.." "..tostring(format("%0.1f", color.g)).."" +.." "..tostring(format("%0.1f", color.b)).."" +.." "..tostring(format("%0.1f", color.alpha)).."" +) +--]] + _G[frame]:SetBackdrop({ + bgFile="Interface\\Tooltips\\UI-Tooltip-Background", +-- edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", +-- edgeFile="Interface\\DialogFrame\\UI-DialogBox-Gold-Border", + edgeFile="Interface\\Glues\\Common\\TextPanel-Border", + tile = true, + tileEdge = true, +-- insets = { left = 1, right = 1, top = 1, bottom = 1 }, + tileSize = 8, + edgeSize = 8, + }) + + _G[frame]:SetBackdropBorderColor( + TOOLTIP_DEFAULT_COLOR.r, + TOOLTIP_DEFAULT_COLOR.g, + TOOLTIP_DEFAULT_COLOR.b); + _G[frame]:SetBackdropColor( + color.r, + color.g, + color.b, + color.alpha); +--[[ + -- Apply the texture to the bar, using the system repeat to fill it + tex:SetColorTexture( + color.r, + color.g, + color.b, + color.alpha + ) + tex:SetAllPoints() + tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true + tex:SetVertTile(true) -- ensures image is 'full' height of frame +--]] +end + +local function Set_Skin(frame, tex, skin) + -- Use the texture / skin per user selectable options + + -- skins are in two parts - top & bottom... + -- TODO : have Short bars choose top or bottom skin?? + local edge = "" + if TitanBarData[frame].vert == TITAN_BOTTOM + then + edge = TITAN_BOTTOM + else + edge = TITAN_TOP + end + + -- Apply the texture to the bar, using the system repeat to fill it + local texture_file = skin.path.."TitanPanelBackground"..edge.."0" +--[[ +print("_Skin" +.." "..tostring(TitanBarData[frame].tex_name.."" +--.." "..tostring(tex:GetName()).."" +.." "..tostring(skin.path).."" +--.."\n "..tostring(edge).."" +--.." "..tostring(skin.alpha).."" +--.."\n "..tostring(tex:GetTexture()).."" +) +--]] +--[[ -- appears seeting image this way just smears image... + _G[frame]:SetBackdrop({ + bgFile=texture_file, +-- edgeFile=nil, + tile = true, +-- tileSize = 256, +-- tileEdge = true, +-- insets = { left = 1, right = 1, top = 1, bottom = 1 }, +-- tileSize = 8, +-- edgeSize = 8, + }) +--]] + tex:SetAllPoints() + tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true + tex:SetTexture(texture_file, "REPEAT") + tex:SetVertTile(true) -- ensures image is 'full' height of frame +-- tex:SetHeight(TITAN_PANEL_BAR_TEXTURE_HEIGHT) -- leaves a gap if used + tex:SetAlpha(skin.alpha) +end + +function TitanPanel_SetBarTexture(frame) + if frame and TitanBarData[frame] then + -- proceed + else + return + end + + -- Create the path & file name to the texture + local tex = TitanBarData[frame].tex_name + if _G[tex] then + titanTexture = _G[tex] + else + titanTexture = _G[frame]:CreateTexture(tex, "BACKGROUND") + end + titanTexture:SetTexture() + _G[frame]:SetBackdrop({ + bgFile="", + }) + +--[[ +print("_Tex" +.." "..tostring(TitanBarData[frame].name).."" +--.." "..tostring(tex).."" +.." "..tostring(titanTexture:GetName()).."" +--.." "..tostring(skin.path).."" +--.."\n "..tostring(edge).."" +--.." "..tostring(skin.alpha).."" +--.."\n "..tostring(tex:GetTexture()).."" +.." "..tostring(TitanBarDataVars["Global"].texure).."" +.." "..tostring(TitanBarDataVars[frame].texure).."" +) +--]] + -- Use the texture / skin per user selectable options + if TitanBarDataVars["Global"].texure == TitanVars.SKIN then + Set_Skin(frame, titanTexture, TitanBarDataVars["Global"].skin) -- tex_path = TitanPanelGetVar("TexturePath") + elseif TitanBarDataVars["Global"].texure == TitanVars.COLOR then + Set_Color(frame, titanTexture, TitanBarDataVars["Global"].color) + elseif TitanBarDataVars[frame].texure == TitanVars.SKIN then + Set_Skin(frame, titanTexture, TitanBarDataVars[frame].skin) + elseif TitanBarDataVars[frame].texure == TitanVars.COLOR then + Set_Color(frame, titanTexture, TitanBarDataVars[frame].color) + end +end + +-------------------------------------------------------------- +-- +-- auto hide event handlers +--[[ Titan +NAME: TitanPanelBarButton_OnLeave +DESC: On leaving the display check if we have to hide the Titan bar. A timer is used - when it expires the bar is hid. +VAR: self - expected to be a Titan bar +OUT: None +--]] +function TitanPanelBarButton_OnLeave(self) + local frame = (self and self:GetName() or nil) + local bar = (TitanBarData[frame] and TitanBarData[frame].name or nil) + + -- if auto hide is active then let the timer hide the bar + local hide = (bar and TitanBarDataVars[frame].auto_hide or nil) +-- local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) + if hide then + Titan_AutoHide_Timers(frame, "Leave") + end +end + +--[[ Titan +NAME: TitanPanelBarButton_OnEnter +DESC: No code - this is a place holder for the XML template. +VAR: self - expected to be a Titan bar +OUT: None +--]] +function TitanPanelBarButton_OnEnter(self) + -- no work to do +end + +--[[ Titan +NAME: TitanPanelBarButtonHider_OnLeave +DESC: No code - this is a place holder for the XML template. +VAR: self - expected to be a Titan bar +OUT: None +--]] +function TitanPanelBarButtonHider_OnLeave(self) + -- no work to do +end + +--[[ Titan +NAME: TitanPanelBarButtonHider_OnEnter +DESC: On entering the hider check if we need to show the display bar. +VAR: self - expected to be a Titan hider bar +OUT: None +NOTE: +- No action is taken if the user is on combat. +:NOTE +--]] +function TitanPanelBarButtonHider_OnEnter(self) + -- make sure self is valid + local index = self and self:GetName() or nil + if not index then return end -- sanity check + + -- so the bar does not 'appear' when moused over in combat + if TitanPanelGetVar("LockAutoHideInCombat") and InCombatLockdown() then return end + + -- find the relevant bar data + local frame = nil + for idx,v in pairs (TitanBarData) do + if index == TitanBarData[idx].hider then + frame = idx + end + end + -- Now process that bar + if frame then + Titan_AutoHide_Timers(frame, "Enter") + TitanPanelBarButton_Show(frame) + end +end + +-------------------------------------------------------------- +-- +-- Titan Bar + +--[[ Titan +NAME: TitanPanelBarButton_ForceLDBLaunchersRight +DESC: Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. Any visible plugin will be forced to the right side on the same bar it is currently on. +VAR: None +OUT: None +--]] +function TitanPanelBarButton_ForceLDBLaunchersRight() + local plugin, index, id; + for index, id in pairs(TitanPluginsIndex) do + plugin = TitanUtils_GetPlugin(id); + if 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["TitanPanel"..id..TITAN_PANEL_BUTTON_TEXT] = nil; + if button:IsVisible() then + local bar = TitanUtils_GetWhichBar(id) + TitanPanel_RemoveButton(id); + TitanUtils_AddButtonOnBar(bar, id) + end + end + end + end +end + +--[[ local +NAME: TitanAnchors +DESC: Helper to create the 'anchor' frames used by other addons that need to adjust so Titan can be visible. The anchor frames are adjusted depending on which Titan bars the user selects to show. +VAR: None +OUT: None +NOTE: +- TitanPanelTopAnchor - the frame at the bottom of the top bar(s) shown. +- TitanPanelBottomAnchor - the frame at the top of the bottom bar(s) shown. +:NOTE +--]] +local function TitanAnchors() + local anchor_top = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_TOP) + local anchor_bot = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM) + 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()) + 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 +) +--]] + 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 + +--[[ Titan +NAME: TitanPanelBarButton_DisplayBarsWanted +DESC: Show all the Titan bars the user has selected. +VAR: None +OUT: None +--]] +function TitanPanelBarButton_DisplayBarsWanted(reason) +--[===[ +print("_DisplayBarsWanted" +.." "..tostring(reason).."" +) +--]===] + -- Check all bars to see if the user has requested they be shown + for idx,v in pairs (TitanBarData) do + -- Show / hide plus kick auto hide, if needed + Titan_AutoHide_Init(idx) + end + + -- Set anchors for other addons to use. + TitanAnchors() +end + +--[[ Titan +NAME: TitanPanelBarButton_HideAllBars +DESC: This routine will hide all the Titan bars (and hiders) regardless of what the user has selected. +VAR: None +OUT: None +NOTE: +- For example when the pet battle is active. We cannot figure out how to move the pet battle frame so we are punting and hiding Titan... +- We only need to hide the bars (and hiders) - not adjust frames +:NOTE +--]] +function TitanPanelBarButton_HideAllBars() + for idx,v in pairs (TitanBarData) do + TitanPanelBarButton_Hide(idx) + end +end + +--[[ Titan +NAME: TitanPanelBarButton_HideTopBars +DESC: This routine will hide the bars Titan bars (and hiders) regardless of what the user has selected. +VAR: None +OUT: None +NOTE: +- For example when the class hall +- We only need to hide the bars (and hiders) - not adjust frames +:NOTE +--]] +function TitanPanelBarButton_HideTopBars() + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar"].show then +-- if TitanPanelGetVar("Bar_Show") then + TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar") + end + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar2"].show then +-- if TitanPanelGetVar("Bar2_Show") then + TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar2") + end +end + +--[[ Titan +NAME: TitanPanelBarButton_HideBottomBars +DESC: This routine will hide the bottom Titan bars (and hiders) regardless of what the user has selected. +VAR: None +OUT: None +NOTE: +- For example when the override bar is being used +- We only need to hide the bars (and hiders) - not adjust frames +:NOTE +--]] +function TitanPanelBarButton_HideBottomBars() + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"].show then +-- if TitanPanelGetVar("AuxBar_Show") then + TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar") + end + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"].show then +-- if TitanPanelGetVar("AuxBar2_Show") then + TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2") + end +end + +local function showBar(frame_str) + -- Conditions where this bar should not be shown... + local flag = true -- only set false for known conditions + + if frame_str == TITAN_PANEL_DISPLAY_PREFIX.."Bar" + or frame_str == TITAN_PANEL_DISPLAY_PREFIX.."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" + ) + then + flag = false + end + -- ===== In Pet Battle + if C_PetBattles.IsInBattle() + then + flag = false + end + end + + -- ===== In Combat : User selected + if TitanBarDataVars[frame_str].hide_in_combat + or TitanPanelGetVar("HideBarsInCombat") then + if in_combat then -- InCombatLockdown() too slow + flag = false + end + end +--[[ +print("showBar" +--.." "..tostring(C_PetBattles.IsInBattle()).."" +.." > "..tostring(flag).."" +) +--]] + return flag +end + +--[[ Titan +NAME: TitanPanelBarButton_Show +DESC: Show / hide the given Titan bar based on the user selection. +VAR: frame - expected to be a Titan bar name (string) +OUT: None +NOTE: +- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. +:NOTE +--]] +function TitanPanelBarButton_Show(frame) + local display = _G[frame]; + local bar = TitanBarData[frame].name + + if display and TitanBarData[frame].name + then + local x, y, w = TitanVariables_GetBarPos(frame) + local show = TitanBarData[frame].show + local bott = TitanBarData[frame].bott + + -- Show the display bar if the user requested it + -- And there are no conditions preventing... + if TitanBarDataVars[frame].show -- User requested + and showBar(frame) -- No preventing condition + then + display:ClearAllPoints(); +--[===[ +local sx, sy = TitanUtils_ScreenSize(false) +print("TB_Show" +--.." "..tostring(frame).."" +.." "..tostring(bar).."" +.." "..tostring(TitanBarDataVars[frame].show).."" +) +print(">>" +--.." "..tostring(show.pt).."" +--.." "..tostring(show.rel_fr).."" +--.." "..tostring(show.rel_pt).."" +.." x:"..tostring(format("%0.1f", x)).."" +.." y:"..tostring(format("%0.1f", y)).."" +.." w:"..tostring(format("%0.1f", w)).."" +.." sx:"..tostring(format("%0.1f", sx)).."" +.." sy:"..tostring(format("%0.1f", sy)).."" +) +--]===] + if TitanBarData[frame].user_move then + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) + else + display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) + local h = TITAN_PANEL_BAR_HEIGHT -- / UIParent:GetEffectiveScale() -- adjust scale so it is full height + display:SetPoint(bott.pt, bott.rel_fr, bott.rel_pt, x, y - h) + end + TitanPanel_SetBarTexture(frame) + + if TitanBarData[frame].hider then + _G[TitanBarData[frame].hider]:Hide() + else + -- not allowed for this bar + end + else + -- The user has not elected to show this bar + TitanPanelBarButton_Hide(frame) + end + end +end + +--[[ Titan +NAME: TitanPanelBarButton_Hide +DESC: Hide the given Titan bar based on the user selection. +VAR: frame - expected to be a Titan bar name (string) +OUT: None +NOTE: +- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. +- Also moves the hider bar if auto hide is not selected. +:NOTE +--]] +function TitanPanelBarButton_Hide(frame) + if TITAN_PANEL_MOVING == 1 then return end + + local display = _G[frame] + local data = TitanBarData[frame] + + if display and data + then + local x, y, w = TitanVariables_GetBarPos(frame) + -- This moves rather than hides. If we just hide then the plugins will still show. + -- Hide by ensuriing the Y offset is off the screen. + display:ClearAllPoints() + local h = (math.abs(y) + TITAN_PANEL_BAR_HEIGHT * 2) * (-1 * y) + local h = data.hide_y +--[[ +print("_Hide" +--.." "..tostring(frame).."" +.." "..tostring(data.name).."" +.." "..tostring(TitanBarDataVars[frame].show).."" +.." "..tostring(h).."" +) +--]] + if TitanBarData[frame].user_move then + display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) + else + display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) + display:SetPoint(data.bott.pt, data.bott.rel_fr, data.bott.rel_pt, x, h - TITAN_PANEL_BAR_HEIGHT) + end + + if TitanBarData[frame].hider then + local hider = _G[data.hider] + if 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 + hider:Hide() + end + else + -- not allowed for this bar + end + end +end + +--[[ Titan +NAME: TitanPanel_InitPanelButtons +DESC: Show all user selected plugins on the Titan bar(s) then justify per the user selection. +VAR: None +OUT: None +--]] +function TitanPanel_InitPanelButtons() + local button + local r_prior = {} + local l_prior = {} + local scale = TitanPanelGetVar("Scale"); + local button_spacing = TitanPanelGetVar("ButtonSpacing") * scale + local icon_spacing = TitanPanelGetVar("IconSpacing") * scale + + local prior = {} + -- set prior to the starting offsets + -- The right side plugins are set here. + -- 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 + local bar = TitanBarData[idx].name + local y_off = TitanBarData[idx].plugin_y_offset + prior[bar] = { + right = { + button = TITAN_PANEL_DISPLAY_PREFIX..bar, + anchor = "RIGHT", + x = 5, -- Offset of first plugin to right side of screen + y = y_off, + }, + left = { + button = TITAN_PANEL_DISPLAY_PREFIX..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 + 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 = "TitanPanel"..id.."Button" + -- 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 = "TitanPanel"..id.."Button" + -- 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 + end + -- Set panel button init flag + TITAN_PANEL_BUTTONS_INIT_FLAG = 1; + TitanPanelButton_Justify(); +end + +--[[ Titan +NAME: TitanPanel_ReOrder +DESC: Reorder all the shown all user selected plugins on the Titan bar(s). Typically used after a button has been removed / hidden. +VAR: index - the index of the plugin removed so the list can be updated +OUT: None +--]] +function TitanPanel_ReOrder(index) + for i = index, table.getn(TitanPanelSettings.Buttons) do + TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i+1] + end +end + +--[[ Titan +NAME: TitanPanel_RemoveButton +DESC: Remove a plugin then show all the shown all user selected plugins on the Titan bar(s). +VAR: id - the plugin name (string) +OUT: None +NOTE: +- This cancels all timers of name "TitanPanel"..id as a safeguard to destroy any active plugin timers based on a fixed naming convention : TitanPanel..id, eg. "TitanPanelClock" this prevents "rogue" timers being left behind by lack of an OnHide check +:NOTE +--]] +function TitanPanel_RemoveButton(id) + if ( not TitanPanelSettings ) then + return; + end + + local i = TitanPanel_GetButtonNumber(id) + local currentButton = TitanUtils_GetButton(id); + + -- safeguard ... + 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 "?")) + if currentButton then + currentButton:Hide(); + end + -- Show the existing buttons + TitanPanel_InitPanelButtons(); +end + +--[[ Titan +NAME: TitanPanel_GetButtonNumber +DESC: Get the index of the given plugin from the Titan plugin displayed list. +VAR: id - the plugin name (string) +OUT: index of the plugin in the Titan plugin list or the end of the list. The routine returns +1 if not found so it is 'safe' to update / add to the Location +--]] +function TitanPanel_GetButtonNumber(id) + if (TitanPanelSettings) then + for i = 1, table.getn(TitanPanelSettings.Buttons) do + if(TitanPanelSettings.Buttons[i] == id) then + return i; + end + end + return table.getn(TitanPanelSettings.Buttons)+1; + else + return 0; + end +end + +--[[ Titan +NAME: TitanPanel_RefreshPanelButtons +DESC: Update / refresh each plugin from the Titan plugin list. Used when a Titan option is changed that effects all plugins. +VAR: None +OUT: None +--]] +function TitanPanel_RefreshPanelButtons() + if (TitanPanelSettings) then + for i = 1, table.getn(TitanPanelSettings.Buttons) do + TitanPanelButton_UpdateButton(TitanPanelSettings.Buttons[i], 1); + end + end +end + +--[[ Titan +NAME: TitanPanelButton_Justify +DESC: Justify the plugins on each Titan bar. Used when the user changes the 'center' option on a Titan bar. +VAR: None +OUT: None +--]] +function TitanPanelButton_Justify() + -- Only the left side buttons are justified. + if ( not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings ) then + return; + end + if InCombatLockdown() then +--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 y_offset + local firstLeftButton + local scale = TitanPanelGetVar("Scale"); + local button_spacing = TitanPanelGetVar("ButtonSpacing") * scale + local icon_spacing = TitanPanelGetVar("IconSpacing") * scale + local leftWidth = 0; + local rightWidth = 0; + local counter = 0; + local align = 0; + local center_offset = 0; + + -- Look at each bar for plugins. + 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)]) + 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 + -- 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 + leftWidth = 0; + rightWidth = 0; + counter = 0; + -- Calc the total width of the icons so we know where to start + for index, id in pairs(TitanPanelSettings.Buttons) do + local button = TitanUtils_GetButton(id); + if button and button:GetWidth() then + if TitanUtils_GetWhichBar(id) == bar then + if (TitanGetVar(id, "DisplayOnRightSide")) then + rightWidth = rightWidth + + icon_spacing + + button:GetWidth(); + else + counter = counter + 1; + leftWidth = leftWidth + + button_spacing + + button:GetWidth() + end + end + end + end + -- 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) + firstLeftButton:SetPoint("LEFT", idx, "CENTER", center_offset, y_offset); + end + end + end +end + +-------------------------------------------------------------- +-- +-- Local routines for Titan menu creation + +local R_ADDONS = "Addons_" +local R_PLUGIN = "Plugin_" +local R_SETTINGS = "Settings" +local R_PROFILE = "Profile_" + +--[[ local +NAME: BuildMainMenu +DESC: Show main Titan (right click) menu. +VAR: None +OUT: None +--]] +local function BuildMainMenu(frame) + local locale_bar = TitanBarData[frame].locale_name + local info = {}; + ----------------- + -- Menu title + 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 + info = {}; + info.notCheckable = true + info.text = L["TITAN_PANEL_MENU_CATEGORIES"][index]; + info.value = R_ADDONS .. TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY[index]; + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info); + end + + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + + ----------------- + -- 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) + end + TitanPanelRightClickMenu_AddButton(info); + + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + + ----------------- + -- Profiles + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILES"]); + + ----------------- + -- Load/Delete + info = {}; + info.notCheckable = true + info.text = L["TITAN_PANEL_MENU_MANAGE_SETTINGS"]; + info.value = R_SETTINGS + info.hasArrow = 1; + -- lock this menu in combat + 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 + TitanPanelRightClickMenu_AddButton(info); + + ----------------- + -- Save + info = {}; + info.notCheckable = true + info.text = L["TITAN_PANEL_MENU_SAVE_SETTINGS"]; + info.value = "SettingsCustom"; + info.func = TitanPanel_SaveCustomProfile; + -- 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 + TitanPanelRightClickMenu_AddButton(info); + + local glob, toon, player, server = TitanUtils_GetGlobalProfile() + info = {}; + info.text = "Use Global Profile" + info.value = "Use Global Profile" + info.func = function() + TitanUtils_SetGlobalProfile(not glob, toon) + TitanVariables_UseSettings(nil, TITAN_PROFILE_USE) + end; + info.checked = glob --TitanAllGetVar("GlobalProfileUse") + info.keepShownOnClick = nil + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); + + ----------------- + -- Hide this bar + info = {}; + info.text = (HIDE or "Hide") + info.value = "HideMe" + info.notCheckable = true + 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") + end + info.keepShownOnClick = nil + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + +end + +--[[ local +NAME: BuildServerProfilesMenu +DESC: Show list of servers / custom submenu off Profiles/Manage from the Titan (right click) menu. +VAR: None +OUT: None +--]] +local function BuildServerProfilesMenu() + local info = {}; + local servers = {}; + local player = nil; + local server = nil; + local s, e, ident; + local setonce = 0; + + if ( TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS ) then + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_SERVERS"], + TitanPanelRightClickMenu_GetDropdownLevel()); + -- Normal profile per toon + for index, id in pairs(TitanSettings.Players) do + player, server = TitanUtils_ParseName(index) + + if TitanUtils_GetCurrentIndex(servers, server) == nil then + if server ~= TITAN_CUSTOM_PROFILE_POSTFIX then + table.insert(servers, server); + info = {}; + info.notCheckable = true + info.text = server; + info.value = R_PROFILE..server; + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + end + end + -- Custom profiles + for index, id in pairs(TitanSettings.Players) do + player, server = TitanUtils_ParseName(index) + + if TitanUtils_GetCurrentIndex(servers, server) == nil then + 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; + end + info = {}; + info.notCheckable = true + info.text = player; + info.value = R_PROFILE..player; + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + end + end + end +end + +--[[ local +NAME: TitanPanel_PlayerSettingsMenu +DESC: Show list of toons submenu off Profiles/Manage/ from the Titan right click menu. +VAR: None +OUT: None +NOTE: +- There are 2 level 3 menus possible + 1) Under profiles, then value could be the server of a saved toon + 2) Under plugins value could be the options of a plugin +:NOTE +--]] +local function BuildPluginMenu() + -- + local info = {}; + + -- Handle the plugins + + for index, id in pairs(TitanPluginsIndex) do + local plugin = TitanUtils_GetPlugin(id) +-- local _, _, menu_plugin = string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_PLUGIN.."(.-)") + local par_val = TitanPanelRightClickMenu_GetDropdMenuValue() + local menu_plugin = string.gsub(par_val, R_PLUGIN, "") +-- if plugin.id and plugin.id == TitanPanelRightClickMenu_GetDropdMenuValue() then + if plugin.id and plugin.id == menu_plugin then + --title + info = {}; + info.text = TitanPlugins[plugin.id].menuText; + info.notCheckable = true + info.notClickable = 1; + info.isTitle = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + --ShowIcon + if plugin.controlVariables.ShowIcon then + info = {}; + info.text = L["TITAN_PANEL_MENU_SHOW_ICON"]; + 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}) + end + info.keepShownOnClick = 1; + info.checked = TitanGetVar(plugin.id, "ShowIcon"); + info.disabled = nil; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + + --ShowLabel + if plugin.controlVariables.ShowLabelText then + info = {}; + info.text = L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"]; + 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}) + end + info.keepShownOnClick = 1; + info.checked = TitanGetVar(plugin.id, "ShowLabelText"); + info.disabled = nil; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + + --ShowRegularText (LDB data sources only atm) + if plugin.controlVariables.ShowRegularText then + info = {}; + info.text = L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] + 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}) + end + info.keepShownOnClick = 1; + info.checked = TitanGetVar(plugin.id, "ShowRegularText"); + info.disabled = nil; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + + --ShowColoredText + if plugin.controlVariables.ShowColoredText then + info = {}; + info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"]; + 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}) + end + info.keepShownOnClick = 1; + info.checked = TitanGetVar(plugin.id, "ShowColoredText"); + info.disabled = nil; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + + -- Right-side plugin + if plugin.controlVariables.DisplayOnRightSide then + info = {}; + info.text = L["TITAN_PANEL_MENU_LDB_SIDE"]; + info.value = plugin.id + info.arg1 = plugin.id + info.func = function(self, p_id) -- (self, info.arg1, info.arg2) + TitanToggleVar(p_id, "DisplayOnRightSide", false) + local bar = TitanUtils_GetWhichBar(p_id) + TitanPanel_RemoveButton(p_id); + TitanUtils_AddButtonOnBar(bar, p_id); + end + info.checked = TitanGetVar(plugin.id, "DisplayOnRightSide"); + info.disabled = nil; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + end + end +end + +local function BuildProfileMenu() + -- + local info = {}; + local setonce = 0; + + -- + -- Handle the profiles + -- +-- for index, id in pairs(TitanSettings.Players) do + for idx = 1, #TitanVars.players do + local index = TitanVars.players[idx] + local player, server = TitanUtils_ParseName(index) + local off = (index == TitanSettings.Player) + or ((index == TitanAllGetVar("GlobalProfileUse")) and (TitanAllGetVar("GlobalProfileUse"))) + local par_val = TitanPanelRightClickMenu_GetDropdMenuValue() + local menu_val = string.gsub(par_val, R_PROFILE, "") + + -- handle custom profiles here + if server == TITAN_CUSTOM_PROFILE_POSTFIX + and player == menu_val then + info = {}; + info.notCheckable = true + info.disabled = TitanAllGetVar("GlobalProfileUse") + info.text = L["TITAN_PANEL_MENU_LOAD_SETTINGS"]; + info.value = index; + info.func = function() + TitanVariables_UseSettings(index, TITAN_PROFILE_USE) + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.notCheckable = true + info.disabled = off + info.text = L["TITAN_PANEL_MENU_DELETE_SETTINGS"]; + info.value = index; + info.arg1 = index; + info.func = function(self, player) -- (self, info.arg1, info.arg2) + if TitanSettings.Players[player] then + TitanSettings.Players[player] = nil; + profname = TitanUtils_ParseName(index) + TitanPrint( + L["TITAN_PANEL_MENU_PROFILE"] + .." '"..profname.."' " + ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] + , "info") + TitanPanelRightClickMenu_Close(); + end + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end -- if server and player + + -- handle regular profiles here + 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()); + setonce = 1; + end + info = {}; + info.notCheckable = true + info.text = player; + info.value = index; + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + end -- for players +end + +--[[ local +NAME: BuildAProfileMenu +DESC: Show save / load submenu off Profiles/Manage// from the Titan (right click) menu. +VAR: None +OUT: None +--]] +local function BuildAProfileMenu() + local info = {}; + + info = {}; + info.notCheckable = true + info.disabled = TitanAllGetVar("GlobalProfileUse") + info.text = L["TITAN_PANEL_MENU_LOAD_SETTINGS"]; + info.value = TitanPanelRightClickMenu_GetDropdMenuValue(); + info.func = function() + TitanVariables_UseSettings(TitanPanelRightClickMenu_GetDropdMenuValue(), TITAN_PROFILE_USE) + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.notCheckable = true + info.disabled = (TitanPanelRightClickMenu_GetDropdMenuValue() == TitanSettings.Player) + or ((TitanPanelRightClickMenu_GetDropdMenuValue() == TitanAllGetVar("GlobalProfileName")) + and (TitanAllGetVar("GlobalProfileUse"))) + info.text = L["TITAN_PANEL_MENU_DELETE_SETTINGS"]; + info.value = TitanPanelRightClickMenu_GetDropdMenuValue(); + info.func = function() + -- do not delete if current profile - .disabled + if TitanSettings.Players[info.value] then + TitanSettings.Players[info.value] = nil; + TitanPrint( + L["TITAN_PANEL_MENU_PROFILE"] + .." '"..info.value.."' " + ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] + , "info") + TitanPanelRightClickMenu_Close(); + end + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); +end + +--[[ local +NAME: BuildPluginCategoryMenu +DESC: Show the submenu with list of plugin off the category from the Titan (right click) menu. +VAR: None +OUT: None +--]] +local function BuildPluginCategoryMenu(frame) + local info = {}; + 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 + 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 + end + end +end + +--[[ Titan +NAME: TitanPanelRightClickMenu_PrepareBarMenu +DESC: This is the controller to show the proper level of the Titan (right click) menu. +VAR: self - expected to be the Tian bar that was right clicked +OUT: None +--]] +function TitanPanelRightClickMenu_PrepareBarMenu(self) + -- Determine which bar was clicked on + -- This MUST match the convention used in TitanPanel.xml to declare + -- the dropdown menu. ($parentRightClickMenu) + local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); + local lev = (TitanPanelRightClickMenu_GetDropdownLevel() or 1) +--[[ +print("_prep R click" +.." "..tostring(frame).."" +.." "..tostring(lev).."" +) +--]] + + -- Level 1 + if lev == 1 then + BuildMainMenu(frame) + end + + -- Level 2 + if ( lev == 2 ) then + if string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_ADDONS) then + BuildPluginCategoryMenu(frame) + end + + if ( TitanPanelRightClickMenu_GetDropdMenuValue() == R_SETTINGS ) then + BuildServerProfilesMenu() + end + return; + end + + -- Level 3 + if ( lev == 3 ) then + if string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_PLUGIN) then + BuildPluginMenu() + end + if string.find(TitanPanelRightClickMenu_GetDropdMenuValue(), R_PROFILE) then + BuildProfileMenu() + end + return; + end + + -- Level 4 + if ( lev == 4 ) then + BuildAProfileMenu() -- only load / delete profiles for now + return; + end + +end + +--[[ Titan +NAME: TitanPanel_IsPluginShown +DESC: Determine if the given plugin is shown on a Titan bar. The Titan bar could be not shown or on auto hide and the plugin will still be 'shown'. +VAR: id - plugin name (string) +OUT: int - index of the plugin or nil +--]] +function TitanPanel_IsPluginShown(id) + if ( id and TitanPanelSettings ) then + return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id); + end +end + +--[[ Titan +NAME: TitanPanel_GetPluginSide +DESC: Determine if the given plugin is or would be on right or left of a Titan bar. This returns right or left regardless of whether the plugin is 'shown'. +VAR: id - plugin name (string) +OUT: string - "Right" or "Left" +--]] +function TitanPanel_GetPluginSide(id) + if ( TitanGetVar(id, "DisplayOnRightSide") ) then + return TITAN_RIGHT; + else + return TITAN_LEFT; + end +end diff --git a/Titan/Titan.toc b/Titan/Titan.toc index 151544f..d57aade 100644 --- a/Titan/Titan.toc +++ b/Titan/Titan.toc @@ -14,9 +14,19 @@ ## X-License: All rights reserved (See license.txt) ## X-WoWI-ID: 8092 -embeds.xml +libs\Ace\LibStub\LibStub.lua +libs\Ace\CallbackHandler-1.0\CallbackHandler-1.0.xml +libs\Ace\AceAddon-3.0\AceAddon-3.0.xml +libs\Ace\AceHook-3.0\AceHook-3.0.xml +libs\Ace\AceTimer-3.0\AceTimer-3.0.xml +libs\Ace\AceGUI-3.0\AceGUI-3.0.xml +libs\Ace\AceConfig-3.0\AceConfig-3.0.xml +libs\Ace\AceLocale-3.0\AceLocale-3.0.xml +libs\Ace\LibSharedMedia-3.0\lib.xml +libs\Ace\AceGUI-3.0-SharedMediaWidgets\widget.xml +libs\Ace\LibQTip-1.0\lib.xml -LibDataBroker-1.1.lua +libs\LibDataBroker-1.1.lua locale\Localization.lua locale\Localization.BR.lua @@ -32,10 +42,11 @@ locale\Localization.TW.lua TitanUtils.lua TitanVariables.lua -TitanPanelTemplate.xml +TitanTemplate.xml +TitanTemplate.lua TitanMovable.lua TitanConfig.lua TitanAutoHide.lua -TitanPanel.xml -TitanPanel.lua -LDBToTitan.lua +Titan.xml +Titan.lua +TitanLDB.lua diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua new file mode 100644 index 0000000..584a1f5 --- /dev/null +++ b/Titan/TitanLDB.lua @@ -0,0 +1,922 @@ +--[[ File +NAME: LibDataBrokerToTitan.lua +DESC: A "bridge" module to ensure proper registration and communication of LDB plugins with Titan Panel +--]] +--[[ API +NAME: Titan LDB overview +DESC: Titan will automatically convert a LDB type addon to a Titan plugin. +Only LDB types listed in the LDB 1.1 spec are supported. Custom types are not supported. + +Supported type +- "launcher" become "icon" plugins + icon* - always shown + OnClick* - + label^ - + right side^ - default + tooltip +- "data source" become "combo" plugins with icon; a tooltip/Click; and optional label + icon^ - + OnClick - + text*^ - or value & suffix + label^ - + OnEnter - + OnLeave - + tooltip + OnTooltipShow - + +- "macro" become "combo" plugins with icon; a tooltip/Click; and optional label + icon^ - + commandtext^ - + label^ - + OnEnter - + OnLeave - + tooltip + OnTooltipShow - + +* required by LDB spec +^ user controlled show / hide +:DESC +--]] + +--[[ doc +----------------------------------------------------------------- +-- By Titan Dev team +-- Originally by Tristanian aka "TristTitan" as a Titan member +-- Created and initially commited on : July 29th, 2008 +----------------------------------------------------------------- +--]] +local xcategories = { +-- Titan categories mapping to match addon metadata information + ["Combat"] = "Combat", + ["General"] = "General", + ["Information"] = "Information", + ["Interface"] = "Interface", + ["Profession"] = "Profession", +-- Ace2 table mapping to Titan categories in order to match +-- addon metadata information + ["Action Bars"] = "Interface", + ["Auction"] = "Information", + ["Audio"] = "Interface", + ["Battlegrounds/PvP"] = "Information", + ["Buffs"] = "Information", + ["Chat/Communication"] = "Interface", + ["Druid"] = "Information", + ["Hunter"] = "Information", + ["Mage"] = "Information", + ["Paladin"] = "Information", + ["Priest"] = "Information", + ["Rogue"] = "Information", + ["Shaman"] = "Information", + ["Warlock"] = "Information", + ["Warrior"] = "Information", + ["Healer"] = "Information", + ["Tank"] = "Information", + ["Caster"] = "Information", +-- ["Combat"] = "Combat", + ["Compilations"] = "General", + ["Data Export"] = "General", + ["Development Tools "] = "General", + ["Guild"] = "Information", + ["Frame Modification"] = "Interface", + ["Interface Enhancements"] = "Interface", + ["Inventory"] = "Information", + ["Library"] = "General", + ["Map"] = "Interface", + ["Mail"] = "Information", + ["Miscellaneous"] = "General", + ["Misc"] = "General", + ["Quest"] = "Information", + ["Raid"] = "Information", + ["Tradeskill"] = "Profession", + ["UnitFrame"] = "Interface", +} +local LAUNCHER = "launcher" +local DATA_SOURCE = "data source" +local SupportedDOTypes = {DATA_SOURCE, LAUNCHER, "macro"} -- in the 1.1 spec + +-- constants & variables +local CALLBACK_PREFIX = "LibDataBroker_AttributeChanged_" +local NAME_PREFIX = "" --"LDBT_" +local _G = getfenv(0); +local InCombatLockdown = _G.InCombatLockdown; +-- Create control frame so we can get events +local LDBToTitan = CreateFrame("Frame", "LDBTitan") +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"; + +-- Events we want for LDBToTitan +LDBToTitan:RegisterEvent("PLAYER_LOGIN") +--LDBToTitan:RegisterEvent("PLAYER_ENTERING_WORLD") + +local function If_Show_Tooltip() + local use_mod = TitanAllGetVar("UseTooltipModifer") + local use_alt = TitanAllGetVar("TooltipModiferAlt") + local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") + local use_shift = TitanAllGetVar("TooltipModiferShift") + local ok = false + local tmp_txt = "" + if use_mod then + if (use_alt and IsAltKeyDown()) + or (use_ctrl and IsControlKeyDown()) + or (use_shift and IsShiftKeyDown()) + then + ok = true + end + else + ok = true + end + return ok +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBSetOwnerPosition +DESC: Properly anchor tooltips of the Titan (LDB) plugin +VAR: parent +VAR: anchorPoint +VAR: relativeToFrame +VAR: relativePoint +VAR: xOffset +VAR: yOffset +VAR: frame +--]] +function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) + if frame:GetName() == "GameTooltip" then + -- Changes for 9.1.5 Removed the background template from the GameTooltip + -- Making changes to it difficult and possibly changing the tooltip globally. + + frame:SetOwner(parent, "ANCHOR_NONE"); + + -- set font size for the Game Tooltip + if not TitanPanelGetVar("DisableTooltipFont") then + if TitanTooltipScaleSet < 1 then + TitanTooltipOrigScale = GameTooltip:GetScale(); + TitanTooltipScaleSet = TitanTooltipScaleSet + 1; + end + frame:SetScale(TitanPanelGetVar("TooltipFont")); + end + end + frame:ClearAllPoints(); + frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBSetTooltip +DESC: Fill in the tooltip for the Titan (LDB) plugin +VAR: name - Titan id of the plugin +VAR: frame - tooltip frame +VAR: func - tooltip function to be run +OUT: None +--]] +function LDBToTitan:TitanLDBSetTooltip(name, frame, func) +-- Check to see if we allow tooltips to be shown + if not TitanPanelGetVar("ToolTipsShown") + or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + return + end + + local button = TitanUtils_GetButton(name); + local scale = TitanPanelGetVar("Scale"); + local offscreenX, offscreenY; + local i = TitanPanel_GetButtonNumber(name); + local bar = TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(name) + local vert = TitanBarData[bar].vert + -- Get TOP or BOTTOM for the anchor and relative anchor + local rel_pt, pt + if vert == TITAN_TOP then + pt = "TOP" + rel_pt = "BOTTOM" + else + pt = "BOTTOM" + rel_pt = "TOP" + end + + if _G[bar] 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 + offscreenX, offscreenY = TitanUtils_GetOffscreen(frame); + if ( offscreenX == -1 ) then + self:TitanLDBSetOwnerPosition(button, pt.."LEFT", bar, + rel_pt.."LEFT", 0, 0, frame); + elseif ( offscreenX == 1 ) then + self:TitanLDBSetOwnerPosition(button, pt.."RIGHT", bar, + rel_pt.."RIGHT", 0, 0, frame); + end + else + end + + if func and If_Show_Tooltip() then func(frame) end; -- TODO: use pcall?? + frame:Show(); +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBHandleScripts +DESC: Script Handler for the Titan (LDB) plugin +VAR: event - event to process +VAR: name - id of the plugin +VAR: _ - not used +VAR: func - function to be run +VAR: obj - LDB object +OUT: None +NOTE: +- This implementation will work fine for a static tooltip but may have implications for dynamic ones so for now, we'll only set it once (no callback) and see what happens +:NOTE +--]] +function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) + local TitanPluginframe = _G["TitanPanel"..NAME_PREFIX..name.."Button"]; + + -- tooltip + if event:find("tooltip") and not event:find("OnTooltipShow") then + local pluginframe = _G[obj.tooltip] or obj.tooltip + if pluginframe then + TitanPluginframe:SetScript("OnEnter", function(self) + TitanPanelButton_OnEnter(self); + LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) + end + ) + + TitanPluginframe:SetScript("OnMouseDown", function(self) + pluginframe:Hide(); + end + ) + + if pluginframe:GetScript("OnLeave") then + -- do nothing + else + TitanPluginframe:SetScript("OnLeave", function(self) + if obj.OnLeave then + obj.OnLeave(self) + end + pluginframe:Hide(); + TitanPanelButton_OnLeave(self); + end + ) + end + + if pluginframe:GetName()~="GameTooltip" then + if pluginframe:GetScript("OnShow") then + -- do nothing + else + pluginframe:SetScript("OnShow", function(self) + LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, pluginframe, nil) + end + ) + end + end + end + + -- OnTooltipShow + elseif event:find("OnTooltipShow") then + TitanPluginframe:SetScript("OnEnter", function(self) + if TITAN_PANEL_MOVING == 0 and func then + LDBToTitan:TitanLDBSetTooltip(NAME_PREFIX..name, GameTooltip, func); + end + TitanPanelButton_OnEnter(self); + end + ) + TitanPluginframe:SetScript("OnLeave", function(self) + GameTooltip:Hide(); + TitanPanelButton_OnLeave(self); + end + ) + + -- OnDoubleClick + elseif event:find("OnDoubleClick") and not event:find("OnClick") then + TitanPluginframe:SetScript("OnDoubleClick", function(self, button) + if TITAN_PANEL_MOVING == 0 then + func(self, button) + end + end + ) + + -- OnClick + elseif event:find("OnClick") then + TitanPluginframe:SetScript("OnClick", function(self, button) + if TITAN_PANEL_MOVING == 0 then + func(self, button) + end + -- implement a safeguard, since the DO may actually use + -- Blizzy dropdowns ! + if not TitanPanelRightClickMenu_IsVisible() then + TitanPanelButton_OnClick(self, button); + else + TitanUtils_CloseAllControlFrames(); + end + end + ) + -- OnEnter + else + TitanPluginframe:SetScript("OnEnter", function(self) + -- Check for tooltip libs without embedding them + if AceLibrary and AceLibrary:HasInstance("Tablet-2.0") then + Tablet = AceLibrary("Tablet-2.0") + end + LibQTip = LibStub("LibQTip-1.0", true) + -- Check to see if we allow tooltips to be shown + if not TitanPanelGetVar("ToolTipsShown") + or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + -- if a plugin is using tablet, then detach and close the tooltip + if Tablet and Tablet:IsRegistered(TitanPluginframe) + and Tablet:IsAttached(TitanPluginframe) then + Tablet:Detach(TitanPluginframe); + Tablet:Close(TitanPluginframe); + end + return; + else + -- if a plugin is using tablet, then re-attach the tooltip + -- (it will auto-open on mouseover) + if Tablet and Tablet:IsRegistered(TitanPluginframe) + and not Tablet:IsAttached(TitanPluginframe) then + Tablet:Attach(TitanPluginframe); + end + end + -- if a plugin is using tablet then set its transparency + -- and font size accordingly + if Tablet and Tablet:IsRegistered(TitanPluginframe) then + Tablet:SetTransparency(TitanPluginframe, TitanPanelGetVar("TooltipTrans")) + if not TitanPanelGetVar("DisableTooltipFont") then + Tablet:SetFontSizePercent(TitanPluginframe, TitanPanelGetVar("TooltipFont")) + elseif TitanPanelGetVar("DisableTooltipFont") + and Tablet:GetFontSizePercent(TitanPluginframe)~=1 then + Tablet:SetFontSizePercent(TitanPluginframe, 1) + end + end + -- set original tooltip scale for GameTooltip + if not TitanPanelGetVar("DisableTooltipFont") then + TitanTooltipOrigScale = GameTooltip:GetScale(); + end + -- call OnEnter on LDB Object + if TITAN_PANEL_MOVING == 0 and func and If_Show_Tooltip() then + func(self) + end + + TitanPanelButton_OnEnter(self); + -- LibQTip-1.0 support code + if LibQTip then + local tt = nil + local key, tip + for key, tip in LibQTip:IterateTooltips() do + if tip then + local _, relativeTo = tip:GetPoint() + if relativeTo + and relativeTo:GetName() == TitanPluginframe:GetName() then + tt = tip + break + end + end + end + if tt then + -- set transparency + local red, green, blue, _ = tt:GetBackdropColor() + local red2, green2, blue2, _ = tt:GetBackdropBorderColor() + tt:SetBackdropColor(red,green,blue, + TitanPanelGetVar("TooltipTrans")) + tt:SetBackdropBorderColor(red2,green2,blue2, + TitanPanelGetVar("TooltipTrans")) + end + end + -- /LibQTip-1.0 support code + end + ) + + -- OnLeave + TitanPluginframe:SetScript("OnLeave", function(self) + if obj.OnLeave then + obj.OnLeave(self) + end + TitanPanelButton_OnLeave(self); + end + ) + end +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBTextUpdate +DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text of the LDB object +VAR: _ - not used +VAR: name - id of the plugin +VAR: event - event to process +VAR: attr - LDB obj attribute (field) that changed +VAR: value - new value of attr +VAR: dataobj - LDB object +OUT: None +--]] +function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) + -- just in case the LDB is active before Titan can register it... + if not Titan__InitializedPEW then + -- plugins have not been registered yet. + return + end + -- This check is overkill but just in case... + local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) + local ldb = plugin and plugin.LDBVariables + if not ldb then + -- This plugin has not been registered + return + end + + -- Accept the various display elements and update the Titan plugin + if attr == "value" then ldb.value = value end + if attr == "suffix" then ldb.suffix = value end + if attr == "text" then ldb.text = value end + if attr == "label" then ldb.label = value end + + -- Now update the button with the change + TitanPanelButton_UpdateButton(NAME_PREFIX..name) +end + +--[[ Titan +NAME: TitanLDBShowText +DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text +VAR: name - id of the plugin +OUT: label of text to show +OUT: text to show +--]] +function TitanLDBShowText(name) + -- Set 'label1' and 'value1' for the Titan button display + local nametrim = string.gsub (name, "LDBT_", ""); + local fontstring = _G["TitanPanel"..NAME_PREFIX..nametrim..TITAN_PANEL_BUTTON_TEXT]; + local separator = ": " + local lab1, val1 = "", "" + local plugin = TitanUtils_GetPlugin(name) + local ldb = plugin and plugin.LDBVariables + + if ldb then -- sanity check + -- Check for display label + if TitanGetVar(name, "ShowLabelText") then + lab1 = (ldb.label or "") + else + lab1 = "" + end + + if lab1 == "" then + -- leave alone + else + lab1 = lab1..separator + end + + -- Check for display text + -- Check for display text + -- .text is required to show + -- .value is the text of the value - 100.0 in 100.0 FPS + -- .suffix is the text after the value - FPS in 100.0 FPS + if TitanGetVar(name, "ShowRegularText") then + val1 = (ldb.text or "") + else + val1 = "" + end + else + -- return values will be empty strings + end + + if lab1 == "" then + lab1 = nil + else + lab1 = TitanUtils_GetNormalText(lab1) + end + if val1 == "" then + val1 = nil + else + val1 = TitanGetVar(name, "ShowColoredText") + and TitanUtils_GetGreenText(val1) or TitanUtils_GetHighlightText(val1) + end + return lab1, val1 +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBTextUpdate +DESC: Icon callback for the Titan (LDB) plugin when the LDB addon changes the icon of the LDB object +VAR: _ - not used +VAR: name - id of the plugin +VAR: attr - LDB obj attribute (field) that changed +VAR: value - new value of attr +VAR: dataobj - LDB object +OUT: None +--]] +function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) + -- just in case the LDB is active before Titan can register it... + if not Titan__InitializedPEW then + -- no plugins are registered yet + return + end + -- This check is overkill but just in case... + local plugin = TitanUtils_GetPlugin(NAME_PREFIX..name) + local ldb = plugin and plugin.LDBVariables + if not ldb then + -- This plugin is not registered yet + return + end + + if attr == "icon" then + TitanPlugins[NAME_PREFIX..name].icon = value; + TitanPanelButton_SetButtonIcon(NAME_PREFIX..name); + end + + -- support for iconCoords, iconR, iconG, iconB attributes + if attr == "iconCoords" then + TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, value); + end + + if attr == "iconR" or attr == "iconB" or attr == "iconG" then + TitanPanelButton_SetButtonIcon(NAME_PREFIX..name, nil, + dataobj.iconR, dataobj.iconG, dataobj.iconB); + end +end + +--[[ Titan +NAME: TitanLDBRefreshButton +DESC: Refresh all text & icon for LDB addons that were successfully registered +VAR: None +OUT: None +NOTE: +- Ensure all the LDB buttons are updated. +- This is called once x seconds after PEW. This helps close the gap where LDB addons set their text on their PEW event +:NOTE +--]] +function TitanLDBRefreshButton() +-- TitanDebug("LDB: RefreshButton") + for name, obj in ldb:DataObjectIterator() do + if obj then + local unused = nil + LDBToTitan:TitanLDBTextUpdate(unused, name, "text", (obj.text or ""), obj) + LDBToTitan:TitanLDBIconUpdate(unused, name, "icon", (obj.icon or iconTitanDefault), obj) + else +-- TitanDebug("LDB: '"..name.."' no refresh") + end + end +end + +--[[ Titan +NAME: LDBToTitan:TitanLDBCreateObject +DESC: New DO (Data Object) gets created here +VAR: _ - not used +VAR: name - id of the plugin +VAR: obj - LDB object +OUT: None +NOTE: +- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object)and creates a Titan plugin. +- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended. +:NOTE +--]] +function LDBToTitan:TitanLDBCreateObject(_, name, obj) + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug(tostring(name).." Attempting to register "); + end + + -- couple sanity checks + if not obj or not name then + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug("LDB request to create Titan plugin was unrecognizable!!!!"); + end + return + end + + -- anything to pass to the developer / user + local notes = "" + + -- sanity check for supported types + obj.type = obj.type or "Unknown" + local supported = false -- assume failure + for idx in ipairs(SupportedDOTypes) do + if obj.type and obj.type == SupportedDOTypes[idx] then + supported = true + end + end + if supported then + -- all is good - continue plugin creation + else + -- Create enough of a plugin to tell the user / developer + -- that this plugin failed miserably + local issue = "Unsupported LDB type '"..tostring(obj.type).."'" + local plugin = + { + self = nil, + button = nil, + isChild = nil, + name = (name or "?"), + issue = issue, + notes = "", + status = TITAN_REGISTER_FAILED, + category = "", + plugin_type = (obj.type or ""), + } + TitanUtils_PluginFail(plugin) + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug(TITAN_REGISTER_FAILED.." "..issue); + end + return -- get out, there is nothing more that can be done + end + + -- + -- Handle the display attributes of the DO and register the appropriate callbacks + -- + -- Init the display elements of the plugin + local ldb__label = obj.label or "" + local ldb__suffix = obj.suffix or "" + local ldb__value = obj.value or "" + local ldb__text = obj.text or "" + local ldb__icon = obj.icon or iconTitanDefault + + -- if .icon exists honor it and assume the addon may change it + if obj.icon then + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_icon", "TitanLDBIconUpdate") + end + + -- LAUNCHER text display elements + if obj.type == LAUNCHER then + if obj.label then + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") + elseif obj.text then + -- This is a 'be nice' check. It technically violates the 1.1 spec. + -- Blank the .text so the rest of the routines work + ldb__label = obj.text + obj.text = "" + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") + notes = notes.."\n" + .."This is a LDB '"..LAUNCHER + .."' without .label using .text instead!!!!" + end + end + if Titan__InitializedPEW then + notes = notes.."\n" + .."Will be registered as single LDB plugin after the normal registration." + end + -- DATA_SOURCE text display elements + if obj.type == DATA_SOURCE then + -- .text so always allow it + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") + if obj.label then + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") + end + if obj.suffix then + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_suffix", "TitanLDBTextUpdate") + end + if obj.value then + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_value", "TitanLDBTextUpdate") + end + end + + -- + -- These are icon extensions listed within the 1.1 spec + -- + -- support for iconCoords, iconR, iconG, iconB attributes + -- Due to the callbacks being fired these can easily affect + -- performance, BEWARE when using them ! + -- + -- capture the icon coords & color for the Titan plugin + if obj.iconCoords then + self:TitanLDBIconUpdate(nil, name, "iconCoords", obj.iconCoords, obj) + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_iconCoords", "TitanLDBIconUpdate") + end + if obj.iconR and obj.iconG and obj.iconB then + self:TitanLDBIconUpdate(nil, name, "iconR", obj.iconR, obj) + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_iconR", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_iconG", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_iconB", "TitanLDBIconUpdate") + end + + -- + -- Setup the Titan plugin for this LDB addon + -- + + -- Create the appropriate Titan registry for the DO + local registry = { + id = NAME_PREFIX..name, + ldb = tostring(obj.type), + -- per 1.1 spec if .label exists use it else use data object's name + menuText = obj.label or name, + buttonTextFunction = "TitanLDBShowText", + icon = ldb__icon, + iconWidth = 16, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = false, + ShowColoredText = false, + DisplayOnRightSide = true + }, + savedVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowRegularText = true, + ShowColoredText = false, + DisplayOnRightSide = false + }, + LDBVariables = { + value = ldb__value, + suffix = ldb__suffix, + text = ldb__text, + label = ldb__label, + name = name, + type = (obj.type or ""), + }, + notes = notes, + iconCoords = (obj.iconCoords or nil), + iconR = (obj.iconR or nil), + iconB = (obj.iconB or nil), + iconG = (obj.iconG or nil), + }; + + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug("" + .." type: '"..tostring(registry.ldb).."' " + ) + end + + -- Set the plugin category, if it exists, else default to "General" + -- Per the 1.1 LDB spec we check for a tocname attrib first, + -- if found we use it, if not we assume that the DO "name" + -- attribute is the same as the actual + -- addon name, which might not always be the case. + -- Titan defaults again to "General" if no categoy is found + -- via a check in the menu implementation, later on. + local addoncategory, addonversion; + local tempname = obj.tocname or name; + + -- This was a sanity check but does not allow for multiple + -- LDB to be within an addon yet act as their own addon. +-- if IsAddOnLoaded(tempname) then + addoncategory = GetAddOnMetadata(tempname, "X-Category"); + registry["category"]= (addoncategory and xcategories[addoncategory]) + or (obj.category) + or nil + addonversion = GetAddOnMetadata(tempname, "Version") + or (obj.version) + or "" + registry["version"]= addonversion; +-- end + + -- Depending on the LDB type set the control and saved Variables appropriately + if obj.type == LAUNCHER then + -- controls + -- one interpretation of the LDB spec is launchers + -- should always have an icon. + registry["controlVariables"].ShowIcon = true; + registry["controlVariables"].ShowRegularText = false; -- no text + -- defaults + registry["savedVariables"].ShowRegularText = false; + registry["savedVariables"].DisplayOnRightSide = true; -- start on right side + end + + if obj.type == DATA_SOURCE then + -- controls + registry["controlVariables"].ShowRegularText = true; + -- defaults + registry["savedVariables"].ShowRegularText = true; + end + + -- + -- Create the Titan frame for this LDB addon + -- Titan _OnLoad will be used to request the plugin be registered by Titan + local newTitanFrame -- a frame + if obj.type == "macro" then -- custom + newTitanFrame = CreateFrame("Button", + "TitanPanel"..NAME_PREFIX..name.."Button", + UIParent, "TitanPanelComboTemplate") +-- UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") + newTitanFrame:RegisterForClicks("AnyUp", "AnyDown") + newTitanFrame:SetMouseClickEnabled(true) + newTitanFrame:SetAttribute("type", "macro") +-- newTitanFrame:SetAttribute("macro", obj.commandtext) + newTitanFrame:SetAttribute("macrotext", obj.commandtext) + newTitanFrame:SetScript("OnClick", function(self, button, down) + SecureUnitButton_OnClick(self, button, down) + --TitanPanelBarButton_OnClick(self, button) + end) +--[[ +print("LDB macrotext" +.." "..tostring(obj.commandtext).."" +) +--]] + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug("" + .." macrotext cmd: '"..tostring(obj.commandtext).."' " + ) + end + else + newTitanFrame = CreateFrame("Button", + "TitanPanel"..NAME_PREFIX..name.."Button", + UIParent, "TitanPanelComboTemplate") + end + + newTitanFrame.TitanCreatedBy = "LDB" + newTitanFrame.TitanType = "macro" + newTitanFrame.TitanName = (name or "?") + newTitanFrame.TitanAction = (obj.commandtext or "None") + + newTitanFrame.registry = registry + newTitanFrame:SetFrameStrata("FULLSCREEN"); + newTitanFrame:SetToplevel(true); + newTitanFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp"); + + -- Use the routines given by the DO in this precedence + -- tooltip > OnEnter > OnTooltipShow > + -- or register a callback in case it is created later. Per the 1.1 LDB spec + if obj.tooltip then + self:TitanLDBHandleScripts("tooltip", name, nil, obj.tooltip, obj) + elseif obj.OnEnter then + self:TitanLDBHandleScripts("OnEnter", name, nil, obj.OnEnter, obj) + elseif obj.OnTooltipShow then + self:TitanLDBHandleScripts("OnTooltipShow", name, nil, obj.OnTooltipShow, obj) + else + self:TitanLDBHandleScripts("OnEnter", name, nil, nil, obj) + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_OnEnter", "TitanLDBHandleScripts") + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_OnTooltipShow", "TitanLDBHandleScripts") + end + + -- Use the OnClick given by the DO + -- or register a callback in case it is created later. + if obj.OnClick then + self:TitanLDBHandleScripts("OnClick", name, nil, obj.OnClick) + else + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_OnClick", "TitanLDBHandleScripts") + end + + -- + -- OnDoubleClick is UNDOCUMENTED in the 1.1 spec + -- but was implemented by the original developer + -- + -- Use the OnDoubleClick given by the DO + -- or register a callback in case it is created later. + if obj.OnDoubleClick then + self:TitanLDBHandleScripts("OnDoubleClick", name, nil, obj.OnDoubleClick) + else + ldb.RegisterCallback(self, + CALLBACK_PREFIX..name.."_OnDoubleClick", "TitanLDBHandleScripts") + end + + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug("" + .." id: '"..tostring(registry.id).."' " + .." type: '"..tostring(registry.ldb).."' " + .." type: '"..tostring(registry.ldb).."' " + ) + end + if TITAN_PANEL_VARS.debug.ldb_setup then + TitanDebug("" + .." id: '"..tostring(registry.id).."' " + .." registered" + ) + end + + -- If plugins have already been registered and loaded then get this one loaded + -- This works because the .registry is now set + if Titan__InitializedPEW then +--[[ +print("LDB late" +.." id: '"..tostring(registry.id).."' " +) +--]] + TitanUtils_RegisterPluginList() +-- TitanPanel_PlayerEnteringWorld() + end +end + +--[[ Titan +NAME: LDBToTitan:SetScript +DESC: OnEvent handler for LDBToTitan +VAR: event - string +VAR: function +OUT: None +NOTE: +- PLAYER_LOGIN - Read through all the LDB object created so far and create cooresponding Titan plugins. +:NOTE +--]] +LDBToTitan:SetScript("OnEvent", function(self, event, ...) + if (event == "PLAYER_LOGIN") then + self:UnregisterEvent("PLAYER_LOGIN") + -- In case a LDB plugin is created later... + ldb.RegisterCallback(self, + "LibDataBroker_DataObjectCreated", "TitanLDBCreateObject") + + -- Register the LDB plugins that have been created so far + for name, obj in ldb:DataObjectIterator() do + self:TitanLDBCreateObject(nil, name, obj) + --TitanDebug("Registered "..name.."."); + end + end + +--[[ + if (event == "PLAYER_ENTERING_WORLD") then + self:UnregisterEvent("PLAYER_ENTERING_WORLD") + end +--]] +end +) \ No newline at end of file diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua deleted file mode 100644 index e364fb2..0000000 --- a/Titan/TitanPanel.lua +++ /dev/null @@ -1,2188 +0,0 @@ ---[[ 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. ---]] - --- Locals -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 InCombatLockdown = _G.InCombatLockdown; -local IsTitanPanelReset = nil; -local new_toon = false - --- Library references -local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) -local AceTimer = LibStub("AceTimer-3.0") -local media = LibStub("LibSharedMedia-3.0") -local AceConfigDialog = LibStub("AceConfigDialog-3.0") - --- TitanDebug (cmd.." : "..p1.." "..p2.." "..p3.." "..#cmd_list) - --------------------------------------------------------------- --- -function TitanPanel_OkToReload() - StaticPopupDialogs["TITAN_RESET_RELOAD"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) - .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - ReloadUI() - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RESET_RELOAD"); -end - ---[[ Titan -NAME: TitanPanel_ResetToDefault -DESC: Give the user a 'are you sure'. If the user accepts then reset current toon back to default Titan settings. -VAR: None -OUT: None -NOTE: -- Even if the user was using global profiles they will not when this is done. -:NOTE ---]] -function TitanPanel_ResetToDefault() - StaticPopupDialogs["TITAN_RESET_BAR"] = { - text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) - .."\n\n"..L["TITAN_PANEL_RESET_WARNING"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - TitanVariables_UseSettings(TitanSettings.Player, TITAN_PROFILE_RESET); - IsTitanPanelReset = true; - ReloadUI() - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RESET_BAR"); -end - ---[[ Titan -NAME: TitanPanel_SaveCustomProfile -DESC: The user wants to save a custom Titan profile. Show the user the dialog boxes to make it happen. -VAR: None -OUT: None -NOTE: -- The profile is written to the Titan saved variables. A reload of the UI is needed to ensure the profile is written to disk for the user to load later. -:NOTE ---]] -function TitanPanel_SaveCustomProfile() - -- Create the dialog box code we'll need... - - -- helper to actually write the profile to the Titan saved vars - local function Write_profile(name) - local currentprofilevalue, _, _ = TitanUtils_GetPlayer() - local profileName = TitanUtils_CreateName(name, TITAN_CUSTOM_PROFILE_POSTFIX) - TitanSettings.Players[profileName] = - TitanSettings.Players[currentprofilevalue] - TitanPrint(L["TITAN_PANEL_MENU_PROFILE_SAVE_PENDING"] - .."'"..name.."'" - , "info") - end - -- helper to ask the user to overwrite a profile - local function Overwrite_profile(name) - local dialogFrame = - StaticPopup_Show("TITAN_OVERWRITE_CUSTOM_PROFILE", name); - if dialogFrame then - dialogFrame.data = name; - end - end - -- helper to handle getting the profile name from the user - 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, " ", "" ); - 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 profileName = TitanUtils_CreateName(concprofileName, TITAN_CUSTOM_PROFILE_POSTFIX) - if TitanSettings.Players[profileName] then - -- Warn the user of an existing profile - Overwrite_profile(rawprofileName) - self:Hide(); - return; - else - -- Save the requested profile - Write_profile(rawprofileName) - self:Hide(); - StaticPopup_Show("TITAN_RELOADUI"); - end - end - -- 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"], - button1 = "OKAY", - OnAccept = function(self) - ReloadUI(); -- ensure profile is written to disk - end, - showAlert = 1, - whileDead = 1, - timeout = 0, - }; - - -- 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"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self, data) - Write_profile(data) - self:Hide(); - StaticPopup_Show("TITAN_RELOADUI"); - end, - showAlert = 1, - whileDead = 1, - timeout = 0, - hideOnEscape = 1 - }; - - -- 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"], - button1 = ACCEPT, - button2 = CANCEL, - hasEditBox = 1, - maxLetters = 20, - OnAccept = function(self) - -- self refers to this frame with the Accept button - Get_profile_name(self) - end, - OnShow = function(self) - self.editBox:SetFocus(); - end, - OnHide = function(self) - self.editBox:SetText(""); - end, - EditBoxOnEnterPressed = function(self) - -- We need to get the parent because self refers to the edit box. - Get_profile_name(self:GetParent()) - end, - EditBoxOnEscapePressed = function(self) - self:GetParent():Hide(); - end, - timeout = 0, - exclusive = 1, - whileDead = 1, - hideOnEscape = 1 - }; - - 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"] = {} - -end - ---[[ Titan -NAME: TitanSetPanelFont -DESC: Set or change the font and font size of text on the Titan bar. This affects ALL plugins. -VAR: fontname - The text name of the font to use. Defaults to Titan default if none given. -VAR: fontsize - The size of the font to use. Defaults to Titan default if none given. -OUT: None -NOTE: -- Each registered plugin will have its font updated. Then all plugins will be refreshed to show the new font. -:NOTE ---]] -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); - end - end - end - end - end - TitanPanel_RefreshPanelButtons(); -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"); --- --- Event routine : redirects to TitanPanelBarButton: routines below. -_G[TITAN_PANEL_CONTROL]:SetScript("OnEvent", function(_, event, ...) - _G[TITAN_PANEL_CONTROL][event](_G[TITAN_PANEL_CONTROL], ...) -end) - - ---[[ Titan -NAME: TitanPanel_PlayerEnteringWorld -DESC: Do all the setup needed when a user logs in / reload UI / enter or leave an instance. -VAR: None -OUT: None -NOTE: -- This is called after the 'player entering world' event is fired by Blizz. -- This is also used when a LDB plugin is created after Titan runs the 'player entering world' code. -:NOTE ---]] -function TitanPanel_PlayerEnteringWorld(reload) ---[[ -print("PEW" -.." "..tostring(Titan__InitializedPEW).."" -) ---]] - if Titan__InitializedPEW then - -- Currently no additional steps needed - else - -- Get Profile and Saved Vars - new_toon = TitanVariables_InitTitanSettings(); - if TitanAllGetVar("Silenced") then - -- No header output - else - TitanPrint("", "header") - end - - if not ServerTimeOffsets then - ServerTimeOffsets = {}; - end - if not ServerHourFormat then - ServerHourFormat = {}; - end - - -- Set the two anchors in their default positions - -- until the Titan bars are drawn - TitanPanelTopAnchor:ClearAllPoints(); - TitanPanelTopAnchor:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0); - TitanPanelBottomAnchor:ClearAllPoints(); - TitanPanelBottomAnchor:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0); - - -- Ensure the bars are created before the plugins are registered. - 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 - - 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") - end - - -- 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") - TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", - function() - if OrderHallCommandBar then - OrderHallCommandBar:Hide() - OrderHallCommandBar:UnregisterAllEvents() - OrderHallCommandBar.Show = function () end - end - end - ) - else - local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0") - TitanPanelAce:Unhook("OrderHall_CheckCommandBar") - end - - end - local _ = nil - 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 - TitanUtils_RegisterPluginList() - - -- Init detailed settings only after plugins are registered! - local profile_action = nil - if new_toon then - profile_action = TITAN_PROFILE_RESET - else - profile_action = TITAN_PROFILE_INIT - end - - TitanVariables_UseSettings(nil, profile_action) - - -- all addons are loaded so update the config (options) - -- some could have registered late... - TitanUpdateConfig("init") - - -- Init panel font - local isfontvalid = media:IsValid("font", TitanPanelGetVar("FontName")) - if isfontvalid then - TitanSetPanelFont(TitanPanelGetVar("FontName"), TitanPanelGetVar("FontSize")) - else - -- 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 - - -- Init panel frame strata - TitanVariables_SetPanelStrata(TitanPanelGetVar("FrameStrata")) - - -- Titan Panel has initialized its variables and registered plugins. - -- Allow Titan - and others - to adjust the bars - Titan__InitializedPEW = true - - -- Move frames --- TitanMovable_SecureFrames() - - -- Also sync LDB object text with their created Titan plugin - TitanLDBRefreshButton() -end - --------------------------------------------------------------- --- --- Event handlers --- ---[===[ - local WoWClassicEra, WoWClassicTBC, WoWWOTLKC, WoWRetail - if wowversion < 20000 then - WoWClassicEra = true - elseif wowversion < 30000 then - WoWClassicTBC = true - elseif wowversion < 40000 then - WoWWOTLKC = true - elseif wowversion > 90000 then - WoWRetail = true - else - -- n/a - end ---]===] -function TitanPanelBarButton:ADDON_LOADED(addon) - if addon == TITAN_ID then - -- Determine WoW TOC Version - local wowversion = select(4, GetBuildInfo()) - if wowversion >= 100000 then -- Initialize Titan - -- Event registration - _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD"); - _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"); - else - -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era - -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. - TitanPrint("Titan did not initialize!!!!" - , "error") - TitanPrint("This version needs API released with " - .." "..tostring(EXPANSION_NAME9).."" - .." (10.00.xx)" - , "error") - end - -- Unregister event - saves a few event calls. - self:UnregisterEvent("ADDON_LOADED"); - self.ADDON_LOADED = nil - end -end - -function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2) - local call_success = nil - local ret_val = nil - ---[[ -print("PLAYER_ENTERING_WORLD" -.." "..tostring(arg1).."" -.." "..tostring(arg2).."" -) ---]] - call_success, -- needed for pcall - ret_val = -- actual return values - pcall (TitanPanel_PlayerEnteringWorld, arg2) - -- pcall does not allow errors to propagate out. Any error - -- is returned as text with the success / fail. - -- Think of it as sort of a try - catch block - if call_success then - -- Titan initialized properly - else - -- something really bad occured... - TitanPrint("Titan could not initialize!!!! Cleaning up...", "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, ...) - - -- Hide the bars. At times they are there but at 0% transparency. - -- They can be over the Blizz action bars creating havoc. - TitanPrint("-- Hiding Titan bars...", "warning") - TitanPanelBarButton_HideAllBars() - - -- Remove the options pages - TitanUpdateConfig("nuke") - -- What else to clean up??? - - -- raise the error to WoW for display, if display errors is set. - -- This *must be* the last statement of the routine! - error(ret_val, 1) - end -end - -function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) - if cvarname == "USE_UISCALE" - or cvarname == "WINDOWED_MODE" - or cvarname == "uiScale" then - if TitanPlayerSettings and TitanPanelGetVar("Scale") then - TitanPanel_InitPanelBarButton() -- TitanPanel_SetScale() - end - end -end - -function TitanPanelBarButton:PLAYER_LOGOUT() - if not IsTitanPanelReset then - -- for debug - if TitanPanelRegister then - TitanPanelRegister.ToBe = TitanPluginToBeRegistered - TitanPanelRegister.ToBeNum = TitanPluginToBeRegisteredNum - TitanPanelRegister.TitanPlugins = TitanPlugins - end - end - Titan__InitializedPEW = nil -end - -function TitanPanelBarButton:ZONE_CHANGED() - TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED") -end - -function TitanPanelBarButton:ZONE_CHANGED_INDOORS() - TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_INDOORS") -end - -function TitanPanelBarButton:ZONE_CHANGED_NEW_AREA() - TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_NEW_AREA") -end - -function TitanPanelBarButton:PET_BATTLE_OPENING_START() ---print("PET_BATTLE_OPENING_START") - TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_OPENING_START") - -- Hide all bars and hiders --- TitanPanelBarButton_HideAllBars() -end - -function TitanPanelBarButton:PET_BATTLE_CLOSE() ---print("PET_BATTLE_CLOSE") - TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_CLOSE") -end - -local in_combat = false -- seems InCombatLockdown may not be set fast enough to reliably hide bars... -function TitanPanelBarButton:PLAYER_REGEN_ENABLED() - in_combat = false - TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_ENABLED") -end - -function TitanPanelBarButton:PLAYER_REGEN_DISABLED() - in_combat = true - TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_DISABLED") -end --- - ---[[ Titan -NAME: TitanPanelBarButton_OnClick -DESC: Handle the button clicks on any Titan bar. -VAR: self - expected to be a Titan bar -VAR: button - which mouse button was clicked -OUT: None -NOTE: -- This only reacts to the right or left mouse click without modifiers. -- Used in the set script for the Titan display and hider frames -:NOTE ---]] -function TitanPanelBarButton_OnClick(self, button) - -- ensure that the right-click menu will not appear on "hidden" bottom bar(s) ---[[ -print("_OnClick" -.." "..tostring(bar).."" -) ---]] - if (button == "LeftButton") then - TitanUtils_CloseAllControlFrames(); - TitanUtils_CloseRightClickMenu(); - elseif (button == "RightButton") then - TitanUtils_CloseAllControlFrames(); - TitanPanelRightClickMenu_Close(); - -- Show RightClickMenu anyway - TitanPanelRightClickMenu_Toggle(self) - end -end - --- --- Slash command handler --- ---[[ local -NAME: TitanPanel_ParseSlashCmd -DESC: Helper to parse the user commands. -VAR: cmd - user string from the command 'window' -OUT: table - table of 'words' the user typed in -NOTE: -- each 'word' in words table is made lower case for comparison simplicity -: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 "?") - end ---[[ - local tmp = "" - for idx,v in pairs (words) do - tmp = tmp.."'"..words[idx].."' " - end - - TitanDebug (tmp.." : "..#words) ---]] - return words -end - ---[[ local -NAME: handle_slash_help -DESC: Helper to tell the user the relevant Titan commands. -VAR: cmd - string 'all' | 'reset' | 'gui' | 'silent' -OUT: None -NOTE: -- Depending on cmd put to chat the appropriate help -:NOTE ---]] -local function handle_slash_help(cmd) - cmd = cmd or "all" - - -- Give the user the general help if we can not figure out what they want - TitanPrint("", "header") - -- Cannot count registered plugins after initial registration TitanUtils_RegisterPluginList() - - if cmd == "reset" then - TitanPrint(L["TITAN_PANEL_SLASH_RESET_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_RESET_1"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_RESET_2"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_RESET_3"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_RESET_4"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_RESET_5"], "plain") - end - if cmd == "gui" then - TitanPrint(L["TITAN_PANEL_SLASH_GUI_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_GUI_1"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_GUI_2"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_GUI_3"], "plain") - end - if cmd == "profile" then - TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_1"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_2"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_PROFILE_3"], "plain") - end - if cmd == "silent" then - TitanPrint(L["TITAN_PANEL_SLASH_SILENT_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_SILENT_1"], "plain") - end - if cmd == "orderhall" then - TitanPrint(L["TITAN_PANEL_SLASH_ORDERHALL_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_ORDERHALL_1"], "plain") - end - if cmd == "help" then - TitanPrint(L["TITAN_PANEL_SLASH_HELP_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_HELP_1"], "plain") - end - if cmd == "all" then - TitanPrint(L["TITAN_PANEL_SLASH_ALL_0"], "plain") - TitanPrint(L["TITAN_PANEL_SLASH_ALL_1"], "plain") - end -end - ---[[ local -NAME: handle_reset_cmds -DESC: Helper to execute the various reset commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_reset_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - -- sanity check - if (not cmd == "reset") then - return - end - - if p1 == nil then - TitanPanel_ResetToDefault(); - elseif p1 == "tipfont" then - 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(); - local red2, green2, blue2, _ = GameTooltip:GetBackdropBorderColor(); - 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); - TitanPanel_InitPanelBarButton() -- TitanPanel_SetScale() - TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info") - else - TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning") - end - elseif p1 == "spacing" then - TitanPanelSetVar("ButtonSpacing", 20); - TitanPanel_InitPanelButtons(); - TitanPrint(L["TITAN_PANEL_SLASH_RESP4"], "info") - else - handle_slash_help("reset") - end -end - ---[[ local -NAME: handle_giu_cmds -DESC: Helper to execute the gui related commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_giu_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - -- sanity check - if (not cmd == "gui") then - return - end - --- 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... - -end - ---[[ local -NAME: handle_profile_cmds -DESC: Helper to execute the profile related commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_profile_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - local p2 = cmd_list[3] or nil - local p3 = cmd_list[4] or nil - -- sanity check - if (not cmd == "profile") then - return - end - - if p1 == "use" and p2 and p3 then - if TitanAllGetVar("GlobalProfileUse") then - TitanPrint(L["TITAN_PANEL_GLOBAL_ERR_1"], "info") - else - TitanVariables_UseSettings(TitanUtils_CreateName(p2, p3), TITAN_PROFILE_USE) - end - else - handle_slash_help("profile") - end -end - ---[[ local -NAME: handle_silent_cmds -DESC: Helper to execute the silent commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_silent_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - -- sanity check - if (not cmd == "silent") then - return - end - - if TitanAllGetVar("Silenced") then - TitanAllSetVar("Silenced", false); - 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") - end -end - ---[[ local -NAME: handle_orderhall_cmds -DESC: Helper to execute the orderhall commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_orderhall_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - -- sanity check - if (not cmd == "orderhall") then - return - end - - if TitanAllGetVar("OrderHall") then - TitanAllSetVar("OrderHall", false); - 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"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - ReloadUI(); - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RELOAD"); - else - TitanAllSetVar("OrderHall", true); - 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"], - button1 = ACCEPT, - button2 = CANCEL, - OnAccept = function(self) - ReloadUI(); - end, - showAlert = 1, - timeout = 0, - whileDead = 1, - hideOnEscape = 1 - }; - StaticPopup_Show("TITAN_RELOAD"); - end -end - ---[[ local -NAME: handle_help_cmds -DESC: Helper to execute the help commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] -local function handle_help_cmds(cmd_list) - local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil - -- sanity check - if (not cmd == "help") then - return - end - - handle_slash_help(p1 or "all") -end - ---[[ local -NAME: TitanPanel_RegisterSlashCmd -DESC: Helper to parse and execute all the Titan slash commands from the user. -VAR: cmd - The command (string) the user typed in -OUT: None ---]] -local function TitanPanel_RegisterSlashCmd(cmd_str) - local cmd_list = {} - -- parse what the user typed - cmd_list = TitanPanel_ParseSlashCmd(cmd_str) - local cmd = cmd_list[1] or "" - local p1 = cmd_list[2] or "" - local p2 = cmd_list[3] or "" - local p3 = cmd_list[4] or "" - - if (cmd == "reset") then - handle_reset_cmds(cmd_list) - elseif (cmd == "gui") then - handle_giu_cmds(cmd_list) - elseif (cmd == "profile") then - handle_profile_cmds(cmd_list) - elseif (cmd == "silent") then - handle_silent_cmds(p1) - elseif (cmd == "orderhall") then - handle_orderhall_cmds(p1) - elseif (cmd == "help") then - handle_slash_help(p1) - else - handle_slash_help("all") - end -end - --------------------------------------------------------------- --- --- Register slash commands for Titan Panel -SlashCmdList["TitanPanel"] = TitanPanel_RegisterSlashCmd; -SLASH_TitanPanel1 = "/titanpanel"; -SLASH_TitanPanel2 = "/titan"; - --------------------------------------------------------------- --- --- Texture routines -local function Set_Color(frame, tex, color) - ---[[ -print("_Set bar color" -.." "..tostring(TitanBarData[frame].tex_name).."" ---.." "..tostring(tex:GetName()).."" -.." "..tostring(format("%0.1f", color.r)).."" -.." "..tostring(format("%0.1f", color.g)).."" -.." "..tostring(format("%0.1f", color.b)).."" -.." "..tostring(format("%0.1f", color.alpha)).."" -) ---]] - _G[frame]:SetBackdrop({ - bgFile="Interface\\Tooltips\\UI-Tooltip-Background", --- edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", --- edgeFile="Interface\\DialogFrame\\UI-DialogBox-Gold-Border", - edgeFile="Interface\\Glues\\Common\\TextPanel-Border", - tile = true, - tileEdge = true, --- insets = { left = 1, right = 1, top = 1, bottom = 1 }, - tileSize = 8, - edgeSize = 8, - }) - - _G[frame]:SetBackdropBorderColor( - TOOLTIP_DEFAULT_COLOR.r, - TOOLTIP_DEFAULT_COLOR.g, - TOOLTIP_DEFAULT_COLOR.b); - _G[frame]:SetBackdropColor( - color.r, - color.g, - color.b, - color.alpha); ---[[ - -- Apply the texture to the bar, using the system repeat to fill it - tex:SetColorTexture( - color.r, - color.g, - color.b, - color.alpha - ) - tex:SetAllPoints() - tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true - tex:SetVertTile(true) -- ensures image is 'full' height of frame ---]] -end - -local function Set_Skin(frame, tex, skin) - -- Use the texture / skin per user selectable options - - -- skins are in two parts - top & bottom... - -- TODO : have Short bars choose top or bottom skin?? - local edge = "" - if TitanBarData[frame].vert == TITAN_BOTTOM - then - edge = TITAN_BOTTOM - else - edge = TITAN_TOP - end - - -- Apply the texture to the bar, using the system repeat to fill it - local texture_file = skin.path.."TitanPanelBackground"..edge.."0" ---[[ -print("_Skin" -.." "..tostring(TitanBarData[frame].tex_name.."" ---.." "..tostring(tex:GetName()).."" -.." "..tostring(skin.path).."" ---.."\n "..tostring(edge).."" ---.." "..tostring(skin.alpha).."" ---.."\n "..tostring(tex:GetTexture()).."" -) ---]] ---[[ -- appears seeting image this way just smears image... - _G[frame]:SetBackdrop({ - bgFile=texture_file, --- edgeFile=nil, - tile = true, --- tileSize = 256, --- tileEdge = true, --- insets = { left = 1, right = 1, top = 1, bottom = 1 }, --- tileSize = 8, --- edgeSize = 8, - }) ---]] - tex:SetAllPoints() - tex:SetHorizTile(true) -- ensures repeat; 'smears' if not sest to true - tex:SetTexture(texture_file, "REPEAT") - tex:SetVertTile(true) -- ensures image is 'full' height of frame --- tex:SetHeight(TITAN_PANEL_BAR_TEXTURE_HEIGHT) -- leaves a gap if used - tex:SetAlpha(skin.alpha) -end - -function TitanPanel_SetBarTexture(frame) - if frame and TitanBarData[frame] then - -- proceed - else - return - end - - -- Create the path & file name to the texture - local tex = TitanBarData[frame].tex_name - if _G[tex] then - titanTexture = _G[tex] - else - titanTexture = _G[frame]:CreateTexture(tex, "BACKGROUND") - end - titanTexture:SetTexture() - _G[frame]:SetBackdrop({ - bgFile="", - }) - ---[[ -print("_Tex" -.." "..tostring(TitanBarData[frame].name).."" ---.." "..tostring(tex).."" -.." "..tostring(titanTexture:GetName()).."" ---.." "..tostring(skin.path).."" ---.."\n "..tostring(edge).."" ---.." "..tostring(skin.alpha).."" ---.."\n "..tostring(tex:GetTexture()).."" -.." "..tostring(TitanBarDataVars["Global"].texure).."" -.." "..tostring(TitanBarDataVars[frame].texure).."" -) ---]] - -- Use the texture / skin per user selectable options - if TitanBarDataVars["Global"].texure == TitanVars.SKIN then - Set_Skin(frame, titanTexture, TitanBarDataVars["Global"].skin) -- tex_path = TitanPanelGetVar("TexturePath") - elseif TitanBarDataVars["Global"].texure == TitanVars.COLOR then - Set_Color(frame, titanTexture, TitanBarDataVars["Global"].color) - elseif TitanBarDataVars[frame].texure == TitanVars.SKIN then - Set_Skin(frame, titanTexture, TitanBarDataVars[frame].skin) - elseif TitanBarDataVars[frame].texure == TitanVars.COLOR then - Set_Color(frame, titanTexture, TitanBarDataVars[frame].color) - end -end - --------------------------------------------------------------- --- --- auto hide event handlers ---[[ Titan -NAME: TitanPanelBarButton_OnLeave -DESC: On leaving the display check if we have to hide the Titan bar. A timer is used - when it expires the bar is hid. -VAR: self - expected to be a Titan bar -OUT: None ---]] -function TitanPanelBarButton_OnLeave(self) - local frame = (self and self:GetName() or nil) - local bar = (TitanBarData[frame] and TitanBarData[frame].name or nil) - - -- if auto hide is active then let the timer hide the bar - local hide = (bar and TitanBarDataVars[frame].auto_hide or nil) --- local hide = (bar and TitanPanelGetVar(bar.."_Hide") or nil) - if hide then - Titan_AutoHide_Timers(frame, "Leave") - end -end - ---[[ Titan -NAME: TitanPanelBarButton_OnEnter -DESC: No code - this is a place holder for the XML template. -VAR: self - expected to be a Titan bar -OUT: None ---]] -function TitanPanelBarButton_OnEnter(self) - -- no work to do -end - ---[[ Titan -NAME: TitanPanelBarButtonHider_OnLeave -DESC: No code - this is a place holder for the XML template. -VAR: self - expected to be a Titan bar -OUT: None ---]] -function TitanPanelBarButtonHider_OnLeave(self) - -- no work to do -end - ---[[ Titan -NAME: TitanPanelBarButtonHider_OnEnter -DESC: On entering the hider check if we need to show the display bar. -VAR: self - expected to be a Titan hider bar -OUT: None -NOTE: -- No action is taken if the user is on combat. -:NOTE ---]] -function TitanPanelBarButtonHider_OnEnter(self) - -- make sure self is valid - local index = self and self:GetName() or nil - if not index then return end -- sanity check - - -- so the bar does not 'appear' when moused over in combat - if TitanPanelGetVar("LockAutoHideInCombat") and InCombatLockdown() then return end - - -- find the relevant bar data - local frame = nil - for idx,v in pairs (TitanBarData) do - if index == TitanBarData[idx].hider then - frame = idx - end - end - -- Now process that bar - if frame then - Titan_AutoHide_Timers(frame, "Enter") - TitanPanelBarButton_Show(frame) - end -end - --------------------------------------------------------------- --- --- Titan Bar - ---[[ Titan -NAME: TitanPanelBarButton_ForceLDBLaunchersRight -DESC: Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. Any visible plugin will be forced to the right side on the same bar it is currently on. -VAR: None -OUT: None ---]] -function TitanPanelBarButton_ForceLDBLaunchersRight() - local plugin, index, id; - for index, id in pairs(TitanPluginsIndex) do - plugin = TitanUtils_GetPlugin(id); - if 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["TitanPanel"..id..TITAN_PANEL_BUTTON_TEXT] = nil; - if button:IsVisible() then - local bar = TitanUtils_GetWhichBar(id) - TitanPanel_RemoveButton(id); - TitanUtils_AddButtonOnBar(bar, id) - end - end - end - end -end - ---[[ local -NAME: TitanAnchors -DESC: Helper to create the 'anchor' frames used by other addons that need to adjust so Titan can be visible. The anchor frames are adjusted depending on which Titan bars the user selects to show. -VAR: None -OUT: None -NOTE: -- TitanPanelTopAnchor - the frame at the bottom of the top bar(s) shown. -- TitanPanelBottomAnchor - the frame at the top of the bottom bar(s) shown. -:NOTE ---]] -local function TitanAnchors() - local anchor_top = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_TOP) - local anchor_bot = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM) - 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()) - 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 -) ---]] - 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 - ---[[ Titan -NAME: TitanPanelBarButton_DisplayBarsWanted -DESC: Show all the Titan bars the user has selected. -VAR: None -OUT: None ---]] -function TitanPanelBarButton_DisplayBarsWanted(reason) ---[===[ -print("_DisplayBarsWanted" -.." "..tostring(reason).."" -) ---]===] - -- Check all bars to see if the user has requested they be shown - for idx,v in pairs (TitanBarData) do - -- Show / hide plus kick auto hide, if needed - Titan_AutoHide_Init(idx) - end - - -- Set anchors for other addons to use. - TitanAnchors() -end - ---[[ Titan -NAME: TitanPanelBarButton_HideAllBars -DESC: This routine will hide all the Titan bars (and hiders) regardless of what the user has selected. -VAR: None -OUT: None -NOTE: -- For example when the pet battle is active. We cannot figure out how to move the pet battle frame so we are punting and hiding Titan... -- We only need to hide the bars (and hiders) - not adjust frames -:NOTE ---]] -function TitanPanelBarButton_HideAllBars() - for idx,v in pairs (TitanBarData) do - TitanPanelBarButton_Hide(idx) - end -end - ---[[ Titan -NAME: TitanPanelBarButton_HideTopBars -DESC: This routine will hide the bars Titan bars (and hiders) regardless of what the user has selected. -VAR: None -OUT: None -NOTE: -- For example when the class hall -- We only need to hide the bars (and hiders) - not adjust frames -:NOTE ---]] -function TitanPanelBarButton_HideTopBars() - if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar"].show then --- if TitanPanelGetVar("Bar_Show") then - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar") - end - if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."Bar2"].show then --- if TitanPanelGetVar("Bar2_Show") then - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."Bar2") - end -end - ---[[ Titan -NAME: TitanPanelBarButton_HideBottomBars -DESC: This routine will hide the bottom Titan bars (and hiders) regardless of what the user has selected. -VAR: None -OUT: None -NOTE: -- For example when the override bar is being used -- We only need to hide the bars (and hiders) - not adjust frames -:NOTE ---]] -function TitanPanelBarButton_HideBottomBars() - if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar"].show then --- if TitanPanelGetVar("AuxBar_Show") then - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar") - end - if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"].show then --- if TitanPanelGetVar("AuxBar2_Show") then - TitanPanelBarButton_Hide(TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2") - end -end - -local function showBar(frame_str) - -- Conditions where this bar should not be shown... - local flag = true -- only set false for known conditions - - if frame_str == TITAN_PANEL_DISPLAY_PREFIX.."Bar" - or frame_str == TITAN_PANEL_DISPLAY_PREFIX.."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" - ) - then - flag = false - end - -- ===== In Pet Battle - if C_PetBattles.IsInBattle() - then - flag = false - end - end - - -- ===== In Combat : User selected - if TitanBarDataVars[frame_str].hide_in_combat - or TitanPanelGetVar("HideBarsInCombat") then - if in_combat then -- InCombatLockdown() too slow - flag = false - end - end ---[[ -print("showBar" ---.." "..tostring(C_PetBattles.IsInBattle()).."" -.." > "..tostring(flag).."" -) ---]] - return flag -end - ---[[ Titan -NAME: TitanPanelBarButton_Show -DESC: Show / hide the given Titan bar based on the user selection. -VAR: frame - expected to be a Titan bar name (string) -OUT: None -NOTE: -- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. -:NOTE ---]] -function TitanPanelBarButton_Show(frame) - local display = _G[frame]; - local bar = TitanBarData[frame].name - - if display and TitanBarData[frame].name - then - local x, y, w = TitanVariables_GetBarPos(frame) - local show = TitanBarData[frame].show - local bott = TitanBarData[frame].bott - - -- Show the display bar if the user requested it - -- And there are no conditions preventing... - if TitanBarDataVars[frame].show -- User requested - and showBar(frame) -- No preventing condition - then - display:ClearAllPoints(); ---[===[ -local sx, sy = TitanUtils_ScreenSize(false) -print("TB_Show" ---.." "..tostring(frame).."" -.." "..tostring(bar).."" -.." "..tostring(TitanBarDataVars[frame].show).."" -) -print(">>" ---.." "..tostring(show.pt).."" ---.." "..tostring(show.rel_fr).."" ---.." "..tostring(show.rel_pt).."" -.." x:"..tostring(format("%0.1f", x)).."" -.." y:"..tostring(format("%0.1f", y)).."" -.." w:"..tostring(format("%0.1f", w)).."" -.." sx:"..tostring(format("%0.1f", sx)).."" -.." sy:"..tostring(format("%0.1f", sy)).."" -) ---]===] - if TitanBarData[frame].user_move then - display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) - else - display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) - local h = TITAN_PANEL_BAR_HEIGHT -- / UIParent:GetEffectiveScale() -- adjust scale so it is full height - display:SetPoint(bott.pt, bott.rel_fr, bott.rel_pt, x, y - h) - end - TitanPanel_SetBarTexture(frame) - - if TitanBarData[frame].hider then - _G[TitanBarData[frame].hider]:Hide() - else - -- not allowed for this bar - end - else - -- The user has not elected to show this bar - TitanPanelBarButton_Hide(frame) - end - end -end - ---[[ Titan -NAME: TitanPanelBarButton_Hide -DESC: Hide the given Titan bar based on the user selection. -VAR: frame - expected to be a Titan bar name (string) -OUT: None -NOTE: -- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. -- Also moves the hider bar if auto hide is not selected. -:NOTE ---]] -function TitanPanelBarButton_Hide(frame) - if TITAN_PANEL_MOVING == 1 then return end - - local display = _G[frame] - local data = TitanBarData[frame] - - if display and data - then - local x, y, w = TitanVariables_GetBarPos(frame) - -- This moves rather than hides. If we just hide then the plugins will still show. - -- Hide by ensuriing the Y offset is off the screen. - display:ClearAllPoints() - local h = (math.abs(y) + TITAN_PANEL_BAR_HEIGHT * 2) * (-1 * y) - local h = data.hide_y ---[[ -print("_Hide" ---.." "..tostring(frame).."" -.." "..tostring(data.name).."" -.." "..tostring(TitanBarDataVars[frame].show).."" -.." "..tostring(h).."" -) ---]] - if TitanBarData[frame].user_move then - display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) - else - display:SetPoint(data.show.pt, data.show.rel_fr, data.show.rel_pt, x, h) - display:SetPoint(data.bott.pt, data.bott.rel_fr, data.bott.rel_pt, x, h - TITAN_PANEL_BAR_HEIGHT) - end - - if TitanBarData[frame].hider then - local hider = _G[data.hider] - if 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 - hider:Hide() - end - else - -- not allowed for this bar - end - end -end - ---[[ Titan -NAME: TitanPanel_InitPanelButtons -DESC: Show all user selected plugins on the Titan bar(s) then justify per the user selection. -VAR: None -OUT: None ---]] -function TitanPanel_InitPanelButtons() - local button - local r_prior = {} - local l_prior = {} - local scale = TitanPanelGetVar("Scale"); - local button_spacing = TitanPanelGetVar("ButtonSpacing") * scale - local icon_spacing = TitanPanelGetVar("IconSpacing") * scale - - local prior = {} - -- set prior to the starting offsets - -- The right side plugins are set here. - -- 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 - local bar = TitanBarData[idx].name - local y_off = TitanBarData[idx].plugin_y_offset - prior[bar] = { - right = { - button = TITAN_PANEL_DISPLAY_PREFIX..bar, - anchor = "RIGHT", - x = 5, -- Offset of first plugin to right side of screen - y = y_off, - }, - left = { - button = TITAN_PANEL_DISPLAY_PREFIX..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 - 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 = "TitanPanel"..id.."Button" - -- 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 = "TitanPanel"..id.."Button" - -- 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 - end - -- Set panel button init flag - TITAN_PANEL_BUTTONS_INIT_FLAG = 1; - TitanPanelButton_Justify(); -end - ---[[ Titan -NAME: TitanPanel_ReOrder -DESC: Reorder all the shown all user selected plugins on the Titan bar(s). Typically used after a button has been removed / hidden. -VAR: index - the index of the plugin removed so the list can be updated -OUT: None ---]] -function TitanPanel_ReOrder(index) - for i = index, table.getn(TitanPanelSettings.Buttons) do - TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i+1] - end -end - ---[[ Titan -NAME: TitanPanel_RemoveButton -DESC: Remove a plugin then show all the shown all user selected plugins on the Titan bar(s). -VAR: id - the plugin name (string) -OUT: None -NOTE: -- This cancels all timers of name "TitanPanel"..id as a safeguard to destroy any active plugin timers based on a fixed naming convention : TitanPanel..id, eg. "TitanPanelClock" this prevents "rogue" timers being left behind by lack of an OnHide check -:NOTE ---]] -function TitanPanel_RemoveButton(id) - if ( not TitanPanelSettings ) then - return; - end - - local i = TitanPanel_GetButtonNumber(id) - local currentButton = TitanUtils_GetButton(id); - - -- safeguard ... - 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 "?")) - if currentButton then - currentButton:Hide(); - end - -- Show the existing buttons - TitanPanel_InitPanelButtons(); -end - ---[[ Titan -NAME: TitanPanel_GetButtonNumber -DESC: Get the index of the given plugin from the Titan plugin displayed list. -VAR: id - the plugin name (string) -OUT: index of the plugin in the Titan plugin list or the end of the list. The routine returns +1 if not found so it is 'safe' to update / add to the Location ---]] -function TitanPanel_GetButtonNumber(id) - if (TitanPanelSettings) then - for i = 1, table.getn(TitanPanelSettings.Buttons) do - if(TitanPanelSettings.Buttons[i] == id) then - return i; - end - end - return table.getn(TitanPanelSettings.Buttons)+1; - else - return 0; - end -end - ---[[ Titan -NAME: TitanPanel_RefreshPanelButtons -DESC: Update / refresh each plugin from the Titan plugin list. Used when a Titan option is changed that effects all plugins. -VAR: None -OUT: None ---]] -function TitanPanel_RefreshPanelButtons() - if (TitanPanelSettings) then - for i = 1, table.getn(TitanPanelSettings.Buttons) do - TitanPanelButton_UpdateButton(TitanPanelSettings.Buttons[i], 1); - end - end -end - ---[[ Titan -NAME: TitanPanelButton_Justify -DESC: Justify the plugins on each Titan bar. Used when the user changes the 'center' option on a Titan bar. -VAR: None -OUT: None ---]] -function TitanPanelButton_Justify() - -- Only the left side buttons are justified. - if ( not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings ) then - return; - end - if InCombatLockdown() then ---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 y_offset - local firstLeftButton - local scale = TitanPanelGetVar("Scale"); - local button_spacing = TitanPanelGetVar("ButtonSpacing") * scale - local icon_spacing = TitanPanelGetVar("IconSpacing") * scale - local leftWidth = 0; - local rightWidth = 0; - local counter = 0; - local align = 0; - local center_offset = 0; - - -- Look at each bar for plugins. - 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)]) - 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 - -- 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 - leftWidth = 0; - rightWidth = 0; - counter = 0; - -- Calc the total width of the icons so we know where to start - for index, id in pairs(TitanPanelSettings.Buttons) do - local button = TitanUtils_GetButton(id); - if button and button:GetWidth() then - if TitanUtils_GetWhichBar(id) == bar then - if (TitanGetVar(id, "DisplayOnRightSide")) then - rightWidth = rightWidth - + icon_spacing - + button:GetWidth(); - else - counter = counter + 1; - leftWidth = leftWidth - + button_spacing - + button:GetWidth() - end - end - end - end - -- 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) - firstLeftButton:SetPoint("LEFT", idx, "CENTER", center_offset, y_offset); - end - end - end -end - --------------------------------------------------------------- --- --- Local routines for Titan menu creation - ---[[ local -NAME: TitanPanel_MainMenu -DESC: Show main Titan (right click) menu. -VAR: None -OUT: None ---]] -local function TitanPanel_MainMenu(frame) - local locale_bar = TitanBarData[frame].locale_name - local info = {}; - ----------------- - -- Menu title - 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 - info = {}; - info.notCheckable = true - info.text = L["TITAN_PANEL_MENU_CATEGORIES"][index]; - info.value = "Addons_" .. TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY[index]; - info.hasArrow = 1; - TitanPanelRightClickMenu_AddButton(info); - end - - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - - ----------------- - -- 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) - end - TitanPanelRightClickMenu_AddButton(info); - - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - - ----------------- - -- Profiles - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILES"]); - - ----------------- - -- Load/Delete - info = {}; - info.notCheckable = true - info.text = L["TITAN_PANEL_MENU_MANAGE_SETTINGS"]; - info.value = "Settings"; - info.hasArrow = 1; - -- lock this menu in combat - 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 - TitanPanelRightClickMenu_AddButton(info); - - ----------------- - -- Save - info = {}; - info.notCheckable = true - info.text = L["TITAN_PANEL_MENU_SAVE_SETTINGS"]; - info.value = "SettingsCustom"; - info.func = TitanPanel_SaveCustomProfile; - -- 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 - TitanPanelRightClickMenu_AddButton(info); - - local glob, toon, player, server = TitanUtils_GetGlobalProfile() - info = {}; - info.text = "Use Global Profile" - info.value = "Use Global Profile" - info.func = function() - TitanUtils_SetGlobalProfile(not glob, toon) - TitanVariables_UseSettings(nil, TITAN_PROFILE_USE) - end; - info.checked = glob --TitanAllGetVar("GlobalProfileUse") - info.keepShownOnClick = nil - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - - ----------------- - -- Hide this bar - info = {}; - info.text = (HIDE or "Hide") - info.value = "" - info.notCheckable = true - info.arg1 = frame; - info.func = function(self, frame_str) - TitanBarDataVars[frame_str].show = not TitanBarDataVars[frame_str].show - TitanPanelBarButton_DisplayBarsWanted(frame_str.." user clicked Hide") - end - info.keepShownOnClick = nil - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - -end - ---[[ local -NAME: TitanPanel_ServerSettingsMenu -DESC: Show list of servers / custom submenu off Profiles/Manage from the Titan (right click) menu. -VAR: None -OUT: None ---]] -local function TitanPanel_ServerSettingsMenu() - local info = {}; - local servers = {}; - local player = nil; - local server = nil; - local s, e, ident; - local setonce = 0; - - if ( TitanPanelRightClickMenu_GetDropdMenuValue() == "Settings" ) then - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_SERVERS"], - TitanPanelRightClickMenu_GetDropdownLevel()); - -- Normal profile per toon - for index, id in pairs(TitanSettings.Players) do - player, server = TitanUtils_ParseName(index) - - if TitanUtils_GetCurrentIndex(servers, server) == nil then - if server ~= TITAN_CUSTOM_PROFILE_POSTFIX then - table.insert(servers, server); - info = {}; - info.notCheckable = true - info.text = server; - info.value = server; - info.hasArrow = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - end - end - -- Custom profiles - for index, id in pairs(TitanSettings.Players) do - player, server = TitanUtils_ParseName(index) - - if TitanUtils_GetCurrentIndex(servers, server) == nil then - 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; - end - info = {}; - info.notCheckable = true - info.text = player; - info.value = player; - info.hasArrow = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - end - end - end -end - ---[[ Titan -NAME: TitanPanel_PlayerSettingsMenu -DESC: Show list of toons submenu off Profiles/Manage/ from the Titan (right click) menu. -VAR: None -OUT: None -NOTE: -- There are 2 level 3 menus possible - 1) Under profiles, then value could be the server of a saved toon - 2) Under plugins value could be the options of a plugin -:NOTE ---]] -local function TitanPanel_PlayerSettingsMenu() - -- - local info = {}; - local player = nil; - local server = nil; - local s, e, ident; - local plugin, profname; - local setonce = 0; - local off = nil - - -- - -- Handle the profiles - -- - for index, id in pairs(TitanSettings.Players) do - player, server = TitanUtils_ParseName(index) - off = (index == TitanSettings.Player) - or ((index == TitanAllGetVar("GlobalProfileUse")) and (TitanAllGetVar("GlobalProfileUse"))) - - -- handle custom profiles here - if server == TITAN_CUSTOM_PROFILE_POSTFIX - and player == TitanPanelRightClickMenu_GetDropdMenuValue() then - info = {}; - info.notCheckable = true - info.disabled = TitanAllGetVar("GlobalProfileUse") - info.text = L["TITAN_PANEL_MENU_LOAD_SETTINGS"]; - info.value = index; - info.func = function() - TitanVariables_UseSettings(index, TITAN_PROFILE_USE) - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.notCheckable = true - info.disabled = off - info.text = L["TITAN_PANEL_MENU_DELETE_SETTINGS"]; - info.value = index; - info.func = function() - if TitanSettings.Players[info.value] then - TitanSettings.Players[info.value] = nil; - profname = TitanUtils_ParseName(index) - TitanPrint( - L["TITAN_PANEL_MENU_PROFILE"] - .." '"..profname.."' " - ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] - , "info") - TitanPanelRightClickMenu_Close(); - end - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end -- if server and player - - -- handle regular profiles here - if server == TitanPanelRightClickMenu_GetDropdMenuValue() then - -- Set the label once - if setonce and setonce == 0 then - TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_MENU_PROFILE_CHARS"], TitanPanelRightClickMenu_GetDropdownLevel()); - setonce = 1; - end - info = {}; - info.notCheckable = true - info.text = player; - info.value = index; - info.hasArrow = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - end -- for players - - -- Handle the plugins - - for index, id in pairs(TitanPluginsIndex) do - plugin = TitanUtils_GetPlugin(id); - if plugin.id and plugin.id == TitanPanelRightClickMenu_GetDropdMenuValue() then - --title - info = {}; - info.text = TitanPlugins[plugin.id].menuText; - info.notCheckable = true - info.notClickable = 1; - info.isTitle = 1; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - --ShowIcon - if plugin.controlVariables.ShowIcon then - info = {}; - info.text = L["TITAN_PANEL_MENU_SHOW_ICON"]; - info.value = {plugin.id, "ShowIcon", nil}; - info.func = function() - TitanPanelRightClickMenu_ToggleVar({info.value[1], "ShowIcon", nil}) - end - info.keepShownOnClick = 1; - info.checked = TitanGetVar(info.value[1], "ShowIcon"); - info.disabled = nil; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - - --ShowLabel - if plugin.controlVariables.ShowLabelText then - info = {}; - info.text = L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"]; - info.value = {plugin.id, "ShowLabelText", nil}; - info.func = function() - TitanPanelRightClickMenu_ToggleVar({info.value[1], "ShowLabelText", nil}) - end - info.keepShownOnClick = 1; - info.checked = TitanGetVar(info.value[1], "ShowLabelText"); - info.disabled = nil; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - - --ShowRegularText (LDB data sources only atm) - if plugin.controlVariables.ShowRegularText then - info = {}; - info.text = L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] - info.value = {plugin.id, "ShowRegularText", nil}; - info.func = function() - TitanPanelRightClickMenu_ToggleVar({info.value[1], "ShowRegularText", nil}) - end - info.keepShownOnClick = 1; - info.checked = TitanGetVar(info.value[1], "ShowRegularText"); - info.disabled = nil; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - - --ShowColoredText - if plugin.controlVariables.ShowColoredText then - info = {}; - info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"]; - info.value = {plugin.id, "ShowColoredText", nil}; - info.func = function() - TitanPanelRightClickMenu_ToggleVar({info.value[1], "ShowColoredText", nil}) - end - info.keepShownOnClick = 1; - info.checked = TitanGetVar(info.value[1], "ShowColoredText"); - info.disabled = nil; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - - -- Right-side plugin - if plugin.controlVariables.DisplayOnRightSide then - info = {}; - info.text = L["TITAN_PANEL_MENU_LDB_SIDE"]; - info.value = {plugin.id, "DisplayOnRightSide", nil}; - info.func = function () - TitanToggleVar(info.value[1], "DisplayOnRightSide") - local bar = TitanUtils_GetWhichBar(id) - TitanPanel_RemoveButton(id); - TitanUtils_AddButtonOnBar(bar, id); - end - info.checked = TitanGetVar(info.value[1], "DisplayOnRightSide"); - info.disabled = nil; - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - end - end - end -end - ---[[ Titan -NAME: TitanPanel_SettingsSelectionMenu -DESC: Show save / load submenu off Profiles/Manage// from the Titan (right click) menu. -VAR: None -OUT: None ---]] -local function TitanPanel_SettingsSelectionMenu() - local info = {}; - - info = {}; - info.notCheckable = true - info.disabled = TitanAllGetVar("GlobalProfileUse") - info.text = L["TITAN_PANEL_MENU_LOAD_SETTINGS"]; - info.value = TitanPanelRightClickMenu_GetDropdMenuValue(); - info.func = function() - TitanVariables_UseSettings(TitanPanelRightClickMenu_GetDropdMenuValue(), TITAN_PROFILE_USE) - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - - info = {}; - info.notCheckable = true - info.disabled = (TitanPanelRightClickMenu_GetDropdMenuValue() == TitanSettings.Player) - or ((TitanPanelRightClickMenu_GetDropdMenuValue() == TitanAllGetVar("GlobalProfileName")) - and (TitanAllGetVar("GlobalProfileUse"))) - info.text = L["TITAN_PANEL_MENU_DELETE_SETTINGS"]; - info.value = TitanPanelRightClickMenu_GetDropdMenuValue(); - info.func = function() - -- do not delete if current profile - .disabled - if TitanSettings.Players[info.value] then - TitanSettings.Players[info.value] = nil; - TitanPrint( - L["TITAN_PANEL_MENU_PROFILE"] - .." '"..info.value.."' " - ..L["TITAN_PANEL_MENU_PROFILE_DELETED"] - , "info") - TitanPanelRightClickMenu_Close(); - end - end - TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); -end - ---[[ Titan -NAME: TitanPanel_BuildOtherPluginsMenu -DESC: Show the submenu with list of plugin off the category from the Titan (right click) menu. -VAR: None -OUT: None ---]] -local function TitanPanel_BuildOtherPluginsMenu(frame) - local info = {}; - 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() == "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 - if plugin.controlVariables then - info.hasArrow = 1; - end - info.value = 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 - end - end -end - ---[[ Titan -NAME: TitanPanelRightClickMenu_PrepareBarMenu -DESC: This is the controller to show the proper level of the Titan (right click) menu. -VAR: self - expected to be the Tian bar that was right clicked -OUT: None ---]] -function TitanPanelRightClickMenu_PrepareBarMenu(self) - -- Determine which bar was clicked on - -- This MUST match the convention used in TitanPanel.xml to declare - -- the dropdown menu. ($parentRightClickMenu) - local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); - local lev = (TitanPanelRightClickMenu_GetDropdownLevel() or 1) ---[[ -print("_prep R click" -.." "..tostring(frame).."" -.." "..tostring(lev).."" -) ---]] - - -- Level 1 - if lev == 1 then - TitanPanel_MainMenu(frame) - end - - -- Level 2 - if ( lev == 2 ) then - TitanPanel_BuildOtherPluginsMenu(frame); - TitanPanel_ServerSettingsMenu(); - return; - end - - -- Level 3 - if ( lev == 3 ) then - TitanPanel_PlayerSettingsMenu(); - return; - end - - -- Level 4 - if ( lev == 4 ) then - TitanPanel_SettingsSelectionMenu(); - return; - end - -end - ---[[ Titan -NAME: TitanPanel_IsPluginShown -DESC: Determine if the given plugin is shown on a Titan bar. The Titan bar could be not shown or on auto hide and the plugin will still be 'shown'. -VAR: id - plugin name (string) -OUT: int - index of the plugin or nil ---]] -function TitanPanel_IsPluginShown(id) - if ( id and TitanPanelSettings ) then - return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id); - end -end - ---[[ Titan -NAME: TitanPanel_GetPluginSide -DESC: Determine if the given plugin is or would be on right or left of a Titan bar. This returns right or left regardless of whether the plugin is 'shown'. -VAR: id - plugin name (string) -OUT: string - "Right" or "Left" ---]] -function TitanPanel_GetPluginSide(id) - if ( TitanGetVar(id, "DisplayOnRightSide") ) then - return TITAN_RIGHT; - else - return TITAN_LEFT; - end -end diff --git a/Titan/TitanPanelTemplate.lua b/Titan/TitanPanelTemplate.lua deleted file mode 100644 index e4765a3..0000000 --- a/Titan/TitanPanelTemplate.lua +++ /dev/null @@ -1,1550 +0,0 @@ ---[[ File -NAME: TitanPanelTemplate.lua -DESC: Contains the routines to handle a frame created as a Titan plugin. ---]] ---[[ API -NAME: TitanPanelTemplate overview -DESC: See TitanPanelButtonTemplate.xml also. - -A Titan plugin is a frame created using one of the button types in TitanPanelButtonTemplate.xml which inherits TitanPanelButtonTemplate. -The available plugin types are: -TitanPanelTextTemplate - A frame that only displays text ("$parentText") -TitanPanelIconTemplate - A frame that only displays an icon ("$parentIcon") -TitanPanelComboTemplate - A frame that displays an icon then text ("$parentIcon" "$parentText") - -Most plugins use the combo template. - -TitanPanelButtonTemplate.xml contains other templates available to be used. -TitanOptionsSliderTemplate - A frame that contains the basics of a slider control. See TitanVolume for an example. -TitanPanelChildButtonTemplate - A frame that allows a plugin within a plugin. The older version of TitanGold was an example. This may not be used anymore. - -Each template contains: -- a frame to handle a menu invoked by a right mouse click ("$parentRightClickMenu") -- default event handlers for - - TitanPanelButton_OnLoad(self); - - - TitanPanelButton_OnShow(self); - - - TitanPanelButton_OnClick(self, button); - - - TitanPanelButton_OnEnter(self); - - - TitanPanelButton_OnLeave(self); - -If these events are overridden then the default routine needs to be included! -:DESC ---]] - --- Globals - --- Constants -local TITAN_PANEL_LABEL_SEPARATOR = " " -local TITAN_PANEL_BUTTON_WIDTH_CHANGE_TOLERANCE = 10; -local TITAN_PANEL_BUTTON_TYPE_TEXT = 1; -local TITAN_PANEL_BUTTON_TYPE_ICON = 2; -local TITAN_PANEL_BUTTON_TYPE_COMBO = 3; -local TITAN_PANEL_BUTTON_TYPE_CUSTOM = 4; -local pluginOnEnter = nil; -local TITAN_PANEL_MOVE_ADDON = nil; -local TITAN_PANEL_DROPOFF_ADDON = nil; - --- Library instances -local LibQTip = nil -local _G = getfenv(0); -local InCombatLockdown = _G.InCombatLockdown; -local media = LibStub("LibSharedMedia-3.0") - --- ---========================== --- Routines to handle moving and sizing of short bars --- - -local function CheckBarBounds(self, width) - local result = {} - local err = "" - local res = "" - - local f_name = self:GetName() - local bar_name = TitanBarData[f_name].name - local locale_name = TitanBarData[f_name].locale_name - - if TitanBarData[f_name].user_move - and TitanBarDataVars[f_name].show - then - local tscale = TitanPanelGetVar("Scale") ---[===[ -print("CheckBounds" -.." '"..tostring(bar_name).."'" -.." "..(width == 0 and "drag" or "width").."" -.." T "..tostring(format("%0.1f", tscale)).."" -.." UI "..tostring(format("%0.1f", UIParent:GetEffectiveScale())).."" -) ---]===] - -- Assumes BOTTOMLEFT of screen per Short bar defaults. - -- Top and right adjust an addition pixel, - -- if resolution is not 'pixel perfect' rounding could cause algorithm to think bar is off screen - local orig_w = self:GetWidth() - local l_off = self:GetLeft() - local r_off = self:GetRight() - local t_off = self:GetTop() - local b_off = self:GetBottom() - local screen_right, screen_top = TitanUtils_ScreenSize() - - local w = 0 - local x_off = 0 - local y_off = 0 - local w_off = 0 -local show_errs = true - if (width == 0) then -- drag and drop - -- Keep the width - w_off = orig_w ---[===[ -print(">>CheckBounds" -.." '"..tostring(bar_name).."'" -.." 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)).."" -.." et "..tostring(format("%0.1f", (t_off * tscale))).."" -) ---]===] - -- Assume all ok :) - x_off = l_off - y_off = b_off - res = "Ok" - if l_off < 0 then - x_off = 0 - err = "Off left side of screen, leaving on the edge." - res = "Off L" - elseif r_off > screen_right then - x_off = (screen_right - orig_w) - 1 - err = "Off right side of screen, leaving on the edge." - res = "Off R" - end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - , "warning") - end - if (t_off * tscale) > screen_top then - y_off = b_off - ((t_off * tscale) - screen_top) - 1 - err = "Off top of screen, leaving on the edge." - res = "Off T" - elseif b_off < 0 then - y_off = 0 - err = "Off bottom of screen, leaving on the edge." - res = "Off B" - end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - , "warning") - end - else -- width change - local min_w, min_h, max_w, max_h = self:GetResizeBounds() - -- Keep the X and Y - x_off = l_off - y_off = b_off - - w = orig_w + width - if w < min_w then - -- do nothing - too small - w_off = min_w - err = "Width too small. Set to min width." - res = "Too small" - elseif w > max_w then - w_off = max_w - err = "Width too big. Set to max width." -- too wide - res = "Too big" - elseif x_off + w > screen_right then - w_off = orig_w - err = "Off right side of screen, leaving on the edge." - res = "Off R" - else - w_off = w - res = "Ok" - end - self:SetSize(w_off, TITAN_PANEL_BAR_HEIGHT) - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", orig_w)).."]" - .." ["..tostring(format("%0.1f", w_off)).."]" - , "warning") - end - end - ---[===[ ---[[ -print(">>CheckBounds" -.." '"..tostring(bar_name).."'" -.." '"..tostring(res).."'" -.."\n" -.." x "..tostring(format("%0.1f", l_off)).."" -.." => "..tostring(format("%0.1f", x_off)).."" -.."\n" -.." y "..tostring(format("%0.1f", b_off)).."" -.." => "..tostring(format("%0.1f", y_off)).."" -.."\n" -.." w "..tostring(format("%0.1f", orig_w)).."" -.." + "..tostring(format("%0.1f", width)).."" -.." = "..tostring(format("%0.1f", w_off)).."" -.."\n" -.." s "..tostring(format("%0.1f", screen_right)).."w" -.." x "..tostring(format("%0.1f", screen_top)).."h" -) ---]] ---]===] - - TitanVariables_SetBarPos(self, false, x_off, y_off, w_off) - else - -- Controlled with anchor points; cannot move so no check is needed - end - - if err == "" then - -- all is good - result.ok = true - else - result.ok = false - end - ---[[ -print("CheckBounds" -.." '"..tostring(locale_name).."'" -.." w "..tostring(format("%0.1f", orig_w)).."" -.." + "..tostring(format("%0.1f", w)).."" -.." = "..tostring(format("%0.1f", self:GetWidth())).."" -) -print(">>" -.." x "..tostring(format("%0.1f", x_off)).."" -.." => "..tostring(format("%0.1f", result.x)).."" -) -print(">>" -.." y "..tostring(format("%0.1f", y_off)).."" -.." => "..tostring(format("%0.1f", result.y)).."" -) -print(">>" -.." w "..tostring(format("%0.1f", self:GetWidth())).."" -.." s "..tostring(format("%0.1f", screen_edge)).."" -) ---]] - return result -end - -local function OnMoveStart(self) - if IsShiftKeyDown() then - if self:IsMovable() then - self.isMoving = true ---[[ -print("OnMoveStart" -.." "..tostring(self:GetName()).."" -.." "..tostring(IsShiftKeyDown()).."" -.." "..tostring(IsAltKeyDown()).."" -.."\n" -.." x "..tostring(format("%0.1f", self:GetLeft())).."" -.." y "..tostring(format("%0.1f", self:GetTop())).."" -) ---]] - self:StartMoving() - _G.GameTooltip:Hide() - end - else - -- Do not move - end -end - -local function OnMovingStop(self) - - self:StopMovingOrSizing() - self.isMoving = nil - - local res = CheckBarBounds(self, 0) ---[[ -print("OnMovingStop" -.." "..tostring(self:GetName()).."" -.." x: "..tostring(res.x).."" -.." y: "..tostring(res.y).."" -.." ok: "..tostring(res.ok).."" -) ---]] - if res.ok then - else - end - -- Seems overkill - this will recalc all bars... - TitanPanel_InitPanelBarButton("OnMovingStop") -end - -local function OnMouseWheel(self, d) - if IsShiftKeyDown() then - local old_w = self:GetWidth() - local res = CheckBarBounds(self, d) - if res.ok then - end ---[[ -print("wheel" -.." "..tostring(f_name).."" -.." old: "..tostring(old_w).."" -.." new: "..tostring(self:GetWidth()).."" -.." ok: "..tostring(res.ok).."" -) ---]] - -- Seems overkill - this will recalc all bars but recalc of textures could be needed... - TitanPanel_InitPanelBarButton("OnMouseWheel") - end -end - ---========================== - ---[[ local -NAME: TitanPanel_SetScale -DESC: Set the scale of each plugin and each Titan bar. -VAR: None -OUT: None ---]] -function TitanPanel_SetScale() - local scale = TitanPanelGetVar("Scale"); - - -- Set all the Titan bars - for idx,v in pairs (TitanBarData) do - local bar_name = TITAN_PANEL_DISPLAY_PREFIX..TitanBarData[idx].name - _G[bar_name]:SetScale(scale) - end - -- Set all the registered plugins - for index, value in pairs(TitanPlugins) do - if index then - TitanUtils_GetButton(index):SetScale(scale); - end - end -end - ---[[ local -NAME: TitanTooltip_AddTooltipText -DESC: Helper to add a line of tooltip text to the tooltip. -VAR: text - string -OUT: None -NOTE: -- Append a "\n" to the end if there is not one already there -:NOTE ---]] -local function TitanTooltip_AddTooltipText(text) - if ( text ) then - -- Append a "\n" to the end - 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 - -- Add as double wide - GameTooltip:AddDoubleLine(text1, text2); - elseif ( text1 ~= "" ) then - -- Add single column line - GameTooltip:AddLine(text1); - else - -- Assume a blank line - GameTooltip:AddLine("\n"); - end - end - end -end - ---[[ local -NAME: TitanTooltip_SetOwnerPosition -DESC: Set both the parent and the position of GameTooltip for the plugin tooltip. -VAR: parent - reference to the frame to attach the tooltip to -VAR: anchorPoint - tooltip anchor location (side or corner) to use -VAR: relativeToFrame - string name name of the frame, usually the plugin), to attach the tooltip to -VAR: relativePoint - parent anchor location (side or corner) to use -VAR: xOffset - X offset from the anchor point -VAR: yOffset - Y offset from the anchor point -VAR: frame - reference to the tooltip -OUT: None ---]] -local function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) - if not frame then - frame = _G["GameTooltip"] - end - -- Changes for 9.1.5 Removed the background template from the GameTooltip - -- Making changes to it difficult and possibly changing the tooltip globally. - - frame:SetOwner(parent, "ANCHOR_NONE"); - frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, - xOffset, yOffset); - - -- set font size for the Game Tooltip - if not TitanPanelGetVar("DisableTooltipFont") then - if TitanTooltipScaleSet < 1 then - TitanTooltipOrigScale = frame:GetScale(); - TitanTooltipScaleSet = TitanTooltipScaleSet + 1; - end - frame:SetScale(TitanPanelGetVar("TooltipFont")); - end -end - ---[[ local -NAME: TitanTooltip_SetGameTooltip -DESC: Helper to set the tooltip of the given Titan plugin. -First check for a custom function. If no function then use the plugin tooltip title and text. -VAR: self - frame reference of the plugin -OUT: None -NOTE: -- If a custom function is given pcall (protected call) is used in case the function errors out. Currently the error is allowed to occur silently because it could generate a lot of text to chat. -:NOTE ---]] -local function TitanTooltip_SetGameTooltip(self) - 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 - GameTooltip:SetText(self.tooltipTitle, - HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); - if ( self.tooltipText ) then - TitanTooltip_AddTooltipText(self.tooltipText); - end - end - - GameTooltip:Show(); -end - ---[[ local -NAME: TitanTooltip_SetPanelTooltip -DESC: Helper to set the screen position of the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: id - string name of the plugin -VAR: frame - reference to the tooltip -OUT: None ---]] -local function TitanTooltip_SetPanelTooltip(self, id, frame) - -- sanity checks - if not TitanPanelGetVar("ToolTipsShown") - 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); - local offscreenX, offscreenY; - local bar = TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(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 - ---[[ -print("_tooltip" -.." "..tostring(self:GetName()).."" -.." "..tostring(pt).."" -.." "..tostring(rel_pt).."" -.." "..tostring(format("%0.1f", GameTooltip:GetWidth())).."" -.." "..tostring(format("%0.1f", GameTooltip:GetHeight())).."" -) ---]] - TitanTooltip_SetOwnerPosition(button, pt, button:GetName(), rel_pt, 0, 0, frame) - TitanTooltip_SetGameTooltip(self); -end - ---[[ local -NAME: TitanPanelButton_SetTooltip -DESC: Set the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: id - string name of the plugin ---]] -local function TitanPanelButton_SetTooltip(self, id) - -- ensure that the 'self' passed is a valid frame reference - if not self:GetName() then return end - - local call_success = nil - local tmp_txt = "" - local use_mod = TitanAllGetVar("UseTooltipModifer") - local use_alt = TitanAllGetVar("TooltipModiferAlt") - 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()) - then - ok = true - end - else - ok = true - end - - 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]; - 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 -end - ---[[ local -NAME: TitanPanelButton_IsText -DESC: Is the given Titan plugin of type text? -VAR: id - string name of the plugin -OUT: boolean ---]] -local function TitanPanelButton_IsText(id) - if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_TEXT) then - return 1; - end -end - ---[[ local -NAME: TitanPanelButton_IsCombo -DESC: Is the given Titan plugin of type combo? -VAR: id - string name of the plugin -OUT: boolean ---]] -local function TitanPanelButton_IsCombo(id) - if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_COMBO) then - return 1; - end -end - ---[[ Titan -NAME: TitanPanelButton_IsIcon -DESC: Is the given Titan plugin of type icon? -VAR: id - string name of the plugin -OUT: boolean ---]] -function TitanPanelButton_IsIcon(id) - if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_ICON) then - return 1; - end -end - ---[[ local -NAME: TitanPanelButton_IsCustom -DESC: Is the given Titan plugin of type custom? -VAR: id - string name of the plugin -OUT: boolean ---]] -local function TitanPanelButton_IsCustom(id) - if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_CUSTOM) then - return 1; - end -end - ---[[ local -NAME: TitanPanelButton_OnDragStart -DESC: Handle the OnDragStart event of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: ChildButton - boolean -OUT: None -NOTE: -- Do nothing if the user has locked plugins or if in combat. -- Set the .isMoving of the plugin (frame) so other routine can check it. -- Set TITAN_PANEL_MOVING so any Titan routine will know a 'drag & drop' is in progress. -- Set TITAN_PANEL_MOVE_ADDON so sanity checks can be done on the 'drop'. -:NOTE ---]] -local function TitanPanelButton_OnDragStart(self, ChildButton) - if TitanPanelGetVar("LockButtons") or InCombatLockdown() then return end - - local frname = self; - if ChildButton then - frname = self:GetParent(); - end - - -- Clear button positions or we'll grab the button and all buttons 'after' - local i,j; - for i, j in pairs(TitanPanelSettings.Buttons) do - local pluginid = _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; - if pluginid then - pluginid:ClearAllPoints() - end - end - - -- Start the drag; close any tooltips and open control frames - frname:StartMoving(); - frname.isMoving = true; - TitanUtils_CloseAllControlFrames(); - TitanPanelRightClickMenu_Close(); - if AceLibrary then - if AceLibrary:HasInstance("Dewdrop-2.0") then - AceLibrary("Dewdrop-2.0"):Close() - end - if AceLibrary:HasInstance("Tablet-2.0") then - AceLibrary("Tablet-2.0"):Close() - end - end - GameTooltip:Hide(); - -- LibQTip-1.0 support code - LibQTip = LibStub("LibQTip-1.0", true) - if LibQTip then - local key, tip - 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 - end - end - end - -- /LibQTip-1.0 support code - - -- Hold the plugin id so we can do checks on the drop - TITAN_PANEL_MOVE_ADDON = TitanUtils_GetButtonID(self:GetName()); - if ChildButton then - TITAN_PANEL_MOVE_ADDON = - TitanUtils_GetButtonID(self:GetParent():GetName()); - end - -- Tell Titan that a drag & drop is in process - TITAN_PANEL_MOVING = 1; - -- Store the OnEnter handler so the tooltip does not show - or other oddities - pluginOnEnter = self:GetScript("OnEnter") - self:SetScript("OnEnter", nil) -end - ---[[ local -NAME: TitanPanelButton_OnDragStop -DESC: Handle the OnDragStop event of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: ChildButton - boolean -OUT: None -NOTE: -- Clear the .isMoving of the plugin (frame). -- Clear TITAN_PANEL_MOVING. -- Clear TITAN_PANEL_MOVE_ADDON. -:NOTE ---]] -local function TitanPanelButton_OnDragStop(self, ChildButton) - if TitanPanelGetVar("LockButtons") then - return - end - local ok_to_move = true - local nonmovableFrom = false; - local nonmovableTo = false; - local frname = self; - if ChildButton then - frname = self:GetParent(); - end - if TITAN_PANEL_MOVING == 1 then - frname:StopMovingOrSizing(); - frname.isMoving = false; - TITAN_PANEL_MOVING = 0; - - -- See if the plugin is supposed to stay on the bar it is on - if TitanGetVar(TITAN_PANEL_MOVE_ADDON, "ForceBar") then - ok_to_move = false - end - - -- eventually there could be several reasons to not allow - -- the plugin to move - if ok_to_move then - local i,j; - for i, j in pairs(TitanPanelSettings.Buttons) do - local pluginid = - _G["TitanPanel"..TitanPanelSettings.Buttons[i].."Button"]; - if (pluginid and MouseIsOver(pluginid)) and frname ~= pluginid then - TITAN_PANEL_DROPOFF_ADDON = TitanPanelSettings.Buttons[i]; - end - end - - -- switching sides is not allowed - nonmovableFrom = TitanUtils_ToRight(TITAN_PANEL_MOVE_ADDON) - nonmovableTo = TitanUtils_ToRight(TITAN_PANEL_DROPOFF_ADDON) - if nonmovableTo ~= nonmovableFrom then - TITAN_PANEL_DROPOFF_ADDON = nil; - end - - if TITAN_PANEL_DROPOFF_ADDON == nil then - -- See if the plugin was dropped on a bar rather than - -- another plugin. - local bar - local tbar = nil - -- Find which bar it was dropped on - for idx,v in pairs(TitanBarData) do - bar = idx - if (bar and MouseIsOver(_G[bar])) then - tbar = bar - end - end - - if tbar then - TitanPanel_RemoveButton(TITAN_PANEL_MOVE_ADDON) - TitanUtils_AddButtonOnBar(TitanBarData[tbar].name, TITAN_PANEL_MOVE_ADDON) - else - -- not sure what the user did... - end - else - -- plugin was dropped on another plugin - swap (for now) - local dropoff = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons - ,TITAN_PANEL_DROPOFF_ADDON); - local pickup = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons - ,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 - TitanPanelSettings.Buttons[dropoff] = TITAN_PANEL_MOVE_ADDON; - TitanPanelSettings.Location[dropoff] = dropoffbar; - TitanPanelSettings.Buttons[pickup] = TITAN_PANEL_DROPOFF_ADDON; - TitanPanelSettings.Location[pickup] = pickupbar; - end - end - end - - -- This is important! The start drag cleared the button positions so - -- the buttons need to be put back properly. - TitanPanel_InitPanelButtons(); - TITAN_PANEL_MOVE_ADDON = nil; - TITAN_PANEL_DROPOFF_ADDON = nil; - -- Restore the OnEnter script handler - if pluginOnEnter then self:SetScript("OnEnter", pluginOnEnter) end - pluginOnEnter = nil; - end -end - ---[[ API -NAME: TitanOptionSlider_TooltipText -DESC: Set the color of the tooltip text to normal (white) with the value in green. -VAR: text - the label for value -VAR: value - the value -OUT: string - encoded color string of text and value ---]] -function TitanOptionSlider_TooltipText(text, value) - return (text or "?") .. " " .. GREEN_FONT_COLOR_CODE .. value .. FONT_COLOR_CODE_CLOSE; -end - ---[[ API -NAME: TitanPanelButton_OnLoad -DESC: Handle the OnLoad event of the requested Titan plugin. Ensure the plugin is set to be registered. -VAR: isChildButton - boolean -NOTE: -- This is called from the Titan plugin frame in the OnLoad event - usually as the frame is created. -- This starts the plugin registration process. See TitanUtils for more details on plugin registration. -- The plugin registration is a two step process because not all addons create Titan plugins in the frame create. The Titan feature of converting LDB addons to Titan plugins is an example. -:NOTE ---]] -function TitanPanelButton_OnLoad(self, isChildButton) -- Used by plugins - TitanUtils_PluginToRegister(self, isChildButton) -end - ---[[ API -NAME: TitanPanelPluginHandle_OnUpdate -DESC: A method to refresh the display of a Titan plugin. -VAR: table - the frame of the plugin -VAR: oldarg - nil or command -NOTE: -- This is used by some plugins. It is not used within Titan. -- The expected usage is either: -1) Table contains {, } -2) table = and oldarg = -- oldarg - nil or command -1 = refresh button -2 = refresh tooltip -3 = refresh button and tooltip -:NOTE ---]] -function TitanPanelPluginHandle_OnUpdate(table, oldarg) -- Used by plugins - local id, updateType = nil, nil - -- set the id and updateType - -- old method - if table and type(table) == "string" and oldarg then - id = table - updateType = oldarg - end - -- new method - if table and type(table) == "table" then - if table[1] then id = table[1] end - if table[2] then updateType = table[2] end - end - - -- id is required - if id then - if updateType == TITAN_PANEL_UPDATE_BUTTON - 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["TitanPanel"..id.."Button"]) then - if TitanPanelRightClickMenu_IsVisible() or TITAN_PANEL_MOVING == 1 then - return - end - - TitanPanelButton_SetTooltip(_G["TitanPanel"..id.."Button"], id) - end - end -end - ---[[ API -NAME: TitanPanelDetectPluginMethod -DESC: Poorly named routine that sets the OnDragStart & OnDragStop scripts of a Titan plugin. -VAR: id - the string name of the plugin -VAR: isChildButton - boolean ---]] -function TitanPanelDetectPluginMethod(id, isChildButton) - -- Ensure the id is not nil - if not id then return end - local TitanPluginframe = _G["TitanPanel"..id.."Button"]; - if isChildButton then - TitanPluginframe = _G[id]; - end - -- Ensure the frame is valid - if not TitanPluginframe and TitanPluginframe:GetName() then return end -- sanity check... - - -- Set the OnDragStart script - TitanPluginframe:SetScript("OnDragStart", function(self) - if not IsShiftKeyDown() - and not IsControlKeyDown() - and not IsAltKeyDown() then - if isChildButton then - TitanPanelButton_OnDragStart(self, true); - else - TitanPanelButton_OnDragStart(self); - end - end - end) - - -- Set the OnDragStop script - TitanPluginframe:SetScript("OnDragStop", function(self) - if isChildButton then - TitanPanelButton_OnDragStop(self, true) - else - TitanPanelButton_OnDragStop(self); - end - end) ---[[ - -- Set the key down script - for modifiers - TitanPluginframe:SetScript("OnKeyDown", function(self) - if IsModifierKeyDown() then - TitanPanelButton_SetTooltip(self, id) - end - end) - - -- Set the key up script - for modifiers - TitanPluginframe:SetScript("OnKeyUp", function(self) - if IsModifierKeyDown() then - -- ? do nothing - else - GameTooltip:Hide() - end - end) ---]] -end - ---[[ API -NAME: TitanPanelButton_OnShow -DESC: Handle the OnShow event of the requested Titan plugin. -VAR:self - frame reference of the plugin ---]] -function TitanPanelButton_OnShow(self) -- Used by plugins - local id = nil; - -- ensure that the 'self' passed is a valid frame reference - if self and self:GetName() then - id = TitanUtils_GetButtonID(self:GetName()); - end - -- ensure that id is a valid Titan plugin - if (id) then - TitanPanelButton_UpdateButton(id, 1); - end -end - ---[[ API -NAME: TitanPanelButton_OnClick -DESC: Handle the OnClick mouse event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: button - mouse button that was clicked -VAR: isChildButton - boolean ! NO LONGER USED ! -NOTE: -- Only the left and right mouse buttons are handled by Titan. -:NOTE ---]] -function TitanPanelButton_OnClick(self, button, isChildButton) -- Used by plugins - local id - -- ensure that the 'self' passed is a valid frame reference - if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, - TitanUtils_GetParentButtonID(self:GetName()), - TitanUtils_GetButtonID(self:GetName())); - end - ---[[ -if self.TitanType == "macro" then -print("TPB OnClick" -.." "..tostring(self:GetName()).." " -.." "..tostring(button).." " -.." "..tostring(issecure()).." " -.." "..tostring(self:GetAttribute("type")).." " -.." "..tostring(self:GetAttribute("macrotext")).." " -) -end ---]] - if id then - local controlFrame = TitanUtils_GetControlFrame(id); - - if (button == "LeftButton") then - local isControlFrameShown; - if (not controlFrame) then - isControlFrameShown = false; - elseif (controlFrame:IsVisible()) then - isControlFrameShown = false; - else - isControlFrameShown = true; - end - - TitanUtils_CloseAllControlFrames(); - TitanPanelRightClickMenu_Close(); - - 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 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) - frame properly. - NOTE: If Titan bars need a left click to show a control frame the offset - will need to be changed to use the cursor position like right click menu!! - --]] - if (self:GetTop() - controlFrame:GetHeight()) > 0 then - point = "TOP" - rel_point = "BOTTOM" - else -- below screen - point = "BOTTOM" - rel_point = "TOP" - end - - local x = 0 - local y = 0 - - controlFrame:ClearAllPoints(); - 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 - -- Off to left of screen which should not happen... - 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) - end - - controlFrame:Show(); - end - elseif (button == "RightButton") then - TitanUtils_CloseAllControlFrames(); - -- Show RightClickMenu anyway - TitanPanelRightClickMenu_Close(); - TitanPanelRightClickMenu_Toggle(self); - end - - GameTooltip:Hide(); - end -end - ---[[ API -NAME: TitanPanelButton_OnEnter -DESC: Handle the OnEnter cursor event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: isChildButton - boolean -NOTE: -- The cursor has moved over the plugin so show the plugin tooltip. -- Save same hassle by doing nothing if the tooltip is already shown or if the cursor is moving. -- If the "is moving" is set the user is dragging this plugin around so do nothing here. -:NOTE ---]] -function TitanPanelButton_OnEnter(self, isChildButton) -- Used by plugins - local id = nil; - -- ensure that the 'self' passed is a valid frame reference - if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, - TitanUtils_GetParentButtonID(self:GetName()), - TitanUtils_GetButtonID(self:GetName())); - end - - if (id) then - local controlFrame = TitanUtils_GetControlFrame(id); - if (controlFrame and controlFrame:IsVisible()) then - return; - elseif (TitanPanelRightClickMenu_IsVisible()) then - return; - else - if TITAN_PANEL_MOVING == 0 then - TitanPanelButton_SetTooltip(self, id); - end - if self.isMoving then - GameTooltip:Hide(); - end - end - end -end - ---[[ API -NAME: TitanPanelButton_OnLeave -DESC: Handle the OnLeave cursor event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: isChildButton - boolean -NOTE: -- The cursor has moved off the plugin so hide the plugin tooltip. -:NOTE ---]] -function TitanPanelButton_OnLeave(self, isChildButton) - local id = nil; - -- ensure that the 'self' passed is a valid frame reference - if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, - TitanUtils_GetParentButtonID(self:GetName()), - TitanUtils_GetButtonID(self:GetName())); - end - - if (id) then - GameTooltip:Hide(); - end - - if not TitanPanelGetVar("DisableTooltipFont") then - -- reset original Tooltip Scale - GameTooltip:SetScale(TitanTooltipOrigScale); - TitanTooltipScaleSet = 0; - end -end - --- local routines for Update Button ---[[ local -NAME: TitanPanelButton_SetButtonText -DESC: Set / update the text of the given Titan plugin. -VAR: id - string name of the plugin -NOTE: -- The plugin is expected to tell Titan what routine is to be called in .registry.buttonTextFunction. -- The text routine is called in protected mode (pcall) to ensure the Titan main routines still run. -: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) end -local function TitanPanelButton_SetButtonText(id) - if not (id and TitanUtils_IsPluginRegistered(id)) then return end - - local buttonTextFunction = _G[TitanUtils_GetPlugin(id).buttonTextFunction]; - if not buttonTextFunction then return end - local button = TitanUtils_GetButton(id); - 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 - 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) - - return - end - - - 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") - else - end - else - label1 = "" - end - if label2 or value2 then - values = 2 - if show_label then - if TitanGetVar(id, "CustomLabel2TextShow") then - -- override the label per the user - label2 = TitanGetVar(id, "CustomLabel2Text") - else - end - else - label2 = "" - end - if label3 or value3 then - if show_label then - if TitanGetVar(id, "CustomLabel3TextShow") then - -- override the label per the user - label3 = TitanGetVar(id, "CustomLabel3Text") - else - end - else - 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 - 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 "" - ) -end - ---[[ local -NAME: TitanPanelButton_SetTextButtonWidth -DESC: Set the text width of the given Titan plugin that is text only. -VAR: id - string name of the plugin -VAR: setButtonWidth - new width -NOTE: -- Titan uses a tolerance setting to prevent endless updating of the text width. -: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(); - end - end -end - ---[[ local -NAME: TitanPanelButton_SetIconButtonWidth -DESC: Set the icon width of the given Titan plugin that is icon only. -VAR: id - string name of the plugin -NOTE: -- The plugin is expected to tell Titan what the icon width is in .registry.iconButtonWidth. -:NOTE ---]] -local function TitanPanelButton_SetIconButtonWidth(id) - if (id) then - local button = TitanUtils_GetButton(id); - if ( TitanUtils_GetPlugin(id).iconButtonWidth ) then - button:SetWidth(TitanUtils_GetPlugin(id).iconButtonWidth); - end - end -end - ---[[ local -NAME: TitanPanelButton_SetComboButtonWidth -DESC: Set the icon width of the given Titan plugin that is a combo - icon & text. -VAR: id - string name of the plugin -VAR: setButtonWidth - new width -NOTE: -- The plugin is expected to tell Titan what the icon width is in .registry.iconButtonWidth. -:NOTE ---]] -local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) - if (id) then - 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 iconWidth, iconButtonWidth, newButtonWidth; - - -- Get icon button width - iconButtonWidth = 0; - if ( TitanUtils_GetPlugin(id).iconButtonWidth ) then - iconButtonWidth = TitanUtils_GetPlugin(id).iconButtonWidth; - elseif ( icon:GetWidth() ) then - iconButtonWidth = icon:GetWidth(); - end - - if ( TitanGetVar(id, "ShowIcon") and ( iconButtonWidth ~= 0 ) ) then - icon:Show(); - text:ClearAllPoints(); - text:SetPoint("LEFT", icon:GetName(), "RIGHT", 2, 1); - - newButtonWidth = text:GetWidth() + iconButtonWidth; - else - icon:Hide(); - text:ClearAllPoints(); - text:SetPoint("LEFT", button:GetName(), "LEFT", 0, 1); - - 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 ) - then - button:SetWidth(newButtonWidth); - TitanPanelButton_Justify(); - end - end -end - ---[[ API -NAME: TitanPanelButton_UpdateButton -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); - 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) - ); - 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); - end -end - - ---[[ API -NAME: TitanPanelButton_UpdateTooltip -DESC: Update the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin ---]] -function TitanPanelButton_UpdateTooltip(self) -- Used by plugins - if not self then return end - if (GameTooltip:IsOwned(self)) then - local id = TitanUtils_GetButtonID(self:GetName()); - - TitanPanelButton_SetTooltip(self, id); - end -end - ---[[ API -NAME: TitanPanelButton_SetButtonIcon -DESC: Set the icon of the given Titan plugin. -VAR: id - string name of the plugin -VAR: iconCoords - if given, this is the placing of the icon within the plugin -VAR: iconR - if given, this is the Red (RBG) setting of the icon -VAR: iconG - if given, this is the Green (RBG) setting of the icon -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; - - 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) - end - end -end - ---[[ Titan -NAME: TitanPanelButton_GetType -DESC: Get the type of the given Titan plugin. -VAR: id - string name of the plugin -OUT: type - The type of the plugin (text, icon, combo (default)) -NOTE: -- This assumes that the developer is playing nice and is using the Titan templates as is... -: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 - 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; - end - - return type; -end - ---[[ Titan -NAME: TitanPanelButton_ApplyBarPos -DESC: Apply saved Bar position to the Bar frame. -VAR: frame_str - string name of the Bar frame -OUT: None -NOTE: -- Bit of a sledge hammer; used when loading a profile over the current so the Bars are properly placed. -:NOTE ---]] -function TitanPanelButton_ApplyBarPos(frame_str) - local frame = _G[frame_str] - local bdata = TitanBarData[frame] - local fdata = TitanBarDataVars[frame_str] - if frame and bdata and fdata then - frame:ClearAllPoints(); - if bdata.user_move then - frame:SetPoint(bdata.show.pt, bdata.show.rel_fr, bdata.show.rel_pt, fdata.off_x, fdata.off_y) - else - -- Set full bar, ignore - end - end -end - ---[[ Titan -NAME: TitanOptionsSliderTemplate_OnLoad -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, - }) -end - ---[[ Titan -NAME: TitanPanel_InitPanelBarButton -DESC: Set the scale, texture (graphic), and transparancy of all the Titan bars based on the user selection. -VAR: None -OUT: None ---]] -function TitanPanel_InitPanelBarButton() - -- Set initial Panel Scale - TitanPanel_SetScale(); - - for idx,v in pairs (TitanBarData) do --- CheckBarBounds(_G[idx], 0) - TitanPanel_SetBarTexture(idx) - end - - TitanPanelBarButton_DisplayBarsWanted("InitPanelBarButton") -end - --- ---========================== --- Routines to handle creation of Titan bars --- ---[[ Titan -NAME: TitanPanelButton_CreateBar(frame_str) -DESC: Create a Titan bar that can show plugins. -VAR: frame_str - name of the frame -NOTE: -- This assumes ... -:NOTE ---]] -function TitanPanelButton_CreateBar(frame_str) - local this_bar = frame_str - local a_bar = CreateFrame("Button", this_bar, UIParent, "Titan_Bar__Display_Template") - - local bar_data = TitanBarData[this_bar] - - -- ====== - -- Scripts - a_bar:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) - a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) - a_bar:SetFrameStrata("DIALOG") - - local x, y, w = TitanVariables_GetBarPos(frame_str) - local sx, sy = TitanUtils_ScreenSize() ---[[ -print("_Create bar" -.." "..tostring(bar_data.name).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(bar_data.show.pt).."" -.." "..tostring(bar_data.show.rel_fr).."" -.." "..tostring(bar_data.show.rel_pt).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(format("%0.1f", x)).."" -.." "..tostring(format("%0.1f", y)).."" -.." "..tostring(format("%0.1f", w)).."" -) ---]] - if bar_data.user_move then - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) - a_bar:SetMovable(true) - a_bar:SetResizable(true) - a_bar:EnableMouse(true) - a_bar:RegisterForDrag("LeftButton") - a_bar:SetScript("OnDragStart", OnMoveStart) - a_bar:SetScript("OnDragStop", OnMovingStop) - a_bar:SetScript("OnMouseWheel", OnMouseWheel) - a_bar:SetSize(w, TITAN_PANEL_BAR_HEIGHT) - else - -- Static full width bar - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y - TITAN_PANEL_BAR_HEIGHT) - end - - -- ====== - -- Bounds only effective on Short bars for now - -- Min : No smaller than the padding & one icon - -- Max : No wider than the screen - -- does not seem to work to restrict size automatically... - a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, sx, TITAN_PANEL_BAR_HEIGHT) - - a_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - a_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - -- ====== - -- Frame for right clicks - f = CreateFrame("Frame", this_bar.."RightClickMenu", UIParent, "UIDropDownMenuTemplate") - - -- ====== - -- Hider for auto hide feature - local hide_bar_name = TITAN_PANEL_HIDE_PREFIX..bar_data.name - if bar_data.hider then ---[[ -print("_Create hide bar" -.." "..tostring(bar_data.name).."" -.." "..tostring(hide_bar_name).."" -) ---]] - - local hide_bar = CreateFrame("Button", hide_bar_name, UIParent, "TitanPanelBarButtonHiderTemplate") - hide_bar:SetFrameStrata("DIALOG") - hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, -y) - - -- Set script handlers for display - hide_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - hide_bar:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) - hide_bar:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) - hide_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - hide_bar:SetFrameStrata("BACKGROUND") - hide_bar:SetSize(sx, TITAN_PANEL_BAR_HEIGHT) - else - -- Not allowed for this bar - end -end - diff --git a/Titan/TitanPanelTemplate.xml b/Titan/TitanPanelTemplate.xml deleted file mode 100644 index 7624d06..0000000 --- a/Titan/TitanPanelTemplate.xml +++ /dev/null @@ -1,173 +0,0 @@ - -