Thread Tools Display Modes
02-27-11, 10:57 PM   #21
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Originally Posted by SDPhantom View Post
Nothing indicates that it's secure code.
I might misunderstand secure. I had initially tried putting hard values in the function you posted earlier (works great):

lua Code:
  1. function QuestInfo_Display(template, parentFrame, acceptButton, material)
  2.     local lastFrame, shownFrame, bottomShownFrame;  
  3.     local elementsTable = template.elements;
  4.     local bottomShownFrame;
  5.    
  6.     QuestInfoFrame.questLog = template.questLog;
  7.     QuestInfoFrame.chooseItems = template.chooseItems;
  8.     QuestInfoFrame.tooltip = template.tooltip;  
  9.     QuestInfoFrame.acceptButton = acceptButton;
  10.    
  11.     if ( QuestInfoFrame.material ~= material ) then
  12.         QuestInfoFrame.material = material;
  13.         local textColor, titleTextColor = GetMaterialTextColors(material);  
  14.         -- headers
  15.         QuestInfoTitleHeader:SetTextColor(1, 0.85, 0)
  16.         QuestInfoDescriptionHeader:SetTextColor(1, 0.85, 0)
  17.         QuestInfoObjectivesHeader:SetTextColor(1, 0.85, 0)
  18.         QuestInfoRewardsHeader:SetTextColor(1, 0.85, 0)
  19.         -- other text
  20.         QuestInfoDescriptionText:SetTextColor(1, 1, 1);
  21.         QuestInfoObjectivesText:SetTextColor(1, 1, 1);
  22.         QuestInfoGroupSize:SetTextColor(1, 1, 1);
  23.         QuestInfoRewardText:SetTextColor(1, 1, 1);
  24.         -- reward frame text
  25.         QuestInfoItemChooseText:SetTextColor(1, 1, 1);
  26.         QuestInfoItemReceiveText:SetTextColor(1, 1, 1);
  27.         QuestInfoSpellLearnText:SetTextColor(1, 1, 1);
  28.         QuestInfoXPFrameReceiveText:SetTextColor(1, 1, 1);
  29.    
  30.     for i = 1, #elementsTable, 3 do
  31.         shownFrame, bottomShownFrame = elementsTable[i]();
  32.         if ( shownFrame ) then
  33.             shownFrame:SetParent(parentFrame);
  34.             if ( lastFrame ) then
  35.                 shownFrame:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", elementsTable[i+1], elementsTable[i+2]);
  36.             else
  37.                 shownFrame:SetPoint("TOPLEFT", parentFrame, "TOPLEFT", elementsTable[i+1], elementsTable[i+2]);        
  38.             end
  39.             lastFrame = bottomShownFrame or shownFrame;
  40.         end
  41.     end
  42. end

Then tried the Game92's solution (also works):

lua Code:
  1. local QuestInfo_Display = function()
  2.     QuestInfoTitleHeader:SetTextColor(1, 0.85, 0)
  3.     QuestInfoDescriptionHeader:SetTextColor(1, 0.85, 0)
  4.     QuestInfoObjectivesHeader:SetTextColor(1, 0.85, 0)
  5.     QuestInfoRewardsHeader:SetTextColor(1, 0.85, 0)
  6.     QuestInfoDescriptionText:SetTextColor(1, 1, 1);
  7.     QuestInfoObjectivesText:SetTextColor(1, 1, 1);
  8.     QuestInfoGroupSize:SetTextColor(1, 1, 1);
  9.     QuestInfoRewardText:SetTextColor(1, 1, 1);
  10.     QuestInfoItemChooseText:SetTextColor(1, 1, 1);
  11.     QuestInfoItemReceiveText:SetTextColor(1, 1, 1);
  12.     QuestInfoSpellLearnText:SetTextColor(1, 1, 1);
  13.     QuestInfoXPFrameReceiveText:SetTextColor(1, 1, 1);
  14. end
  15. hooksecurefunc("QuestInfo_Display", QuestInfo_Display)

Then changed it to remove QuestInfo_Display which I understood to be protected:

lua Code:
  1. local doit = function()
  2.     QuestInfoTitleHeader:SetTextColor(1, 0.85, 0)
  3.     QuestInfoDescriptionHeader:SetTextColor(1, 0.85, 0)
  4.     QuestInfoObjectivesHeader:SetTextColor(1, 0.85, 0)
  5.     QuestInfoRewardsHeader:SetTextColor(1, 0.85, 0)
  6.     QuestInfoDescriptionText:SetTextColor(1, 1, 1);
  7.     QuestInfoObjectivesText:SetTextColor(1, 1, 1);
  8.     QuestInfoGroupSize:SetTextColor(1, 1, 1);
  9.     QuestInfoRewardText:SetTextColor(1, 1, 1);
  10.     QuestInfoItemChooseText:SetTextColor(1, 1, 1);
  11.     QuestInfoItemReceiveText:SetTextColor(1, 1, 1);
  12.     QuestInfoSpellLearnText:SetTextColor(1, 1, 1);
  13.     QuestInfoXPFrameReceiveText:SetTextColor(1, 1, 1);
  14. end
  15. doit()

This has no effect (I didn't expect it to), but i'm not exactly sure why. The default QuestInfo_Display function is runs. In the hooksecurefunc example do both the hooked and the secure run (which first)?

Last edited by Aprikot : 02-27-11 at 10:59 PM. Reason: quote added
  Reply With Quote
02-28-11, 12:37 AM   #22
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
QuestInfo_Display() isn't protected, it's just standard Lua code defined in the default UI. You still need to stop the original version of it from overriding your settings while allowing the other things it does to happen, hence the modified version I posted to overwrite it.

It's simply the same function with all the text color code taken out of it.



Originally Posted by Aprikot View Post
... This has no effect (I didn't expect it to), but i'm not exactly sure why. The default QuestInfo_Display function is runs. In the hooksecurefunc example do both the hooked and the secure run (which first)?
Using the code I put in my second post replaces the original function with the modified one. There's no need for hooksecurefunc() on it since it isn't a protected function.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 02-28-11 at 01:06 AM.
  Reply With Quote
02-28-11, 01:05 AM   #23
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
I see. Is it correct that this and the hooksecure methods are interchangeable?
  Reply With Quote
02-28-11, 07:37 PM   #24
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
The hooksecurefunc() method uses up more CPU time running the original function, then running your hook. The replacement method changes the function so it no longer modifies the text colors, actually making it run faster than it did before.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
03-01-11, 10:12 AM   #25
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Ah, that makes sense. So much to learn.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GameFontBlack


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