Enhance speech frame behavior and settings

This commit is contained in:
Roman Jaroš 2025-03-04 07:49:19 +01:00
parent e37886072f
commit 8b53a5247c
12 changed files with 65 additions and 43 deletions

View file

@ -125,6 +125,7 @@ local function ApplySpeechPlaceholders(text)
local formatted = text; local formatted = text;
formatted = string.gsub(formatted, '<name>', playerName); formatted = string.gsub(formatted, '<name>', playerName);
formatted = string.gsub(formatted, 'Champions', playerName); formatted = string.gsub(formatted, 'Champions', playerName);
formatted = string.gsub(formatted, 'champions', playerName);
return formatted return formatted
end end

View file

@ -8,7 +8,7 @@ end
local function SplitSentences(paragraph) local function SplitSentences(paragraph)
local sentences = {} local sentences = {}
for sentence in string.gmatch(paragraph, "([^%.%?!]+[%.%?!]?)[%s]*") do for sentence in string.gmatch(paragraph, "([^,%.%?!]+[,%.%?!]?)[%s]*") do
local trimmed = sentence:gsub("^%s+", ""):gsub("%s+$", "") local trimmed = sentence:gsub("^%s+", ""):gsub("%s+$", "")
if #trimmed > 0 then if #trimmed > 0 then
table.insert(sentences, trimmed) table.insert(sentences, trimmed)

View file

@ -1,28 +1,35 @@
local messages = {} local messages = {}
local function ReflowMessages() local function ReflowMessages()
local offsetY = 5 local offsetY = 5
for i = #messages, 1, -1 do for i = #messages, 1, -1 do
local msg = messages[i] local fs = messages[i]
msg:ClearAllPoints() fs:ClearAllPoints()
msg:SetPoint( fs:SetPoint(
"BOTTOMLEFT", "BOTTOMLEFT",
CzechQuestsAddon.translationSpeechFrame.content, CzechQuestsAddon.translationSpeechFrame.content,
"BOTTOMLEFT", "BOTTOMLEFT",
10, 5,
offsetY offsetY
) )
offsetY = offsetY + msg:GetHeight() fs:Show()
offsetY = offsetY + fs:GetHeight()
end end
if #messages == 0 then if #messages == 0 then
CzechQuestsAddon.translationSpeechFrame:Hide() CzechQuestsAddon.translationSpeechFrame:Hide()
end end
CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY + 5) offsetY = offsetY + 5
if offsetY < 150 then
offsetY = 150
end
CzechQuestsAddon.translationSpeechFrame:UpdateScrollChildRect() -- Ujistí se, že velikost obsahu je aktuální CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY)
CzechQuestsAddon.translationSpeechFrame:UpdateScrollChildRect()
local maxScroll = CzechQuestsAddon.translationSpeechFrame:GetVerticalScrollRange() local maxScroll = CzechQuestsAddon.translationSpeechFrame:GetVerticalScrollRange()
CzechQuestsAddon.translationSpeechFrame:SetVerticalScroll(maxScroll) -- Nastaví rolování na dolní okraj CzechQuestsAddon.translationSpeechFrame:SetVerticalScroll(maxScroll)
end end
@ -33,7 +40,7 @@ local function RemoveMessage(frame)
local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha") local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha")
fadeOut:SetFromAlpha(1) fadeOut:SetFromAlpha(1)
fadeOut:SetToAlpha(0) fadeOut:SetToAlpha(0)
fadeOut:SetDuration(0.2) fadeOut:SetDuration(1)
fadeOut:SetStartDelay(0) fadeOut:SetStartDelay(0)
fadeAnimationGroup:SetScript("OnFinished", function() fadeAnimationGroup:SetScript("OnFinished", function()
@ -42,7 +49,6 @@ local function RemoveMessage(frame)
ReflowMessages() ReflowMessages()
end) end)
fs:Show()
fadeAnimationGroup:Play() fadeAnimationGroup:Play()
break break
@ -54,8 +60,6 @@ local function AddMessage(sender, message)
local formattedText = string.format("|cffffd200%s|r\n%s", sender, message) local formattedText = string.format("|cffffd200%s|r\n%s", sender, message)
local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText) local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText)
CzechQuestsAddon.translationSpeechFrame:Show()
table.insert(messages, frame) table.insert(messages, frame)
ReflowMessages() ReflowMessages()
@ -66,7 +70,12 @@ end
function CzechQuestsAddon:ShowSpeechTranslation(sender, message) function CzechQuestsAddon:ShowSpeechTranslation(sender, message)
local text = CzechQuestsAddon:GetData("speech", message) local text = CzechQuestsAddon:GetData("speech", message)
if text == nil and CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING then
text = message
end
if text ~= nil then if text ~= nil then
CzechQuestsAddon.translationSpeechFrame:Show()
AddMessage(sender, text) AddMessage(sender, text)
end end
end end

View file

@ -22,8 +22,9 @@ CzechQuestsAddon.data.quest[78529] = {
} }
CzechQuestsAddon.data.quest[81514] = { CzechQuestsAddon.data.quest[81514] = {
titleMale = "Bountiful Delves", titleMale = "Bountiful Delves",
objectiveMale = "Dokonči venkovní události, světové úkoly nebo získej renown a získej obnovený klíč od truhly nebo úlomky klíče od truhly, které ti umožní odemknout truhlu v Bountiful Delve.", objectiveMale = "Dokonči venkovní události, světové úkoly nebo týdenní úkoly, abys získal Restored Coffer Key nebo Coffer Key Shards, které ti umožní odemknout truhlu v Bountiful Delve.",
descriptionMale = "K boji proti Xal'atathovi budeme potřebovat spoustu zdrojů. Naštěstí pro vás jsme objevili zdroj! Některá naleziště, která jsme našli, jsou 'štědrá' na to, že tam padouši hromadí další poklady. Tento poklad lze odemknout pouze pomocí speciálních klíčů, které najdete po celém Khaz Algaru. Klíče a fragmenty klíčů lze nalézt po celém světě. Ulovte je a ponořte se do štědrého hloubení!", objectiveFemale = "Dokonči venkovní události, světové úkoly nebo týdenní úkoly, abys získala Restored Coffer Key nebo Coffer Key Shards, které ti umožní odemknout truhlu v Bountiful Delve.",
descriptionMale = "K boji proti Xal'atath budeme potřebovat spoustu zdrojů. Naštěstí pro tebe jsme objevili zdroj! Některá naleziště, která jsme našli, jsou 'štědrá' v tom, že tam padouši hromadí další poklady. Tento poklad lze odemknout pouze pomocí speciálních klíčů, které najdeš po celém Khaz Algar. Klíče a fragmenty klíčů lze nalézt po celém světě. Ulov je a ponoř se do štědrého hloubení!",
progressMale = "Už jsi našel klíč?", progressMale = "Už jsi našel klíč?",
progressFemale = "Už jsi našla klíč?", progressFemale = "Už jsi našla klíč?",
completionMale = "To byl ale úlovek! Máš chuť na trochu víc zábavy?", completionMale = "To byl ale úlovek! Máš chuť na trochu víc zábavy?",

View file

@ -5489,24 +5489,12 @@ CzechQuestsAddon.data.quest[88878] = {
CzechQuestsAddon.data.speech["It's just business pal."] = { CzechQuestsAddon.data.speech["It's just business pal."] = {
text = "Je to jen obchod, kamaráde.", text = "Je to jen obchod, kamaráde.",
} }
CzechQuestsAddon.data.speech["Where is Noggenfogger's Shipment? Don't you make me look bad in front of him."] = {
text = "Kde se nachází zásilka Noggenfogger? Nechtěj, abych před ním vypadal špatně.",
}
CzechQuestsAddon.data.speech["I had to be a... big shot..."] = { CzechQuestsAddon.data.speech["I had to be a... big shot..."] = {
text = "Musel jsem být... velký...", text = "Musel jsem být... velký...",
} }
CzechQuestsAddon.data.speech["You get the delivery to the secret project site yesterday! And whatever's left goes to Venture for munition's testing."] = {
text = "Dodávku na tajné místo projektu jste obdrželi včera! A co zbylo, jde do Venture na testování munice.",
}
CzechQuestsAddon.data.speech["This tollbooth has to be brand new."] = { CzechQuestsAddon.data.speech["This tollbooth has to be brand new."] = {
text = "Tato mýtná budka musí být úplně nová.", text = "Tato mýtná budka musí být úplně nová.",
} }
CzechQuestsAddon.data.speech["Where is Noggenfogger's shipment? Don't you make me look bad in front of him."] = {
text = "Kde je zásilka Noggenfogger? Nechtěj, abych před ním vypadal špatně.",
}
CzechQuestsAddon.data.speech["You get the delivery to the secret project site yesterday! And whatever's left goes to Venture for munitions testing."] = {
text = "Dodávku na tajné místo projektu jste obdrželi včera! A co zbylo, jde do Venture na testování munice.",
}
CzechQuestsAddon.data.speech["Yer back! What happened?"] = { CzechQuestsAddon.data.speech["Yer back! What happened?"] = {
text = "Jsi zpátky! Co se stalo?", text = "Jsi zpátky! Co se stalo?",
} }

View file

@ -51,7 +51,7 @@ function CzechQuestsAddon:AddSpeechOptions(category, layout)
category, category,
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_WIDTH", "CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_WIDTH",
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH), type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH),
"Šírka zprávy", "Šírka okna",
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH,
function() function()
return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH
@ -66,18 +66,29 @@ function CzechQuestsAddon:AddSpeechOptions(category, layout)
) )
end end
) )
local windowWidthSizeSliderOption = Settings.CreateSliderOptions(200, 800, 10) local windowWidthSizeSliderOption = Settings.CreateSliderOptions(200, 1000, 10)
windowWidthSizeSliderOption:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right); windowWidthSizeSliderOption:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right);
Settings.CreateSlider(category, windowWidthSizeSlider, windowWidthSizeSliderOption) Settings.CreateSlider(category, windowWidthSizeSlider, windowWidthSizeSliderOption)
-- Show original
local originalWhenMissingCheckbox = Settings.RegisterAddOnSetting(
category,
"CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING",
"TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING",
CzechQuestsAddon_Store.config,
type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING),
"Original pokud není preklad",
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING
)
Settings.CreateCheckbox(category, originalWhenMissingCheckbox)
local initializer= CreateSettingsButtonInitializer( local initializer= CreateSettingsButtonInitializer(
'Resetovat pozici okna', 'Resetovat pozici okna',
'RESET', 'RESET',
function() function()
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0} CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0}
CzechQuestsAddon.translationSpeechFrame:ClearAllPoints()
CzechQuestsAddon.translationSpeechFrame:SetPoint( CzechQuestsAddon.translationSpeechFrame:SetPoint(
"CENTER", UIParent, "CENTER", "TOPLEFT", UIParent, "TOPLEFT",
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x, CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x,
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y
) )

View file

@ -2,8 +2,9 @@ function CzechQuestsAddon:CreateTranslationSpeechFrame()
local scroll = {}; local scroll = {};
-- Speech Translation Frame -- Speech Translation Frame
scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "MinimalScrollFrameTemplate") scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "UIPanelScrollFrameTemplate")
scroll:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 150) scroll:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 150)
scroll:Hide()
-- Make movable -- Make movable
scroll:SetMovable(true) scroll:SetMovable(true)
@ -57,13 +58,12 @@ function CzechQuestsAddon:CreateTranslationSpeechFrame()
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y
) )
scroll:Hide()
scroll.content:SetPoint("BOTTOMLEFT", scroll, "BOTTOMLEFT", 0, 0) scroll.content:SetPoint("BOTTOMLEFT", scroll, "BOTTOMLEFT", 0, 0)
return scroll; return scroll;
end end
function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message) function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message)
local frame = {}; local frame = {};
@ -71,6 +71,9 @@ function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message)
frame = CreateFrame("Frame", nil, CzechQuestsAddon.translationSpeechFrame.content) frame = CreateFrame("Frame", nil, CzechQuestsAddon.translationSpeechFrame.content)
frame:SetSize(CzechQuestsAddon.translationSpeechFrame.content:GetWidth() - 20, 1) frame:SetSize(CzechQuestsAddon.translationSpeechFrame.content:GetWidth() - 20, 1)
-- Hide
frame:Hide()
-- Message -- Message
frame.string = frame:CreateFontString(nil, "OVERLAY") frame.string = frame:CreateFontString(nil, "OVERLAY")
frame.string:SetWidth(frame:GetWidth()) frame.string:SetWidth(frame:GetWidth())

View file

@ -67,6 +67,9 @@ local function OnEvent(self, event, addonName, ...)
if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH then if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH then
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH = 320; CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH = 320;
end end
if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING then
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING = false;
end
if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION then if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION then
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0} CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0}
end end

View file

@ -2,7 +2,7 @@
## Title: CzechQuests ## Title: CzechQuests
## Notes: Addon displays texts of quests in Czech language as tooltip ## Notes: Addon displays texts of quests in Czech language as tooltip
## Author: Roman Jaroš ## Author: Roman Jaroš
## Version: 0.2.11 ## Version: 0.2.12
## SavedVariables: CzechQuestsAddon_Store ## SavedVariables: CzechQuestsAddon_Store
## Category: Quests ## Category: Quests
## IconTexture: Interface\AddOns\CzechQuests\Assets\Icons\Logo ## IconTexture: Interface\AddOns\CzechQuests\Assets\Icons\Logo

View file

@ -2,7 +2,7 @@
## Title: CzechQuests ## Title: CzechQuests
## Notes: Addon displays texts of quests in Czech language as tooltip ## Notes: Addon displays texts of quests in Czech language as tooltip
## Author: Roman Jaroš ## Author: Roman Jaroš
## Version: 0.1.10 ## Version: 0.1.11
## SavedVariables: CzechQuestsAddon_Store ## SavedVariables: CzechQuestsAddon_Store
CzechQuests.lua CzechQuests.lua

View file

@ -62,13 +62,18 @@ make_zip() {
files_to_zip+=("$line") files_to_zip+=("$line")
done < <(find . -name "*.lua" -path "./Addon/Frames/*") done < <(find . -name "*.lua" -path "./Addon/Frames/*")
# includes frames # includes code
while IFS= read -r line; do while IFS= read -r line; do
files_to_zip+=("$line") files_to_zip+=("$line")
done < <(find . -name "*.ttf" -path "./Assets/*") done < <(find . -name "*.lua" -path "./Addon/Code/*")
# includes assets
while IFS= read -r line; do
files_to_zip+=("$line")
done < <(find . -name "*" -path "./Assets/*")
# includes other files # includes other files
files_to_zip+=("./Addon/Data/other.lua" "./Addon/Addon.lua" "./Addon/Translation.lua" "./Addon/Utils.lua" "./CzechQuests.lua") files_to_zip+=("./Addon/Data/other.lua" "./Addon/Addon.lua" "./CzechQuests.lua")
# prepare output directory # prepare output directory
for file in "${files_to_zip[@]}"; do for file in "${files_to_zip[@]}"; do

View file

@ -2,12 +2,12 @@
src_folder="." src_folder="."
wow_source_folder="retail" #wow_source_folder="retail"
wow_destiny_folder="retail" #wow_destiny_folder="retail"
#wow_destiny_folder="beta" #wow_destiny_folder="beta"
#wow_source_folder="classic_era" wow_source_folder="classic_era"
#wow_destiny_folder="classic_era" wow_destiny_folder="classic_era"
# CLASSIC ERA # CLASSIC ERA
dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests" dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests"
@ -17,3 +17,4 @@ fswatch -o "$src_folder" | while read -r change; do
rsync -au --delete "$src_folder/Addon/Data/$wow_source_folder/" "$dest_folder/Addon/Data/" rsync -au --delete "$src_folder/Addon/Data/$wow_source_folder/" "$dest_folder/Addon/Data/"
cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/" cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/"
done done