Thread Tools Display Modes
04-13-24, 08:06 AM   #21
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Yes the first part sets the panel up as part of the settings system - you just need to add your controls to it as you did.

The second part, will open to your addon page ( all going well - it did for me ).


All you have to do now is make sure your addon does the rest of the stuff you wanted it to, and if you were saving stuff for future play sessions, you need to use the saved variables table to store it.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
04-13-24, 08:19 AM   #22
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Look at what I changed in the files, they were copies of what you posted. So, you should see what I changed and why I changed it because of the notes I put in there.

If it doesn't work after you have added what you think is all that needs to be added, check again in case you missed something. Even doing something in the wrong order can affect the output. Names of frames and tables can affect things as well.

I have set the files up so that they are separate files talking to each other. You can add another file that does the main stuff in the addon and have the settings panel talk to it.

For example:

QuestCompletionFrame.lua
SettingsPanel.lua
MinimapButton.lua

QuestCompletionFrame.lua could hold all your quest completion code and not talk to the settings or the minimap button.

SettingsPanel needs to know about the QuestCompletionFrame as you have it showing and hiding the frame when the check boxes are clicked.

MinimapButton.lua needs to know about the SettingsPanel to open it up and show the controls.


Now, the question is, if you were going to use the SavedVariablesTable for session to session access to the settings. Then you can either have that set up in its own file and loaded before QuestCompletionFrame or you can have QuestCompletionFrame set those variables up, the game handles loading and saving them when you log in and out. All you have to do is make sure that it exists.

For example:
If you had a SavedVariablesTable called .. ZTVCurrentSettings then you would do this to initialise it, ready for use.
ZTVCurrentSettings = ZTVCurrentSettings or {}
This makes sure that any existing values are kept, or it creates a new table because there are no existing values.
You can use this at the top of the file that first needs access to it.

In either case it needs to be sorted out before you get and set them in SettingsPanel or use them in QuestCompletionFrame. Like I said, order is everything.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
04-14-24, 10:00 PM   #23
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
As I understand it, the line in the "AddonName.tok." file is responsible for saving the position of the "icon on the minimap".
Lua Code:
  1. ## SavedVariables: TestingAddonSettingsData
And the line in the file
Lua Code:
  1. icon:Register(addonName, minimapIcon, TestingAddonSettingsData) -- Replace MyAddonDB with your saved variables table name
  2. end
Shows what needs to be saved.

Then why doesn’t my “minimap icon” save its position after exiting the game?
  Reply With Quote
04-15-24, 01:56 AM   #24
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
That I don't know as I never really used the minimap icon.

bugsack uses it but it doesn't save anything to it apart from whether it shows it on the minimap or not.


Okay, looking at a few query posts about the icon .. and a look in the libdbicon source file itself I can see that they have set aside a table of values for saving the minimap values if the minimap icon addon chooses to do so.

Lua Code:
  1. minimapIcon = {
  2.             hide = false,
  3.             lock = false,
  4.             minimapPos = 205,
  5.             radius = 80
  6.         }

Now looking at
Lua Code:
  1. ## SavedVariables: TestingAddonSettingsData
Lua Code:
  1. icon:Register(addonName, minimapIcon, TestingAddonSettingsData.minimapIcon)

Would be the better set up allowing your addon to have other settings for the rest of the addon and the minimapIcon section for the minimap icon part.
In theory the libdbicon stuff should handle the saving of it, as long as you set it up.
So, lets give that a whirl on my test example I made before to see if my theory works out.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
04-15-24, 02:30 AM   #25
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Well my test addon doesn't save it .. but, testing bugsack and it does. So something in its code must be saving it in some form.

edit: Okay figured it out ..

Files Changed:
TestAddonSettings.toc
File changed to have 2 saved variable tables, one for the addon data and one for the minimap icon data
Lua Code:
  1. ## Interface: 100207
  2. ## Title: TestAddonSettings
  3. ## Author: Xrystal (c) 2024  All Rights Reserved
  4. ## Version: 0.0.1.001
  5. ## Notes: Testing Addon Settings
  6. ## RequiredDeps:
  7. ## OptionalDeps:
  8. ## DefaultState: Enabled
  9. ## LoadOnDemand: 0
  10. ## SavedVariables: TestAddonSettingsData, TestAddonSettingsData_MinimapIcon
  11. ## SavedVariablesPerCharacter:
  12.  
  13. SettingsPanel.lua
  14. MinimapButton.lua
  15. Code.lua


MinimapButton.lua
-- Redesigned file to match bugsacks segmented approach ( in case that was the solution ). It looks tidier though so kept it
-- Made sure Saved Variable tables were initialised with default values
-- MinimapButton's saved variable data was put in its own table, not a sub table same as bugsack
-- The MinimapButton was also initialised on player login - of course this would be when the saved variables would have been loaded up - this might have been all we needed to do.

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Main Addon SavedVariable Table
  4. TestAddonSettingsData = TestAddonSettingsData or {}
  5.  
  6. -- Minimap Icon SavedVariable Table
  7. TestAddonSettingsData_MinimapIcon = TestAddonSettingsData_MinimapIcon or {}
  8.  
  9. -- Initialise Minimap Icon values
  10. -- Use settings panel to allow player to change these
  11. -- When you move the minimap icon around the minimap the ldb library updates the respective MinimapIcon saved variable table
  12. -- The MinimapIcon Saved Variable Data has to be its own table, not a sub table
  13. TestAddonSettingsData_MinimapIcon.hide = false
  14. TestAddonSettingsData_MinimapIcon.lock = false            
  15. TestAddonSettingsData_MinimapIcon.minimapPos = 120
  16. TestAddonSettingsData_MinimapIcon.radius = 80
  17.  
  18. -- Make sure library exists
  19. local ldb = LibStub:GetLibrary("LibDataBroker-1.1", true)
  20. if not ldb then return end
  21.  
  22. -- Create Plugin
  23. local plugin = ldb:NewDataObject(addonName, {
  24.     type = "data source",
  25.     text = addonName,
  26.     icon = "Interface\\BUTTONS\\UI-GroupLoot-Dice-Up", -- Replace with path to your icon
  27. })
  28.  
  29. -- Handle OnClick functionality
  30. function plugin.OnClick(self, button)
  31.     if button == "LeftButton" then
  32.         Settings.OpenToCategory(addon.category:GetID()) -- Open or close the options panel
  33.     end
  34. end
  35.  
  36. -- Handle OnTooltipShow functionality
  37. function plugin.OnTooltipShow(tooltip)
  38.     tooltip:SetText(addonName)
  39.     tooltip:AddLine("Click to open options")
  40.     tooltip:Show()
  41. end
  42.    
  43. -- Initialise Minimap Icon on Player Login    
  44. local f = CreateFrame("Frame")
  45. f:SetScript("OnEvent", function()
  46.     local icon = LibStub("LibDBIcon-1.0", true)
  47.     if not icon then return end
  48.     icon:Register(addonName, plugin, TestAddonSettingsData_MinimapIcon)
  49. end)
  50. f:RegisterEvent("PLAYER_LOGIN")

Anyway, after these changes, the minimap button now retains its location successfully.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 04-15-24 at 03:01 AM.
  Reply With Quote
04-15-24, 10:27 PM   #26
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Thank you very much, you helped me a lot. This is a great forum and I will recommend it to everyone.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Button on the minimap


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off