Thread Tools Display Modes
06-15-10, 05:06 PM   #21
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by v6o View Post
What Xrystal said is the easiest way to handle multiple frames; let them handle their own events.


And for the "self error"; You're doing it wrong here. You're not passing self as the first argument.
should be

No point creating the small extra function, this also passes all arguments.
yea this is all falling into place more as i go along, i had not figured that part out yet before i needed to have a bunch of those functions inside the setscript... now i only need one

edit -- v6o -- if i do GrimUI.PartyNameTextEvents without (self) at the end it knows that function needs to work onitself right? so when i do the setscript there are no (self)'s in the mater? it knows to get the (self) on GrimUI.PartyNameTextEvents automatically?

edit -- oh yea im not actually getting errors or even trying any of this in game right now... im working all based on theory. i want to understand whats going on so it becomes easier to write code without so much guess and check... i just figured there would be a self error there based on the theory of the mater...

edit -- made it look like this based on that idea...

lua Code:
  1. local function GUISetPartyEventScripts(id)
  2.     local frame = _G['GrimUIPartyFrame' .. id]
  3.     frame.GUIHealthEvents:SetScript("OnEvent", GrimUI.HealthEventFunc)
  4.  
  5.     frame.GUIManaEvents:SetScript("OnEvent", GrimUI.ManaEventFunc)
  6.  
  7.     frame.GUINameTextEvents:SetScript("OnEvent", GrimUI.PartyNameTextEvents)
  8.  
  9.     frame.GUILvlClassTextEvents:SetScript("OnEvent", GrimUI.LvlClassTextEvents)
  10.  
  11.     frame.GUIpvpIconEvent:SetScript("OnEvent", GrimUI.pvpIconEvent)
  12.  
  13.     frame.GUIPartyLeaderEvent:SetScript("OnEvent", GrimUI.PartyLeaderEvent)
  14.  
  15.     frame.GUIOffLineDeadEvents:SetScript("OnEvent", GrimUI.DeadOffLineEvents)
  16.  
  17.     frame.GUItargetOfFrameEvents:SetScript("OnEvent", GrimUI.TargEventFunc)
  18. end
  19.  
  20. for id = 1, 4 do
  21.     GUISetPartyEventScripts(id)
  22. end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-15-10 at 05:16 PM.
  Reply With Quote
06-15-10, 05:11 PM   #22
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
You can register any event to any frame that supports it, even if it it not parented.

The thing you just have to remember is for a lot of events the first argument is usually the unit id and you will need to check if it the correct one for your frame.


And again a lot of your SetScripts do not need the extra function call you're doing. Instead of doing

Code:
frame.GUIHealthEvents:SetScript("OnEvent", function(self)
GrimUI.HealthEventFunc(self)
end)
You should just do

Code:
frame.GUIHealthEvents:SetScript("OnEvent", GrimUI.HealthEventFunc)
It will still pass all arguments by the event to HealthEventFunc
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 06-15-10 at 05:15 PM.
  Reply With Quote
06-15-10, 10:10 PM   #23
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
edit- okay i changed the code to the following and no longer get any errors how ever when i first load up the dropdownmenu is open i have to click cancel? and none of the event scripts are working

lua Code:
  1. frame.HealthBorder:SetBackdropBorderColor(0, 0, 0, 1)
  2.     frame.HealthBorder:SetFrameStrata("BACKGROUND")
  3.     frame.HealthBorder:SetFrameLevel("3")
  4.     frame.HealthBorder:RegisterForClicks("AnyUp")
  5.     frame.HealthBorder:SetAttribute("unit", "Party" .. id)
  6.     frame.HealthBorder:SetAttribute("*type1", "target")
  7.  
  8.     local showPartymenu = ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..id.."DropDown]", "cursor", 0, 0)
  9.  
  10.     frame.HealthBorder.showPartymenu = showPartymenu
  11.     frame.HealthBorder.unit = "party" .. id
  12.     frame.HealthBorder:SetAttribute("*type2", "showPartymenu")
  13.     frame.HealthBorder:SetScript("OnEnter", UnitFrame_OnEnter)
  14.     frame.HealthBorder:SetScript("OnLeave", UnitFrame_OnLeave)
  15.     frame.HealthBorder:SetFrameStrata("HIGH")
  16.     frame.HealthBorder:SetFrameLevel("2")
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
06-15-10, 10:11 PM   #24
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
event scripts look like this...

lua Code:
  1. function GrimUI.PartyTargEventFunc(self)
  2.     if UnitExists(self.unittarget) == 1 and UnitIsUnit(self.unittarget, "target") == 1 then
  3.         frame.targetOfFrame.targetOfText:SetText("** YOUR TARGET **")
  4.     end
  5.     if  UnitExists(self.unittarget) == 1 and UnitName(self.unittarget) == UnitName("player") then
  6.         frame.targetOfFrame.targetOfText:SetText("** YOU **")
  7.     end
  8.     if  UnitExists(self.unittarget) == 1 and UnitName(self.unittarget) ~= UnitName("player") and UnitIsUnit(self.unittarget, "target") ~= 1 then
  9.         local nametstr = ("%s"):format(UnitName(self.unittarget))
  10.         frame.targetOfFrame.targetOfText:SetText(nametstr)
  11.     end
  12.     if UnitExists(self.unittarget) == nil then
  13.         frame.targetOfFrame.targetOfText:SetText("-No Target-")
  14.         frame.targetOfFrame.texture:SetTexture(0, 0, 0, 0)
  15.     end
  16.     if UnitExists(self.unittarget) == 1 and UnitIsEnemy("player", self.unittarget) == 1 then
  17.         frame.targetOfFrame.texture:SetTexture(.40, .10, .10, 1)
  18.     end
  19.     if UnitExists(self.unittarget) == 1 and UnitIsFriend("player", self.unittarget) == 1 then
  20.         frame.targetOfFrame.texture:SetTexture(.10, .40, .10, 1)
  21.     end
  22. end

the setscript function looks like this...

lua Code:
  1. local function GUISetPartyEventScripts(id)
  2.     local frame = _G['GrimUIPartyFrame' .. id]
  3.     frame.GUIHealthEvents:SetScript("OnEvent", GrimUI.HealthEventFunc)
  4.  
  5.     frame.GUIManaEvents:SetScript("OnEvent", GrimUI.ManaEventFunc)
  6.  
  7.     frame.GUINameTextEvents:SetScript("OnEvent", GrimUI.PartyNameTextEvents)
  8.  
  9.     frame.GUILvlClassTextEvents:SetScript("OnEvent", GrimUI.LvlClassTextEvents)
  10.  
  11.     frame.GUIpvpIconEvent:SetScript("OnEvent", GrimUI.pvpIconEvent)
  12.  
  13.     frame.GUIPartyLeaderEvent:SetScript("OnEvent", GrimUI.PartyLeaderEvent)
  14.  
  15.     frame.GUIOffLineDeadEvents:SetScript("OnEvent", GrimUI.DeadOffLineEvents)
  16.  
  17.     frame.GUItargetOfFrameEvents:SetScript("OnEvent", GrimUI.TargEventFunc)
  18. end
  19.  
  20. for id = 1, 4 do
  21.     GUISetPartyEventScripts(id)
  22. end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
06-15-10, 10:37 PM   #25
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
welp ive been at this all day heading to bed. thanks for all the help from everyone today. this is what it looks like the two major problems are the dropdownmenu's and the events not registering. btw it is a WHOLE lot smaller thanks!!!!!

lua Code:
  1. local module = GrimUI:RegisterModule("PartyFrames")
  2.  
  3. -----------------------------------
  4. -- GUI Party Frame main creation.
  5. -----------------------------------
  6. CreateFrame("Frame", "GrimPartyMain", UIParent, "SecureHandlerStateTemplate");
  7.  
  8. --SecureHandler_OnLoad(GrimPartyMain);
  9. --GrimPartyMain:SetFrameRef("GrimPartyMain", GrimPartyMain);
  10. --GrimPartyMain:Execute([[
  11. --GrimPartyMain = self:GetFrameRef("GrimPartyMain");
  12. --]]);
  13. --GrimPartyMain:Execute("raidhideparty = " .. tostring(GetCVar("hidePartyInRaid"))); -- hook to Blizzard option for party raid hide frames
  14. --GrimPartyMain:SetAttribute("_onstate-unitexists", [[
  15. --  --if raidhideparty == 1 and newstate then
  16. --  --GrimPartyMain:Hide()
  17. --  --end
  18. --  --if raidhideparty ~= 1 and newstate then
  19. --  --GrimPartyMain:Show()
  20. --  --end
  21. --]]);
  22. --GrimPartyMain:SetAttribute("unit", "raid1");
  23. --GrimPartyMain(GrimPartyMain, true);
  24. --GrimPartyMain:SetAttribute("state-unitexists", UnitExists("raid1"));
  25.  
  26. --##########################################--
  27. -- individual frame creations party 1,2,3,4 --
  28. --##########################################--
  29. local function createPartyFrames(i)
  30.    
  31.     -- Main Frame
  32.     local frame = CreateFrame("Frame", "GrimUIPartyFrame" .. i, UIParent, "SecureUnitButtonTemplate")
  33.     frame.unit = "party" .. i
  34.     frame.unittarget = "party"..i.."target"
  35.     -- Pedestal Frame
  36.     frame.PedestalFrame = CreateFrame("Frame", nil, frame)
  37.    
  38.     -- Health Bar
  39.     frame.HealthBorder = CreateFrame("button", nil, frame)
  40.     frame.HealthBar = CreateFrame("StatusBar", nil, frame)
  41.     frame.HealthNumTxtFrame = CreateFrame("Frame", nil, frame)
  42.    
  43.     -- Mana Bar
  44.     frame.ManaBorder = CreateFrame("button", nil, frame)
  45.     frame.ManaBar = CreateFrame("StatusBar", nil, frame)
  46.     frame.ManaNumTxtFrame = CreateFrame("Frame", nil, frame)
  47.    
  48.     -- Misc Frames
  49.     frame.InfoTextFrame = CreateFrame("button", nil, frame)
  50.     frame.LetterFrame = CreateFrame("Frame", nil, frame)
  51.     frame.LeaderFrame = CreateFrame("Frame", nil, frame)
  52.     frame.pvpIconFrame = CreateFrame("Frame", nil, frame)
  53.     frame.offDeadGhostTxtFrame = CreateFrame("Frame", nil, frame)
  54.    
  55.     -- Target Bar
  56.     frame.targetOfFrame = CreateFrame("Frame", nil, frame)
  57.     frame.targetOfClickFrame = CreateFrame("button", nil, frame)
  58.    
  59.     -- texture creation
  60.     frame.PedestalFrame.texture = frame.PedestalFrame:CreateTexture()
  61.     frame.LeaderFrame.texture = frame.LeaderFrame:CreateTexture()
  62.     frame.pvpIconFrame.texture = frame.pvpIconFrame:CreateTexture()
  63.     frame.targetOfFrame.texture = frame.targetOfFrame:CreateTexture(nil, "BACKGROUND")
  64.    
  65.     -- texture setallpoints that remain the same for both party styles
  66.     frame.PedestalFrame.texture:SetAllPoints(frame.PedestalFrame)
  67.     frame.targetOfFrame.texture:SetAllPoints(frame.targetOfFrame)
  68.     frame.LeaderFrame.texture:SetAllPoints(frame.LeaderFrame)
  69.     frame.pvpIconFrame.texture:SetAllPoints(frame.pvpIconFrame)
  70.    
  71.     -- font creation
  72.     frame.HealthBorder.percentHText = frame.HealthBorder:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  73.     frame.ManaBorder.percentMText = frame.ManaBorder:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  74.     frame.InfoTextFrame.NameText = frame.InfoTextFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  75.     frame.LetterFrame.LetterHText = frame.LetterFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  76.     frame.LetterFrame.LetterMText = frame.LetterFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  77.     frame.HealthNumTxtFrame.chnumtxt = frame.HealthNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  78.     frame.HealthNumTxtFrame.mhnumtxt = frame.HealthNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  79.     frame.ManaNumTxtFrame.CMNumTxt = frame.ManaNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  80.     frame.ManaNumTxtFrame.MMNumTxt = frame.ManaNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  81.     frame.InfoTextFrame.LvlClassText = frame.InfoTextFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  82.     frame.offDeadGhostTxtFrame.DeadOfflineTxt = frame.offDeadGhostTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  83.     frame.targetOfFrame.targetOfText = frame.targetOfFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  84.  
  85.     -- event frames
  86.     frame.GUIHealthEvents = CreateFrame("Frame", nil, frame)
  87.     frame.GUIManaEvents = CreateFrame("Frame", nil, frame)
  88.     frame.GUINameTextEvents = CreateFrame("Frame", nil, frame)
  89.     frame.GUILvlClassTextEvents = CreateFrame("frame", nil, frame)
  90.     frame.GUIPartyLeaderEvent = CreateFrame("Frame", nil, frame)
  91.     frame.GUIpvpIconEvent = CreateFrame("Frame", nil, frame)
  92.     frame.GUIOffLineDeadEvents = CreateFrame("Frame", nil, frame)
  93.     frame.GUItargetOfFrameEvents = CreateFrame("frame", nil, frame)
  94.    
  95. end
  96.  
  97. for id = 1, 4 do
  98.     createPartyFrames(id)
  99. end
  100.  
  101.  
  102. --###############################################
  103. --##   Event Frames for current Party Styles   ##
  104. --###############################################
  105. local function GUIRegisterPartyEvents(id)
  106. -- Health Events
  107.     local frame = _G['GrimUIPartyFrame' .. id]
  108.     frame.GUIHealthEvents:RegisterEvent("PLAYER_ENTERING_WORLD")
  109.     frame.GUIHealthEvents:RegisterEvent("UNIT_HEALTH")
  110.     frame.GUIHealthEvents:RegisterEvent("UNIT_LEVEL")
  111.     frame.GUIHealthEvents:RegisterEvent("UNIT_AURA")
  112.     frame.GUIHealthEvents:RegisterEvent("UNIT_MAXHEALTH")
  113.     frame.GUIHealthEvents:RegisterEvent("PARTY_MEMBERS_CHANGED")
  114.  
  115. -- Mana Events
  116.     frame.GUIManaEvents.RegisterEvents = GrimUI.RegisterEvents
  117.     frame.GUIManaEvents:RegisterEvents('PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'UNIT_HEALTH', 'UNIT_LEVEL', 'UNIT_MANA', 'UNIT_AURA','UNIT_DISPLAYPOWER', 'UNIT_ENERGY', 'UNIT_MAXENERGY', 'UNIT_MAXMANA', 'UNIT_MAXRUNICPOWER', 'UNIT_RUNIC_POWER', 'UNIT_RAGE')
  118.  
  119.     frame.GUINameTextEvents:RegisterEvent("PLAYER_ENTERING_WORLD")
  120.     frame.GUINameTextEvents:RegisterEvent("PARTY_MEMBERS_CHANGED")
  121.     frame.GUINameTextEvents:RegisterEvent("UNIT_NAME_UPDATE")
  122.     frame.GUINameTextEvents:RegisterEvent("UNIT_FLAGS")
  123.     frame.GUINameTextEvents:RegisterEvent("UNIT_THREAT_LIST_UPDATE")
  124.     frame.GUINameTextEvents:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
  125.     frame.GUINameTextEvents:RegisterEvent("UNIT_COMBAT")
  126.  
  127.     frame.GUILvlClassTextEvents:RegisterEvent("PLAYER_ENTERING_WORLD")
  128.     frame.GUILvlClassTextEvents:RegisterEvent("PARTY_MEMBERS_CHANGED")
  129.     frame.GUILvlClassTextEvents:RegisterEvent("UNIT_LEVEL")
  130.  
  131.     frame.GUIPartyLeaderEvent:RegisterEvent("PLAYER_ENTERING_WORLD")
  132.     frame.GUIPartyLeaderEvent:RegisterEvent("PARTY_LEADER_CHANGED")
  133.     frame.GUIPartyLeaderEvent:RegisterEvent("PARTY_MEMBERS_CHANGED")
  134.     frame.GUIPartyLeaderEvent:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  135.  
  136.     frame.GUIpvpIconEvent:RegisterEvent("PLAYER_ENTERING_WORLD")
  137.     frame.GUIpvpIconEvent:RegisterEvent("UNIT_FACTION")
  138.     frame.GUIpvpIconEvent:RegisterEvent("PARTY_MEMBERS_CHANGED")
  139.     frame.GUIpvpIconEvent:RegisterEvent("UNIT_DYNAMIC_FLAGS")
  140.  
  141.     frame.GUIOffLineDeadEvents.RegisterEvents = GrimUI.RegisterEvents
  142.     frame.GUIOffLineDeadEvents:RegisterEvents('PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'PARTY_MEMBER_DISABLE', 'PARTY_MEMBER_ENABLE', 'UNIT_HEALTH')
  143.  
  144.     frame.GUItargetOfFrameEvents.RegisterEvents = GrimUI.RegisterEvents
  145.     frame.GUItargetOfFrameEvents:RegisterEvents('PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'PARTY_LEADER_CHANGED', 'PLAYER_TARGET_CHANGED', 'UNIT_TARGET')
  146. end
  147.  
  148. for id = 1, 4 do
  149.     GUIRegisterPartyEvents(id)
  150. end
  151.  
  152.  
  153. --################################--  DO NOT MESS WITH THIS ITS CRITICAL TO THE MOVEFRAMES.LUA
  154. --  PartyLayoutInitiate Function  --
  155. --################################--
  156.  
  157. --------------
  158. --- PARTY 1
  159. -------------
  160. function GrimUI:Party1LayoutInitiate()
  161.  
  162.     local parentFrame = {}
  163.     local frame = parentFrame[self] or self;
  164.    
  165.     ---
  166.     -- Party1 Frame SetPoint
  167.     ---
  168.     if not GrimUIPartyFrame1:IsShown() then return end;
  169.    
  170.     if not GrimLayout.GrimUIPartyFrame1 then
  171.         GrimUIPartyFrame1:ClearAllPoints();
  172.         GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22)
  173.     end
  174.    
  175.     if GrimLayout.disabled == true then
  176.         GrimUIPartyFrame1:ClearAllPoints();
  177.         GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22)
  178.     --elseif GrimLayout.nosave == true then
  179.       --    GUI_Party1Frame:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22)
  180.      
  181.      
  182.     elseif GrimLayout.GrimUIPartyFrame1 then
  183.           if GrimLayout[GrimUIPartyFrame1:GetName()] then
  184.               local points = GrimLayout[GrimUIPartyFrame1:GetName()];
  185.               if not points then
  186.               GrimUIPartyFrame1:ClearAllPoints()
  187.               GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22) return
  188.               elseif points[1] == "nil" then
  189.               GrimUIPartyFrame1:ClearAllPoints();
  190.               GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22) return
  191.               elseif points[1] == "LEFT" and points[2] == "UIParent" and points[3] == "TOPRIGHT" then
  192.               GrimUIPartyFrame1:ClearAllPoints();
  193.               GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22) return
  194.               end;
  195.            
  196.               GrimUIPartyFrame1:ClearAllPoints();
  197.               GrimUIPartyFrame1:SetPoint(points[1], points[2],points[3], points[4], points[5]);
  198.             end
  199.     end
  200. end
  201.  
  202. ----------------
  203. -- PARTY 2
  204. ----------------
  205. function GrimUI:Party2LayoutInitiate()
  206.     local parentFrame = {}
  207.     local frame = parentFrame[self] or self;
  208.    
  209.     ---
  210.     -- Party2 Frame SetPoint
  211.     ---
  212.     if not GrimUIPartyFrame2:IsShown() then return end;
  213.     if not GrimLayout.GrimUIPartyFrame2 then
  214.         GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GrimUIPartyFrame1, "BOTTOMRIGHT", -1, 0)
  215.     end
  216.    
  217.     if GrimLayout.disabled == true then
  218.         GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GrimUIPartyFrame1, "BOTTOMRIGHT", -1, 0)
  219.     --elseif GrimLayout.nosave == true then
  220.           --GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GUI_Party1Frame, "BOTTOMRIGHT", -1, 0)
  221.      
  222.      
  223.     elseif GrimLayout.GrimUIPartyFrame2 then
  224.           if GrimLayout[GrimUIPartyFrame2:GetName()] then
  225.               local points = GrimLayout[GrimUIPartyFrame2:GetName()];
  226.               if not points then GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GUI_Party1Frame, "BOTTOMRIGHT", -1, 0) return
  227.               elseif points[1] == "nil" then GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GUI_Party1Frame, "BOTTOMRIGHT", -1, 0) return
  228.               elseif points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then
  229.               GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GUI_Party1Frame, "BOTTOMRIGHT", -1, 0) return
  230.               end;
  231.               GrimUIPartyFrame2:ClearAllPoints();
  232.               GrimUIPartyFrame2:SetPoint(points[1], points[2],points[3], points[4], points[5]);
  233.             end
  234.     end
  235. end
  236.  
  237. ----------------
  238. -- PARTY 3
  239. ----------------
  240. function GrimUI:Party3LayoutInitiate()
  241.     local parentFrame = {}
  242.     local frame = parentFrame[self] or self;
  243.     ---
  244.     -- Party3 Frame SetPoint
  245.     ---
  246.     if not GrimUIPartyFrame3:IsShown() then return end;
  247.     if not GrimLayout.GrimUIPartyFrame3 then
  248.         GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22)
  249.     end
  250.    
  251.     if GrimLayout.disabled == true then
  252.         GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22)
  253.     --elseif GrimLayout.nosave == true then
  254.           --GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22)
  255.      
  256.      
  257.     elseif GrimLayout.GrimUIPartyFrame3 then
  258.           if GrimLayout[GrimUIPartyFrame3:GetName()] then
  259.               local points = GrimLayout[GrimUIPartyFrame3:GetName()];
  260.               if not points then GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22) return
  261.               elseif points[1] == "nil" then GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22) return
  262.               elseif points[1] == "RIGHT" and points[2] == "UIParent" and points[3] == "TOPLEFT" then
  263.               GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22) return
  264.               end;
  265.               GrimUIPartyFrame3:ClearAllPoints();
  266.               GrimUIPartyFrame3:SetPoint(points[1], points[2],points[3], points[4], points[5]);
  267.             end
  268.     end
  269. end
  270.  
  271. ----------------
  272. -- PARTY 4
  273. ----------------
  274. function GrimUI:Party4LayoutInitiate()
  275.     local parentFrame = {}
  276.     local frame = parentFrame[self] or self;
  277.     ---
  278.     -- Party4 Frame SetPoint
  279.     ---
  280.     if not GrimUIPartyFrame4:IsShown() then return end;
  281.     if not GrimLayout.GrimUIPartyFrame4 then
  282.         GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0)
  283.     end
  284.  
  285.     if GrimLayout.disabled == true then
  286.         GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0)
  287.     --elseif GrimLayout.nosave == true then
  288.           --GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0)
  289.      
  290.      
  291.     elseif GrimLayout.GrimUIPartyFrame4 then
  292.           if GrimLayout[GrimUIPartyFrame4:GetName()] then
  293.               local points = GrimLayout[GrimUIPartyFrame4:GetName()];
  294.               if not points then GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0) return
  295.               elseif points[1] == "nil" then GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0) return
  296.               elseif points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then
  297.               GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0) return
  298.               end;
  299.               GrimUIPartyFrame4:ClearAllPoints();
  300.               GrimUIPartyFrame4:SetPoint(points[1], points[2],points[3], points[4], points[5]);
  301.             end
  302.     end
  303. end
  304.  
  305. ----------------------------------------------
  306. -- PLAYER_LOGIN functions - one time run on first load
  307. -----------------------------------------------
  308. local GrimUIPartyFramesOnLogin = CreateFrame("Frame", UIParent)
  309. GrimUIPartyFramesOnLogin:RegisterEvent("PLAYER_LOGIN")
  310. GrimUIPartyFramesOnLogin:SetScript("OnEvent", function(event)
  311.    
  312.     -- check opetions panel for GUI and Bliz hide options and then force one way or the other.
  313.     GrimUI.PartyHideShowFunc()
  314.     GrimUI.BPartyHideShowFunc()
  315. end)
  316.  
  317. -------------------------------------------------------------
  318. -- Update Show/hide in raid based on the Bliz Variable chosen
  319. --------------------------------------------------------------
  320. local UpdatePartyCVar = CreateFrame("Frame", "UpdatePartyCVar", UIParent, "SecureHandlerStateTemplate");
  321. UpdatePartyCVar:RegisterEvent("CVAR_UPDATE")
  322.  
  323. UpdatePartyCVar:SetScript("OnEvent", function()
  324.  
  325.     if GetCVarBool("hidePartyInRaid") then
  326.         RegisterStateDriver(GrimPartyMain, "visibility", "[@raid1,exists]hide;show");
  327.     else
  328.         UnregisterStateDriver(GrimPartyMain, "visibility");
  329.         GrimPartyMain:Show();
  330.         GrimUI.UpdatePartyStyle()
  331.         GrimUI.Party1LayoutInitiate()
  332.         GrimUI.Party2LayoutInitiate()
  333.         GrimUI.Party3LayoutInitiate()
  334.         GrimUI.Party4LayoutInitiate()
  335.     end
  336. end)
  337.  
  338.  
  339.  
  340.  
  341.  
  342. local function PFClearAllPoints(id)
  343.  
  344.     local frame = _G['GrimUIPartyFrame' .. id]
  345.     -- frames
  346.     frame.PedestalFrame:ClearAllPoints()
  347.     frame.HealthBorder:ClearAllPoints()
  348.     frame.HealthBar:ClearAllPoints()
  349.     frame.ManaBorder:ClearAllPoints()
  350.     frame.ManaBar:ClearAllPoints()
  351.     frame.InfoTextFrame:ClearAllPoints()
  352.     frame.LetterFrame:ClearAllPoints()
  353.     frame.HealthNumTxtFrame:ClearAllPoints()
  354.     frame.ManaNumTxtFrame:ClearAllPoints()
  355.     frame.LeaderFrame:ClearAllPoints()
  356.     frame.pvpIconFrame:ClearAllPoints()
  357.     frame.offDeadGhostTxtFrame:ClearAllPoints()
  358.     frame.targetOfFrame:ClearAllPoints()
  359.     frame.targetOfClickFrame:ClearAllPoints()
  360.    
  361.     -- Textblocks
  362.     frame.HealthBorder.percentHText:ClearAllPoints()
  363.     frame.ManaBorder.percentMText:ClearAllPoints()
  364.     frame.InfoTextFrame.NameText:ClearAllPoints()
  365.     frame.LetterFrame.LetterHText:ClearAllPoints()
  366.     frame.LetterFrame.LetterMText:ClearAllPoints()
  367.     frame.HealthNumTxtFrame.chnumtxt:ClearAllPoints()
  368.     frame.HealthNumTxtFrame.mhnumtxt:ClearAllPoints()
  369.     frame.ManaNumTxtFrame.CMNumTxt:ClearAllPoints()
  370.     frame.ManaNumTxtFrame.MMNumTxt:ClearAllPoints()
  371.     frame.InfoTextFrame.LvlClassText:ClearAllPoints()
  372.     frame.offDeadGhostTxtFrame.DeadOfflineTxt:ClearAllPoints()
  373.     frame.targetOfFrame.targetOfText:ClearAllPoints()
  374.    
  375.     -- Textures
  376.     frame.targetOfFrame.texture:ClearAllPoints()
  377. end
  378.  
  379.  
  380. -----------------------------
  381. -- Grim Layout Style 1 ------------
  382. -----------------------------
  383.  
  384. function GrimUI.GrimStyle1(id)
  385.    
  386.     local frame = _G['GrimUIPartyFrame' .. id]
  387.    
  388.     -- ClearAllPoints for all frames in this style.
  389.     PFClearAllPoints(id)
  390.    
  391.     -- main frame set height/width start
  392.     frame:SetWidth(223)
  393.     frame:SetHeight(135)
  394.  
  395.     -- pedestal
  396.     frame.PedestalFrame:SetPoint("BOTTOM", frame, "BOTTOM", -62, 0)
  397.     frame.PedestalFrame:SetHeight(15)
  398.     frame.PedestalFrame:SetWidth(49)
  399.     frame.PedestalFrame.texture:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\pedestal.tga")
  400.     frame.PedestalFrame:SetFrameStrata("LOW")
  401.     frame.PedestalFrame:SetFrameLevel("2")
  402.  
  403.     -- health bar start
  404.     frame.HealthBorder:SetHeight(100)
  405.     frame.HealthBorder:SetWidth(31)
  406.     frame.HealthBorder:SetPoint("BOTTOMLEFT", "GrimUIPartyFrame" .. id, "BOTTOMLEFT", 0, 0)
  407.     frame.HealthBorder:SetBackdrop{
  408.             bgFile = nil,
  409.             edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5,
  410.             insets = { left = 0, right = 0, top = 0, bottom = 0 }
  411.         }
  412.     frame.HealthBorder:SetBackdropBorderColor(0, 0, 0, 1)
  413.     frame.HealthBorder:SetFrameStrata("BACKGROUND")
  414.     frame.HealthBorder:SetFrameLevel("3")
  415.     frame.HealthBorder:RegisterForClicks("AnyUp")
  416.     frame.HealthBorder:SetAttribute("unit", "Party" .. id)
  417.     frame.HealthBorder:SetAttribute("*type1", "target")
  418.  
  419.     local showPartymenu = ToggleDropDownMenu(1, nil, _G["PartyMemberFrame"..id.."DropDown"], "cursor", 0, 0)
  420.  
  421.     frame.HealthBorder.showPartymenu = showPartymenu
  422.     frame.HealthBorder.unit = "party" .. id
  423.     frame.HealthBorder:SetAttribute("*type2", "showPartymenu")
  424.     frame.HealthBorder:SetScript("OnEnter", UnitFrame_OnEnter)
  425.     frame.HealthBorder:SetScript("OnLeave", UnitFrame_OnLeave)
  426.     frame.HealthBorder:SetFrameStrata("HIGH")
  427.     frame.HealthBorder:SetFrameLevel("2")
  428.  
  429.     frame.HealthBar:SetWidth(29)
  430.     frame.HealthBar:SetHeight(98)
  431.     frame.HealthBar:SetPoint("CENTER", frame.HealthBorder, "CENTER", 0, 0)
  432.     frame.HealthBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
  433.     frame.HealthBar:SetStatusBarColor(.231, .682, .419, 1)
  434.     frame.HealthBar:SetOrientation("VERTICAL")
  435.     frame.HealthBar:SetFrameStrata("BACKGROUND")
  436.     frame.HealthBar:SetFrameLevel("2")
  437.  
  438.     frame.HealthBorder.percentHText:SetPoint("TOP", frame.HealthBorder, "TOP", 0, -1)
  439.     frame.HealthBorder.percentHText:SetTextColor(1, 1, 1, 1)
  440.     frame.HealthBorder.percentHText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
  441.  
  442.     -- mana bar Start
  443.     frame.ManaBorder:SetHeight(100)
  444.     frame.ManaBorder:SetWidth(31)
  445.     frame.ManaBorder:SetPoint("BOTTOM", frame, "BOTTOM", -29, 0)
  446.     frame.ManaBorder:SetBackdrop{
  447.             bgFile = nil,
  448.             edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5,
  449.             insets = { left = 0, right = 0, top = 0, bottom = 0 }
  450.         }
  451.     frame.ManaBorder:SetBackdropBorderColor(0, 0, 0, 1)
  452.     frame.ManaBorder:SetFrameStrata("LOW")
  453.     frame.ManaBorder:SetFrameLevel("3")
  454.  
  455.     frame.ManaBorder:RegisterForClicks("AnyUp")
  456.     frame.ManaBorder:SetAttribute("unit", "Party" .. id)
  457.     frame.ManaBorder:SetAttribute("*type1", "target")
  458.     frame.ManaBorder.showPartymenu = showPartymenu
  459.     frame.ManaBorder.unit = "Party" .. id
  460.     frame.ManaBorder:SetAttribute("*type2", "showPartymenu")
  461.     frame.ManaBorder:SetScript("OnEnter", UnitFrame_OnEnter)
  462.     frame.ManaBorder:SetScript("OnLeave", UnitFrame_OnLeave)
  463.     frame.ManaBorder:SetFrameStrata("HIGH")
  464.     frame.ManaBorder:SetFrameLevel("2")
  465.  
  466.     frame.ManaBar:SetWidth(29)
  467.     frame.ManaBar:SetHeight(98)
  468.     frame.ManaBar:SetPoint("CENTER", frame.ManaBorder, "CENTER", 0, 0)
  469.     frame.ManaBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
  470.     frame.ManaBar:SetOrientation("VERTICAL")
  471.     frame.ManaBar:SetFrameStrata("BACKGROUND")
  472.     frame.ManaBar:SetFrameLevel("2")
  473.  
  474.     frame.ManaBorder.percentMText:SetPoint("TOP", frame.ManaBorder, "TOP", 0, -1)
  475.     frame.ManaBorder.percentMText:SetTextColor(1, 1, 1, 1)
  476.     frame.ManaBorder.percentMText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
  477.  
  478. --  TextInfo Frame Start
  479.     frame.InfoTextFrame:SetPoint("RIGHT", frame, "RIGHT", 0, -7)
  480.     frame.InfoTextFrame:SetWidth(125)
  481.     frame.InfoTextFrame:SetHeight(79)
  482.     frame.InfoTextFrame:SetFrameStrata("HIGH")
  483.     frame.InfoTextFrame:SetFrameLevel("5")
  484.     frame.InfoTextFrame:RegisterForClicks("AnyUp")
  485.     frame.InfoTextFrame:SetAttribute("unit", "Party" .. id)
  486.     frame.InfoTextFrame:SetAttribute("*type1", "target")
  487.     frame.InfoTextFrame.showPartymenu = showPartymenu
  488.     frame.InfoTextFrame.unit = "Party" .. id
  489.     frame.InfoTextFrame:SetAttribute("*type2", "showPartymenu")
  490.     frame.InfoTextFrame:SetScript("OnEnter", UnitFrame_OnEnter)
  491.     frame.InfoTextFrame:SetScript("OnLeave", UnitFrame_OnLeave)
  492.  
  493.     -- name text Frame Start
  494.     frame.InfoTextFrame.NameText:SetPoint("TOPLEFT", frame.InfoTextFrame, "TOPLEFT", -1, 0)
  495.     frame.InfoTextFrame.NameText:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", 0, 0)
  496.     frame.InfoTextFrame.NameText:SetJustifyH("LEFT")
  497.     frame.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  498.     frame.InfoTextFrame.NameText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 17, "OUTLINE")
  499.  
  500.     frame.LetterFrame:SetPoint("LEFT", frame.InfoTextFrame, "LEFT", 0, -20)
  501.     frame.LetterFrame:SetWidth(1)
  502.     frame.LetterFrame:SetHeight(1)
  503.    
  504.     frame.LetterFrame.LetterHText:SetPoint("LEFT", frame.LetterFrame, "LEFT", 2, 0)
  505.     frame.LetterFrame.LetterHText:SetTextColor(0.937, 1, 0.345, 1)
  506.     frame.LetterFrame.LetterHText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  507.    
  508.     frame.LetterFrame.LetterMText:SetPoint("LEFT", frame.LetterFrame, "LEFT", 60, 0)
  509.     frame.LetterFrame.LetterMText:SetTextColor(0.937, 1, 0.345, 1)
  510.     frame.LetterFrame.LetterMText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  511.    
  512.     frame.LetterFrame.LetterHText:SetText("H:")
  513.     frame.LetterFrame.LetterMText:SetText("M:")
  514.    
  515.     frame.LetterFrame.LetterHText:Show()
  516.     frame.LetterFrame.LetterMText:Show()
  517. ------------------------------------------------------------------------------
  518.     -- health numbered text start
  519.    
  520.     frame.HealthNumTxtFrame:SetPoint("LEFT", Party1InfoTextFrame, "LEFT", 0, -16)
  521.     frame.HealthNumTxtFrame:SetWidth(1)
  522.     frame.HealthNumTxtFrame:SetHeight(1)
  523.    
  524.     frame.HealthNumTxtFrame.chnumtxt:SetPoint("LEFT", frame.HealthNumTxtFrame , "LEFT", 16, 0)
  525.     frame.HealthNumTxtFrame.chnumtxt:SetTextColor(1, 1, 1, 1)
  526.     frame.HealthNumTxtFrame.chnumtxt:SetJustifyH("RIGHT")
  527.     frame.HealthNumTxtFrame.chnumtxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  528.    
  529.     frame.HealthNumTxtFrame.mhnumtxt:Show()
  530.     frame.HealthNumTxtFrame.mhnumtxt:SetPoint("TOP", frame.chnumtxtFrame , "BOTTOM", 0, 0)
  531.     frame.HealthNumTxtFrame.mhnumtxt:SetTextColor(1, 1, 1, 1)
  532.     frame.HealthNumTxtFrame.mhnumtxt:SetJustifyH("RIGHT")
  533.     frame.HealthNumTxtFrame.mhnumtxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  534.    
  535.     -- Mana numbered text start
  536.     frame.ManaNumTxtFrame:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", -8, -16)
  537.    
  538.     frame.ManaNumTxtFrame:SetWidth(1)
  539.     frame.ManaNumTxtFrame:SetHeight(1)
  540.    
  541.     frame.ManaNumTxtFrame.CMNumTxt:SetPoint("RIGHT", frame.ManaNumTxtFrame, "RIGHT", 0, 0)
  542.     frame.ManaNumTxtFrame.CMNumTxt:SetTextColor(1, 1, 1, 1)
  543.     frame.ManaNumTxtFrame.CMNumTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  544.    
  545.     frame.ManaNumTxtFrame.MMNumTxt:Show()
  546.     frame.ManaNumTxtFrame.MMNumTxt:SetPoint("TOP", frame.CMNumTxtFrame, "BOTTOM", 0, 0)
  547.     frame.ManaNumTxtFrame.MMNumTxt:SetTextColor(1, 1, 1, 1)
  548.     frame.ManaNumTxtFrame.MMNumTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  549.  
  550.     frame.InfoTextFrame.LvlClassText:SetPoint("TOP", frame.InfoTextFrame, "TOP", 0, -34)
  551.     frame.InfoTextFrame.LvlClassText:SetPoint("LEFT", frame.InfoTextFrame, "LEFT", 2, 0)
  552.     frame.InfoTextFrame.LvlClassText:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", 0, 0)
  553.     frame.InfoTextFrame.LvlClassText:SetJustifyH("LEFT")
  554.     frame.InfoTextFrame.LvlClassText:SetTextColor(0.937, 1, 0.345, 1)
  555.     frame.InfoTextFrame.LvlClassText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  556.    
  557.     -- party 1 party leader icon
  558.     frame.LeaderFrame:SetPoint("TOPLEFT", frame.InfoTextFrame, "TOPLEFT", 3, -17)
  559.     frame.LeaderFrame:SetHeight(20)
  560.     frame.LeaderFrame:SetWidth(20)
  561.     frame.LeaderFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon.blp")
  562.     frame.LeaderFrame:Hide()
  563.    
  564. -- Party 1 PVP icon
  565.     frame.pvpIconFrame:SetPoint("TOPLEFT", Party1InfoTextFrame, "TOPLEFT", 22, -17)
  566.     frame.pvpIconFrame:SetHeight(21)
  567.     frame.pvpIconFrame:SetWidth(21)
  568.    
  569.  
  570.     -- Offline/Dead overlay
  571.     frame.offDeadGhostTxtFrame:SetPoint("LEFT", frame, "LEFT", 15, 0)
  572.     frame.offDeadGhostTxtFrame:SetWidth(68)
  573.     frame.offDeadGhostTxtFrame:SetHeight(15)
  574.     frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetPoint("CENTER", frame.offDeadGhostTxtFrame , "CENTER", 0, 0)
  575.     frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetTextColor(.85, .10, .10, 1)
  576.     frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetJustifyH("CENTER")
  577.     frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 18, "OUTLINE")
  578.    
  579.     --Target targettarget Frame START
  580.     frame.targetOfFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 1)
  581.     frame.targetOfFrame:SetFrameStrata("HIGH")
  582.     frame.targetOfFrame:SetFrameLevel("5")
  583.     frame.targetOfFrame.targetOfText:SetPoint("CENTER", frame.targetOfFrame, "CENTER", 0, 2)
  584.     frame.targetOfFrame.targetOfText:SetPoint("LEFT", frame.targetOfFrame, "LEFT", 0, 1)
  585.     frame.targetOfFrame.targetOfText:SetPoint("RIGHT", frame.targetOfFrame, "RIGHT", 0, 1)
  586.     frame.targetOfFrame.targetOfText:SetTextColor(1, 1, 1, 1)
  587.     frame.targetOfFrame.targetOfText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 11, "OUTLINE")
  588.    
  589.     frame.targetOfClickFrame:SetWidth(122)
  590.     frame.targetOfClickFrame:SetHeight(19)
  591.     frame.targetOfFrame:SetWidth(122)
  592.     frame.targetOfFrame:SetHeight(19)
  593.     frame.targetOfClickFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 1)
  594.     frame.targetOfClickFrame:SetFrameStrata("HIGH")
  595.     frame.targetOfClickFrame:SetFrameLevel("6")
  596.    
  597.     frame.targetOfClickFrame:RegisterForClicks("AnyUp")
  598.     frame.targetOfClickFrame:SetAttribute("unit", "Party"..id.."target")
  599.     frame.targetOfClickFrame:SetAttribute("*type1", "target")
  600.     RegisterUnitWatch(frame.targetOfClickFrame)
  601.    
  602.     local showPartytargetmenu ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor", 0, 0)
  603.  
  604.     frame.targetOfClickFrame.showPartytargetmenu = showPartytargetmenu
  605.     frame.targetOfClickFrame.unit = "Party"..id.."target"
  606.     frame.targetOfClickFrame:SetAttribute("*type2", "showPartytargetmenu")
  607.     frame.targetOfClickFrame:SetScript("OnEnter", UnitFrame_OnEnter)
  608.     frame.targetOfClickFrame:SetScript("OnLeave", UnitFrame_OnLeave)
  609. end
  610.  
  611.  
  612. ----------------------
  613. -- PARTY STYLE 2 ------------
  614. ---------------------------
  615. function GrimUI.GrimStyle2(id)  
  616.     local frame = _G['GrimUIPartyFrame' .. id]
  617.    
  618.     -- ClearAllPoints for all frames in this style.
  619.     PFClearAllPoints(id)
  620.    
  621.     -- main frame set height/width start
  622.     frame:SetWidth(192)
  623.     frame:SetHeight(135)
  624.    
  625.     --  Party1 pedestal
  626.     Party1PedestalFrame:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 4, 0)
  627.     Party1PedestalFrame:SetHeight(15)
  628.     Party1PedestalFrame:SetWidth(49)
  629.     Party1PedestalFrame.texture:Hide()
  630.     Party1PedestalFrame.texture:ClearAllPoints()
  631.     Party1PedestalFrame.texture:Show()
  632.     Party1PedestalFrame.texture:SetAllPoints(Party1PedestalFrame)
  633.     Party1PedestalFrame.texture:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\pedestal.tga")
  634.     Party1PedestalFrame:SetFrameStrata("LOW")
  635.     Party1PedestalFrame:SetFrameLevel("2")
  636.    
  637.     -- party 1 health bar start
  638.     Party1HealthBorder:SetHeight(28)
  639.     Party1HealthBorder:SetWidth(140)
  640.     Party1HealthBorder:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 47)
  641.     Party1HealthBorder:SetBackdrop{
  642.             bgFile = nil,
  643.             edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5,
  644.             insets = { left = 0, right = 0, top = 0, bottom = 0 }
  645.         }
  646.     Party1HealthBorder:SetBackdropBorderColor(0, 0, 0, 1)
  647.     Party1HealthBorder:SetFrameStrata("BACKGROUND")
  648.     Party1HealthBorder:SetFrameLevel("3")
  649.     Party1HealthBorder:RegisterForClicks("AnyUp")
  650.     Party1HealthBorder:SetAttribute("unit", "Party1")
  651.     Party1HealthBorder:SetAttribute("*type1", "target")
  652.  
  653.         local showParty1menu = function()
  654.             ToggleDropDownMenu(1, nil, PartyMemberFrame1DropDown, "cursor", 0, 0)
  655.         end
  656.  
  657.     Party1HealthBorder.showParty1menu = showParty1menu
  658.     Party1HealthBorder.unit = "Party1"
  659.     Party1HealthBorder:SetAttribute("*type2", "showParty1menu")
  660.     Party1HealthBorder:SetScript("OnEnter", UnitFrame_OnEnter)
  661.     Party1HealthBorder:SetScript("OnLeave", UnitFrame_OnLeave)
  662.     Party1HealthBorder:SetFrameStrata("BACKGROUND")
  663.     Party1HealthBorder:SetFrameLevel("2")
  664.  
  665.     Party1HealthBar:SetHeight(26)
  666.     Party1HealthBar:SetWidth(138)
  667.    
  668.     Party1HealthBar:SetPoint("CENTER", Party1HealthBorder, "CENTER", 0, 0)
  669.    
  670.     Party1HealthBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
  671.     Party1HealthBar:SetStatusBarColor(.231, .682, .419, 1)
  672.     Party1HealthBar:SetOrientation("HORIZONTAL")
  673.     Party1HealthBar:SetFrameStrata("BACKGROUND")
  674.     Party1HealthBar:SetFrameLevel("2")
  675.  
  676.     percentParty1HText:SetPoint("BOTTOMLEFT", Party1HealthBorder, "BOTTOMLEFT", 0, 2)
  677.    
  678.     percentParty1HText:SetTextColor(1, 1, 1, 1)
  679.     percentParty1HText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
  680.  
  681. -- party 1 mana bar Start
  682.  
  683.     Party1ManaBorder:SetHeight(28)
  684.     Party1ManaBorder:SetWidth(140)
  685.     Party1ManaBorder:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 20)
  686.     Party1ManaBorder:SetBackdrop{
  687.             bgFile = nil,
  688.             edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5,
  689.             insets = { left = 0, right = 0, top = 0, bottom = 0 }
  690.         }
  691.     Party1ManaBorder:SetBackdropBorderColor(0, 0, 0, 1)
  692.     Party1ManaBorder:SetFrameStrata("BACKGROUND")
  693.     Party1ManaBorder:SetFrameLevel("3")
  694.  
  695.     Party1ManaBorder:RegisterForClicks("AnyUp")
  696.     Party1ManaBorder:SetAttribute("unit", "Party1")
  697.     Party1ManaBorder:SetAttribute("*type1", "target")
  698.  
  699.     local showParty1menu = function()
  700.         ToggleDropDownMenu(1, nil, PartyMemberFrame1DropDown, "cursor", 0, 0)
  701.     end
  702.    
  703.     Party1ManaBorder.showParty1menu = showParty1menu
  704.     Party1ManaBorder.unit = "Party1"
  705.     Party1ManaBorder:SetAttribute("*type2", "showParty1menu")
  706.     Party1ManaBorder:SetScript("OnEnter", UnitFrame_OnEnter)
  707.     Party1ManaBorder:SetScript("OnLeave", UnitFrame_OnLeave)
  708.     Party1ManaBorder:SetFrameStrata("BACKGROUND")
  709.     Party1ManaBorder:SetFrameLevel("2")
  710.  
  711.  
  712.     Party1ManaBar:SetWidth(138)
  713.     Party1ManaBar:SetHeight(26)
  714.     Party1ManaBar:SetPoint("CENTER", Party1ManaBorder, "CENTER", 0, 0)
  715.     Party1ManaBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
  716.     Party1ManaBar:SetOrientation("HORIZONTAL")
  717.     Party1ManaBar:SetFrameStrata("BACKGROUND")
  718.     Party1ManaBar:SetFrameLevel("2")
  719.  
  720.     percentParty1MText:SetPoint("BOTTOMLEFT", Party1ManaBorder, "BOTTOMLEFT", 0, 2)
  721.     percentParty1MText:SetTextColor(1, 1, 1, 1)
  722.     percentParty1MText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
  723.  
  724.  
  725.  
  726.    
  727. -- Party 1 Mana bar end
  728.  
  729. -- Party 1 TextInfo Frame Start
  730.  
  731.     Party1InfoTextFrame:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 75)
  732.     Party1InfoTextFrame:SetWidth(140)
  733.     Party1InfoTextFrame:SetHeight(26)
  734.     Party1InfoTextFrame:SetFrameStrata("HIGH")
  735.     Party1InfoTextFrame:SetFrameLevel("5")
  736.    
  737.     Party1InfoTextFrame:RegisterForClicks("AnyUp")
  738.     Party1InfoTextFrame:SetAttribute("unit", "Party1")
  739.     Party1InfoTextFrame:SetAttribute("*type1", "target")
  740.  
  741.         local showParty1menu = function()
  742.             ToggleDropDownMenu(1, nil, PartyMemberFrame1DropDown, "cursor", 0, 0)
  743.         end
  744.     Party1InfoTextFrame.showParty1menu = showParty1menu
  745.     Party1InfoTextFrame.unit = "Party1"
  746.     Party1InfoTextFrame:SetAttribute("*type2", "showParty1menu")
  747.     Party1InfoTextFrame:SetScript("OnEnter", UnitFrame_OnEnter)
  748.     Party1InfoTextFrame:SetScript("OnLeave", UnitFrame_OnLeave)
  749.    
  750.     -- party 1 name text Frame Start
  751.  
  752.     Party1NameText:SetPoint("TOPLEFT", Party1InfoTextFrame, "TOPLEFT", -1, 9)
  753.     Party1NameText:SetPoint("TOPRIGHT", Party1InfoTextFrame, "TOPRIGHT", 0, 9)
  754.     Party1NameText:SetJustifyH("LEFT")
  755.     Party1NameText:SetTextColor(1, 1, 1, 1)
  756.     Party1NameText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 17, "OUTLINE")
  757.  
  758.     -- health numbered text start
  759.     Party1HealthNumTxtFrame:SetPoint("RIGHT", Party1HealthBorder, "RIGHT", 0, 0)
  760.     Party1HealthNumTxtFrame:SetWidth(1)
  761.     Party1HealthNumTxtFrame:SetHeight(1)
  762.     Party1chnumtxtFrame:SetPoint("RIGHT", Party1HealthNumTxtFrame , "RIGHT", 0, 0)
  763.     Party1chnumtxtFrame:SetTextColor(1, 1, 1, 1)
  764.     Party1chnumtxtFrame:SetJustifyH("RIGHT")
  765.     Party1chnumtxtFrame:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  766.    
  767.     -- Mana numbered text start
  768.     Party1ManaNumTxtFrame:SetPoint("RIGHT", Party1ManaBorder, "RIGHT", 0, 0)
  769.     Party1ManaNumTxtFrame:SetWidth(1)
  770.     Party1ManaNumTxtFrame:SetHeight(1)
  771.    
  772.     Party1CMNumTxtFrame:SetPoint("RIGHT", Party1ManaNumTxtFrame, "RIGHT", 0, 0)
  773.     Party1CMNumTxtFrame:SetTextColor(1, 1, 1, 1)
  774.     Party1CMNumTxtFrame:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  775.    
  776.     --  mana numbered text end
  777.     ------------------------------
  778.  
  779.     Party1LvlClassText:SetPoint("BOTTOM", Party1InfoTextFrame, "BOTTOM", 0, 3)
  780.     Party1LvlClassText:SetPoint("LEFT", Party1InfoTextFrame, "LEFT", 2, 0)
  781.     Party1LvlClassText:SetPoint("RIGHT", Party1InfoTextFrame, "RIGHT", 0, 0)
  782.     Party1LvlClassText:SetJustifyH("LEFT")
  783.     Party1LvlClassText:SetTextColor(0.937, 1, 0.345, 1)
  784.     Party1LvlClassText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
  785.  
  786.     --  party leader icon
  787.     Party1LeaderFrame:SetPoint("BOTTOMRIGHT", Party1InfoTextFrame, "BOTTOMRIGHT", 0, 0)
  788.     Party1LeaderFrame:SetHeight(18)
  789.     Party1LeaderFrame:SetWidth(18)
  790.     Party1LeaderFrame.texture = Party1LeaderFrame:CreateTexture()
  791.     Party1LeaderFrame.texture:SetAllPoints(Party1LeaderFrame)
  792.     Party1LeaderFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon.blp")
  793.     Party1LeaderFrame:Hide()
  794.    
  795. -- PVP icon
  796.     Party1pvpIconFrame:SetPoint("BOTTOMRIGHT", Party1InfoTextFrame, "BOTTOMRIGHT", -18, -2)
  797.     Party1pvpIconFrame:SetHeight(19)
  798.     Party1pvpIconFrame:SetWidth(19)
  799.     Party1pvpIconFrame.texture = Party1pvpIconFrame:CreateTexture()
  800.     Party1pvpIconFrame.texture:SetAllPoints(Party1pvpIconFrame)
  801.  
  802.     -- Offline/Dead overlay
  803.     Party1offDeadGhostTxtFrame:SetPoint("LEFT", GUI_Party1Frame, "LEFT", 15, 0)
  804.    
  805.     Party1offDeadGhostTxtFrame:SetWidth(68)
  806.     Party1offDeadGhostTxtFrame:SetHeight(15)
  807.    
  808.     Party1DeadOfflineTxt:ClearAllPoints()
  809.     Party1DeadOfflineTxt:SetPoint("CENTER", Party1offDeadGhostTxtFrame , "CENTER", 0, 0)
  810.    
  811.     Party1DeadOfflineTxt:SetTextColor(.85, .10, .10, 1)
  812.     Party1DeadOfflineTxt:SetJustifyH("CENTER")
  813.     Party1DeadOfflineTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 18, "OUTLINE")
  814.    
  815.    
  816.     --Target targettarget Frame START
  817.     targetOfParty1Frame:SetWidth(140)
  818.     targetOfParty1Frame:SetHeight(19)
  819.     targetOfParty1Frame:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 1)
  820.    
  821.     Party1ttbg:SetAllPoints(targetOfParty1Frame)
  822.  
  823.     targetOfParty1Text:SetPoint("CENTER", targetOfParty1Frame, "CENTER", 0, 0)
  824.     targetOfParty1Text:SetPoint("LEFT", targetOfParty1Frame, "LEFT", 0, 1)
  825.     targetOfParty1Text:SetPoint("RIGHT", targetOfParty1Frame, "RIGHT", 0, 1)
  826.     targetOfParty1Text:SetTextColor(1, 1, 1, 1)
  827.     targetOfParty1Text:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 11, "OUTLINE")
  828.  
  829.     targetOfParty1Frame:SetScript("OnEvent", function(self)
  830.         GrimUI.Party1Style2TargEventFunc()
  831.     end)
  832.    
  833.     targetOfParty1ClickFrame:SetWidth(140)
  834.     targetOfParty1ClickFrame:SetHeight(19)
  835.    
  836.     targetOfParty1ClickFrame:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 1)
  837.    
  838.     targetOfParty1ClickFrame:SetFrameStrata("HIGH")
  839.     targetOfParty1ClickFrame:SetFrameLevel("6")
  840.    
  841.     targetOfParty1ClickFrame:RegisterForClicks("AnyUp")
  842.     targetOfParty1ClickFrame:SetAttribute("unit", "Party1target")
  843.     targetOfParty1ClickFrame:SetAttribute("*type1", "target")
  844.     RegisterUnitWatch(targetOfParty1ClickFrame)
  845.  
  846.         local showParty1targetmenu = function()
  847.             ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor", 0, 0)
  848.        
  849.         end
  850.        
  851.     targetOfParty1ClickFrame.showParty1targetmenu = showParty1targetmenu
  852.     targetOfParty1ClickFrame.unit = "Party1target"
  853.     targetOfParty1ClickFrame:SetAttribute("*type2", "showParty1targetmenu")
  854.     targetOfParty1ClickFrame:SetScript("OnEnter", UnitFrame_OnEnter)
  855.     targetOfParty1ClickFrame:SetScript("OnLeave", UnitFrame_OnLeave)
  856.    
  857.    
  858.     -- after thoughts
  859.     Party1LetterMText:Hide()
  860.     Party1LetterHText:Hide()
  861.     Party1MMNumTxt:Hide()
  862.     Party1mhnumtxt:Hide()
  863.    
  864. end
  865.  
  866.  
  867. ---------------------------------------------------
  868. ---- DUEL STYLE FUNCTIONS -------------------------
  869. ---------------------------------------------------
  870. function GrimUI.PartyNameColoring(self)
  871.     if UnitExists(self.unit) == 1 then
  872.         self.InfoTextFrame.NameText:SetFormattedText("%s", UnitName(self.unit))
  873.         if event == "PLAYER_ENTERING_WORLD" then
  874.             if UnitThreatSituation(self.unit) == nil then
  875.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  876.             else
  877.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  878.             end
  879.             if UnitAffectingCombat(self,unit) == nil then
  880.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  881.             else
  882.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  883.             end
  884.         end
  885.         if event == "UNIT_FLAGS" then
  886.             if UnitThreatSituation(self.unit) == nil then
  887.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  888.             else
  889.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  890.             end
  891.             if UnitAffectingCombat(self,unit) == nil then
  892.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  893.             else
  894.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  895.             end
  896.         end
  897.         if event == "UNIT_THREAT_LIST_UPDATE" then
  898.             if UnitThreatSituation(self.unit) == nil then
  899.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  900.             else
  901.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  902.             end
  903.             if UnitAffectingCombat(self,unit) == nil then
  904.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  905.             else
  906.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  907.             end
  908.         end
  909.         if event == "UNIT_THREAT_SITUATION_UPDATE" then
  910.             if UnitThreatSituation(self.unit) == nil then
  911.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  912.             else
  913.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  914.             end
  915.             if UnitAffectingCombat(self,unit) == nil then
  916.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  917.             else
  918.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  919.             end
  920.         end
  921.         if event == "UNIT_COMBAT" then
  922.             if UnitThreatSituation(self.unit) == nil then
  923.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  924.             else
  925.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  926.             end
  927.             if UnitAffectingCombat(self,unit) == nil then
  928.                 self.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
  929.             else
  930.                 self.InfoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
  931.             end
  932.         end
  933.     end
  934. end
  935.  
  936. ---------------------------------
  937. -- OnEvent SetScript Functions --
  938. ---------------------------------
  939. function GrimUI.PartyNameTextEvents(self)
  940.     if UnitExists(self.unit) == 1 then
  941.         self.InfoTextFrame.NameText:SetFormattedText("%s", UnitName(self.unit))
  942.     end
  943.     GrimUI.PartyNameColoring(self)
  944. end
  945.  
  946. function GrimUI.PartyLvlClassTextEvents(self)
  947.     if UnitExists(self.unit) == 1 and UnitClass(self.unit) ~= nil then
  948.         self.InfoTextFrame.LvlClassText:SetFormattedText("%s %s", UnitLevel(self.unit), UnitClass(self.unit))
  949.     elseif UnitExists(self.unit) == 1 and UnitClass(self.unit) == nil then
  950.         self.InfoTextFrame.LvlClassText:SetText("")
  951.     end
  952. end
  953.  
  954. function GrimUI.PartyPartyLeaderEvent(self)
  955.     if UnitIsPartyLeader(self.unit) == 1 then
  956.         self.Party1LeaderFrame:Show()
  957.     end
  958.     if UnitIsPartyLeader(self.unit) ~= 1 then
  959.         self.Party1LeaderFrame:Hide()
  960.     end
  961. end
  962.  
  963. function GrimUI.PartypvpIconEvent()
  964.     if UnitFactionGroup(self.unit) == "Alliance" then    
  965.         self.pvpIconFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-PVP-Alliance.blp")
  966.     elseif UnitFactionGroup(self.unit) == "Horde" then
  967.         self.pvpIconFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-PVP-Horde.blp")
  968.     end
  969.     if UnitIsPVP(self.unit) == 1 then
  970.         self.Party1pvpIconFrame:Show()
  971.     end
  972.     if UnitIsPVP(self.unit) ~= 1 then
  973.         self.Party1pvpIconFrame:Hide()
  974.     end
  975. end
  976.  
  977. function GrimUI.PartyHealthEventFunc(self)
  978.    
  979.     local S1HealthText = ("%s/%s"):format(UnitHealth(self.unit), UnitHealthMax(self.unit))
  980.     local chnumtxt = ("%s"):format(UnitHealth(self.unit))
  981.     local mhnumtxt = ("%s"):format(UnitHealthMax(self.unit))
  982.    
  983.     if UnitIsConnected(self.unit) == nil or UnitHealth(self.unit) == nil or UnitHealthMax(self.unit) == nil then
  984.         self.HealthBorder.percentHText:SetText("0%")
  985.     else
  986.         local Hstr = ("%s%%"):format(floor(UnitHealth(self.unit) / UnitHealthMax(self.unit * 100)))
  987.         self.HealthBorder.percentHText:SetText(Hstr)
  988.     end
  989.    
  990.     self.HealthBar:SetMinMaxValues(min(0, UnitHealth(self.unit), UnitHealthMax(self.unit)))
  991.     self.HealthBar:SetValue(UnitHealth("Party1"))
  992.    
  993.     if GrimUIData.GUIPartyStyle == 1 then
  994.         self.HealthNumTxtFrame.chnumtxt:SetText(chnumtxt)
  995.         self.HealthNumTxtFrame.mhnumtxt:SetText(mhnumtxt)
  996.     elseif GrimUIData.GUIPartyStyle == 2 then
  997.         frame.HealthNumTxtFrame.chnumtxt:SetText(S1HealthText)
  998.     end
  999. end
  1000.  
  1001. function GrimUI.PartyManaEventFunc(self)
  1002.     if UnitManaMax(self.unit) >= 1 then
  1003.         local perMstr = ("%s%%"):format(floor(UnitMana(self.unit) / UnitManaMax(self.unit) * 100))
  1004.         self.ManaBorder.percentMText:SetText(perMstr)
  1005.     end
  1006.     if UnitManaMax(self.unit) == 0 then
  1007.         local perMstr = ("0%")
  1008.         self.ManaBorder.percentMText:SetText(perMstr)
  1009.     end
  1010.     if UnitPowerType(self.unit) == 0 then
  1011.         self.ManaBar:SetMinMaxValues(min(0, UnitMana("Party1")), UnitManaMax(self.unit))
  1012.         self.ManaBar:SetValue(UnitMana(self.unit))
  1013.         self.ManaBar:SetStatusBarColor(.556, .556, .921, 1)
  1014.     elseif UnitPowerType("Party1") == 1 or 3 or 6 then
  1015.         self.ManaBar:SetMinMaxValues(min(0, UnitPower("Party1")), UnitPowerMax(self.unit))
  1016.         self.ManaBar:SetValue(UnitPower(self.unit))
  1017.         self.ManaBar:SetStatusBarColor(.656, .456, .456, 1)
  1018.     end
  1019.     if GrimUIData.GUIPartyStyle == 1 then
  1020.         if UnitPowerType(self.unit) == 0 then
  1021.             local curmanaSTR = ("%s"):format(UnitMana(self.unit))
  1022.             local maxManaSTR = ("%s"):format(UnitManaMax(self.unit))
  1023.             self.ManaNumTxtFrame.CMNumTxt:SetText(Party1curmanaSTR)
  1024.             self.ManaNumTxtFrame.MMNumTxt:SetText(Party1maxManaSTR)
  1025.         elseif UnitPowerType(self.unit) == 1 or 3 or 6 then
  1026.             local Party1curpwrSTR = ("%s"):format(UnitPower(self.unit))
  1027.             local Party1maxpwrSTR = ("%s"):format(UnitPowerMax(self.unit))
  1028.             self.ManaNumTxtFrame.CMNumTxt:SetText(Party1curpwrSTR)
  1029.             self.ManaNumTxtFrame.MMNumTxt:SetText(Party1maxpwrSTR)
  1030.         end
  1031.     elseif GrimUIData.GUIPartyStyle == 2 then
  1032.         if UnitPowerType(self.unit) == 0 then
  1033.             local S1ManaText = ("%s/%s"):format(UnitMana(self.unit), UnitManaMax(self.unit))
  1034.             self.ManaNumTxtFrame.CMNumTxt:SetText(S1ManaText)
  1035.         elseif UnitPowerType(self.unit) == 1 or 3 or 6 then
  1036.             local S1ManaText = ("%s/%s"):format(UnitPower(self.unit), UnitPowerMax(self.unit))
  1037.             self.ManaNumTxtFrame.CMNumTxt:SetText(S1ManaText)
  1038.         end
  1039.     end
  1040. end
  1041.  
  1042. function GrimUI.PartyDeadOffLineEvents(self)
  1043.     if UnitIsDead(self.unit) == 1 and UnitIsConnected(self.unit) == 1 and UnitIsGhost(self.unit) == nil then
  1044.         Party1DeadOfflineTxt:SetText("Dead")
  1045.     elseif Party1isGhost == 1 and UnitIsConnected(self.unit) == 1 then
  1046.         Party1DeadOfflineTxt:SetText("Ghost")
  1047.     elseif UnitIsDead(self.unit) == nil and UnitIsConnected(self.unit) == nil and UnitIsGhost(self.unit) == nil then
  1048.         Party1DeadOfflineTxt:SetText("Offline")
  1049.     elseif UnitIsDead(self.unit) == 1 and UnitIsConnected(self.unit) == nil and UnitIsGhost(self.unit) == nil then
  1050.         Party1DeadOfflineTxt:SetText("Dead\n Offline")
  1051.     elseif UnitIsConnected(self.unit) == nil and UnitIsGhost(self.unit) == 1 then
  1052.         Party1DeadOfflineTxt:SetText("Ghost\n Offline")
  1053.     elseif UnitIsDead(self.unit) == nil and UnitIsConnected(self.unit) == 1 and UnitIsGhost(self.unit) == nil then
  1054.         Party1DeadOfflineTxt:SetText(nil)
  1055.     end
  1056.  
  1057. end
  1058.  
  1059. function GrimUI.PartyTargEventFunc(self)
  1060.     if UnitExists(self.unittarget) == 1 and UnitIsUnit(self.unittarget, "target") == 1 then
  1061.         frame.targetOfFrame.targetOfText:SetText("** YOUR TARGET **")
  1062.     end
  1063.     if  UnitExists(self.unittarget) == 1 and UnitName(self.unittarget) == UnitName("player") then
  1064.         frame.targetOfFrame.targetOfText:SetText("** YOU **")
  1065.     end
  1066.     if  UnitExists(self.unittarget) == 1 and UnitName(self.unittarget) ~= UnitName("player") and UnitIsUnit(self.unittarget, "target") ~= 1 then
  1067.         local nametstr = ("%s"):format(UnitName(self.unittarget))
  1068.         frame.targetOfFrame.targetOfText:SetText(nametstr)
  1069.     end
  1070.     if UnitExists(self.unittarget) == nil then
  1071.         frame.targetOfFrame.targetOfText:SetText("-No Target-")
  1072.         frame.targetOfFrame.texture:SetTexture(0, 0, 0, 0)
  1073.     end
  1074.     if UnitExists(self.unittarget) == 1 and UnitIsEnemy("player", self.unittarget) == 1 then
  1075.         frame.targetOfFrame.texture:SetTexture(.40, .10, .10, 1)
  1076.     end
  1077.     if UnitExists(self.unittarget) == 1 and UnitIsFriend("player", self.unittarget) == 1 then
  1078.         frame.targetOfFrame.texture:SetTexture(.10, .40, .10, 1)
  1079.     end
  1080. end
  1081.  
  1082. --###################
  1083. -- Party Event Scripts
  1084. --###################
  1085.  
  1086. local function GUISetPartyEventScripts(id)
  1087.     local frame = _G['GrimUIPartyFrame' .. id]
  1088.     frame.GUIHealthEvents:SetScript("OnEvent", GrimUI.HealthEventFunc)
  1089.  
  1090.     frame.GUIManaEvents:SetScript("OnEvent", GrimUI.ManaEventFunc)
  1091.  
  1092.     frame.GUINameTextEvents:SetScript("OnEvent", GrimUI.PartyNameTextEvents)
  1093.  
  1094.     frame.GUILvlClassTextEvents:SetScript("OnEvent", GrimUI.LvlClassTextEvents)
  1095.  
  1096.     frame.GUIpvpIconEvent:SetScript("OnEvent", GrimUI.pvpIconEvent)
  1097.  
  1098.     frame.GUIPartyLeaderEvent:SetScript("OnEvent", GrimUI.PartyLeaderEvent)
  1099.  
  1100.     frame.GUIOffLineDeadEvents:SetScript("OnEvent", GrimUI.DeadOffLineEvents)
  1101.  
  1102.     frame.GUItargetOfFrameEvents:SetScript("OnEvent", GrimUI.TargEventFunc)
  1103. end
  1104.  
  1105. for id = 1, 4 do
  1106.     GUISetPartyEventScripts(id)
  1107. end
  1108.  
  1109. ------------------------------------------------
  1110. -- SetAttribe Unit watchs for main party frames.
  1111. ------------------------------------------------
  1112. GrimUIPartyFrame1:SetAttribute('unit', 'Party1')
  1113. RegisterUnitWatch(GrimUIPartyFrame1)
  1114.  
  1115. GrimUIPartyFrame1:SetScript("OnShow", GrimUI.Party1LayoutInitiate)
  1116.  
  1117. GrimUIPartyFrame2:SetAttribute('unit', 'Party2')
  1118. RegisterUnitWatch(GrimUIPartyFrame2)
  1119.  
  1120. GrimUIPartyFrame2:SetScript("OnShow", GrimUI.Party2LayoutInitiate)
  1121.  
  1122. GrimUIPartyFrame3:SetAttribute('unit', 'Party3')
  1123. RegisterUnitWatch(GrimUIPartyFrame3)
  1124.  
  1125. GrimUIPartyFrame3:SetScript("OnShow", GrimUI.Party3LayoutInitiate)
  1126.  
  1127. GrimUIPartyFrame4:SetAttribute('unit', 'Party4')
  1128. RegisterUnitWatch(GrimUIPartyFrame4)
  1129.  
  1130. GrimUIPartyFrame4:SetScript("OnShow", GrimUI.Party4LayoutInitiate)
  1131.  
  1132. ------------------------
  1133. -- Update Party Frame Style select function
  1134. -------------------------
  1135.  
  1136. local function UpdatePartyStyle()
  1137.     if GrimUIData.GUIPartyStyle == 1 then
  1138.         for id = 1, 4 do
  1139.             GrimUI.GrimStyle1(id)
  1140.         end
  1141.     elseif GrimUIData.GUIPartyStyle == 2 then
  1142.         for id = 1, 4 do
  1143.             GrimUI.GrimStyle2(id)
  1144.         end
  1145.     end
  1146. end
  1147.  
  1148. GrimUI.UpdatePartyStyle = UpdatePartyStyle
  1149.  
  1150. ----------------------------------------------
  1151. -- PLAYER_ENTERING_WORLD functions - every load screen - reloads - instances
  1152. -----------------------------------------------
  1153. local GrimUIPartyFramesOnEntering = CreateFrame("Frame", "GrimUIPartyFramesOnEntering", UIParent)
  1154. GrimUIPartyFramesOnEntering:RegisterEvent("PLAYER_ENTERING_WORLD")
  1155. GrimUIPartyFramesOnEntering:SetScript("OnEvent", function(event)
  1156.    
  1157.     -- check opetions panel for GUI and Bliz hide options and then force one way or the other.
  1158.     GrimUI.PartyHideShowFunc()
  1159.     GrimUI.BPartyHideShowFunc()
  1160.    
  1161.     GrimUI.UpdatePartyStyle()
  1162.    
  1163.     -- run the layout update right before player enters the world.
  1164.     GrimUI.Party1LayoutInitiate()
  1165.     GrimUI.Party2LayoutInitiate()
  1166.     GrimUI.Party3LayoutInitiate()
  1167.     GrimUI.Party4LayoutInitiate()
  1168.    
  1169.     -- show in arenas checks after normal hideshow func so if you have chosen to hide its always hidden.
  1170.     local inInstance, instanceType = IsInInstance()
  1171.     if inInstance == 1 and instanceType == "arena" then
  1172.    
  1173.         if GrimUIData.GUIPartyFrame == "show" then
  1174.         GrimPartyMain.Show = GrimPartyMain:Show()
  1175.         GrimPartyMain:Show();
  1176.         elseif GrimUIData.GUIPartyFrame == "hide" then
  1177.         GrimPartyMain.Hide = GrimPartyMain:Hide()
  1178.         GrimPartyMain:Hide();
  1179.         end
  1180.     end
  1181.    
  1182.    
  1183. end)
  1184.  
  1185.     -- Clique inclusion start
  1186. --ClickCastFrames = ClickCastFrames or {}
  1187. --ClickCastFrames[healthborder] = true
  1188. --ClickCastFrames[GrimPlayerManaborder] = true
  1189. --ClickCastFrames[playerModelClickFrame] = true
  1190. -- Clique inclusion end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
06-16-10, 05:01 AM   #26
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Looking much better. I cleaned it up some but there is still more to do. Your separate frames for handling the events are going to be a pain because the frame they pass isn't the "main" frame that you coded the handlers around. I changed the .targetOf part to tie events directly to itself so that should help a little.

I also made it so that the frames (and their targets) should now auto show/hide and also register/unregister their events in the process. I commented out the other function you have for hiding/showing because it shouldn't be necessary and could actually make the current code break.

All dry-coded and untested of course...

Code:
local module = GrimUI:RegisterModule("PartyFrames")
 
-----------------------------------
-- Party Frame Header
-----------------------------------
local GrimPartyMain = CreateFrame('Frame', "GrimPartyMain", UIParent, 'SecureHandlerStateTemplate')

GrimPartyMain:SetAttribute('_onstate-group', [[
	self[newstate](self)
]])
 

--##########################################--
-- individual frame creations party 1,2,3,4 --
--##########################################--
local function showPartyMenu(self)
	ToggleDropDownMenu(1, nil, _G["PartyMemberFrame" .. self.id .. "DropDown"], "cursor", 0, 0)
end

local function showPartyTargetMenu(self)
	ToggleDropDownMenu(1, nil, TargetFrameDropDown, 'cursor', 0, 0)
end
 
local function CreateUnitButton(name, parent, unit, menufunc)
	local frame = CreateFrame('Button', name, parent, 'SecureUnitButtonTemplate')
	SecureUnitButton_OnLoad(frame, unit, menufunc)
	frame:RegisterForClicks('AnyUp')
	frame:SetScript('OnEnter', UnitFrame_OnEnter)
	frame:SetScript('OnLeave', UnitFrame_OnLeave)

	GrimPartyMain:WrapScript(frame, 'OnAttributeChanged', [[
		if name ~= 'state-exists' then return end
		self[value](self)
	]])
	RegisterStateDriver(frame, 'exists', ("[@%s, exists] Show; Hide"):format(unit))

	frame.unit = unit
	return frame
end
 
for id = 1, 4 do
	local unit = 'party' .. id
	local frame = CreateUnitButton("GrimUIPartyFrame" .. id, GrimPartyMain, unit, showPartyMenu)

	frame.id = id
	frame.unittarget = unit .. 'target'

	-- Pedestal Frame
	frame.PedestalFrame = CreateFrame("Frame", nil, frame)

	-- Health Bar
	frame.HealthBorder = CreateFrame("Button", nil, frame)
	frame.HealthBar = CreateFrame("StatusBar", nil, frame)
	frame.HealthNumTxtFrame = CreateFrame("Frame", nil, frame)

	-- Mana Bar
	frame.ManaBorder = CreateFrame("Button", nil, frame)
	frame.ManaBar = CreateFrame("StatusBar", nil, frame)
	frame.ManaNumTxtFrame = CreateFrame("Frame", nil, frame)

	-- Misc Frames
	frame.InfoTextFrame = CreateFrame("Button", nil, frame)
	frame.LetterFrame = CreateFrame("Frame", nil, frame)
	frame.LeaderFrame = CreateFrame("Frame", nil, frame)
	frame.pvpIconFrame = CreateFrame("Frame", nil, frame)
	frame.offDeadGhostTxtFrame = CreateFrame("Frame", nil, frame)

	-- Target Bar
	frame.targetOfFrame = CreateUnitButton(nil, frame, frame.unittarget, showPartyTargetMenu)
	RegisterUnitWatch(frame.targetOfFrame)

	-- texture creation
	frame.PedestalFrame.texture = frame.PedestalFrame:CreateTexture()
	frame.LeaderFrame.texture = frame.LeaderFrame:CreateTexture()
	frame.pvpIconFrame.texture = frame.pvpIconFrame:CreateTexture()
	frame.targetOfFrame.texture = frame.targetOfFrame:CreateTexture(nil, "BACKGROUND")

	-- texture SetAllPoints that remain the same for both party styles
	frame.PedestalFrame.texture:SetAllPoints()
	frame.targetOfFrame.texture:SetAllPoints()
	frame.LeaderFrame.texture:SetAllPoints()
	frame.pvpIconFrame.texture:SetAllPoints()

	-- font creation
	frame.HealthBorder.percentHText = frame.HealthBorder:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.ManaBorder.percentMText = frame.ManaBorder:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.InfoTextFrame.NameText = frame.InfoTextFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.LetterFrame.LetterHText = frame.LetterFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.LetterFrame.LetterMText = frame.LetterFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.HealthNumTxtFrame.chnumtxt = frame.HealthNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.HealthNumTxtFrame.mhnumtxt = frame.HealthNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.ManaNumTxtFrame.CMNumTxt = frame.ManaNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.ManaNumTxtFrame.MMNumTxt = frame.ManaNumTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.InfoTextFrame.LvlClassText = frame.InfoTextFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.offDeadGhostTxtFrame.DeadOfflineTxt = frame.offDeadGhostTxtFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	frame.targetOfFrame.targetOfText = frame.targetOfFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")

	-- event frames
	frame.GUIHealthEvents = CreateFrame("Frame", nil, frame) 
	frame.GUIManaEvents = CreateFrame("Frame", nil, frame)
	frame.GUINameTextEvents = CreateFrame("Frame", nil, frame)
	frame.GUILvlClassTextEvents = CreateFrame("frame", nil, frame)
	frame.GUIPartyLeaderEvent = CreateFrame("Frame", nil, frame)
	frame.GUIpvpIconEvent = CreateFrame("Frame", nil, frame)
	frame.GUIOffLineDeadEvents = CreateFrame("Frame", nil, frame)
end
 
 
--###############################################
--##   Event Frames for current Party Styles   ##
--###############################################
local function RegisterEvents(frame, ...)
	local Register = frame.RegisterEvent
	for index = 1, select('#', ...) do
		Register(frame, select(index, ...))
	end
end

local function OnHide(self)
	local Unregister = self.UnregisterAllEvents
	Unregister(self.GUIHealthEvents)
	Unregister(self.GUINameTextEvents)
	Unregister(self.GUILvlClassTextEvents)
	Unregister(self.GUIPartyLeaderEvent)
	Unregister(self.GUIpvpIconEvent)
	Unregister(self.GUIManaEvents)
	Unregister(self.GUIOffLineDeadEvents)
end

local function OnShow(self)
	RegisterEvents(self.GUIHealthEvents, 'PLAYER_ENTERING_WORLD', 'UNIT_HEALTH', 'UNIT_LEVEL', 'UNIT_AURA', 'UNIT_MAXHEALTH', 'PARTY_MEMBERS_CHANGED')
	RegisterEvents(self.GUINameTextEvents, 'PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'UNIT_NAME_UPDATE', 'UNIT_FLAGS', 'UNIT_THREAT_LIST_UPDATE', 'UNIT_THREAT_SITUATION_UPDATE', 'UNIT_COMBAT')
	RegisterEvents(self.GUILvlClassTextEvents, 'PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'UNIT_LEVEL')
	RegisterEvents(self.GUIPartyLeaderEvent, 'PLAYER_ENTERING_WORLD', 'PARTY_LEADER_CHANGED', 'PARTY_MEMBERS_CHANGED', 'ZONE_CHANGED_NEW_AREA')
	RegisterEvents(self.GUIpvpIconEvent, 'PLAYER_ENTERING_WORLD', 'UNIT_FACTION', 'PARTY_MEMBERS_CHANGED', 'UNIT_DYNAMIC_FLAGS')
	RegisterEvents(self.GUIManaEvents, 'PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'UNIT_HEALTH', 'UNIT_LEVEL', 'UNIT_MANA', 'UNIT_AURA','UNIT_DISPLAYPOWER', 'UNIT_ENERGY', 'UNIT_MAXENERGY', 'UNIT_MAXMANA', 'UNIT_MAXRUNICPOWER', 'UNIT_RUNIC_POWER', 'UNIT_RAGE')
	RegisterEvents(self.GUIOffLineDeadEvents, 'PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'PARTY_MEMBER_DISABLE', 'PARTY_MEMBER_ENABLE', 'UNIT_HEALTH')
end

local function OnShowTarget(self)
	RegisterEvents(self, 'PLAYER_ENTERING_WORLD', 'PARTY_MEMBERS_CHANGED', 'PARTY_LEADER_CHANGED', 'PLAYER_TARGET_CHANGED', 'UNIT_TARGET')
end

for id = 1, 4 do
	local frame = _G["GrimUIPartyFrame" .. id]
	frame:SetScript('OnHide', OnHide)
	frame:SetScript('OnShow', OnShow)
	frame.targetOf:SetScript('OnHide', frame.UnregisterAllEvents)
	frame.targetOf:SetScript('OnShow', OnShowTarget)
end
 
 
--################################--  DO NOT MESS WITH THIS ITS CRITICAL TO THE MOVEFRAMES.LUA 
--  PartyLayoutInitiate Function  --
--################################--

local function loadDefaultPosition(id, ...)
	local frame = _G["GrimUIPartyFrame" .. id]
	for index = 1, select('#', ...) do
		frame[index] = select(index, ...)
	end
end

loadDefaultPosition(1, "LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22)
loadDefaultPosition(2, "BOTTOMLEFT", GrimUIPartyFrame1, "BOTTOMRIGHT", -1, 0)
loadDefaultPosition(3, "RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22)
loadDefaultPosition(4, "BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0)

-- If these values are invalid then they should be purged, not allowed to persist:
--    all: points[1] == "nil"
--	party1: points[1] == "LEFT" and points[2] == "UIParent" and points[3] == "TOPRIGHT" then 
--	party2: points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then 
--	party3: points[1] == "RIGHT" and points[2] == "UIParent" and points[3] == "TOPLEFT" then 
--	party4: points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then 
 
function GrimUI.PartyLayoutInitiate()
	for id = 1, 4 do
		local name = "GrimUIPartyFrame" .. id
		local frame = _G[name]
		local points = not GrimLayout.disabled --[[and not GrimLayout.nosave]] and GrimLayout[name]
		frame:ClearAllPoints()
		if type(points) ~= 'table' or not pcall(frame.SetPoints, frame, unpack(points)) then
			frame:SetPoints(unpack(frame))
		end
	end
end


local function PFClearAllPoints(id)
	local frame = _G["GrimUIPartyFrame" .. id]

	-- frames
	frame.PedestalFrame:ClearAllPoints()
	frame.HealthBorder:ClearAllPoints()
	frame.HealthBar:ClearAllPoints()
	frame.ManaBorder:ClearAllPoints()
	frame.ManaBar:ClearAllPoints()
	frame.InfoTextFrame:ClearAllPoints()
	frame.LetterFrame:ClearAllPoints()
	frame.HealthNumTxtFrame:ClearAllPoints()
	frame.ManaNumTxtFrame:ClearAllPoints()
	frame.LeaderFrame:ClearAllPoints()
	frame.pvpIconFrame:ClearAllPoints()
	frame.offDeadGhostTxtFrame:ClearAllPoints()
	frame.targetOfFrame:ClearAllPoints()

	-- Textblocks
	frame.HealthBorder.percentHText:ClearAllPoints()
	frame.ManaBorder.percentMText:ClearAllPoints()
	frame.InfoTextFrame.NameText:ClearAllPoints()
	frame.LetterFrame.LetterHText:ClearAllPoints()
	frame.LetterFrame.LetterMText:ClearAllPoints()
	frame.HealthNumTxtFrame.chnumtxt:ClearAllPoints()
	frame.HealthNumTxtFrame.mhnumtxt:ClearAllPoints()
	frame.ManaNumTxtFrame.CMNumTxt:ClearAllPoints()
	frame.ManaNumTxtFrame.MMNumTxt:ClearAllPoints()
	frame.InfoTextFrame.LvlClassText:ClearAllPoints()
	frame.offDeadGhostTxtFrame.DeadOfflineTxt:ClearAllPoints()
	frame.targetOfFrame.targetOfText:ClearAllPoints()
 
	-- Textures
	frame.targetOfFrame.texture:ClearAllPoints()
end
 
 
-------------------------
-- Grim Layout Style 1 --
-------------------------
function GrimUI.GrimStyle1(id)
    local frame = _G["GrimUIPartyFrame" .. id]
    
    -- ClearAllPoints for all frames in this style.
    PFClearAllPoints(id)
    
    -- Main frame set height/width
    frame:SetWidth(223)
    frame:SetHeight(135)
 
    -- Pedestal
    frame.PedestalFrame:SetPoint("BOTTOM", frame, "BOTTOM", -62, 0)
    frame.PedestalFrame:SetHeight(15)
    frame.PedestalFrame:SetWidth(49)
    frame.PedestalFrame.texture:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\pedestal.tga")
    frame.PedestalFrame:SetFrameStrata("LOW")
    frame.PedestalFrame:SetFrameLevel("2")
 
    -- Hhealth bar
    frame.HealthBorder:SetHeight(100)
    frame.HealthBorder:SetWidth(31)
    frame.HealthBorder:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 0)
    frame.HealthBorder:SetBackdrop{ 
            bgFile = nil, 
            edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5, 
            insets = { left = 0, right = 0, top = 0, bottom = 0 } 
        } 
    frame.HealthBorder:SetBackdropBorderColor(0, 0, 0, 1)
    frame.HealthBorder:SetFrameStrata("HIGH")
    frame.HealthBorder:SetFrameLevel("2")
 
    frame.HealthBar:SetWidth(29)
    frame.HealthBar:SetHeight(98)
    frame.HealthBar:SetPoint("CENTER", frame.HealthBorder, "CENTER", 0, 0)
    frame.HealthBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
    frame.HealthBar:SetStatusBarColor(.231, .682, .419, 1)
    frame.HealthBar:SetOrientation("VERTICAL")
    frame.HealthBar:SetFrameStrata("BACKGROUND")
    frame.HealthBar:SetFrameLevel("2")
 
    frame.HealthBorder.percentHText:SetPoint("TOP", frame.HealthBorder, "TOP", 0, -1)
    frame.HealthBorder.percentHText:SetTextColor(1, 1, 1, 1)
    frame.HealthBorder.percentHText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
 
    -- Mana bar
    frame.ManaBorder:SetHeight(100)
    frame.ManaBorder:SetWidth(31)
    frame.ManaBorder:SetPoint("BOTTOM", frame, "BOTTOM", -29, 0)
    frame.ManaBorder:SetBackdrop{ 
            bgFile = nil, 
            edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5, 
            insets = { left = 0, right = 0, top = 0, bottom = 0 } 
        } 
    frame.ManaBorder:SetBackdropBorderColor(0, 0, 0, 1)
    frame.ManaBorder:SetFrameStrata("HIGH")
    frame.ManaBorder:SetFrameLevel("2")
 
    frame.ManaBar:SetWidth(29)
    frame.ManaBar:SetHeight(98)
    frame.ManaBar:SetPoint("CENTER", frame.ManaBorder, "CENTER", 0, 0)
    frame.ManaBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
    frame.ManaBar:SetOrientation("VERTICAL")
    frame.ManaBar:SetFrameStrata("BACKGROUND")
    frame.ManaBar:SetFrameLevel("2")
 
    frame.ManaBorder.percentMText:SetPoint("TOP", frame.ManaBorder, "TOP", 0, -1)
    frame.ManaBorder.percentMText:SetTextColor(1, 1, 1, 1)
    frame.ManaBorder.percentMText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
 
    -- TextInfo
    frame.InfoTextFrame:SetPoint("RIGHT", frame, "RIGHT", 0, -7)
    frame.InfoTextFrame:SetWidth(125)
    frame.InfoTextFrame:SetHeight(79)
    frame.InfoTextFrame:SetFrameStrata("HIGH")
    frame.InfoTextFrame:SetFrameLevel("5")
 
    -- Name text
    frame.InfoTextFrame.NameText:SetPoint("TOPLEFT", frame.InfoTextFrame, "TOPLEFT", -1, 0)
    frame.InfoTextFrame.NameText:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", 0, 0)
    frame.InfoTextFrame.NameText:SetJustifyH("LEFT")
    frame.InfoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
    frame.InfoTextFrame.NameText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 17, "OUTLINE")
 
    frame.LetterFrame:SetPoint("LEFT", frame.InfoTextFrame, "LEFT", 0, -20)
    frame.LetterFrame:SetWidth(1)
    frame.LetterFrame:SetHeight(1)
    
    frame.LetterFrame.LetterHText:SetPoint("LEFT", frame.LetterFrame, "LEFT", 2, 0)
    frame.LetterFrame.LetterHText:SetTextColor(0.937, 1, 0.345, 1)
    frame.LetterFrame.LetterHText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    frame.LetterFrame.LetterMText:SetPoint("LEFT", frame.LetterFrame, "LEFT", 60, 0)
    frame.LetterFrame.LetterMText:SetTextColor(0.937, 1, 0.345, 1)
    frame.LetterFrame.LetterMText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    frame.LetterFrame.LetterHText:SetText("H:")
    frame.LetterFrame.LetterMText:SetText("M:")
    
    frame.LetterFrame.LetterHText:Show()
    frame.LetterFrame.LetterMText:Show()

    -- health numbered text start
    frame.HealthNumTxtFrame:SetPoint("LEFT", frame.InfoTextFrame, "LEFT", 0, -16)
    frame.HealthNumTxtFrame:SetWidth(1)
    frame.HealthNumTxtFrame:SetHeight(1)
    
    frame.HealthNumTxtFrame.chnumtxt:SetPoint("LEFT", frame.HealthNumTxtFrame , "LEFT", 16, 0)
    frame.HealthNumTxtFrame.chnumtxt:SetTextColor(1, 1, 1, 1)
    frame.HealthNumTxtFrame.chnumtxt:SetJustifyH("RIGHT")
    frame.HealthNumTxtFrame.chnumtxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    frame.HealthNumTxtFrame.mhnumtxt:Show()
    frame.HealthNumTxtFrame.mhnumtxt:SetPoint("TOP", frame.chnumtxtFrame , "BOTTOM", 0, 0)
    frame.HealthNumTxtFrame.mhnumtxt:SetTextColor(1, 1, 1, 1)
    frame.HealthNumTxtFrame.mhnumtxt:SetJustifyH("RIGHT")
    frame.HealthNumTxtFrame.mhnumtxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    -- Mana numbered text start
    frame.ManaNumTxtFrame:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", -8, -16)
    
    frame.ManaNumTxtFrame:SetWidth(1)
    frame.ManaNumTxtFrame:SetHeight(1)
    
    frame.ManaNumTxtFrame.CMNumTxt:SetPoint("RIGHT", frame.ManaNumTxtFrame, "RIGHT", 0, 0)
    frame.ManaNumTxtFrame.CMNumTxt:SetTextColor(1, 1, 1, 1)
    frame.ManaNumTxtFrame.CMNumTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    frame.ManaNumTxtFrame.MMNumTxt:Show()
    frame.ManaNumTxtFrame.MMNumTxt:SetPoint("TOP", frame.CMNumTxtFrame, "BOTTOM", 0, 0)
    frame.ManaNumTxtFrame.MMNumTxt:SetTextColor(1, 1, 1, 1)
    frame.ManaNumTxtFrame.MMNumTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
 
    frame.InfoTextFrame.LvlClassText:SetPoint("TOP", frame.InfoTextFrame, "TOP", 0, -34)
    frame.InfoTextFrame.LvlClassText:SetPoint("LEFT", frame.InfoTextFrame, "LEFT", 2, 0)
    frame.InfoTextFrame.LvlClassText:SetPoint("RIGHT", frame.InfoTextFrame, "RIGHT", 0, 0)
    frame.InfoTextFrame.LvlClassText:SetJustifyH("LEFT")
    frame.InfoTextFrame.LvlClassText:SetTextColor(0.937, 1, 0.345, 1)
    frame.InfoTextFrame.LvlClassText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    -- Leader icon
    frame.LeaderFrame:SetPoint("TOPLEFT", frame.InfoTextFrame, "TOPLEFT", 3, -17)
    frame.LeaderFrame:SetHeight(20)
    frame.LeaderFrame:SetWidth(20)
    frame.LeaderFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon.blp")
    frame.LeaderFrame:Hide()
    
    -- PVP icon
    frame.pvpIconFrame:SetPoint("TOPLEFT", frame.InfoTextFrame, "TOPLEFT", 22, -17)
    frame.pvpIconFrame:SetHeight(21)
    frame.pvpIconFrame:SetWidth(21)
 
    -- Offline/Dead overlay
    frame.offDeadGhostTxtFrame:SetPoint("LEFT", frame, "LEFT", 15, 0)
    frame.offDeadGhostTxtFrame:SetWidth(68)
    frame.offDeadGhostTxtFrame:SetHeight(15)
    frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetPoint("CENTER", frame.offDeadGhostTxtFrame , "CENTER", 0, 0)
    frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetTextColor(.85, .10, .10, 1)
    frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetJustifyH("CENTER")
    frame.offDeadGhostTxtFrame.DeadOfflineTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 18, "OUTLINE")
    
    -- Target of target
    frame.targetOfFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 1)
    frame.targetOfFrame:SetWidth(122)
    frame.targetOfFrame:SetHeight(19)
    frame.targetOfFrame:SetFrameStrata("HIGH")
    frame.targetOfFrame:SetFrameLevel("5")
    frame.targetOfFrame.targetOfText:SetPoint("CENTER", frame.targetOfFrame, "CENTER", 0, 2)
    frame.targetOfFrame.targetOfText:SetPoint("LEFT", frame.targetOfFrame, "LEFT", 0, 1)
    frame.targetOfFrame.targetOfText:SetPoint("RIGHT", frame.targetOfFrame, "RIGHT", 0, 1)
    frame.targetOfFrame.targetOfText:SetTextColor(1, 1, 1, 1)
    frame.targetOfFrame.targetOfText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 11, "OUTLINE")
end
 
 
-------------------------
-- Grim Layout Style 2 --
-------------------------
function GrimUI.GrimStyle2(id)  
    local frame = _G["GrimUIPartyFrame" .. id]
    
    -- ClearAllPoints for all frames in this style.
    PFClearAllPoints(id)
    
    -- Mmain frame set height/width
    frame:SetWidth(192)
    frame:SetHeight(135)
    
    -- Pedestal
    Party1PedestalFrame:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 4, 0)
    Party1PedestalFrame:SetHeight(15)
    Party1PedestalFrame:SetWidth(49)
    Party1PedestalFrame.texture:Hide()
    Party1PedestalFrame.texture:ClearAllPoints()
    Party1PedestalFrame.texture:Show()
    Party1PedestalFrame.texture:SetAllPoints(Party1PedestalFrame)
    Party1PedestalFrame.texture:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\pedestal.tga")
    Party1PedestalFrame:SetFrameStrata("LOW")
    Party1PedestalFrame:SetFrameLevel("2")
    
    -- party 1 health bar start
    Party1HealthBorder:SetHeight(28)
    Party1HealthBorder:SetWidth(140)
    Party1HealthBorder:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 47)
    Party1HealthBorder:SetBackdrop{ 
            bgFile = nil, 
            edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5, 
            insets = { left = 0, right = 0, top = 0, bottom = 0 } 
        } 
    Party1HealthBorder:SetBackdropBorderColor(0, 0, 0, 1)
    Party1HealthBorder:SetFrameStrata("BACKGROUND")
    Party1HealthBorder:SetFrameLevel("2")
 
    Party1HealthBar:SetHeight(26)
    Party1HealthBar:SetWidth(138)
    
    Party1HealthBar:SetPoint("CENTER", Party1HealthBorder, "CENTER", 0, 0)
    
    Party1HealthBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
    Party1HealthBar:SetStatusBarColor(.231, .682, .419, 1)
    Party1HealthBar:SetOrientation("HORIZONTAL")
    Party1HealthBar:SetFrameStrata("BACKGROUND")
    Party1HealthBar:SetFrameLevel("2")
 
    percentParty1HText:SetPoint("BOTTOMLEFT", Party1HealthBorder, "BOTTOMLEFT", 0, 2)
    
    percentParty1HText:SetTextColor(1, 1, 1, 1)
    percentParty1HText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")
 
-- party 1 mana bar Start
 
    Party1ManaBorder:SetHeight(28)
    Party1ManaBorder:SetWidth(140)
    Party1ManaBorder:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 20)
    Party1ManaBorder:SetBackdrop{ 
            bgFile = nil, 
            edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 5, 
            insets = { left = 0, right = 0, top = 0, bottom = 0 } 
        } 
    Party1ManaBorder:SetBackdropBorderColor(0, 0, 0, 1)
    Party1ManaBorder:SetFrameStrata("BACKGROUND")
    Party1ManaBorder:SetFrameLevel("2")

    Party1ManaBar:SetWidth(138)
    Party1ManaBar:SetHeight(26)
    Party1ManaBar:SetPoint("CENTER", Party1ManaBorder, "CENTER", 0, 0)
    Party1ManaBar:SetStatusBarTexture("Interface\\AddOns\\!GrimUI\\Art\\VBarTexture.tga")
    Party1ManaBar:SetOrientation("HORIZONTAL")
    Party1ManaBar:SetFrameStrata("BACKGROUND")
    Party1ManaBar:SetFrameLevel("2")
 
    percentParty1MText:SetPoint("BOTTOMLEFT", Party1ManaBorder, "BOTTOMLEFT", 0, 2)
    percentParty1MText:SetTextColor(1, 1, 1, 1)
    percentParty1MText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 10, "NORMAL")

-- Party 1 Mana bar end 
 
-- Party 1 TextInfo Frame Start
 
    Party1InfoTextFrame:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 75)
    Party1InfoTextFrame:SetWidth(140)
    Party1InfoTextFrame:SetHeight(26)
    Party1InfoTextFrame:SetFrameStrata("HIGH")
    Party1InfoTextFrame:SetFrameLevel("5")
    
    -- party 1 name text Frame Start
 
    Party1NameText:SetPoint("TOPLEFT", Party1InfoTextFrame, "TOPLEFT", -1, 9)
    Party1NameText:SetPoint("TOPRIGHT", Party1InfoTextFrame, "TOPRIGHT", 0, 9)
    Party1NameText:SetJustifyH("LEFT")
    Party1NameText:SetTextColor(1, 1, 1, 1)
    Party1NameText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 17, "OUTLINE")
 
    -- health numbered text start
    Party1HealthNumTxtFrame:SetPoint("RIGHT", Party1HealthBorder, "RIGHT", 0, 0)
    Party1HealthNumTxtFrame:SetWidth(1)
    Party1HealthNumTxtFrame:SetHeight(1)
    Party1chnumtxtFrame:SetPoint("RIGHT", Party1HealthNumTxtFrame , "RIGHT", 0, 0)
    Party1chnumtxtFrame:SetTextColor(1, 1, 1, 1)
    Party1chnumtxtFrame:SetJustifyH("RIGHT")
    Party1chnumtxtFrame:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    -- Mana numbered text start
    Party1ManaNumTxtFrame:SetPoint("RIGHT", Party1ManaBorder, "RIGHT", 0, 0)
    Party1ManaNumTxtFrame:SetWidth(1)
    Party1ManaNumTxtFrame:SetHeight(1)
    
    Party1CMNumTxtFrame:SetPoint("RIGHT", Party1ManaNumTxtFrame, "RIGHT", 0, 0)
    Party1CMNumTxtFrame:SetTextColor(1, 1, 1, 1)
    Party1CMNumTxtFrame:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
    
    --  mana numbered text end
    ------------------------------
 
    Party1LvlClassText:SetPoint("BOTTOM", Party1InfoTextFrame, "BOTTOM", 0, 3)
    Party1LvlClassText:SetPoint("LEFT", Party1InfoTextFrame, "LEFT", 2, 0)
    Party1LvlClassText:SetPoint("RIGHT", Party1InfoTextFrame, "RIGHT", 0, 0)
    Party1LvlClassText:SetJustifyH("LEFT")
    Party1LvlClassText:SetTextColor(0.937, 1, 0.345, 1)
    Party1LvlClassText:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 12, "OUTLINE")
 
    --  party leader icon
    Party1LeaderFrame:SetPoint("BOTTOMRIGHT", Party1InfoTextFrame, "BOTTOMRIGHT", 0, 0)
    Party1LeaderFrame:SetHeight(18)
    Party1LeaderFrame:SetWidth(18)
    Party1LeaderFrame.texture = Party1LeaderFrame:CreateTexture()
    Party1LeaderFrame.texture:SetAllPoints(Party1LeaderFrame)
    Party1LeaderFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon.blp")
    Party1LeaderFrame:Hide()
    
-- PVP icon
    Party1pvpIconFrame:SetPoint("BOTTOMRIGHT", Party1InfoTextFrame, "BOTTOMRIGHT", -18, -2)
    Party1pvpIconFrame:SetHeight(19)
    Party1pvpIconFrame:SetWidth(19)
    Party1pvpIconFrame.texture = Party1pvpIconFrame:CreateTexture()
    Party1pvpIconFrame.texture:SetAllPoints(Party1pvpIconFrame)
 
    -- Offline/Dead overlay
    Party1offDeadGhostTxtFrame:SetPoint("LEFT", GUI_Party1Frame, "LEFT", 15, 0)
    
    Party1offDeadGhostTxtFrame:SetWidth(68)
    Party1offDeadGhostTxtFrame:SetHeight(15)
    
    Party1DeadOfflineTxt:ClearAllPoints()
    Party1DeadOfflineTxt:SetPoint("CENTER", Party1offDeadGhostTxtFrame , "CENTER", 0, 0)
    
    Party1DeadOfflineTxt:SetTextColor(.85, .10, .10, 1)
    Party1DeadOfflineTxt:SetJustifyH("CENTER")
    Party1DeadOfflineTxt:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font1.ttf", 18, "OUTLINE")
    
    
    --Target targettarget Frame START 
    targetOfParty1Frame:SetWidth(140)
    targetOfParty1Frame:SetHeight(19)
    targetOfParty1Frame:SetPoint("BOTTOMRIGHT", GUI_Party1Frame, "BOTTOMRIGHT", 0, 1)
    
    Party1ttbg:SetAllPoints(targetOfParty1Frame)
 
    targetOfParty1Text:SetPoint("CENTER", targetOfParty1Frame, "CENTER", 0, 0)
    targetOfParty1Text:SetPoint("LEFT", targetOfParty1Frame, "LEFT", 0, 1)
    targetOfParty1Text:SetPoint("RIGHT", targetOfParty1Frame, "RIGHT", 0, 1)
    targetOfParty1Text:SetTextColor(1, 1, 1, 1)
    targetOfParty1Text:SetFont("Interface\\AddOns\\!GrimUI\\Fonts\\GrimUI_Font3.ttf", 11, "OUTLINE")
 
    targetOfParty1Frame:SetScript("OnEvent", function(self) 
        GrimUI.Party1Style2TargEventFunc()
    end)
    
    -- after thoughts
    Party1LetterMText:Hide()
    Party1LetterHText:Hide()
    Party1MMNumTxt:Hide()
    Party1mhnumtxt:Hide()
end

 
-----------------------
-- OnEvent Functions --
-----------------------
local function PartyNameTextEvents(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	local name = UnitName(self.unit)
	if name then
		self = self.infoTextFrame.NameText
		self.infoTextFrame.NameText:SetText(name)
		if UnitThreatSituation(self.unit) or UnitAffectingCombat(self.unit) then
			self.infoTextFrame.NameText:SetTextColor(1, 0, 0, 1)
		else
			self.infoTextFrame.NameText:SetTextColor(1, 1, 1, 1)
		end
	end
end
 
local function PartyLvlClassTextEvents(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	local class = UnitClass(self.unit)
	if class then
		self.InfoTextFrame.LvlClassText:SetFormattedText("%s %s", UnitLevel(self.unit), class)
	else
		self.InfoTextFrame.LvlClassText:SetText("")
	end
end
 
local function PartyPartyLeaderEvent(self)
	if UnitIsPartyLeader(self.unit) then
		self.LeaderFrame:Show()
	else
		self.LeaderFrame:Hide()
	end
end
 
local function PartypvpIconEvent(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	if UnitIsPVP(self.unit) then
		self.pvpIconFrame:Show()
	else
		self.pvpIconFrame:Hide()
	end
end
 
local function PartyHealthEventFunc(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	local curHealth, maxHealth = UnitHealth(self.unit), UnitHealthMax(self.unit)
	if curHealth and maxHealth and UnitIsConnected(self.unit) then
		self.HealthBorder.percentHText:SetFormattedText("%s%%", floor(curHealth / maxHealth * 100))
		self.HealthBar:SetMinMaxValues(min(0, curHealth), maxHealth)) 
		self.HealthBar:SetValue(curHealth) 
		if GrimUIData.GUIPartyStyle == 2 then 
			self.HealthNumTxtFrame.chnumtxt:SetFormattedText("%s/%s", curHealth, maxHealth)
		else
			self.HealthNumTxtFrame.chnumtxt:SetText(curHealth) 
			self.HealthNumTxtFrame.mhnumtxt:SetText(maxHealth)
		end
	else
		self.HealthBorder.percentHText:SetText("0%")
	end
end
 
local function PartyManaEventFunc(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	local powerType, curPower, maxPower = UnitPowerType(self.unit)
	if powerType == 0 then
		curPower, maxPower = UnitMana(self.unit), UnitMaxMana(self.unit)
		self.ManaBar:SetMinMaxValues(min(0, curPower), maxPower)
		self.ManaBar:SetValue(curPower) 
		self.ManaBar:SetStatusBarColor(0.556, 0.556, 0.921, 1)
	elseif powerType == 1 or powerType == 3 or powerType == 6 then
		curPower, maxPower = UnitPower(self.unit), UnitPowerMax(self.unit)
		self.ManaBar:SetMinMaxValues(min(0, curPower), maxPower)
		self.ManaBar:SetValue(curPower)
		self.ManaBar:SetStatusBarColor(0.656, 0.456, 0.456, 1)
	else
		return
	end

	if maxPower > 0 then
		self.ManaBorder.percentMText:SetFormattedText("%s%%", floor(curPower / maxPower * 100))
	else
		self.ManaBorder.percentMText:SetText("0%")
	end

	if GrimUIData.GUIPartyStyle == 2 then 
		self.ManaNumTxtFrame.CMNumTxt:SetFormattedText("%s/%s", curPower, maxPower) 
	else
		self.ManaNumTxtFrame.CMNumTxt:SetText(curPower)
		self.ManaNumTxtFrame.MMNumTxt:SetText(maxPower)
	end
end

 
local function PartyDeadOffLineEvents(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	if not UnitIsConnected(self.unit) then
		if UnitIsGhost(self.unit) then
			self.DeadOfflineTxt:SetText("Ghost\n Offline")
		elseif UnitIsDead(self.unit) then
			self.DeadOfflineTxt:SetText("Dead\n Offline")
		else
			self.DeadOfflineTxt:SetText("Offline")
		end
	elseif UnitIsGhost(self.unit) then
		self.DeadOfflineTxt:SetText("Ghost")
	elseif UnitIsDead(self.unit) then
		self.DeadOfflineTxt:SetText("Dead")
	else
		self.DeadOfflineTxt:SetText("")
	end
end


local function PartyTargEventFunc(self, event, unit)
	if event:match('^UNIT_') and self.unit ~= unit then return end
	if UnitExists(self.unit) then
		if UnitIsUnit(self.unit, 'player') then
			self.targetOfText:SetText("** YOU **")
		elseif UnitIsUnit(self.unittarget, 'target') then
			self.targetOfText:SetText("** YOUR TARGET **")
		else
			self.targetOfText:SetText(UnitName(self.unit))
		end
		if UnitIsFriend(self.unit, 'player') then
			self.texture:SetTexture(0.10, 0.40, 0.10, 1)
		else
			self.texture:SetTexture(0.40, 0.10, 0.10, 1)
		end
	else
		self.targetOfText:SetText("-No Target-")
		self.texture:SetTexture(0, 0, 0, 0)
	end
end


--###################
-- Party Event Scripts
--###################
for id = 1, 4 do
	local frame = _G['GrimUIPartyFrame' .. id]
	frame.GUIHealthEvents:SetScript("OnEvent", HealthEventFunc) 
	frame.GUIManaEvents:SetScript("OnEvent", ManaEventFunc) 
	frame.GUINameTextEvents:SetScript("OnEvent", PartyNameTextEvents)
	frame.GUILvlClassTextEvents:SetScript("OnEvent", LvlClassTextEvents) 
	frame.GUIpvpIconEvent:SetScript("OnEvent", pvpIconEvent) 
	frame.GUIPartyLeaderEvent:SetScript("OnEvent", PartyLeaderEvent) 
	frame.GUIOffLineDeadEvents:SetScript("OnEvent", DeadOffLineEvents)
	frame.targetOfFrame:SetScript("OnEvent", PartyTargEventFunc) 
end


------------------------
-- Update Party Frame Style select function
-------------------------
function GrimUI.UpdatePartyStyle()
	if GrimUIData.GUIPartyStyle == 2 then
		for id = 1, 4 do
			GrimUI.GrimStyle2(id)
		end
	else	-- Default to 1
		for id = 1, 4 do
			GrimUI.GrimStyle1(id)
		end
	end
end


-----------------------------------------------------
-- One time init and then monitor for cvar changes --
-----------------------------------------------------
local monitor = CreateFrame('Frame')
monitor:SetScript('OnEvent', function(self, event)
	local pvpTexture = "Interface\\GroupFrame\\UI-Group-PVP-" .. UnitFactionGroup('player')
	for id = 1, 4 do
		_G["GrimUIPartyFrame" .. id].pvpIconFrame.texture:SetTexture(pvpTexture)
	end

--	GrimUI.PartyHideShowFunc()
	GrimUI.BPartyHideShowFunc()

	GrimUI.UpdatePartyStyle()
	GrimUI.PartyLayoutInitiate()

	self:SetScript('OnEvent', function(self, event, cvar, value)
		if event == 'CVAR_UPDATE' then
			if cvar ~= "hidePartyInRaid" then return end
			if value == "1" then
				RegisterStateDriver(GrimPartyMain, 'group', "[group:raid] Hide; [group:party] Show; Hide")
			else
				RegisterStateDriver(GrimPartyMain, 'group', "[group] Show; Hide")
			end
		else
			local inInstance, instanceType = IsInInstance()
			if inInstance and instanceType == "arena" and GrimUIData.GUIPartyFrame == "show" then
				RegisterStateDriver(GrimPartyMain, 'group', "Show")
			elseif GetCVarBool('hidePartyInRaid') then
				RegisterStateDriver(GrimPartyMain, 'group', "[group:raid] Hide; [group:party] Show; Hide")
			else
				RegisterStateDriver(GrimPartyMain, 'group', "[group] Show; Hide")
			end
		end
	end)
	self:RegisterEvent('CVAR_UPDATE')
end)
monitor:SetScript('PLAYER_ENTERING_WORLD')

 
    -- Clique inclusion start
--ClickCastFrames = ClickCastFrames or {}
--ClickCastFrames[healthborder] = true
--ClickCastFrames[GrimPlayerManaborder] = true
--ClickCastFrames[playerModelClickFrame] = true
-- Clique inclusion end

Last edited by Vrul : 06-16-10 at 05:52 AM. Reason: Cut-and-paste is too hard!
  Reply With Quote
06-16-10, 07:32 AM   #27
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmmm the only hide/show function i did was actually in the options file and it was so that people could force hide the party frames if they did not want to use the GrimUI partyframes at all. and of course a function that will force hide/show the bliz party frames to. its supposed to allow the user to chose either GrimUI party frames, bliz party frames or something else entirely. the function in the options.lua looks like this.

lua Code:
  1. function GrimUI:PartyHideShowFunc()
  2.    
  3.     if GrimUIData.GUIPartyFrame == "show" then
  4.     --GrimPartyMain.Show = GrimPartyMain:Show()
  5.     GrimPartyMain:Show()
  6.     --GrimPartyMain.Hide = GrimUI.Dummy
  7.    
  8.     end
  9.     if GrimUIData.GUIPartyFrame == "hide" then
  10.     --GrimPartyMain.Hide = GrimPartyMain:Hide()
  11.     GrimPartyMain:Hide()
  12.     --GrimPartyMain.Show = GrimUI.Dummy
  13.     end
  14. end

clearly i was already having problems with it which is why there is comment out sectins. anyway to restore that option?

oh yea about to test stuff, i dont fully understand what you did to the move frames section but it will be interesting if this works.

okay looked over everything and yea my options.lua is borked good now lol. also i fixed a few errors but one im not sure about its erroring on this piece of code and ive never seen an event set as a setscript, not sure what should be there? or if that is right and the error is in the script itself? monitor:SetScript('PLAYER_ENTERING_WORLD') monitor has a setscript is that just out of place? i commented it out and loaded bug free but its clear that the PLAYER_ENTERING_WORLD scripts are not running IE the bliz party frames do not do there show/hide check and when i invite someone to group the frames never appear but also no bugs either....

the bliz party frames just has to do with that monitor section and it not being called on PLAYER_ENTERING_WORLD
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 07:54 AM.
  Reply With Quote
06-16-10, 07:59 AM   #28
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
here is the option part that is a problem, i know that when its borked it can bork the whole partyframes.lua even if there are no errors in the partyframes.lua... or at lest it did before...

lua Code:
  1. ------------------------------------
  2.     -- GrimUI PartyFrame Layout style menue
  3.     ----------------
  4.  
  5.  
  6.     GrimUIPartyStyleMenu = CreateFrame("Frame", "GrimUIPartyStyleMenu", GrimOptionsPanel, "UIDropDownMenuTemplate");
  7.     GrimUIPartyStyleMenu:ClearAllPoints()
  8.     GrimUIPartyStyleMenu:SetPoint("LEFT",GrimOptionsPanel, 0, 70);
  9.     GrimUIPartyStyleMenu:Show()
  10.    
  11.     name = GrimUIPartyStyleMenu:CreateFontString()
  12.     name:SetPoint('LEFT', GrimUIPartyStyleMenu, 'RIGHT', -5, 0)
  13.     name:SetFontObject(GameFontNormal)
  14.     name:SetText('Party Frame Style')
  15.  
  16. local PartyStyleSelection = function()
  17.     local items = {
  18.        "Vertical Style",
  19.        "Horizontal Style",
  20.     }
  21.      
  22.     local function OnClick(self)
  23.        UIDropDownMenu_SetSelectedID(GrimUIPartyStyleMenu, self:GetID())
  24.        GrimUIData.GUIPartyStyle = self.value
  25.        
  26.         if GrimUIData.GUIPartyStyle == 1 then
  27.        
  28.         GrimUI.UpdatePartyStyle()
  29.        
  30.         GrimUI.PartyLayoutInitiate()
  31.  
  32.        
  33.  
  34.         end
  35.        
  36.         if GrimUIData.GUIPartyStyle == 2 then
  37.        
  38.         GrimUI.UpdatePartyStyle()
  39.         GrimUI.PartyLayoutInitiate()
  40.  
  41.        
  42.         end
  43.     end
  44.      
  45.     local function initialize(self, level)
  46.        for k,v in pairs(items) do
  47.           info = UIDropDownMenu_CreateInfo()
  48.           info.text = v
  49.           info.value = k
  50.           info.func = OnClick
  51.           UIDropDownMenu_AddButton(info, level)
  52.        end
  53.  
  54.     end
  55.      
  56.      
  57.      
  58.     UIDropDownMenu_Initialize(GrimUIPartyStyleMenu, initialize)
  59.     UIDropDownMenu_SetWidth(GrimUIPartyStyleMenu, 100);
  60.     UIDropDownMenu_SetButtonWidth(GrimUIPartyStyleMenu, 124)
  61.     UIDropDownMenu_SetSelectedID(GrimUIPartyStyleMenu, 1)
  62.     UIDropDownMenu_JustifyText(GrimUIPartyStyleMenu, "LEFT")
  63.  
  64. end
  65.  
  66. PartyStyleSelection()

and should this be setpoints? or setpoint? frame:SetPoints(unpack(frame)) im getting an error there. edit -- yes its supposed to be setpoint and not setpoints.... soon as i changed that no more positioning problems and my options panel is working again, two problems still all having to do with events and setscripts. So nothing is registering on player_entering_world? maybe that monitor:setScript"player_entering_world" part i commented out? also no events are registering still although maybe thats because of the monitor part?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 08:04 AM.
  Reply With Quote
06-16-10, 08:12 AM   #29
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
the frame movement is all borked to... the frame mover code looks like this... this is why those sections for initiate were critical they were designed to work in conjunction with this file...

lua Code:
  1. local module = GrimUI:RegisterModule("MoveFrames")
  2.  
  3. local addon = CreateFrame("Frame", nil, nil, "SecureActionButtonTemplate")
  4.  
  5. -- These frames are hooked on login.
  6. local frames = {
  7.   -- ["FrameName"] = true (the parent frame should be moved) or false (the frame itself should be moved)
  8.  
  9.   -- Blizzard Frames
  10.   ["RuneFrame"] = false,
  11.   --["SpellBookFrame"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  12.   ["QuestLogFrame"] = false,
  13.   --["FriendsFrame"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  14.   ["LFGParentFrame"] = false,
  15.   ["KnowledgeBaseFrame"] = true,
  16.   ["HelpFrame"] = false,
  17.   ["GossipFrame"] = false,
  18.   ["MerchantFrame"] = false,
  19.   ["MailFrame"] = false,
  20.   ["GuildRegistrarFrame"] = false,
  21.   ["DressUpFrame"] = false,
  22.   ["TabardFrame"] = false,
  23.   ["TaxiFrame"] = false,
  24.   ["QuestFrame"] = false,
  25.   ["TradeFrame"] = false,
  26.   ["LootFrame"] = false,  -- may cause taint with position saving testing!
  27.   ["PetStableFrame"] = false,
  28.   ["StackSplitFrame"] = false,
  29.   ["PetitionFrame"] = false,
  30.   ["WorldStateScoreFrame"] = false,
  31.   ["BattlefieldFrame"] = false,
  32.   ["ArenaFrame"] = false,
  33.   ["ItemTextFrame"] = false,
  34.   --["GameMenuFrame"] = false, -- causes taint errors with position saving.. testing!
  35.   ["InterfaceOptionsFrame"] = false, -- causes taint errors with position saving.. testing!
  36.   ["MacOptionsFrame"] = false,
  37.   --["PetPaperDollFrame"] = false, -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  38.   --["PetPaperDollFrameCompanionFrame"] = "false", -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  39.   --["PetPaperDollFramePetFrame"] = "false", -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  40.   ["PaperDollFrame"] = true, -- causes taint only for SetPoint on main frame! OnShow handler taint
  41.   ["ReputationFrame"] = true,
  42.   ["SkillFrame"] = true, -- causes taint only for SetPoint on main frame! OnShow handler taint
  43.   ["PVPFrame"] = true, -- causes taint only for SetPoint on main frame! OnShow handler taint
  44.   --["PVPBattlegroundFrame"] = false,
  45.   ["SendMailFrame"] = true,
  46.   ["TokenFrame"] = true,
  47.   ["InterfaceOptionsFrame"] = false,
  48.   ["VideoOptionsFrame"] = false,
  49.   ["AudioOptionsFrame"] = false,
  50.   ["BankFrame"] = false,
  51.   --["VehicleMenuBar"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  52.   ["TimeManagerFrame"] = false,
  53.   ["LFDParentFrame"] = false,
  54.   --["MultiBarBottomLeft"] = false, -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  55.   --["MultiBarLeft"] = false, -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  56.   --["MultiBarBottomRight"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  57.   --["MultiBarRight"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  58.   --["ShapeshiftBarFrame"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  59.   --["BonusActionBarFrame"] = false,  -- DONT MOVE THIS WITH THIS CODE TAINTS FRAME MANAGEMENT!!!!!!!
  60.  
  61.   -- GUI inclusions in this mess...
  62.  
  63.   ["GrimPlayerFrame"] = false,
  64.   --["InfoEventDisplayFrame"] = true,
  65.  
  66.  
  67.   ["GrimUIPartyFrame1"] = false,
  68.   ["GrimUIPartyFrame2"] = false,
  69.   ["GrimUIPartyFrame3"] = false,
  70.   ["GrimUIPartyFrame4"] = false,
  71.  
  72.   ["GUIObjectivesAnchor"] = false,
  73.  
  74.  
  75.  
  76.   -- AddOns
  77.   ["LudwigFrame"] = false,
  78. }
  79.  
  80. -- Frames provided by load on demand addons, hooked when the addon is loaded.
  81. local lodFrames = {
  82.   -- AddonName = { list of frames, same syntax as above }
  83.   Blizzard_AuctionUI = { ["AuctionFrame"] = false },
  84.   Blizzard_BindingUI = { ["KeyBindingFrame"] = false },
  85.   Blizzard_CraftUI = { ["CraftFrame"] = false },
  86.   Blizzard_GMSurveyUI = { ["GMSurveyFrame"] = false },
  87.   Blizzard_InspectUI = { ["InspectFrame"] = false, ["InspectPVPFrame"] = true, ["InspectTalentFrame"] = true },
  88.   Blizzard_ItemSocketingUI = { ["ItemSocketingFrame"] = false },
  89.   Blizzard_MacroUI = { ["MacroFrame"] = false },
  90.   Blizzard_TalentUI = { ["PlayerTalentFrame"] = false },
  91.   Blizzard_TradeSkillUI = { ["TradeSkillFrame"] = false },
  92.   Blizzard_TrainerUI = { ["ClassTrainerFrame"] = false },
  93.   Blizzard_GuildBankUI = { ["GuildBankFrame"] = false, ["GuildBankEmblemFrame"] = true },
  94.   Blizzard_TimeManager = { ["TimeManagerFrame"] = false },
  95.   Blizzard_AchievementUI = { ["AchievementFrame"] = false, ["AchievementFrameHeader"] = true, ["AchievementFrameCategoriesContainer"] = "AchievementFrame" },
  96.   Blizzard_TokenUI = { ["TokenFrame"] = true },
  97.   Blizzard_ItemSocketingUI = { ["ItemSocketingFrame"] = false },
  98.   Blizzard_GlyphUI = { ["GlyphFrame"] = "PlayerTalentFrame" },
  99.   Blizzard_BarbershopUI = { ["BarberShopFrame"] = false },
  100.   Blizzard_Calendar = { ["CalendarFrame"] = false, ["CalendarCreateEventFrame"] = true },
  101.   GrimUI = { ["GrimParty1Frame"] = false, ["GrimParty2Frame"] = false },
  102.  
  103.  
  104. }
  105.  
  106. local parentFrame = {}
  107. local hooked = {}
  108.  
  109. --  Fyrye's Edit for position saving start --
  110. local version = GetAddOnMetadata("GrimUI", "Version");
  111. if not GrimLayout or version ~= "3.3.82" then
  112.     GrimLayout = {
  113.         locked = {},
  114.         disabled = false,
  115.                 nosave = false,
  116.     };
  117. end
  118.  
  119. local doReset = false;
  120. local isEnabled = function() return(GrimLayout.disabled and "Disabled" or "Enabled"); end
  121. --  Fyrye's Edit for position saving end --
  122.  
  123. local function print(msg)
  124.   DEFAULT_CHAT_FRAME:AddMessage("GrimUI FrameMover" .. msg)
  125. end
  126.  
  127. function addon:PLAYER_LOGIN()
  128.  
  129.   self:HookFrames(frames)
  130.  
  131.   -- Bugfix for 3.1+ Battleground frame (wrong anchor)
  132.   --if PVPBattlegroundFrameFrameLabel and PVPBattlegroundFrame then
  133.     --PVPBattlegroundFrameFrameLabel:ClearAllPoints()
  134.     --PVPBattlegroundFrameFrameLabel:SetPoint("TOP", PVPBattlegroundFrame, "TOP", 0, -17)
  135.   --end
  136.   -- Bugfix for 3.2 Battleground frame -.-
  137.   --if PVPBattlegroundFrameNameHeader and PVPBattlegroundFrame then
  138.    -- PVPBattlegroundFrameNameHeader:ClearAllPoints()
  139.    -- PVPBattlegroundFrameNameHeader:SetPoint("TOPLEFT", PVPBattlegroundFrame, "TOPLEFT", 70, -55)
  140.     --PVPBattlegroundFrameNameHeader2:ClearAllPoints()
  141.     --PVPBattlegroundFrameNameHeader2:SetPoint("TOPLEFT", PVPBattlegroundFrame, "TOPLEFT", 70, -172)
  142.   --end
  143. end
  144.  
  145.  
  146. function addon:ADDON_LOADED(name)
  147.   local frameList = lodFrames[name]
  148.   if frameList then
  149.     self:HookFrames(frameList)
  150.   end
  151.  
  152.   end
  153.  
  154. --  Fyrye's Edit for position saving start --
  155. local function toggleLock(frame)
  156.     frame = parentFrame[frame] or frame;
  157.     if not GrimLayout.locked[frame:GetName()] then
  158.         GrimLayout.locked[frame:GetName()] = true;
  159.         print( frame:GetName() .. " locked");
  160.    
  161.    
  162.     else
  163.         GrimLayout.locked[frame:GetName()] = nil;
  164.         print( frame:GetName() .. " unlocked");
  165.     end
  166. end
  167.  
  168. local function ShowHandler(self)
  169.   if GrimLayout.disabled then return; end
  170.           if GrimLayout.nosave then return; end
  171.        if InCombatLockdown() then return; end
  172.                              
  173.           frame = parentFrame[self] or self;
  174.        
  175.        
  176.         if frame then
  177.          
  178.          
  179.           if GrimLayout[frame:GetName()] then
  180.               --if frame == GUI_Party1Frame then return; end
  181.             --if frame == GUI_Party2Frame then return; end
  182.             --if frame == GUI_Party3Frame then return; end
  183.             --if frame == GUI_Party4Frame then return; end
  184.               local points = GrimLayout[frame:GetName()];
  185.               if not points then return; end
  186.               if points == "nil" then return; end
  187.               frame:ClearAllPoints();
  188.               frame:SetPoint(points[1], points[2], points[3], points[4], points[5]);
  189.       end
  190.       end
  191. end
  192.  
  193.  
  194. local function HideHandler(self, frame)
  195.    
  196.    
  197.     if GrimLayout.disabled == true then return; end
  198.     if GrimLayout.doReset then GrimLayout.doReset = false; return; end
  199.         if GrimLayout.nosave == true then return; end
  200.    
  201.    
  202.      frame = parentFrame[self] or self;
  203.    
  204.         if frame then
  205.         --if frame == GUI_Party1Frame then return; end
  206.             --if frame == GUI_Party2Frame then return; end
  207.             --if frame == GUI_Party3Frame then return; end
  208.             --if frame == GUI_Party4Frame then return; end
  209.         local point, _, relativePoint, xOfs, yOfs = frame:GetPoint();
  210.         GrimLayout[frame:GetName()] = {tostring(point), "UIParent", tostring(relativePoint), xOfs, yOfs};
  211.     end
  212.  end  
  213.    
  214.  
  215.  
  216. function GrimUI:PlayerFrameSavePosition(self)
  217.  
  218.  
  219.       frame = parentFrame[self] or self;
  220.         if frame then
  221.         local point, _, relativePoint, xOfs, yOfs = GrimPlayerFrame:GetPoint();
  222.         GrimLayout[GrimPlayerFrame:GetName()] = {tostring(point), "UIParent", tostring(relativePoint), xOfs, yOfs};
  223.     end
  224. end
  225.  
  226.  
  227. --  Fyrye's Edit for position saving end --
  228.  
  229. local function MouseDownHandler(frame, button)
  230.  
  231.   --if InCombatLockdown() then return; end
  232.   frame = parentFrame[frame] or frame
  233.   if frame and button == "LeftButton" then
  234.     --  Fyrye's Edit for position saving start --
  235.     if IsAltKeyDown() then
  236.     toggleLock(frame);
  237.     return;
  238.     elseif IsControlKeyDown() then
  239.     GrimLayout[frame:GetName()] = nil;
  240.     doReset = true;
  241.     print( frame:GetName() .. " will be reset when next opened");
  242.    
  243.     return;
  244.     elseif IsShiftKeyDown() then
  245.     GrimLayout.disabled = not GrimLayout.disabled;
  246.     print(" MoveFrames is now "..isEnabled());
  247.     if not GrimLayout.disabled then
  248.         ShowHandler(frame);
  249.     end
  250.     return;
  251.     end
  252.     if GrimLayout.locked[frame:GetName()] then
  253.         return;
  254.     end
  255.     if GrimLayout.disabled then
  256.         return;
  257.     end
  258.     frame:StartMoving()
  259.     frame:SetUserPlaced(false)
  260.   --  Fyrye's Edit for position saving end --
  261.   end
  262. end
  263.  
  264. local function MouseUpHandler(frame, button)
  265.   --if InCombatLockdown() then return; end
  266.   frame = parentFrame[frame] or frame
  267.   if frame and button == "LeftButton" then
  268.     frame:StopMovingOrSizing()
  269.     --if GrimLayout.disabled == "true" then return; end
  270.     --if doReset then doReset = false; return; end
  271.         --if GrimLayout.nosave then return; end
  272.       if GrimLayout.nosave == true then return
  273.       else
  274.    
  275.  
  276.         local point, _, relativePoint, xOfs, yOfs = frame:GetPoint();
  277.         GrimLayout[frame:GetName()] = {tostring(point), "UIParent", tostring(relativePoint), xOfs, yOfs};
  278.     end
  279.     end
  280. end
  281.  
  282.  
  283. function addon:HookFrames(list)
  284.   for name, child in pairs(list) do
  285.     self:HookFrame(name, child)
  286.   end
  287. end
  288.  
  289. function addon:HookFrame(name, moveParent)
  290.   local frame = _G[name]
  291.   local parent
  292.   if frame and not hooked[name] then
  293.     if moveParent then
  294.       if type(moveParent) == "string" then
  295.         parent = _G[moveParent]
  296.       else
  297.         parent = frame:GetParent()
  298.       end
  299.       if not parent then
  300.         print(" Parent frame not found: " .. name)
  301.         return
  302.       end
  303.       parentFrame[frame] = parent
  304.     end
  305.     if parent then
  306.       parent:SetMovable(true)
  307.       parent:SetClampedToScreen(false)
  308.     end
  309.     frame:EnableMouse(true)
  310.     frame:SetMovable(true)
  311.     frame:SetClampedToScreen(false)
  312.     self:HookScript(frame, "OnMouseDown", MouseDownHandler)
  313.     self:HookScript(frame, "OnMouseUp", MouseUpHandler)
  314.     --  Fyrye's Edit for position saving start --
  315.     self:HookScript(frame, "OnShow", ShowHandler);
  316.     self:HookScript(frame, "OnHide", HideHandler);
  317.     --  Fyrye's Edit for position saving end --
  318.     hooked[name] = true
  319.     end
  320. end
  321.  
  322. function addon:HookScript(frame, script, handler)
  323.   if not frame.GetScript then return end
  324.   local oldHandler = frame:GetScript(script)
  325.   if oldHandler then
  326.     frame:SetScript(script, function(...)
  327.       handler(...)
  328.       oldHandler(...)
  329.     end)
  330.   else
  331.     frame:SetScript(script, handler)
  332.   end
  333. end
  334.  
  335. addon:SetScript("OnEvent", function(f, e, ...) f[e](f, ...) end)
  336. addon:RegisterEvent("PLAYER_LOGIN")
  337. addon:RegisterEvent("ADDON_LOADED")
  338.  
  339. -- Hook bag frames
  340. hooksecurefunc("ContainerFrame_GenerateFrame", function(frame, size, id)
  341.   if id <= NUM_BAG_FRAMES or id == KEYRING_CONTAINER then
  342.     addon:HookFrame(frame:GetName())
  343.   end
  344. end)
  345.  
  346.  --  Fyrye's Edit for slash commands start --
  347. SLASH_GRIMUI1, SLASH_GRIMUI2 = '/grimui', '/gui';
  348. local function slashhandler(msg, editbox)
  349.  if msg == 'help' then
  350.   DEFAULT_CHAT_FRAME:AddMessage(" ");
  351.   print(' To reset a single frame press Ctrl and Left click that frame.');
  352.   print(' To Disable/Enable Moveable Frames press Shift and Left click any frame.');
  353.   print(' To Lock a frame in place press Alt and Left click that frame.');
  354.   print(' To reset all frames type /grimui framereset.')
  355.   elseif msg == 'framereset' then
  356.   GrimLayout = {
  357.         locked = {},
  358.         disabled = false,
  359.     };
  360.   GrimPlayerFrame:ClearAllPoints()
  361.   GrimPlayerFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", -10, 245)
  362.  
  363.   GrimUIPartyFrame1:ClearAllPoints()
  364.   GrimUIPartyFrame1:SetPoint("LEFT", GrimUIcoreArtB1, "TOPRIGHT", -81, -22)
  365.  
  366.   GrimUIPartyFrame2:ClearAllPoints()
  367.   GrimUIPartyFrame2:SetPoint("BOTTOMLEFT", GrimUIPartyFrame1, "BOTTOMRIGHT", -1, 0)
  368.  
  369.   GrimUIPartyFrame3:ClearAllPoints()
  370.   GrimUIPartyFrame3:SetPoint("RIGHT", GrimUIcoreArtB4, "TOPLEFT", -139, -22)
  371.  
  372.   GrimUIPartyFrame4:ClearAllPoints()
  373.   GrimUIPartyFrame4:SetPoint("BOTTOMLEFT", GrimUIPartyFrame3, "BOTTOMRIGHT", -1, 0)
  374.  
  375.   DEFAULT_CHAT_FRAME:AddMessage(" ");
  376.   print(' All frames have been reset to defaults');
  377.  elseif msg == 'nosave' then
  378.     GrimLayout.nosave = not GrimLayout.nosave;
  379.     print(string.format("%s",GrimLayout.nosave and "Saving Disabled" or "Saving Enabled"));
  380.  else
  381.   DEFAULT_CHAT_FRAME:AddMessage(" ");
  382.   print(" To display help type: /grimui help");
  383.   print(" To reset all moveable frame positions type: /grimui framereset");
  384.   print(" To toggle frame position saving type: /grimui nosave");
  385.   print(" FrameMover is currently "..isEnabled());
  386.  end
  387. end
  388. SlashCmdList["GRIMUI"] = slashhandler;

this is based on the original MoveAnything code not any of the new ones... and i take that back the frame movement only appears to cause errors when you try to select layouts otherwise when i get the frame to show it is moveable... lol.

i added a registerevent to the monitor part for player entering world its now checking those things properly again at lest. although you put the pvp icon in the monitor script? so the pvp icon is always up now lol...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 08:32 AM.
  Reply With Quote
06-16-10, 08:39 AM   #30
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
i take it back... the frame positions are not saving it loads to default position everytime you reload....

back to what Vrul said about the handlers, events and mainframe. So im guessing this is why the events are not working?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 09:04 AM.
  Reply With Quote
06-16-10, 09:07 AM   #31
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
-- If these values are invalid then they should be purged, not allowed to persist:
-- all: points[1] == "nil"
-- party1: points[1] == "LEFT" and points[2] == "UIParent" and points[3] == "TOPRIGHT" then
-- party2: points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then
-- party3: points[1] == "RIGHT" and points[2] == "UIParent" and points[3] == "TOPLEFT" then
-- party4: points[1] == "BOTTOMLEFT" and points[2] == "UIParent" and points[3] == "BOTTOMRIGHT" then


they are only invalid at certain moments like if you do a /GUI framereset then do /reload it would fire a onhide whitch would save invalid positions because it would read the original setpoints but it would only do this until you moved the frame with the frame mover the moment you mouseup from moving it saves new points and valid positions then recalls those each time... i think this is partly why its not saving position now.

take that back it was if you do a /framereset or do a /reload with a framereset and then atempt to hide show the frames with the hideshow option in the bliz panel. of course thats borked but... somethings still off with the position saving.

another edit-- okay so on the events... i think i understand what your saying i created x# of frames each to handle events of a certain type and those frames are not hooked to the partyframes as they should be, the events should actually be registered to the frame upon which the events script will affect? so best way maybe is to register them all to GrimUIPartyFramex then mash the event scripts into one and then do if event statements for every event?

wait wait... thinking about it originally i had made global event frames and had their setscript run the event functions and they were not even parented to the grimuipartyframes at all and they worked ok. not efficient im sure but... so umm im still confused? it looks like it should work in theory.

movement edit -- okay it looks like it is still saving the position correctly and when someone joins the party it loads to the saved position spot but when ever i /reload it resets the position. any idea why? it has to do with the change to layoutinitiate... im still studying that chunk trying to figure out what you did with it. awesome its not 4 hudge functions now but lol its not working as intended anymore, granted im sure messing with that chunk of code was difficult without knowing what the moveframes.lua looks like.

also just noticed something with the dropdowns... im gonna have to look closely at the code you made for it but the way those were designed orignally there are 4 dropdown points, the targetframe whitch drops down the targets dropdown, then the infotextframe is one, the mana and health bars are two dif ones to. Why? its done this way so that when i do the clique inclusions each one of those things can then be turned into a different clique button, that way you can have your infotext frame do party targeting and dropdown menu as normal then set the health and mana bars to be two different clickcasts. hooking it to the main player frame makes the menu all over the place because that frame is oversized in comparison to everything in it to provide grab space above the name for the frame movement functions. i know... its a big tangled mess lol.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 10:20 AM.
  Reply With Quote
06-16-10, 10:36 AM   #32
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
All 4 files involved with this maybe itll alliviate some confusion if it can all be seen... noticed Vrul that you made a new function for the registerevents? didnt dbl check if it matched the one in the core ornot but... this way it all can be seen.

GrimUICore.lua -- http://www.pastey.net/137744 -- this is the very first file in my UI to load. Loads variable defaults, sets up a few tables and loads addon wide util functions.

PartyFrames.lua -- http://www.pastey.net/137745 -- obviously the party frames. loads after GrimUICore. includes changes i made this morn to what Vrul posted.

MoveFrames.lua -- http://www.pastey.net/137747 -- moves a lot of frames including the GrimPlayerFrame and Partyframes. Loads after PartyFrames.

GrimUIOptions.lua -- http://www.pastey.net/137748 -- Last file in the whole addon to load controls all of the few options currently available accross all files, primarily involves playerframe and party frame for both GrimUI and Bliz frames. by options i mean options actually in the OptionsPanel.


oh btw... the current GrimUI release the partyframes function perfectly except the option to switch styles is not available there... you would have to change the variable in the wtf by hand to make it switch lol. But the frames function as intended minus the raid hide/show part but yea the frame movement functions right. and the file is still a monster lol

edit-- so after a lot of testing and reading i have it narrowed down to 3 things wrong i think. the frame movement is not loading its saved position as it should because of the layoutinitiate() function. The events are not registering no completly sure why, and the dropdown menus need to have various parents rather then parented to the grimpartyframe which i may have under control, target drop down is showing the party member drop down rather then target drop to to... 3 problems position loading, events registration and dropdowns. pretty good considering i dont know what im doing and vrul was doing it half blind

edit-- oh and yes im well aware that style2 to is borked i have not even begun to fix that part
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 06-16-10 at 11:46 AM.
  Reply With Quote
06-16-10, 11:43 AM   #33
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Grimsin View Post
ive never seen an event set as a setscript, not sure what should be there? or if that is right and the error is in the script itself? monitor:SetScript('PLAYER_ENTERING_WORLD') monitor has a setscript is that just out of place?
No that was a mistake, it should have been monitor:RegisterEvent('PLAYER_ENTERING_WORLD')
  Reply With Quote
06-16-10, 11:50 AM   #34
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
i know this is just throwing another monkey wrench into the issue but that force hide show function i had... idealy an unregister module function or turn of module option that unloads the whole partyframe module would be best. i dont know if thats possible... and would most likely involve a reload to actually unload it entirely. im sure of that... to get rid of the frames already created before the module is unregistered...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
06-16-10, 11:51 AM   #35
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Vrul View Post
No that was a mistake, it should have been monitor:RegisterEvent('PLAYER_ENTERING_WORLD')
yea i figured that out
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
06-16-10, 11:52 AM   #36
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Grimsin View Post
okay it looks like it is still saving the position correctly and when someone joins the party it loads to the saved position spot but when ever i /reload it resets the position. any idea why? it has to do with the change to layoutinitiate... im still studying that chunk trying to figure out what you did with it. awesome its not 4 hudge functions now but lol its not working as intended anymore, granted im sure messing with that chunk of code was difficult without knowing what the moveframes.lua looks like.
I'll look over the other code you posted related to it and see how it all ties together and adjust it from there. Will take awhile because I have to do a bunch of stuff today but I'll get to it.
  Reply With Quote
06-16-10, 11:54 AM   #37
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Grimsin View Post
i know this is just throwing another monkey wrench into the issue but that force hide show function i had... idealy an unregister module function or turn of module option that unloads the whole partyframe module would be best. i dont know if thats possible... and would most likely involve a reload to actually unload it entirely. im sure of that... to get rid of the frames already created before the module is unregistered...
Once a frame is made you are stuck with it until a reload. It can be changed to work how you said though, just give me some time to look it all over again.
  Reply With Quote
06-16-10, 12:07 PM   #38
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Vrul View Post
I'll look over the other code you posted related to it and see how it all ties together and adjust it from there. Will take awhile because I have to do a bunch of stuff today but I'll get to it.
Awsome, thank you so much. Im going to keep studying the changes you made last night. Also going to fix some of my other modules with what ive learned from you and Cargor the last few days about shortening my code now i got a handle on the function(i) and for id = 1, 4 do i can cut back on a lot of repetitive coding.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » breaking it down.

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