📄 earthquestlog.lua
字号:
local index = numQuestChoices;
if ( mod(index, 2) == 0 ) then
index = index - 1;
end
questItemReceiveText:SetPoint("TOPLEFT", questItemName..index, "BOTTOMLEFT", 3, -5);
else
questItemReceiveText:SetText(TEXT(REWARD_ITEMS_ONLY));
questItemReceiveText:SetPoint("TOPLEFT", questLogName.."RewardTitleText", "BOTTOMLEFT", 3, -5);
end
questItemReceiveText:Show();
QuestFrame_SetAsLastShown(questItemReceiveText, spacerFrame);
-- Setup mandatory rewards
for i=1, numQuestRewards, 1 do
questItem = getglobal(questItemName..(i + numQuestChoices));
questItem.info = questInfo.rewards[i].info;
numItems = 1;
name, texture, numItems, quality, isUsable = questInfo.rewards[i].name, questInfo.rewards[i].texture, questInfo.rewards[i].numItems, questInfo.rewards[i].quality, questInfo.rewards[i].isUsable;
questItem:SetID(i)
questItem:Show();
-- For the tooltip
questItem.rewardType = "item";
QuestFrame_SetAsLastShown(questItem, spacerFrame);
getglobal(questItemName..(i + numQuestChoices).."Name"):SetText(name);
SetItemButtonCount(questItem, numItems);
SetItemButtonTexture(questItem, texture);
if ( isUsable ) then
SetItemButtonTextureVertexColor(questItem, 1.0, 1.0, 1.0);
SetItemButtonNameFrameVertexColor(questItem, 1.0, 1.0, 1.0);
else
SetItemButtonTextureVertexColor(questItem, 0.5, 0, 0);
SetItemButtonNameFrameVertexColor(questItem, 1.0, 0, 0);
end
if ( i > 1 ) then
if ( mod(i,2) == 1 ) then
questItem:SetPoint("TOPLEFT", questItemName..((i + numQuestChoices) - 2), "BOTTOMLEFT", 0, -2);
else
questItem:SetPoint("TOPLEFT", questItemName..((i + numQuestChoices) - 1), "TOPRIGHT", 1, 0);
end
else
questItem:SetPoint("TOPLEFT", questLogName.."ItemReceiveText", "BOTTOMLEFT", -3, -5);
end
rewardsCount = rewardsCount + 1;
end
-- Setup spell reward
if ( numQuestSpellRewards > 0 ) then
texture, name = questInfo.spellReward.texture, questInfo.spellReward.name;
questItem = getglobal(questItemName..(rewardsCount + numQuestChoices + 1));
questItem:Show();
-- For the tooltip
questItem.rewardType = "spell";
SetItemButtonCount(questItem, 0);
SetItemButtonTexture(questItem, texture);
getglobal(questItemName..(rewardsCount + numQuestChoices + 1).."Name"):SetText(name);
if ( rewardsCount > 0 ) then
if ( mod(rewardsCount,2) == 0 ) then
questItem:SetPoint("TOPLEFT", questItemName..((rewardsCount + numQuestChoices) - 1), "BOTTOMLEFT", 0, -2);
else
questItem:SetPoint("TOPLEFT", questItemName..((rewardsCount + numQuestChoices)), "TOPRIGHT", 1, 0);
end
else
questItem:SetPoint("TOPLEFT", questLogName.."ItemReceiveText", "BOTTOMLEFT", -3, -5);
end
end
else
questItemReceiveText:Hide();
end
end
--[[
--
-- Functions beyond this point are tool function and not meant for general use.
--
-- -Alex
--
--]]
--[[ Validates a Frame ]]--
function EarthQuestLog_CheckFrame(frame)
if ( frame ) then
return true;
else
Sea.io.error("Invalid frame passed to EarthQuestLog_CheckFrame");
return nil;
end
end
--[[ Validates a Quest Entry ]]--
function EarthQuestLog_CheckTable(questInfo)
if ( not questInfo ) then
Sea.io.error("QuestInfo sent to EarthQuestLog is nil! Name:", this:GetName() );
return false;
end
if ( type(questInfo) ~= "table" ) then
Sea.io.error("QuestInfo sent to EarthQuestLog is not a table! Name:", this:GetName() );
return false;
end
for k,v in questInfo do
--Something
if ( type(k) ~= "number" ) then
Sea.io.error("Invalid index in data: ",this:GetName() );
return false;
end
if ( EarthTree_CheckItem(v) == false ) then
Sea.io.error("Invalid item: ",k);
return false;
end
end
return true;
end
--[[ Validates a Table Item ]]--
function EarthTree_CheckItem(item)
if ( not item.title and not item.right ) then
Sea.io.error("No title or subtext provided: ",this:GetName() );
return false;
end
-- Now subfunctioned, this may never be used.
if ( not item.titleColor ) then
item.titleColor = EARTHTREE_COLOR_STRING;
end
if ( not item.rightColor ) then
item.rightColor = EARTHTREE_COLOR_STRING;
end
if ( item.children ) then
return EarthTree_CheckTable(item.children);
end
end
--
-- Sets the location of the Tooltip
--
function EarthQuestLog_SetTooltip(frame, tooltipText)
if ( frame.tooltip ) then
local tooltip = getglobal(frame.tooltip);
if ( tooltipText ) then
-- Set the location of the tooltip
if ( frame.tooltipPlacement == "cursor" ) then
tooltip:SetOwner(UIParent,"ANCHOR_CURSOR");
elseif ( frame.tooltipPlacement == "button" ) then
tooltip:SetOwner(this,frame.tooltipAnchor);
else
tooltip:SetOwner(frame,frame.tooltipAnchor);
end
Sea.wow.tooltip.protectTooltipMoney();
tooltip:SetText(tooltipText, 0.8, 0.8, 1.0);
tooltip:Show();
Sea.wow.tooltip.unprotectTooltipMoney();
end
end
end
--
-- Hides the location of the Tooltip
--
function EarthQuestLog_HideTooltip(frame)
if ( frame.tooltip ) then
getglobal(frame.tooltip):Hide();
getglobal(frame.tooltip):SetOwner(UIParent, "ANCHOR_RIGHT");
end
end
--[[ Frame Event Handlers ]]--
function EarthQuestLog_Frame_OnLoad()
this.onClick = EarthQuestLog_Frame_OnClick;
this.onShow = EarthQuestLog_Frame_OnShow;
this.onEvent = EarthQuestLog_Frame_OnEvent;
-- Use any tooltip you'd like. I use my own
this.tooltip = "EarthTooltip";
--
-- Can be "button", "frame", "cursor"
--
this.tooltipPlacement = "cursor";
this.tooltipAnchor = "ANCHOR_RIGHT"; -- Can be any valid tooltip anchor
this.activeTable = {};
end
function EarthQuestLog_Frame_OnShow()
end
function EarthQuestLog_Frame_OnClick()
end
function EarthQuestLog_Frame_OnEvent()
end
--[[ Item Texture Handlers ]]--
function EarthQuestLog_Item_OnLoad()
this.onEnter = EarthQuestLog_Item_OnEnter;
this.onLeave = EarthQuestLog_Item_OnLeave;
this.onClick = EarthQuestLog_Item_OnClick;
this:Hide();
end
function EarthQuestLog_Item_OnEnter()
if ( this:GetAlpha() > 0 ) then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
if ( this.rewardType == "item" ) then
Sea.wow.tooltip.protectTooltipMoney();
GameTooltip:SetHyperlink(this.info.link);
Sea.wow.tooltip.unprotectTooltipMoney();
elseif ( this.rewardType == "spell" ) then
Sea.wow.tooltip.protectTooltipMoney();
GameTooltip:SetText(this.info);
Sea.wow.tooltip.unprotectTooltipMoney();
end
end
end
function EarthQuestLog_Item_OnLeave()
GameTooltip:Hide();
end
function EarthQuestLog_Item_OnClick()
if ( IsShiftKeyDown() ) then
if ( ChatFrameEditBox:IsVisible() ) then
ChatFrameEditBox:Insert("|c"..this.info.color.."|H"..this.info.link.."|h"..this.info.linkname.."|h|r");
end
end
end
function EarthQuestLog_RewardItem_OnLoad()
this.onEnter = EarthQuestLog_RewardItem_OnEnter;
this.onLeave = EarthQuestLog_RewardItem_OnLeave;
this.onClick = EarthQuestLog_RewardItem_OnClick;
end
function EarthQuestLog_RewardItem_OnEnter()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
if ( this.rewardType == "item" ) then
Sea.wow.tooltip.protectTooltipMoney();
GameTooltip:SetHyperlink(this.info.link);
Sea.wow.tooltip.unprotectTooltipMoney();
elseif ( this.rewardType == "spell" ) then
Sea.wow.tooltip.protectTooltipMoney();
GameTooltip:SetText(this.info);
Sea.wow.tooltip.unprotectTooltipMoney();
end
end
function EarthQuestLog_RewardItem_OnLeave()
GameTooltip:Hide();
end
function EarthQuestLog_RewardItem_OnClick()
if ( IsShiftKeyDown() ) then
if ( ChatFrameEditBox:IsVisible() ) then
ChatFrameEditBox:Insert("|c"..this.info.color.."|H"..this.info.link.."|h"..this.info.linkname.."|h|r");
end
return;
end
if ( this.type == "choice" ) then
QuestRewardItemHighlight:SetPoint("TOPLEFT", this:GetName(), "TOPLEFT", -8, 7);
QuestRewardItemHighlight:Show();
QuestFrameRewardPanel.itemChoice = this:GetID();
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -