Refactor and expand Translation and Quest management.
This commit is contained in:
parent
4660216504
commit
5f21775771
20 changed files with 2546 additions and 9969 deletions
283
Addon/Addon.lua
Executable file → Normal file
283
Addon/Addon.lua
Executable file → Normal file
|
@ -1,189 +1,3 @@
|
|||
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:IsShown() then
|
||||
-- get quest ID
|
||||
local questId = C_QuestLog.GetSelectedQuest()
|
||||
-- detect if quest frame does not include npc preview
|
||||
local hasModel = QuestModelScene:IsShown()
|
||||
-- show translation frame
|
||||
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 0
|
||||
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
|
||||
-- get quest ID
|
||||
local questId = GetQuestID()
|
||||
-- detect if quest frame does not include npc preview
|
||||
local hasModel = QuestModelScene and QuestModelScene:IsShown() or false
|
||||
-- show translation frame
|
||||
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.descriptionMale
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
CzechQuestsAddon.translationSpeechFrame.text:SetText(text)
|
||||
CzechQuestsAddon.translationSpeechFrame.text:SetPoint(
|
||||
"TOPLEFT", CzechQuestsAddon.translationSpeechFrame.npcName, "BOTTOMLEFT", 0, -10
|
||||
)
|
||||
|
||||
CzechQuestsAddon.translationSpeechFrame:Show()
|
||||
|
||||
print(blue .. "[CZ]" .. reset .. " " .. yellow .. sender .. reset .. ": " .. white .. text .. reset)
|
||||
end
|
||||
|
||||
if timerHandle then
|
||||
timerHandle:Cancel()
|
||||
end
|
||||
|
||||
timerHandle = C_Timer.NewTimer(10, function()
|
||||
CzechQuestsAddon.translationSpeechFrame:Hide()
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
-- Hover is enabled only for QuestLogFrame and QuestMapDetailsScrollFrame
|
||||
local function SetHoverScripts(frame)
|
||||
frame:SetScript("OnEnter", function()
|
||||
CzechQuestsAddon:ShowQuestTranslation()
|
||||
|
@ -195,60 +9,65 @@ local function SetHoverScripts(frame)
|
|||
end
|
||||
|
||||
function CzechQuestsAddon:InitializeTranslations()
|
||||
-- create translation frame
|
||||
CzechQuestsAddon.translationQuestFrame = CzechQuestsAddon:CreateTranslationQuestFrame()
|
||||
CzechQuestsAddon.translationSpeechFrame = CzechQuestsAddon:CreateTranslationSpeechFrame()
|
||||
-- Activate Quest translations
|
||||
if CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_ENABLED then
|
||||
CzechQuestsAddon.translationQuestFrame = CzechQuestsAddon:CreateTranslationQuestFrame()
|
||||
|
||||
-- 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")
|
||||
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")
|
||||
|
||||
-- Define event handler for the main frame
|
||||
CzechQuestsAddon.translationQuestFrame:SetScript("OnEvent", function(self, event)
|
||||
if event == "PLAYER_LOGIN" then
|
||||
-- classic
|
||||
if QuestLogFrame then
|
||||
SetHoverScripts(QuestLogFrame)
|
||||
CzechQuestsAddon.translationQuestFrame:SetScript("OnEvent", function(self, event)
|
||||
if event == "PLAYER_LOGIN" then
|
||||
-- classic
|
||||
if QuestLogFrame then
|
||||
SetHoverScripts(QuestLogFrame)
|
||||
end
|
||||
-- retail
|
||||
if QuestMapDetailsScrollFrame then
|
||||
SetHoverScripts(QuestMapDetailsScrollFrame)
|
||||
end
|
||||
end
|
||||
-- retail
|
||||
if QuestMapDetailsScrollFrame then
|
||||
SetHoverScripts(QuestMapDetailsScrollFrame)
|
||||
|
||||
if event == "QUEST_PROGRESS" or event == "QUEST_COMPLETE" or event == "QUEST_DETAIL" or event == "QUEST_FINISHED" then
|
||||
CzechQuestsAddon:ShowQuestTranslation(event)
|
||||
end
|
||||
end
|
||||
|
||||
if event == "QUEST_PROGRESS" or event == "QUEST_COMPLETE" or event == "QUEST_DETAIL" or event == "QUEST_FINISHED" then
|
||||
CzechQuestsAddon:ShowQuestTranslation(event)
|
||||
end
|
||||
if (event == "ITEM_TEXT_READY") then
|
||||
CzechQuestsAddon:ShowQuestItemTranslation()
|
||||
end
|
||||
|
||||
if (event == "ITEM_TEXT_READY") then
|
||||
CzechQuestsAddon:ShowQuestItemTranslation()
|
||||
end
|
||||
if CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING then
|
||||
if event == "PLAYER_STARTED_MOVING" then
|
||||
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA / 100
|
||||
)
|
||||
elseif event == "PLAYER_STOPPED_MOVING" then
|
||||
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(1)
|
||||
end
|
||||
end
|
||||
|
||||
if event == "PLAYER_STARTED_MOVING" then
|
||||
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA / 100
|
||||
)
|
||||
elseif event == "PLAYER_STOPPED_MOVING" then
|
||||
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(1)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
end)
|
||||
-- Activate Speech translations
|
||||
if CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ENABLED then
|
||||
CzechQuestsAddon.translationSpeechFrame = CzechQuestsAddon:CreateTranslationSpeechFrame()
|
||||
|
||||
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")
|
||||
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)
|
||||
CzechQuestsAddon.translationSpeechFrame:SetScript("OnEvent", function(self, event, message, sender)
|
||||
CzechQuestsAddon:ShowSpeechTranslation(sender, message)
|
||||
end)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,35 +1,29 @@
|
|||
function CzechQuestsAddon:GetData(key, id)
|
||||
if CzechQuestsAddon.data[key] then
|
||||
if key == "quest" then
|
||||
if CzechQuestsAddon.data[key][id] then
|
||||
local quest = CzechQuestsAddon.data[key][id];
|
||||
local QuestTextMethod = {
|
||||
Description = GetQuestText,
|
||||
Objective = GetObjectiveText,
|
||||
};
|
||||
|
||||
local function ResolveFemaleVersion(maleVersion, femaleVersion)
|
||||
local gender = UnitSex("player")
|
||||
if gender == 2 then
|
||||
return maleVersion
|
||||
else
|
||||
return femaleVersion == "" and maleVersion or femaleVersion
|
||||
end
|
||||
end
|
||||
local function GetQuestText(method)
|
||||
local text = QuestTextMethod[method]();
|
||||
if text then
|
||||
return text
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local standardQuest = {
|
||||
title = ResolveFemaleVersion(quest.titleMale, quest.titleFemale),
|
||||
objective = ResolveFemaleVersion(quest.objectiveMale, quest.objectiveFemale),
|
||||
description = ResolveFemaleVersion(quest.descriptionMale, quest.descriptionFemale),
|
||||
progress = ResolveFemaleVersion(quest.progressMale, quest.progressFemale),
|
||||
completion = ResolveFemaleVersion(quest.completionMale, quest.completionFemale),
|
||||
}
|
||||
return standardQuest
|
||||
end
|
||||
elseif CzechQuestsAddon.data[key][id] then
|
||||
return CzechQuestsAddon.data[key][id]
|
||||
local function GetQuestLogQuestIndex(questID)
|
||||
local numEntries = C_QuestLog.GetNumQuestLogEntries()
|
||||
for questLogIndex = 1, numEntries do
|
||||
local info = C_QuestLog.GetInfo(questLogIndex)
|
||||
if info and info.questID == questID then
|
||||
return questLogIndex
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:replacePlaceholders(text)
|
||||
local function ReplacePlaceholders(text)
|
||||
if text == nil then
|
||||
return text
|
||||
end
|
||||
|
@ -81,26 +75,52 @@ function CzechQuestsAddon:replacePlaceholders(text)
|
|||
return formatted
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:dumpTable(tbl, indent)
|
||||
-- Initialize indent if not provided
|
||||
indent = indent or 0
|
||||
local function TransformText(text)
|
||||
return ReplacePlaceholders(text)
|
||||
end
|
||||
|
||||
-- Check if the input is actually a table
|
||||
if type(tbl) ~= "table" then
|
||||
print(string.rep(" ", indent) .. tostring(tbl))
|
||||
return
|
||||
local function ResolveGender(maleVersion, femaleVersion)
|
||||
local gender = UnitSex("player")
|
||||
if gender == 2 then
|
||||
return TransformText(maleVersion)
|
||||
else
|
||||
return femaleVersion == nil and TransformText(maleVersion) or TransformText(femaleVersion)
|
||||
end
|
||||
end
|
||||
|
||||
-- Iterate through the table and print keys and values
|
||||
for k, v in pairs(tbl) do
|
||||
local formatting = string.rep(" ", indent) .. tostring(k) .. ": "
|
||||
if type(v) == "table" then
|
||||
print(formatting)
|
||||
CzechQuestsAddon:dumpTable(v, indent + 1)
|
||||
elseif type(v) == "boolean" then
|
||||
print(formatting .. (v and "true" or "false"))
|
||||
local function GetQuest(id)
|
||||
local quest = CzechQuestsAddon.data.quest[id];
|
||||
if quest then
|
||||
local description = ""
|
||||
local objective = ""
|
||||
if QuestMapDetailsScrollFrame and QuestMapDetailsScrollFrame:IsVisible() then
|
||||
local index = GetQuestLogQuestIndex(id)
|
||||
description, objective = GetQuestLogQuestText(index)
|
||||
else
|
||||
print(formatting .. tostring(v))
|
||||
description = GetQuestText("Description")
|
||||
objective = GetQuestText("Objective")
|
||||
end
|
||||
return {
|
||||
title = ResolveGender(quest.titleMale, quest.titleFemale),
|
||||
objective = CzechQuestsAddon:TransformIntoParagraphs(
|
||||
objective, ResolveGender(quest.objectiveMale, quest.objectiveFemale)
|
||||
),
|
||||
description = CzechQuestsAddon:TransformIntoParagraphs(
|
||||
description, ResolveGender(quest.descriptionMale, quest.descriptionFemale)
|
||||
),
|
||||
progress = ResolveGender(quest.progressMale, quest.progressFemale),
|
||||
completion = ResolveGender(quest.completionMale, quest.completionFemale),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:GetData(key, id)
|
||||
if CzechQuestsAddon.data[key] then
|
||||
if key == "quest" then
|
||||
return GetQuest(id)
|
||||
elseif CzechQuestsAddon.data[key][id] then
|
||||
return CzechQuestsAddon.data[key][id]
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
144
Addon/Code/Quest.lua
Executable file
144
Addon/Code/Quest.lua
Executable file
|
@ -0,0 +1,144 @@
|
|||
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
|
51
Addon/Code/QuestParser.lua
Executable file
51
Addon/Code/QuestParser.lua
Executable file
|
@ -0,0 +1,51 @@
|
|||
local function SplitParagraphs(text)
|
||||
local paragraphs = {}
|
||||
for paragraph in string.gmatch(text, "([^\n]+)") do
|
||||
table.insert(paragraphs, paragraph)
|
||||
end
|
||||
return paragraphs
|
||||
end
|
||||
|
||||
local function SplitSentences(paragraph)
|
||||
local sentences = {}
|
||||
for sentence in string.gmatch(paragraph, "([^%.%?!]+[%.%?!]?)[%s]*") do
|
||||
local trimmed = sentence:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
if #trimmed > 0 then
|
||||
table.insert(sentences, trimmed)
|
||||
end
|
||||
end
|
||||
return sentences
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:TransformIntoParagraphs(original_text, translation_text)
|
||||
if original_text == "" or original_text == nil then
|
||||
return translation_text
|
||||
end
|
||||
|
||||
local original_paragraphs = SplitParagraphs(original_text)
|
||||
local translation_paragraphs = {}
|
||||
|
||||
local translation_sentences = SplitSentences(translation_text)
|
||||
local counter = 1
|
||||
|
||||
for _, orig_paragraph in ipairs(original_paragraphs) do
|
||||
local orig_sentences = SplitSentences(orig_paragraph)
|
||||
|
||||
local paragraph_sentence_count = #orig_sentences
|
||||
local collected = {}
|
||||
|
||||
for i = 1, paragraph_sentence_count do
|
||||
if translation_sentences[counter] then
|
||||
table.insert(collected, translation_sentences[counter])
|
||||
counter = counter + 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(translation_paragraphs, table.concat(collected, " "))
|
||||
end
|
||||
|
||||
local final_text = table.concat(translation_paragraphs, "\n")
|
||||
return final_text
|
||||
end
|
67
Addon/Code/Speeches.lua
Executable file
67
Addon/Code/Speeches.lua
Executable file
|
@ -0,0 +1,67 @@
|
|||
local messages = {}
|
||||
local function ReflowMessages()
|
||||
local offsetY = 5
|
||||
for i = #messages, 1, -1 do
|
||||
local msg = messages[i]
|
||||
msg:ClearAllPoints()
|
||||
msg:SetPoint(
|
||||
"BOTTOMLEFT",
|
||||
CzechQuestsAddon.translationSpeechFrame.content,
|
||||
"BOTTOMLEFT",
|
||||
10,
|
||||
offsetY
|
||||
)
|
||||
offsetY = offsetY + msg:GetHeight()
|
||||
end
|
||||
|
||||
CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY + 5)
|
||||
end
|
||||
|
||||
local function RemoveMessage(frame)
|
||||
local emptyMessages = true
|
||||
for i, fs in ipairs(messages) do
|
||||
emptyMessages = false
|
||||
if fs == frame then
|
||||
local fadeAnimationGroup = fs:CreateAnimationGroup()
|
||||
local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha")
|
||||
fadeOut:SetFromAlpha(1)
|
||||
fadeOut:SetToAlpha(0)
|
||||
fadeOut:SetDuration(0.2)
|
||||
fadeOut:SetStartDelay(0)
|
||||
|
||||
fadeAnimationGroup:SetScript("OnFinished", function()
|
||||
table.remove(messages, i)
|
||||
fs:Hide()
|
||||
ReflowMessages()
|
||||
end)
|
||||
|
||||
fs:Show()
|
||||
fadeAnimationGroup:Play()
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if emptyMessages then
|
||||
CzechQuestsAddon.translationSpeechFrame:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function AddMessage(sender, message)
|
||||
local formattedText = string.format("|cffffd200%s|r\n%s", sender, message)
|
||||
local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText)
|
||||
|
||||
CzechQuestsAddon.translationSpeechFrame:Show()
|
||||
|
||||
table.insert(messages, frame)
|
||||
ReflowMessages()
|
||||
|
||||
C_Timer.After(30, function()
|
||||
RemoveMessage(frame)
|
||||
end)
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:ShowSpeechTranslation(sender, message)
|
||||
local text = CzechQuestsAddon:GetData("speech", message) or message
|
||||
AddMessage(sender, text)
|
||||
end
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -9,21 +9,20 @@ function GetFontOptions()
|
|||
end
|
||||
|
||||
function CzechQuestsAddon:InitializeSettings()
|
||||
CzechQuestsAddon.optionsFrame = {};
|
||||
CzechQuestsAddon.optionsFrame, layout = Settings.RegisterVerticalLayoutCategory("CzechQuests")
|
||||
local category, layout = Settings.RegisterVerticalLayoutCategory("CzechQuests")
|
||||
|
||||
-- Add options for quests
|
||||
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Questy"))
|
||||
CzechQuestsAddon:AddQuestOptions(CzechQuestsAddon.optionsFrame)
|
||||
CzechQuestsAddon:AddQuestOptions(category, layout)
|
||||
|
||||
-- Add options for speech
|
||||
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Projevy"))
|
||||
CzechQuestsAddon:AddSpeechOptions(CzechQuestsAddon.optionsFrame)
|
||||
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Projevy (zatím ve vývoji)"))
|
||||
CzechQuestsAddon:AddSpeechOptions(category, layout)
|
||||
|
||||
-- Add options for speech
|
||||
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Ostatní"))
|
||||
CzechQuestsAddon:AddOthersOptions(CzechQuestsAddon.optionsFrame)
|
||||
CzechQuestsAddon:AddOthersOptions(category, layout)
|
||||
|
||||
-- Store it into Addon options
|
||||
Settings.RegisterAddOnCategory(CzechQuestsAddon.optionsFrame)
|
||||
Settings.RegisterAddOnCategory(category)
|
||||
end
|
|
@ -1,9 +1,21 @@
|
|||
function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
||||
function CzechQuestsAddon:AddQuestOptions(category)
|
||||
|
||||
-- Enable translations
|
||||
local enableCheckbox = Settings.RegisterAddOnSetting(
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_ENABLED",
|
||||
"TRANSLATION_QUEST_FRAME_ENABLED",
|
||||
CzechQuestsAddon_Store.config,
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_ENABLED),
|
||||
"Zapnout *",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_ENABLED
|
||||
)
|
||||
Settings.CreateCheckbox(category, enableCheckbox)
|
||||
|
||||
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
||||
-- Add DARK mode checkbox
|
||||
local darkModeCheckbox = Settings.RegisterAddOnSetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_DARK_MODE",
|
||||
"TRANSLATION_QUEST_FRAME_DARK_MODE",
|
||||
CzechQuestsAddon_Store.config,
|
||||
|
@ -11,7 +23,7 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
"Použít tmavý režim",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_DARK_MODE
|
||||
)
|
||||
Settings.CreateCheckbox(optionsFrame, darkModeCheckbox)
|
||||
Settings.CreateCheckbox(category, darkModeCheckbox)
|
||||
end
|
||||
|
||||
-- define FontOptions
|
||||
|
@ -26,7 +38,7 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
|
||||
-- Add header font dropdown menu
|
||||
local headerFontFamilyDropdown = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY),
|
||||
"Písmo nadpisu",
|
||||
|
@ -39,11 +51,11 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
CzechQuestsAddon:UpdateTranslationQuestFrameFontSettings()
|
||||
end
|
||||
)
|
||||
Settings.CreateDropdown(optionsFrame, headerFontFamilyDropdown, GetFontOptions)
|
||||
Settings.CreateDropdown(category, headerFontFamilyDropdown, GetFontOptions)
|
||||
|
||||
-- Add text font dropdown menu
|
||||
local textFontFamilyDropdown = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY),
|
||||
"Písmo textu",
|
||||
|
@ -56,11 +68,11 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
CzechQuestsAddon:UpdateTranslationQuestFrameFontSettings()
|
||||
end
|
||||
)
|
||||
Settings.CreateDropdown(optionsFrame, textFontFamilyDropdown, GetFontOptions)
|
||||
Settings.CreateDropdown(category, textFontFamilyDropdown, GetFontOptions)
|
||||
|
||||
-- Add slider for change primary header font size
|
||||
local primaryHeaderFontSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_PRIMARY_HEADER_FONT_SIZE",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_PRIMARY_HEADER_FONT_SIZE),
|
||||
"Velikost názvu",
|
||||
|
@ -75,11 +87,11 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
)
|
||||
local primaryHeaderFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
|
||||
primaryHeaderFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, primaryHeaderFontSizeSlider, primaryHeaderFontSizeSliderOptions)
|
||||
Settings.CreateSlider(category, primaryHeaderFontSizeSlider, primaryHeaderFontSizeSliderOptions)
|
||||
|
||||
-- Add slider for change secondary header font size
|
||||
local secondaryHeaderFontSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_SECONDARY_HEADER_FONT_SIZE",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_SECONDARY_HEADER_FONT_SIZE),
|
||||
"Velikost nadpisu",
|
||||
|
@ -94,12 +106,12 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
)
|
||||
local secondaryHeaderFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
|
||||
secondaryHeaderFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, secondaryHeaderFontSizeSlider, secondaryHeaderFontSizeSliderOptions)
|
||||
Settings.CreateSlider(category, secondaryHeaderFontSizeSlider, secondaryHeaderFontSizeSliderOptions)
|
||||
|
||||
|
||||
-- Add slider for change secondary header font size
|
||||
local textFontSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE),
|
||||
"Velikost textu",
|
||||
|
@ -114,11 +126,23 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
)
|
||||
local textFontSizeSliderOptions = Settings.CreateSliderOptions(10, 30, 1)
|
||||
textFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, textFontSizeSlider, textFontSizeSliderOptions)
|
||||
Settings.CreateSlider(category, textFontSizeSlider, textFontSizeSliderOptions)
|
||||
|
||||
-- Add DARK mode checkbox
|
||||
local darkModeCheckbox = Settings.RegisterAddOnSetting(
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING",
|
||||
"TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING",
|
||||
CzechQuestsAddon_Store.config,
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING),
|
||||
"Pruhlednost pouze pri chuzi *",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING
|
||||
)
|
||||
Settings.CreateCheckbox(category, darkModeCheckbox)
|
||||
|
||||
-- Add slider for change secondary header font size
|
||||
local textureAlphaSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA),
|
||||
"Pruhlednost pozadí",
|
||||
|
@ -132,6 +156,6 @@ function CzechQuestsAddon:AddQuestOptions(optionsFrame)
|
|||
)
|
||||
local textureAlphaSliderOptions = Settings.CreateSliderOptions(10, 100, 10)
|
||||
textureAlphaSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, textureAlphaSlider, textureAlphaSliderOptions)
|
||||
Settings.CreateSlider(category, textureAlphaSlider, textureAlphaSliderOptions)
|
||||
|
||||
end
|
||||
|
|
|
@ -1,94 +1,90 @@
|
|||
function CzechQuestsAddon:AddSpeechOptions(optionsFrame)
|
||||
function CzechQuestsAddon:AddSpeechOptions(category, layout)
|
||||
|
||||
-- Add header font dropdown menu
|
||||
local npcFontFamilyDropdown = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY),
|
||||
"Písmo jména",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY,
|
||||
function()
|
||||
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY
|
||||
end,
|
||||
function(value)
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY = value
|
||||
CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
end
|
||||
-- Enable translations
|
||||
local enableCheckbox = Settings.RegisterAddOnSetting(
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_ENABLED",
|
||||
"TRANSLATION_SPEECH_FRAME_ENABLED",
|
||||
CzechQuestsAddon_Store.config,
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ENABLED),
|
||||
"Zapnout *",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ENABLED
|
||||
)
|
||||
Settings.CreateDropdown(optionsFrame, npcFontFamilyDropdown, GetFontOptions)
|
||||
Settings.CreateCheckbox(category, enableCheckbox)
|
||||
|
||||
-- Add text font dropdown menu
|
||||
local textFontFamilyDropdown = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY),
|
||||
"Písmo textu",
|
||||
"Písmo textu *",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY,
|
||||
function()
|
||||
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY
|
||||
end,
|
||||
function(value)
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY = value
|
||||
CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
end
|
||||
)
|
||||
Settings.CreateDropdown(optionsFrame, textFontFamilyDropdown, GetFontOptions)
|
||||
|
||||
-- Add slider for change primary header font size
|
||||
local npcFontSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE),
|
||||
"Velikost jméma",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE,
|
||||
function()
|
||||
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE
|
||||
end,
|
||||
function(value)
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE = value
|
||||
CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
end
|
||||
)
|
||||
local npcFontSizeOption = Settings.CreateSliderOptions(8, 30, 1)
|
||||
npcFontSizeOption:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, npcFontSizeSlider, npcFontSizeOption)
|
||||
Settings.CreateDropdown(category, textFontFamilyDropdown, GetFontOptions)
|
||||
|
||||
-- Add slider for change secondary header font size
|
||||
local textFontSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE),
|
||||
"Velikost textu",
|
||||
"Velikost textu *",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE,
|
||||
function()
|
||||
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE
|
||||
end,
|
||||
function(value)
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE = value
|
||||
CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
end
|
||||
)
|
||||
local textFontSizeSliderOptions = Settings.CreateSliderOptions(8, 30, 1)
|
||||
textFontSizeSliderOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, textFontSizeSlider, textFontSizeSliderOptions)
|
||||
Settings.CreateSlider(category, textFontSizeSlider, textFontSizeSliderOptions)
|
||||
|
||||
-- Add slider for change secondary header font size
|
||||
-- Add slider for change frame width
|
||||
local windowWidthSizeSlider = Settings.RegisterProxySetting(
|
||||
optionsFrame,
|
||||
category,
|
||||
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_WIDTH",
|
||||
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH),
|
||||
"Šírka zpráva",
|
||||
"Šírka zprávy",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH,
|
||||
function()
|
||||
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH
|
||||
end,
|
||||
function(value)
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH = value
|
||||
CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
CzechQuestsAddon.translationSpeechFrame:SetWidth(
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH
|
||||
)
|
||||
CzechQuestsAddon.translationSpeechFrame.content:SetWidth(
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH
|
||||
)
|
||||
end
|
||||
)
|
||||
local windowWidthSizeSliderOption = Settings.CreateSliderOptions(200, 800, 10)
|
||||
windowWidthSizeSliderOption:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
|
||||
Settings.CreateSlider(optionsFrame, windowWidthSizeSlider, windowWidthSizeSliderOption)
|
||||
Settings.CreateSlider(category, windowWidthSizeSlider, windowWidthSizeSliderOption)
|
||||
|
||||
local initializer= CreateSettingsButtonInitializer(
|
||||
'Resetovat pozici okna',
|
||||
'RESET',
|
||||
function()
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0}
|
||||
CzechQuestsAddon.translationSpeechFrame:ClearAllPoints()
|
||||
CzechQuestsAddon.translationSpeechFrame:SetPoint(
|
||||
"CENTER", UIParent, "CENTER",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y
|
||||
)
|
||||
end,
|
||||
nil,
|
||||
"Resetovat pozici okna"
|
||||
)
|
||||
layout:AddInitializer(initializer)
|
||||
|
||||
end
|
||||
|
|
|
@ -100,6 +100,10 @@ function CzechQuestsAddon:SetTranslationQuestFrameTextureFromSettings(frame)
|
|||
frame.secondaryText:SetTextColor(255, 255, 255, 1)
|
||||
end
|
||||
end
|
||||
|
||||
if not CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING then
|
||||
frame.texture:SetAlpha(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA / 100)
|
||||
end
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:UpdateTranslationQuestFrameFontSettings()
|
||||
|
@ -129,10 +133,6 @@ function CzechQuestsAddon:UpdateTranslationQuestFrameFontSettings()
|
|||
end
|
||||
|
||||
function CzechQuestsAddon:ShowTranslationQuestFrame(primaryHeader, primaryText, secondaryHeader, secondaryText, parentFrame, yOffset, xOffset)
|
||||
-- replace placeholders with current values
|
||||
primaryText = CzechQuestsAddon:replacePlaceholders(primaryText);
|
||||
secondaryText = CzechQuestsAddon:replacePlaceholders(secondaryText);
|
||||
|
||||
-- when user change own setting, does not require reload, just apply it
|
||||
CzechQuestsAddon:SetTranslationQuestFrameTextureFromSettings(CzechQuestsAddon.translationQuestFrame)
|
||||
|
||||
|
|
|
@ -1,59 +1,96 @@
|
|||
function CzechQuestsAddon:CreateTranslationSpeechFrame()
|
||||
local frame = {};
|
||||
local scroll = {};
|
||||
|
||||
-- Speech Translation Frame
|
||||
frame = CreateFrame("Frame", "CzechQuestsTranslationSpeechFrame", UIParant, "BackdropTemplate")
|
||||
frame:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 50)
|
||||
frame:SetPoint("CENTER", UIParent, "CENTER")
|
||||
scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "MinimalScrollFrameTemplate")
|
||||
scroll:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 120)
|
||||
|
||||
-- Make draggable
|
||||
frame:EnableMouse(true)
|
||||
frame:SetMovable(true)
|
||||
frame:RegisterForDrag("LeftButton")
|
||||
frame:SetScript("OnDragStart", function(self) self:StartMoving() end)
|
||||
frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
|
||||
-- Make movable
|
||||
scroll:SetMovable(true)
|
||||
scroll:EnableMouse(true)
|
||||
scroll:RegisterForDrag("LeftButton")
|
||||
|
||||
frame:Hide()
|
||||
scroll:SetScript("OnDragStart", function()
|
||||
scroll:StartMoving()
|
||||
end)
|
||||
|
||||
frame.npcName = frame:CreateFontString("CzechQuestsTranslationSpeechNpcName", "OVERLAY")
|
||||
frame.npcName:SetTextColor(1, 1, 0)
|
||||
frame.npcName:SetFont(
|
||||
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE,
|
||||
"OUTLINE"
|
||||
scroll:SetScript("OnDragStop", function(self)
|
||||
scroll:StopMovingOrSizing()
|
||||
local finalLeft, finalTop = self:GetLeft(), self:GetTop()
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = {
|
||||
x = finalLeft,
|
||||
y = finalTop
|
||||
}
|
||||
end)
|
||||
|
||||
-- Hide sidebar
|
||||
scroll.ScrollBar:Hide()
|
||||
scroll.ScrollBar.Show = function() end
|
||||
|
||||
-- Speech Translation Content Frame
|
||||
scroll.content = CreateFrame("Frame", nil, scroll)
|
||||
scroll.content:SetSize(scroll:GetWidth(), 1)
|
||||
|
||||
scroll:SetScrollChild(scroll.content)
|
||||
|
||||
-- Texture for control color and alpha
|
||||
scroll.content.texture = scroll.content:CreateTexture(nil, "ARTWORK")
|
||||
scroll.content.texture:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
scroll.content.texture:SetVertexColor(0, 0, 0, 0.2)
|
||||
|
||||
-- Set points to edges
|
||||
scroll.content.texture:SetPoint("TOPLEFT", scroll.content ,"TOPLEFT", 0, 0)
|
||||
scroll.content.texture:SetPoint("BOTTOMRIGHT", scroll.content ,"BOTTOMRIGHT", 0, 0)
|
||||
|
||||
scroll:SetScript("OnEnter", function()
|
||||
scroll.content.texture:SetAlpha(0.8)
|
||||
end)
|
||||
scroll:SetScript("OnLeave", function()
|
||||
scroll.content.texture:SetAlpha(0.2)
|
||||
end)
|
||||
|
||||
-- Set position
|
||||
scroll:ClearAllPoints()
|
||||
scroll:SetPoint(
|
||||
"TOPLEFT", UIParent, "TOPLEFT",
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y
|
||||
)
|
||||
frame.npcName:SetPoint("LEFT", frame, "LEFT", 0, 5)
|
||||
|
||||
frame.text = frame:CreateFontString("CzechQuestsTranslationSpeechText", "OVERLAY")
|
||||
frame.text:SetTextColor(1, 1, 1)
|
||||
frame.text:SetWordWrap(true)
|
||||
frame.text:SetFont(
|
||||
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE,
|
||||
"OUTLINE"
|
||||
)
|
||||
frame.text:SetTextColor(1, 1, 1)
|
||||
frame.text:SetWidth(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH)
|
||||
frame.text:SetJustifyH("LEFT")
|
||||
frame.text:SetJustifyV("TOP")
|
||||
scroll:Hide()
|
||||
|
||||
return frame;
|
||||
scroll.content:SetPoint("BOTTOMLEFT", scroll, "BOTTOMLEFT", 0, 0)
|
||||
|
||||
return scroll;
|
||||
end
|
||||
|
||||
function CzechQuestsAddon:UpdateTranslationSpeechFrameSettings()
|
||||
-- Font
|
||||
CzechQuestsAddon.translationSpeechFrame.npcName:SetFont(
|
||||
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_FAMILY,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_NPC_FONT_SIZE,
|
||||
"OUTLINE"
|
||||
)
|
||||
CzechQuestsAddon.translationSpeechFrame.text:SetFont(
|
||||
function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message)
|
||||
local frame = {};
|
||||
|
||||
-- Create content for messages
|
||||
frame = CreateFrame("Frame", nil, CzechQuestsAddon.translationSpeechFrame.content)
|
||||
frame:SetSize(CzechQuestsAddon.translationSpeechFrame.content:GetWidth() - 20, 1)
|
||||
|
||||
-- Message
|
||||
frame.string = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.string:SetWidth(frame:GetWidth())
|
||||
frame.string:SetTextColor(1, 1, 1)
|
||||
frame.string:SetWordWrap(true)
|
||||
|
||||
frame.string:SetPoint("TOPLEFT", frame, "TOPLEFT", 5, -5)
|
||||
frame.string:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -5, 5)
|
||||
|
||||
frame.string:SetJustifyH("LEFT")
|
||||
|
||||
frame.string:SetFont(
|
||||
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY,
|
||||
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE,
|
||||
"OUTLINE"
|
||||
)
|
||||
|
||||
-- Width
|
||||
CzechQuestsAddon.translationSpeechFrame.text:SetWidth(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH)
|
||||
CzechQuestsAddon.translationSpeechFrame:SetWidth(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH)
|
||||
frame.string:SetText(message)
|
||||
|
||||
frame:SetHeight(frame.string:GetHeight() + 10)
|
||||
|
||||
return frame;
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue