addon/Addon/Code/Quest.lua

144 lines
No EOL
5.5 KiB
Lua
Executable file

function CzechQuestsAddon:ShowQuestTranslation(event)
-- Hide frame, may contain old texts
CzechQuestsAddon.translationQuestFrame:Hide()
-- Classic Era has QuestLogFrame
if QuestLogFrame then
if QuestLogFrame:IsShown() then
local questIndex = GetQuestLogSelection()
if questIndex > 0 then
local questId = select(8, GetQuestLogTitle(questIndex))
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
CzechQuestsAddon:ShowTranslationQuestFrame(
questTitle,
questData.objective,
"Popis",
questData.description,
QuestLogFrame,
-14,
0
)
CzechQuestsAddon.translationQuestFrame:Show()
end
end
end
end
-- Retail has QuestMapDetailsScrollFrame
if QuestMapDetailsScrollFrame then
if QuestMapDetailsScrollFrame:IsVisible() then
local questId = C_QuestLog.GetSelectedQuest()
local hasModel = QuestModelScene:IsVisible()
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
local xOffset = hasModel and 210 or 50
CzechQuestsAddon:ShowTranslationQuestFrame(
questTitle,
questData.objective,
"Popis",
questData.description,
QuestMapFrame,
0,
xOffset
)
CzechQuestsAddon.translationQuestFrame:Show()
else
CzechQuestsAddon.translationQuestFrame:Hide()
end
end
end
-- If quest is right from NPC, this work for both wow version
if event ~= nil then
local questId = GetQuestID()
local hasModel = QuestModelScene and QuestModelScene:IsShown() or false
if questId then
local questData = CzechQuestsAddon:GetData("quest", questId)
if questData then
CzechQuestsAddon.translationQuestFrame:Show()
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
local questTitle = questData.title .. suffix
local xOffset = hasModel and 210 or 0
if event == "QUEST_PROGRESS" then
CzechQuestsAddon:ShowTranslationQuestFrame(
questTitle,
questData.progress,
"",
"",
QuestFrame,
-20,
xOffset
)
elseif event == "QUEST_COMPLETE" then
CzechQuestsAddon:ShowTranslationQuestFrame(
questTitle,
questData.completion,
"",
"",
QuestFrame,
-20,
xOffset
)
elseif event == "QUEST_DETAIL" then
CzechQuestsAddon:ShowTranslationQuestFrame(
questTitle,
questData.description,
"Cíl úkolu",
questData.objective,
QuestFrame,
-20,
xOffset
)
else
CzechQuestsAddon.translationQuestFrame:Hide()
end
else
CzechQuestsAddon.translationQuestFrame:Hide()
end
end
end
end
function CzechQuestsAddon:ShowQuestItemTranslation()
-- Hide frame, may contain old texts
CzechQuestsAddon.translationQuestFrame:Hide()
-- should work for both wow version
if ItemTextFrame:IsShown() then
local item = {}
-- get item name
local itemName = ItemTextGetItem();
local titlePage = CzechQuestsAddon:GetData("item", itemName)
-- check if item is translated
if titlePage ~= nil then
item.name = titlePage.titleMale;
local pageNum = ItemTextGetPage()
local contentPage = CzechQuestsAddon:GetData("item", itemName .. '__' .. pageNum)
-- check if item is translated
if contentPage ~= nil then
item.content = contentPage.text
if item.name ~= nil and item.content ~= nil then
CzechQuestsAddon:ShowTranslationQuestFrame(
item.name,
item.content,
"",
"",
ItemTextFrame,
-20,
0
)
end
end
end
CzechQuestsAddon.translationQuestFrame:Show()
end
end