Thread Tools Display Modes
02-07-12, 05:12 AM   #1
lemmi13
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 5
Thumbs up SOLVED: Problem Script kgpanels & recount

Hi

I'd like to hide recount when I'm not in a party oder raid. Therefore I wrote some Scripts in kgpanels.

OnLoad:
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")
OnEvent:
Code:
local party_members = GetNumPartyMembers();
local raid_members = GetNumRaidMembers();
if (party_members < 1 and raid_members < 1) then
   Recount.MainWindow:Hide();
   self:Hide();
else
   Recount.RefreshMainWindow();
   Recount.MainWindow:Show();
   self:Show();
end;
The Box in kgpanels hides, when I'm not in a group but recount is still visible.


The funny things is that when I create an oncklick event within kgpanels:

Code:
Recount.MainWindow:Hide();
self:Hide();
or run a macro with

Code:
/run Recount.MainWindow:Hide();
Recount Hides.


Where is the problem in my kgpanel scripts? I can't figure out the misstake.


Thanks in advance for any help

Cheers

lemmi

Last edited by lemmi13 : 02-07-12 at 04:44 PM. Reason: SOLVED
  Reply With Quote
02-07-12, 01:48 PM   #2
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Your script is good, it's Recount that's causing your problem. It seems to have a mind of it's own when it comes to showing and hiding.

You can parent the Recount panel to your kgPanels panel though and use the following code:


OnLoad
Lua Code:
  1. self:RegisterEvent("PARTY_MEMBERS_CHANGED")
  2. self:RegisterEvent("RAID_ROSTER_UPDATE")
  3. Recount_MainWindow:SetParent(self)

OnEvent
Lua Code:
  1. local pmems = GetNumPartyMembers()
  2. local rmems = GetNumRaidMembers()
  3. if (pmems < 1 and rmems < 1) then -- you're neither in a party or a raid
  4.   self:Hide()
  5. elseif (pmems >= 1 or rmems >= 1) then -- it knows it needs to do something
  6.   self:Show() -- you're panel (and Recount) shows
  7. end

That should work. Because you've told Recount to parent to your own panel at OnLoad, it can only show when your panel does, so you should be in a position where you just need to tell your panel what to do.

While I'm at it, you can add this to OnLoad too to ensure that your panel always re-sizes correctly whenever Recount_MainWindow's size changes.

Ordinarily, anchoring your frame to 2 opposing corners of another frame at OnLoad should ensure that your frame and the other frame remain the same size regardless, but that doesn't seem to be the case with kgPanels. Hence, the following is required (untested):

OnLoad
Lua Code:
  1. Recount_MainWindow:HookScript("OnSizeChanged", function
  2.   self:ClearAllPoints()
  3.   self:SetPoint("TOPLEFT", Recount_MainWindow, "TOPLEFT", -2, 2)
  4.   self:SetPoint("BOTTOMRIGHT", Recount_MainWindow, "BOTTOMRIGHT", 2, -2)
  5. end)

Put Recount in the "Script Dependences" bit to prevent problems during OnLoad.

Hope this helped.
__________________
__________________

Last edited by Aanson : 07-22-12 at 04:01 AM. Reason: Removed code
  Reply With Quote
02-07-12, 04:15 PM   #3
lemmi13
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 5
Ahh Great! Thanks for your help.

I just added

Code:
Recount.MainWindow:SetParent(self)
to OnLoad and everything is fine.


So for the Frame the working script is:


OnLoad:
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")

Recount.MainWindow:SetParent(self)
OnEvent:
Code:
local party_members = GetNumPartyMembers();
local raid_members = GetNumRaidMembers();
if (party_members < 1 and raid_members < 1) then
   self:Hide();
else
   self:Show();
end;

Thanks a lot for your help, Aanson.

Best wishes

lemmi

Last edited by lemmi13 : 02-07-12 at 04:21 PM.
  Reply With Quote
02-07-12, 10:03 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Doesn't Recount already have an option for this? Turn off data collection for everything except party and raid if you haven't already (since you obviously don't care about such data) and then turn on "hide when not collecting".
  Reply With Quote
02-08-12, 10:28 AM   #5
lemmi13
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 5
Originally Posted by Phanx View Post
Doesn't Recount already have an option for this? Turn off data collection for everything except party and raid if you haven't already (since you obviously don't care about such data) and then turn on "hide when not collecting".
Yes, but to be honest - i got stucked to the config options at Recount.
  Reply With Quote
07-18-12, 07:45 AM   #6
griffulas
A Kobold Labourer
Join Date: Jul 2012
Posts: 1
Im trying to create a similar panel, but id like it show in raid/party and have a chat tap with it so raid and party chat will show with a panel behind it about my main chat window
  Reply With Quote
07-22-12, 03:22 AM   #7
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by griffulas View Post
Im trying to create a similar panel, but id like it show in raid/party and have a chat tap with it so raid and party chat will show with a panel behind it about my main chat window
Yeah, that's pretty easily achievable. If you've not done so already, create a new chat window and use settings to pick Raid Chat. Same for Party Chat.

Then, the following code can be used (assuming you're also using kgPanels):

OnLoad
Lua Code:
  1. self:RegisterEvent("PARTY_MEMBERS_CHANGED")
  2. self:RegisterEvent("RAID_ROSTER_UPDATE")
  3. Recount.MainWindow:SetParent(self)

OnEvent
Lua Code:
  1. local pmems = GetNumPartyMembers()
  2. local rmems = GetNumRaidMembers()
  3. if (pmems < 1 and rmems < 1) then -- you're neither in a party or a raid
  4.   self:Hide()
  5.   ChatFrame1Tab:Click("LeftButton") -- you're using your standard chat
  6. elseif (pmems >= 1 or rmems >= 1) then -- it knows it needs to do something
  7.   self:Show() -- you're panel (and Recount) shows
  8.   if pmems >= 1 then -- you're in a party
  9.     ChatFrame3Tab:Click("LeftButton") -- (provided ChatFrame3 shows Party Chat)
  10.   elseif rmems >= 1 then -- you're in a raid (or a party has been converted to raid)
  11.     ChatFrame4Tab:Click("LeftButton") -- (provided ChatFrame4 shows Raid Chat)
  12.   end
  13. end

This can also be achieved by registering / unregistering to/from Party Chat or Raid chat and using the same ChatFrame (ie ChatFrame1 or ChatFrame3) but I personally think that the above method is the cleanest and most effective solution.
__________________
__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Problem Script kgpanels & recount


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