2024-08-19 13:08:40 +02:00
|
|
|
function CzechQuestsAddon:ShowQuestTranslation(event)
|
|
|
|
-- Hide frame, may contain old texts
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
2024-08-19 13:08:40 +02:00
|
|
|
|
|
|
|
-- 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
|
2024-08-25 11:50:46 +02:00
|
|
|
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
|
2024-08-19 13:08:40 +02:00
|
|
|
local questTitle = questData.title .. suffix
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-19 13:08:40 +02:00
|
|
|
questTitle,
|
2024-08-26 09:25:41 +02:00
|
|
|
questData.objective,
|
|
|
|
"Popis",
|
|
|
|
questData.description,
|
|
|
|
QuestLogFrame,
|
|
|
|
-14,
|
|
|
|
0
|
2024-08-19 13:08:40 +02:00
|
|
|
)
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Show()
|
2024-08-19 13:08:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Retail has QuestMapDetailsScrollFrame
|
|
|
|
if QuestMapDetailsScrollFrame then
|
|
|
|
if QuestMapDetailsScrollFrame:IsShown() then
|
2024-08-20 13:09:39 +02:00
|
|
|
-- get quest ID
|
2024-08-19 13:08:40 +02:00
|
|
|
local questId = C_QuestLog.GetSelectedQuest()
|
2024-08-20 13:09:39 +02:00
|
|
|
-- detect if quest frame does not include npc preview
|
2024-08-21 12:33:41 +02:00
|
|
|
local hasModel = QuestModelScene:IsShown()
|
2024-08-20 13:09:39 +02:00
|
|
|
-- show translation frame
|
2024-08-19 13:08:40 +02:00
|
|
|
local questData = CzechQuestsAddon:GetData("quest", questId)
|
|
|
|
if questData then
|
2024-08-25 11:50:46 +02:00
|
|
|
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
|
2024-08-19 13:08:40 +02:00
|
|
|
local questTitle = questData.title .. suffix
|
2024-08-21 12:33:41 +02:00
|
|
|
local xOffset = hasModel and 210 or 0
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-26 09:25:41 +02:00
|
|
|
questTitle,
|
|
|
|
questData.objective,
|
|
|
|
"Popis",
|
|
|
|
questData.description,
|
|
|
|
QuestMapFrame,
|
|
|
|
0,
|
|
|
|
xOffset
|
2024-07-07 12:29:29 +02:00
|
|
|
)
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Show()
|
2024-07-07 12:29:29 +02:00
|
|
|
else
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
2024-07-07 12:29:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-19 13:08:40 +02:00
|
|
|
-- If quest is right from NPC, this work for both wow version
|
2024-08-26 22:25:54 +02:00
|
|
|
if event ~= nil then
|
2024-08-20 13:09:39 +02:00
|
|
|
-- get quest ID
|
2024-08-19 13:08:40 +02:00
|
|
|
local questId = GetQuestID()
|
2024-08-20 13:09:39 +02:00
|
|
|
-- detect if quest frame does not include npc preview
|
2024-08-21 12:33:41 +02:00
|
|
|
local hasModel = QuestModelScene and QuestModelScene:IsShown() or false
|
2024-08-20 13:09:39 +02:00
|
|
|
-- show translation frame
|
2024-07-07 12:29:29 +02:00
|
|
|
if questId then
|
2024-08-19 13:08:40 +02:00
|
|
|
local questData = CzechQuestsAddon:GetData("quest", questId)
|
2024-07-07 12:29:29 +02:00
|
|
|
if questData then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Show()
|
2024-08-25 11:50:46 +02:00
|
|
|
local suffix = CzechQuestsAddon_Store.config.DEBUG_MODE and " (" .. questId .. ")" or ""
|
2024-08-19 13:08:40 +02:00
|
|
|
local questTitle = questData.title .. suffix
|
2024-08-21 12:33:41 +02:00
|
|
|
local xOffset = hasModel and 210 or 0
|
2024-08-19 13:08:40 +02:00
|
|
|
if event == "QUEST_PROGRESS" then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-26 09:25:41 +02:00
|
|
|
questTitle,
|
|
|
|
questData.progress,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QuestFrame,
|
|
|
|
-20,
|
|
|
|
xOffset
|
2024-07-07 12:29:29 +02:00
|
|
|
)
|
2024-08-19 13:08:40 +02:00
|
|
|
elseif event == "QUEST_COMPLETE" then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-26 09:25:41 +02:00
|
|
|
questTitle,
|
|
|
|
questData.completion,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QuestFrame,
|
|
|
|
-20,
|
|
|
|
xOffset
|
2024-07-07 12:29:29 +02:00
|
|
|
)
|
2024-08-19 13:08:40 +02:00
|
|
|
elseif event == "QUEST_DETAIL" then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-26 09:25:41 +02:00
|
|
|
questTitle,
|
|
|
|
questData.description,
|
|
|
|
"Cíl úkolu",
|
|
|
|
questData.objective,
|
|
|
|
QuestFrame,
|
|
|
|
-20,
|
|
|
|
xOffset
|
2024-07-07 12:29:29 +02:00
|
|
|
)
|
2024-08-19 13:08:40 +02:00
|
|
|
else
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
2024-07-07 12:29:29 +02:00
|
|
|
end
|
|
|
|
else
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
2024-07-07 12:29:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-08-19 13:08:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function CzechQuestsAddon:ShowQuestItemTranslation()
|
|
|
|
-- Hide frame, may contain old texts
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
2024-07-07 12:29:29 +02:00
|
|
|
|
2024-08-19 13:08:40 +02:00
|
|
|
-- should work for both wow version
|
2024-07-15 13:37:24 +02:00
|
|
|
if ItemTextFrame:IsShown() then
|
2024-08-26 09:25:41 +02:00
|
|
|
local item = {}
|
2024-08-26 22:25:54 +02:00
|
|
|
|
|
|
|
-- get item name
|
2024-08-26 09:25:41 +02:00
|
|
|
local itemName = ItemTextGetItem();
|
|
|
|
local titlePage = CzechQuestsAddon:GetData("item", itemName)
|
2024-08-26 22:25:54 +02:00
|
|
|
|
|
|
|
-- 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.descriptionMale
|
|
|
|
if item.name ~= nil and item.content ~= nil then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon:ShowTranslationQuestFrame(
|
2024-08-26 22:25:54 +02:00
|
|
|
item.name,
|
|
|
|
item.content,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
ItemTextFrame,
|
|
|
|
-20,
|
|
|
|
0
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2024-08-24 19:46:31 +02:00
|
|
|
end
|
2024-08-26 22:25:54 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:Show()
|
2024-07-15 13:37:24 +02:00
|
|
|
end
|
2024-07-07 12:29:29 +02:00
|
|
|
end
|
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
function CzechQuestsAddon:ShowSpeechTranslation(sender, message)
|
|
|
|
local blue = "|cffADD8E6"
|
|
|
|
local yellow = "|cffffd200"
|
|
|
|
local white = "|cffffffff"
|
|
|
|
local reset = "|r"
|
|
|
|
|
|
|
|
local text = nil
|
|
|
|
local translation = CzechQuestsAddon:GetData("speech", message)
|
|
|
|
|
|
|
|
if translation ~= nil then
|
|
|
|
text = translation.text
|
|
|
|
|
|
|
|
CzechQuestsAddon.translationSpeechFrame.npcName:SetText(sender)
|
2024-07-15 13:37:24 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationSpeechFrame.text:SetText(text)
|
|
|
|
CzechQuestsAddon.translationSpeechFrame.text:SetPoint(
|
|
|
|
"TOPLEFT", CzechQuestsAddon.translationSpeechFrame.npcName, "BOTTOMLEFT", 0, -10
|
|
|
|
)
|
2024-07-07 12:29:29 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationSpeechFrame:Show()
|
|
|
|
|
|
|
|
print(blue .. "[CZ]" .. reset .. " " .. yellow .. sender .. reset .. ": " .. white .. text .. reset)
|
|
|
|
end
|
|
|
|
|
|
|
|
if timerHandle then
|
|
|
|
timerHandle:Cancel()
|
2024-08-19 13:08:40 +02:00
|
|
|
end
|
2025-02-26 02:05:52 +01:00
|
|
|
|
|
|
|
timerHandle = C_Timer.NewTimer(10, function()
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:Hide()
|
|
|
|
end)
|
|
|
|
|
2024-08-19 13:08:40 +02:00
|
|
|
end
|
2024-07-15 13:37:24 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
-- Hover is enabled only for QuestLogFrame and QuestMapDetailsScrollFrame
|
|
|
|
local function SetHoverScripts(frame)
|
|
|
|
frame:SetScript("OnEnter", function()
|
|
|
|
CzechQuestsAddon:ShowQuestTranslation()
|
|
|
|
end)
|
2024-08-25 11:50:46 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
frame:SetScript("OnLeave", function()
|
|
|
|
CzechQuestsAddon.translationQuestFrame:Hide()
|
|
|
|
end)
|
|
|
|
end
|
2024-08-25 11:50:46 +02:00
|
|
|
|
2025-02-26 02:05:52 +01:00
|
|
|
function CzechQuestsAddon:InitializeTranslations()
|
|
|
|
-- create translation frame
|
|
|
|
CzechQuestsAddon.translationQuestFrame = CzechQuestsAddon:CreateTranslationQuestFrame()
|
|
|
|
CzechQuestsAddon.translationSpeechFrame = CzechQuestsAddon:CreateTranslationSpeechFrame()
|
|
|
|
|
|
|
|
-- Register events
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("PLAYER_LOGIN")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("QUEST_PROGRESS")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("QUEST_COMPLETE")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("QUEST_FINISHED")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("QUEST_DETAIL")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("ITEM_TEXT_READY")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("PLAYER_STARTED_MOVING")
|
|
|
|
CzechQuestsAddon.translationQuestFrame:RegisterEvent("PLAYER_STOPPED_MOVING")
|
2024-08-25 11:50:46 +02:00
|
|
|
|
|
|
|
-- Define event handler for the main frame
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame:SetScript("OnEvent", function(self, event)
|
2024-08-25 11:50:46 +02:00
|
|
|
if event == "PLAYER_LOGIN" then
|
|
|
|
-- classic
|
|
|
|
if QuestLogFrame then
|
|
|
|
SetHoverScripts(QuestLogFrame)
|
|
|
|
end
|
|
|
|
-- retail
|
|
|
|
if QuestMapDetailsScrollFrame then
|
|
|
|
SetHoverScripts(QuestMapDetailsScrollFrame)
|
|
|
|
end
|
2024-07-15 13:37:24 +02:00
|
|
|
end
|
2024-07-07 12:29:29 +02:00
|
|
|
|
2024-08-25 11:50:46 +02:00
|
|
|
if event == "QUEST_PROGRESS" or event == "QUEST_COMPLETE" or event == "QUEST_DETAIL" or event == "QUEST_FINISHED" then
|
|
|
|
CzechQuestsAddon:ShowQuestTranslation(event)
|
|
|
|
end
|
2024-08-19 13:08:40 +02:00
|
|
|
|
2024-08-25 11:50:46 +02:00
|
|
|
if (event == "ITEM_TEXT_READY") then
|
|
|
|
CzechQuestsAddon:ShowQuestItemTranslation()
|
|
|
|
end
|
2025-02-10 14:56:27 +01:00
|
|
|
|
|
|
|
if event == "PLAYER_STARTED_MOVING" then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(
|
2025-02-10 14:56:27 +01:00
|
|
|
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA / 100
|
|
|
|
)
|
|
|
|
elseif event == "PLAYER_STOPPED_MOVING" then
|
2025-02-26 02:05:52 +01:00
|
|
|
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(1)
|
2025-02-10 14:56:27 +01:00
|
|
|
end
|
|
|
|
|
2024-08-25 11:50:46 +02:00
|
|
|
end)
|
2025-02-26 02:05:52 +01:00
|
|
|
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:RegisterEvent("CHAT_MSG_MONSTER_SAY")
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:RegisterEvent("CHAT_MSG_MONSTER_YELL")
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:RegisterEvent("CHAT_MSG_MONSTER_PARTY")
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")
|
|
|
|
|
|
|
|
-- Define event handler for the main frame
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:SetScript("OnEvent", function(self, event, message, sender)
|
|
|
|
CzechQuestsAddon:ShowSpeechTranslation(sender, message)
|
|
|
|
end)
|
|
|
|
|
|
|
|
end
|