Thread Tools Display Modes
03-19-12, 12:13 PM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
kgPanels - How do I save my user created settings between sessions?

Hey!

I'm still working on my UI with kgPanels and I've run into (another) unexpected problem.

Please keep in mind that I'm a fairly simple chap.

I've created a smart chat window which automatically docks/un-docks the chat frames when a message of a certain type is received. Ie. if a whisper is received and the chat window is docked, it will un-dock (popup) for 10 seconds and then pop back down again if I don't attempt to interact with it (thanks again Phanx for the .counter & elapsed code).

I've been wanting to make settings for it though and (again, remember that I'm simple), I thought that I could just create simple frames; if the frame is hidden, the option is off, if it's shown (with 0 opacity and completely inert), the option is on. But to my horror, I've discovered that the frame will always revert back to 'shown' by default when there is a /rl or restart.

I've spent ages on making up an options frame. Each option has the word 'disabled' in red and if clicked (and the invisible panel shows), it changes to 'enabled' in green.

I already have all the OnEvent code in a different panel which will check to see if a particular option panel is 'shown' before executing the code.

Basically, and I know this has been a long time in coming, my question is, is there any simple way for me to save the settings between sessions? A wee example would be amazing if it's possible.

If it's not simple, a little guidance or a point in the right direction would be great.

Thanks very much for reading all this.
__________________
__________________
  Reply With Quote
03-19-12, 01:02 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Aanson View Post
I thought that I could just create simple frames; if the frame is hidden, the option is off, if it's shown (with 0 opacity and completely inert), the option is on. But to my horror, I've discovered that the frame will always revert back to 'shown' by default when there is a /rl or restart.
You would need to look in the kgPanels options code to see what function(s) it calls when you hide/show a panel, and then call those same functions from your panel, so that the setting is saved in the kgPanels database.
  Reply With Quote
03-19-12, 01:54 PM   #3
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by Phanx View Post
You would need to look in the kgPanels options code to see what function(s) it calls when you hide/show a panel, and then call those same functions from your panel, so that the setting is saved in the kgPanels database.
Cheers Phanx, I'll try and see what I can see right now.
__________________
__________________
  Reply With Quote
03-19-12, 03:48 PM   #4
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
I've had a look through the code but I've not been able to find anything that sticks out that I can use. I've been thinking though (bipolar and when I'm feeling my best, I get very inventive lol... think up a new idea every 2 seconds before I get to jot the previous one down).

Do you think I could manage a workaround by using SetScript, ie.

With reference to my original post, i click an option so that it says 'enabled'. As well as the click action showing the frame, it also changes it's OnLoad script like so..

local flag = kgPanels:FetchFrame("ChatWindowOptionsFrame(11)WhisperOptFlag1of3");

"Option button" OnClick:

if not flag:IsVisible() then
flag:Show()
flag:SetScript(OnLoad, flag.Show)
elseif flag:IsVisible() then
flag:Hide()
flag:SetScript(OnLoad, flag.Hide)
end

I'll give it a try and see but while typing it out, it's dawned on me that this change to the OnLoad code likely won't be saved between sessions either!
__________________
__________________
  Reply With Quote
03-19-12, 04:18 PM   #5
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
No, that didn't work (even after remembering to add the ""s around OnLoad.

But then, should I have expected it to really?

I'll keep at it and report back how I get on, just incase, for whatever reason, someone else at some point is looking to try and do the same thing.
__________________
__________________
  Reply With Quote
03-19-12, 07:25 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Setting an OnLoad script like that will not do anything. You need to find the code in kgPanels that actually saves the panel's properties in the kgPanels saved variables database, and add similar code to your panel's scripts so that clicking on the panel does the same thing as clicking "Hide this panel" in the kgPanels options window (if there is such an option; if not, you're probably out of luck).

I don't have time to dig through the massive and convoluted options code for kgPanels right now, so I can't help much beyond that.

Realistically, though, what you're doing sounds far beyond the scope of what kgPanels is meant to do, and you should probably just write your own addon with real options instead of art panels simulating buttons simulating options.
  Reply With Quote
03-19-12, 08:05 PM   #7
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Phanx View Post
Realistically, though, what you're doing sounds far beyond the scope of what kgPanels is meant to do, and you should probably just write your own addon with real options instead of art panels simulating buttons simulating options.
This
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » kgPanels - How do I save my user created settings between sessions?


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