diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index f04548c..ca4751e 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -548,7 +548,7 @@ function TitanPanelButton_OnLoad(self, isChildButton) -- Used by plugins TitanUtils_PluginToRegister(self, isChildButton) end ---[[ API +--[[ API -- Used by plugins NAME: TitanPanelPluginHandle_OnUpdate DESC: A method to refresh the display of a Titan plugin. VAR: table - the frame of the plugin @@ -564,7 +564,7 @@ NOTE: 3 = refresh button and tooltip :NOTE --]] -function TitanPanelPluginHandle_OnUpdate(table, oldarg) -- Used by plugins +function TitanPanelPluginHandle_OnUpdate(table, oldarg) local id, updateType = nil, nil -- set the id and updateType -- old method @@ -636,12 +636,12 @@ function TitanPanelDetectPluginMethod(id, isChildButton) end) end ---[[ API +--[[ API -- Used by plugins 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 +function TitanPanelButton_OnShow(self) local id = nil; -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then @@ -653,7 +653,7 @@ function TitanPanelButton_OnShow(self) -- Used by plugins end end ---[[ API +--[[ API -- Used by plugins NAME: TitanPanelButton_OnClick DESC: Handle the OnClick mouse event of the requested Titan plugin. VAR: self - frame reference of the plugin @@ -663,7 +663,7 @@ NOTE: - Only the left and right mouse buttons are handled by Titan. :NOTE --]] -function TitanPanelButton_OnClick(self, button, isChildButton) -- Used by plugins +function TitanPanelButton_OnClick(self, button, isChildButton) local id -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then @@ -699,15 +699,14 @@ end TitanUtils_CloseAllControlFrames(); TitanPanelRightClickMenu_Close(); - local position = TitanUtils_GetWhichBar(id) +-- 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. + 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!! --]] @@ -748,7 +747,7 @@ end end end ---[[ API +--[[ API -- Used by plugins NAME: TitanPanelButton_OnEnter DESC: Handle the OnEnter cursor event of the requested Titan plugin. VAR: self - frame reference of the plugin @@ -759,7 +758,7 @@ NOTE: - 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 +function TitanPanelButton_OnEnter(self, isChildButton) local id = nil; -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then @@ -1082,13 +1081,13 @@ local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) end end ---[[ API +--[[ API -- Used by plugins 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 +function TitanPanelButton_UpdateButton(id, setButtonWidth) -- local button, id = TitanUtils_GetButton(id); local plugin = TitanUtils_GetPlugin(id) -- safeguard to avoid errors @@ -1116,12 +1115,12 @@ function TitanPanelButton_UpdateButton(id, setButtonWidth) -- Used by plugins end end ---[[ API +--[[ API -- Used by plugins 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 +function TitanPanelButton_UpdateTooltip(self) if not self then return end if (GameTooltip:IsOwned(self)) then local id = TitanUtils_GetButtonID(self:GetName()); diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 7fb148f..b7c09e7 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -2492,7 +2492,7 @@ function TitanDebug(debug_message, debug_type) end function TitanPluginDebug(id, debug_message) - msg = + local msg = TitanUtils_GetGoldText("<"..tostring(id).."> "..date("%H:%M:%S")) .." "..TitanUtils_GetHexText(tostring(debug_message), "1DA6C5") diff --git a/Titan/Titan_Mainline.toc b/Titan/Titan_Mainline.toc index fc127e0..e26017a 100644 --- a/Titan/Titan_Mainline.toc +++ b/Titan/Titan_Mainline.toc @@ -2,6 +2,7 @@ ## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.6|r ## Author: Titan Panel Dev Team ## Version: 8.0.6 +## IconTexture: Interface\Icons\Achievement_Dungeon_UlduarRaid_Titan_01 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## Notes: Adds display bars to show and control information/launcher plugins. ## X-Credits: TitanMod, Dark Imakuni, Adsertor, Titan Dev Team diff --git a/TitanBag/TitanBag_Mainline.toc b/TitanBag/TitanBag_Mainline.toc index e705136..fe9b3a0 100644 --- a/TitanBag/TitanBag_Mainline.toc +++ b/TitanBag/TitanBag_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanBag\TitanBag ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClock/TitanClock_Mainline.toc b/TitanClock/TitanClock_Mainline.toc index 1879d02..e7e7f69 100644 --- a/TitanClock/TitanClock_Mainline.toc +++ b/TitanClock/TitanClock_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\Icons\Spell_Nature_TimeStop ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanGold/TitanGold_Mainline.toc b/TitanGold/TitanGold_Mainline.toc index d474dc5..876009f 100644 --- a/TitanGold/TitanGold_Mainline.toc +++ b/TitanGold/TitanGold_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanGold\Artwork\TitanGold ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: GoldSave diff --git a/TitanLDB/DevReadMe.lua b/TitanLDB/DevReadMe.lua new file mode 100644 index 0000000..6b7cebc --- /dev/null +++ b/TitanLDB/DevReadMe.lua @@ -0,0 +1,82 @@ +--[[ LDB Addon +StarterLDB.lua +This is a simplistic example of a LDB (LibDataBroker) Addon. +It is assumed that you understand the Blizzard addon basics. +It is based loosely on the Titan Bag plugin but is not Titan specific. + +It is not required that a display addon exist for your addon to run; Such as Titan :-) +However your addon will need to enable command line commands or the user will not be able to see or do anything. + +If running this example, it shows up in the Titan right click menu under : General > LDBStarter + +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example to just run this as is, remove the 'Example' from the folder name then start or reload WoW. +This is explained in more detail below in 'Folder Structure'. + +Enjoy! +By: The Titan Development Team +--]] + +--[[ Folder Structure +Inside this folder you will notice : +- three .toc files +- one .lua file +- one .tga file +- Artwork folder containg the icon used by the addon +- libs folder containing the LDB lib file + +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example, to just run this as is, remove the 'Example' from the files ending in tocExample then start or reload WoW. +This is explained in more detail below. + +There are sites (wowhead or wow wiki as examples) that have deeper explainations on addon development. +Please use these sites for more addon information. + +=== .toc or TOC +The folder and the .toc files MUST have the same name! +Sort of... the name prior to the underscore(_) must be the same. The name after that (postfix) has meaning to the WoW addon loader. +WoW accepts three TOC versions represented by the three postix values : +_Mainline : current retail version +_Wrath : Wrath of the Lich King version. +_Vanilla : Classic Era version +These values may change as the versions evolve, say Cata is added to Wrath. +Or they may not :). Years from now we may wonder why Wrath represents Dragonflight! + +If your plugin is only for Classic Era then delete or leave the 'mainline' and 'wrath' .toc files as they are. +Changing the filename will prevent WoW from loading the addon into that version of the game. + +NOTE: The ## Interface value should match the current interface value of the cooresponding WoW version. +In BattleNet this typcially shown below the 'Play' button. +DragonFlight 10.02.05 is represented without dots - 100205 - in the .toc. +If the interface value is higher or lower WoW will complain that you are running 'out of date' addons. + +=== .lua +This is the code for the plugin. + +=== /Artwork +The .tga file is the icon used by the plugin. +The icon is specified in the .obj created for the LDB init routine. +WoW can use several different types of icons. This discussion is outside the scope of this example. + +=== libs +The file implementing the LDB functions. +See https://github.com/tekkub/libdatabroker-1-1/wiki/ for an API description. +LibDataBroker-1.1.lua at https://github.com/tekkub/libdatabroker-1-1/ +It *should* be included in the LDB compliant display addon. +It must be included in the display addon that shows LDB addons. + + +Anyone can extract the code and art from WoW. This can be handy to get code examples. +And to grab icons to use for a plugin. My understanding is any icon can be used within WoW without violating the WoW ToS. +WoW icons tend to be .blp files. These files are NOT easy to look at or manipulate!! +Wowhead has an icon lookup that is useful which also shows the name of the icon file. +You will need to research third party tools to manipulate .blp files. +--]] + +--[[ Saved Variables +Saved variables are not part of this addon and outside the scope of this example. + +However, if using saved variables consider not referencing them until Player Entering World event or +registering for the event fired once saved variables are loaded. +See the referenced web sites above for more detail. +--]] diff --git a/TitanLDB/TitanLDB_Mainline.tocExample b/TitanLDB/TitanLDB_Mainline.tocExample new file mode 100644 index 0000000..ed50362 --- /dev/null +++ b/TitanLDB/TitanLDB_Mainline.tocExample @@ -0,0 +1,13 @@ +## Interface: 100205 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLDB/TitanLDB_Vanilla.tocExample b/TitanLDB/TitanLDB_Vanilla.tocExample new file mode 100644 index 0000000..4a1ad2f --- /dev/null +++ b/TitanLDB/TitanLDB_Vanilla.tocExample @@ -0,0 +1,13 @@ +## Interface: 11500 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLDB/TitanLDB_Wrath.tocExample b/TitanLDB/TitanLDB_Wrath.tocExample new file mode 100644 index 0000000..368ecd3 --- /dev/null +++ b/TitanLDB/TitanLDB_Wrath.tocExample @@ -0,0 +1,13 @@ +## Interface: 30403 +## Title: StarterLDB +## Notes: LDB example +## Author: Titan Dev Team +## DefaultState: Enabled +## SavedVariables: +## OptionalDeps: +## Dependencies: +## Version: 1.1 +## X-Child-Of: +## DefaultState: disabled +libs/LibDataBroker-1.1.lua +StarterLDB.lua diff --git a/TitanLocation/TitanLocation_Mainline.toc b/TitanLocation/TitanLocation_Mainline.toc index c3dd488..87cc27f 100644 --- a/TitanLocation/TitanLocation_Mainline.toc +++ b/TitanLocation/TitanLocation_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanLocation\TitanLocation ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLootType/TitanLootType_Mainline.toc b/TitanLootType/TitanLootType_Mainline.toc index 3fbee4a..1a934a2 100644 --- a/TitanLootType/TitanLootType_Mainline.toc +++ b/TitanLootType/TitanLootType_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.00.0|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanLootType\TitanLootType ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanPerformance/TitanPerformance_Mainline.toc b/TitanPerformance/TitanPerformance_Mainline.toc index 7db4bbf..03def6f 100644 --- a/TitanPerformance/TitanPerformance_Mainline.toc +++ b/TitanPerformance/TitanPerformance_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanPerformance\TitanPerformance ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanPlugin/DevReadMe.lua b/TitanPlugin/DevReadMe.lua new file mode 100644 index 0000000..349252c --- /dev/null +++ b/TitanPlugin/DevReadMe.lua @@ -0,0 +1,322 @@ +--[[ Example +This example is intended to introduce Titan plugin essentials by using a Titan addon plugin loosely based on Titan Bag. +Titan is REQUIRED for this addon to run without throwing errors. + +NOTE: The terms addon and plugin are essentially the same. +Here plugin is used when the addon is displayed by Titan. + +NOTE: This example uses AceLocale. Titan locale strings were left in the code so it will run as is. +Please use your own strings - localized or not. + +NOTE: Titan includes several libraries which have not changed in quite a while. You are free to use these. +If you require additional libraries, please include them in your addon. + +NOTE: Timers are outside the scope of this example. +See other Titan built-in plugins for timers (AceTimer). +--]] + +--[[ Folder Structure +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example to just run this as is, remove the 'Example' from the TOC file name then start or reload WoW. +This is explained in more detail below. + + +This plugin folder must be added to the Addon folder to be considered for loading into WoW. +Inside this folder you will notice : +- three .tocExample files +- one .lua file - your great idea +- one .tga file - the icon used by the plugin + +There are sites (wowhead or wow wiki as examples) that have deeper explainations on addon development. +Please use these sites for more addon information. + +=== .toc +The folder and the .toc files MUST have the same name! +Sort of... the name prior to the underscore(_) must be the same as the folder name. +The name after that (postfix) has meaning to WoW addon loader. +WoW has three versions represented by the three postix values. +_Mainline : current retail version +_Wrath : Wrath of the Lich King version. +_Vanilla : Classic Era version +These values may change as the versions evolve, say Cata is added to Wrath. +Or they may not :). Years from now we may wonder why Wrath represents Dragonflight! + +If your plugin is only for Classic Era then delete or rename the 'mainline' and 'wrath' .toc files. +Changing the filename will prevent WoW from loading the addon into that version of the game. + +Titan uses this method. Notice Titan folder has no 'wrath' or 'vanilla' .toc. +TitanClassic has has both 'wrath' and 'vanilla' .toc but no 'mainline' .toc. +This allows Titan plugins intended for Classic versions to run without change. + +NOTE: The ## Interface value should match the current interface value of the coorsponding WoW version. +In BattleNet this typcially shown below the 'Play' button. +DragonFlight 10.02.05 is represented without dots - 100205 - in the .toc. + +If the interface value is higher or lower, WoW will complain that you are running 'out of date' addons. + +=== .lua +This is the code for the plugin. + +=== .tga +This file is the icon used by the plugin. +It is specified in the .registry used by Titan. +WoW can use several different types of icons. This discussion is outside the scope of this example. + +=== LDB +Titan includes the LDB lib. It is not needed in the Titan plugin folder. + +=== icons and artwork +Anyone can extract the code and art from WoW. This can be handy to get code examples. +And to grab icons to use for a plugin. My undestanding is any icon can be used within WoW without violating the ToS. +WoW icons tend to be .blp files. These files are NOT easy to look at or manipulate!! +You will need to research third party tools to manipulate .blp files. +--]] + +--[[ File Structure +The plugin starts with local constants used throughout. +Then local variables; then functions. + +NOTE: Titan locale strings were left in the code so it will run as is. +Please use your own strings - localized or not. + +The design uses local functions. Mainly for clarity and a small speed increase. +Titan specific details will be noted and explained. +The comments will specify where names are important. +Any local routine or variable with 'bag' in the name can be changed to your design or deleted. + +Suggested path is start with Create_Frames at the bottom of the file. It is where the magic starts. + +NOTE: Feel free to look at Titan code. Pay attention to the comments. +Any routine labeled as <block comment start> API can be used by a plugin. +Titan API routines will be maintained and the functionality expected to remain stable. +Any parameter or functionality changes to API will be 'broadcast' on delivery sites and our sites (Discord, our web page). + +Of course feel free to reach out on our Discord site with any questions or suggestions! +--]] + +--[[ Editting +As noted above, remove the 'Example' from the TOC file name that cooresponds to the version of WoW you are developing for. +It is not required to change all TOC files at the same time. +Then start or reload WoW. + +This example may seem daunting at first. We decided to leave Bag as is (as of Jan 2024) to give plenty of coding examples. + +Routines: +GetBagData will be replaced by your code. It uses local function IsProfessionBagID. +ToggleBags is called from OnClick. This will be replaced by your code that handles mouse clicks. + +CreateMenu will need to be changed to implement your right click menu, if any. + +The other routines will be modified to implement your idea. +--]] + +--[[ Code flow +NOTE: The .toc states Titan is required [## Dependencies: Titan]. +WoW insures Titan is loaded BEFORE this addon. + +First step: ==== Starting WoW +Wow will 'load' this addon after Titan is loaded. + +Any code outside the Lua functions will be run. +- local VERSION = GetAddOnMetadata(add_on, "Version") will run GetAddOnMetadata +- bag_info will be populated +- ... +- Create_Frames is called + +Create_Frames will create the addon frame stated in TITAN_BUTTON. +Then calls local OnLoad. +Then sets the frame scripts for the addon. See Frame Scripts +NOTE: The frame is created using a Titan template. A Titan template handles some frame processing. + +OnLoad does two important things +1) Sets the .registry of the addon - See the .registry comment block +2) Registers for PLAYER_ENTERING_WORLD +NOTE: OnLoad should be small and not assume saved variable data is ready / loaded yet. + +Next: ==== Waiting for WoW +WoW fires a bunch of events as this and other addons are loaded. + +Eventually the game and all addons are loaded and this plugin receives the PLAYER_ENTERING_WORLD event via frame OnEvent. +When processing PLAYER_ENTERING_WORLD, only register for events and access local data. +Do not assume saved variables from registry or server data is ready. + +Titan also receives the PLAYER_ENTERING_WORLD event. +It is best to assume there is NO guarantee this plugin receives the event before or after Titan! +Titan then processes its own data, creates Titan bars, registers Titan plugins and LDB addons, and syncs plugin saved variables. +Titan will process and set any saved variables specified in the .registry of this plugin! + +Next: ==== Still waiting for WoW +Titan shows the user requested bars with the user requested plugins. +OnShow is called by Titan when placing this plugin on a bar or the user requests the plugin to be shown. + +NOTE: It is best to assume any saved variables in .registry are NOT ready until OnShow! + +OnShow now does all processing to set up this plugin properly. +Once set up, this addon needs to call TitanPanelButton_UpdateButton to update the plugin text. +The plugin is now ready for the user. + +Next: ==== Ready to play WoW, Yeah! +The plugin is 'idle' until : +- Titan calls TitanPanelButton_UpdateButton(TITAN_PLUGIN) to (re)display this plugin +- User selects show this plugin (Config or menu) +- User changes a plugin option using the plugin menu +- User clicks on this plugin - OnClick +- Any registered event is received - OnEvent +- User mouses over plugin - OnEnter +- User mouse leaves plugin - OnLeave +- A timer or callback calls a plugin routine +Next: ==== +The above step continues until: +- User hides the plugin +- The user logs out the character or exits WoW or reloads UI +Then OnHide to be eventually called. + +On logout or exit the saved variables are saved to the local system. +NOTE: Any saved variables specified in .registry - savedVariables - are saved by WoW on logout or exit. +No additional actions are required. + +==== Using OnShow to set up this addon is good practice : +It should: +- Register any events the plugin will react to +- Process any saved variable data now +- Create any timers +- Set the initial plugin - icon, label, text + +This ensures: +- All saved variable data is set +- Less processing if the user never selects the plugin or clicks Hide + +==== Using OnHide to clean up is good practice : +It should: +- Unregister any events the pluginhad registered +- Remove any timers +- Cleanup any plugin specifc data or objects + +This ensures: +- Less processing when the user clicks Hide + +==== TitanPanelButton_UpdateButton(TITAN_PLUGIN) should be called by this plugin whenever the plugin text could change; +usually when events are received or on user action. +NOTE: This routine expects label - value pairs (up to 4). Titan uses 'show label' to control showing the label or not. +Titan Performance uses and shows multiple label - value pairs based on user selection. + +==== OnEnter and OnLeave +NOTE: The Titan template handles OnEnter and OnLeave to show or hide the tooltip. +Titan calls the specified .registry routine to show the tooltip - tooltipTextFunction. + +==== Additional saved variables specific to this addon must be handled by this addon and are outside the scope of this example. +See Titan Gold for an example of a Titan plugin that has its own saved variables. +--]] + +--[[ Frame Scripts +The frame scripts are how WoW and Titan interact with this addon. + +OnShow script : +This is triggered when this plugin (frame) is shown - init; reload; user selected show (Titan menu or config). +OnShow handles any plugin specific code. +It is suggested events this plugin are interested in be registered here to minimize processing. +Then call TitanPanelButton_UpdateButton(TITAN_PLUGIN) to get the text updated. +Titan will use the routine specified in the .registry - buttonTextFunction + +TitanPanelButton_OnShow ensures the plugin is placed on the selected bar - from user or saved variables. + +Technically : +- Titan calls the now registered plugin frame - TITAN_BUTTON:Show() +- Which first calls the frame script :OnShow() as set by the Titan template +- Eventually calling OnShow() in this addon as set in Create_Frames + +OnClick script : +Right click is handled by the Titan template chosen and is assumed to be a create menu request.should be procssed by this plugin. + +Any other mouse click combination should be handled by the plugin code. + +Right click: TitanPanelButton_OnClick is called to handle right click which invokes the plugin menu. +The routine can be known in one of two ways: +1) Specified in the registry - preferred - menuTextFunction +2) Create the expected routine - TitanPanelRightClickMenu_Prepare<id>Menu +Titan will use the registry over the created routine. It will not use both. + +OnEnter script : +OnEnter is handled by the Titan template to show the tool tip. +It calls the routine specified in registry - tooltipTextFunction . + +OnLeave script : +OnLeave is handled by the Titan template to hide the tool tip. + +OnHide script : +OnHide should +- Do any cleanup +- Stop any timers +- Unregister any events +These steps keep processing to a minimum and reduces the chance of errors to the user. + +OnEvent script : +All events registered for should be handled here. +--]] +--[[ Events +Titan Bag uses PLAYER_ENTERING_WORLD to handle a difference between retail and Classic versions when opening bags via the addon. + +BAG_UPDATE just updates the text (count) whenever this event is fired. +NOTE: The event also fires when moving items within the bag... +--]] + +--[[ .registry attributes +This is the GUTS of a Titan plugin. The .registry on the frame contains all +the information to register the plugin for display. + +Every plugin registry with an id should appear in Titan > Configuration > Attempts. +Information about the plugin is shown there along with pass / fail. +If the plugin failed to register, the error is shown there. + +NOTE: Titan looks for 3 routines. See .registry Routines. + +Attributes: +.id : Required : must be unique across plugins. If there are duplicates, the first one 'wins'. +.category : The general grouping this plugin is in. + The complete category list is in TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY (TitanGlobal.lua) + "Built-ins" is reserved for plugins that Titan releases. +.version : plugin version shown in menus and config. +.menuText : Used by as the title for the right click menu. +.menuTextFunction : See .registry Routines. +.buttonTextFunction : See .registry Routines. +.tooltipTitle : Used as the title for the tool tip +.tooltipTextFunction : See .registry Routines. +.icon : Allowed path to the icon to be used. It is recommended to store the icon in the plugin folder, + even if copied from WoW folder. +.iconWidth : Best left at 16... +.notes : This is shown in Titan > Config > Plugins when this plugin is selected. +.controlVariables : This list is used by TitanPanelRightClickMenu_AddControlVars(TITAN_PLUGIN) + true : Will be included in the menu + false : Will not be included in the menu +.savedVariables : These are the variables stored in Titan saved variables. + The initial values are used only if that particular is 'new' to that character (new Titan install, new character). + If a value is removed then it is removed from the saved variables as Titan is run for each character. + +--]] +--[[ .registry Routines +Titan looks for 3 routines: +- Routine that updates the plugin text : .buttonTextFunction +- Routine that creates the tool tip : .tooltipTextFunction +- Routine that creates the options (right click) : .menuTextFunction OR "TitanPanelRightClickMenu_Prepare"<id>"Menu" + +.menuTextFunction : This is the routine called by Titan on right click. + This is the newer, prefered method which makes the options menu routine explicit. 2024 Feb + The older method is still supported! + Titan builds the expected routine name as "TitanPanelRightClickMenu_Prepare"<id>"Menu". + In this example TitanPanelRightClickMenu_PrepareStarterMenu +.buttonTextFunction : This is called whenever the button is to be updated. + This is called from within the plugin and from Titan by calling TitanPanelButton_UpdateButton(TITAN_PLUGIN) . + Titan will usually show "<?>" if the routine dies. + If you need to see the error, search for this attribute in Titan folder and uncomment the print of the error message. + This may generate a LOT of messages! +.tooltipTextFunction : This is called when OnEnter of the plugin frame is triggered. + The Titan templates set the OnEnter script for the plugin frame. + On a tooltip error, Titan will usually show part of the error in the tool tip. + If you need to see the error, search for this attribute in Titan folder and uncomment the print of the error message. + +NOTE: The specified routine is called securely (pcall) to protect Titan. +NOTE: These routines are expected to have NO parameters. Handling parameters was not implemented in any version of Titan. +NOTE: Routine can be specified (changed as of 2024 Feb) - +- As a string, it MUST be in the global namespace. Strings were the only way for a long time. +- As a function, it may be in the global namespace but could be local. This example usees uses a local routine. +--]] diff --git a/TitanPlugin/TitanPlugin_Mainline.tocExample b/TitanPlugin/TitanPlugin_Mainline.tocExample new file mode 100644 index 0000000..9429319 --- /dev/null +++ b/TitanPlugin/TitanPlugin_Mainline.tocExample @@ -0,0 +1,9 @@ +## Interface: 100205 +## Title: Titan Starter +## Version: 1.0.0 +## Notes: Adds bag and free slot information to Titan Panel +## Author: Titan Panel Development Team (http://www.titanpanel.org) +## SavedVariables: +## Dependencies: Titan +## DefaultState: disabled +TitanStarter.lua diff --git a/TitanPlugin/TitanPlugin_Vanilla.tocExample b/TitanPlugin/TitanPlugin_Vanilla.tocExample new file mode 100644 index 0000000..fb4fe22 --- /dev/null +++ b/TitanPlugin/TitanPlugin_Vanilla.tocExample @@ -0,0 +1,10 @@ +## Interface: 11500 +## Title: TitanStarter +## Version: 1.0.0 +## Notes: Adds bag and free slot information to Titan Panel +## Author: Titan Panel Development Team (http://www.titanpanel.org) +## SavedVariables: +## OptionalDeps: +## Dependencies: TitanClassic +## DefaultState: disabled +TitanStarter.lua diff --git a/TitanPlugin/TitanPlugin_Wrath.tocExample b/TitanPlugin/TitanPlugin_Wrath.tocExample new file mode 100644 index 0000000..809e85d --- /dev/null +++ b/TitanPlugin/TitanPlugin_Wrath.tocExample @@ -0,0 +1,10 @@ +## Interface: 30403 +## Title: Titan Starter +## Version: 1.0.0 +## Notes: Adds bag and free slot information to Titan Panel +## Author: Titan Panel Development Team (http://www.titanpanel.org) +## SavedVariables: +## OptionalDeps: +## Dependencies: TitanClassic +## DefaultState: disabled +TitanStarter.lua diff --git a/TitanPlugin/TitanStarter.lua b/TitanPlugin/TitanStarter.lua new file mode 100644 index 0000000..a7053ca --- /dev/null +++ b/TitanPlugin/TitanStarter.lua @@ -0,0 +1,935 @@ +---@diagnostic disable: duplicate-set-field +--[[ +-- ************************************************************************** +-- * TitanStarter.lua +-- * +-- * By: The Titan Panel Development Team +-- ************************************************************************** +--]] +--[[ Example +This example is intended to introduce Titan plugin essentials by using a basic Titan addon plugin loosely based on Titan Bag. +Titan is REQUIRED for this addon to run without throwing errors. + +NOTE: The terms addon and plugin are essentially the same. +Here plugin is used when the addon is displayed by Titan. + +NOTE: This example uses AceLocale. Titan locale strings were left in the code so it will run as is. +Please use your own strings - localized or not. + +NOTE: Titan includes several libraries which have not changed in quite a while. You are free to use these. +If you require additional libraries, please include them in your addon. + +NOTE: Timers are outside the scope of this example. +See other Titan built-in plugins for timers (AceTimer). +--]] + +--[[ Folder Structure +NOTE: Before running this addon, the folder and file prefix must be the same to be considered for loading into WoW! +For example to just run this as is, remove the 'Example' from the TOC file name then start or reload WoW. +This is explained in more detail below. + + +This plugin folder must be added to the Addon folder to be considered for loading into WoW. +Inside this folder you will notice : +- three .tocExample files +- one .lua file - your great idea +- one .tga file - the icon used by the plugin + +There are sites (wowhead or wow wiki as examples) that have deeper explainations on addon development. +Please use these sites for more addon information. + +=== .toc +The folder and the .toc files MUST have the same name! +Sort of... the name prior to the underscore(_) must be the same as the folder name. +The name after that (postfix) has meaning to WoW addon loader. +WoW has three versions represented by the three postix values. +_Mainline : current retail version +_Wrath : Wrath of the Lich King version. +_Vanilla : Classic Era version +These values may change as the versions evolve, say Cata is added to Wrath. +Or they may not :). Years from now we may wonder why Wrath represents Dragonflight! + +If your plugin is only for Classic Era then delete or rename the 'mainline' and 'wrath' .toc files. +Changing the filename will prevent WoW from loading the addon into that version of the game. + +Titan uses this method. Notice Titan folder has no 'wrath' or 'vanilla' .toc. +TitanClassic has has both 'wrath' and 'vanilla' .toc but no 'mainline' .toc. +This allows Titan plugins intended for Classic versions to run without change. + +NOTE: The ## Interface value should match the current interface value of the coorsponding WoW version. +In BattleNet this typcially shown below the 'Play' button. +DragonFlight 10.02.05 is represented without dots - 100205 - in the .toc. + +If the interface value is higher or lower, WoW will complain that you are running 'out of date' addons. + +=== .lua +This is the code for the plugin. + +=== .tga +This file is the icon used by the plugin. +It is specified in the .registry used by Titan. +WoW can use several different types of icons. This discussion is outside the scope of this example. + +=== LDB +Titan includes the LDB lib. It is not needed in the Titan plugin folder. + +=== icons and artwork +Anyone can extract the code and art from WoW. This can be handy to get code examples. +And to grab icons to use for a plugin. My undestanding is any icon can be used within WoW without violating the ToS. +WoW icons tend to be .blp files. These files are NOT easy to look at or manipulate!! +You will need to research third party tools to manipulate .blp files. +--]] + +--[[ File Structure +The plugin starts with local constants used throughout. +Then local variables; then functions. + +NOTE: Titan locale strings were left in the code so it will run as is. +Please use your own strings - localized or not. + +The design uses local functions. Mainly for clarity and a small speed increase. +Titan specific details will be noted and explained. +The comments will specify where names are important. +Any local routine or variable with 'bag' in the name can be changed to your design or deleted. + +Suggested path is start with Create_Frames at the bottom of the file. It is where the magic starts. + +Note: Feel free to look at Titan code. Pay attention to the comments. +Any routine labeled as <block comment start> API can be used by a plugin. +Titan API routines will be maintained and the functionality expected to remain stable. +Any parameter or functionality changes to API will be 'broadcast' on delivery sites and our sites (Discord, our web page). + +Of course feel free to reach out on our Discord site with any questions or suggestions! +--]] + +--[[ Editting +As noted above, remove the 'Example' from the TOC file name that cooresponds to the version of WoW you are developing for. +It is not required to change all TOC files at the same time. +Then start or reload WoW. + +This example may seem daunting at first. We decided to leave Bag as is (as of Jan 2024) to give plenty of coding examples. + +Routines: +GetBagData will be replaced by your code. It uses local function IsProfessionBagID. +ToggleBags is called from OnClick. This will be replaced by your code that handles mouse clicks. + +CreateMenu will need to be changed to implement your right click menu, if any. + +The other routines will be modified to implement your idea. +--]] + +--[[ Code flow +NOTE: The .toc states Titan is required [## Dependencies: Titan]. +WoW insures Titan is loaded BEFORE this addon. + +First step: ==== Starting WoW +Wow will 'load' this addon after Titan is loaded. + +Any code outside the Lua functions will be run. +- local VERSION = GetAddOnMetadata(add_on, "Version") will run GetAddOnMetadata +- bag_info will be populated +- ... +- Create_Frames is called + +Create_Frames will create the addon frame stated in TITAN_BUTTON. +Then calls local OnLoad. +Then sets the frame scripts for the addon. See Frame Scripts +NOTE: The frame is created using a Titan template. A Titan template handles some frame processing. + +OnLoad does two important things +1) Sets the .registry of the addon - See the .registry comment block +2) Registers for PLAYER_ENTERING_WORLD +NOTE: OnLoad should be small and not assume saved variable data is ready / loaded yet. + +Next: ==== Waiting for WoW +WoW fires a bunch of events as this and other addons are loaded. + +Eventually the game and all addons are loaded and this plugin receives the PLAYER_ENTERING_WORLD event via frame OnEvent. +When processing PLAYER_ENTERING_WORLD, only register for events and access local data. +Do not assume saved variables from registry or server data is ready. + +Titan also receives the PLAYER_ENTERING_WORLD event. +It is best to assume there is NO guarantee this plugin receives the event before or after Titan! +Titan then processes its own data, creates Titan bars, registers Titan plugins and LDB addons, and syncs plugin saved variables. +Titan will process and set any saved variables specified in the .registry of this plugin! + +Next: ==== Still waiting for WoW +Titan shows the user requested bars with the user requested plugins. +OnShow is called by Titan when placing this plugin on a bar or the user requests the plugin to be shown. + +NOTE: It is best to assume any saved variables in .registry are NOT ready until OnShow! + +OnShow now does all processing to set up this plugin properly. +Once set up, this addon needs to call TitanPanelButton_UpdateButton to update the plugin text. +The plugin is now ready for the user. + +Next: ==== Ready to play WoW, Yeah! +The plugin is 'idle' until : +- Titan calls TitanPanelButton_UpdateButton(TITAN_PLUGIN) to (re)display this plugin +- User selects show this plugin (Config or menu) +- User changes a plugin option using the plugin menu +- User clicks on this plugin - OnClick +- Any registered event is received - OnEvent +- User mouses over plugin - OnEnter +- User mouse leaves plugin - OnLeave +- A timer or callback calls a plugin routine +Next: ==== +The above step continues until: +- User hides the plugin +- The user logs out the character or exits WoW or reloads UI +Then OnHide to be eventually called. + +On logout or exit the saved variables are saved to the local system. +NOTE: Any saved variables specified in .registry - savedVariables - are saved by WoW on logout or exit. +No additional actions are required. + +==== Using OnShow to set up this addon is good practice : +It should: +- Register any events the plugin will react to +- Process any saved variable data now +- Create any timers +- Set the initial plugin - icon, label, text + +This ensures: +- All saved variable data is set +- Less processing if the user never selects the plugin or clicks Hide + +==== Using OnHide to clean up is good practice : +It should: +- Unregister any events the pluginhad registered +- Remove any timers +- Cleanup any plugin specifc data or objects + +This ensures: +- Less processing when the user clicks Hide + +==== TitanPanelButton_UpdateButton(TITAN_PLUGIN) should be called by this plugin whenever the plugin text could change; +usually when events are received or on user action. +Note: This routine expects label - value pairs (up to 4). Titan uses 'show label' to control showing the label or not. +Titan Performance uses and shows multiple label - value pairs based on user selection. + +==== OnEnter and OnLeave +NOTE: The Titan template handles OnEnter and OnLeave to show or hide the tooltip. +Titan calls the specified .registry routine to show the tooltip - tooltipTextFunction. + +==== Additional saved variables specific to this addon must be handled by this addon and are outside the scope of this example. +See Titan Gold for an example of a Titan plugin that has its own saved variables. +--]] + +--[[ Frame Scripts +The frame scripts are how WoW and Titan interact with this addon. + +OnShow script : +This is triggered when this plugin (frame) is shown - init; reload; user selected show (Titan menu or config). +OnShow handles any plugin specific code. +It is suggested events this plugin are interested in be registered here to minimize processing. +Then call TitanPanelButton_UpdateButton(TITAN_PLUGIN) to get the text updated. +Titan will use the routine specified in the .registry - buttonTextFunction + +TitanPanelButton_OnShow ensures the plugin is placed on the selected bar - from user or saved variables. + +Technically : +- Titan calls the now registered plugin frame - TITAN_BUTTON:Show() +- Which first calls the frame script :OnShow() as set by the Titan template +- Eventually calling OnShow() in this addon as set in Create_Frames + +OnClick script : +Right click is handled by the Titan template chosen and is assumed to be a create menu request.should be procssed by this plugin. + +Any other mouse click combination should be handled by the plugin code. + +Right click: TitanPanelButton_OnClick is called to handle right click which invokes the plugin menu. +The routine can be known in one of two ways: +1) Specified in the registry - preferred - menuTextFunction +2) Create the expected routine - TitanPanelRightClickMenu_Prepare<id>Menu +Titan will use the registry over the created routine. It will not use both. + +OnEnter script : +OnEnter is handled by the Titan template to show the tool tip. +It calls the routine specified in registry - tooltipTextFunction . + +OnLeave script : +OnLeave is handled by the Titan template to hide the tool tip. + +OnHide script : +OnHide should +- Do any cleanup +- Stop any timers +- Unregister any events +These steps keep processing to a minimum and reduces the chance of errors to the user. + +OnEvent script : +All events registered for should be handled here. +--]] +--[[ Events +Titan Bag uses PLAYER_ENTERING_WORLD to handle a difference between retail and Classic versions when opening bags via the addon. + +BAG_UPDATE just updates the text (count) whenever this event is fired. +Note the event also fires when moving items within the bag... +--]] + +--[[ .registry attributes +This is the GUTS of a Titan plugin. The .registry on the frame contains all +the information to register the plugin for display. + +Every plugin registry with an id should appear in Titan > Configuration > Attempts. +Information about the plugin is shown there along with pass / fail. +If the plugin failed to register, the error is shown there. + +NOTE: Titan looks for 3 routines. See .registry Routines. + +Attributes: +.id : Required : must be unique across plugins. If there are duplicates, the first one 'wins'. +.category : The general grouping this plugin is in. + The complete category list is in TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY (TitanGlobal.lua) + "Built-ins" is reserved for plugins that Titan releases. +.version : plugin version shown in menus and config. +.menuText : Used by as the title for the right click menu. +.menuTextFunction : See .registry Routines. +.buttonTextFunction : See .registry Routines. +.tooltipTitle : Used as the title for the tool tip +.tooltipTextFunction : See .registry Routines. +.icon : Allowed path to the icon to be used. It is recommended to store the icon in the plugin folder, + even if copied from WoW folder. +.iconWidth : Best left at 16... +.notes : This is shown in Titan > Config > Plugins when this plugin is selected. +.controlVariables : This list is used by TitanPanelRightClickMenu_AddControlVars(TITAN_PLUGIN) + true : Will be included in the menu + false : Will not be included in the menu +.savedVariables : These are the variables stored in Titan saved variables. + The initial values are used only if that particular is 'new' to that character (new Titan install, new character). + If a value is removed then it is removed from the saved variables as Titan is run for each character. + +--]] +--[[ .registry Routines +Titan looks for 3 routines: +- Routine that updates the plugin text : .buttonTextFunction +- Routine that creates the tool tip : .tooltipTextFunction +- Routine that creates the options (right click) : .menuTextFunction OR "TitanPanelRightClickMenu_Prepare"<id>"Menu" + +.menuTextFunction : This is the routine called by Titan on right click. + This is the newer, prefered method which makes the options menu routine explicit. 2024 Feb + The older method is still supported! + Titan builds the expected routine name as "TitanPanelRightClickMenu_Prepare"<id>"Menu". + In this example TitanPanelRightClickMenu_PrepareStarterMenu +.buttonTextFunction : This is called whenever the button is to be updated. + This is called from within the plugin and from Titan by calling TitanPanelButton_UpdateButton(TITAN_PLUGIN) . + Titan will usually show "<?>" if the routine dies. + If you need to see the error, search for this attribute in Titan folder and uncomment the print of the error message. + This may generate a LOT of messages! +.tooltipTextFunction : This is called when OnEnter of the plugin frame is triggered. + The Titan templates set the OnEnter script for the plugin frame. + On a tooltip error, Titan will usually show part of the error in the tool tip. + If you need to see the error, search for this attribute in Titan folder and uncomment the print of the error message. + +NOTE: The specified routine is called securely (pcall) to protect Titan. +NOTE: These routines are expected to have NO parameters. Handling parameters was not implemented in any version of Titan. +NOTE: Routine can be specified (changed as of 2024 Feb) - +- As a string, it MUST be in the global namespace. Strings were the only way for a long time. +- As a function, it may be in the global namespace but could be local. This example usees uses a local routine. +--]] + +-- ******************************** Constants ******************************* +local add_on = ... +local _G = _G --getfenv(0); +local artwork_path = "Interface\\AddOns\\TitanPlugin\\" +-- NOTE: The plugin id needs be unique across Titan plugins +-- It does not need to match the addon id. +local TITAN_PLUGIN = "Starter" +-- NOTE: The convention is TitanPanel<id>Button +local TITAN_BUTTON = "TitanPanel" .. TITAN_PLUGIN .. "Button" +local VERSION = C_AddOns.GetAddOnMetadata(add_on, "Version") + +local TITAN_BAG_THRESHOLD_TABLE = { + Values = { 0.5, 0.75, 0.9 }, + Colors = { HIGHLIGHT_FONT_COLOR, NORMAL_FONT_COLOR, ORANGE_FONT_COLOR, RED_FONT_COLOR }, +} + +-- ******************************** Variables ******************************* +local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) + +local bag_info = { -- itemType : warcraft.wiki.gg/wiki/itemType + [1] = -- Soul bag + { color = { r = 0.96, g = 0.55, b = 0.73 } }, -- PINK + [2] = -- HERBALISM = + { color = { r = 0, g = 1, b = 0 } }, -- GREEN + [3] = -- ENCHANTING = + { color = { r = 0, g = 0, b = 1 } }, -- BLUE + [4] = -- ENGINEERING = + { color = { r = 1, g = 0.49, b = 0.04 } }, -- ORANGE + [5] = -- JEWELCRAFTING = + { color = { r = 1, g = 0, b = 0 } }, -- RED + [6] = -- MINING = + { color = { r = 1, g = 1, b = 1 } }, -- WHITE + [7] = -- LEATHERWORKING = + { color = { r = 0.78, g = 0.61, b = 0.43 } }, -- TAN + [8] = -- INSCRIPTION = + { color = { r = 0.58, g = 0.51, b = 0.79 } }, -- PURPLE + [9] = -- FISHING = + { color = { r = 0.41, g = 0.8, b = 0.94 } }, -- LIGHT_BLUE + [10] = -- COOKING = + { color = { r = 0.96, g = 0.55, b = 0.73 } }, -- PINK + -- These are Classic arrow or bullet bags + [22] = -- Classic arrow + { color = { r = 1, g = .4, b = 0 } }, -- copper + [23] = -- Classic bullet + { color = { r = 0.8, g = 0.8, b = 0.8 } }, -- silver +} + +local trace = false -- true / false Make true when debug output is needed. + +local MIN_BAGS = 0 +local MAX_BAGS = Constants.InventoryConstants.NumBagSlots +local bag_data = {} -- to hold the user bag data + +-- ******************************** Functions ******************************* + +local function IsProfessionBagID(slot) + -- The info needed is available using GetItemInfoInstant; only the bag / item id is required + -- itemType : warcraft.wiki.gg/wiki/itemType + local res = false + local style = 0 + local info, itemId, itemType, itemSubType, itemEquipLoc, itemTexture, classID, subclassID + local inv_id = C_Container.ContainerIDToInventoryID(slot) + + if inv_id == nil then + -- Only works on bag and bank bags NOT backpack! + else + info = GetInventoryItemLink("player", inv_id) + itemId, itemType, itemSubType, itemEquipLoc, itemTexture, classID, subclassID = GetItemInfoInstant(info) + style = subclassID + --[[ +TitanPluginDebug("T isP 0:" + .." "..tostring(slot).."" + .." "..tostring(itemId).."" + .." '"..tostring(itemType).."'" + .." '"..tostring(itemSubType).."'" + .." "..tostring(itemEquipLoc).."" + .." '"..tostring(itemTexture).."'" + .." "..tostring(classID).."" + .." "..tostring(subclassID).."" + ) +--]] + if classID == 1 then -- is a container / bag + if subclassID >= 1 then + -- profession bag of some type [2 - 10] Jan 2024 (DragonFlight / Wrath / Classic Era) + -- OR soul bag [1] + res = true + else + -- is a arrow or bullet; only two options + end + elseif classID == 6 then -- is a 'projectile' holder + res = true + -- is a ammo bag or quiver; only two options + elseif classID == 11 then -- is a 'quiver'; Wrath and CE + res = true + -- is a ammo pouch or quiver; only two options + style = subclassID + 20 -- change to get local color for name + else + -- not a bag + end + end + + if trace then + TitanPluginDebug("T isP:" + .. " " .. tostring(res) .. "" + .. " " .. tostring(style) .. "" + .. " " .. tostring(itemId) .. "" + .. " " .. tostring(classID) .. "" + .. " " .. tostring(subclassID) .. "" + .. " " .. tostring(inv_id) .. "" + ) + end + + return res, style +end + +local function ToggleBags() + if TitanGetVar(TITAN_PLUGIN, "OpenBags") then + ToggleAllBags() + else + end +end + +--[[ +Where the magic happens! +It is good practice - and good memory - to document the 'why' the code does what it does. +And give details that are not obvious to the reader who did not write the code. +--]] +local function GetBagData(id) + --[[ + The bag name is not always available when player entering world + Grabbing the total slots is available though to determine if a bag exists. + The user may see bag name as UNKNOWN until an event triggers a bag check AND the name is available. + --]] + + local total_slots = 0 + local total_free = 0 + local total_used = 0 + + local count_prof = TitanGetVar(TITAN_PLUGIN, "CountProfBagSlots") + + for bag_slot = MIN_BAGS, MAX_BAGS do -- assuming 0 (Backpack) will not be a profession bag + local slots = C_Container.GetContainerNumSlots(bag_slot) + + -- Ensure a blank structure exists + bag_data[bag_slot] = { + has_bag = false, + name = "", + maxi_slots = 0, + free_slots = 0, + used_slots = 0, + style = "", + color = "", + } + + if slots > 0 then + bag_data[bag_slot].has_bag = true + + local bag_name = (C_Container.GetBagName(bag_slot) or UNKNOWN) + bag_data[bag_slot].name = bag_name + bag_data[bag_slot].maxi_slots = slots + + local free = C_Container.GetContainerNumFreeSlots(bag_slot) + local used = slots - free + bag_data[bag_slot].free_slots = free + bag_data[bag_slot].used_slots = used + + -- some info is not known until the name is available... + -- The API requires name to get the bag ID. + local bag_type = "none" + local color = { r = 0, g = 0, b = 0 } -- black (should never be used...) + + -- Jan 2024 : Moved away from named based to an id based. Allows name to come later from server + local is_prof_bag, style = IsProfessionBagID(bag_slot) + --[[ +if trace then +TitanPluginDebug("T Bag...:" +.." "..tostring(bag_slot).."" +.." "..tostring(is_prof_bag).."" +.." '"..tostring(style).."'" +.." "..tostring(itemClassID).."" +.." "..tostring(itemSubClassID).."" +) +end +--]] + if is_prof_bag then + color = bag_info[style].color + bag_type = "profession" + else + bag_type = "normal" + end + bag_data[bag_slot].style = bag_type + bag_data[bag_slot].color = color + + -- add to total + if bag_data[bag_slot].style == "profession" then + if count_prof then + total_slots = total_slots + slots + total_free = total_free + free + total_used = total_used + used + else + -- ignore in totals + end + else + total_slots = total_slots + slots + total_free = total_free + free + total_used = total_used + used + end + else + bag_data[bag_slot].has_bag = false + end + + if trace then + TitanPluginDebug("T info" + .. " " .. tostring(bag_slot) .. "" + .. " ?:" .. tostring(bag_data[bag_slot].has_bag) .. "" + .. " max: " .. tostring(bag_data[bag_slot].maxi_slots) .. "" + .. " used: " .. tostring(bag_data[bag_slot].used_slots) .. "" + .. " free: " .. tostring(bag_data[bag_slot].free_slots) .. "" + .. " type: " .. tostring(bag_data[bag_slot].style) .. "" + .. " count: " .. tostring(count_prof) .. "" + .. " '" .. tostring(bag_data[bag_slot].name) .. "'" + ) + end + end + + bag_data.total_slots = total_slots + bag_data.total_free = total_free + bag_data.total_used = total_used + + local bagText = "" + if (TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots")) then + bagText = format(L["TITAN_BAG_FORMAT"], total_used, total_slots); + else + bagText = format(L["TITAN_BAG_FORMAT"], total_free, total_slots); + end + + local bagRichText = "" + if (TitanGetVar(TITAN_PLUGIN, "ShowColoredText")) then + local color = "" + color = TitanUtils_GetThresholdColor(TITAN_BAG_THRESHOLD_TABLE, total_used / total_slots); + bagRichText = TitanUtils_GetColoredText(bagText, color); + else + bagRichText = TitanUtils_GetHighlightText(bagText); + end + + bagRichText = + bagRichText --..bagRichTextProf[1]..bagRichTextProf[2]..bagRichTextProf[3]..bagRichTextProf[4]..bagRichTextProf[5]; + + return L["TITAN_BAG_BUTTON_LABEL"], bagRichText +end + +local function CreateMenu() + if trace then + TitanPluginDebug("TS event" + .. " " .. tostring(TitanPanelRightClickMenu_GetDropdownLevel()) .. "" + .. " '" .. tostring(TitanPanelRightClickMenu_GetDropdMenuValue()) .. "'" + ) + end + local info = {} + -- level 2 + if TitanPanelRightClickMenu_GetDropdownLevel() == 2 then + if TitanPanelRightClickMenu_GetDropdMenuValue() == "Options" then + TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_OPTIONS"], TitanPanelRightClickMenu_GetDropdownLevel()) + info = {}; + info.text = L["TITAN_BAG_MENU_SHOW_USED_SLOTS"]; + info.func = function() + TitanSetVar(TITAN_PLUGIN, "ShowUsedSlots", 1); + TitanPanelButton_UpdateButton(TITAN_PLUGIN); + end + info.checked = TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots"); + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_BAG_MENU_SHOW_AVAILABLE_SLOTS"]; + info.func = function() + TitanSetVar(TITAN_PLUGIN, "ShowUsedSlots", nil); + TitanPanelButton_UpdateButton(TITAN_PLUGIN); + end + info.checked = TitanUtils_Toggle(TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots")); + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_BAG_MENU_SHOW_DETAILED"]; + info.func = function() + TitanToggleVar(TITAN_PLUGIN, "ShowDetailedInfo"); + end + info.checked = TitanGetVar(TITAN_PLUGIN, "ShowDetailedInfo"); + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + info = {}; + info.text = L["TITAN_BAG_MENU_OPEN_BAGS"] + info.func = function() + TitanToggleVar(TITAN_PLUGIN, "OpenBags") + end + info.checked = TitanGetVar(TITAN_PLUGIN, "OpenBags"); + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + end + return + end + + -- level 1 + TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_PLUGIN].menuText); + + info = {}; + info.notCheckable = true + info.text = L["TITAN_PANEL_OPTIONS"]; + info.value = "Options" + info.hasArrow = 1; + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + TitanPanelRightClickMenu_AddSpacer(); + info = {}; + info.text = L["TITAN_BAG_MENU_IGNORE_PROF_BAGS_SLOTS"]; + info.func = function() + TitanToggleVar(TITAN_PLUGIN, "CountProfBagSlots"); + TitanPanelButton_UpdateButton(TITAN_PLUGIN); + end + info.checked = not TitanGetVar(TITAN_PLUGIN, "CountProfBagSlots") + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + + TitanPanelRightClickMenu_AddControlVars(TITAN_PLUGIN) +end + +local function GetButtonText(id) + local strA, strB = GetBagData(id) + return strA, strB +end + +local function GetTooltipText() + local returnstring = ""; + + if trace then + TitanPluginDebug("TS tool tip" + .. " detail " .. tostring(TitanGetVar(TITAN_PLUGIN, "ShowDetailedInfo")) .. "" + .. " used " .. tostring(TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots")) .. "" + .. " prof " .. tostring(TitanGetVar(TITAN_PLUGIN, "CountProfBagSlots")) .. "" + .. " color " .. tostring(TitanGetVar(TITAN_PLUGIN, "ShowColoredText")) .. "" + .. " open " .. tostring(TitanGetVar(TITAN_PLUGIN, "OpenBags")) .. "" + ) + end + + if TitanGetVar(TITAN_PLUGIN, "ShowDetailedInfo") then + returnstring = "\n"; + if TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots") then + returnstring = returnstring .. TitanUtils_GetNormalText(L["TITAN_BAG_MENU_TEXT"]) + .. ":\t" .. TitanUtils_GetNormalText(L["TITAN_BAG_USED_SLOTS"]) .. ":\n"; + else + returnstring = returnstring .. TitanUtils_GetNormalText(L["TITAN_BAG_MENU_TEXT"]) + .. ":\t" .. TitanUtils_GetNormalText(L["TITAN_BAG_FREE_SLOTS"]) .. ":\n"; + end + + for bag = MIN_BAGS, MAX_BAGS do + local bagText, bagRichText, color; + --[[ +TitanPluginDebug("T Bag: TT" +.." "..tostring(bag).."" +.." "..tostring(bag_data[bag].has_bag).."" +.." "..tostring(bag_data[bag].name).."" +.." "..tostring(bag_data[bag].maxi_slots).."" +.." "..tostring(bag_data[bag].used_slots).."" +.." "..tostring(bag_data[bag].free_slots).."" +) +--]] + if bag_data[bag] and bag_data[bag].has_bag then + if (TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots")) then + bagText = format(L["TITAN_BAG_FORMAT"], bag_data[bag].used_slots, bag_data[bag].maxi_slots); + else + bagText = format(L["TITAN_BAG_FORMAT"], bag_data[bag].free_slots, bag_data[bag].maxi_slots); + end + + if bag_data[bag].style == "profession" + and not TitanGetVar(TITAN_PLUGIN, "CountProfBagSlots") + then + bagRichText = "|cffa0a0a0" .. bagText .. "|r" -- show as gray + elseif (TitanGetVar(TITAN_PLUGIN, "ShowColoredText")) then + if bag_data[bag].maxi_slots == 0 then + color = TitanUtils_GetThresholdColor(TITAN_BAG_THRESHOLD_TABLE, 1); + else + color = TitanUtils_GetThresholdColor(TITAN_BAG_THRESHOLD_TABLE, + bag_data[bag].used_slots / bag_data[bag].maxi_slots); + end + bagRichText = TitanUtils_GetColoredText(bagText, color); + else + -- use without color + bagRichText = TitanUtils_GetHighlightText(bagText); + end + + local name_text = bag_data[bag].name + if bag_data[bag].style == "profession" + then + name_text = TitanUtils_GetColoredText(name_text, bag_data[bag].color) + else + -- use without color + end + returnstring = returnstring .. name_text .. "\t" .. bagRichText .. "\n"; + else + returnstring = returnstring .. NONE .. "\n"; + end + end + returnstring = returnstring .. "\n"; + end + + if TitanGetVar(TITAN_PLUGIN, "ShowUsedSlots") then + local xofy = "" .. tostring(bag_data.total_used) + .. "/" .. tostring(bag_data.total_slots) .. "\n" + returnstring = returnstring .. TitanUtils_GetNormalText(L["TITAN_BAG_USED_SLOTS"]) + .. ":\t" .. xofy + else + local xofy = "" .. tostring(bag_data.total_free) + .. "/" .. tostring(bag_data.total_slots) .. "\n" + returnstring = returnstring .. TitanUtils_GetNormalText(L["TITAN_BAG_USED_SLOTS"]) + .. ":\t" .. xofy + end + + -- Add Hint + if TitanGetVar(TITAN_PLUGIN, "OpenBags") then + returnstring = returnstring .. TitanUtils_GetGreenText(L["TITAN_BAG_TOOLTIP_HINTS"]) + else + -- nop + end + return returnstring +end + +local function OnLoad(self) + local notes = "" + .. "Adds bag and free slot information to Titan Panel.\n" + -- .."- xxx.\n" + self.registry = { + id = TITAN_PLUGIN, + category = "Information", + version = VERSION, + menuText = L["TITAN_BAG_MENU_TEXT"], + menuTextFunction = CreateMenu, + buttonTextFunction = GetButtonText, + tooltipTitle = L["TITAN_BAG_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + icon = artwork_path .. "TitanStarter", + iconWidth = 16, + notes = notes, + controlVariables = { + ShowIcon = true, + ShowLabelText = true, + ShowColoredText = true, + DisplayOnRightSide = true, + }, + savedVariables = { + ShowUsedSlots = 1, + ShowDetailedInfo = false, + CountProfBagSlots = false, + ShowIcon = 1, + ShowLabelText = 1, + ShowColoredText = 1, + DisplayOnRightSide = false, + OpenBags = false, + OpenBagsClassic = "new_install", + } + }; + if TITAN_ID == "Titan" then -- 10.* / Retail + -- for taint issue + self.registry.savedVariables.OpenBags = false + else + -- does not taint so default to open bags on click + self.registry.savedVariables.OpenBags = true + end + + self:RegisterEvent("PLAYER_ENTERING_WORLD"); + + if trace then + TitanPluginDebug("TS OnLoad" + .. " complete" + ) + end +end + +local function OnEvent(self, event, a1, a2, ...) + if trace then + TitanPluginDebug("TS event" + .. " " .. tostring(event) .. "" + .. " " .. tostring(a1) .. "" + ) + end + + if event == "PLAYER_ENTERING_WORLD" then + if a1 == true and TITAN_ID == "Titan" then -- 10.* / Retail + -- initial login + + TitanPrint(L["TITAN_BAG_TAINT_TEXT"], "warning") + else -- either Classic version + local open = TitanGetVar(TITAN_PLUGIN, "OpenBagsClassic") + if open == "new_install" then -- + -- set to default behavior of opening bag on left click + TitanSetVar(TITAN_PLUGIN, "OpenBags", true) + TitanSetVar(TITAN_PLUGIN, "OpenBagsClassic", "processed") -- don't do again + else + -- already processed... + end + end + end + + if event == "BAG_UPDATE" then + -- update the plugin text + TitanPanelButton_UpdateButton(TITAN_PLUGIN); + end +end + +local function OnClick(self, button) + if trace then + TitanPluginDebug("TS click" + .. " " .. tostring(button) .. "" + ) + end + + if (button == "LeftButton") then + ToggleBags(); + end +end + +local function OnShow(self) + if trace then + TitanPluginDebug("TS OnShow" + .. " register" + ) + end + -- Register for bag updates and update the plugin text + self:RegisterEvent("BAG_UPDATE") + TitanPanelButton_UpdateButton(TITAN_PLUGIN); +end + +local function OnHide(self) + if trace then + TitanPluginDebug("TS OnShow" + .. " unregister" + ) + end + self:UnregisterEvent("BAG_UPDATE") +end + +-- ====== Create needed frames +local function Create_Frames() + if _G[TITAN_BUTTON] then + return -- if already created + end + + if trace then + TitanPluginDebug("TS frames" + .. " '" .. tostring(TITAN_BUTTON) .. "'" + ) + end + + -- general container frame + local f = CreateFrame("Frame", nil, UIParent) + -- f:Hide() + + -- Titan plugin button + --[[ + The plugin frame is created here. The typical plugin is a 'combo' which includes + - an icon (can be shown or hidden) + - label - value pair where the label can be turned off + There can be multiple label - value pairs; TitanPerformance uses this scheme. + + The frame is 'forever' as are most of WoW game frames. + --]] + local window = CreateFrame("Button", TITAN_BUTTON, f, "TitanPanelComboTemplate") + window:SetFrameStrata("FULLSCREEN") + -- Using SetScript to set "OnLoad" does not work + -- + -- This routine sets the guts of the plugin - the .registry + OnLoad(window); + + --[[ + Below are the frame 'events' that need to be processed. + A couple have Titan routines that ensure the plugin is properly on / off a Titan bar. + + The combined Titan changed design to register for events when the user places the plugin + on the bar (OnShow) and unregister events when the user hids the plugin (OnHide). + This reduces cycles the plugin uses when the user does not want the plugin. + + NOTE: If a Titan bar is hidden, the plugins on it will still run. + NOTE: Titan plugins are NOT child frames!! Meaning plugins are not automatically hidden when the + bar they visible on is hidden! + --]] + window:SetScript("OnShow", function(self) + OnShow(self) + -- This routine ensures the plugin is put where the user requested it. + -- Titan saves the bar the plugin was on. It does not save the relative order. + TitanPanelButton_OnShow(self); + end) + window:SetScript("OnHide", function(self) + OnHide(self) + -- We use the Blizzard frame hide to visually remove the frame + end) + window:SetScript("OnEvent", function(self, event, ...) + -- Handle any events the plugin is interested in + OnEvent(self, event, ...) + end) + window:SetScript("OnClick", function(self, button) + -- Typically this routine handles actions on left click + OnClick(self, button); + -- Typically this routine handles the menu creation on right click + TitanPanelButton_OnClick(self, button); + end) +end + +Create_Frames() -- do the work diff --git a/TitanPlugin/TitanStarter.tga b/TitanPlugin/TitanStarter.tga new file mode 100644 index 0000000..6a7ddda Binary files /dev/null and b/TitanPlugin/TitanStarter.tga differ diff --git a/TitanRegen/TitanClassicRegen.lua b/TitanRegen/TitanClassicRegen.lua deleted file mode 100644 index cb578a4..0000000 --- a/TitanRegen/TitanClassicRegen.lua +++ /dev/null @@ -1,316 +0,0 @@ --- ************************************************************************** --- * TitanClassicRegen.lua --- * --- * By: TitanMod, Dark Imakuni, Adsertor and the Titan Panel Development Team --- ************************************************************************** - --- ******************************** Constants ******************************* -local TITAN_REGEN_ID = "Regen" -local TITAN_REGEN_HP_FORMAT = "%d"; -local TITAN_REGEN_HP_FORMAT_PERCENT = "%.2f"; -local TITAN_REGEN_MP_FORMAT = "%d"; -local TITAN_REGEN_MP_FORMAT_PERCENT = "%.2f"; -local updateTable = {TITAN_REGEN_ID, TITAN_PANEL_UPDATE_ALL}; --- ******************************** Variables ******************************* -local TITAN_RegenCurrHealth = 0; -local TITAN_RegenCurrMana = 0; -local TITAN_RegenMP = 0; -local TITAN_RegenHP = 0; -local TITAN_RegenCheckedManaState = 0; -local TITAN_RegenMaxHPRate = 0; -local TITAN_RegenMinHPRate = 9999; -local TITAN_RegenMaxMPRate = 0; -local TITAN_RegenMinMPRate = 9999; -local TITAN_RegenMPDuringCombat = 0; -local TITAN_RegenMPCombatTrack = 0; -local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) --- ******************************** Functions ******************************* - --- ************************************************************************** --- NAME : TitanRegenTemp_GetColoredTextRGB(text, r, g, b) --- DESC : Define colors for colored text and display --- VARS : text = text to display, r = red value, g = green value, b = blue value --- ************************************************************************** -local function TitanRegenTemp_GetColoredTextRGB(text, r, g, b) - if (text and r and g and b) then - local redColorCode = format("%02x", r * 255); - local greenColorCode = format("%02x", g * 255); - local blueColorCode = format("%02x", b * 255); - local colorCode = "|cff"..redColorCode..greenColorCode..blueColorCode; - return colorCode..text..FONT_COLOR_CODE_CLOSE; - end -end - --- ************************************************************************** --- NAME : TitanPanelRegenButton_OnLoad() --- DESC : Registers the plugin upon it loading --- ************************************************************************** -function TitanPanelRegenButton_OnLoad(self) - self.registry = { - id = TITAN_REGEN_ID, - category = "Built-ins", - version = TITAN_VERSION, - menuText = L["TITAN_REGEN_MENU_TEXT"], - buttonTextFunction = "TitanPanelRegenButton_GetButtonText", - tooltipTitle = L["TITAN_REGEN_MENU_TOOLTIP_TITLE"], - tooltipTextFunction = "TitanPanelRegenButton_GetTooltipText", - controlVariables = { - ShowIcon = false, - ShowLabelText = true, - ShowRegularText = false, - ShowColoredText = false, - DisplayOnRightSide = true, - }, - savedVariables = { - ShowLabelText = 1, - ShowHPRegen = 1, - ShowPercentage = false, - ShowColoredText = false, - DisplayOnRightSide = false, - } - }; - - self:RegisterEvent("UNIT_HEALTH"); - self:RegisterEvent("UNIT_POWER_UPDATE"); - self:RegisterEvent("PLAYER_ENTERING_WORLD"); - self:RegisterEvent("PLAYER_REGEN_DISABLED"); - self:RegisterEvent("PLAYER_REGEN_ENABLED"); -end - --- ************************************************************************** --- NAME : TitanPanelXPButton_OnEvent --- DESC : Parse events registered to addon and act on them --- ************************************************************************** -function TitanPanelRegenButton_OnEvent(self, event, a1, a2, ...) - if ( event == "PLAYER_ENTERING_WORLD") then - end - - if ( event == "PLAYER_REGEN_DISABLED") then - TITAN_RegenMPDuringCombat = 0; - TITAN_RegenMPCombatTrack = 1; - end - - if ( event == "PLAYER_REGEN_ENABLED") then - TITAN_RegenMPCombatTrack = 0; - end - - local currHealth = 0; - local currMana = 0; - local runUpdate = 0; - - if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then - if ( event == "UNIT_HEALTH" and a1 == "player") then - currHealth = UnitHealth("player"); - runUpdate = 1; - if ( currHealth > TITAN_RegenCurrHealth and TITAN_RegenCurrHealth ~= 0 ) then - TITAN_RegenHP = currHealth-TITAN_RegenCurrHealth; - - if (TITAN_RegenHP > TITAN_RegenMaxHPRate) then - TITAN_RegenMaxHPRate = TITAN_RegenHP; - end - if (TITAN_RegenHP < TITAN_RegenMinHPRate or TITAN_RegenMinHPRate == 9999) then - TITAN_RegenMinHPRate = TITAN_RegenHP; - end - end - TITAN_RegenCurrHealth = currHealth; - end - end - - local pval, ptype = UnitPowerType("player") - if (pval == 0) then -- Mana - if ( event == "UNIT_POWER_UPDATE" and a1 == "player" and a2 == "MANA") then - currMana = UnitPower("player"); - runUpdate = 1; - if ( currMana > TITAN_RegenCurrMana and TITAN_RegenCurrMana ~= 0 ) then - TITAN_RegenMP = currMana-TITAN_RegenCurrMana; - - if (TITAN_RegenMPCombatTrack == 1) then - TITAN_RegenMPDuringCombat = TITAN_RegenMPDuringCombat + TITAN_RegenMP; - end - - if (TITAN_RegenMP > TITAN_RegenMaxMPRate) then - TITAN_RegenMaxMPRate = TITAN_RegenMP; - end - if (TITAN_RegenMP < TITAN_RegenMinMPRate or TITAN_RegenMinMPRate == 9999) then - TITAN_RegenMinMPRate = TITAN_RegenMP; - end - end - TITAN_RegenCurrMana = currMana; - end - end - - if (runUpdate == 1) then - TitanPanelPluginHandle_OnUpdate(updateTable) - end -end - --- ************************************************************************** --- NAME : TitanPanelRegenButton_GetButtonText(id) --- DESC : Calculate regeneration logic for button text --- VARS : id = button ID --- ************************************************************************** -function TitanPanelRegenButton_GetButtonText(id) - local labelTextHP = ""; - local valueTextHP = ""; - local labelTextMP = ""; - local valueTextMP = ""; - local OutputStr = ""; - - if UnitHealth("player") == UnitHealthMax("player") then - TITAN_RegenHP = 0; - end - if UnitPower("player") == UnitPowerMax("player", 0) then - TITAN_RegenMP = 0; - end - - -- safety in case both are off, then cant ever turn em on - if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then - TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1); - end - - if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then - labelTextHP = L["TITAN_REGEN_BUTTON_TEXT_HP"]; - if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then - valueTextHP = format(TITAN_REGEN_HP_FORMAT_PERCENT, (TITAN_RegenHP/UnitHealthMax("player"))*100); - else - valueTextHP = format(TITAN_REGEN_HP_FORMAT, TITAN_RegenHP); - end - if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then - valueTextHP = TitanUtils_GetGreenText(valueTextHP); - else - valueTextHP = TitanUtils_GetHighlightText(valueTextHP); - end - end - - local pval, ptype = UnitPowerType("player") - if (pval == 0) then -- Mana only - labelTextMP = L["TITAN_REGEN_BUTTON_TEXT_MP"]; - if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then - valueTextMP = format(TITAN_REGEN_MP_FORMAT_PERCENT, (TITAN_RegenMP/UnitPowerMax("player", 0))*100); - else - valueTextMP = format(TITAN_REGEN_MP_FORMAT, TITAN_RegenMP); - end - if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then - valueTextMP = TitanRegenTemp_GetColoredTextRGB(valueTextMP, 0.0, 0.0, 1.0); - else - valueTextMP = TitanUtils_GetHighlightText(valueTextMP); - end - end - - -- supports turning off labels - return labelTextHP, valueTextHP, labelTextMP, valueTextMP; -end - --- ************************************************************************** --- NAME : TitanPanelRegenButton_GetTooltipText() --- DESC : Display tooltip text --- ************************************************************************** -function TitanPanelRegenButton_GetTooltipText() - local minHP = TITAN_RegenMinHPRate; - local minMP = TITAN_RegenMinMPRate; - - if minHP == 9999 then minHP = 0 end; - if minMP == 9999 then minMP = 0 end; - - local txt = "" - - txt = txt.. - format(L["TITAN_REGEN_TOOLTIP1"], UnitHealth("player"),UnitHealthMax("player"),UnitHealthMax("player")-UnitHealth("player")).."\n".. - format(L["TITAN_REGEN_TOOLTIP3"], TITAN_RegenMaxHPRate).."\n".. - format(L["TITAN_REGEN_TOOLTIP4"], minHP).."\n" - - local pval, ptype = UnitPowerType("player") - if (pval == 0) then - local regenPercent = 0 - regenPercent = (TITAN_RegenMPDuringCombat/UnitPowerMax("player", 0))*100; - - txt = txt.."\n".. - format(L["TITAN_REGEN_TOOLTIP2"], UnitPower("player"),UnitPowerMax("player", 0),UnitPowerMax("player", 0)-UnitPower("player")).."\n".. - format(L["TITAN_REGEN_TOOLTIP5"], TITAN_RegenMaxMPRate).."\n".. - format(L["TITAN_REGEN_TOOLTIP6"], minMP).."\n".. - format(L["TITAN_REGEN_TOOLTIP7"], TITAN_RegenMPDuringCombat, regenPercent).."\n" - else - -- L["TITAN_REGEN_TOOLTIP2"] = "Mana: \t"..GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." ("..RED_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE..")"; - POWER = GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE - txt = txt.."\n".. - ptype.." \t".. - format(POWER, UnitPower("player"),UnitPowerMax("player", pval)).."\n" - -- Energy : The formula is (energyRegen)*(1+hastePercent) - end - - return txt -end - --- ************************************************************************** --- NAME : TitanPanelRightClickMenu_PrepareTitanRegenMenu() --- DESC : Display rightclick menu options --- ************************************************************************** -function TitanPanelRightClickMenu_PrepareRegenMenu() - local id = TITAN_REGEN_ID; - local info; - - TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText); - - info = {}; - info.text = L["TITAN_REGEN_MENU_HP"]; - info.func = TitanRegen_ShowHPRegen; - info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen"); - L_UIDropDownMenu_AddButton(info); - - info = {}; - info.text = L["TITAN_REGEN_MENU_PERCENT"]; - info.func = TitanRegen_ShowPercentage; - info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowPercentage"); - L_UIDropDownMenu_AddButton(info); - - TitanPanelRightClickMenu_AddSpacer(); - - info = {}; - info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"]; - info.func = TitanRegen_ShowColoredText; - info.checked = TitanGetVar(TITAN_REGEN_ID, "ShowColoredText"); - L_UIDropDownMenu_AddButton(info); - - TitanPanelRightClickMenu_AddToggleLabelText(TITAN_REGEN_ID); - TitanPanelRightClickMenu_AddToggleRightSide(TITAN_REGEN_ID); - TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], id, TITAN_PANEL_MENU_FUNC_HIDE); -end - --- ************************************************************************** --- NAME : TitanRegen_UpdateSettings() --- DESC : Update button text on setting change --- ************************************************************************** -function TitanRegen_UpdateSettings() - -- safety in case both are off, then cant ever turn em on - if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then - TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1); - end - TitanPanelButton_UpdateButton(TITAN_REGEN_ID); -end - --- ************************************************************************** --- NAME : TitanRegen_ShowHPRegen() --- DESC : Show HP regeneration option on button --- ************************************************************************** -function TitanRegen_ShowHPRegen() - TitanToggleVar(TITAN_REGEN_ID, "ShowHPRegen"); - TitanRegen_UpdateSettings(); -end - --- ************************************************************************** --- NAME : TitanRegen_ShowPercentage() --- DESC : Show values as percentage option on button --- ************************************************************************** -function TitanRegen_ShowPercentage() - TitanToggleVar(TITAN_REGEN_ID, "ShowPercentage"); - TitanRegen_UpdateSettings(); -end - --- ************************************************************************** --- NAME : TitanRegen_ShowColoredText() --- DESC : Show colored text option on button --- ************************************************************************** -function TitanRegen_ShowColoredText() - TitanToggleVar(TITAN_REGEN_ID, "ShowColoredText"); - TitanRegen_UpdateSettings(); -end \ No newline at end of file diff --git a/TitanRegen/TitanClassicRegen.xml b/TitanRegen/TitanClassicRegen.xml deleted file mode 100644 index aa88003..0000000 --- a/TitanRegen/TitanClassicRegen.xml +++ /dev/null @@ -1,19 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ -..\FrameXML\UI.xsd"> - <Script file="TitanClassicRegen.lua"/> - <Frame parent="UIParent"> - <Frames> - <Button name="TitanPanelRegenButton" inherits="TitanPanelTextTemplate" frameStrata="FULLSCREEN" toplevel="true"> - <Scripts> - <OnLoad> - TitanPanelRegenButton_OnLoad(self); - TitanPanelButton_OnLoad(self); - </OnLoad> - <OnEvent> - TitanPanelRegenButton_OnEvent(self, event, ...); - </OnEvent> - </Scripts> - </Button> - </Frames> - </Frame> -</Ui> \ No newline at end of file diff --git a/TitanRepair/TitanRepair_Mainline.toc b/TitanRepair/TitanRepair_Mainline.toc index 8477ee7..e3fb835 100644 --- a/TitanRepair/TitanRepair_Mainline.toc +++ b/TitanRepair/TitanRepair_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanRepair\TitanRepair ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume_Mainline.toc b/TitanVolume/TitanVolume_Mainline.toc index 052f58d..e31eaf2 100644 --- a/TitanVolume/TitanVolume_Mainline.toc +++ b/TitanVolume/TitanVolume_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\AddOns\TitanVolume\Artwork\TitanVolumeHigh ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP_Mainline.toc b/TitanXP/TitanXP_Mainline.toc index ccfebab..1b18ad6 100644 --- a/TitanXP/TitanXP_Mainline.toc +++ b/TitanXP/TitanXP_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100205 ## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.6|r ## Version: 8.0.6 +## IconTexture: Interface\Icons\xp_icon ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: