Thread Tools Display Modes
04-11-24, 05:13 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
Button on the minimap

Hi all. I created a button on the minimap. But I can’t get it to open another LUA file.

the button itself (triggered by LMB).

Lua Code:
  1. local addonName, addon = ...
  2. local addonName = "MyAddon"
  3. local L = {} -- Localization table (if needed)
  4.  
  5. -- Check if the addon object is already registered
  6. if not LibStub("LibDBIcon-1.0", true):GetMinimapButton(addonName) then
  7.     -- Create the minimap icon
  8.     local icon = LibStub("LibDBIcon-1.0")
  9.     local minimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
  10.         type = "data source",
  11.         text = addonName,
  12.         icon = "Interface\\AddOns\\TEST_ADDON\\Icons\\goblin", -- Replace with path to your icon
  13.         OnClick = function(_, button)
  14.             if button == "LeftButton" then
  15.                 MyAddonOptionsPanel_Toggle() -- Open or close the options panel
  16.             end
  17.         end,
  18.         OnTooltipShow = function(tooltip)
  19.             tooltip:SetText(addonName)
  20.             tooltip:AddLine("Click to open options")
  21.             tooltip:Show()
  22.         end,
  23.     })
  24.  
  25.     -- Register the minimap icon
  26.     icon:Register(addonName, minimapIcon, MyAddonOptionsPanelDB) -- Replace MyAddonDB with your saved variables table name
  27. end
  28.  
  29. -- Define the function to toggle the options panel
  30. function MyAddonOptionsPanel_Toggle()
  31.     -- Add code to open or close the options panel here
  32.     print("Toggle options panel")
  33. end


The frame that the button should open

Lua Code:
  1. local panel = CreateFrame("Frame", "MyAddonOptionsPanel", InterfaceOptionsFrame)
  Reply With Quote
04-11-24, 06:11 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Your toggle function only displays text in the chat frame - did you check to see if it appeared ?
Lua Code:
  1. function MyAddonOptionsPanel_Toggle()
  2.     -- Add code to open or close the options panel here
  3.     print("Toggle options panel")
  4. end

If that text appeared then it is working, you just need to add your code to manage the opening and closing of the panel.
__________________


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-11-24, 07:51 AM   #3
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
Originally Posted by Xrystal View Post
Your toggle function only displays text in the chat frame - did you check to see if it appeared ?
Lua Code:
  1. function MyAddonOptionsPanel_Toggle()
  2.     -- Add code to open or close the options panel here
  3.     print("Toggle options panel")
  4. end

If that text appeared then it is working, you just need to add your code to manage the opening and closing of the panel.
Hello. Yes, the inscription "Toggle options panel" appears. How to add? I'm new to writing addons for wow.
  Reply With Quote
04-11-24, 10:37 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
I've personally not used the Wow Options system, but I would try to use the example in the wiki page below. If you were aiming to have a panel inside the wow options screen like several addons have done before .. you might want to see how close you are to the example in there.

https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel

Take note of the known bug mentioned in the small print at the bottom.
__________________


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-11-24, 11:50 PM   #5
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131


You gave an example of creating a panel. I was looking for how to open it through the “icon on the minimap”.
  Reply With Quote
04-12-24, 03:09 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Okay.

Which one of these were you hoping to implement ? Each one will involve different set up and calls to show up.

1. Display Panel in pre Dragonflight InterfaceOptionsFrame

Use example in https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel to make sure your panel is correctly set up to work with the Interface Options Addons Panel system. And then use

`InterfaceOptionsFrame_OpenToCategory(panel)` to open the frame when you click your button ( you might have to call it twice for it to work as per the comment in the small print at the bottom. It will have a close button to close it again - no need to toggle.


2. Display your own custom panel on the main screen like any other frame you create.

In this case, make sure your frame has a background/backdrop and any other controls it needs. And then you can use the following function to toggle your panel to show or hide based on its current status when you click your button.

Example Code:
Lua Code:
  1. local function TogglePanel(panel)
  2.     if panel:IsShown() then
  3.        panel:Hide()
  4.    else
  5.       panel:Show()
  6.    end
  7. end function

But you would have to change this
Lua Code:
  1. local panel = CreateFrame("Frame", "MyAddonOptionsPanel", InterfaceOptionsFrame)
  2. -- Rest of your panel creation code

To this
Lua Code:
  1. local panel = CreateFrame("Frame", "MyAddonOptionsPanel",UIParent)
  2. -- Rest of your panel creation code

3. Have your panel show up as part of the Dragonflight SettingsPanel

https://warcraft.wiki.gg/wiki/Patch_10.0.0/API_changes gives you some sort of example on how to set up your frame to be part of the settings panel. But not an example on how to jump to your panel.

There is a similar Settings.OpenToCategory() function which Fizzle points to in https://www.wowinterface.com/forums/...11&postcount=2 but it only goes to the AddOns tab and not a particular AddOns panel.
__________________


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-12-24, 04:47 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Just copied the Dragonflight Settings example and tested a button click to open and Fizzles code works. It won't go straight to your addon page, but it will go to the addon page list section.

This was the code I used:
Lua Code:
  1. local addonName, addonNS = ...
  2.  
  3. XSettings_PanelTest_SavedVariables = {}
  4. local function OnSettingChanged(_, setting, value)
  5.     local variable = setting:GetVariable()
  6.     XSettings_PanelTest_SavedVariables[variable] = value
  7. end
  8.  
  9. local category = Settings.RegisterVerticalLayoutCategory("XSettings_PanelTest")
  10.  
  11. do
  12.     local variable = "toggle"
  13.     local name = "Test Checkbox"
  14.     local tooltip = "This is a tooltip for the checkbox."
  15.     local defaultValue = false
  16.  
  17.     local setting = Settings.RegisterAddOnSetting(category, name, variable, type(defaultValue), defaultValue)
  18.     Settings.CreateCheckBox(category, setting, tooltip)
  19.     Settings.SetOnValueChangedCallback(variable, OnSettingChanged)
  20. end
  21.  
  22. do
  23.     local variable = "slider"
  24.     local name = "Test Slider"
  25.     local tooltip = "This is a tooltip for the slider."
  26.     local defaultValue = 180
  27.     local minValue = 90
  28.     local maxValue = 360
  29.     local step = 10
  30.  
  31.     local setting = Settings.RegisterAddOnSetting(category, name, variable, type(defaultValue), defaultValue)
  32.     local options = Settings.CreateSliderOptions(minValue, maxValue, step)
  33.     options:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
  34.     Settings.CreateSlider(category, setting, options, tooltip)
  35.     Settings.SetOnValueChangedCallback(variable, OnSettingChanged)
  36. end
  37.  
  38. do
  39.     local variable = "selection"
  40.     local defaultValue = 2  -- Corresponds to "Option 2" below.
  41.     local name = "Test Dropdown"
  42.     local tooltip = "This is a tooltip for the dropdown."
  43.  
  44.     local function GetOptions()
  45.         local container = Settings.CreateControlTextContainer()
  46.         container:Add(1, "Option 1")
  47.         container:Add(2, "Option 2")
  48.         container:Add(3, "Option 3")
  49.         return container:GetData()
  50.     end
  51.  
  52.     local setting = Settings.RegisterAddOnSetting(category, name, variable, type(defaultValue), defaultValue)
  53.     Settings.CreateDropDown(category, setting, GetOptions, tooltip)
  54.     Settings.SetOnValueChangedCallback(variable, OnSettingChanged)
  55. end
  56.  
  57. Settings.RegisterAddOnCategory(category)
  58.  
  59.  
  60. local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
  61. btn:SetPoint("CENTER")
  62. btn:SetSize(100, 40)
  63. btn:SetText("Click me")
  64. btn:SetScript("OnClick", function(self, button, down)
  65.     Settings.OpenToCategory()  
  66.     SettingsPanel.AddOnsTab:Click()
  67. end)
  68. btn:RegisterForClicks("AnyDown", "AnyUp")
__________________


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-12-24, 04:47 AM   #8
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
I need the settings menu for my addon to open.
How it works for me now (a menu with game settings opens)

How I want it to work (my addon settings should open)


Here is my final code
Lua Code:
  1. local addonName, addon = ...
  2. local addonName = "MyAddon"
  3. local L = {} -- Localization table (if needed)
  4.  
  5. -- Check if the addon object is already registered
  6. if not LibStub("LibDBIcon-1.0", true):GetMinimapButton(addonName) then
  7.     -- Create the minimap icon
  8.     local icon = LibStub("LibDBIcon-1.0")
  9.     local minimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
  10.         type = "data source",
  11.         text = addonName,
  12.         icon = "Interface\\AddOns\\ZamestoTV_GoldFarm\\Icons\\goblin", -- Replace with path to your icon
  13.         OnClick = function(_, button)
  14.             if button == "LeftButton" then
  15.                 MyAddonOptionsPanel_Toggle() -- Open or close the options panel
  16.             end
  17.         end,
  18.         OnTooltipShow = function(tooltip)
  19.             tooltip:SetText(addonName)
  20.             tooltip:AddLine("Click to open options")
  21.             tooltip:Show()
  22.         end,
  23.     })
  24.  
  25.     -- Register the minimap icon
  26.     icon:Register(addonName, minimapIcon, MyAddonOptionsPanelDB) -- Replace MyAddonDB with your saved variables table name
  27. end
  28.  
  29. -- Define the function to toggle the options panel
  30. function MyAddonOptionsPanel_Toggle()
  31.     -- Add code to open or close the options panel here
  32.     InterfaceOptionsFrame_OpenToCategory("MyAddonOptionsPanel") -- Open options panel to a specific category
  33.     print("Toggle options panel")
  34. end
  35.  
  36. -- Define the function to toggle the panel visibility
  37. local function TogglePanel(panel)
  38.     if panel:IsShown() then
  39.         panel:Hide()
  40.     else
  41.         panel:Show()
  42.     end
  43. end

Last edited by Hubb777 : 04-12-24 at 07:14 AM.
  Reply With Quote
04-12-24, 07:22 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Yes, my last example, 2 lines in the OnClick script will open the settings panel to the addon list page. There doesn't seem to be a way addons can open to their own section of the settings by code. Maybe it is protected and needs the user to select the item in the list.


Where is the code where you set up your settings/options page ?

You might still have stuff missing to make it work.

And how you have done it will determine whether you need to use
Lua Code:
  1. InterfaceOptions_OpenToCategory("AddonName")
or
Lua Code:
  1. Settings.OpenToCategory(category:GetID())

As a reminder:
This link gives you an example on how to use the OLD InterfaceOptionsFrame way of adding a settings page. And includes the example on how to show the page on request.
https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel

This post from 2 years ago talks through a few problems people have had getting it to work. It might help you.
https://www.wowinterface.com/forums/...ad.php?t=57172



Bear in mind that the
Lua Code:
  1. InterfaceOptionsFrame_OpenToCategory("MyAddonOptionsPanel")
line is deprecated in Dragonflight and will be removed eventually.

Instead it is replaced with
Lua Code:
  1. Settings.OpenToCategory()

So, you might want to consider using the new Settings functionality added in Dragonflight. This will save you having to figure it out again later when it stops working when the functionality is removed.

But you have to set up your settings page to work with Blizzards Settings ( my last block of code gives an example of how one of those ways works - Vertical Display - and the link below also includes the Canvas route and that is the closest to the old InterfaceOptions way).

As a reminder:
https://warcraft.wiki.gg/wiki/Patch_...s#Settings_API Gives you an example of how to set that up ( my last code block is a copy of this with a button to click it open added.

You can then use the following to open up the settings frame and show the addon page ( finally managed to get it work with my example with the following in the OnClick function.
Lua Code:
  1. Settings.OpenToCategory(category:GetID())

category is set up when you create your settings panel and connect it to the settings system.


So .. depending on how you have created your panel, will determine which version you use and whether it will work or not.
__________________


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-12-24 at 09:04 AM.
  Reply With Quote
04-12-24, 10:02 PM   #10
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
Looks like I didn't succeed =(

I added this to the code of the panel that I want to open:
Lua Code:
  1. local category = Settings.RegisterCanvasLayoutCategory(panel, "MyAddonOptionsPanel")
  2.     Settings.RegisterAddOnCategory(category)

I also changed the button code on the minimap
Lua Code:
  1. local addonName, addon = ...
  2. -- Create the minimap icon
  3. local addonName = "MyAddon"
  4. local LDB = LibStub("LibDataBroker-1.1")
  5. local minimapIcon = LibStub("LibDBIcon-1.0")
  6.  
  7. -- Create a data broker object for the addon
  8. local dataBroker = LDB:NewDataObject(addonName, {
  9.     type = "data source",
  10.     icon = "Interface\\AddOns\\ZamestoTV_GoldFarm\\Icons\\goblin", -- Replace with your addon's icon path
  11.     OnClick = function(self, button)
  12.         if button == "LeftButton" then
  13.             local categoryID = MyAddonOptionsPanel:GetID() -- Replace with your addon's options panel ID
  14.             Settings.OpenToCategory(categoryID)
  15.         end
  16.     end,
  17. })
  18.  
  19. -- Register the data broker with the minimap icon
  20. minimapIcon:Register(addonName, dataBroker, {
  21.     hide = false,
  22.     minimapPos = 180, -- Set the position on the minimap (in degrees)
  23. })
  24.  
  25. -- Add a function to set the category ID for opening
  26. function addon:SetOptionsPanelCategory(categoryID)
  27.     MyAddonOptionsPanel:SetID(categoryID)
  28. end

As a result, the button works without changes (using the example with the pictures above)

Last edited by Hubb777 : 04-12-24 at 10:49 PM.
  Reply With Quote
04-13-24, 01:28 AM   #11
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
So is it working as you wanted or not ?

Is it opening to your addon's settings panel ?
Is it showing all the controls you set up for it ?
Is it saving the settings between play sessions ( if you wanted it to do that )
__________________


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, 04:06 AM   #12
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
How I have it now (and how it was before): I click on the “icon on the minimap” and the “game settings” open (see picture below)

How I want: When I click the “icon on the minimap”, the settings of my addon “MyAddonOptionsPanel” open. (see picture below)
  Reply With Quote
04-13-24, 04:19 AM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Your code must still be missing something which is why I asked to see the code where you create your settings panel. How you create that will determine how you display 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, 04:40 AM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
I would suggest you try creating a simple addon that just shows a settings panel, using the example code on the wiki.gg page I linked. Once you have seen how that works, you can add your addon's functionality.

It was what I did to figure out how it worked so I could explain it to you.
__________________


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, 05:13 AM   #15
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
Originally Posted by Xrystal View Post
Your code must still be missing something which is why I asked to see the code where you create your settings panel. How you create that will determine how you display it.
Sorry. Looks like I didn't see it. Here is the panel code.

Lua Code:
  1. local addonName, addon = ...
  2. -- Create a function to add options to the Interface Options Addons panel
  3. local function AddAddonOptions()
  4.     local panel = CreateFrame("Frame", "MyAddonOptionsPanel", UIParent)
  5.     panel.name = "ZamestoTV: Gold" -- Replace "MyAddon" with your addon's name
  6.  
  7.     -- Create a checkbox for QuestCompletionFrame
  8.     local completionCheckBox = CreateFrame("CheckButton", "QuestCompletionFrameCheckbox", panel, "InterfaceOptionsCheckButtonTemplate")
  9.     completionCheckBox:SetPoint("TOPLEFT", 16, -16)
  10.     completionCheckBox.Text:SetText("Enable Quest Completion Frame") -- Replace with your desired default text
  11.     completionCheckBox.tooltipText = "Enable the Quest Completion Frame" -- Replace with your desired default tooltip text
  12.  
  13.     completionCheckBox:SetScript("OnClick", function(self)
  14.         local isChecked = self:GetChecked()
  15.         -- Handle the checkbox state change here
  16.         if isChecked then
  17.             -- Checkbox is checked, enable QuestCompletionFrame
  18.             QuestCompletionFrame:Show()
  19.         else
  20.             -- Checkbox is unchecked, disable QuestCompletionFrame
  21.             QuestCompletionFrame:Hide()
  22.         end
  23.     end)
  24.  
  25.     -- Create a checkbox for ZAMTimer777 frame
  26.     local timerCheckBox = CreateFrame("CheckButton", "ZAMTimer777Checkbox", panel, "InterfaceOptionsCheckButtonTemplate")
  27.     timerCheckBox:SetPoint("TOPLEFT", completionCheckBox, "BOTTOMLEFT", 0, -8)
  28.     timerCheckBox.Text:SetText("Enable ZAMTimer777 Frame") -- Replace with your desired default text
  29.     timerCheckBox.tooltipText = "Enable the ZAMTimer777 Frame" -- Replace with your desired default tooltip text
  30.  
  31.     timerCheckBox:SetScript("OnClick", function(self)
  32.         local isChecked = self:GetChecked()
  33.         -- Handle the checkbox state change here
  34.         if isChecked then
  35.             -- Checkbox is checked, enable ZAMTimer777 frame
  36.             ZAMTimer777:Show()
  37.         else
  38.             -- Checkbox is unchecked, disable ZAMTimer777 frame
  39.             ZAMTimer777:Hide()
  40.         end
  41.     end)
  42.  
  43.     -- Add the panel to the Interface Options Addons category
  44.     InterfaceOptions_AddCategory(panel)
  45.  
  46.     -- Handle language localization
  47.     local locale = GetLocale()
  48.     if locale == "deDE" then
  49.         -- German localization
  50.         completionCheckBox.Text:SetText("Aufgabenliste: Ein-/Ausblenden")
  51.         completionCheckBox.tooltipText = "Aufgabenliste: Ein-/Ausblenden"
  52.         timerCheckBox.Text:SetText("Timer: Ein-/Ausblenden")
  53.         timerCheckBox.tooltipText = "Timer: Ein-/Ausblenden"
  54.         panel.name = "ZamestoTV: Gold"
  55.     elseif locale == "enUS" then
  56.         -- English localization
  57.         completionCheckBox.Text:SetText("To Do List: Show/Hide")
  58.         completionCheckBox.tooltipText = "To Do List: Show/Hide"
  59.         timerCheckBox.Text:SetText("Timer: Show/Hide")
  60.         timerCheckBox.tooltipText = "Timer: Show/Hide"
  61.         panel.name = "ZamestoTV: Gold"
  62.     end
  63. end
  64.  
  65. -- Register the addon-specific options when the player logs in
  66. local frame = CreateFrame("FRAME")
  67. frame:RegisterEvent("PLAYER_LOGIN")
  68. frame:SetScript("OnEvent", function()
  69.     AddAddonOptions()
  70. end)

I'm new to writing LUA, but I was advised to use ChatGPT (with the help of it I was able to create the panel code and the "icons on the minimap" code)

Last edited by Hubb777 : 04-13-24 at 05:15 AM.
  Reply With Quote
04-13-24, 05:50 AM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
That's understandable.

ChatGPT may not be wise enough to realise new addons are probably best to use new functions rather than ones that will be gone by the next expansion.

Looking at your code I can see you have mixed and matched the two ways ( new and old ) which explains why it doesn't quite work as you expected.

Let me rig up a version of this panel frame that should work.
__________________


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, 06:12 AM   #17
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
Originally Posted by Xrystal View Post

Let me rig up a version of this panel frame that should work.
It would be fantastic.
  Reply With Quote
04-13-24, 07:00 AM   #18
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 131
yes it works. Thank you very much
As I understand it, this part of the code in the “panel” answers: the panel will open through the minimap icon yes/no? Right?
Lua Code:
  1. addon.category = Settings.RegisterCanvasLayoutCategory(panel, addonName)
  2.     Settings.RegisterAddOnCategory(addon.category)
Is this part of the code in the “minimap icon” code?
Lua Code:
  1. OnClick = function(_, button)
  2.             if button == "LeftButton" then
  3.                 Settings.OpenToCategory(addon.category:GetID()) -- Open or close the options panel
  4.             end
  5.         end,
Can I add these parts to my other addon and everything will work there too? Or am I missing something?
  Reply With Quote
04-13-24, 08:06 AM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
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   #20
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
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

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

Thread Tools
Display Modes

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