⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 earthquestlog.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
--[[
--
--	Earth Quest Log
--
--		An simpler way of showing a custom quest
--
--		by Alexander Brazie
--
--]]

EARTHQUESTLOG_MAX_OBJECTIVES = 30;
EARTHQUESTLOG_MAX_ITEMS = 10;

-- Debug Toggles
EARTHQUESTLOG_DEBUG = true;
EQ_DEBUG = "EARTHQUESTLOG_DEBUG";

--
--[[ Update the new Quest Log Frame ]]--
--
function EarthQuestLog_LoadQuest(questLogName, questInfo)
	local frame = getglobal(questLogName);

	if ( frame ) then 
		frame.questInfo = questInfo;
	end
end

--
--	Retrieves the current quest in the log
--
function EarthQuestLog_GetQuest(questLogName)
	local frame = getglobal(questLogName);

	if ( frame ) then 
		return frame.questInfo;
	end
end

--
--[[ Update the new Quest Log Frame ]]--
--
function EarthQuestLog_Clear(questLogName)
	local frame = getglobal(questLogName);

	if ( frame ) then 
		frame.questInfo = nil;
	end
	EarthQuestLog_Update(questLogName);
end



--
-- Updates the quest log 
-- 

--(This is just a giant cut and paste from the 
-- Blizz version. Ugly, but effective! )

function EarthQuestLog_Update(questLogName)
	local questInfo = getglobal(questLogName).questInfo;

	if ( not questInfo ) then 
		questInfo = {};
	end

	local questTitle = questInfo.title;
	if ( not questTitle ) then
		questTitle = "";
	end
	if ( questInfo.failed ) then
		questTitle = questTitle.." - ("..TEXT(FAILED)..")";
	end
	getglobal(questLogName.."QuestTitle"):SetText(questTitle);

	local questDescription, questObjectives = questInfo.description, questInfo.objective;
	getglobal(questLogName.."ObjectivesText"):SetText(questObjectives);
	
	local questTimer = questInfo.timer;
	if ( questTimer ) then
		getglobal(questLogName).hasTimer = 1;
		getglobal(questLogName).timePassed = 0;
		getglobal(questLogName.."TimerText"):Show();
		getglobal(questLogName.."TimerText"):SetText(TEXT(TIME_REMAINING).." "..SecondsToTime(questTimer));
		getglobal(questLogName.."Objective1"):SetPoint("TOPLEFT", questLogName.."TimerText", "BOTTOMLEFT", 0, -10);
	else
		getglobal(questLogName).hasTimer = nil;
		getglobal(questLogName.."TimerText"):Hide();
		getglobal(questLogName.."Objective1"):SetPoint("TOPLEFT", questLogName.."ObjectivesText", "BOTTOMLEFT", 0, -10);
	end
	
	local numObjectives = 0;
	if ( questInfo.objectives ) then numObjectives = table.getn(questInfo.objectives) end;
	for i=1, numObjectives, 1 do
		local string = getglobal(questLogName.."Objective"..i);
		local text;
		local type;
		local finished;
		text, type, finished = questInfo.objectives[i].text, questInfo.objectives[i].questType, questInfo.objectives[i].finished; 
		if ( not text or strlen(text) == 0 ) then
			text = type;
		end
		if ( finished ) then
			string:SetTextColor(0.2, 0.2, 0.2);
			text = text.." ("..TEXT(COMPLETE)..")";
		else
			string:SetTextColor(0, 0, 0);
		end
		string:SetText(text);
		string:Show();
		QuestFrame_SetAsLastShown(string);
	end

	for i=numObjectives + 1, MAX_OBJECTIVES, 1 do
		getglobal(questLogName.."Objective"..i):Hide();
	end
	
	-- If there's money required then anchor and display it
	if ( questInfo.requiredMoney ) then
		if ( numObjectives > 0 ) then
			getglobal(questLogName.."RequiredMoneyText"):SetPoint("TOPLEFT", questLogName.."Objective"..numObjectives, "BOTTOMLEFT", 0, -4);
		else
			getglobal(questLogName.."RequiredMoneyText"):SetPoint("TOPLEFT", questLogName.."ObjectivesText", "BOTTOMLEFT", 0, -10);
		end
		
		MoneyFrame_Update(questLogName.."RequiredMoneyFrame", questInfo.requiredMoney);
		
		if ( questInfo.requiredMoney > GetMoney() ) then
			-- Not enough money
			getglobal(questLogName.."RequiredMoneyText"):SetTextColor(0, 0, 0);
			SetMoneyFrameColor(questLogName.."RequiredMoneyFrame", 1.0, 0.1, 0.1);
		else
			getglobal(questLogName.."RequiredMoneyText"):SetTextColor(0.2, 0.2, 0.2);
			SetMoneyFrameColor(questLogName.."RequiredMoneyFrame", 1.0, 1.0, 1.0);
		end
		getglobal(questLogName.."RequiredMoneyText"):Show();
		getglobal(questLogName.."RequiredMoneyFrame"):Show();
	else
		getglobal(questLogName.."RequiredMoneyText"):Hide();
		getglobal(questLogName.."RequiredMoneyFrame"):Hide();
	end

	if ( questInfo.requiredMoney ) then
		getglobal(questLogName.."DescriptionTitle"):SetPoint("TOPLEFT", questLogName.."RequiredMoneyText", "BOTTOMLEFT", 0, -10);
	elseif ( numObjectives > 0 ) then
		getglobal(questLogName.."DescriptionTitle"):SetPoint("TOPLEFT", questLogName.."Objective"..numObjectives, "BOTTOMLEFT", 0, -10);
	else
		if ( questTimer ) then
			getglobal(questLogName.."DescriptionTitle"):SetPoint("TOPLEFT", questLogName.."TimerText", "BOTTOMLEFT", 0, -10);
		else
			getglobal(questLogName.."DescriptionTitle"):SetPoint("TOPLEFT", questLogName.."ObjectivesText", "BOTTOMLEFT", 0, -10);
		end
	end
	if ( questDescription ) then
		getglobal(questLogName.."QuestDescription"):SetText(questDescription);
		QuestFrame_SetAsLastShown(getglobal(questLogName.."QuestDescription"));
	else 
		getglobal(questLogName.."QuestDescription"):SetText("");
	end
	local numRewards = 0; 
	if ( questInfo.rewards ) then numRewards = table.getn(questInfo.rewards); end
	local numChoices = 0;
	if ( questInfo.choices ) then numChoices = table.getn(questInfo.choices); end
	local money;

	if ( questInfo.rewardMoney ) then
		money = questInfo.rewardMoney;
	else 
		money = 0;
	end

	if ( (numRewards + numChoices + money) > 0 ) then
		getglobal(questLogName.."RewardTitleText"):Show();
		QuestFrame_SetAsLastShown(getglobal(questLogName.."RewardTitleText"));
	else
		getglobal(questLogName.."RewardTitleText"):Hide();
	end

	EarthQuestLog_QuestItems_Update(questLogName, questInfo);
	getglobal(questLogName.."DetailScrollFrameScrollBar"):SetValue(0);
	getglobal(questLogName.."DetailScrollFrame"):UpdateScrollChildRect();
end

function EarthQuestLog_QuestItems_Update(questLogName, questInfo)
	local numQuestRewards;
	local numQuestChoices;
	local numQuestSpellRewards = 0;
	local money;
	local spacerFrame;

	numQuestRewards = 0; 
	if ( questInfo.rewards ) then numQuestRewards = table.getn(questInfo.rewards); end
	numQuestChoices = 0;
	if ( questInfo.choices ) then numQuestChoices = table.getn(questInfo.choices); end

	if ( questInfo.spellReward ) then
		numQuestSpellRewards = 1;
	end
	money = 0;
	if ( questInfo.rewardMoney ) then money = questInfo.rewardMoney; end

	spacerFrame = QuestLogSpacerFrame;

	local totalRewards = numQuestRewards + numQuestChoices + numQuestSpellRewards;
	local questItemName = questLogName.."Item";
	local material = QuestFrame_GetMaterial();
	local  questItemReceiveText = getglobal(questLogName.."ItemReceiveText")
	if ( totalRewards == 0 and money == 0 ) then
		getglobal(questLogName.."RewardTitleText"):Hide();
	else
		getglobal(questLogName.."RewardTitleText"):Show();
		QuestFrame_SetTitleTextColor(getglobal(questLogName.."RewardTitleText"), material);
		QuestFrame_SetAsLastShown(getglobal(questLogName.."RewardTitleText"), spacerFrame);
	end
	if ( money == 0 ) then
		getglobal(questLogName.."MoneyFrame"):Hide();
	else
		getglobal(questLogName.."MoneyFrame"):Show();
		QuestFrame_SetAsLastShown(getglobal(questLogName.."MoneyFrame"), spacerFrame);
		MoneyFrame_Update(questLogName.."MoneyFrame", money);
	end
	
	for i=totalRewards + 1, MAX_NUM_ITEMS, 1 do
		getglobal(questItemName..i):Hide();
	end
	local questItem, name, texture, quality, isUsable, numItems = 1;
	if ( numQuestChoices > 0 ) then
		getglobal(questLogName.."ItemChooseText"):Show();
		QuestFrame_SetTextColor(getglobal(questLogName.."ItemChooseText"), material);
		QuestFrame_SetAsLastShown(getglobal(questLogName.."ItemChooseText"), spacerFrame);
		for i=1, numQuestChoices, 1 do	
			questItem = getglobal(questItemName..i);
			questItem.info = questInfo.choices[i].info;
			numItems = 1;

			name, texture, numItems, quality, isUsable = questInfo.choices[i].name, questInfo.choices[i].texture,  questInfo.choices[i].numItems,  questInfo.choices[i].quality,  questInfo.choices[i].isUsable;

			questItem:SetID(i)
			questItem:Show();

			-- For the tooltip
			questItem.rewardType = "item";

			QuestFrame_SetAsLastShown(questItem, spacerFrame);
			getglobal(questItemName..i.."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.9, 0, 0);
				SetItemButtonNameFrameVertexColor(questItem, 0.9, 0, 0);
			end
			if ( i > 1 ) then
				if ( mod(i,2) == 1 ) then
					questItem:SetPoint("TOPLEFT", questItemName..(i - 2), "BOTTOMLEFT", 0, -2);
				else
					questItem:SetPoint("TOPLEFT", questItemName..(i - 1), "TOPRIGHT", 1, 0);
				end
			else
				questItem:SetPoint("TOPLEFT", questLogName.."ItemChooseText", "BOTTOMLEFT", -3, -5);
			end
			
		end
	else
		getglobal(questLogName.."ItemChooseText"):Hide();
	end
	local rewardsCount = 0;
	if ( numQuestRewards > 0 or money > 0 or numQuestSpellRewards > 0) then
		QuestFrame_SetTextColor(questItemReceiveText, material);
		-- Anchor the reward text differently if there are choosable rewards
		if ( numQuestChoices > 0  ) then
			questItemReceiveText:SetText(TEXT(REWARD_ITEMS));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -