How to move my slash commands to the options panel?
So my brain hurts from trying to figure this out. I tried to look at some of the other addons that I have installed, but they all seem to use libraries for this, which I don't use or really understand.
So I currently use a set of slash commands to handle the only configurable portion of my addon, the color in which the text is displayed for the user. Currently this is how I accomplish this: Lua Code:
I figured the first thing I would try to get working is adding a button to the options panel, which when you click on it, it calls my already defined color picker functions. Lua Code:
This successfully adds a new panel to the ingame options window with the desired title displayed and the clickable button. However, when I actually click on the button, it throws an error: Code:
5x ConvertRatings/ConvertRatings.lua:27: bad argument #1 to 'SetColorRGB' (Usage: self:SetColorRGB(rgb)) Lua Code:
but that just throws a different error when you load in: Code:
2x ConvertRatings/ConvertRatings.lua:79: Usage: Button:HookScript("frameScriptTypeName", function[, bindingType]) What probably glaring issue am I not seeing here? Why does changing it from a slash command to a button press fuck it all up? |
Code:
cvrbutton:HookScript("OnClick", function() ShowColorPicker(cvred, cvgreen, cvblue, nil, myColorCallback) end) |
Quote:
Wrapping ShowColorPicker in function() and end seemed to do the trick as the color picker now shows and sets the color when you pick one. |
Ok so I have one final problem that I can't seem to figure out, and my googling has turned up no help.
In addition to the color wheel, I have some hard coded color options that I want the user to be able to choose from via a drop down menu. I was able to successfully get the drop down to successfully open, set the colors in my addon and then display the current color chosen in the drop down frame when it is closed. My saved variables get set properly so the color is saved between sessions. What I can't figure out is how to get the drop down menu to read from the saved variables so that it will correctly display the chosen value when the user opens up the options menu in a different session. When I reload the ui, it sets the value of the displayed text to "Default". I tried to not declare a default value for cvcolor at the top of the file, but then i get a nil value concat error. cvred, cvgreen, cvblue, cvalpha, cvcolor are all declared in my toc and I can watch the saved variables file get updated when i reload the ui. Again I'm probably missing something stupid easy. Lua Code:
Edit: I just noticed that when I click on the dropdown menu in the options frame, the displayed text changes to the value currently set in the saved variable. So it knows what it is between sessions, it just doesn't update until i click on the drop down menu frame. |
I figured it out.
I had to add the UIDropDownMenu_SetText fucntion to my addon's hook to the PLAYER_ENTERING_WORLD event. Now when I open up the options frame in a different session, it correctly displays the value set in the saved variable in the drop down menu. |
All times are GMT -6. The time now is 06:01 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI